forlogic-core 1.13.1 → 1.14.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/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),a=require("react"),t=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"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),x=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("react-i18next"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),y=require("react-router-dom"),j=require("@radix-ui/react-tooltip"),N=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-progress"),P=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),_=require("@radix-ui/react-alert-dialog"),I=require("@radix-ui/react-avatar"),A=require("react-day-picker"),E=require("vaul"),M=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),z=require("@radix-ui/react-radio-group"),D=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"),B=require("@tiptap/react"),V=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("zod"),J=require("@hookform/resolvers");function Y(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var Z=Y(a),ee=Y(c),ae=Y(u),te=Y(m),se=Y(h),re=Y(x),ne=Y(f),ie=Y(j),oe=Y(N),le=Y(w),de=Y(C),ce=Y(k),ue=Y(S),me=Y(P),pe=Y(T),he=Y(_),xe=Y(I),fe=Y(M),ge=Y(R),be=Y(z),ve=Y(F),ye=Y(L),je=Y(O),Ne=Y(U),we=Y($),Ce=Y(q);function ke(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Se(...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 a={};for(const[t,s]of Object.entries(e))a[t]=Pe(s);return a}return e},Te=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"}}),_e=Z.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:Se(Te({variant:s,size:r,className:a})),ref:o,...i})});_e.displayName="Button";const Ie=a.forwardRef(({className:a,children:t,...s},r)=>e.jsx(_e,{ref:r,variant:"action",size:"sm",className:Se("h-7 px-2 text-xs",a),...s,children:t||e.jsx(d.EllipsisVertical,{size:12})}));Ie.displayName="ActionButton";const Ae=Z.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:Se("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",a),ref:r,...s}));Ae.displayName="Input";const Ee=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=Z.forwardRef(({className:a,...t},s)=>e.jsx(ee.Root,{ref:s,className:Se(Ee(),a),...t}));Me.displayName=ee.Root.displayName;const Re=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));Re.displayName="Card";const ze=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("flex flex-col space-y-1.5 p-6",a),...t}));ze.displayName="CardHeader";const De=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Se("text-2xl font-semibold leading-none tracking-tight",a),...t}));De.displayName="CardTitle";const Fe=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));Fe.displayName="CardDescription";const Le=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("p-6 pt-0",a),...t}));Le.displayName="CardContent";const Oe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("flex items-center p-6 pt-0",a),...t}));Oe.displayName="CardFooter";const Ue=Z.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(te.Root,{ref:n,decorative:s,orientation:t,className:Se("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));Ue.displayName=te.Root.displayName;const $e=ae.Root,qe=ae.Trigger,Be=ae.Portal,Ve=ae.Close,We=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{ref:s,className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t}));We.displayName=ae.Overlay.displayName;const He={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},Ge=Z.forwardRef(({className:a,children:t,size:s="md",...r},n)=>e.jsxs(Be,{children:[e.jsx(We,{}),e.jsxs(ae.Content,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-[85vw] max-h-[85vh] 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%] sm:rounded-lg",He[s],a),...r,children:[t,e.jsxs(ae.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"})]})]})]}));Ge.displayName=ae.Content.displayName;const Qe=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Se("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(Ue,{className:"mt-2"})]});Qe.displayName="DialogHeader";const Ke=({className:a,...t})=>e.jsx("div",{className:Se("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Ke.displayName="DialogBody";const Xe=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ue,{className:"mb-4"}),e.jsx("div",{className:Se("flex flex-row justify-end gap-2",a),...s,children:t})]});Xe.displayName="DialogFooter";const Je=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Se("text-lg font-semibold leading-none tracking-tight",a),...t}));Je.displayName=ae.Title.displayName;const Ye=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));Ye.displayName=ae.Description.displayName;const Ze=p.FormProvider,ea=Z.createContext({}),aa=()=>{const e=Z.useContext(ea),a=Z.useContext(ta),{getFieldState:t,formState:s}=p.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},ta=Z.createContext({}),sa=Z.forwardRef(({className:a,...t},s)=>{const r=Z.useId();return e.jsx(ta.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Se("space-y-2",a),...t})})});sa.displayName="FormItem";const ra=Z.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=aa();return e.jsx(Me,{ref:s,className:Se(r&&"text-destructive",a),htmlFor:n,...t})});ra.displayName="FormLabel";const na=Z.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=aa();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...a})});na.displayName="FormControl";const ia=Z.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=aa();return e.jsx("p",{ref:s,id:r,className:Se("text-sm text-muted-foreground",a),...t})});ia.displayName="FormDescription";const oa=Z.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:i}=aa(),o=n?String(n?.message):t;return o?e.jsx("p",{ref:r,id:i,className:Se("text-sm font-medium text-destructive",a),...s,children:o}):null});oa.displayName="FormMessage";const la=se.Root,da=se.Group,ca=se.Value,ua=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Se("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",a),...s,children:[t,e.jsx(se.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ua.displayName=se.Trigger.displayName;const ma=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Se("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));ma.displayName=se.ScrollUpButton.displayName;const pa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Se("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));pa.displayName=se.ScrollDownButton.displayName;const ha=Z.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:o,className:Se("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",a),position:s,collisionBoundary:n,...i,children:[e.jsx(ma,{}),e.jsx(se.Viewport,{className:Se("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(pa,{})]})}));ha.displayName=se.Content.displayName;const xa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Label,{ref:s,className:Se("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));xa.displayName=se.Label.displayName;const fa=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Item,{ref:r,className:Se("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...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:t})]}));fa.displayName=se.Item.displayName;const ga=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Separator,{ref:s,className:Se("-mx-1 my-1 h-px bg-muted",a),...t}));ga.displayName=se.Separator.displayName;const ba=Z.forwardRef(({className:a,...t},s)=>e.jsx(re.Root,{ref:s,className:Se("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",a),...t,children:e.jsx(re.Indicator,{className:Se("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));ba.displayName=re.Root.displayName;const va=Z.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:Se("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",a),ref:s,...t}));va.displayName="Textarea";const ya=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"}}),ja=Z.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:Se(ya({variant:t}),a),...s}));ja.displayName="Badge";const Na={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function wa({size:a="md",className:t}){return e.jsx(d.Loader2,{className:Se("animate-spin text-muted-foreground",Na[a],t)})}const Ca=({...a})=>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"}},...a}),ka=ne.Root,Sa=ne.Trigger,Pa=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(ne.Portal,{container:r,children:e.jsx(ne.Content,{ref:i,align:t,sideOffset:s,className:Se("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",a),...n})}));Pa.displayName=ne.Content.displayName;const Ta=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ta.displayName="Command";const _a=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Se("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",a),...t})}));_a.displayName="CommandInput";const Ia=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Ia.displayName="CommandList";const Aa=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("py-6 text-center text-sm text-muted-foreground",a),...t}));Aa.displayName="CommandEmpty";const Ea=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("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",a),...t}));Ea.displayName="CommandGroup";const Ma=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("-mx-1 h-px bg-border",a),...t}));Ma.displayName="CommandSeparator";const Ra=Z.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Se("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",a),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Ra.displayName="CommandItem";const za=({className:a,...t})=>e.jsx("span",{className:Se("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function Da({className:a,...t}){return e.jsx("div",{className:Se("animate-pulse rounded-md bg-muted",a),...t})}za.displayName="CommandShortcut";const Fa=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function La({multiple:t,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:x,className:f,sortOptions:b,maxDisplayedBadges:v,popoverContainer:y,onOpen:j,onClose:N}){const{t:w}=g.useTranslation(),[C,k]=a.useState(!1),[S,P]=a.useState(""),T=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),_=a.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),I=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return b?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,b]),A=a.useMemo(()=>{if(!S)return I;const e=Fa(S);return I.filter(a=>Fa(a.label).includes(e))},[I,S]),E=a.useMemo(()=>I.filter(e=>T.includes(e.value)),[I,T]),M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?T.filter(a=>a!==e):"")},R=v?E.slice(0,v):E,z=v&&E.length>v?E.length-v:0;return e.jsxs("div",{className:Se("space-y-2",f),children:[c&&e.jsxs(Me,{children:[c,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(ka,{open:C,onOpenChange:e=>{k(e),e?j?.():(P(""),N?.())},modal:!1,children:[e.jsx(Sa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":C,disabled:h,className:Se("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]}):t?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(a=>e.jsxs(ja,{variant:"secondary",className:"gap-1 pr-1",children:[a.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(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(a.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),z>0&&e.jsxs(ja,{variant:"outline",className:"gap-1",children:["+",z]})]}):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(Pa,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:_,collisionBoundary:_,children:e.jsxs(Ta,{children:[e.jsx(_a,{placeholder:p,value:S,onChange:e=>P(e.target.value)}),e.jsx(Ia,{children:0===s.length?e.jsx(Aa,{children:m}):0===A.length?e.jsx(Aa,{children:w("no_results")}):e.jsx(Ea,{children:A.map(a=>e.jsxs(Ra,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];n(a)}else n(e),k(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Se("mr-2 h-4 w-4",T.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function Oa({multiple:a=!1,options:t,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:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:b=!1,error:v,className:y,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k}){const{t:S}=g.useTranslation(),P=s||t||[],T=i||n,_=c||S("select_placeholder"),I=p||S("no_results"),A=h||S("search_placeholder");if(b)return e.jsxs("div",{className:Se("space-y-2",y),children:[u&&e.jsxs(Me,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Da,{className:"h-10 w-full"})]});const E="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return E?e.jsxs("div",{className:Se("space-y-2",y),children:[u&&e.jsxs(Me,{children:[u,f&&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(La,{multiple:a,options:P,value:r||(a?[]:""),onChange:T,getOptionValue:o,getOptionLabel:l,placeholder:_,label:u,icon:m,emptyMessage:I,searchPlaceholder:A,disabled:x,required:f,className:y,sortOptions:j,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k})}var Ua=Object.defineProperty;class $a{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}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),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),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:t,errors:s}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.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";t.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:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?Ua(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})($a,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const qa="qualiex_access_token",Ba="qualiex_id_token",Va="supabase_token",Wa="oauth_state",Ha="oauth_nonce",Ga="selected_alias",Qa="manual_logout",Ka={setAccessToken:e=>localStorage.setItem(qa,e),getAccessToken:()=>localStorage.getItem(qa),setIdToken:e=>localStorage.setItem(Ba,e),getIdToken:()=>localStorage.getItem(Ba),getSupabaseToken:()=>localStorage.getItem(Va),setOAuthState:e=>sessionStorage.setItem(Wa,e),getOAuthState:()=>sessionStorage.getItem(Wa),clearOAuthState:()=>sessionStorage.removeItem(Wa),setOAuthNonce:e=>sessionStorage.setItem(Ha,e),getOAuthNonce:()=>sessionStorage.getItem(Ha),clearOAuthNonce:()=>sessionStorage.removeItem(Ha),setSelectedAlias:e=>localStorage.setItem(Ga,e),getSelectedAlias:()=>localStorage.getItem(Ga),clearSelectedAlias:()=>localStorage.removeItem(Ga),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Ka.getAccessToken()||!Ka.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Va,e),Ka._clearValidationCache()},areAllTokensValid:()=>{const e=Ka.getAccessToken(),a=Ka.getIdToken();if(!e||!a)return!1;try{const t=$a.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Ka.getAccessToken(),t=Ka.getIdToken(),s=Ka.getSupabaseToken();return a&&Ka.isTokenExpired(a)&&(localStorage.removeItem(qa),e=!0),t&&Ka.isTokenExpired(t)&&(localStorage.removeItem(Ba),e=!0),s&&Ka.isTokenExpired(s)&&(localStorage.removeItem(Va),e=!0),e},clearAll:()=>{localStorage.removeItem(qa),localStorage.removeItem(Ba),localStorage.removeItem(Va),localStorage.removeItem(Ga),localStorage.removeItem(Qa),sessionStorage.removeItem(Wa),sessionStorage.removeItem(Ha)},setManualLogout:()=>localStorage.setItem(Qa,"true"),isManualLogout:()=>"true"===localStorage.getItem(Qa),clearManualLogout:()=>localStorage.removeItem(Qa),isTokenExpired:e=>{try{return $a.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Ka._validationCache.isValid=!1,Ka._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Ka.getSupabaseToken();if(!e)return!1;if(Ka.isTokenExpired(e))return Ka._clearValidationCache(),Ka._handleExpiredToken(),!1;const a=Date.now();return a-Ka._validationCache.timestamp<Ka._validationCache.cacheValidityMs?Ka._validationCache.isValid:(Ka._validationCache.isValid=!0,Ka._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>Ka.isSupabaseTokenValid()?Ka.getSupabaseToken():null,_handleExpiredToken:()=>{Ka.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Ka.isSupabaseTokenValid())return null;const e=Ka.getSupabaseToken();if(!e)return null;try{const a=$a.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return Ka._handleExpiredToken(),null}},getCompanyId:e=>{const a=Ka.getAccessToken();if(a)try{const t=$a.parseJwtPayload(a);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 a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=Ka.extractTokenData();if(t?.companyId)return t.companyId;const s=Ka.getIdToken();if(s)try{const a=$a.parseJwtPayload(s);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 a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Ka.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Ka.getIdToken();if(!e)return[];try{const a=$a.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var Xa=Object.defineProperty,Ja=(e,a,t)=>((e,a,t)=>a in e?Xa(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ya=new class{constructor(){Ja(this,"errors",[]),Ja(this,"toastCount",0),Ja(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);l.toast.error(e,{description:t})}}getErrorTitle(e){const a=e.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?"Sessão Expirada":a.includes("token")||a.includes("autenticação")?"Erro de Autenticação":a.includes("api")||a.includes("network")?"Erro de Conexão":"Erro"}success(e,a){l.toast.success(e,{description:a})}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 Za=Object.defineProperty,et=(e,a,t)=>((e,a,t)=>a in e?Za(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const at=(void 0).VITE_SUPABASE_URL,tt=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,st=class e{constructor(){et(this,"client"),et(this,"currentToken",null),et(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:tt};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return b.createClient(at,tt,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("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,a)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Ka.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return Ya.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};et(st,"instance");let rt=st;function nt(){return rt.getInstance().getClient()}class it{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Ka.getSupabaseToken();if(e&&Ka.isSupabaseTokenValid())return e}const r=nt(),{data:n,error:i}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token&&n.access_token?(Ka.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}var ot=Object.defineProperty,lt=(e,a,t)=>((e,a,t)=>a in e?ot(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class dt{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Ka.getAccessToken(),a=Ka.getSelectedAlias();if(!e||!a)return null;const t=await it.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Ka.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}lt(dt,"isRegenerating",!1),lt(dt,"onLogoutCallback",null);class ct{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Ka.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var ut=Object.defineProperty;class mt{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await dt.attemptRegeneration()?(this.isRetrying=!1,!0):(ct.handleError(e),this.isRetrying=!1,!1)}catch(s){return ct.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Ka.getAccessToken();return e?Ka.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,a,t)=>{((e,a,t)=>{a in e?ut(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(mt,"isRetrying",!1);var pt=Object.defineProperty,ht=(e,a,t)=>((e,a,t)=>a in e?pt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const xt=new class{constructor(){ht(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=mt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ka.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Ya.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=t}if(!Array.isArray(s))return Ya.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){if(await mt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Ya.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=t}return Array.isArray(s)?s.map(this.mapToQualiexUser):(Ya.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return Ya.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return Ya.handleError(r,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return Ya.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),s=new Map;return t.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const a=Ka.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},ft={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},gt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},bt={debounceDelay:500},vt=()=>{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},yt={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},jt=()=>yt,Nt={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},wt={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 Ct(e,a){const t=jt(),s=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function kt(e,a){const t=jt(),s=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function St(e,a){const t=jt(),s=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Pt(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||Ct(e.idField),emailField:e.emailField||kt(e.idField),usernameField:e.usernameField||St(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Ct(e),emailField:kt(e),usernameField:St(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const Tt=new Map;class _t{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=Tt.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await xt.fetchUsers(e,a);return Tt.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);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,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Ka.areAllTokensValid())return e;const t=Ka.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=Pt(a.userIdFields,a.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(t){return Ya.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,a){return this.enrichWithUserData(e,{entityName:a.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const It=["responsible_name"],At=e=>It.includes(e);function Et(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"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(!Ka.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return nt().schema(o).from(r)},u=(e,a,t,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const o=a.includes(".");return o||At(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:o}},m=async(e,a,t,r,n)=>{const i=Pt(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(At(a)||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 _t.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>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 _t.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})};return{async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,i,o),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let b=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=Pt(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Pe(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).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,a){const t={...Pe(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).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 a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}}}const Mt=()=>{Ka.clearManualLogout()},Rt=e=>e?.placeId||null,zt=e=>e?.placeName||null,Dt=e=>({placeId:Rt(e),placeName:zt(e)}),Ft=class{static async initialize(){try{if(!Ka.hasAllTokens()||!Ka.areAllTokensValid())return Ka.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 a=Ka.getAccessToken(),t=Ka.getIdToken();Mt();const s=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Ka.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=Ka.getSelectedAlias(),a=e&&r.some(a=>a.alias===e);l=a?e:n||r[0]?.alias||null}!Ka.isSupabaseTokenValid()&&l&&await dt.attemptRegeneration();let d=null;if(l){const e=Ka.getCompanyId(l),a=r.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,u=null;if(s?.id&&l){const a=Ka.getCompanyId(l);if(a)try{const e=(await xt.fetchActiveUsersMap(l,a)).get(s.id);if(e){const a=Dt(e);c=a.placeId,u=a.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=nt(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Ka.generateOAuthState();Ka.setOAuthState(e);const a=Ka.generateOAuthNonce();Ka.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(ft.oauth.authUrl);s.searchParams.set("client_id",ft.oauth.clientId),s.searchParams.set("response_type",ft.oauth.responseType),s.searchParams.set("scope",ft.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),vt(),window.location.href=s.toString()}static async processCallback(){try{if(Ka.hasAllTokens()){if(!Ka.getValidSupabaseToken()){Ka.getAccessToken();await dt.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(!s||!r)throw new Error("Tokens não encontrados na URL de callback");Ka.setAccessToken(s),Ka.setIdToken(r),Mt();const i=this.extractAliasFromAccessToken(s);if(i)Ka.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(r);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Ka.setSelectedAlias(e[0].alias)}if(!await dt.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Ka.clearOAuthState(),Ka.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Ka.setManualLogout(),Ka.clearAll(),window.location.href="/login"}static decodeToken(e){return $a.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};dt.setLogoutCallback(()=>{Ft.logout()});let Lt=Ft;const Ot=a.createContext(void 0),Ut=({children:t})=>{const[s,r]=a.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[i,o]=a.useState(!1),[l,d]=a.useState(0),c=a.useCallback(e=>{r(a=>({...a,...e}))},[]),u=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),m=a.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=a.useCallback(async e=>{try{u(!0);const t=Ka.getAccessToken();if(!t)return;const r=await it.generateToken(t,e.alias,void 0,!0);if(!r)return;Ka.setSupabaseToken(r),Ka.setSelectedAlias(e.alias);const i=Ka.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Ka.getCompanyId(e.alias),d={id:l||e.id,name:e.name,alias:o};let m=null,p=null;if(s.user?.id&&o&&l)try{const e=(await xt.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const a=Dt(e);m=a.placeId,p=a.placeName}}catch(a){}c({alias:o,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{u(!1)}},[c,n,u,s.user]),h=a.useCallback(async()=>await Lt.processCallback(),[]),x=a.useCallback(async()=>{Lt.logout(),m(),n&&await n.clear()},[m,n]),f=a.useCallback(e=>{o(e)},[]),g=a.useCallback(()=>{d(e=>e+1)},[]),b=a.useCallback(()=>{d(e=>e+1)},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Ka.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Lt.initialize();if(!e)return;a&&a.isAuthenticated?c({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&u(!1)}catch(a){e&&(ct.handleError(a),u(!1))}})(),()=>{e=!1}},[c,u,x]);const y=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,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,x,h,p,i,f,g,b]);return e.jsx(Ot.Provider,{value:y,children:t})},$t=()=>{const e=a.useContext(Ot);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function qt({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=y.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=$t(),h=a.useCallback(a=>{const t=`${e}_${a}`,s=o.get(t);return s||(o.get(a)||"")},[o,e]),x=h("search"),f=h("sortField")||gt.sorting.defaultField,g=h("sortDirection")||gt.sorting.defaultDirection,b=parseInt(h("page")||"1"),j=parseInt(h("limit")||String(gt.pagination.defaultPageSize)),N=x,w=a.useMemo(()=>({search:N,sortField:f,sortDirection:g,page:b,limit:j,...n}),[N,f,g,b,j,n]),C=a.useCallback(()=>t.getAll(w),[t,w]),k=v.useQuery({queryKey:[e,u,m,w],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:t.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(wt.success.created(s)),i?.()},onError:e=>{l.toast.error(`${wt.error.create(s)}: ${e.message}`)}}),P=v.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(wt.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${wt.error.update(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:t.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(wt.success.deleted(s))},onError:e=>{l.toast.error(`${wt.error.delete(s)}: ${e.message}`)}}),_=a.useCallback(a=>{const t={...Object.fromEntries(o)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[o,d,e]),I=a.useCallback(e=>{_({search:e,page:1})},[_]),A=a.useCallback(e=>{_({sortField:e,sortDirection:f===e&&"asc"===g?"desc":"asc",page:1})},[f,g,_]),E=a.useCallback(e=>{_({page:e})},[_]),M=a.useCallback(e=>{_({limit:e,page:1})},[_]),R=a.useCallback(()=>{const a=Object.fromEntries(o),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,o,e]),[z,D]=a.useState([]),F=a.useCallback(e=>{D(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=a.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];D(a=>a.length===e.length?[]:e)},[k?.data?.data]),O=a.useCallback(()=>{D([])},[]),U=a.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&z.length===e.length},[z,k?.data?.data]),$=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${t.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),q=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):S.mutate({...t,alias:u})},[u,S,P]);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||gt.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:T?.isPending??!1,error:k?.error||null,searchTerm:x,sortField:f,sortDirection:g,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:S.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:T.mutate,save:q,handleSearch:I,handleSort:A,handlePageChange:E,handleItemsPerPageChange:M,clearFilters:R,refetch:k.refetch,selectedIds:z,selectItem:F,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}const Bt=Z.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:Se("w-full caption-bottom text-sm table-fixed",a),...t}));Bt.displayName="Table";const Vt=Z.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:Se("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Vt.displayName="TableHeader";const Wt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:Se("[&_tr:last-child]:border-0",a),...t}));Wt.displayName="TableBody";const Ht=Z.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:Se("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Ht.displayName="TableFooter";const Gt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:Se("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Gt.displayName="TableRow";const Qt=Z.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:Se("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",a),...t}));Qt.displayName="TableHead";const Kt=Z.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:Se("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Kt.displayName="TableCell";const Xt=Z.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:Se("mt-4 text-sm text-muted-foreground",a),...t}));function Jt({rows:a=5,columns:t=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:t}).map((a,t)=>e.jsx(Da,{className:"h-4 w-24"},t))})}),e.jsx("div",{children:Array.from({length:a}).map((a,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:t}).map((a,t)=>e.jsx(Da,{className:"h-4 w-20"},t))})},s))})]})})}function Yt({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(Re,{children:[e.jsxs(ze,{children:[e.jsx(Da,{className:"h-4 w-3/4"}),e.jsx(Da,{className:"h-3 w-1/2"})]}),e.jsx(Le,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(Da,{className:"h-3 w-full"}),e.jsx(Da,{className:"h-3 w-2/3"})]})})]},t))})}Xt.displayName="TableCaption";const Zt={default:d.FileX,search:d.Search,error:d.AlertCircle};function es({icon:a,title:t,description:s,action:r,className:n,variant:i="default"}){const o=a?()=>a:Zt[i];return e.jsxs("div",{className:Se("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:t}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(_e,{onClick:r.onClick,variant:"outline",children:r.label})]})}const as=ie.Provider,ts=ie.Root,ss=ie.Trigger,rs=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:t,className:Se("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",a),...s}));function ns({children:a,className:t}){const s=Z.useRef(null),[r,n]=Z.useState(!1);Z.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[a]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(as,{delayDuration:300,children:e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:i}),e.jsx(rs,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):i}rs.displayName=ie.Content.displayName;const is=Z.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const i="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:Se("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:Se("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});is.displayName="TableResizeHandle";const os=oe.Root,ls=oe.Trigger,ds=oe.Group,cs=oe.Portal,us=oe.Sub,ms=oe.RadioGroup,ps=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Se("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ps.displayName=oe.SubTrigger.displayName;const hs=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.SubContent,{ref:s,className:Se("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",a),...t}));hs.displayName=oe.SubContent.displayName;const xs=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:t,className:Se("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",a),...s})}));xs.displayName=oe.Content.displayName;const fs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Item,{ref:r,className:Se("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",t&&"pl-8",a),...s}));fs.displayName=oe.Item.displayName;const gs=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Se("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",a),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(oe.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));gs.displayName=oe.CheckboxItem.displayName;const bs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Se("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));bs.displayName=oe.RadioItem.displayName;const vs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Label,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));vs.displayName=oe.Label.displayName;const ys=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.Separator,{ref:s,className:Se("-mx-1 my-1 h-px bg-muted",a),...t}));ys.displayName=oe.Separator.displayName;const js=({className:a,...t})=>e.jsx("span",{className:Se("ml-auto text-xs tracking-widest opacity-60",a),...t});js.displayName="DropdownMenuShortcut";const Ns=le.Root,ws=le.Trigger,Cs=le.Group,ks=le.Portal,Ss=le.Sub,Ps=le.RadioGroup,Ts=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Se("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ts.displayName=le.SubTrigger.displayName;const _s=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.SubContent,{ref:s,className:Se("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",a),...t}));_s.displayName=le.SubContent.displayName;const Is=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Se("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",a),...t})}));Is.displayName=le.Content.displayName;const As=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Item,{ref:r,className:Se("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",t&&"pl-8",a),...s}));As.displayName=le.Item.displayName;const Es=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Se("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",a),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"})})}),t]}));Es.displayName=le.CheckboxItem.displayName;const Ms=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Se("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",a),...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"})})}),t]}));Ms.displayName=le.RadioItem.displayName;const Rs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Label,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));Rs.displayName=le.Label.displayName;const zs=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Separator,{ref:s,className:Se("-mx-1 my-1 h-px bg-border",a),...t}));zs.displayName=le.Separator.displayName;const Ds=({className:a,...t})=>e.jsx("span",{className:Se("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Ds.displayName="ContextMenuShortcut";const Fs=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=g.useTranslation(),c=[];if(a){const e={icon:d.Edit,label:l("edit"),onClick:a};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&&t){const e={icon:d.Trash2,label:l("delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===o?fs:As;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(u,{onClick:a.onClick,className:Se("whitespace-normal cursor-pointer",a.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(a.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.label]},t))})},Ls=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(os,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(_e,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(xs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Fs,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:i,renderAs:"dropdown"})})]}),Os=150;function Us({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,i]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Os,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Os,e),{})}),[o,l]=a.useState(!1),[d,c]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??Os)},[r,n]);a.useEffect(()=>{if(!o||!d)return;const a=e.find(e=>e.key===d),r=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));i(e=>{const a={...e,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(null),t&&i(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[o,d,e,t,s]),a.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Os,e),{});i(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:p,resetWidths:h}}function $s({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=a.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]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{o&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[o,l,t]);a.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return i?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=a.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}}const qs=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(ba,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Bs=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,enableColumnResize:b=!0,resizeStorageKey:v})=>{const{t:y}=g.useTranslation(),{setSearchVisible:j}=$t(),[N,w]=a.useState(!1);a.useEffect(()=>(j(!0),()=>j(!1)),[j]),a.useEffect(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:P}=Us({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:v?`${v}-columns`:void 0,enabled:b}),{isDragging:T,activeRow:_,handleMouseDown:I,getRowHeight:A}=$s({rowIds:t.entities.map(e=>e.id),storageKey:v?`${v}-rows`:void 0,enabled:!1}),E=a.useMemo(()=>(()=>{if(b)return s.map(e=>{const a=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=s.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,b,C]),M=!f&&(m||x.length>0);return N?t.isLoading?e.jsx(Yt,{count:3}):0===t.entities.length?e.jsx(es,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&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&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(Ns,{children:[e.jsx(ws,{asChild:!0,children:e.jsx(Re,{className:Se("overflow-hidden cursor-pointer hover:bg-muted/50",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:e.jsx(Le,{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(qs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(t=>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:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Ls,{onEdit:r?()=>{r(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})})})}),e.jsx(Is,{className:"w-[160px]",children:e.jsx(Fs,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&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&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),t.isLoading?e.jsx(Jt,{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(Bt,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Vt,{children:e.jsxs(Gt,{children:[u&&e.jsx(Qt,{className:"w-[50px]",children:e.jsx(qs,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),s.map(a=>{const s=b&&!1!==a.resizable,r=S===String(a.key);return e.jsxs(Qt,{className:Se(a.className,a.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(n=String(a.key),t.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(is,{direction:"horizontal",onMouseDown:e=>P(String(a.key),e),isDragging:r})]},String(a.key));var n}),e.jsx(Qt,{className:"w-[50px] text-center",children:y("actions")})]})}),e.jsx(Wt,{children:0===t.entities.length?e.jsx(Gt,{children:e.jsx(Kt,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(es,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):t.entities.map(a=>{const n=A(a.id);return a.id,e.jsxs(Ns,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(Gt,{className:Se("cursor-pointer hover:bg-muted/50 relative",u&&t.selectedIds.includes(a.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Kt,{onClick:e=>e.stopPropagation(),children:e.jsx(qs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),s.map(t=>e.jsx(Kt,{className:t.className,children:e.jsx(ns,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),e.jsx(Kt,{className:"text-center",children:l?l(a):e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})}),e.jsx(Is,{className:"w-[160px]",children:e.jsx(Fs,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})]})})})]})};function Vs(e,t,s,r){const[n,i]=a.useState({}),[o,l]=a.useState({}),d=a.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,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.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(a,t);if(e)return e}catch(s){}}};a.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},a=e(d),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);c(e)&&(a=e.toISOString().split("T")[0])}else c(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),t&&Object.keys(t).forEach(e=>{a.find(a=>a.name===e)||void 0===t[e]||(n[e]=t[e])}),i(n),l({}),s&&s(n)},[d,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:o,updateField:(e,a)=>{i(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),o[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Ws=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Hs=({value:a="#3b82f6",onChange:t,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Me,{children:s}),e.jsxs(ka,{children:[e.jsx(Sa,{asChild:!0,children:e.jsxs(_e,{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:a}}),a]})}),e.jsx(Pa,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Me,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Ae,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Me,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Ws.map(a=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>t?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),Gs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.Root,{ref:r,className:Se("relative overflow-hidden",a),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(Qs,{}),e.jsx(de.Corner,{})]}));Gs.displayName=de.Root.displayName;const Qs=Z.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:t,className:Se("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Qs.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},Xs=({value:t="Star",onChange:s,label:r})=>{const{t:n}=g.useTranslation(),[i,o]=a.useState(""),l=Object.entries(Ks).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Ks[t]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Me,{children:r}),e.jsxs(ka,{children:[e.jsx(Sa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(Pa,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Me,{htmlFor:"icon-search",children:n("search")}),e.jsx(Ae,{id:"icon-search",placeholder:n("search"),value:i,onChange:e=>o(e.target.value)})]}),e.jsx(Gs,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:l.map(([a,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(a),title:a,children:e.jsx(r,{className:"h-4 w-4"})},a))})})]})})]})]})},Js=Z.forwardRef(({className:a,...t},s)=>e.jsx(ce.Root,{className:Se("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",a),...t,ref:s,children:e.jsx(ce.Thumb,{className:Se("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 Ys=(e={})=>{const{user:a,alias:t}=$t(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",t],queryFn:()=>xt.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},Zs=({value:t,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:x,sortOptions:f=!0,popoverContainer:b,onOpen:v,onClose:y})=>{const{t:j}=g.useTranslation(),{data:N=[],isLoading:w,error:C}=Ys({enabled:m}),k=a.useMemo(()=>x?N.filter(x):N,[N,x]),S=a.useCallback(e=>{if("custom"===p&&h)return h(e);const a=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[p,h]);return e.jsx(Oa,{multiple:r,value:t??(r?[]:""),onChange:s,options:k,isLoading:w,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||j("search_placeholder"),searchPlaceholder:j("search_placeholder"),emptyMessage:j("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:f,popoverContainer:b,onOpen:v,onClose:y})};function er({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(s?.[0]?.id||""),h=a.useRef(null),[x,f]=a.useState(null),b=a.useCallback(e=>{h.current=e,f(e)},[]),v=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:y,errors:j,updateField:N,handleSubmit:w}=Vs(v,r,void 0,o),C=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(y):e.disabled||!1})):[],[s,y]),k=a.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const a=C.find(e=>!e.disabled);return a?.id||m},[C,m]);a.useEffect(()=>{k!==m&&p(k)},[k,m]);const S=C.find(e=>e.id===k),P=a=>{const t=(a.computedValue,y[a.name]),s=void 0!==t?t:"",r=j[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",i=t?Se("space-y-2 w-full",a.wrapperClassName):Se("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:i,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>P(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Zs,{value:s||"",onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(va,{id:a.name,value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(la,{value:String(s),onValueChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(ua,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ca,{placeholder:a.placeholder})}),e.jsx(ha,{children:a.options?.map(a=>e.jsx(fa,{value:a.value,children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Oa,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"date":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:"date",value:String(s),onChange:e=>N(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Se("w-full",r?"border-destructive":"",a.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":return e.jsxs("div",{children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>N(a.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Hs,{value:s||a.defaultValue||"#3b82f6",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Xs,{value:s||a.defaultValue||"Star",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"custom":if(!a.component)return null;const o=a.component,l="function"==typeof a.componentProps?a.componentProps(y):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:x,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"number":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);N(a.name,s)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e.jsx(ba,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),e.jsxs(Me,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},a.name);default:return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:"text",value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},T=a.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 a=S.component;return e.jsx(a,{formData:y,updateField:N,errors:j,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(P)})},[S,y,N,j,c,P]),_=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(a=>e.jsx(_e,{variant:k===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=C.find(a=>a.id===e);a&&!a.disabled&&p(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-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:w(n),className:"space-y-3 md:space-y-4",children:[T(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(_e,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(_e,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx($e,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Ge,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Qe,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(Je,{children:t}),e.jsx(Ye,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),_]})})}function ar({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(a-1)*r+1,c=Math.min(a*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(la,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(ua,{className:"h-8 w-[70px]",children:e.jsx(ca,{})}),e.jsxs(ha,{children:[e.jsx(fa,{value:"10",children:"10"}),e.jsx(fa,{value:"25",children:"25"}),e.jsx(fa,{value:"50",children:"50"}),e.jsx(fa,{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(_e,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,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:a}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function tr({manager:a}){return e.jsx(ar,{currentPage:a.pagination.currentPage,totalPages:a.pagination.totalPages,totalItems:a.pagination.totalItems,itemsPerPage:a.pagination.itemsPerPage,onPageChange:a.handlePageChange,onItemsPerPageChange:a.handleItemsPerPageChange,variant:"full"})}const sr=({selectedCount:a,onClearSelection:t,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=g.useTranslation();return 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:a})}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,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((a,t)=>{const s=a.icon;return e.jsxs(_e,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:n,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),a.label]},t)}),s&&e.jsxs(_e,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})},rr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},nr={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},ir={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function or({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Se("flex","column"===t?"flex-col":"flex-row",rr[s],nr[r],ir[n],i&&"flex-wrap",o),children:a})}function lr({manager:a,filters:t,inline:s=!1}){const{t:r}=g.useTranslation(),{isSearchVisible:n}=$t(),i=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.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(Ae,{placeholder:r("search"),value:a.searchTerm,onChange:e=>a.handleSearch(e.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((a,t)=>e.jsxs("select",{value:a.value||"",onChange:e=>a.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:[a.placeholder&&e.jsx("option",{value:"",children:a.placeholder}),a.options.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...a.props})},`custom-${t}`)}),i&&e.jsxs(_e,{variant:"outline",onClick:a.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(or,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(or,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function dr({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){t&&t.queryKey;const{t:l}=g.useTranslation(),{setSearchVisible:c}=$t(),[u,m]=y.useSearchParams(),[p,h]=a.useState(!1),[x,f]=a.useState(null),[b,v]=a.useState({isOpen:!1,entityId:null,entityName:""}),[j,N]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(o&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=o.column,t[a]=o.direction,m(t)}}},[]);const w=()=>{v({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&t.selectedIds.length>0&&e.jsx(sr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:t.selectedIds.length})},customActions:s.bulkActions,isLoading:t.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:[e.jsxs(_e,{onClick:()=>{s.onNew?s.onNew():(f(null),h(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((a,t)=>e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e.jsx(a.icon,{size:16,className:"mr-2"}),a.label]},t))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(lr,{manager:t,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(t.entities,t)}):e.jsx(Bs,{manager:t,columns:s.columns,onEdit:e=>{s.onEdit?s.onEdit(e):(f(e),h(!0))},onDelete:e=>{v({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(tr,{manager:t})}),!s.useCustomRouting&&e.jsx(er,{open:p,title:x?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:x||void 0,onSubmit:e=>{n(e),h(!1),f(null)},onCancel:()=>{h(!1),f(null)},isLoading:t.isLoading,submitButtonText:l(x?"update":"create")}),e.jsx($e,{open:b.isOpen,onOpenChange:w,children:e.jsxs(Ge,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Je,{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:b.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Xe,{children:[e.jsx(_e,{variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{b.entityId&&(t.deleteEntity(b.entityId),v({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx($e,{open:j.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Ge,{size:"sm",children:[e.jsx(Qe,{showSeparator:!0,children:e.jsx(Je,{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:j.count})," ",1===j.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Xe,{children:[e.jsx(_e,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),N({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function cr(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function ur(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const mr=Z.forwardRef(({className:a,value:t,...s},r)=>e.jsx(ue.Root,{ref:r,className:Se("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(ue.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function pr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Se("flex items-center justify-between mb-6",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:Se("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",t.isActive&&"border-primary bg-primary text-primary-foreground",t.isCompleted&&"border-primary bg-primary text-primary-foreground",!t.isActive&&!t.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!t.isDisabled&&"cursor-pointer hover:border-primary/50",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:t.isCompleted?e.jsx(d.Check,{className:"w-5 h-5"}):r+1}),r<a.length-1&&e.jsx("div",{className:Se("flex-1 h-0.5 mx-2 transition-colors",t.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},t.id))})}function hr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Se("flex items-center gap-2 mb-6 overflow-x-auto",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsxs("div",{className:Se("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",t.isActive&&"bg-primary text-primary-foreground font-medium",t.isCompleted&&"bg-primary/10 text-primary",!t.isActive&&!t.isCompleted&&"bg-muted text-muted-foreground",s&&!t.isDisabled&&"cursor-pointer hover:bg-primary/20",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:r+1}),e.jsx("span",{className:"text-sm",children:t.label}),t.isCompleted&&e.jsx(d.Check,{className:"w-4 h-4 ml-1"})]}),r<a.length-1&&e.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},t.id))})}function xr({steps:a,currentStepIndex:t,className:s}){const r=a[t],n=(t+1)/a.length*100;return e.jsxs("div",{className:Se("mb-6 space-y-2",s),children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Etapa ",t+1," de ",a.length]}),e.jsx("span",{className:"font-medium",children:r?.label})]}),e.jsx(mr,{value:n,className:"h-2"})]})}function fr({isFirstStep:a,isLastStep:t,canGoNext:s,canGoPrevious:r,isLoading:n,onPrevious:i,onNext:o,onSubmit:l,previousButtonText:d,nextButtonText:c,submitButtonText:u}){const{t:m}=g.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:r&&!a&&e.jsx(_e,{type:"button",variant:"outline",onClick:i,disabled:n,children:d||m("previous")})}),e.jsxs("div",{className:"flex gap-2",children:[s&&!t&&e.jsx(_e,{type:"button",onClick:o,disabled:n,children:c||m("next")}),t&&e.jsx(_e,{type:"button",onClick:l,disabled:n,children:n?m("saving"):u||m("save")})]})]})}mr.displayName=ue.Root.displayName;const gr=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"}}),br={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},vr=Z.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},i)=>{const o=br[t||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Se(gr({variant:t}),a),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});vr.displayName="Alert";const yr=Z.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:Se("mb-1 font-medium leading-none tracking-tight",a),...t}));yr.displayName="AlertTitle";const jr=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("text-sm [&_p]:leading-relaxed",a),...t}));jr.displayName="AlertDescription";const Nr=a.createContext(void 0);function wr({children:t,actions:s}){const[r,n]=a.useState({}),[i,o]=a.useState(s);return a.useEffect(()=>{o(s)},[s]),e.jsx(Nr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:t})}function Cr(){const e=a.useContext(Nr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const kr=(void 0).VITE_SUPABASE_URL,Sr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Pr=null;var Tr=Object.defineProperty,_r=(e,a,t)=>((e,a,t)=>a in e?Tr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ir=new class{constructor(){_r(this,"cache",{}),_r(this,"cacheTimestamps",new Map),_r(this,"CACHE_TTL",3e5),_r(this,"loadingPromises",new Map)}isCacheValid(e){const a=this.cacheTimestamps.get(e);return!!a&&Date.now()-a<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const a=this.loadingPromises.get(e);if(a)return a;const t=this.fetchTranslations(e);this.loadingPromises.set(e,t);try{return await t}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const a=(!Pr&&kr&&Sr&&(Pr=b.createClient(kr,Sr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Pr),{data:t,error:s}=await a.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 t?.forEach(a=>{let t;t="pt-BR"===e?a.pt:"en-US"===e?a.en||a.pt:"es-ES"===e&&a.es||a.pt,t&&(r[a.key]=t)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(a){return{}}}async upsertTranslation(e,a,t,s){const r=nt(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=nt(),{error:t}=await a.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(t)throw t;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Ar=Object.defineProperty,Er=(e,a,t)=>((e,a,t)=>a in e?Ar(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Mr="true"===(void 0).VITE_I18N_DEBUG_MODE;o.use(new class{constructor(e=!1){Er(this,"type","backend"),Er(this,"isDebugMode"),Er(this,"cache",new Map),Er(this,"loadingPromises",new Map),this.isDebugMode=e}read(e,a,t){if(this.cache.has(e))return void t(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{t(null,this.cache.get(e)||{})});const s=Ir.loadTranslations(e).then(a=>{if(this.isDebugMode){const t={};Object.keys(a).forEach(e=>{t[e]=`[${e} ✅]`}),this.cache.set(e,t)}else this.cache.set(e,a)}).catch(a=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,s),s.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,s){}}(Mr)).use(g.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Mr?`[${e} ❌]`:`[⚠️ ${e}]`});const Rr=new class{async getUserPreferences(e,a){if(!Ka.areAllTokensValid())return null;const t=nt();try{const{data:s,error:r}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(r)return"PGRST116"===r.code?this.createDefaultPreferences(e,a):("42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied"),null);if(!s)return this.createDefaultPreferences(e,a);const n=s;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(s){return null}}async createDefaultPreferences(e,a){const t=nt(),s={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:a};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,a,t){const s=nt();try{const{error:r}=await s.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(r)throw r}catch(r){throw r}}},zr=a.createContext(void 0),Dr=({children:t})=>{const{user:s,alias:r}=$t(),[n,i]=a.useState({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[l,d]=a.useState(!0);a.useEffect(()=>{(async()=>{if(s?.id&&r)try{const e=await Rr.getUserPreferences(s.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{d(!1)}else d(!1)})()},[s?.id,r]);const c=a.useCallback(async e=>{if(s?.id&&r)try{await Rr.updatePreferences(s.id,r,{locale:e}),i(a=>({...a,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[s?.id,r]),u=a.useCallback(async e=>{if(s?.id&&r)try{await Rr.updatePreferences(s.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[s?.id,r]),m=a.useCallback(async e=>{if(s?.id&&r)try{await Rr.updatePreferences(s.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[s?.id,r]);return e.jsx(zr.Provider,{value:{...n,setLocale:c,setTimezone:u,setDatetimeFormat:m,isLoading:l},children:t})},Fr=()=>{const e=a.useContext(zr);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Lr({children:t}){const{ready:s}=g.useTranslation(),[r,n]=a.useState(!0);return a.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(wa,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:t})}const Or=me.Root,Ur=me.CollapsibleTrigger,$r=me.CollapsibleContent;var qr=Object.defineProperty,Br=(e,a,t)=>((e,a,t)=>a in e?qr(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class Vr extends a.Component{constructor(e){super(e),Br(this,"copyErrorDetails",()=>{const e=Ya.getErrors().slice(0,2),a=`\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,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(a),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,a){if((void 0).DEV)throw e;Ya.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Ya.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(De,{children:"Algo deu errado"})]}),e.jsxs(Le,{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(Or,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Ur,{asChild:!0,children:e.jsxs(_e,{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($r,{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(Gs,{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})})]})]}),a.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:a.map((a,t)=>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:[t+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(a.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),e.jsxs(_e,{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(_e,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Wr=pe.Root,Hr=Z.forwardRef(({className:a,...t},s)=>e.jsx(pe.Item,{ref:s,className:Se("border-b",a),...t}));Hr.displayName="AccordionItem";const Gr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Header,{className:"flex",children:e.jsxs(pe.Trigger,{ref:r,className:Se("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[t,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Gr.displayName=pe.Trigger.displayName;const Qr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.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:Se("pb-4 pt-0",a),children:t})}));Qr.displayName=pe.Content.displayName;const Kr=he.Root,Xr=he.Trigger,Jr=he.Portal,Yr=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Overlay,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Yr.displayName=he.Overlay.displayName;const Zr=Z.forwardRef(({className:a,...t},s)=>e.jsxs(Jr,{children:[e.jsx(Yr,{}),e.jsx(he.Content,{ref:s,className:Se("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",a),...t})]}));Zr.displayName=he.Content.displayName;const en=({className:a,...t})=>e.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",a),...t});en.displayName="AlertDialogHeader";const an=({className:a,...t})=>e.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});an.displayName="AlertDialogFooter";const tn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Title,{ref:s,className:Se("text-lg font-semibold",a),...t}));tn.displayName=he.Title.displayName;const sn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Description,{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));sn.displayName=he.Description.displayName;const rn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Action,{ref:s,className:Se(Te(),a),...t}));rn.displayName=he.Action.displayName;const nn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Cancel,{ref:s,className:Se(Te({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));nn.displayName=he.Cancel.displayName;const on=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Root,{ref:s,className:Se("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));on.displayName=xe.Root.displayName;const ln=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Image,{ref:s,className:Se("aspect-square h-full w-full",a),...t}));ln.displayName=xe.Image.displayName;const dn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Fallback,{ref:s,className:Se("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));dn.displayName=xe.Fallback.displayName;const cn=Z.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));cn.displayName="Breadcrumb";const un=Z.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:Se("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));un.displayName="BreadcrumbList";const mn=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Se("inline-flex items-center gap-1.5",a),...t}));mn.displayName="BreadcrumbItem";const pn=Z.forwardRef(({asChild:a,className:s,...r},n)=>{const i=a?t.Slot:"a";return e.jsx(i,{ref:n,className:Se("transition-colors hover:text-foreground",s),...r})});pn.displayName="BreadcrumbLink";const hn=Z.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Se("font-normal text-foreground",a),...t}));hn.displayName="BreadcrumbPage";const xn=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Se("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(d.ChevronRight,{})});xn.displayName="BreadcrumbSeparator";const fn=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Se("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});fn.displayName="BreadcrumbEllipsis";const gn=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"}}),bn=Z.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:Se(gn({orientation:t}),a),...s}));function vn(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function yn(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function jn(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.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,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}function Nn(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[0],n=a.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=t.valueCallback?t.valueCallback(i):i;return{value:i,rest:a.slice(r.length)}}}bn.displayName="ButtonGroup";const wn={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"}},Cn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},kn={ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:yn({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:yn({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:yn({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:yn({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:yn({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"})},Sn={ordinalNumber:Nn({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:jn({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:jn({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:jn({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:jn({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:jn({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"})},Pn={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=wn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:{date:vn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:vn({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:vn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,s)=>Cn[e],localize:kn,match:Sn,options:{weekStartsOn:0,firstWeekContainsDate:1}},Tn={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"}},_n={date:vn({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:vn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:vn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},In={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"},An={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"},En={ordinalNumber:(e,a)=>Number(e)+"º",era:yn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:yn({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:yn({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:yn({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:yn({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"})},Mn={ordinalNumber:Nn({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:jn({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:jn({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:jn({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:jn({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:jn({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"})},Rn={code:"es",formatDistance:(e,a,t)=>{let s;const r=Tn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:_n,formatRelative:(e,a,t,s)=>1!==a.getHours()?An[e]:In[e],localize:En,match:Mn,options:{weekStartsOn:1,firstWeekContainsDate:1}},zn={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"}},Dn={date:vn({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:vn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:vn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Fn={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Ln={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:yn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:yn({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:yn({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:yn({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:yn({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"})},On={ordinalNumber:Nn({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:jn({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:jn({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:jn({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:jn({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:jn({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"})},Un={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=zn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:Dn,formatRelative:(e,a,t,s)=>{const r=Fn[e];return"function"==typeof r?r(a):r},localize:Ln,match:On,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $n({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(A.DayPicker,{showOutsideDays:s,className:Se("p-3 pointer-events-auto",a),locale:Un,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Se(Te({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Se(Te({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{Chevron:({orientation:a})=>"left"===a?e.jsx(d.ChevronLeft,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}$n.displayName="Calendar";const qn={Root:function({children:a,className:t}){return e.jsx("div",{className:Se("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(Re,{className:Se("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Le,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:Se("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:t})]})}};const Bn=({shouldScaleBackground:a=!0,...t})=>e.jsx(E.Drawer.Root,{shouldScaleBackground:a,...t});Bn.displayName="Drawer";const Vn=E.Drawer.Trigger,Wn=E.Drawer.Portal,Hn=E.Drawer.Close,Gn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Overlay,{ref:s,className:Se("fixed inset-0 z-50 bg-black/80",a),...t}));Gn.displayName=E.Drawer.Overlay.displayName;const Qn=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Wn,{children:[e.jsx(Gn,{}),e.jsxs(E.Drawer.Content,{ref:r,className:Se("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));Qn.displayName="DrawerContent";const Kn=({className:a,...t})=>e.jsx("div",{className:Se("grid gap-1.5 p-4 text-center sm:text-left",a),...t});Kn.displayName="DrawerHeader";const Xn=({className:a,...t})=>e.jsx("div",{className:Se("mt-auto flex flex-col gap-2 p-4",a),...t});Xn.displayName="DrawerFooter";const Jn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Title,{ref:s,className:Se("text-lg font-semibold leading-none tracking-tight",a),...t}));Jn.displayName=E.Drawer.Title.displayName;const Yn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Description,{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));Yn.displayName=E.Drawer.Description.displayName;const Zn={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))]"},ei={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const ai=fe.Root,ti=fe.Trigger,si=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:t,sideOffset:s,className:Se("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",a),...r}));si.displayName=fe.Content.displayName;const ri=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Se("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",a),...t}));ri.displayName="InputGroup";const ni=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"}}),ii=Z.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Se(ni({align:t}),a),...s}));ii.displayName="InputGroupAddon";const oi=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"}}),li=Z.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(_e,{ref:n,"data-slot":"input-group-button",variant:s,className:Se(oi({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));li.displayName="InputGroupButton";const di=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ae,{ref:s,"data-slot":"input-group-control",className:Se("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));di.displayName="InputGroupInput";const ci=Z.forwardRef(({className:a,...t},s)=>e.jsx(va,{ref:s,"data-slot":"input-group-control",className:Se("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ci.displayName="InputGroupTextarea";const ui=Z.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:Se("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));ui.displayName="H1";const mi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:Se("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));mi.displayName="H2";const pi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Se("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));pi.displayName="H3";const hi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:Se("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));hi.displayName="H4";const xi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Se("leading-7 [&:not(:first-child)]:mt-6",a),...t}));xi.displayName="P";const fi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Se("text-xl text-muted-foreground",a),...t}));fi.displayName="Lead";const gi=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Se("text-lg font-semibold",a),...t}));gi.displayName="Large";const bi=Z.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:Se("text-sm font-medium leading-none",a),...t}));bi.displayName="Small";const vi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));vi.displayName="Muted";const yi=Z.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:Se("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));yi.displayName="InlineCode";const ji=Z.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:Se("mt-6 border-l-2 pl-6 italic",a),...t}));ji.displayName="Blockquote";const Ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Se("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));Ni.displayName="List";const wi=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Root,{ref:r,className:Se("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Ii,{})]}));wi.displayName=ge.Root.displayName;const Ci=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.List,{ref:s,className:Se("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));Ci.displayName=ge.List.displayName;const ki=ge.Item,Si=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"),Pi=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Trigger,{ref:r,className:Se(Si(),"group",a),...s,children:[t," ",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"})]}));Pi.displayName=ge.Trigger.displayName;const Ti=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Content,{ref:s,className:Se("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 ",a),...t}));Ti.displayName=ge.Content.displayName;const _i=ge.Link,Ii=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:Se("absolute left-0 top-full flex justify-center"),children:e.jsx(ge.Viewport,{className:Se("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)]",a),ref:s,...t})}));Ii.displayName=ge.Viewport.displayName;const Ai=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Indicator,{ref:s,className:Se("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",a),...t,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ai.displayName=ge.Indicator.displayName;const Ei=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Se("mx-auto flex w-full justify-center",a),...t});Ei.displayName="Pagination";const Mi=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Se("flex flex-row items-center gap-1",a),...t}));Mi.displayName="PaginationContent";const Ri=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Se("",a),...t}));Ri.displayName="PaginationItem";const zi=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:Se(Te({variant:t?"outline":"ghost",size:s}),a),...r});zi.displayName="PaginationLink";const Di=({className:a,...t})=>e.jsxs(zi,{"aria-label":"Go to previous page",size:"default",className:Se("gap-1 pl-2.5",a),...t,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Di.displayName="PaginationPrevious";const Fi=({className:a,...t})=>e.jsxs(zi,{"aria-label":"Go to next page",size:"default",className:Se("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Fi.displayName="PaginationNext";const Li=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:Se("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Li.displayName="PaginationEllipsis";const Oi=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Root,{className:Se("grid gap-2",a),...t,ref:s}));Oi.displayName=be.Root.displayName;const Ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Item,{ref:s,className:Se("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",a),...t,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"})})}));Ui.displayName=be.Item.displayName;const $i=D.Panel,qi=ae.Root,Bi=ae.Trigger,Vi=ae.Close,Wi=ae.Portal,Hi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Hi.displayName=ae.Overlay.displayName;const Gi=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"}}),Qi=Z.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(Wi,{children:[e.jsx(Hi,{}),e.jsxs(ae.Content,{ref:n,className:Se(Gi({side:a}),t),...r,children:[s,e.jsxs(ae.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"})]})]})]}));Qi.displayName=ae.Content.displayName;const Ki=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Se("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(Ue,{className:"mt-2"})]});Ki.displayName="SheetHeader";const Xi=({className:a,...t})=>e.jsx("div",{className:Se("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Xi.displayName="SheetBody";const Ji=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ue,{className:"mb-4"}),e.jsx("div",{className:Se("flex flex-row justify-end gap-2",a),...s,children:t})]});Ji.displayName="SheetFooter";const Yi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Se("text-lg font-semibold text-foreground",a),...t}));Yi.displayName=ae.Title.displayName;const Zi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Se("text-sm text-muted-foreground",a),...t}));Zi.displayName=ae.Description.displayName;const eo="sidebar:state",ao=Z.createContext(null);function to(){const e=Z.useContext(ao);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const so=Z.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=Z.useState(!1);Z.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=Z.useState(!1),[p,h]=Z.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(eo);return null!==e?"true"===e:a}return a}),x=t??p,f=Z.useCallback(e=>{const a="function"==typeof e?e(x):e;s?s(a):h(a),"undefined"!=typeof window&&localStorage.setItem(eo,String(a))},[s,x]),g=Z.useCallback(()=>d?m(e=>!e):f(e=>!e),[d,f,m]);Z.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=x?"expanded":"collapsed",v=Z.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,x,f,d,u,m,g]);return e.jsx(ao.Provider,{value:v,children:e.jsx(as,{delayDuration:0,children:e.jsx("div",{className:Se("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})})})});so.displayName="SidebarProvider";const ro=Z.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=to();return"none"===s?e.jsx("div",{className:Se("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(qi,{open:c,onOpenChange:u,...i,children:e.jsxs(Qi,{"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:a,children:[e.jsx(Yi,{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":t,"data-side":a,children:[e.jsx("div",{className:Se("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"===t||"inset"===t?"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:Se("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===t||"inset"===t?"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})})]})});ro.displayName="Sidebar";const no=Z.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=to();return e.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Se("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});no.displayName="SidebarTrigger";const io=Z.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=to();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Se("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",a),...t})});io.displayName="SidebarRail";const oo=Z.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:Se("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",a),...t}));oo.displayName="SidebarInset";const lo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ae,{ref:s,"data-sidebar":"input",className:Se("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));lo.displayName="SidebarInput";const co=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Se("flex flex-col gap-2 p-2",a),...t}));co.displayName="SidebarHeader";const uo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Se("flex flex-col gap-2 p-2",a),...t}));uo.displayName="SidebarFooter";const mo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ue,{ref:s,"data-sidebar":"separator",className:Se("mx-2 w-auto bg-sidebar-border",a),...t}));mo.displayName="SidebarSeparator";const po=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Se("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));po.displayName="SidebarContent";const ho=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Se("relative flex w-full min-w-0 flex-col p-2",a),...t}));ho.displayName="SidebarGroup";const xo=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Se("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",a),...r})});xo.displayName="SidebarGroupLabel";const fo=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Se("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",a),...r})});fo.displayName="SidebarGroupAction";const go=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Se("w-full text-sm",a),...t}));go.displayName="SidebarGroupContent";const bo=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Se("flex w-full min-w-0 flex-col gap-1",a),...t}));bo.displayName="SidebarMenu";const vo=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Se("group/menu-item relative",a),...t}));vo.displayName="SidebarMenuItem";const yo=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"}}),jo=Z.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?t.Slot:"button",{isMobile:u,state:m}=to(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Se(yo({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:p}),e.jsx(rs,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):p});jo.displayName="SidebarMenuButton";const No=Z.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Se("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",a),...n})});No.displayName="SidebarMenuAction";const wo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Se("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",a),...t}));wo.displayName="SidebarMenuBadge";const Co=Z.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=Z.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Se("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&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}})]})});Co.displayName="SidebarMenuSkeleton";const ko=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Se("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",a),...t}));ko.displayName="SidebarMenuSub";const So=Z.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));So.displayName="SidebarMenuSubItem";const Po=Z.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Se("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})});Po.displayName="SidebarMenuSubButton";const To=Z.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const i=t||s||[0];return e.jsxs(ve.Root,{ref:n,value:t,defaultValue:s,className:Se("relative flex w-full touch-none select-none items-center",a),...r,children:[e.jsx(ve.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ve.Range,{className:"absolute h-full bg-primary"})}),i.map((a,t)=>e.jsx(ve.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"},t))]})});To.displayName=ve.Root.displayName;const _o=ye.Root,Io=Z.forwardRef(({className:a,...t},s)=>e.jsx(ye.List,{ref:s,className:Se("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));Io.displayName=ye.List.displayName;const Ao=Z.forwardRef(({className:a,...t},s)=>e.jsx(ye.Trigger,{ref:s,className:Se("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",a),...t}));Ao.displayName=ye.Trigger.displayName;const Eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(ye.Content,{ref:s,className:Se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));Eo.displayName=ye.Content.displayName;const Mo=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"}}),Ro=Z.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(je.Root,{ref:n,className:Se(Mo({variant:t,size:s,className:a})),...r}));Ro.displayName=je.Root.displayName;const zo=Z.createContext({size:"default",variant:"default"}),Do=Z.forwardRef(({className:a,variant:t,size:s,children:r,...n},i)=>e.jsx(Ne.Root,{ref:i,className:Se("flex items-center justify-center gap-1",a),...n,children:e.jsx(zo.Provider,{value:{variant:t,size:s},children:r})}));Do.displayName=Ne.Root.displayName;const Fo=Z.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=Z.useContext(zo);return e.jsx(Ne.Item,{ref:i,className:Se(Mo({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Fo.displayName=Ne.Item.displayName;const Lo=we.Menu,Oo=we.Group,Uo=we.Portal,$o=we.Sub,qo=we.RadioGroup,Bo=Z.forwardRef(({className:a,...t},s)=>e.jsx(we.Root,{ref:s,className:Se("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));Bo.displayName=we.Root.displayName;const Vo=Z.forwardRef(({className:a,...t},s)=>e.jsx(we.Trigger,{ref:s,className:Se("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",a),...t}));Vo.displayName=we.Trigger.displayName;const Wo=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(we.SubTrigger,{ref:n,className:Se("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Wo.displayName=we.SubTrigger.displayName;const Ho=Z.forwardRef(({className:a,...t},s)=>e.jsx(we.SubContent,{ref:s,className:Se("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",a),...t}));Ho.displayName=we.SubContent.displayName;const Go=Z.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(we.Portal,{children:e.jsx(we.Content,{ref:i,align:t,alignOffset:s,sideOffset:r,className:Se("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",a),...n})}));Go.displayName=we.Content.displayName;const Qo=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(we.Item,{ref:r,className:Se("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",t&&"pl-8",a),...s}));Qo.displayName=we.Item.displayName;const Ko=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(we.CheckboxItem,{ref:n,className:Se("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",a),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(we.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));Ko.displayName=we.CheckboxItem.displayName;const Xo=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(we.RadioItem,{ref:r,className:Se("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(we.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Xo.displayName=we.RadioItem.displayName;const Jo=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(we.Label,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Jo.displayName=we.Label.displayName;const Yo=Z.forwardRef(({className:a,...t},s)=>e.jsx(we.Separator,{ref:s,className:Se("-mx-1 my-1 h-px bg-muted",a),...t}));Yo.displayName=we.Separator.displayName;const Zo=({className:a,...t})=>e.jsx("span",{className:Se("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Zo.displayname="MenubarShortcut";const el={light:"",dark:".dark"},al=Z.createContext(null);function tl(){const e=Z.useContext(al);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const sl=Z.forwardRef(({id:a,className:t,children:s,config:r,...n},i)=>{const o=Z.useId(),l=`chart-${a||o.replace(/:/g,"")}`;return e.jsx(al.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Se("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",t),...n,children:[e.jsx(rl,{id:l,config:r}),e.jsx(Ce.ResponsiveContainer,{children:s})]})})});sl.displayName="Chart";const rl=({id:a,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(el).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${s.map(([a,t])=>{const s=t.theme?.[e]||t.color;return s?` --color-${a}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},nl=Ce.Tooltip,il=Z.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=tl(),f=Z.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=dl(x,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof o?s?.label:x[o]?.label||o;return l?e.jsx("div",{className:Se("font-medium",d),children:l(r,t)}):r?e.jsx("div",{className:Se("font-medium",d),children:r}):null},[o,l,t,n,d,x,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Se("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:f,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=dl(x,a,s),o=u||a.payload?.fill||a.color;return e.jsx("div",{className:Se("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!==a?.value&&a.name?c(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Se("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:Se("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||a.name})]}),void 0!==a.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof a.value?a.value.toLocaleString():a.value})]})]})},a.dataKey||t)})})]})});il.displayName="ChartTooltip";const ol=Ce.Legend,ll=Z.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=tl();return s?.length?e.jsx("div",{ref:i,className:Se("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",a),children:s.map(a=>{const s=`${n||a.dataKey||"value"}`,r=dl(o,a,s);return e.jsxs("div",{className:Se("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:a.color}}),r?.label]},a.value)})}):null});function dl(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}ll.displayName="ChartLegend";const cl=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:Se("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),ul=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function ml({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=g.useTranslation(),m=[];return a&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:a,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"})}),t&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:t,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsxs(os,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(_e,{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(xs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,t)=>e.jsxs(fs,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},t))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((a,t)=>e.jsxs(_e,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e.jsx(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:a.label})]},t))})}function pl(e){const a=y.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const hl=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],xl=[{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"}],fl=[{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/New_York",label:"New York (UTC-5/-4)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6/-5)",offset:"-06:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8/-7)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0/+1)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1/+2)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1/+2)",offset:"+01:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10/+11)",offset:"+10:00"}],gl=()=>{const{locale:a,datetimeFormat:t,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Fr(),{t:o}=g.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[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(la,{value:a,onValueChange:r,children:[e.jsx(ua,{children:e.jsx(ca,{})}),e.jsx(ha,{children:hl.map(a=>e.jsxs(fa,{value:a.value,children:[a.flag," ",a.label]},a.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.jsxs(la,{value:s,onValueChange:i,children:[e.jsx(ua,{children:e.jsx(ca,{})}),e.jsx(ha,{children:fl.map(a=>e.jsx(fa,{value:a.value,children:a.label},a.value))})]})]}),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.jsxs(la,{value:t,onValueChange:n,children:[e.jsx(ua,{children:e.jsx(ca,{})}),e.jsx(ha,{children:xl.map(a=>e.jsx(fa,{value:a.value,children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{children:a.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},bl=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=$t(),[p,h]=a.useState(!1),x="true"===(void 0).VITE_SHOW_USER_PREFERENCES,f=o?.[0]||null,g=l?o?.find(e=>e.alias===l):f,b=o||[],v=r||g||f||f,y=a.useCallback(e=>{n?n(e):m(e)},[n,m]),j=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===v?.alias),s=a.filter(e=>e.alias!==v?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[b,v?.alias]);if(!c||!i)return null;const N=()=>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})]})}),j.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",j.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[j.slice(0,3).map(a=>e.jsx(ja,{variant:a.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>y(a),children:a.name},a.alias)),j.length>3&&e.jsxs(ja,{variant:"outline",className:"text-xs",children:["+",j.length-3]})]})]})]});return"dropdown"===t?e.jsxs(os,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(_e,{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(xs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(us,{children:[e.jsxs(ps,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(hs,{children:j.map(a=>e.jsxs(fs,{onClick:()=>y(a),className:a.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===v?.alias&&e.jsx(ja,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),x&&e.jsx(ys,{}),x&&e.jsxs(fs,{onClick:()=>h(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(fs,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Ge,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Preferências de Internacionalização"})}),e.jsx(gl,{})]})})]}):e.jsxs(Re,{className:s,children:[e.jsx(ze,{children:e.jsx(De,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Le,{className:"space-y-4",children:[e.jsx(N,{}),e.jsx(Ue,{}),x&&e.jsxs(_e,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(_e,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Ge,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Preferências de Internacionalização"})}),e.jsx(gl,{})]})})]})]})}),vl=a.createContext({});function yl({children:t,config:s}){const r=a.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(vl.Provider,{value:r,children:t})}function jl(){return a.useContext(vl)}function Nl(){const e=y.useLocation(),{navigation:a}=jl(),{t:t}=g.useTranslation();if(!a)return t("page");const s=a.find(a=>a.path===e.pathname);if(s)return s.label;const r=a.find(a=>e.pathname.startsWith(a.path+"/"));return r?.label||t("page")}function wl(e,t){const[s,r]=a.useState(()=>e),n=a.useRef(void 0),i=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},t),i),[e,t,i]),[s,i]}const Cl=a.memo(function({actions:t}){const s=y.useLocation(),r=Nl(),{navigation:n,appName:i}=jl(),{metadata:o,headerActions:l}=Cr(),{t:c}=g.useTranslation(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:x,switchUnit:f}=$t(),b=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[v,j]=y.useSearchParams(),[N,w]=a.useState(()=>v.get("search")||""),[C,k]=wl(N,bt.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(v);C?(e.set("search",C),e.set("page","1")):e.delete("search"),j(e)},[C,j,p]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),P=o.title||r,T=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:P}),e.jsx(ja,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),T&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T})]}),p&&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(Ae,{placeholder:c("search"),value:N,onChange:e=>(e=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(_e,{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(),w("");const e=new URLSearchParams(v);e.delete("search"),e.delete("page"),j(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:x,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||t)&&e.jsx("div",{className:"flex items-center gap-2",children:l||t}),(void 0).VITE_WIKI_URL&&e.jsx(_e,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>ke((void 0).VITE_WIKI_URL,e),title:c("open_wiki"),children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(bl,{variant:"dropdown",selectedUnit:b,onUnitChange:f})})]})]})})}),kl=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Sl=(e={})=>{const{enabled:a=!0}=e,{alias:t}=$t();return v.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=nt(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!ct.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},Pl="forlogic-sidebar-pinned",Tl=()=>{try{const e=localStorage.getItem(Pl);return!!e&&JSON.parse(e)}catch{return!1}},_l=e=>{const a=["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 a[e%a.length]},Il=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,Al={logo:`${Il}/${Nt.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Il}/${Nt.isQualiex?"small-forlogic.svg":"small.svg"}`},El=Al.logo,Ml=Al.smallLogo;function Rl({appName:a,isPinned:t,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=g.useTranslation(),{data:l,isLoading:c,error:u}=Sl({enabled:n}),m=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(l,e)};return e.jsxs(co,{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:Al.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 "+(t?"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:Al.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(os,{onOpenChange:i,children:[e.jsx(ls,{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:a})]}),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(xs,{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((a,t)=>e.jsx("div",{onClick:()=>m(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${_l(t)} 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:a.name}),a.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function zl({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=a;if(!n||0===n.length)return null;const l=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],i=a.icon||o,d=s||a.disabled,c=e.jsx(_e,{onClick:a.onClick,disabled:d,className:Se("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:c}),e.jsx(rs,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const c=e.jsx(_e,{disabled:s,className:Se("w-full gap-2 justify-start",t&&"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(os,{children:[e.jsx(ls,{asChild:!0,children:t?e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:c}),e.jsx(rs,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(xs,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:n.map(a=>{const t=a.icon;return e.jsxs(fs,{onClick:a.onClick,disabled:a.disabled,className:"cursor-pointer",children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})}function Dl({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=a.useState(!1),m=a.useRef(null);a.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 p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!c)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[c,e,t,s,l,n,i]),a.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 Fl=a.createContext(void 0);function Ll(){const e=a.useContext(Fl);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Ol({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=g.useTranslation(),{open:l,setOpen:c}=to(),u=y.useLocation(),{alias:m,user:p}=$t(),{hasOpenModal:h}=Ll(),[x,f]=a.useState(!1),[b,v]=a.useState(Tl),[j,N]=a.useState(!1),w=a.useRef(!1),C=r?Dl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{c(!!b||!(!j&&!x))},[b,j,x,c]);return e.jsxs(ro,{collapsible:"icon",onMouseEnter:()=>{b||w.current||N(!0)},onMouseLeave:()=>{b||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(Rl,{appName:t?.appName||o("module_title"),isPinned:b,onPinToggle:()=>{const e=!b;v(e),(e=>{try{localStorage.setItem(Pl,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),c(!1),setTimeout(()=>{w.current=!1},300))},open:l,dropdownOpen:x,onDropdownChange:f}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(as,{children:e.jsx(zl,{config:t.moduleActions,isCollapsed:!l,isDisabled:h})})}),e.jsx(po,{children:s||e.jsx(ho,{className:"p-0 mt-6",children:e.jsx(go,{children:e.jsx(bo,{className:"space-y-2",children:e.jsx(as,{children:t?.navigation?.map((a,t)=>{const s=({item:a,index:t})=>{const r=`${a.path}-${t}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:i}=kl({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),l=a.permissionCheck&&!n;if(l&&"Admin"===a.label)return null;const c=i?d.Loader2:l?d.Lock:a.icon;l?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e.jsx(Or,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(vo,{children:[e.jsx(Ur,{asChild:!0,children:e.jsx(jo,{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:a.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($r,{children:e.jsx(ko,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(vo,{children:l||i?e.jsxs(ts,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(jo,{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:a.label})]})})}),e.jsx(rs,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(jo,{asChild:!0,isActive:(h=a.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(y.Link,{to:a.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:a.label})]})})},a.path);var h};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Se("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 Ul=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=a.useMemo(()=>s||e.jsx(Ol,{config:r}),[s,r]),o=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(yl,{config:r,children:e.jsx(wr,{children:e.jsx(so,{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(Cl,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})}),$l={"pt-BR":Un,"en-US":Pn,"es-ES":Rn},ql=(e,a="pt-BR")=>{if(!e)return"";const t=i.parseISO(e);if(!i.isValid(t))return"Invalid date";const s=$l[a]||Un;return i.format(t,"PP",{locale:s})};class Bl{static async sendEmail(e){const a=nt(),{data:t,error:s}=await a.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 t}}const Vl=Bl;function Wl({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=g.useTranslation(),[m,p]=a.useState([]),[h,x]=a.useState(!1),[f,b]=a.useState(""),{data:v=[],isLoading:y}=Ys({enabled:t}),j=a.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),N=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},w=1===m.length,C=m.length>0;return e.jsx($e,{open:t,onOpenChange:s,children:e.jsxs(Ge,{className:"max-w-2xl",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",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(Ae,{placeholder:u("search_placeholder"),value:f,onChange:e=>b(e.target.value),className:"pl-9"})]}),e.jsx(Gs,{className:"h-[400px] pr-4",children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(Da,{className:"h-16 w-full"},t))}):0===j.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:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:j.map(a=>{const t=a.userId===l,s=c.includes(a.userId||""),r=m.includes(a.userId||"");return e.jsxs("div",{className:Se("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>N(a.userId||""),children:[e.jsx(ba,{checked:r,onCheckedChange:()=>N(a.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:a.userName}),t&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(t||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},a.userId)})})}),e.jsxs(Xe,{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)"]})}),w&&i&&e.jsxs(_e,{onClick:async()=>{if(i&&1===m.length){x(!0);try{await i(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(_e,{onClick:async()=>{if(o&&0!==m.length){x(!0);try{await o(m,r),p([])}finally{x(!1)}}},disabled:h,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Hl({place:t,level:s=0,manageAccessConfig:r}){const[n,i]=a.useState(!1),[o,l]=a.useState(!1),c=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Or,{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(Ur,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Se("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:t.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",t.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:t.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(ja,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(ml,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx($r,{children:t.subPlaces.map(a=>e.jsx(Hl,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx(Ue,{}),r&&e.jsx(Wl,{open:o,onOpenChange:l,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}var Gl=Object.defineProperty,Ql=(e,a,t)=>((e,a,t)=>a in e?Gl(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Kl=new class{constructor(){Ql(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=mt.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Ka.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await mt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return Ya.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Ya.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Xl(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Jl(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Yl(){const{alias:e,isAuthenticated:a}=$t(),t=Ka.getAccessToken(),{data:s=[]}=Ys({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=nt(),{data:r,error:n}=await a.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(a=>a.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 a=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:a?.name||"[Não encontrado]",email:a?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e).length})}),Xl(o)},enabled:!!t&&!!e&&a&&s.length>0})}function Zl(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=nt();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await rd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function ed(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=nt();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(!t.users.length)throw new Error("Selecione pelo menos um liderado");const r=t.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",a).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 t.users){if(t.id_leader&&d.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await rd(s,a,e,d.id_user,t.id_leader)}const i=t.users.map(e=>({alias:a,id_user:e.id_user,id_leader:t.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=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function ad(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=nt();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await rd(s,a,e,r.id_user,t.id_leader,t.id);const{data:n,error:i}=await s.schema(e).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",a).select().single();if(i)throw i;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function td(){const{alias:e}=$t(),a=v.useQueryClient(),t=nt();return v.useMutation({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(s)throw s},onSuccess:()=>{a.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 sd(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=nt();return v.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!a)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",a).eq("is_removed",!1).eq("id_leader",t),s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).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||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==t),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const y of x)await rd(s,a,e,y.id_user,t,y.id);for(const y of g){if(y.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await rd(s,a,e,y.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(x.length){const r=x.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:t}).in("id",r).eq("alias",a))}if(g.length){const r=g.map(e=>({alias:a,id_user:e.id_user,id_leader:t,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:x.length,created:g.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),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 rd(e,a,t,s,r,n){const{data:i,error:o}=await e.schema(t).from("leaders").select("id, id_user, id_leader").eq("alias",a).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 nd({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),i=a.children.length>0,o=32*a.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(a.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(a)},className:"font-medium hover:text-primary hover:underline text-left",children:a.name||a.id_user||a.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),i&&n&&a.children.map(a=>e.jsx(nd,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}function id(e,a,t){function s(t,s){if(t._zod||Object.defineProperty(t,"_zod",{value:{def:s,constr:i,traits:new Set},enumerable:!1}),t._zod.traits.has(e))return;t._zod.traits.add(e),a(t,s);const r=i.prototype,n=Object.keys(r);for(let e=0;e<n.length;e++){const a=n[e];a in t||(t[a]=r[a].bind(t))}}const r=t?.Parent??Object;class n extends r{}function i(e){var a;const r=t?.Parent?new n:this;s(r,e),(a=r._zod).deferred??(a.deferred=[]);for(const t of r._zod.deferred)t();return r}return Object.defineProperty(n,"name",{value:e}),Object.defineProperty(i,"init",{value:s}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>!!(t?.Parent&&a instanceof t.Parent)||a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class od extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ld={};function dd(e){return ld}function cd(e,a){return"bigint"==typeof a?a.toString():a}const ud="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function md(e){return"string"==typeof e?e:e?.message}function pd(e,a,t){const s={...e,path:e.path??[]};if(!e.message){const r=md(e.inst?._zod.def?.error?.(e))??md(a?.error?.(e))??md(t.customError?.(e))??md(t.localeError?.(e))??"Invalid input";s.message=r}return delete s.inst,delete s.continue,a?.reportInput||delete s.input,s}const hd=(e,a)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:a,enumerable:!1}),e.message=JSON.stringify(a,cd,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xd=id("$ZodError",hd),fd=id("$ZodError",hd,{Parent:Error}),gd=e=>(a,t,s,r)=>{const n=s?Object.assign(s,{async:!1}):{async:!1},i=a._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new od;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(e=>pd(e,n,dd())));throw ud(a,r?.callee),a}return i.value},bd=gd(fd),vd=e=>async(a,t,s,r)=>{const n=s?Object.assign(s,{async:!0}):{async:!0};let i=a._zod.run({value:t,issues:[]},n);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(r?.Err??e)(i.issues.map(e=>pd(e,n,dd())));throw ud(a,r?.callee),a}return i.value},yd=vd(fd);function jd(e,a){try{var t=e()}catch(e){return a(e)}return t&&t.then?t.then(void 0,a):t}function Nd(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t}function wd(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("invalid_union"===s.code&&s.errors.length>0){var o=s.errors[0][0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("invalid_union"===s.code&&s.errors.forEach(function(a){return a.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t}function Cd(e,a,t){if(void 0===t&&(t={}),"_def"in(s=e)&&"object"==typeof s._def&&"typeName"in s._def)return function(r,n,i){try{return Promise.resolve(jd(function(){return Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](r,a)).then(function(e){return i.shouldUseNativeValidation&&J.validateFieldsNatively({},i),{errors:{},values:t.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(null==e?void 0:e.issues)}(e))return{values:{},errors:J.toNestErrors(Nd(e.errors,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw e}))}catch(s){return Promise.reject(s)}};var s;if(function(e){return"_zod"in e&&"object"==typeof e._zod}(e))return function(r,n,i){try{return Promise.resolve(jd(function(){return Promise.resolve(("sync"===t.mode?bd:yd)(e,r,a)).then(function(e){return i.shouldUseNativeValidation&&J.validateFieldsNatively({},i),{errors:{},values:t.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof xd}(e))return{values:{},errors:J.toNestErrors(wd(e.issues,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw e}))}catch(s){return Promise.reject(s)}};throw new Error("Invalid input: not a Zod schema")}const kd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string()).min(1,"Selecione pelo menos um liderado")}),Sd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string())});function Pd({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=Ys(),[l,c]=a.useState(""),u=a.useRef(null),m=a.useRef(0),{t:p}=g.useTranslation(),h=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=l.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const s=t.includes(e.userId),r=t.includes(a.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),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:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{placeholder:p("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ba,{id:a.userId,checked:t.includes(a.userId),onCheckedChange:()=>{return e=a.userId,u.current&&(m.current=u.current.scrollTop),void(t.includes(e)?s(t.filter(a=>a!==e)):s([...t,e]));var e}}),e.jsx(Me,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:t.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Td({leader:t,prefilledLeaderId:s,onSuccess:r}){const{t:n}=g.useTranslation(),{alias:i}=$t(),o=!!t,l=t?.id.startsWith("virtual-"),c=ed(),u=Zl(),m=ad(),h=sd(),x=td(),{data:f=[]}=Yl(),{data:b=[]}=Ys(),[v,y]=a.useState(""),j=Jl(f).map(e=>e.id_user),N=o?Jl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],w=p.useForm({resolver:Cd(o?Sd:kd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?N:[]}});a.useEffect(()=>{if(t){const e=Jl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);w.reset({id_leader:t.id_leader||null,id_users:e})}else s?w.reset({id_leader:s,id_users:[]}):w.reset({id_leader:null,id_users:[]})},[i,t?.id,t?.id_user,t?.id_leader,s,f]);const C=c.isPending||u.isPending||m.isPending||h.isPending||x.isPending,k=w.watch("id_leader"),S=w.watch("id_users"),P=o?[t.id_user,...j.filter(e=>e!==t.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...j.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:w.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await m.mutateAsync({id:t.id,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:a})}r?.()}catch(a){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Me,{children:n("leader")}),e.jsx(Ae,{value:b.find(e=>e.userId===t.id_user)?.userName||t.name||t.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Me,{children:n("superior")}),e.jsxs(la,{value:k||"none",onValueChange:e=>w.setValue("id_leader","none"===e?null:e),children:[e.jsx(ua,{children:e.jsx(ca,{placeholder:n("select_placeholder")})}),e.jsxs(ha,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ae,{placeholder:n("superior_search"),value:v,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Gs,{className:"h-[200px]",children:[e.jsx(fa,{value:"none",children:"[Nenhum]"}),b.filter(e=>{const a=o?e.userId!==t.id_user:!S.includes(e.userId),s=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return a&&s}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(a=>e.jsx(fa,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${i}`),w.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:w.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(Me,{children:[n("subordinates")," *"]}),e.jsx(Pd,{value:S,onChange:e=>w.setValue("id_users",e),excludeUserIds:P,error:w.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(_e,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!x.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(_e,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(t&&window.confirm(n("remove_confirm")))try{await x.mutateAsync(t.id),r?.()}catch(e){}},className:"ml-auto",children:x.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 _d({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx($e,{open:a,onOpenChange:t,children:e.jsxs(Ge,{className:"sm:max-w-[500px]",children:[e.jsx(Qe,{children:e.jsx(Je,{children:n})}),e.jsx(Td,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const Id="leadership-expanded-nodes",Ad=(e,a)=>{try{localStorage.setItem(`${Id}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function Ed(e){const[t,s]=a.useState(!1),[r,n]=a.useState(0),{t:i}=g.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,a)=>{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 t={...c,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await o(e,t);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{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,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t,progress:r}}function Md(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function Rd(e,a){const t=Md(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function zd(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function Dd(e,a){const t=zd(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function Fd(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Ld(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Od(e,a){return e/a}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 g.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return g.useTranslation}}),exports.AUTH_CONFIG=ft,exports.Accordion=Wr,exports.AccordionContent=Qr,exports.AccordionItem=Hr,exports.AccordionTrigger=Gr,exports.ActionButton=Ie,exports.ActionMenu=ml,exports.ActionMenuItems=Fs,exports.Alert=vr,exports.AlertDescription=jr,exports.AlertDialog=Kr,exports.AlertDialogAction=rn,exports.AlertDialogCancel=nn,exports.AlertDialogContent=Zr,exports.AlertDialogDescription=sn,exports.AlertDialogFooter=an,exports.AlertDialogHeader=en,exports.AlertDialogOverlay=Yr,exports.AlertDialogPortal=Jr,exports.AlertDialogTitle=tn,exports.AlertDialogTrigger=Xr,exports.AlertTitle=yr,exports.AppHeader=Cl,exports.AppLayout=Ul,exports.AppSidebar=Ol,exports.AuthErrorInterceptor=ct,exports.AuthProvider=Ut,exports.AuthService=Lt,exports.Avatar=on,exports.AvatarFallback=dn,exports.AvatarImage=ln,exports.Badge=ja,exports.BaseForm=er,exports.Blockquote=ji,exports.Breadcrumb=cn,exports.BreadcrumbEllipsis=fn,exports.BreadcrumbItem=mn,exports.BreadcrumbLink=pn,exports.BreadcrumbList=un,exports.BreadcrumbPage=hn,exports.BreadcrumbSeparator=xn,exports.BulkActionBar=sr,exports.Button=_e,exports.ButtonGroup=bn,exports.CRUD_CONFIG=gt,exports.Calendar=$n,exports.CallbackPage=()=>{const{processCallback:t}=$t(),[s,r]=a.useState(null),[n,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{i(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return s?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(De,{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(Le,{className:"space-y-4",children:[e.jsx(vr,{variant:"danger",children:e.jsx(jr,{children:s})}),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(_e,{onClick:o,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(wa,{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(_e,{onClick:l,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(De,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(Le,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(wa,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=Re,exports.CardContent=Le,exports.CardDescription=Fe,exports.CardFooter=Oe,exports.CardHeader=ze,exports.CardSkeleton=Yt,exports.CardTitle=De,exports.ChartContainer=sl,exports.ChartLegend=ol,exports.ChartLegendContent=ll,exports.ChartStyle=rl,exports.ChartTooltip=nl,exports.ChartTooltipContent=il,exports.Checkbox=ba,exports.Collapsible=Or,exports.CollapsibleContent=$r,exports.CollapsibleTrigger=Ur,exports.ColorPicker=Hs,exports.Combobox=Oa,exports.Command=Ta,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(Ta,{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:a})}),exports.CommandEmpty=Aa,exports.CommandGroup=Ea,exports.CommandInput=_a,exports.CommandItem=Ra,exports.CommandList=Ia,exports.CommandSeparator=Ma,exports.CommandShortcut=za,exports.ContextMenu=Ns,exports.ContextMenuCheckboxItem=Es,exports.ContextMenuContent=Is,exports.ContextMenuGroup=Cs,exports.ContextMenuItem=As,exports.ContextMenuLabel=Rs,exports.ContextMenuPortal=ks,exports.ContextMenuRadioGroup=Ps,exports.ContextMenuRadioItem=Ms,exports.ContextMenuSeparator=zs,exports.ContextMenuShortcut=Ds,exports.ContextMenuSub=Ss,exports.ContextMenuSubContent=_s,exports.ContextMenuSubTrigger=Ts,exports.ContextMenuTrigger=ws,exports.CoreProviders=function({children:a,queryClient:t}){const s=t??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Vr,{children:e.jsx(g.I18nextProvider,{i18n:o,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx(Ut,{children:e.jsx(Dr,{children:e.jsx(Lr,{children:a})})})})})})},exports.CrudPageInternal=dr,exports.CrudPagination=tr,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=g.useTranslation(),l=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&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(Ae,{type:"text",placeholder:o("search"),value:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:a},t)),n&&l&&r&&e.jsxs(_e,{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=ar,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:y}){const{columnWidths:j,isDragging:N,activeColumn:w,handleMouseDown:C}=Us({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:y?`${y}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:P,getRowHeight:T}=$s({rowIds:t.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),_=a.useMemo(()=>{if(b)return s.map(e=>`${j[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[s,b,j]);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((a,t)=>e.jsx(Da,{className:"h-12 w-full"},t))})});if(0===t.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=N||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(I?"select-none":""),children:e.jsxs(Bt,{className:m,children:[e.jsx(Vt,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Gt,{children:[p&&e.jsx(Qt,{className:"w-[40px]",children:e.jsx(ba,{checked:g,onCheckedChange:f,"aria-label":"Selecionar todos"})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,o=w===String(a.key);return e.jsxs(Qt,{className:`${a.className||""} relative`,style:{width:_[t]},children:[a.sortable&&i?e.jsxs("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(l=String(a.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:a.header}),s&&e.jsx(is,{direction:"horizontal",onMouseDown:e=>C(String(a.key),e),isDragging:o})]},String(a.key));var l}),l&&e.jsx(Qt,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Wt,{children:t.map(a=>{const t=T(a.id);return a.id,e.jsxs(Gt,{onClick:()=>o?.(a),className:(o?"cursor-pointer":"")+" relative",style:t?{height:`${t}px`}:void 0,children:[p&&e.jsx(Kt,{children:e.jsx(ba,{checked:h.includes(a.id),onCheckedChange:()=>x?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),s.map(t=>e.jsx(Kt,{className:t.className,children:e.jsx(ns,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),l&&e.jsx(Kt,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(a)})]},a.id)})})]})})},exports.CrudTable=Bs,exports.DataList=qn,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Pick a date",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(ka,{children:[e.jsx(Sa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",disabled:r,className:Se("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),a?i.format(a,"PPP"):e.jsx("span",{children:s})]})}),e.jsx(Pa,{className:"w-auto p-0",align:"start",children:e.jsx($n,{mode:"single",selected:a,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=$e,exports.DialogBody=Ke,exports.DialogClose=Ve,exports.DialogContent=Ge,exports.DialogDescription=Ye,exports.DialogFooter=Xe,exports.DialogHeader=Qe,exports.DialogOverlay=We,exports.DialogPortal=Be,exports.DialogTitle=Je,exports.DialogTrigger=qe,exports.Drawer=Bn,exports.DrawerClose=Hn,exports.DrawerContent=Qn,exports.DrawerDescription=Yn,exports.DrawerFooter=Xn,exports.DrawerHeader=Kn,exports.DrawerOverlay=Gn,exports.DrawerPortal=Wn,exports.DrawerTitle=Jn,exports.DrawerTrigger=Vn,exports.DropdownMenu=os,exports.DropdownMenuCheckboxItem=gs,exports.DropdownMenuContent=xs,exports.DropdownMenuGroup=ds,exports.DropdownMenuItem=fs,exports.DropdownMenuLabel=vs,exports.DropdownMenuPortal=cs,exports.DropdownMenuRadioGroup=ms,exports.DropdownMenuRadioItem=bs,exports.DropdownMenuSeparator=ys,exports.DropdownMenuShortcut=js,exports.DropdownMenuSub=us,exports.DropdownMenuSubContent=hs,exports.DropdownMenuSubTrigger=ps,exports.DropdownMenuTrigger=ls,exports.EmailService=Bl,exports.EmptyState=es,exports.EntitySelect=Oa,exports.ErrorBoundary=Vr,exports.FilterBar=lr,exports.Form=Ze,exports.FormControl=na,exports.FormDescription=ia,exports.FormField=({...a})=>e.jsx(ea.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=sa,exports.FormLabel=ra,exports.FormMessage=oa,exports.FormSkeleton=function({fields:a=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(Da,{className:"h-4 w-24"}),e.jsx(Da,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Da,{className:"h-10 w-20"}),e.jsx(Da,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Se("grid",Zn[t],ei[s],r),children:a})},exports.H1=ui,exports.H2=mi,exports.H3=pi,exports.H4=hi,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(Da,{className:"h-8 w-8 rounded-full"}),e.jsx(Da,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Da,{className:"h-8 w-8"}),e.jsx(Da,{className:"h-8 w-24"})]})]})},exports.HoverCard=ai,exports.HoverCardContent=si,exports.HoverCardTrigger=ti,exports.IconPicker=Xs,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=Ed({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),b=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("url")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ae,{type:"url",placeholder:u("url_placeholder"),value:m.imageUrl||"",onChange:e=>b("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?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(Me,{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(Me,{htmlFor:"caption",children:u("caption")}),e.jsx(va,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>b("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{htmlFor:"alt",children:u("alt")}),e.jsx(Ae,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>b("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("alignment")}),e.jsxs(la,{value:m.alignment||"center",onValueChange:e=>b("alignment",e),children:[e.jsx(ua,{children:e.jsx(ca,{})}),e.jsxs(ha,{children:[e.jsx(fa,{value:"left",children:u("left")}),e.jsx(fa,{value:"center",children:u("center")}),e.jsx(fa,{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(Me,{htmlFor:"width",children:u("width")}),e.jsx(Ae,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>b("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{htmlFor:"height",children:u("height")}),e.jsx(Ae,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>b("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=>b("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(Me,{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(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{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:a,className:t="",style:s}){if(!a.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${t}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&e.jsxs("a",{href:a.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=yi,exports.Input=Ae,exports.InputGroup=ri,exports.InputGroupAddon=ii,exports.InputGroupButton=li,exports.InputGroupInput=di,exports.InputGroupTextarea=ci,exports.LOGO_CONFIG=Nt,exports.Label=Me,exports.Large=gi,exports.Lead=fi,exports.LeaderRow=nd,exports.LeadershipDialog=_d,exports.LeadershipForm=Td,exports.LeadershipPage=function(){const{alias:t}=$t(),{t:s}=g.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=Yl(),{data:l=[]}=Ys({enabled:!0}),[c,u]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${Id}-${e}`);if(a)return new Set(JSON.parse(a))}catch(i){}return new Set})(t):new Set),[m,p]=a.useState(!1),[h,x]=a.useState(),[f,b]=a.useState(null),v=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),y=new Set(v.map(e=>e.userId)),j=v.length-(r?Jl(r).filter(e=>y.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);a.useEffect(()=>{if(r&&r.length>0&&t){if(!localStorage.getItem(`${Id}-${t}`)){const e=r.map(e=>e.id),a=new Set(e);u(a),Ad(t,a)}}},[r,t]);const N=e=>{u(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&Ad(t,s),s})},w=e=>{x(e),b(null),p(!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(_e,{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(_e,{size:"sm",onClick:()=>{x(void 0),b(null),p(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=Jl(r).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&Ad(t,a)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&Ad(t,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:[j," usuário",1!==j?"s":""," não associado",1!==j?"s":""]})]})})]})}),r&&0!==r.length?e.jsx(Gs,{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(a=>e.jsx(nd,{leader:a,expandedIds:c,onToggleExpand:N,onEdit:w},a.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(_d,{open:m,onOpenChange:()=>{p(!1),x(void 0),b(null)},leader:h,prefilledLeaderId:f,title:h?s("edit")+" "+s("name"):f?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=Ni,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:Se("relative",s),children:[t,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(wa,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Se("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Se("flex items-center justify-center py-8",s),children:e.jsx(wa,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=Dr,exports.LocaleSelector=gl,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(De,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(Le,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(_e,{onClick:async()=>{vt()?await Lt.loginDev():Lt.loginProd()},className:"w-full",size:"lg",children:vt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=wt,exports.ManageAccessModal=Wl,exports.Menubar=Bo,exports.MenubarCheckboxItem=Ko,exports.MenubarContent=Go,exports.MenubarGroup=Oo,exports.MenubarItem=Qo,exports.MenubarLabel=Jo,exports.MenubarMenu=Lo,exports.MenubarPortal=Uo,exports.MenubarRadioGroup=qo,exports.MenubarRadioItem=Xo,exports.MenubarSeparator=Yo,exports.MenubarShortcut=Zo,exports.MenubarSub=$o,exports.MenubarSubContent=Ho,exports.MenubarSubTrigger=Wo,exports.MenubarTrigger=Vo,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,i]=a.useState(!1),o=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=a.useCallback(e=>{i(e)},[]),c=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(Fl.Provider,{value:u,children:t})},exports.MultiSelect=Oa,exports.Muted=vi,exports.NavigationMenu=wi,exports.NavigationMenuContent=Ti,exports.NavigationMenuIndicator=Ai,exports.NavigationMenuItem=ki,exports.NavigationMenuLink=_i,exports.NavigationMenuList=Ci,exports.NavigationMenuTrigger=Pi,exports.NavigationMenuViewport=Ii,exports.NavigationProvider=yl,exports.P=xi,exports.PageBreadcrumb=function({items:a,maxItems:t=3,className:s}){const r=a.length>t?[a[0],...a.slice(-(t-1))]:a,n=a.length>t;return e.jsx(cn,{className:s,children:e.jsx(un,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(mn,{children:[!s&&e.jsx(xn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(fn,{}),e.jsx(xn,{})]}),a.isCurrentPage?e.jsx(hn,{children:a.label}):e.jsx(pn,{href:a.href,children:a.label})]},a.label)})})})},exports.PageMetadataProvider=wr,exports.Pagination=Ei,exports.PaginationContent=Mi,exports.PaginationEllipsis=Li,exports.PaginationItem=Ri,exports.PaginationLink=zi,exports.PaginationNext=Fi,exports.PaginationPrevious=Di,exports.PlaceCard=Hl,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){const{t:r}=g.useTranslation();return t?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")})]})}):a&&0!==a.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(a=>e.jsx(Hl,{place:a,manageAccessConfig:s},a.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=ka,exports.PopoverContent=Pa,exports.PopoverTrigger=Sa,exports.Progress=mr,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=$t();if(a.useEffect(()=>{if(!s)return;const e=()=>{Ka.areAllTokensValid()||Lt.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[s]),a.useEffect(()=>{if(r)return;if(s)return;if(Ka.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const n=vt();(async()=>{n?await Lt.loginDev():Lt.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(De,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(Le,{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(De,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(Le,{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(De,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(Le,{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:vt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=yt,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=_t,exports.QualiexErrorInterceptor=mt,exports.QualiexUserField=Zs,exports.RadioGroup=Oi,exports.RadioGroupItem=Ui,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(D.Separator,{className:Se("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",t),...s,children:a&&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=$i,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(D.Group,{className:Se("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),exports.RichTextEditor=({value:t,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]=a.useState("visual"),p=B.useEditor({extensions:[V.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Q.Color,K.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});Z.useEffect(()=>{p&&t!==p.getHTML()&&p.commands.setContent(t||"")},[t,p]);const h=a.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?p.chain().focus().extendMarkRange("link").setLink({href:a}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Se("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(_e,{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(_e,{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(_e,{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(cl,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(ul,{}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(ul,{}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(ul,{}),e.jsx(cl,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(ul,{}),e.jsx(cl,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(ul,{}),e.jsx(cl,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(cl,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(B.EditorContent,{editor:p,className:Se("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:t||"",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:t||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=bt,exports.ScrollArea=Gs,exports.ScrollBar=Qs,exports.Select=la,exports.SelectContent=ha,exports.SelectGroup=da,exports.SelectItem=fa,exports.SelectLabel=xa,exports.SelectScrollDownButton=pa,exports.SelectScrollUpButton=ma,exports.SelectSearch=Oa,exports.SelectSeparator=ga,exports.SelectTrigger=ua,exports.SelectValue=ca,exports.Separator=Ue,exports.Sheet=qi,exports.SheetBody=Xi,exports.SheetClose=Vi,exports.SheetContent=Qi,exports.SheetDescription=Zi,exports.SheetFooter=Ji,exports.SheetHeader=Ki,exports.SheetOverlay=Hi,exports.SheetPortal=Wi,exports.SheetTitle=Yi,exports.SheetTrigger=Bi,exports.Sidebar=ro,exports.SidebarActionTrigger=zl,exports.SidebarContent=po,exports.SidebarFooter=uo,exports.SidebarGroup=ho,exports.SidebarGroupAction=fo,exports.SidebarGroupContent=go,exports.SidebarGroupLabel=xo,exports.SidebarHeader=Rl,exports.SidebarInput=lo,exports.SidebarInset=oo,exports.SidebarMenu=bo,exports.SidebarMenuAction=No,exports.SidebarMenuBadge=wo,exports.SidebarMenuButton=jo,exports.SidebarMenuItem=vo,exports.SidebarMenuSkeleton=Co,exports.SidebarMenuSub=ko,exports.SidebarMenuSubButton=Po,exports.SidebarMenuSubItem=So,exports.SidebarProvider=so,exports.SidebarRail=io,exports.SidebarSeparator=mo,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(Da,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx(Da,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=no,exports.Skeleton=Da,exports.Slider=To,exports.Small=bi,exports.SonnerToaster=Ca,exports.Spinner=wa,exports.SplitButton=function({label:a,onClick:t,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:Se("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,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,a]}),e.jsxs(os,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(_e,{variant:n,size:i,disabled:m,className:Se("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(xs,{align:c,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(fs,{onClick:a.onClick,disabled:a.disabled,className:Se("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]}):e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,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,a]})},exports.Stack=or,exports.Switch=Js,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:Se("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:Se("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:a}),t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(Ue,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:Se("flex flex-col h-full",t),children:e.jsx(Gs,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=Bt,exports.TableBody=Wt,exports.TableCaption=Xt,exports.TableCell=Kt,exports.TableFooter=Ht,exports.TableHead=Qt,exports.TableHeader=Vt,exports.TableResizeHandle=is,exports.TableRow=Gt,exports.TableRowActions=Ls,exports.TableSkeleton=Jt,exports.Tabs=_o,exports.TabsContent=Eo,exports.TabsList=Io,exports.TabsTrigger=Ao,exports.Textarea=va,exports.Toaster=Ca,exports.Toggle=Ro,exports.ToggleGroup=Do,exports.ToggleGroupItem=Fo,exports.TokenManager=Ka,exports.TokenService=$a,exports.Tooltip=ts,exports.TooltipContent=rs,exports.TooltipProvider=as,exports.TooltipTrigger=ss,exports.TranslationLoader=Lr,exports.TruncatedCell=ns,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{inputType:"url",controls:!0}),h=a.useRef(null),x=a.useRef(null),{upload:f,uploading:b}=Ed({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:y}=Ed({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>Ld(m.videoUrl||Fd(m.embedCode)||""),[m.videoUrl,m.embedCode]),N=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("input_type")}),e.jsxs(la,{value:m.inputType||"url",onValueChange:e=>N("inputType",e),children:[e.jsx(ua,{children:e.jsx(ca,{})}),e.jsxs(ha,{children:[e.jsx(fa,{value:"url",children:u("url")}),e.jsx(fa,{value:"upload",children:u("input_type_upload")}),e.jsx(fa,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||a.name.replace(/\.[^/.]+$/,"")};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?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(Me,{children:u("embed")}),e.jsx(va,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ae,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(t),s(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:y,children:y?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(Me,{htmlFor:"title",children:u("title")}),e.jsx(Ae,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>N("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=>N("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(Me,{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=>N("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(Me,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=m.videoUrl||Fd(m.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===j)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:a}),u("unsupported")]});const t="youtube"===j?Rd(a,m.autoplay):Dd(a,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:t,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(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{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:a,className:t="",style:s}){const r=a.videoUrl||Fd(a.embedCode)||"";if(!r)return null;const n=Ld(r),{t:i}=g.useTranslation();return e.jsx(Re,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Le,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.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:a.title||i("video"),src:"youtube"===n?Rd(r,a.autoplay):Dd(r,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.WizardBreadcrumb=hr,exports.WizardButtons=fr,exports.WizardForm=function({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c,showProgressIndicator:u=!0,progressType:m="stepper",validateOnNext:p=!0,allowSkipSections:h=!1,previousButtonText:x,nextButtonText:f,onStepChange:g,onStepValidationFail:b,renderProgressIndicator:v,renderButtons:y,currentStepIndex:j,onCurrentStepChange:N}){const[w,C]=a.useState(0),k=j??w,S=N??C,P=a.useRef(null),[T,_]=a.useState(null),I=a.useCallback(e=>{P.current=e,_(e)},[]),A=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:E,errors:M,updateField:R,handleSubmit:z}=Vs(A,r,void 0,o);a.useEffect(()=>{o&&S(0)},[o,S]);const D=a.useCallback(()=>{const e=s[k];if(!e)return!0;const a=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),t={};let r=!0;return a.forEach(e=>{const a=E[e.name];if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(t[e.name]=`${e.label} é obrigatório`,r=!1),e.validation&&"function"==typeof e.validation){const s=e.validation(a,E);s&&(t[e.name]=s,r=!1)}}),!r&&b&&b(k,t),r},[s,k,E,b]),F=a.useCallback(()=>{if(p&&!D())return;const e=k+1;e<s.length&&(S(e),g?.(e,s[e].id))},[k,s,p,D,S,g]),L=a.useCallback(()=>{const e=k-1;e>=0&&(S(e),g?.(e,s[e].id))},[k,s,S,g]),O=a.useCallback(()=>{let e=!0;for(let a=0;a<s.length;a++){s[a].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(a=>{const t=E[a.name];a.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(e=!1)})}e&&z(n)()},[s,E,z,n]),U=a.useMemo(()=>s.map((e,a)=>({index:a,id:e.id,label:e.label||e.id,isActive:a===k,isCompleted:a<k,isDisabled:e.disabled||!1})),[s,k]),$=0===k,q=k===s.length-1,B=a.useMemo(()=>{if(!u)return null;if(v)return v(k,s.length,s);const a=h?e=>{S(e),g?.(e,s[e].id)}:void 0;switch(m){case"breadcrumb":return e.jsx(hr,{steps:U,currentStepIndex:k,onStepClick:a});case"progressbar":return e.jsx(xr,{steps:U,currentStepIndex:k});default:return e.jsx(pr,{steps:U,currentStepIndex:k,onStepClick:a})}},[u,v,m,U,k,s,h,S,g]),V=a.useMemo(()=>{const a={isFirstStep:$,isLastStep:q,canGoNext:k<s.length-1,canGoPrevious:k>0,isLoading:d,onPrevious:L,onNext:F,onSubmit:O,previousButtonText:x,nextButtonText:f,submitButtonText:l};return y?y(a):e.jsx(fr,{...a})},[$,q,k,s.length,d,L,F,O,x,f,l,y]),W=a=>{const t=(a.computedValue,E[a.name]),s=void 0!==t?t:"",r=M[a.name];switch(a.type){case"group":return e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsx(Me,{className:"text-sm font-medium",children:a.label}),e.jsx("div",{className:Se("grid gap-4",1===a.columns&&"grid-cols-1",2===a.columns&&"grid-cols-1 md:grid-cols-2",3===a.columns&&"grid-cols-1 md:grid-cols-3",4===a.columns&&"grid-cols-1 md:grid-cols-4",!a.columns&&"grid-cols-1"),children:a.fields?.map(e=>W(e))})]},a.name);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:"number",value:s,onChange:e=>R(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(va,{id:a.name,value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(la,{value:s,onValueChange:e=>R(a.name,e),children:[e.jsx(ua,{className:r?"border-destructive":"",children:e.jsx(ca,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e.jsx(ha,{children:a.options?.map(a=>e.jsx(fa,{value:String(a.value),children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Oa,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>R(a.name,e),placeholder:a.placeholder,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":case"color-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Hs,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Xs,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"user-select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Zs,{value:s,onChange:e=>R(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"custom":return a.render?e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>R(a.name,e),error:r,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name):null;default:return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Me,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ae,{id:a.name,type:a.type||"text",value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},H=s[k];return e.jsx($e,{open:o,onOpenChange:i,children:e.jsxs(Ge,{ref:I,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Qe,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e.jsx(Je,{className:"text-white",children:t})}),B,e.jsx("div",{className:"space-y-4 py-4",children:H?.fields.map(e=>W(e))}),e.jsx("div",{className:"flex justify-between pt-4 border-t",children:V})]})})},exports.WizardProgressBar=xr,exports.WizardStepper=pr,exports.assets=Al,exports.badgeVariants=ya,exports.buildHierarchy=Xl,exports.buttonGroupVariants=gn,exports.buttonVariants=Te,exports.calculateAspectRatio=Od,exports.cn=Se,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??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};return e.jsx(dr,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=pl({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=pl,exports.createService=Et,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=Et({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:a,useCrudHook:(t,s)=>qt({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=kt,exports.deriveNameField=Ct,exports.deriveUsernameField=St,exports.detectVideoProvider=Ld,exports.emailService=Vl,exports.errorService=Ya,exports.extractImageFileName=function(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}},exports.extractVimeoId=zd,exports.extractYouTubeId=Md,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))},exports.flattenTree=Jl,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=ql,exports.formatDatetime=e=>{if(!e)return"";const a=i.parseISO(e);if(!i.isValid(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${a.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,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:ur(e),label:ur(e),...cr(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.getQualiexConfig=jt,exports.getSupabaseClient=nt,exports.handleExternalLink=ke,exports.inputGroupAddonVariants=ni,exports.inputGroupButtonVariants=oi,exports.isDevEnvironment=vt,exports.isImageUrl=function(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))},exports.logoSrc=El,exports.navigationMenuTriggerStyle=Si,exports.normalizeVideoUrl=function(e,a,t){switch(a||Ld(e)){case"youtube":return Rd(e,t);case"vimeo":return Dd(e,t);default:return e}},exports.normalizeVimeoUrl=Dd,exports.normalizeYouTubeUrl=Rd,exports.parseIframeSrc=Fd,exports.placeService=Kl,exports.qualiexApi=xt,exports.resizeKeepingAspect=function(e,a,t,s){const r=Od(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=Pt,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.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=Ml,exports.toggleVariants=Mo,exports.translationService=Ir,exports.trimTextFields=Pe,exports.useActiveModules=Sl,exports.useAuth=$t,exports.useBaseForm=Vs,exports.useColumnResize=Us,exports.useCreateLeaderMutation=function(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=nt();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.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",a).eq("id_user",t.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");t.id_leader&&await rd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=ed,exports.useCreateSingleLeaderMutation=Zl,exports.useCrud=qt,exports.useDebounce=wl,exports.useFormField=aa,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Ll();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a,datetimeFormat:t}=Fr();return{formatDatetime:e=>((e,a="dd/MM/yyyy HH:mm")=>{if(!e)return"";const t=i.parseISO(e);return i.isValid(t)?i.format(t,a):"Invalid date"})(e,t,a),formatDate:a=>ql(a,e),locale:e,timezone:a,datetimeFormat:t}},exports.useLeadershipApi=Yl,exports.useLocale=Fr,exports.useMediaUpload=Ed,exports.useModalState=Ll,exports.useNavigation=jl,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=Cr();a.useEffect(()=>(t(e),()=>s()),[e.title,e.subtitle,t,s])},exports.usePageMetadataContext=Cr,exports.usePageTitle=Nl,exports.usePermissionQuery=kl,exports.useQualiexUsers=Ys,exports.useRemoveLeaderMutation=td,exports.useRouteBreadcrumbs=function(){const e=y.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=$s,exports.useSidebar=to,exports.useSidebarResize=Dl,exports.useSyncSubordinatesMutation=sd,exports.useUpdateLeaderMutation=ad;
1
+ "use strict";var e=require("react/jsx-runtime"),a=require("react"),t=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"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),x=require("@radix-ui/react-checkbox"),f=require("@radix-ui/react-popover"),g=require("react-i18next"),b=require("@supabase/supabase-js"),v=require("@tanstack/react-query"),y=require("react-router-dom"),j=require("@radix-ui/react-tooltip"),N=require("@radix-ui/react-dropdown-menu"),w=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-scroll-area"),k=require("@radix-ui/react-switch"),S=require("@radix-ui/react-progress"),P=require("@radix-ui/react-collapsible"),T=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-alert-dialog"),_=require("@radix-ui/react-avatar"),A=require("react-day-picker"),E=require("vaul"),M=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),D=require("@radix-ui/react-radio-group"),F=require("react-resizable-panels"),z=require("@radix-ui/react-slider"),L=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-toggle"),U=require("@radix-ui/react-toggle-group"),q=require("@radix-ui/react-menubar"),$=require("recharts"),B=require("@tiptap/react"),W=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Q=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),X=require("zod"),J=require("@hookform/resolvers");function Y(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var Z=Y(a),ee=Y(c),ae=Y(u),te=Y(m),se=Y(h),re=Y(x),ne=Y(f),ie=Y(j),oe=Y(N),le=Y(w),de=Y(C),ce=Y(k),ue=Y(S),me=Y(P),pe=Y(T),he=Y(I),xe=Y(_),fe=Y(M),ge=Y(R),be=Y(D),ve=Y(F),ye=Y(z),je=Y(L),Ne=Y(O),we=Y(U),Ce=Y(q),ke=Y($);function Se(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info(o.t("link_copied"))})}function Pe(...e){return n.twMerge(r.clsx(e))}const Te=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Te);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Te(s);return a}return e},Ie=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"}}),_e=Z.forwardRef(({className:a,variant:s,size:r,asChild:n=!1,...i},o)=>{const l=n?t.Slot:"button";return e.jsx(l,{className:Pe(Ie({variant:s,size:r,className:a})),ref:o,...i})});_e.displayName="Button";const Ae=a.forwardRef(({className:a,children:t,...s},r)=>e.jsx(_e,{ref:r,variant:"action",size:"sm",className:Pe("h-7 px-2 text-xs",a),...s,children:t||e.jsx(d.EllipsisVertical,{size:12})}));Ae.displayName="ActionButton";const Ee=Z.forwardRef(({className:a,type:t,...s},r)=>e.jsx("input",{type:t,className:Pe("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",a),ref:r,...s}));Ee.displayName="Input";const Me=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=Z.forwardRef(({className:a,...t},s)=>e.jsx(ee.Root,{ref:s,className:Pe(Me(),a),...t}));Re.displayName=ee.Root.displayName;const De=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));De.displayName="Card";const Fe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex flex-col space-y-1.5 p-6",a),...t}));Fe.displayName="CardHeader";const ze=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("text-2xl font-semibold leading-none tracking-tight",a),...t}));ze.displayName="CardTitle";const Le=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Le.displayName="CardDescription";const Oe=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("p-6 pt-0",a),...t}));Oe.displayName="CardContent";const Ue=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex items-center p-6 pt-0",a),...t}));Ue.displayName="CardFooter";const qe=Z.forwardRef(({className:a,orientation:t="horizontal",decorative:s=!0,...r},n)=>e.jsx(te.Root,{ref:n,decorative:s,orientation:t,className:Pe("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",a),...r}));qe.displayName=te.Root.displayName;const $e=ae.Root,Be=ae.Trigger,We=ae.Portal,Ve=ae.Close,He=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t}));He.displayName=ae.Overlay.displayName;const Ge={sm:"sm:max-w-[420px]",md:"sm:max-w-lg",lg:"sm:max-w-2xl",xl:"sm:max-w-4xl",full:"max-w-[85vw]"},Qe=Z.forwardRef(({className:a,children:t,size:s="md",...r},n)=>e.jsxs(We,{children:[e.jsx(He,{}),e.jsxs(ae.Content,{ref:n,className:Pe("fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-[85vw] max-h-[85vh] 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%] sm:rounded-lg",Ge[s],a),...r,children:[t,e.jsxs(ae.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"})]})]})]}));Qe.displayName=ae.Content.displayName;const Ke=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Ke.displayName="DialogHeader";const Xe=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Xe.displayName="DialogBody";const Je=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Je.displayName="DialogFooter";const Ye=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Ye.displayName=ae.Title.displayName;const Ze=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Ze.displayName=ae.Description.displayName;const ea=p.FormProvider,aa=Z.createContext({}),ta=()=>{const e=Z.useContext(aa),a=Z.useContext(sa),{getFieldState:t,formState:s}=p.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},sa=Z.createContext({}),ra=Z.forwardRef(({className:a,...t},s)=>{const r=Z.useId();return e.jsx(sa.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Pe("space-y-2",a),...t})})});ra.displayName="FormItem";const na=Z.forwardRef(({className:a,...t},s)=>{const{error:r,formItemId:n}=ta();return e.jsx(Re,{ref:s,className:Pe(r&&"text-destructive",a),htmlFor:n,...t})});na.displayName="FormLabel";const ia=Z.forwardRef(({...a},s)=>{const{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=ta();return e.jsx(t.Slot,{ref:s,id:n,"aria-describedby":r?`${i} ${o}`:`${i}`,"aria-invalid":!!r,...a})});ia.displayName="FormControl";const oa=Z.forwardRef(({className:a,...t},s)=>{const{formDescriptionId:r}=ta();return e.jsx("p",{ref:s,id:r,className:Pe("text-sm text-muted-foreground",a),...t})});oa.displayName="FormDescription";const la=Z.forwardRef(({className:a,children:t,...s},r)=>{const{error:n,formMessageId:i}=ta(),o=n?String(n?.message):t;return o?e.jsx("p",{ref:r,id:i,className:Pe("text-sm font-medium text-destructive",a),...s,children:o}):null});la.displayName="FormMessage";const da=se.Root,ca=se.Group,ua=se.Value,ma=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Trigger,{ref:r,className:Pe("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",a),...s,children:[t,e.jsx(se.Icon,{asChild:!0,children:e.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ma.displayName=se.Trigger.displayName;const pa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollUpButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronUp,{className:"h-4 w-4"})}));pa.displayName=se.ScrollUpButton.displayName;const ha=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.ScrollDownButton,{ref:s,className:Pe("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(d.ChevronDown,{className:"h-4 w-4"})}));ha.displayName=se.ScrollDownButton.displayName;const xa=Z.forwardRef(({className:a,children:t,position:s="popper",container:r,collisionBoundary:n,...i},o)=>e.jsx(se.Portal,{container:r,children:e.jsxs(se.Content,{ref:o,className:Pe("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",a),position:s,collisionBoundary:n,...i,children:[e.jsx(pa,{}),e.jsx(se.Viewport,{className:Pe("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(ha,{})]})}));xa.displayName=se.Content.displayName;const fa=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Label,{ref:s,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...t}));fa.displayName=se.Label.displayName;const ga=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(se.Item,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...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:t})]}));ga.displayName=se.Item.displayName;const ba=Z.forwardRef(({className:a,...t},s)=>e.jsx(se.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));ba.displayName=se.Separator.displayName;const va=Z.forwardRef(({className:a,...t},s)=>e.jsx(re.Root,{ref:s,className:Pe("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",a),...t,children:e.jsx(re.Indicator,{className:Pe("flex items-center justify-center text-current"),children:e.jsx(d.Check,{className:"h-4 w-4"})})}));va.displayName=re.Root.displayName;const ya=Z.forwardRef(({className:a,...t},s)=>e.jsx("textarea",{className:Pe("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",a),ref:s,...t}));ya.displayName="Textarea";const ja=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"}}),Na=Z.forwardRef(({className:a,variant:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(ja({variant:t}),a),...s}));Na.displayName="Badge";const wa={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ca({size:a="md",className:t}){return e.jsx(d.Loader2,{className:Pe("animate-spin text-muted-foreground",wa[a],t)})}const ka=({...a})=>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"}},...a}),Sa=ne.Root,Pa=ne.Trigger,Ta=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,container:r,...n},i)=>e.jsx(ne.Portal,{container:r,children:e.jsx(ne.Content,{ref:i,align:t,sideOffset:s,className:Pe("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",a),...n})}));Ta.displayName=ne.Content.displayName;const Ia=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ia.displayName="Command";const _a=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Pe("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",a),...t})}));_a.displayName="CommandInput";const Aa=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Aa.displayName="CommandList";const Ea=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("py-6 text-center text-sm text-muted-foreground",a),...t}));Ea.displayName="CommandEmpty";const Ma=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("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",a),...t}));Ma.displayName="CommandGroup";const Ra=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("-mx-1 h-px bg-border",a),...t}));Ra.displayName="CommandSeparator";const Da=Z.forwardRef(({className:a,disabled:t,onSelect:s,value:r,...n},i)=>e.jsx("div",{ref:i,className:Pe("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",a),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Da.displayName="CommandItem";const Fa=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});function za({className:a,...t}){return e.jsx("div",{className:Pe("animate-pulse rounded-md bg-muted",a),...t})}Fa.displayName="CommandShortcut";const La=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Oa({multiple:t,options:s,value:r,onChange:n,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:x,className:f,sortOptions:b,maxDisplayedBadges:v,popoverContainer:y,onOpen:j,onClose:N}){const{t:w}=g.useTranslation(),[C,k]=a.useState(!1),[S,P]=a.useState(""),T=a.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=a.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),_=a.useMemo(()=>{const e=s.map(e=>({original:e,value:i(e),label:o(e)}));return b?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[s,i,o,b]),A=a.useMemo(()=>{if(!S)return _;const e=La(S);return _.filter(a=>La(a.label).includes(e))},[_,S]),E=a.useMemo(()=>_.filter(e=>T.includes(e.value)),[_,T]),M=(e,a)=>{a.preventDefault(),a.stopPropagation(),n&&n(t?T.filter(a=>a!==e):"")},R=v?E.slice(0,v):E,D=v&&E.length>v?E.length-v:0;return e.jsxs("div",{className:Pe("space-y-2",f),children:[c&&e.jsxs(Re,{children:[c,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Sa,{open:C,onOpenChange:e=>{k(e),e?j?.():(P(""),N?.())},modal:!1,children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":C,disabled:h,className:Pe("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]}):t?e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(a=>e.jsxs(Na,{variant:"secondary",className:"gap-1 pr-1",children:[a.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(a.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(a.value,e),children:e.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},a.value)),D>0&&e.jsxs(Na,{variant:"outline",className:"gap-1",children:["+",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(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ta,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:e.jsxs(Ia,{children:[e.jsx(_a,{placeholder:p,value:S,onChange:e=>P(e.target.value)}),e.jsx(Aa,{children:0===s.length?e.jsx(Ea,{children:m}):0===A.length?e.jsx(Ea,{children:w("no_results")}):e.jsx(Ma,{children:A.map(a=>e.jsxs(Da,{value:a.value,onSelect:()=>(e=>{if(n)if(t){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];n(a)}else n(e),k(!1)})(a.value),className:"cursor-pointer",children:[e.jsx(d.Check,{className:Pe("mr-2 h-4 w-4",T.includes(a.value)?"opacity-100":"opacity-0")}),a.label]},a.value))})})]})})]})]})}function Ua({multiple:a=!1,options:t,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:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:b=!1,error:v,className:y,sortOptions:j=!0,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k}){const{t:S}=g.useTranslation(),P=s||t||[],T=i||n,I=c||S("select_placeholder"),_=p||S("no_results"),A=h||S("search_placeholder");if(b)return e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(za,{className:"h-10 w-full"})]});const E="string"==typeof v?v:v instanceof Error?v.message:v?"Erro ao carregar dados":void 0;return E?e.jsxs("div",{className:Pe("space-y-2",y),children:[u&&e.jsxs(Re,{children:[u,f&&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(Oa,{multiple:a,options:P,value:r||(a?[]:""),onChange:T,getOptionValue:o,getOptionLabel:l,placeholder:I,label:u,icon:m,emptyMessage:_,searchPlaceholder:A,disabled:x,required:f,className:y,sortOptions:j,maxDisplayedBadges:N,popoverContainer:w,onOpen:C,onClose:k})}var qa=Object.defineProperty;class $a{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}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),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),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:t,errors:s}}let i=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.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";t.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:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,a,t)=>{a in e?qa(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})($a,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Ba="qualiex_access_token",Wa="qualiex_id_token",Va="supabase_token",Ha="oauth_state",Ga="oauth_nonce",Qa="selected_alias",Ka="manual_logout",Xa={setAccessToken:e=>localStorage.setItem(Ba,e),getAccessToken:()=>localStorage.getItem(Ba),setIdToken:e=>localStorage.setItem(Wa,e),getIdToken:()=>localStorage.getItem(Wa),getSupabaseToken:()=>localStorage.getItem(Va),setOAuthState:e=>sessionStorage.setItem(Ha,e),getOAuthState:()=>sessionStorage.getItem(Ha),clearOAuthState:()=>sessionStorage.removeItem(Ha),setOAuthNonce:e=>sessionStorage.setItem(Ga,e),getOAuthNonce:()=>sessionStorage.getItem(Ga),clearOAuthNonce:()=>sessionStorage.removeItem(Ga),setSelectedAlias:e=>localStorage.setItem(Qa,e),getSelectedAlias:()=>localStorage.getItem(Qa),clearSelectedAlias:()=>localStorage.removeItem(Qa),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(Va,e),Xa._clearValidationCache()},areAllTokensValid:()=>{const e=Xa.getAccessToken(),a=Xa.getIdToken();if(!e||!a)return!1;try{const t=$a.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=Xa.getAccessToken(),t=Xa.getIdToken(),s=Xa.getSupabaseToken();return a&&Xa.isTokenExpired(a)&&(localStorage.removeItem(Ba),e=!0),t&&Xa.isTokenExpired(t)&&(localStorage.removeItem(Wa),e=!0),s&&Xa.isTokenExpired(s)&&(localStorage.removeItem(Va),e=!0),e},clearAll:()=>{localStorage.removeItem(Ba),localStorage.removeItem(Wa),localStorage.removeItem(Va),localStorage.removeItem(Qa),localStorage.removeItem(Ka),sessionStorage.removeItem(Ha),sessionStorage.removeItem(Ga)},setManualLogout:()=>localStorage.setItem(Ka,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ka),clearManualLogout:()=>localStorage.removeItem(Ka),isTokenExpired:e=>{try{return $a.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 a=Date.now();return a-Xa._validationCache.timestamp<Xa._validationCache.cacheValidityMs?Xa._validationCache.isValid:(Xa._validationCache.isValid=!0,Xa._validationCache.timestamp=a,!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 a=$a.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return Xa._handleExpiredToken(),null}},getCompanyId:e=>{const a=Xa.getAccessToken();if(a)try{const t=$a.parseJwtPayload(a);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 a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=Xa.extractTokenData();if(t?.companyId)return t.companyId;const s=Xa.getIdToken();if(s)try{const a=$a.parseJwtPayload(s);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 a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Xa.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Xa.getIdToken();if(!e)return[];try{const a=$a.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};var Ja=Object.defineProperty,Ya=(e,a,t)=>((e,a,t)=>a in e?Ja(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Za=new class{constructor(){Ya(this,"errors",[]),Ya(this,"toastCount",0),Ya(this,"lastToastTime",0)}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);l.toast.error(e,{description:t})}}getErrorTitle(e){const a=e.toLowerCase();return a.includes("401")||a.includes("unauthorized")||a.includes("expirou")?"Sessão Expirada":a.includes("token")||a.includes("autenticação")?"Erro de Autenticação":a.includes("api")||a.includes("network")?"Erro de Conexão":"Erro"}success(e,a){l.toast.success(e,{description:a})}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 et=Object.defineProperty,at=(e,a,t)=>((e,a,t)=>a in e?et(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const tt=(void 0).VITE_SUPABASE_URL,st=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY,rt=class e{constructor(){at(this,"client"),at(this,"currentToken",null),at(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:st};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return b.createClient(tt,st,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("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,a)}})}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 a=JSON.parse(atob(e.split(".")[1])),t=Math.floor(Date.now()/1e3);return a.exp>t}catch(a){return Za.handleError(a instanceof Error?a:"❌ Supabase - Error validating token",!1),!1}}};at(rt,"instance");let nt=rt;function it(){return nt.getInstance().getClient()}class ot{static async generateToken(e,a,t,s=!1){try{if(!s){const e=Xa.getSupabaseToken();if(e&&Xa.isSupabaseTokenValid())return e}const r=it(),{data:n,error:i}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(t?.(),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"))&&t?.(),null}}}var lt=Object.defineProperty,dt=(e,a,t)=>((e,a,t)=>a in e?lt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);class ct{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Xa.getAccessToken(),a=Xa.getSelectedAlias();if(!e||!a)return null;const t=await ot.generateToken(e,a,this.onLogoutCallback||void 0,!1);return t?(Xa.setSupabaseToken(t),t):null}catch(e){return null}finally{this.isRegenerating=!1}}}dt(ct,"isRegenerating",!1),dt(ct,"onLogoutCallback",null);class ut{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(Xa.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}var mt=Object.defineProperty;class pt{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await ct.attemptRegeneration()?(this.isRetrying=!1,!0):(ut.handleError(e),this.isRetrying=!1,!1)}catch(s){return ut.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,a,t)=>{((e,a,t)=>{a in e?mt(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t})(e,a+"",t)})(pt,"isRetrying",!1);var ht=Object.defineProperty,xt=(e,a,t)=>((e,a,t)=>a in e?ht(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const ft=new class{constructor(){xt(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.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(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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,a){try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];s=t}if(!Array.isArray(s))return Za.handleError("[QualiexApi] Resposta não é um array",!1),[];return s.map(this.mapToQualiexUser)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:a,search:"",filterStatus:"active"},e);let s=t;if(t.data)s=t.data;else{if(!Array.isArray(t))return Za.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];s=t}return Array.isArray(s)?s.map(this.mapToQualiexUser):(Za.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar usuários após renovação de token",!0),[]}const r=t instanceof Error?t.message:"Erro ao buscar usuários da API Qualiex";return Za.handleError(r,!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return Za.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a),s=new Map;return t.forEach(e=>{s.set(e.userId,e)}),s}async getUsers(e){const a=Xa.extractTokenData();return a&&a.companyId?this.fetchUsers(e,a.companyId):[]}async getAllUsers(e){return this.getUsers(e)}},gt={oauth:{authUrl:(void 0).VITE_OAUTH_AUTH_URL,clientId:(void 0).VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},bt={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},vt={debounceDelay:500},yt=()=>{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},jt={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Nt=()=>jt,wt={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},Ct={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 kt(e,a){const t=Nt(),s=a||t.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function St(e,a){const t=Nt(),s=a||t.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Pt(e,a){const t=Nt(),s=a||t.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,s):`${e}${s}`}function Tt(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||kt(e.idField),emailField:e.emailField||St(e.idField),usernameField:e.usernameField||Pt(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:kt(e),emailField:St(e),usernameField:Pt(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const It=new Map;class _t{static async fetchQualiexUsers(e,a){const t=`${a}_${e}`,s=It.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await ft.fetchUsers(e,a);return It.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);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,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!Xa.areAllTokensValid())return e;const t=Xa.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=Tt(a.userIdFields,a.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(t){return Za.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,a){return this.enrichWithUserData(e,{entityName:a.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const At=["responsible_name"],Et=e=>At.includes(e);function Mt(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"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 it().schema(o).from(r)},u=(e,a,t,s)=>{let r=c().select(i||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const o=a.includes(".");return o||Et(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:o}},m=async(e,a,t,r,n)=>{const i=Tt(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),o=a.includes(".");if(Et(a)||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 _t.enrichWithUserData(i.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=o?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",i=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?i:-i}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",i=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?i:-i}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t,n=e.slice(s,r);return{data:n,pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:n.length,totalCount:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>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 _t.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})};return{async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:i,limit:o,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...i}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:i}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,i,o),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let b=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,i,o);if((e=>{if(!d||!l||0===e.length)return!1;const a=Tt(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(b.data)){const e=await m(b.data,t,n,i,o);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:a,error:t}=await c().select(i||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Te(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).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,a){const t={...Te(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).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 a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}}}const Rt=()=>{Xa.clearManualLogout()},Dt=e=>e?.placeId||null,Ft=e=>e?.placeName||null,zt=e=>({placeId:Dt(e),placeName:Ft(e)}),Lt=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 a=Xa.getAccessToken(),t=Xa.getIdToken();Rt();const s=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),n=this.extractAliasFromAccessToken(a),i=Xa.extractTokenData(),o=i?.alias;let l=null;if(o&&r.some(e=>e.alias===o))l=o;else{const e=Xa.getSelectedAlias(),a=e&&r.some(a=>a.alias===e);l=a?e:n||r[0]?.alias||null}!Xa.isSupabaseTokenValid()&&l&&await ct.attemptRegeneration();let d=null;if(l){const e=Xa.getCompanyId(l),a=r.find(e=>e.alias===l);a&&(d={id:e||a.id,name:a.name,alias:a.alias})}let c=null,u=null;if(s?.id&&l){const a=Xa.getCompanyId(l);if(a)try{const e=(await ft.fetchActiveUsersMap(l,a)).get(s.id);if(e){const a=zt(e);c=a.placeId,u=a.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=it(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.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 a=Xa.generateOAuthNonce();Xa.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(gt.oauth.authUrl);s.searchParams.set("client_id",gt.oauth.clientId),s.searchParams.set("response_type",gt.oauth.responseType),s.searchParams.set("scope",gt.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),s.searchParams.set("response_mode","fragment"),yt(),window.location.href=s.toString()}static async processCallback(){try{if(Xa.hasAllTokens()){if(!Xa.getValidSupabaseToken()){Xa.getAccessToken();await ct.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("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),Rt();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 ct.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(),window.location.href="/login"}static decodeToken(e){return $a.parseJwtPayload(e)}static extractUserFromIdToken(e){const a=this.decodeToken(e);return a?{id:a.subNewId,email:a.email,name:a.name,identifier:a.identifier}:null}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}};ct.setLogoutCallback(()=>{Lt.logout()});let Ot=Lt;const Ut=a.createContext(void 0),qt=({children:t})=>{const[s,r]=a.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[i,o]=a.useState(!1),[l,d]=a.useState(0),c=a.useCallback(e=>{r(a=>({...a,...e}))},[]),u=a.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),m=a.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=a.useCallback(async e=>{try{u(!0);const t=Xa.getAccessToken();if(!t)return;const r=await ot.generateToken(t,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,p=null;if(s.user?.id&&o&&l)try{const e=(await ft.fetchActiveUsersMap(o,l)).get(s.user.id);if(e){const a=zt(e);m=a.placeId,p=a.placeName}}catch(a){}c({alias:o,selectedUnit:d,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(a){}finally{u(!1)}},[c,n,u,s.user]),h=a.useCallback(async()=>await Ot.processCallback(),[]),x=a.useCallback(async()=>{Ot.logout(),m(),n&&await n.clear()},[m,n]),f=a.useCallback(e=>{o(e)},[]),g=a.useCallback(()=>{d(e=>e+1)},[]),b=a.useCallback(()=>{d(e=>e+1)},[]);a.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(()=>{e&&(Xa.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,x]),a.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Ot.initialize();if(!e)return;a&&a.isAuthenticated?c({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&u(!1)}catch(a){e&&(ut.handleError(a),u(!1))}})(),()=>{e=!1}},[c,u,x]);const y=a.useMemo(()=>({...s,logout:x,processCallback:h,switchUnit:p,availableUnits:s.companies,isSearchVisible:i,setSearchVisible:f,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,x,h,p,i,f,g,b]);return e.jsx(Ut.Provider,{value:y,children:t})},$t=()=>{const e=a.useContext(Ut);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Bt({queryKey:e,service:t,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:i}){const[o,d]=y.useSearchParams(),c=v.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=$t(),h=a.useCallback(a=>{const t=`${e}_${a}`,s=o.get(t);return s||(o.get(a)||"")},[o,e]),x=h("search"),f=h("sortField")||bt.sorting.defaultField,g=h("sortDirection")||bt.sorting.defaultDirection,b=parseInt(h("page")||"1"),j=parseInt(h("limit")||String(bt.pagination.defaultPageSize)),N=x,w=a.useMemo(()=>({search:N,sortField:f,sortDirection:g,page:b,limit:j,...n}),[N,f,g,b,j,n]),C=a.useCallback(()=>t.getAll(w),[t,w]),k=v.useQuery({queryKey:[e,u,m,w],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:t.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.created(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.create(s)}: ${e.message}`)}}),P=v.useMutation({mutationFn:({id:e,data:a})=>t.update(e,a),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.updated(s)),i?.()},onError:e=>{l.toast.error(`${Ct.error.update(s)}: ${e.message}`)}}),T=v.useMutation({mutationFn:t.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(Ct.success.deleted(s))},onError:e=>{l.toast.error(`${Ct.error.delete(s)}: ${e.message}`)}}),I=a.useCallback(a=>{const t={...Object.fromEntries(o)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[o,d,e]),_=a.useCallback(e=>{I({search:e,page:1})},[I]),A=a.useCallback(e=>{I({sortField:e,sortDirection:f===e&&"asc"===g?"desc":"asc",page:1})},[f,g,I]),E=a.useCallback(e=>{I({page:e})},[I]),M=a.useCallback(e=>{I({limit:e,page:1})},[I]),R=a.useCallback(()=>{const a=Object.fromEntries(o),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,o,e]),[D,F]=a.useState([]),z=a.useCallback(e=>{F(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=a.useCallback(()=>{const e=k?.data?.data.map(e=>e.id)||[];F(a=>a.length===e.length?[]:e)},[k?.data?.data]),O=a.useCallback(()=>{F([])},[]),U=a.useMemo(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,k?.data?.data]),q=v.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(`${t.length} ${s}(s) deletado(s) com sucesso`),O()},onError:e=>{l.toast.error(`Erro ao deletar itens: ${e.message}`)}}),$=a.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):S.mutate({...t,alias:u})},[u,S,P]);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||bt.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:S?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:T?.isPending??!1,error:k?.error||null,searchTerm:x,sortField:f,sortDirection:g,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:S.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:T.mutate,save:$,handleSearch:_,handleSort:A,handlePageChange:E,handleItemsPerPageChange:M,clearFilters:R,refetch:k.refetch,selectedIds:D,selectItem:z,selectAll:L,clearSelection:O,isAllSelected:U,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}const Wt=Z.forwardRef(({className:a,...t},s)=>e.jsx("table",{ref:s,className:Pe("w-full caption-bottom text-sm table-fixed",a),...t}));Wt.displayName="Table";const Vt=Z.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:Pe("[&_tr]:border-b sticky top-0 z-[1] bg-background",a),...t}));Vt.displayName="TableHeader";const Ht=Z.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:Pe("[&_tr:last-child]:border-0",a),...t}));Ht.displayName="TableBody";const Gt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:Pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...t}));Gt.displayName="TableFooter";const Qt=Z.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:Pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",a),...t}));Qt.displayName="TableRow";const Kt=Z.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:Pe("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",a),...t}));Kt.displayName="TableHead";const Xt=Z.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:Pe("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",a),...t}));Xt.displayName="TableCell";const Jt=Z.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:Pe("mt-4 text-sm text-muted-foreground",a),...t}));function Yt({rows:a=5,columns:t=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:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-24"},t))})}),e.jsx("div",{children:Array.from({length:a}).map((a,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:t}).map((a,t)=>e.jsx(za,{className:"h-4 w-20"},t))})},s))})]})})}function Zt({count:a=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:a}).map((a,t)=>e.jsxs(De,{children:[e.jsxs(Fe,{children:[e.jsx(za,{className:"h-4 w-3/4"}),e.jsx(za,{className:"h-3 w-1/2"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-3 w-full"}),e.jsx(za,{className:"h-3 w-2/3"})]})})]},t))})}Jt.displayName="TableCaption";const es={default:d.FileX,search:d.Search,error:d.AlertCircle};function as({icon:a,title:t,description:s,action:r,className:n,variant:i="default"}){const o=a?()=>a:es[i];return e.jsxs("div",{className:Pe("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:t}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(_e,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ts=ie.Provider,ss=ie.Root,rs=ie.Trigger,ns=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:t,className:Pe("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",a),...s}));function is({children:a,className:t}){const s=Z.useRef(null),[r,n]=Z.useState(!1);Z.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[a]);const i=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:a});return r?e.jsx(ts,{delayDuration:300,children:e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:i}),e.jsx(ns,{side:"top",className:"max-w-[400px] break-words",children:a})]})}):i}ns.displayName=ie.Content.displayName;const os=Z.forwardRef(({direction:a,onMouseDown:t,isDragging:s,className:r},n)=>{const i="horizontal"===a;return e.jsx("div",{ref:n,onMouseDown:t,className:Pe("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:Pe("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",i?"h-6 w-0.5":"w-6 h-0.5")})})});os.displayName="TableResizeHandle";const ls=oe.Root,ds=oe.Trigger,cs=oe.Group,us=oe.Portal,ms=oe.Sub,ps=oe.RadioGroup,hs=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Pe("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));hs.displayName=oe.SubTrigger.displayName;const xs=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.SubContent,{ref:s,className:Pe("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",a),...t}));xs.displayName=oe.SubContent.displayName;const fs=Z.forwardRef(({className:a,sideOffset:t=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:t,className:Pe("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",a),...s})}));fs.displayName=oe.Content.displayName;const gs=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Item,{ref:r,className:Pe("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",t&&"pl-8",a),...s}));gs.displayName=oe.Item.displayName;const bs=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Pe("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",a),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(oe.ItemIndicator,{children:e.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));bs.displayName=oe.CheckboxItem.displayName;const vs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Pe("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",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));vs.displayName=oe.RadioItem.displayName;const ys=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(oe.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));ys.displayName=oe.Label.displayName;const js=Z.forwardRef(({className:a,...t},s)=>e.jsx(oe.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));js.displayName=oe.Separator.displayName;const Ns=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest opacity-60",a),...t});Ns.displayName="DropdownMenuShortcut";const ws=le.Root,Cs=le.Trigger,ks=le.Group,Ss=le.Portal,Ps=le.Sub,Ts=le.RadioGroup,Is=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(le.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Is.displayName=le.SubTrigger.displayName;const _s=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.SubContent,{ref:s,className:Pe("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",a),...t}));_s.displayName=le.SubContent.displayName;const As=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Portal,{children:e.jsx(le.Content,{ref:s,className:Pe("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",a),...t})}));As.displayName=le.Content.displayName;const Es=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Item,{ref:r,className:Pe("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",t&&"pl-8",a),...s}));Es.displayName=le.Item.displayName;const Ms=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(le.CheckboxItem,{ref:n,className:Pe("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",a),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"})})}),t]}));Ms.displayName=le.CheckboxItem.displayName;const Rs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(le.RadioItem,{ref:r,className:Pe("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",a),...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"})})}),t]}));Rs.displayName=le.RadioItem.displayName;const Ds=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(le.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",a),...s}));Ds.displayName=le.Label.displayName;const Fs=Z.forwardRef(({className:a,...t},s)=>e.jsx(le.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-border",a),...t}));Fs.displayName=le.Separator.displayName;const zs=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});zs.displayName="ContextMenuShortcut";const Ls=({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:i=[],renderAs:o})=>{const{t:l}=g.useTranslation(),c=[];if(a){const e={icon:d.Edit,label:l("edit"),onClick:a};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&&t){const e={icon:d.Trash2,label:l("delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===o?gs:Es;return e.jsx(e.Fragment,{children:c.map((a,t)=>e.jsxs(u,{onClick:a.onClick,className:Pe("whitespace-normal cursor-pointer",a.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(a.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.label]},t))})},Os=({onEdit:a,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:i=[]})=>e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(d.EllipsisVertical,{size:12})})}),e.jsx(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(Ls,{onEdit:a?e=>{e?.stopPropagation(),a?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:i,renderAs:"dropdown"})})]}),Us=150;function qs({columns:e,storageKey:t,onResize:s,enabled:r=!0}){const[n,i]=a.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});if(t){const e=localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{})}),[o,l]=a.useState(!1),[d,c]=a.useState(null),u=a.useRef(0),m=a.useRef(0),p=a.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??Us)},[r,n]);a.useEffect(()=>{if(!o||!d)return;const a=e.find(e=>e.key===d),r=a?.minWidth??60,n=a?.maxWidth??500,p=e=>{const a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));i(e=>{const a={...e,[d]:t};return s?.(a),a})},h=()=>{l(!1),c(null),t&&i(e=>(localStorage.setItem(t,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[o,d,e,t,s]),a.useEffect(()=>{o?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[o]);const h=a.useCallback(()=>{const a=e.reduce((e,a)=>(e[a.key]=a.defaultWidth??Us,e),{});i(a),t&&localStorage.removeItem(t),s?.(a)},[e,t,s]);return{columnWidths:n,isDragging:o,activeColumn:d,handleMouseDown:p,resetWidths:h}}function $s({rowIds:e,defaultHeight:t=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:i,enabled:o=!0}){const[l,d]=a.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]=a.useState(!1),[m,p]=a.useState(null),h=a.useRef(0),x=a.useRef(0),f=a.useCallback(e=>l[e]??t,[l,t]),g=a.useCallback((e,a)=>{o&&(a.preventDefault(),a.stopPropagation(),u(!0),p(e),h.current=a.clientY,x.current=l[e]??t)},[o,l,t]);a.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return i?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,i]),a.useEffect(()=>{c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[c]);const b=a.useCallback(()=>{d({}),n&&localStorage.removeItem(n),i?.({})},[n,i]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:f}}const Bs=a.memo(({checked:a,onCheckedChange:t})=>e.jsx(va,{checked:a,onCheckedChange:t}),(e,a)=>e.checked===a.checked),Ws=({manager:t,columns:s,onEdit:r,onView:n,onToggleStatus:i,onDelete:o,renderActions:l,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f=!1,enableColumnResize:b=!0,resizeStorageKey:v})=>{const{t:y}=g.useTranslation(),{setSearchVisible:j}=$t(),[N,w]=a.useState(!1);a.useEffect(()=>(j(!0),()=>j(!1)),[j]),a.useEffect(()=>{const e=()=>w(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:P}=qs({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:v?`${v}-columns`:void 0,enabled:b}),{isDragging:T,activeRow:I,handleMouseDown:_,getRowHeight:A}=$s({rowIds:t.entities.map(e=>e.id),storageKey:v?`${v}-rows`:void 0,enabled:!1}),E=a.useMemo(()=>(()=>{if(b)return s.map(e=>{const a=C[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:a,style:{width:`${a}px`}}});let e=0;const a=s.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,b,C]),M=!f&&(m||x.length>0);return N?t.isLoading?e.jsx(Zt,{count:3}):0===t.entities.length?e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&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&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:t.entities.map(a=>e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsx(De,{className:Pe("overflow-hidden cursor-pointer hover:bg-muted/50",u&&t.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},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:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(t=>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:[t.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(a):String(a[t.key]??"")})]},String(t.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):e.jsx(Os,{onEdit:r?()=>{r(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})]})})})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[M&&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&&h&&e.jsxs(_e,{onClick:m,children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),p||y("new")]}),x.map((a,t)=>{const s=a.icon;return e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[s&&e.jsx(s,{size:16,className:"mr-2"}),a.label]},t)})]})}),t.isLoading?e.jsx(Yt,{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(Wt,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),E.map((a,t)=>e.jsx("col",{style:a.style},t)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Vt,{children:e.jsxs(Qt,{children:[u&&e.jsx(Kt,{className:"w-[50px]",children:e.jsx(Bs,{checked:t.isAllSelected,onCheckedChange:t.selectAll})}),s.map(a=>{const s=b&&!1!==a.resizable,r=S===String(a.key);return e.jsxs(Kt,{className:Pe(a.className,a.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:a.sortable?()=>t.handleSort(String(a.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(a.className?.includes("text-center")?"justify-center":""),children:[a.header,a.sortable&&(n=String(a.key),t.sortField!==n?e.jsx(d.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===t.sortDirection?e.jsx(d.ArrowUp,{size:14,className:"ml-1"}):e.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>P(String(a.key),e),isDragging:r})]},String(a.key));var n}),e.jsx(Kt,{className:"w-[50px] text-center",children:y("actions")})]})}),e.jsx(Ht,{children:0===t.entities.length?e.jsx(Qt,{children:e.jsx(Xt,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(as,{title:y("empty_title"),description:y("empty_description"),variant:"search"})})}):t.entities.map(a=>{const n=A(a.id);return a.id,e.jsxs(ws,{children:[e.jsx(Cs,{asChild:!0,children:e.jsxs(Qt,{className:Pe("cursor-pointer hover:bg-muted/50 relative",u&&t.selectedIds.includes(a.id)&&"bg-muted"),style:n?{height:`${n}px`}:void 0,onClick:e=>{e.stopPropagation(),u?t.selectItem(a.id):r?.(a)},children:[u&&e.jsx(Xt,{onClick:e=>e.stopPropagation(),children:e.jsx(Bs,{checked:t.selectedIds.includes(a.id),onCheckedChange:()=>t.selectItem(a.id)})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"")})},String(t.key))),e.jsx(Xt,{className:"text-center",children:l?l(a):e.jsx(Os,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,customActions:c?c(a):[]})})]})}),e.jsx(As,{className:"w-[160px]",children:e.jsx(Ls,{onEdit:r?()=>r(a):void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:i?()=>i(a):void 0,isActive:a.is_actived,canDelete:!!o,customActions:c?c(a):[],renderAs:"context"})})]},a.id)})})]})})})]})};function Vs(e,t,s,r){const[n,i]=a.useState({}),[o,l]=a.useState({}),d=a.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,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.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(a,t);if(e)return e}catch(s){}}};a.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},a=e(d),n={};a.forEach(e=>{let a;if(t&&void 0!==t[e.name]){if(a=t[e.name],null==a&&(a=""),"date"===e.type&&a)if("string"==typeof a){const e=new Date(a);c(e)&&(a=e.toISOString().split("T")[0])}else c(a)&&(a=a.toISOString().split("T")[0])}else a=u(e);n[e.name]=a}),a.forEach(e=>{const a=m(e,n);void 0!==a&&(n[e.name]=a)}),t&&Object.keys(t).forEach(e=>{a.find(a=>a.name===e)||void 0===t[e]||(n[e]=t[e])}),i(n),l({}),s&&s(n)},[d,t,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:o,updateField:(e,a)=>{i(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),o[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Hs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Gs=({value:a="#3b82f6",onChange:t,label:s})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Re,{children:s}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{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:a}}),a]})}),e.jsx(Ta,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{htmlFor:"color-input",children:"Cor personalizada"}),e.jsx(Ee,{id:"color-input",type:"color",value:a,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:"Cores predefinidas"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Hs.map(a=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:a},onClick:()=>t?.(a),"aria-label":`Selecionar cor ${a}`},a))})]})]})})]})]}),Qs=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(de.Root,{ref:r,className:Pe("relative overflow-hidden",a),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(Ks,{}),e.jsx(de.Corner,{})]}));Qs.displayName=de.Root.displayName;const Ks=Z.forwardRef(({className:a,orientation:t="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:t,className:Pe("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ks.displayName=de.ScrollAreaScrollbar.displayName;const Xs={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},Js=({value:t="Star",onChange:s,label:r})=>{const{t:n}=g.useTranslation(),[i,o]=a.useState(""),l=Object.entries(Xs).filter(([e])=>e.toLowerCase().includes(i.toLowerCase())),c=Xs[t]||d.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Re,{children:r}),e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),t]})}),e.jsx(Ta,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Re,{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(([a,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(t===a?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(a),title:a,children:e.jsx(r,{className:"h-4 w-4"})},a))})})]})})]})]})},Ys=Z.forwardRef(({className:a,...t},s)=>e.jsx(ce.Root,{className:Pe("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",a),...t,ref:s,children:e.jsx(ce.Thumb,{className:Pe("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")})}));Ys.displayName=ce.Root.displayName;const Zs=(e={})=>{const{user:a,alias:t}=$t(),{enabled:s=!0}=e;return v.useQuery({queryKey:["qualiex-users",t],queryFn:()=>ft.getUsers(t),enabled:s&&!!t&&!!a,retry:2,retryDelay:1e3})},er=({value:t,onChange:s,multiple:r=!1,label:n,required:i,placeholder:o,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:x,sortOptions:f=!0,popoverContainer:b,onOpen:v,onClose:y})=>{const{t:j}=g.useTranslation(),{data:N=[],isLoading:w,error:C}=Zs({enabled:m}),k=a.useMemo(()=>x?N.filter(x):N,[N,x]),S=a.useCallback(e=>{if("custom"===p&&h)return h(e);const a=e.userName||e.displayName||"";switch(p){case"name-email":return e.userEmail?`${a} (${e.userEmail})`:a;case"name-role":return e.roleName?`${a} - ${e.roleName}`:a;default:return a}},[p,h]);return e.jsx(Ua,{multiple:r,value:t??(r?[]:""),onChange:s,options:k,isLoading:w,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:S,placeholder:o||j("search_placeholder"),searchPlaceholder:j("search_placeholder"),emptyMessage:j("no_results"),label:n,required:i,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:f,popoverContainer:b,onOpen:v,onClose:y})};function ar({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(s?.[0]?.id||""),h=a.useRef(null),[x,f]=a.useState(null),b=a.useCallback(e=>{h.current=e,f(e)},[]),v=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:y,errors:j,updateField:N,handleSubmit:w}=Vs(v,r,void 0,o),C=a.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(y):e.disabled||!1})):[],[s,y]),k=a.useMemo(()=>{const e=C.find(e=>e.id===m);if(e&&!e.disabled)return m;const a=C.find(e=>!e.disabled);return a?.id||m},[C,m]);a.useEffect(()=>{k!==m&&p(k)},[k,m]);const S=C.find(e=>e.id===k),P=a=>{const t=(a.computedValue,y[a.name]),s=void 0!==t?t:"",r=j[a.name];switch(a.type){case"group":const t="horizontal"===a.layout,n=t?`flex gap-3 w-full ${a.className||""}`:"space-y-3",i=t?Pe("space-y-2 w-full",a.wrapperClassName):Pe("space-y-2",a.className,a.wrapperClassName);return e.jsxs("div",{className:i,children:[a.label,e.jsx("div",{className:n,children:a.fields?.map(e=>P(e))})]},a.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s||"",onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,rows:a.rows,maxLength:a.maxLength,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:String(s),onValueChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,children:[e.jsx(ma,{className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(ua,{placeholder:a.placeholder})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>N(a.name,e),placeholder:a.placeholder,disabled:a.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"date":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"date",value:String(s),onChange:e=>N(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,className:Pe("w-full",r?"border-destructive":"",a.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"color",value:s||a.defaultValue||"#000000",onChange:e=>N(a.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s||a.defaultValue||"#3b82f6",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s||a.defaultValue||"Star",onChange:e=>N(a.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},a.name);case"custom":if(!a.component)return null;const o=a.component,l="function"==typeof a.componentProps?a.componentProps(y):a.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(o,{value:s,onChange:e=>{N(a.name,e),a.onValueChange&&a.onValueChange(e)},disabled:a.disabled,error:r,popoverContainer:x,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"number":return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const t=e.target.value,s=""===t?null:Number(t);N(a.name,s)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,min:a.min,step:a.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${a.className||""}`,children:[e.jsx(va,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),e.jsxs(Re,{htmlFor:a.name,className:"cursor-pointer",children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ys,{id:a.name,checked:!!s,onCheckedChange:e=>N(a.name,e),disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},a.name);default:return e.jsxs("div",{className:`space-y-2 ${a.className||""}`,children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"text",value:s||"",onChange:e=>{N(a.name,e.target.value)},placeholder:a.placeholder,disabled:a.disabled,className:`${r?"border-destructive":""} ${a.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},T=a.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 a=S.component;return e.jsx(a,{formData:y,updateField:N,errors:j,users:c,disabled:S.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:S.fields.map(P)})},[S,y,N,j,c,P]),I=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(a=>e.jsx(_e,{variant:k===a.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=C.find(a=>a.id===e);a&&!a.disabled&&p(e)})(a.id),disabled:a.disabled,className:a.disabled?"opacity-50 cursor-not-allowed":"",children:a.title},a.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-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:w(n),className:"space-y-3 md:space-y-4",children:[T(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(_e,{type:"button",variant:"outline",onClick:i,children:u("cancel")}),e.jsx(_e,{type:"submit",disabled:d,children:l||u("save")})]})]})})]});return e.jsx($e,{open:o,onOpenChange:e=>{!1===e&&!0===o&&i()},children:e.jsxs(Qe,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[e.jsx(Ye,{children:t}),e.jsx(Ze,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),I]})})}function tr({currentPage:a,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:i,variant:o="full"}){const l=(a-1)*r+1,c=Math.min(a*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(da,{value:String(r),onValueChange:e=>i(Number(e)),children:[e.jsx(ma,{className:"h-8 w-[70px]",children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"10",children:"10"}),e.jsx(ga,{value:"25",children:"25"}),e.jsx(ga,{value:"50",children:"50"}),e.jsx(ga,{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(_e,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===a,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsLeft,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a-1),disabled:1===a,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:a}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),e.jsx("span",{className:"text-sm font-medium",children:t})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(a+1),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronRight,{size:16})}),e.jsx(_e,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:a===t,className:"h-8 w-8 p-0",children:e.jsx(d.ChevronsRight,{size:16})})]})]})}function sr({manager:a}){return e.jsx(tr,{currentPage:a.pagination.currentPage,totalPages:a.pagination.totalPages,totalItems:a.pagination.totalItems,itemsPerPage:a.pagination.itemsPerPage,onPageChange:a.handlePageChange,onItemsPerPageChange:a.handleItemsPerPageChange,variant:"full"})}const rr=({selectedCount:a,onClearSelection:t,onBulkDelete:s,customActions:r=[],isLoading:n=!1})=>{const{t:i}=g.useTranslation();return 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:a})}),e.jsxs(_e,{variant:"ghost",size:"sm",onClick:t,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((a,t)=>{const s=a.icon;return e.jsxs(_e,{variant:a.variant||"outline",size:"sm",onClick:()=>a.action([]),disabled:n,className:"h-7",children:[s&&e.jsx(s,{size:14,className:"mr-1"}),a.label]},t)}),s&&e.jsxs(_e,{variant:"destructive",size:"sm",onClick:s,disabled:n,className:"h-7",children:[e.jsx(d.Trash2,{size:14,className:"mr-1"}),i("delete")]})]})]})},nr={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ir={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},or={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function lr({children:a,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:i=!1,className:o}){return e.jsx("div",{className:Pe("flex","column"===t?"flex-col":"flex-row",nr[s],ir[r],or[n],i&&"flex-wrap",o),children:a})}function dr({manager:a,filters:t,inline:s=!1}){const{t:r}=g.useTranslation(),{isSearchVisible:n}=$t(),i=a.searchTerm,o=e.jsxs(e.Fragment,{children:[t.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:a.searchTerm,onChange:e=>a.handleSearch(e.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((a,t)=>e.jsxs("select",{value:a.value||"",onChange:e=>a.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:[a.placeholder&&e.jsx("option",{value:"",children:a.placeholder}),a.options.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((a,t)=>{const r=a.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...a.props})},`custom-${t}`)}),i&&e.jsxs(_e,{variant:"outline",onClick:a.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(lr,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(lr,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function cr({manager:t,config:s,formSections:r,onSave:n,onToggleStatus:i,defaultSort:o}){t&&t.queryKey;const{t:l}=g.useTranslation(),{setSearchVisible:c}=$t(),[u,m]=y.useSearchParams(),[p,h]=a.useState(!1),[x,f]=a.useState(null),[b,v]=a.useState({isOpen:!1,entityId:null,entityName:""}),[j,N]=a.useState({isOpen:!1,count:0});a.useEffect(()=>(c(!0),()=>{c(!1)}),[c]),a.useEffect(()=>{if(o&&t){const e=`${t.queryKey}_sortField`,a=`${t.queryKey}_sortDirection`;if(!u.has(e)&&!u.has(a)){const t=Object.fromEntries(u);t[e]=o.column,t[a]=o.direction,m(t)}}},[]);const w=()=>{v({isOpen:!1,entityId:null,entityName:""})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[s.enableBulkActions&&t.selectedIds.length>0&&e.jsx(rr,{selectedCount:t.selectedIds.length,onClearSelection:t.clearSelection,onBulkDelete:s.bulkActions&&s.bulkActions.length>0?void 0:()=>{N({isOpen:!0,count:t.selectedIds.length})},customActions:s.bulkActions,isLoading:t.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:[e.jsxs(_e,{onClick:()=>{s.onNew?s.onNew():(f(null),h(!0))},children:[e.jsx(d.Plus,{size:16,className:"mr-2"}),l("new")]}),s.customActions?.map((a,t)=>e.jsxs(_e,{onClick:a.action,variant:a.variant||"outline",children:[a.icon&&e.jsx(a.icon,{size:16,className:"mr-2"}),a.label]},t))]}),s.filters&&s.filters.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:e.jsx(dr,{manager:t,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(t.entities,t)}):e.jsx(Ws,{manager:t,columns:s.columns,onEdit:e=>{s.onEdit?s.onEdit(e):(f(e),h(!0))},onDelete:e=>{v({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:i,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(sr,{manager:t})}),!s.useCustomRouting&&e.jsx(ar,{open:p,title:x?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:x||void 0,onSubmit:e=>{n(e),h(!1),f(null)},onCancel:()=>{h(!1),f(null)},isLoading:t.isLoading,submitButtonText:l(x?"update":"create")}),e.jsx($e,{open:b.isOpen,onOpenChange:w,children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{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:b.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{b.entityId&&(t.deleteEntity(b.entityId),v({isOpen:!1,entityId:null,entityName:""}))},disabled:t.isDeleting,children:t.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx($e,{open:j.isOpen,onOpenChange:()=>N({isOpen:!1,count:0}),children:e.jsxs(Qe,{size:"sm",children:[e.jsx(Ke,{showSeparator:!0,children:e.jsx(Ye,{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:j.count})," ",1===j.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(Je,{children:[e.jsx(_e,{variant:"outline",onClick:()=>N({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(_e,{variant:"destructive",onClick:()=>{t.bulkDelete?.(t.selectedIds),N({isOpen:!1,count:0})},disabled:t.isBulkDeleting,children:t.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function ur(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function mr(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const pr=Z.forwardRef(({className:a,value:t,...s},r)=>e.jsx(ue.Root,{ref:r,className:Pe("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...s,children:e.jsx(ue.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));function hr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center justify-between mb-6",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:Pe("flex items-center justify-center w-10 h-10 rounded-full border-2 transition-colors font-medium",t.isActive&&"border-primary bg-primary text-primary-foreground",t.isCompleted&&"border-primary bg-primary text-primary-foreground",!t.isActive&&!t.isCompleted&&"border-muted-foreground/30 text-muted-foreground bg-background",s&&!t.isDisabled&&"cursor-pointer hover:border-primary/50",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:t.isCompleted?e.jsx(d.Check,{className:"w-5 h-5"}):r+1}),r<a.length-1&&e.jsx("div",{className:Pe("flex-1 h-0.5 mx-2 transition-colors",t.isCompleted?"bg-primary":"bg-muted-foreground/30"),"aria-hidden":"true"})]},t.id))})}function xr({steps:a,currentStepIndex:t,onStepClick:s,className:r}){return e.jsx("div",{className:Pe("flex items-center gap-2 mb-6 overflow-x-auto",r),children:a.map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[e.jsxs("div",{className:Pe("flex items-center gap-2 px-3 py-2 rounded-md transition-colors",t.isActive&&"bg-primary text-primary-foreground font-medium",t.isCompleted&&"bg-primary/10 text-primary",!t.isActive&&!t.isCompleted&&"bg-muted text-muted-foreground",s&&!t.isDisabled&&"cursor-pointer hover:bg-primary/20",t.isDisabled&&"opacity-50 cursor-not-allowed"),onClick:()=>s&&!t.isDisabled&&s(r),role:s&&!t.isDisabled?"button":void 0,tabIndex:s&&!t.isDisabled?0:void 0,"aria-label":`${t.label} - ${t.isCompleted?"Completo":t.isActive?"Atual":"Pendente"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:r+1}),e.jsx("span",{className:"text-sm",children:t.label}),t.isCompleted&&e.jsx(d.Check,{className:"w-4 h-4 ml-1"})]}),r<a.length-1&&e.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"/"})]},t.id))})}function fr({steps:a,currentStepIndex:t,className:s}){const r=a[t],n=(t+1)/a.length*100;return e.jsxs("div",{className:Pe("mb-6 space-y-2",s),children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Etapa ",t+1," de ",a.length]}),e.jsx("span",{className:"font-medium",children:r?.label})]}),e.jsx(pr,{value:n,className:"h-2"})]})}function gr({isFirstStep:a,isLastStep:t,canGoNext:s,canGoPrevious:r,isLoading:n,onPrevious:i,onNext:o,onSubmit:l,previousButtonText:d,nextButtonText:c,submitButtonText:u}){const{t:m}=g.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:r&&!a&&e.jsx(_e,{type:"button",variant:"outline",onClick:i,disabled:n,children:d||m("previous")})}),e.jsxs("div",{className:"flex gap-2",children:[s&&!t&&e.jsx(_e,{type:"button",onClick:o,disabled:n,children:c||m("next")}),t&&e.jsx(_e,{type:"button",onClick:l,disabled:n,children:n?m("saving"):u||m("save")})]})]})}pr.displayName=ue.Root.displayName;const br=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"}}),vr={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},yr=Z.forwardRef(({className:a,variant:t="info",showIcon:s=!0,children:r,...n},i)=>{const o=vr[t||"info"];return e.jsxs("div",{ref:i,role:"alert",className:Pe(br({variant:t}),a),...n,children:[s&&e.jsx(o,{className:"h-4 w-4"}),r]})});yr.displayName="Alert";const jr=Z.forwardRef(({className:a,...t},s)=>e.jsx("h5",{ref:s,className:Pe("mb-1 font-medium leading-none tracking-tight",a),...t}));jr.displayName="AlertTitle";const Nr=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-sm [&_p]:leading-relaxed",a),...t}));Nr.displayName="AlertDescription";const wr=a.createContext(void 0);function Cr({children:t,actions:s}){const[r,n]=a.useState({}),[i,o]=a.useState(s);return a.useEffect(()=>{o(s)},[s]),e.jsx(wr.Provider,{value:{metadata:r,setMetadata:n,clearMetadata:()=>n({}),headerActions:i,setHeaderActions:o},children:t})}function kr(){const e=a.useContext(wr);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}const Sr=(void 0).VITE_SUPABASE_URL,Pr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;let Tr=null;var Ir=Object.defineProperty,_r=(e,a,t)=>((e,a,t)=>a in e?Ir(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Ar=new class{constructor(){_r(this,"cache",{}),_r(this,"cacheTimestamps",new Map),_r(this,"CACHE_TTL",3e5),_r(this,"loadingPromises",new Map)}isCacheValid(e){const a=this.cacheTimestamps.get(e);return!!a&&Date.now()-a<this.CACHE_TTL}async loadTranslations(e){if(this.isCacheValid(e))return this.cache[e]||{};const a=this.loadingPromises.get(e);if(a)return a;const t=this.fetchTranslations(e);this.loadingPromises.set(e,t);try{return await t}finally{this.loadingPromises.delete(e)}}async fetchTranslations(e){try{const a=(!Tr&&Sr&&Pr&&(Tr=b.createClient(Sr,Pr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}})),Tr),{data:t,error:s}=await a.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 t?.forEach(a=>{let t;t="pt-BR"===e?a.pt:"en-US"===e?a.en||a.pt:"es-ES"===e&&a.es||a.pt,t&&(r[a.key]=t)}),this.cache[e]=r,this.cacheTimestamps.set(e,Date.now()),r}catch(a){return{}}}async upsertTranslation(e,a,t,s){const r=it(),{error:n}=await r.schema("common").from("translations").upsert({key:e,pt:a,en:t,es:s},{onConflict:"key"});if(n)throw n;this.clearCache()}async bulkUpsertTranslations(e){const a=it(),{error:t}=await a.schema("common").from("translations").upsert(e.map(e=>({key:e.key,pt:e.pt,en:e.en,es:e.es})),{onConflict:"key"});if(t)throw t;this.clearCache()}clearCache(){this.cache={},this.cacheTimestamps.clear()}clearCacheForLocale(e){delete this.cache[e],this.cacheTimestamps.delete(e)}};var Er=Object.defineProperty,Mr=(e,a,t)=>((e,a,t)=>a in e?Er(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,"symbol"!=typeof a?a+"":a,t);const Rr="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,a,t){if(this.cache.has(e))return void t(null,this.cache.get(e));if(this.loadingPromises.has(e))return void this.loadingPromises.get(e).then(()=>{t(null,this.cache.get(e)||{})});const s=Ar.loadTranslations(e).then(a=>{if(this.isDebugMode){const t={};Object.keys(a).forEach(e=>{t[e]=`[${e} ✅]`}),this.cache.set(e,t)}else this.cache.set(e,a)}).catch(a=>{this.cache.set(e,{})}).finally(()=>{this.loadingPromises.delete(e)});this.loadingPromises.set(e,s),s.then(()=>{t(null,this.cache.get(e)||{})})}create(e,a,t,s){}}(Rr)).use(g.initReactI18next).init({fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:(e,a)=>Rr?`[${e} ❌]`:`[⚠️ ${e}]`});const Dr=new class{async getUserPreferences(e,a){if(!Xa.areAllTokensValid())return null;const t=it();try{const{data:s,error:r}=await t.schema("common").from("user_preferences").select("*").eq("id_user",e).eq("alias",a).maybeSingle();if(r)return"PGRST116"===r.code?this.createDefaultPreferences(e,a):("42501"===r.code||"PGRST301"===r.code||r.message?.includes("permission denied"),null);if(!s)return this.createDefaultPreferences(e,a);const n=s;return{locale:n.locale,timezone:n.timezone,datetimeFormat:n.datetime_format}}catch(s){return null}}async createDefaultPreferences(e,a){const t=it(),s={id_user:e,locale:"pt-BR",timezone:"America/Sao_Paulo",datetime_format:"dd/MM/yyyy HH:mm",alias:a};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,a,t){const s=it();try{const{error:r}=await s.schema("common").from("user_preferences").update(t).eq("id_user",e).eq("alias",a);if(r)throw r}catch(r){throw r}}},Fr=a.createContext(void 0),zr=({children:t})=>{const{user:s,alias:r}=$t(),[n,i]=a.useState({locale:"pt-BR",timezone:"America/Sao_Paulo",datetimeFormat:"dd/MM/yyyy HH:mm"}),[l,d]=a.useState(!0);a.useEffect(()=>{(async()=>{if(s?.id&&r)try{const e=await Dr.getUserPreferences(s.id,r);e&&(i({locale:e.locale,timezone:e.timezone,datetimeFormat:e.datetimeFormat}),await o.changeLanguage(e.locale),localStorage.setItem("i18nextLng",e.locale))}catch(e){}finally{d(!1)}else d(!1)})()},[s?.id,r]);const c=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{locale:e}),i(a=>({...a,locale:e})),await o.changeLanguage(e),localStorage.setItem("i18nextLng",e)}catch(a){throw a}},[s?.id,r]),u=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{timezone:e}),i(a=>({...a,timezone:e}))}catch(a){throw a}},[s?.id,r]),m=a.useCallback(async e=>{if(s?.id&&r)try{await Dr.updatePreferences(s.id,r,{datetime_format:e}),i(a=>({...a,datetimeFormat:e}))}catch(a){throw a}},[s?.id,r]);return e.jsx(Fr.Provider,{value:{...n,setLocale:c,setTimezone:u,setDatetimeFormat:m,isLoading:l},children:t})},Lr=()=>{const e=a.useContext(Fr);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e};function Or({children:t}){const{ready:s}=g.useTranslation(),[r,n]=a.useState(!0);return a.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(Ca,{size:"lg"}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Carregando traduções..."})]})}):e.jsx(e.Fragment,{children:t})}const Ur=me.Root,qr=me.CollapsibleTrigger,$r=me.CollapsibleContent;var Br=Object.defineProperty,Wr=(e,a,t)=>((e,a,t)=>a in e?Br(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);class Vr extends a.Component{constructor(e){super(e),Wr(this,"copyErrorDetails",()=>{const e=Za.getErrors().slice(0,2),a=`\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,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(a),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,a){if((void 0).DEV)throw e;Za.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const a=Za.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(De,{className:"w-full max-w-2xl",children:[e.jsxs(Fe,{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(ze,{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(Ur,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(qr,{asChild:!0,children:e.jsxs(_e,{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($r,{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})})]})]}),a.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:a.map((a,t)=>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:[t+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(a.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:a.message})]})]})},a.id))})]})]}),e.jsxs(_e,{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(_e,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Hr=pe.Root,Gr=Z.forwardRef(({className:a,...t},s)=>e.jsx(pe.Item,{ref:s,className:Pe("border-b",a),...t}));Gr.displayName="AccordionItem";const Qr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.Header,{className:"flex",children:e.jsxs(pe.Trigger,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...s,children:[t,e.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Qr.displayName=pe.Trigger.displayName;const Kr=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsx(pe.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:Pe("pb-4 pt-0",a),children:t})}));Kr.displayName=pe.Content.displayName;const Xr=he.Root,Jr=he.Trigger,Yr=he.Portal,Zr=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Overlay,{className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Zr.displayName=he.Overlay.displayName;const en=Z.forwardRef(({className:a,...t},s)=>e.jsxs(Yr,{children:[e.jsx(Zr,{}),e.jsx(he.Content,{ref:s,className:Pe("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",a),...t})]}));en.displayName=he.Content.displayName;const an=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",a),...t});an.displayName="AlertDialogHeader";const tn=({className:a,...t})=>e.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});tn.displayName="AlertDialogFooter";const sn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Title,{ref:s,className:Pe("text-lg font-semibold",a),...t}));sn.displayName=he.Title.displayName;const rn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));rn.displayName=he.Description.displayName;const nn=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Action,{ref:s,className:Pe(Ie(),a),...t}));nn.displayName=he.Action.displayName;const on=Z.forwardRef(({className:a,...t},s)=>e.jsx(he.Cancel,{ref:s,className:Pe(Ie({variant:"outline"}),"mt-2 sm:mt-0",a),...t}));on.displayName=he.Cancel.displayName;const ln=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Root,{ref:s,className:Pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...t}));ln.displayName=xe.Root.displayName;const dn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Image,{ref:s,className:Pe("aspect-square h-full w-full",a),...t}));dn.displayName=xe.Image.displayName;const cn=Z.forwardRef(({className:a,...t},s)=>e.jsx(xe.Fallback,{ref:s,className:Pe("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...t}));cn.displayName=xe.Fallback.displayName;const un=Z.forwardRef(({...a},t)=>e.jsx("nav",{ref:t,"aria-label":"breadcrumb",...a}));un.displayName="Breadcrumb";const mn=Z.forwardRef(({className:a,...t},s)=>e.jsx("ol",{ref:s,className:Pe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",a),...t}));mn.displayName="BreadcrumbList";const pn=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("inline-flex items-center gap-1.5",a),...t}));pn.displayName="BreadcrumbItem";const hn=Z.forwardRef(({asChild:a,className:s,...r},n)=>{const i=a?t.Slot:"a";return e.jsx(i,{ref:n,className:Pe("transition-colors hover:text-foreground",s),...r})});hn.displayName="BreadcrumbLink";const xn=Z.forwardRef(({className:a,...t},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Pe("font-normal text-foreground",a),...t}));xn.displayName="BreadcrumbPage";const fn=({children:a,className:t,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pe("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:a??e.jsx(d.ChevronRight,{})});fn.displayName="BreadcrumbSeparator";const gn=({className:a,...t})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});gn.displayName="BreadcrumbEllipsis";const bn=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"}}),vn=Z.forwardRef(({className:a,orientation:t,...s},r)=>e.jsx("div",{ref:r,className:Pe(bn({orientation:t}),a),...s}));function yn(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}function jn(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Nn(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.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,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(o,e=>e.test(i)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(o,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(i.length)}}}function wn(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[0],n=a.match(e.parsePattern);if(!n)return null;let i=e.valueCallback?e.valueCallback(n[0]):n[0];i=t.valueCallback?t.valueCallback(i):i;return{value:i,rest:a.slice(r.length)}}}vn.displayName="ButtonGroup";const Cn={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"}},kn={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Sn={ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:jn({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Pn={ordinalNumber:wn({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Tn={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Cn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:{date:yn({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:yn({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:yn({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},formatRelative:(e,a,t,s)=>kn[e],localize:Sn,match:Pn,options:{weekStartsOn:0,firstWeekContainsDate:1}},In={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"}},_n={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},An={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"},En={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"},Mn={ordinalNumber:(e,a)=>Number(e)+"º",era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Rn={ordinalNumber:wn({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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"})},Dn={code:"es",formatDistance:(e,a,t)=>{let s;const r=In[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:_n,formatRelative:(e,a,t,s)=>1!==a.getHours()?En[e]:An[e],localize:Mn,match:Rn,options:{weekStartsOn:1,firstWeekContainsDate:1}},Fn={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"}},zn={date:yn({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:yn({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:yn({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ln={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},On={ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:jn({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:jn({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:jn({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:jn({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:jn({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"})},Un={ordinalNumber:wn({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Nn({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:Nn({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:Nn({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:Nn({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:Nn({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,a,t)=>{let s;const r=Fn[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:zn,formatRelative:(e,a,t,s)=>{const r=Ln[e];return"function"==typeof r?r(a):r},localize:On,match:Un,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $n({className:a,classNames:t,showOutsideDays:s=!0,...r}){return e.jsx(A.DayPicker,{showOutsideDays:s,className:Pe("p-3 pointer-events-auto",a),locale:qn,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Pe(Ie({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Pe(Ie({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{Chevron:({orientation:a})=>"left"===a?e.jsx(d.ChevronLeft,{className:"h-4 w-4"}):e.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}$n.displayName="Calendar";const Bn={Root:function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-4",t),children:a})},Item:function({children:a,onClick:t,className:s}){return e.jsx(De,{className:Pe("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:e.jsx(Oe,{className:"p-4",children:a})})},Field:function({label:a,value:t,className:s}){return e.jsxs("div",{className:Pe("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:t})]})}};const Wn=({shouldScaleBackground:a=!0,...t})=>e.jsx(E.Drawer.Root,{shouldScaleBackground:a,...t});Wn.displayName="Drawer";const Vn=E.Drawer.Trigger,Hn=E.Drawer.Portal,Gn=E.Drawer.Close,Qn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Overlay,{ref:s,className:Pe("fixed inset-0 z-50 bg-black/80",a),...t}));Qn.displayName=E.Drawer.Overlay.displayName;const Kn=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Hn,{children:[e.jsx(Qn,{}),e.jsxs(E.Drawer.Content,{ref:r,className:Pe("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",a),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));Kn.displayName="DrawerContent";const Xn=({className:a,...t})=>e.jsx("div",{className:Pe("grid gap-1.5 p-4 text-center sm:text-left",a),...t});Xn.displayName="DrawerHeader";const Jn=({className:a,...t})=>e.jsx("div",{className:Pe("mt-auto flex flex-col gap-2 p-4",a),...t});Jn.displayName="DrawerFooter";const Yn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Title,{ref:s,className:Pe("text-lg font-semibold leading-none tracking-tight",a),...t}));Yn.displayName=E.Drawer.Title.displayName;const Zn=Z.forwardRef(({className:a,...t},s)=>e.jsx(E.Drawer.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));Zn.displayName=E.Drawer.Description.displayName;const ei={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))]"},ai={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const ti=fe.Root,si=fe.Trigger,ri=Z.forwardRef(({className:a,align:t="center",sideOffset:s=4,...r},n)=>e.jsx(fe.Content,{ref:n,align:t,sideOffset:s,className:Pe("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",a),...r}));ri.displayName=fe.Content.displayName;const ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Pe("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",a),...t}));ni.displayName="InputGroup";const ii=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"}}),oi=Z.forwardRef(({className:a,align:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Pe(ii({align:t}),a),...s}));oi.displayName="InputGroupAddon";const li=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"}}),di=Z.forwardRef(({className:a,size:t,variant:s="ghost",...r},n)=>e.jsx(_e,{ref:n,"data-slot":"input-group-button",variant:s,className:Pe(li({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",a),...r}));di.displayName="InputGroupButton";const ci=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ci.displayName="InputGroupInput";const ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(ya,{ref:s,"data-slot":"input-group-control",className:Pe("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",a),...t}));ui.displayName="InputGroupTextarea";const mi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h1",{ref:s,className:Pe("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",a),...t}));mi.displayName="H1";const pi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h2",{ref:s,className:Pe("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",a),...t}));pi.displayName="H2";const hi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h3",{ref:s,className:Pe("scroll-m-20 text-2xl font-semibold tracking-tight",a),...t}));hi.displayName="H3";const xi=Z.forwardRef(({className:a,...t},s)=>e.jsx("h4",{ref:s,className:Pe("scroll-m-20 text-xl font-semibold tracking-tight",a),...t}));xi.displayName="H4";const fi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("leading-7 [&:not(:first-child)]:mt-6",a),...t}));fi.displayName="P";const gi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-xl text-muted-foreground",a),...t}));gi.displayName="Lead";const bi=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,className:Pe("text-lg font-semibold",a),...t}));bi.displayName="Large";const vi=Z.forwardRef(({className:a,...t},s)=>e.jsx("small",{ref:s,className:Pe("text-sm font-medium leading-none",a),...t}));vi.displayName="Small";const yi=Z.forwardRef(({className:a,...t},s)=>e.jsx("p",{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));yi.displayName="Muted";const ji=Z.forwardRef(({className:a,...t},s)=>e.jsx("code",{ref:s,className:Pe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",a),...t}));ji.displayName="InlineCode";const Ni=Z.forwardRef(({className:a,...t},s)=>e.jsx("blockquote",{ref:s,className:Pe("mt-6 border-l-2 pl-6 italic",a),...t}));Ni.displayName="Blockquote";const wi=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("my-6 ml-6 list-disc [&>li]:mt-2",a),...t}));wi.displayName="List";const Ci=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Root,{ref:r,className:Pe("relative z-10 flex max-w-max flex-1 items-center justify-center",a),...s,children:[t,e.jsx(Ai,{})]}));Ci.displayName=ge.Root.displayName;const ki=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.List,{ref:s,className:Pe("group flex flex-1 list-none items-center justify-center space-x-1",a),...t}));ki.displayName=ge.List.displayName;const Si=ge.Item,Pi=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"),Ti=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(ge.Trigger,{ref:r,className:Pe(Pi(),"group",a),...s,children:[t," ",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"})]}));Ti.displayName=ge.Trigger.displayName;const Ii=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Content,{ref:s,className:Pe("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 ",a),...t}));Ii.displayName=ge.Content.displayName;const _i=ge.Link,Ai=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:Pe("absolute left-0 top-full flex justify-center"),children:e.jsx(ge.Viewport,{className:Pe("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)]",a),ref:s,...t})}));Ai.displayName=ge.Viewport.displayName;const Ei=Z.forwardRef(({className:a,...t},s)=>e.jsx(ge.Indicator,{ref:s,className:Pe("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",a),...t,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));Ei.displayName=ge.Indicator.displayName;const Mi=({className:a,...t})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Pe("mx-auto flex w-full justify-center",a),...t});Mi.displayName="Pagination";const Ri=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,className:Pe("flex flex-row items-center gap-1",a),...t}));Ri.displayName="PaginationContent";const Di=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,className:Pe("",a),...t}));Di.displayName="PaginationItem";const Fi=({className:a,isActive:t,size:s="icon",...r})=>e.jsx("a",{"aria-current":t?"page":void 0,className:Pe(Ie({variant:t?"outline":"ghost",size:s}),a),...r});Fi.displayName="PaginationLink";const zi=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to previous page",size:"default",className:Pe("gap-1 pl-2.5",a),...t,children:[e.jsx(d.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});zi.displayName="PaginationPrevious";const Li=({className:a,...t})=>e.jsxs(Fi,{"aria-label":"Go to next page",size:"default",className:Pe("gap-1 pr-2.5",a),...t,children:[e.jsx("span",{children:"Next"}),e.jsx(d.ChevronRight,{className:"h-4 w-4"})]});Li.displayName="PaginationNext";const Oi=({className:a,...t})=>e.jsxs("span",{"aria-hidden":!0,className:Pe("flex h-9 w-9 items-center justify-center",a),...t,children:[e.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Oi.displayName="PaginationEllipsis";const Ui=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Root,{className:Pe("grid gap-2",a),...t,ref:s}));Ui.displayName=be.Root.displayName;const qi=Z.forwardRef(({className:a,...t},s)=>e.jsx(be.Item,{ref:s,className:Pe("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",a),...t,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"})})}));qi.displayName=be.Item.displayName;const $i=ve.Panel,Bi=ae.Root,Wi=ae.Trigger,Vi=ae.Close,Hi=ae.Portal,Gi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Overlay,{className:Pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...t,ref:s}));Gi.displayName=ae.Overlay.displayName;const Qi=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"}}),Ki=Z.forwardRef(({side:a="right",className:t,children:s,...r},n)=>e.jsxs(Hi,{children:[e.jsx(Gi,{}),e.jsxs(ae.Content,{ref:n,className:Pe(Qi({side:a}),t),...r,children:[s,e.jsxs(ae.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"})]})]})]}));Ki.displayName=ae.Content.displayName;const Xi=({className:a,showSeparator:t=!1,children:s,...r})=>e.jsxs("div",{className:Pe("flex flex-col flex-shrink-0",a),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),t&&e.jsx(qe,{className:"mt-2"})]});Xi.displayName="SheetHeader";const Ji=({className:a,...t})=>e.jsx("div",{className:Pe("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",a),...t});Ji.displayName="SheetBody";const Yi=({className:a,children:t,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(qe,{className:"mb-4"}),e.jsx("div",{className:Pe("flex flex-row justify-end gap-2",a),...s,children:t})]});Yi.displayName="SheetFooter";const Zi=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Title,{ref:s,className:Pe("text-lg font-semibold text-foreground",a),...t}));Zi.displayName=ae.Title.displayName;const eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(ae.Description,{ref:s,className:Pe("text-sm text-muted-foreground",a),...t}));eo.displayName=ae.Description.displayName;const ao="sidebar:state",to=Z.createContext(null);function so(){const e=Z.useContext(to);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const ro=Z.forwardRef(({defaultOpen:a=!0,open:t,onOpenChange:s,className:r,style:n,children:i,...o},l)=>{const[d,c]=Z.useState(!1);Z.useEffect(()=>{const e=()=>c(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=Z.useState(!1),[p,h]=Z.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(ao);return null!==e?"true"===e:a}return a}),x=t??p,f=Z.useCallback(e=>{const a="function"==typeof e?e(x):e;s?s(a):h(a),"undefined"!=typeof window&&localStorage.setItem(ao,String(a))},[s,x]),g=Z.useCallback(()=>d?m(e=>!e):f(e=>!e),[d,f,m]);Z.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=x?"expanded":"collapsed",v=Z.useMemo(()=>({state:b,open:x,setOpen:f,isMobile:d,openMobile:u,setOpenMobile:m,toggleSidebar:g}),[b,x,f,d,u,m,g]);return e.jsx(to.Provider,{value:v,children:e.jsx(ts,{delayDuration:0,children:e.jsx("div",{className:Pe("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})})})});ro.displayName="SidebarProvider";const no=Z.forwardRef(({side:a="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...i},o)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=so();return"none"===s?e.jsx("div",{className:Pe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:o,...i,children:n}):l?e.jsx(Bi,{open:c,onOpenChange:u,...i,children:e.jsxs(Ki,{"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:a,children:[e.jsx(Zi,{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":t,"data-side":a,children:[e.jsx("div",{className:Pe("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"===t||"inset"===t?"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:Pe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===a?"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"===t||"inset"===t?"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})})]})});no.displayName="Sidebar";const io=Z.forwardRef(({className:a,onClick:t,...s},r)=>{const{toggleSidebar:n}=so();return e.jsxs(_e,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Pe("h-7 w-7",a),onClick:e=>{t?.(e),n()},...s,children:[e.jsx(d.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});io.displayName="SidebarTrigger";const oo=Z.forwardRef(({className:a,...t},s)=>{const{toggleSidebar:r}=so();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Pe("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",a),...t})});oo.displayName="SidebarRail";const lo=Z.forwardRef(({className:a,...t},s)=>e.jsx("main",{ref:s,className:Pe("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",a),...t}));lo.displayName="SidebarInset";const co=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ee,{ref:s,"data-sidebar":"input",className:Pe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",a),...t}));co.displayName="SidebarInput";const uo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Pe("flex flex-col gap-2 p-2",a),...t}));uo.displayName="SidebarHeader";const mo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Pe("flex flex-col gap-2 p-2",a),...t}));mo.displayName="SidebarFooter";const po=Z.forwardRef(({className:a,...t},s)=>e.jsx(qe,{ref:s,"data-sidebar":"separator",className:Pe("mx-2 w-auto bg-sidebar-border",a),...t}));po.displayName="SidebarSeparator";const ho=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Pe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",a),...t}));ho.displayName="SidebarContent";const xo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Pe("relative flex w-full min-w-0 flex-col p-2",a),...t}));xo.displayName="SidebarGroup";const fo=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"div";return e.jsx(i,{ref:n,"data-sidebar":"group-label",className:Pe("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",a),...r})});fo.displayName="SidebarGroupLabel";const go=Z.forwardRef(({className:a,asChild:s=!1,...r},n)=>{const i=s?t.Slot:"button";return e.jsx(i,{ref:n,"data-sidebar":"group-action",className:Pe("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",a),...r})});go.displayName="SidebarGroupAction";const bo=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Pe("w-full text-sm",a),...t}));bo.displayName="SidebarGroupContent";const vo=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Pe("flex w-full min-w-0 flex-col gap-1",a),...t}));vo.displayName="SidebarMenu";const yo=Z.forwardRef(({className:a,...t},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Pe("group/menu-item relative",a),...t}));yo.displayName="SidebarMenuItem";const jo=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"}}),No=Z.forwardRef(({asChild:a=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:i,className:o,...l},d)=>{const c=a?t.Slot:"button",{isMobile:u,state:m}=so(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Pe(jo({variant:r,size:n}),o),...l});return i?("string"==typeof i&&(i={children:i}),e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:p}),e.jsx(ns,{side:"right",align:"center",hidden:"collapsed"!==m||u,...i})]})):p});No.displayName="SidebarMenuButton";const wo=Z.forwardRef(({className:a,asChild:s=!1,showOnHover:r=!1,...n},i)=>{const o=s?t.Slot:"button";return e.jsx(o,{ref:i,"data-sidebar":"menu-action",className:Pe("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",a),...n})});wo.displayName="SidebarMenuAction";const Co=Z.forwardRef(({className:a,...t},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Pe("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",a),...t}));Co.displayName="SidebarMenuBadge";const ko=Z.forwardRef(({className:a,showIcon:t=!1,...s},r)=>{const n=Z.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Pe("rounded-md h-8 flex gap-2 px-2 items-center",a),...s,children:[t&&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}})]})});ko.displayName="SidebarMenuSkeleton";const So=Z.forwardRef(({className:a,...t},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Pe("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",a),...t}));So.displayName="SidebarMenuSub";const Po=Z.forwardRef(({...a},t)=>e.jsx("li",{ref:t,...a}));Po.displayName="SidebarMenuSubItem";const To=Z.forwardRef(({asChild:a=!1,size:s="md",isActive:r,className:n,...i},o)=>{const l=a?t.Slot:"a";return e.jsx(l,{ref:o,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Pe("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})});To.displayName="SidebarMenuSubButton";const Io=Z.forwardRef(({className:a,value:t,defaultValue:s,...r},n)=>{const i=t||s||[0];return e.jsxs(ye.Root,{ref:n,value:t,defaultValue:s,className:Pe("relative flex w-full touch-none select-none items-center",a),...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"})}),i.map((a,t)=>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"},t))]})});Io.displayName=ye.Root.displayName;const _o=je.Root,Ao=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.List,{ref:s,className:Pe("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...t}));Ao.displayName=je.List.displayName;const Eo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Trigger,{ref:s,className:Pe("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",a),...t}));Eo.displayName=je.Trigger.displayName;const Mo=Z.forwardRef(({className:a,...t},s)=>e.jsx(je.Content,{ref:s,className:Pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...t}));Mo.displayName=je.Content.displayName;const Ro=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"}}),Do=Z.forwardRef(({className:a,variant:t,size:s,...r},n)=>e.jsx(Ne.Root,{ref:n,className:Pe(Ro({variant:t,size:s,className:a})),...r}));Do.displayName=Ne.Root.displayName;const Fo=Z.createContext({size:"default",variant:"default"}),zo=Z.forwardRef(({className:a,variant:t,size:s,children:r,...n},i)=>e.jsx(we.Root,{ref:i,className:Pe("flex items-center justify-center gap-1",a),...n,children:e.jsx(Fo.Provider,{value:{variant:t,size:s},children:r})}));zo.displayName=we.Root.displayName;const Lo=Z.forwardRef(({className:a,children:t,variant:s,size:r,...n},i)=>{const o=Z.useContext(Fo);return e.jsx(we.Item,{ref:i,className:Pe(Ro({variant:o.variant||s,size:o.size||r}),a),...n,children:t})});Lo.displayName=we.Item.displayName;const Oo=Ce.Menu,Uo=Ce.Group,qo=Ce.Portal,$o=Ce.Sub,Bo=Ce.RadioGroup,Wo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Root,{ref:s,className:Pe("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",a),...t}));Wo.displayName=Ce.Root.displayName;const Vo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Trigger,{ref:s,className:Pe("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",a),...t}));Vo.displayName=Ce.Trigger.displayName;const Ho=Z.forwardRef(({className:a,inset:t,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Pe("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",t&&"pl-8",a),...r,children:[s,e.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Ho.displayName=Ce.SubTrigger.displayName;const Go=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.SubContent,{ref:s,className:Pe("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",a),...t}));Go.displayName=Ce.SubContent.displayName;const Qo=Z.forwardRef(({className:a,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},i)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:i,align:t,alignOffset:s,sideOffset:r,className:Pe("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",a),...n})}));Qo.displayName=Ce.Content.displayName;const Ko=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Pe("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",t&&"pl-8",a),...s}));Ko.displayName=Ce.Item.displayName;const Xo=Z.forwardRef(({className:a,children:t,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Pe("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",a),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"})})}),t]}));Xo.displayName=Ce.CheckboxItem.displayName;const Jo=Z.forwardRef(({className:a,children:t,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Pe("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",a),...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"})})}),t]}));Jo.displayName=Ce.RadioItem.displayName;const Yo=Z.forwardRef(({className:a,inset:t,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",a),...s}));Yo.displayName=Ce.Label.displayName;const Zo=Z.forwardRef(({className:a,...t},s)=>e.jsx(Ce.Separator,{ref:s,className:Pe("-mx-1 my-1 h-px bg-muted",a),...t}));Zo.displayName=Ce.Separator.displayName;const el=({className:a,...t})=>e.jsx("span",{className:Pe("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});el.displayname="MenubarShortcut";const al={light:"",dark:".dark"},tl=Z.createContext(null);function sl(){const e=Z.useContext(tl);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const rl=Z.forwardRef(({id:a,className:t,children:s,config:r,...n},i)=>{const o=Z.useId(),l=`chart-${a||o.replace(/:/g,"")}`;return e.jsx(tl.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:i,className:Pe("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",t),...n,children:[e.jsx(nl,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});rl.displayName="Chart";const nl=({id:a,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(al).map(([e,t])=>`\n${t} [data-chart=${a}] {\n${s.map(([a,t])=>{const s=t.theme?.[e]||t.color;return s?` --color-${a}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},il=ke.Tooltip,ol=Z.forwardRef(({active:a,payload:t,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:i=!1,label:o,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:x}=sl(),f=Z.useMemo(()=>{if(n||!t?.length)return null;const[a]=t,s=cl(x,a,`${p||a?.dataKey||a?.name||"value"}`),r=p||"string"!=typeof o?s?.label:x[o]?.label||o;return l?e.jsx("div",{className:Pe("font-medium",d),children:l(r,t)}):r?e.jsx("div",{className:Pe("font-medium",d),children:r}):null},[o,l,t,n,d,x,p]);if(!a||!t?.length)return null;const g=1===t.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Pe("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:f,e.jsx("div",{className:"grid gap-1.5",children:t.map((a,t)=>{const s=`${m||a.name||a.dataKey||"value"}`,n=cl(x,a,s),o=u||a.payload?.fill||a.color;return e.jsx("div",{className:Pe("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!==a?.value&&a.name?c(a.value,a.name,a,t,a.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!i&&e.jsx("div",{className:Pe("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:Pe("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||a.name})]}),void 0!==a.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof a.value?a.value.toLocaleString():a.value})]})]})},a.dataKey||t)})})]})});ol.displayName="ChartTooltip";const ll=ke.Legend,dl=Z.forwardRef(({className:a,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},i)=>{const{config:o}=sl();return s?.length?e.jsx("div",{ref:i,className:Pe("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",a),children:s.map(a=>{const s=`${n||a.dataKey||"value"}`,r=cl(o,a,s);return e.jsxs("div",{className:Pe("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:a.color}}),r?.label]},a.value)})}):null});function cl(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}dl.displayName="ChartLegend";const ul=({onClick:a,isActive:t,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:a,disabled:s,title:n,className:Pe("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),ml=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function pl({onEdit:a,onDelete:t,onToggleStatus:s,isActive:r=!0,canEdit:n=!0,canDelete:i=!0,customActions:o=[],renderAs:l="dropdown",variant:c="default"}){const{t:u}=g.useTranslation(),m=[];return a&&n&&m.push({icon:d.Edit,label:u("edit"),onClick:a,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"})}),t&&i&&m.push({icon:d.Trash2,label:u("remove"),onClick:t,variant:"destructive"}),0===m.length?null:"dropdown"===l?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{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(fs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:m.map((a,t)=>e.jsxs(gs,{onClick:a.onClick,className:"destructive"===a.variant?"text-destructive":"",children:[a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4"}),a.label]},t))})]}):e.jsx("div",{className:"flex items-center gap-1",children:m.map((a,t)=>e.jsxs(_e,{variant:"destructive"===a.variant?"destructive":"ghost",size:"compact"===c?"sm":"default",onClick:a.onClick,className:"compact"===c?"h-7 px-2":"",children:[a.icon&&e.jsx(a.icon,{size:"compact"===c?14:16}),"compact"!==c&&e.jsx("span",{className:"ml-1",children:a.label})]},t))})}function hl(e){const a=y.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const xl=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],fl=[{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"}],gl=[{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/New_York",label:"New York (UTC-5/-4)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6/-5)",offset:"-06:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8/-7)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0/+1)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1/+2)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1/+2)",offset:"+01:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10/+11)",offset:"+10:00"}],bl=()=>{const{locale:a,datetimeFormat:t,timezone:s,setLocale:r,setDatetimeFormat:n,setTimezone:i}=Lr(),{t:o}=g.useTranslation();return e.jsxs("div",{className:"space-y-4 p-4",children:[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(da,{value:a,onValueChange:r,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:xl.map(a=>e.jsxs(ga,{value:a.value,children:[a.flag," ",a.label]},a.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.jsxs(da,{value:s,onValueChange:i,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:gl.map(a=>e.jsx(ga,{value:a.value,children:a.label},a.value))})]})]}),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.jsxs(da,{value:t,onValueChange:n,children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsx(xa,{children:fl.map(a=>e.jsx(ga,{value:a.value,children:e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{children:a.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.description," • ",a.example]})]})},a.value))})]})]})]})},vl=a.memo(({variant:t="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:i,companies:o,alias:l,isAuthenticated:c,logout:u,switchUnit:m}=$t(),[p,h]=a.useState(!1),x="true"===(void 0).VITE_SHOW_USER_PREFERENCES,f=o?.[0]||null,g=l?o?.find(e=>e.alias===l):f,b=o||[],v=r||g||f||f,y=a.useCallback(e=>{n?n(e):m(e)},[n,m]),j=a.useMemo(()=>{if(!b?.length)return[];const e=new Map;b.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===v?.alias),s=a.filter(e=>e.alias!==v?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[b,v?.alias]);if(!c||!i)return null;const N=()=>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})]})}),j.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",j.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[j.slice(0,3).map(a=>e.jsx(Na,{variant:a.alias===v?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>y(a),children:a.name},a.alias)),j.length>3&&e.jsxs(Na,{variant:"outline",className:"text-xs",children:["+",j.length-3]})]})]})]});return"dropdown"===t?e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{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(fs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(ms,{children:[e.jsxs(hs,{children:[e.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(xs,{children:j.map(a=>e.jsxs(gs,{onClick:()=>y(a),className:a.alias===v?.alias?"bg-muted":"",children:[e.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),a.name,a.alias===v?.alias&&e.jsx(Na,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},a.alias))})]}),x&&e.jsx(js,{}),x&&e.jsxs(gs,{onClick:()=>h(!0),children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(gs,{onClick:u,children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]}):e.jsxs(De,{className:s,children:[e.jsx(Fe,{children:e.jsx(ze,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(N,{}),e.jsx(qe,{}),x&&e.jsxs(_e,{variant:"outline",onClick:()=>h(!0),size:"sm",className:"w-full",children:[e.jsx(d.Settings,{className:"mr-2 h-4 w-4"}),"Preferências"]}),e.jsxs(_e,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]}),x&&e.jsx($e,{open:p,onOpenChange:h,children:e.jsxs(Qe,{children:[e.jsx(Ke,{children:e.jsx(Ye,{children:"Preferências de Internacionalização"})}),e.jsx(bl,{})]})})]})]})}),yl=a.createContext({});function jl({children:t,config:s}){const r=a.useMemo(()=>({navigation:s?.navigation,appName:s?.appName}),[s?.navigation,s?.appName]);return e.jsx(yl.Provider,{value:r,children:t})}function Nl(){return a.useContext(yl)}function wl(){const e=y.useLocation(),{navigation:a}=Nl(),{t:t}=g.useTranslation();if(!a)return t("page");const s=a.find(a=>a.path===e.pathname);if(s)return s.label;const r=a.find(a=>e.pathname.startsWith(a.path+"/"));return r?.label||t("page")}function Cl(e,t){const[s,r]=a.useState(e),n=a.useRef(),i=a.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return a.useEffect(()=>(i(),n.current=setTimeout(()=>{r(e)},t),i),[e,t,i]),[s,i]}const kl=a.memo(function({actions:t}){const s=y.useLocation(),r=wl(),{navigation:n,appName:i}=Nl(),{metadata:o,headerActions:l}=kr(),{t:c}=g.useTranslation(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:x,switchUnit:f}=$t(),b=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[v,j]=y.useSearchParams(),[N,w]=a.useState(()=>v.get("search")||""),[C,k]=Cl(N,vt.debounceDelay);a.useEffect(()=>{if(!p)return;const e=new URLSearchParams(v);C?(e.set("search",C),e.set("page","1")):e.delete("search"),j(e)},[C,j,p]);const S=n?.find(e=>e.path===s.pathname)||n?.find(e=>s.pathname.startsWith(e.path+"/")),P=o.title||r,T=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:P}),e.jsx(Na,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:i||c("module")})]}),T&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T})]}),p&&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=>{w(e)})(e.target.value),className:"w-full pl-10 pr-8"}),N&&e.jsx(_e,{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(),w("");const e=new URLSearchParams(v);e.delete("search"),e.delete("page"),j(e)},title:c("clear_search"),children:e.jsx(d.X,{size:14})})]}),e.jsx(_e,{variant:"outline",size:"sm",onClick:x,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||t)&&e.jsx("div",{className:"flex items-center gap-2",children:l||t}),(void 0).VITE_WIKI_URL&&e.jsx(_e,{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(vl,{variant:"dropdown",selectedUnit:b,onUnitChange:f})})]})]})})}),Sl=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>v.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),Pl=(e={})=>{const{enabled:a=!0}=e,{alias:t}=$t();return v.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=it(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!ut.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},Tl="forlogic-sidebar-pinned",Il=()=>{try{const e=localStorage.getItem(Tl);return!!e&&JSON.parse(e)}catch{return!1}},_l=e=>{const a=["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 a[e%a.length]},Al=`https://${(void 0).VITE_SUPABASE_PROJECT_ID_STORAGE??(void 0).VITE_SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/library-assets`,El={logo:`${Al}/${wt.isQualiex?"logo-qualiex.svg":"logo.svg"}`,smallLogo:`${Al}/${wt.isQualiex?"small-forlogic.svg":"small.svg"}`},Ml=El.logo,Rl=El.smallLogo;function Dl({appName:a,isPinned:t,onPinToggle:s,open:r,dropdownOpen:n,onDropdownChange:i}){const{t:o}=g.useTranslation(),{data:l,isLoading:c,error:u}=Pl({enabled:n}),m=e=>{((e,a)=>{const t=e?.find(e=>e.url===a);t?.url&&window.open(t.url,"_blank")})(l,e)};return e.jsxs(uo,{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:El.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 "+(t?"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:El.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),e.jsx("div",{className:"mt-2 pt-0",children:e.jsxs(ls,{onOpenChange:i,children:[e.jsx(ds,{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:a})]}),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(fs,{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((a,t)=>e.jsx("div",{onClick:()=>m(a.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${_l(t)} 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:a.name}),a.url&&e.jsx(d.ExternalLink,{className:"h-4 w-4 text-muted-foreground"})]})},a.id))}):e.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:o("no_results")})})]})})]})}function Fl({config:a,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:i="Criar",triggerIcon:o=d.Plus}=a;if(!n||0===n.length)return null;const l=(a,s,r=!1)=>e.jsxs(e.Fragment,{children:[a,!t&&s&&e.jsx("span",{className:"truncate",children:s}),!t&&r&&e.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const a=n[0],i=a.icon||o,d=s||a.disabled,c=e.jsx(_e,{onClick:a.onClick,disabled:d,className:Pe("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:l(e.jsx(i,{className:"h-4 w-4 shrink-0"}),a.label)});return t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:a.label})})]}):c}const c=e.jsx(_e,{disabled:s,className:Pe("w-full gap-2 justify-start",t&&"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(ls,{children:[e.jsx(ds,{asChild:!0,children:t?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:c}),e.jsx(ns,{side:"right",children:e.jsx("p",{children:i})})]}):c}),e.jsx(fs,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:n.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:"cursor-pointer",children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})}function zl({direction:e="right",minWidth:t=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:i,isOpen:o=!0}={}){const[l,d]=a.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=a.useState(!1),m=a.useRef(null);a.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 p=a.useCallback(e=>{e.preventDefault(),u(!0)},[]);return a.useEffect(()=>{if(!c)return;const a=a=>{let r;r="left"===e?window.innerWidth-a.clientX:a.clientX,r=Math.max(t,Math.min(s,r)),d(r),i?.(r)},r=()=>{u(!1),localStorage.setItem(n,l.toString())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)}},[c,e,t,s,l,n,i]),a.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 Ll=a.createContext(void 0);function Ol(){const e=a.useContext(Ll);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Ul({config:t,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:i=384}={}){const{t:o}=g.useTranslation(),{open:l,setOpen:c}=so(),u=y.useLocation(),{alias:m,user:p}=$t(),{hasOpenModal:h}=Ol(),[x,f]=a.useState(!1),[b,v]=a.useState(Il),[j,N]=a.useState(!1),w=a.useRef(!1),C=r?zl({minWidth:n,maxWidth:i,storageKey:"app-sidebar-width",isOpen:l}):null;a.useEffect(()=>{c(!!b||!(!j&&!x))},[b,j,x,c]);return e.jsxs(no,{collapsible:"icon",onMouseEnter:()=>{b||w.current||N(!0)},onMouseLeave:()=>{b||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(Dl,{appName:t?.appName||o("module_title"),isPinned:b,onPinToggle:()=>{const e=!b;v(e),(e=>{try{localStorage.setItem(Tl,JSON.stringify(e))}catch{}})(e),e||(w.current=!0,N(!1),c(!1),setTimeout(()=>{w.current=!1},300))},open:l,dropdownOpen:x,onDropdownChange:f}),t?.moduleActions&&t.moduleActions.actions.length>0&&e.jsx("div",{className:"px-3 py-2",children:e.jsx(ts,{children:e.jsx(Fl,{config:t.moduleActions,isCollapsed:!l,isDisabled:h})})}),e.jsx(ho,{children:s||e.jsx(xo,{className:"p-0 mt-6",children:e.jsx(bo,{children:e.jsx(vo,{className:"space-y-2",children:e.jsx(ts,{children:t?.navigation?.map((a,t)=>{const s=({item:a,index:t})=>{const r=`${a.path}-${t}-${m??"noalias"}-${p?.id??"nouser"}`,{data:n=!0,isLoading:i}=Sl({key:r,enabled:Boolean(a.permissionCheck&&m&&p?.id),checkFn:a.permissionCheck||(()=>Promise.resolve(!0))}),l=a.permissionCheck&&!n;if(l&&"Admin"===a.label)return null;const c=i?d.Loader2:l?d.Lock:a.icon;l?o("restricted_access"):a.complementaryText;return a.children&&a.children.length>0?e.jsx(Ur,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(yo,{children:[e.jsx(qr,{asChild:!0,children:e.jsx(No,{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:a.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($r,{children:e.jsx(So,{children:a.children.map((a,t)=>e.jsx(s,{item:a,index:t},a.path))})})]})},a.path):e.jsx(yo,{children:l||i?e.jsxs(ss,{children:[e.jsx(rs,{asChild:!0,children:e.jsx(No,{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:a.label})]})})}),e.jsx(ns,{children:e.jsx("p",{children:o(i?"checking_access":"restricted_access")})})]}):e.jsx(No,{asChild:!0,isActive:(h=a.path,u.pathname===h||u.pathname.startsWith(h+"/")),size:"lg",className:"h-10",children:e.jsxs(y.Link,{to:a.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:a.label})]})})},a.path);var h};return e.jsx(s,{item:a,index:t},a.path)})})})})})}),r&&C&&l&&e.jsx("div",{ref:C.dragRef,onMouseDown:C.handleMouseDown,className:Pe("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 ql=a.memo(function({children:t,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const i=a.useMemo(()=>s||e.jsx(Ul,{config:r}),[s,r]),o=a.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(jl,{config:r,children:e.jsx(Cr,{children:e.jsx(ro,{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(kl,{})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:t})]})]})})})})}),$l={"pt-BR":qn,"en-US":Tn,"es-ES":Dn},Bl=(e,a="pt-BR")=>{if(!e)return"";const t=i.parseISO(e);if(!i.isValid(t))return"Invalid date";const s=$l[a]||qn;return i.format(t,"PP",{locale:s})};class Wl{static async sendEmail(e){const a=it(),{data:t,error:s}=await a.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 t}}const Vl=Wl;function Hl({open:t,onOpenChange:s,placeId:r,placeName:n,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=g.useTranslation(),[m,p]=a.useState([]),[h,x]=a.useState(!1),[f,b]=a.useState(""),{data:v=[],isLoading:y}=Zs({enabled:t}),j=a.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),N=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},w=1===m.length,C=m.length>0;return e.jsx($e,{open:t,onOpenChange:s,children:e.jsxs(Qe,{className:"max-w-2xl",children:[e.jsx(Ke,{children:e.jsxs(Ye,{className:"flex items-center gap-2",children:[e.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs("div",{className:"relative",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:f,onChange:e=>b(e.target.value),className:"pl-9"})]}),e.jsx(Qs,{className:"h-[400px] pr-4",children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((a,t)=>e.jsx(za,{className:"h-16 w-full"},t))}):0===j.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:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:j.map(a=>{const t=a.userId===l,s=c.includes(a.userId||""),r=m.includes(a.userId||"");return e.jsxs("div",{className:Pe("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>N(a.userId||""),children:[e.jsx(va,{checked:r,onCheckedChange:()=>N(a.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:a.userName}),t&&e.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.userEmail})]}),(t||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},a.userId)})})}),e.jsxs(Je,{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)"]})}),w&&i&&e.jsxs(_e,{onClick:async()=>{if(i&&1===m.length){x(!0);try{await i(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[e.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),C&&o&&e.jsxs(_e,{onClick:async()=>{if(o&&0!==m.length){x(!0);try{await o(m,r),p([])}finally{x(!1)}}},disabled:h,children:[e.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Gl({place:t,level:s=0,manageAccessConfig:r}){const[n,i]=a.useState(!1),[o,l]=a.useState(!1),c=t.subPlaces&&t.subPlaces.length>0,u=t.isActive??!0,m=t.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Ur,{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(qr,{className:"flex items-center gap-2 flex-1",children:[e.jsx(d.ChevronRight,{className:Pe("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:t.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",t.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:t.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(Na,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(pl,{customActions:[{label:"Gerenciar Acessos",icon:d.Settings,onClick:()=>l(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx($r,{children:t.subPlaces.map(a=>e.jsx(Gl,{place:a,level:s+1,manageAccessConfig:r},a.id))})]}),0===s&&e.jsx(qe,{}),r&&e.jsx(Hl,{open:o,onOpenChange:l,placeId:t.id,placeName:t.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(t.id),currentMemberIds:r.getCurrentMemberIds?.(t.id)})]})}var Ql=Object.defineProperty,Kl=(e,a,t)=>((e,a,t)=>a in e?Ql(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t)(e,a+"",t);const Xl=new class{constructor(){Kl(this,"baseUrl",(void 0).VITE_QUALIEX_API_URL)}async makeApiCall(e,a,t){const s=pt.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(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const i=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await pt.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return Za.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Za.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Jl(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Yl(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Zl(){const{alias:e,isAuthenticated:a}=$t(),t=Xa.getAccessToken(),{data:s=[]}=Zs({enabled:!0});return v.useQuery({queryKey:["leadership",e,s.length],queryFn:async()=>{if(!t||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const a=it(),{data:r,error:n}=await a.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(a=>a.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 a=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:a?.name||"[Não encontrado]",email:a?.email||"",subordinatesCount:r.filter(a=>a.id_leader===e).length})}),Jl(o)},enabled:!!t&&!!e&&a&&s.length>0})}function ed(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder virtual promovido com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao criar líder")}})}function ad(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(!t.users.length)throw new Error("Selecione pelo menos um liderado");const r=t.users.map(e=>e.id_user),{data:n}=await s.schema(e).from("leaders").select("id_user").eq("alias",a).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 t.users){if(t.id_leader&&d.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,d.id_user,t.id_leader)}const i=t.users.map(e=>({alias:a,id_user:e.id_user,id_leader:t.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=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{l.toast.error(e.message||"Erro ao adicionar liderados")}})}function td(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");const{data:r}=await s.schema(e).from("leaders").select("id_user").eq("id",t.id).eq("alias",a).single();if(!r)throw new Error("Líder não encontrado");if(r.id_user===t.id_leader)throw new Error("Usuário não pode ser seu próprio líder");t.id_leader&&await nd(s,a,e,r.id_user,t.id_leader,t.id);const{data:n,error:i}=await s.schema(e).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",a).select().single();if(i)throw i;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder atualizado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao atualizar líder")}})}function sd(){const{alias:e}=$t(),a=v.useQueryClient(),t=it();return v.useMutation({mutationFn:async a=>{if(!e)throw new Error("Unidade não selecionada");const{error:s}=await t.schema("common").from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(s)throw s},onSuccess:()=>{a.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 rd(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!a)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",a).eq("is_removed",!1).eq("id_leader",t),s.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",a).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||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),x=m.filter(e=>e.id_leader!==t),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const y of x)await nd(s,a,e,y.id_user,t,y.id);for(const y of g){if(y.id_user===t)throw new Error("Usuário não pode ser seu próprio líder");await nd(s,a,e,y.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(s.schema(e).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",a))}if(x.length){const r=x.map(e=>e.id);b.push(s.schema(e).from("leaders").update({id_leader:t}).in("id",r).eq("alias",a))}if(g.length){const r=g.map(e=>({alias:a,id_user:e.id_user,id_leader:t,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:x.length,created:g.length}},onSuccess:e=>{t.invalidateQueries({queryKey:["leadership",a]}),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 nd(e,a,t,s,r,n){const{data:i,error:o}=await e.schema(t).from("leaders").select("id, id_user, id_leader").eq("alias",a).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 id({leader:a,expandedIds:t,onToggleExpand:s,onEdit:r}){const n=t.has(a.id),i=a.children.length>0,o=32*a.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(a.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(a)},className:"font-medium hover:text-primary hover:underline text-left",children:a.name||a.id_user||a.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:a.subordinatesCount||0})})]}),i&&n&&a.children.map(a=>e.jsx(id,{leader:a,expandedIds:t,onToggleExpand:s,onEdit:r},a.id))]})}var od=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,i=s.path.join(".");if(!t[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];t[i]={message:o.message,type:o.code}}else t[i]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[i].types,d=l&&l[s.code];t[i]=p.appendErrors(i,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},ld=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,i){try{var o=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&J.validateFieldsNatively({},n),{errors:{},values:t.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:J.toNestErrors(od(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(i){return Promise.reject(i)}}};const dd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string()).min(1,"Selecione pelo menos um liderado")}),cd=X.z.object({id_leader:X.z.string().nullable(),id_users:X.z.array(X.z.string())});function ud({value:t,onChange:s,excludeUserIds:r=[],error:n}){const{data:i=[],isLoading:o}=Zs(),[l,c]=a.useState(""),u=a.useRef(null),m=a.useRef(0),{t:p}=g.useTranslation(),h=i.filter(e=>!r.includes(e.userId||"")).filter(e=>{const a=l.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const s=t.includes(e.userId),r=t.includes(a.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",i=a.userName||a.userEmail||"";return n.localeCompare(i)});return a.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[h]),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:p("loading_data")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ee,{placeholder:p("search_user"),value:l,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===h.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:p("search_user")}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(va,{id:a.userId,checked:t.includes(a.userId),onCheckedChange:()=>{return e=a.userId,u.current&&(m.current=u.current.scrollTop),void(t.includes(e)?s(t.filter(a=>a!==e)):s([...t,e]));var e}}),e.jsx(Re,{htmlFor:a.userId,className:"flex-1 cursor-pointer",children:a.userName||a.userEmail})]},a.userId))})}),t.length>0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p("selected_count",{count:t.length})}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function md({leader:t,prefilledLeaderId:s,onSuccess:r}){const{t:n}=g.useTranslation(),{alias:i}=$t(),o=!!t,l=t?.id.startsWith("virtual-"),c=ad(),u=ed(),m=td(),h=rd(),x=sd(),{data:f=[]}=Zl(),{data:b=[]}=Zs(),[v,y]=a.useState(""),j=Yl(f).map(e=>e.id_user),N=o?Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user):[],w=p.useForm({resolver:ld(o?cd:dd),defaultValues:{id_leader:s||(o?t?.id_leader:null)||null,id_users:o?N:[]}});a.useEffect(()=>{if(t){const e=Yl(f).filter(e=>e.id_leader===t.id_user).map(e=>e.id_user);w.reset({id_leader:t.id_leader||null,id_users:e})}else s?w.reset({id_leader:s,id_users:[]}):w.reset({id_leader:null,id_users:[]})},[i,t?.id,t?.id_user,t?.id_leader,s,f]);const C=c.isPending||u.isPending||m.isPending||h.isPending||x.isPending,k=w.watch("id_leader"),S=w.watch("id_users"),P=o?[t.id_user,...j.filter(e=>e!==t.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...j.filter(e=>!S.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:w.handleSubmit(async e=>{try{if(o)if(l){await u.mutateAsync({id_user:t.id_user,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{await m.mutateAsync({id:t.id,id_leader:e.id_leader});const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await h.mutateAsync({leaderUserId:t.id_user,selectedUsers:a})}else{const a=b.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await c.mutateAsync({id_leader:e.id_leader,users:a})}r?.()}catch(a){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Re,{children:n("leader")}),e.jsx(Ee,{value:b.find(e=>e.userId===t.id_user)?.userName||t.name||t.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Re,{children:n("superior")}),e.jsxs(da,{value:k||"none",onValueChange:e=>w.setValue("id_leader","none"===e?null:e),children:[e.jsx(ma,{children:e.jsx(ua,{placeholder:n("select_placeholder")})}),e.jsxs(xa,{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:v,onChange:e=>y(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(Qs,{className:"h-[200px]",children:[e.jsx(ga,{value:"none",children:"[Nenhum]"}),b.filter(e=>{const a=o?e.userId!==t.id_user:!S.includes(e.userId),s=!v||e.userName?.toLowerCase().includes(v.toLowerCase());return a&&s}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(a=>e.jsx(ga,{value:a.userId,children:a.userName},a.userId))]})]})]},`superior-select-${i}`),w.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:w.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsxs(Re,{children:[n("subordinates")," *"]}),e.jsx(ud,{value:S,onChange:e=>w.setValue("id_users",e),excludeUserIds:P,error:w.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(_e,{type:"submit",disabled:C||!o&&0===S.length,children:C&&!x.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(_e,{type:"button",variant:"destructive",disabled:C,onClick:async()=>{if(t&&window.confirm(n("remove_confirm")))try{await x.mutateAsync(t.id),r?.()}catch(e){}},className:"ml-auto",children:x.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 pd({open:a,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return e.jsx($e,{open:a,onOpenChange:t,children:e.jsxs(Qe,{className:"sm:max-w-[500px]",children:[e.jsx(Ke,{children:e.jsx(Ye,{children:n})}),e.jsx(md,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const hd="leadership-expanded-nodes",xd=(e,a)=>{try{localStorage.setItem(`${hd}-${e}`,JSON.stringify(Array.from(a)))}catch(t){}};function fd(e){const[t,s]=a.useState(!1),[r,n]=a.useState(0),{t:i}=g.useTranslation(),{uploadFunction:o,deleteFunction:d,defaultOptions:c,onSuccess:u,onError:m}=e||{};return{upload:async(e,a)=>{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 t={...c,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await o(e,t);return n(100),l.toast.success("Sucesso",{description:i("file_upload_success")}),u?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),m?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{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,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:t,progress:r}}function gd(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function bd(e,a){const t=gd(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function vd(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function yd(e,a){const t=vd(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function jd(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function Nd(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function wd(e,a){return e/a}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 g.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return g.useTranslation}}),exports.AUTH_CONFIG=gt,exports.Accordion=Hr,exports.AccordionContent=Kr,exports.AccordionItem=Gr,exports.AccordionTrigger=Qr,exports.ActionButton=Ae,exports.ActionMenu=pl,exports.ActionMenuItems=Ls,exports.Alert=yr,exports.AlertDescription=Nr,exports.AlertDialog=Xr,exports.AlertDialogAction=nn,exports.AlertDialogCancel=on,exports.AlertDialogContent=en,exports.AlertDialogDescription=rn,exports.AlertDialogFooter=tn,exports.AlertDialogHeader=an,exports.AlertDialogOverlay=Zr,exports.AlertDialogPortal=Yr,exports.AlertDialogTitle=sn,exports.AlertDialogTrigger=Jr,exports.AlertTitle=jr,exports.AppHeader=kl,exports.AppLayout=ql,exports.AppSidebar=Ul,exports.AuthErrorInterceptor=ut,exports.AuthProvider=qt,exports.AuthService=Ot,exports.Avatar=ln,exports.AvatarFallback=cn,exports.AvatarImage=dn,exports.Badge=Na,exports.BaseForm=ar,exports.Blockquote=Ni,exports.Breadcrumb=un,exports.BreadcrumbEllipsis=gn,exports.BreadcrumbItem=pn,exports.BreadcrumbLink=hn,exports.BreadcrumbList=mn,exports.BreadcrumbPage=xn,exports.BreadcrumbSeparator=fn,exports.BulkActionBar=rr,exports.Button=_e,exports.ButtonGroup=vn,exports.CRUD_CONFIG=bt,exports.Calendar=$n,exports.CallbackPage=()=>{const{processCallback:t}=$t(),[s,r]=a.useState(null),[n,i]=a.useState(!1);a.useEffect(()=>{(async()=>{try{if(await t()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[t]);const o=async()=>{i(!0),r(null);try{await t()||r("Falha na autenticação. Tente novamente.")}catch(e){r(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},l=()=>{window.location.href="/"};return s?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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsxs(ze,{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(yr,{variant:"danger",children:e.jsx(Nr,{children:s})}),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(_e,{onClick:o,disabled:n,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{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(_e,{onClick:l,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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{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(Ca,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=De,exports.CardContent=Oe,exports.CardDescription=Le,exports.CardFooter=Ue,exports.CardHeader=Fe,exports.CardSkeleton=Zt,exports.CardTitle=ze,exports.ChartContainer=rl,exports.ChartLegend=ll,exports.ChartLegendContent=dl,exports.ChartStyle=nl,exports.ChartTooltip=il,exports.ChartTooltipContent=ol,exports.Checkbox=va,exports.Collapsible=Ur,exports.CollapsibleContent=$r,exports.CollapsibleTrigger=qr,exports.ColorPicker=Gs,exports.Combobox=Ua,exports.Command=Ia,exports.CommandDialog=({children:a,...t})=>e.jsx("div",{...t,children:e.jsx(Ia,{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:a})}),exports.CommandEmpty=Ea,exports.CommandGroup=Ma,exports.CommandInput=_a,exports.CommandItem=Da,exports.CommandList=Aa,exports.CommandSeparator=Ra,exports.CommandShortcut=Fa,exports.ContextMenu=ws,exports.ContextMenuCheckboxItem=Ms,exports.ContextMenuContent=As,exports.ContextMenuGroup=ks,exports.ContextMenuItem=Es,exports.ContextMenuLabel=Ds,exports.ContextMenuPortal=Ss,exports.ContextMenuRadioGroup=Ts,exports.ContextMenuRadioItem=Rs,exports.ContextMenuSeparator=Fs,exports.ContextMenuShortcut=zs,exports.ContextMenuSub=Ps,exports.ContextMenuSubContent=_s,exports.ContextMenuSubTrigger=Is,exports.ContextMenuTrigger=Cs,exports.CoreProviders=function({children:a,queryClient:t}){const s=t??new v.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}});return e.jsx(Vr,{children:e.jsx(g.I18nextProvider,{i18n:o,children:e.jsx(v.QueryClientProvider,{client:s,children:e.jsx(qt,{children:e.jsx(zr,{children:e.jsx(Or,{children:a})})})})})})},exports.CrudPageInternal=cr,exports.CrudPagination=sr,exports.CrudPrimitiveFilterBar=function({searchValue:a="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:i="horizontal"}){const{t:o}=g.useTranslation(),l=a||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===i?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&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:a,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((a,t)=>e.jsx("div",{className:"vertical"===i?"w-full":"",children:a},t)),n&&l&&r&&e.jsxs(_e,{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=tr,exports.CrudPrimitiveTable=function({data:t,columns:s,sortField:r,sortDirection:n,onSort:i,onRowClick:o,renderActions:l,isLoading:c=!1,emptyMessage:u="Nenhum item encontrado",className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:v,storageKey:y}){const{columnWidths:j,isDragging:N,activeColumn:w,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:y?`${y}-columns`:void 0,onResize:v,enabled:b}),{isDragging:k,activeRow:S,handleMouseDown:P,getRowHeight:T}=$s({rowIds:t.map(e=>e.id),storageKey:y?`${y}-rows`:void 0,enabled:!1}),I=a.useMemo(()=>{if(b)return s.map(e=>`${j[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[s,b,j]);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((a,t)=>e.jsx(za,{className:"h-12 w-full"},t))})});if(0===t.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 _=N||k;return e.jsx("div",{className:"flex-1 overflow-auto "+(_?"select-none":""),children:e.jsxs(Wt,{className:m,children:[e.jsx(Vt,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Qt,{children:[p&&e.jsx(Kt,{className:"w-[40px]",children:e.jsx(va,{checked:g,onCheckedChange:f,"aria-label":"Selecionar todos"})}),s.map((a,t)=>{const s=b&&!1!==a.resizable,o=w===String(a.key);return e.jsxs(Kt,{className:`${a.className||""} relative`,style:{width:I[t]},children:[a.sortable&&i?e.jsxs("button",{onClick:()=>i(String(a.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[a.header,(l=String(a.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:a.header}),s&&e.jsx(os,{direction:"horizontal",onMouseDown:e=>C(String(a.key),e),isDragging:o})]},String(a.key));var l}),l&&e.jsx(Kt,{className:"w-[80px] text-right",children:"Ações"})]})}),e.jsx(Ht,{children:t.map(a=>{const t=T(a.id);return a.id,e.jsxs(Qt,{onClick:()=>o?.(a),className:(o?"cursor-pointer":"")+" relative",style:t?{height:`${t}px`}:void 0,children:[p&&e.jsx(Xt,{children:e.jsx(va,{checked:h.includes(a.id),onCheckedChange:()=>x?.(a.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${a.id}`})}),s.map(t=>e.jsx(Xt,{className:t.className,children:e.jsx(is,{children:t.render?t.render(a):String(a[t.key]??"-")})},String(t.key))),l&&e.jsx(Xt,{className:"text-right",onClick:e=>e.stopPropagation(),children:l(a)})]},a.id)})})]})})},exports.CrudTable=Ws,exports.DataList=Bn,exports.DatePicker=function({date:a,onDateChange:t,placeholder:s="Pick a date",disabled:r=!1,className:n,disabledDates:o}){return e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs(_e,{variant:"outline",disabled:r,className:Pe("w-full justify-start text-left font-normal",!a&&"text-muted-foreground",n),children:[e.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),a?i.format(a,"PPP"):e.jsx("span",{children:s})]})}),e.jsx(Ta,{className:"w-auto p-0",align:"start",children:e.jsx($n,{mode:"single",selected:a,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=$e,exports.DialogBody=Xe,exports.DialogClose=Ve,exports.DialogContent=Qe,exports.DialogDescription=Ze,exports.DialogFooter=Je,exports.DialogHeader=Ke,exports.DialogOverlay=He,exports.DialogPortal=We,exports.DialogTitle=Ye,exports.DialogTrigger=Be,exports.Drawer=Wn,exports.DrawerClose=Gn,exports.DrawerContent=Kn,exports.DrawerDescription=Zn,exports.DrawerFooter=Jn,exports.DrawerHeader=Xn,exports.DrawerOverlay=Qn,exports.DrawerPortal=Hn,exports.DrawerTitle=Yn,exports.DrawerTrigger=Vn,exports.DropdownMenu=ls,exports.DropdownMenuCheckboxItem=bs,exports.DropdownMenuContent=fs,exports.DropdownMenuGroup=cs,exports.DropdownMenuItem=gs,exports.DropdownMenuLabel=ys,exports.DropdownMenuPortal=us,exports.DropdownMenuRadioGroup=ps,exports.DropdownMenuRadioItem=vs,exports.DropdownMenuSeparator=js,exports.DropdownMenuShortcut=Ns,exports.DropdownMenuSub=ms,exports.DropdownMenuSubContent=xs,exports.DropdownMenuSubTrigger=hs,exports.DropdownMenuTrigger=ds,exports.EmailService=Wl,exports.EmptyState=as,exports.EntitySelect=Ua,exports.ErrorBoundary=Vr,exports.FilterBar=dr,exports.Form=ea,exports.FormControl=ia,exports.FormDescription=oa,exports.FormField=({...a})=>e.jsx(aa.Provider,{value:{name:a.name},children:e.jsx(p.Controller,{...a})}),exports.FormItem=ra,exports.FormLabel=na,exports.FormMessage=la,exports.FormSkeleton=function({fields:a=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:a}).map((a,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(za,{className:"h-4 w-24"}),e.jsx(za,{className:"h-10 w-full"})]},t)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(za,{className:"h-10 w-20"}),e.jsx(za,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:a,cols:t="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Pe("grid",ei[t],ai[s],r),children:a})},exports.H1=mi,exports.H2=pi,exports.H3=hi,exports.H4=xi,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(za,{className:"h-8 w-8 rounded-full"}),e.jsx(za,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(za,{className:"h-8 w-8"}),e.jsx(za,{className:"h-8 w-24"})]})]})},exports.HoverCard=ti,exports.HoverCardContent=ri,exports.HoverCardTrigger=si,exports.IconPicker=Js,exports.ImageEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{alignment:"center",allowDownload:!1}),h=a.useRef(null),{upload:x,uploading:f}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),b=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{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=>b("imageUrl",e.target.value),className:"flex-1"}),i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?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(Re,{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(Re,{htmlFor:"caption",children:u("caption")}),e.jsx(ya,{id:"caption",placeholder:u("caption"),value:m.caption||"",onChange:e=>b("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"alt",children:u("alt")}),e.jsx(Ee,{id:"alt",placeholder:u("alt"),value:m.alt||"",onChange:e=>b("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("alignment")}),e.jsxs(da,{value:m.alignment||"center",onValueChange:e=>b("alignment",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"left",children:u("left")}),e.jsx(ga,{value:"center",children:u("center")}),e.jsx(ga,{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(Re,{htmlFor:"width",children:u("width")}),e.jsx(Ee,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>b("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"height",children:u("height")}),e.jsx(Ee,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>b("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=>b("allowDownload",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{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(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{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:a,className:t="",style:s}){if(!a.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[a.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${t}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:a.imageUrl,alt:a.alt||"",style:{width:a.width?`${a.width}px`:"auto",height:a.height?`${a.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),a.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:a.caption}),a.allowDownload&&a.imageUrl&&e.jsxs("a",{href:a.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=ji,exports.Input=Ee,exports.InputGroup=ni,exports.InputGroupAddon=oi,exports.InputGroupButton=di,exports.InputGroupInput=ci,exports.InputGroupTextarea=ui,exports.LOGO_CONFIG=wt,exports.Label=Re,exports.Large=bi,exports.Lead=gi,exports.LeaderRow=id,exports.LeadershipDialog=pd,exports.LeadershipForm=md,exports.LeadershipPage=function(){const{alias:t}=$t(),{t:s}=g.useTranslation(),{data:r,isLoading:n,error:i,refetch:o}=Zl(),{data:l=[]}=Zs({enabled:!0}),[c,u]=a.useState(()=>t?(e=>{try{const a=localStorage.getItem(`${hd}-${e}`);if(a)return new Set(JSON.parse(a))}catch(i){}return new Set})(t):new Set),[m,p]=a.useState(!1),[h,x]=a.useState(),[f,b]=a.useState(null),v=l.filter(e=>e.userName&&"Nome não disponível"!==e.userName),y=new Set(v.map(e=>e.userId)),j=v.length-(r?Yl(r).filter(e=>y.has(e.id_user)&&"[Não encontrado]"!==e.name).length:0);a.useEffect(()=>{if(r&&r.length>0&&t){if(!localStorage.getItem(`${hd}-${t}`)){const e=r.map(e=>e.id),a=new Set(e);u(a),xd(t,a)}}},[r,t]);const N=e=>{u(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),t&&xd(t,s),s})},w=e=>{x(e),b(null),p(!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(_e,{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(_e,{size:"sm",onClick:()=>{x(void 0),b(null),p(!0)},children:[e.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{if(!r)return;const e=Yl(r).filter(e=>e.children.length>0).map(e=>e.id),a=new Set(e);u(a),t&&xd(t,a)},disabled:!r||0===r.length,children:[e.jsx(d.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;u(e),t&&xd(t,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:[j," usuário",1!==j?"s":""," não associado",1!==j?"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(a=>e.jsx(id,{leader:a,expandedIds:c,onToggleExpand:N,onEdit:w},a.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(pd,{open:m,onOpenChange:()=>{p(!1),x(void 0),b(null)},leader:h,prefilledLeaderId:f,title:h?s("edit")+" "+s("name"):f?s("add")+" Liderado":s("add")+" Líder Raiz"},`leadership-dialog-${t}`)]})},exports.List=wi,exports.LoadingState=function({isLoading:a,children:t,className:s,type:r="spinner",size:n="md"}){return a?"overlay"===r?e.jsxs("div",{className:Pe("relative",s),children:[t,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ca,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Pe("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Pe("flex items-center justify-center py-8",s),children:e.jsx(Ca,{size:n})}):e.jsx(e.Fragment,{children:t})},exports.LocaleProvider=zr,exports.LocaleSelector=bl,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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{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(_e,{onClick:async()=>{yt()?await Ot.loginDev():Ot.loginProd()},className:"w-full",size:"lg",children:yt()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=Ct,exports.ManageAccessModal=Hl,exports.Menubar=Wo,exports.MenubarCheckboxItem=Xo,exports.MenubarContent=Qo,exports.MenubarGroup=Uo,exports.MenubarItem=Ko,exports.MenubarLabel=Yo,exports.MenubarMenu=Oo,exports.MenubarPortal=qo,exports.MenubarRadioGroup=Bo,exports.MenubarRadioItem=Jo,exports.MenubarSeparator=Zo,exports.MenubarShortcut=el,exports.MenubarSub=$o,exports.MenubarSubContent=Go,exports.MenubarSubTrigger=Ho,exports.MenubarTrigger=Vo,exports.ModalStateProvider=function({children:t}){const[s,r]=a.useState(new Set),[n,i]=a.useState(!1),o=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=a.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),d=a.useCallback(e=>{i(e)},[]),c=a.useMemo(()=>s.size>0||n,[s,n]),u=a.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:o,unregisterModal:l,setHasOpenModal:d}),[s,c,o,l,d]);return e.jsx(Ll.Provider,{value:u,children:t})},exports.MultiSelect=Ua,exports.Muted=yi,exports.NavigationMenu=Ci,exports.NavigationMenuContent=Ii,exports.NavigationMenuIndicator=Ei,exports.NavigationMenuItem=Si,exports.NavigationMenuLink=_i,exports.NavigationMenuList=ki,exports.NavigationMenuTrigger=Ti,exports.NavigationMenuViewport=Ai,exports.NavigationProvider=jl,exports.P=fi,exports.PageBreadcrumb=function({items:a,maxItems:t=3,className:s}){const r=a.length>t?[a[0],...a.slice(-(t-1))]:a,n=a.length>t;return e.jsx(un,{className:s,children:e.jsx(mn,{children:r.map((a,t)=>{const s=0===t,r=n&&1===t;return e.jsxs(pn,{children:[!s&&e.jsx(fn,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(gn,{}),e.jsx(fn,{})]}),a.isCurrentPage?e.jsx(xn,{children:a.label}):e.jsx(hn,{href:a.href,children:a.label})]},a.label)})})})},exports.PageMetadataProvider=Cr,exports.Pagination=Mi,exports.PaginationContent=Ri,exports.PaginationEllipsis=Oi,exports.PaginationItem=Di,exports.PaginationLink=Fi,exports.PaginationNext=Li,exports.PaginationPrevious=zi,exports.PlaceCard=Gl,exports.PlacesList=function({places:a,isLoading:t,manageAccessConfig:s}){const{t:r}=g.useTranslation();return t?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")})]})}):a&&0!==a.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),a.map(a=>e.jsx(Gl,{place:a,manageAccessConfig:s},a.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=Sa,exports.PopoverContent=Ta,exports.PopoverTrigger=Pa,exports.Progress=pr,exports.ProtectedRoute=({children:t})=>{const{isAuthenticated:s,isLoading:r}=$t();if(a.useEffect(()=>{if(!s)return;const e=()=>{Xa.areAllTokensValid()||Ot.logout()};e();const a=setInterval(e,3e5);return()=>clearInterval(a)},[s]),a.useEffect(()=>{if(r)return;if(s)return;if(Xa.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const n=yt();(async()=>{n?await Ot.loginDev():Ot.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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{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(De,{className:"w-full max-w-md",children:[e.jsx(Fe,{className:"text-center",children:e.jsx(ze,{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:yt()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:t})},exports.QUALIEX_CONFIG=jt,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=_t,exports.QualiexErrorInterceptor=pt,exports.QualiexUserField=er,exports.RadioGroup=Ui,exports.RadioGroupItem=qi,exports.ResizableHandle=({withHandle:a,className:t,...s})=>e.jsx(ve.PanelResizeHandle,{className:Pe("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",t),...s,children:a&&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=$i,exports.ResizablePanelGroup=({className:a,...t})=>e.jsx(ve.PanelGroup,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",a),...t}),exports.RichTextEditor=({value:t,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]=a.useState("visual"),p=B.useEditor({extensions:[W.configure({heading:{levels:[1,2,3]}}),V,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Q.Color,K.configure({multicolor:!0})],content:t||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});Z.useEffect(()=>{p&&t!==p.getHTML()&&p.commands.setContent(t||"")},[t,p]);const h=a.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?p.chain().focus().extendMarkRange("link").setLink({href:a}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Pe("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(_e,{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(_e,{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(_e,{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(ul,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(d.Heading1,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(d.Heading2,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(d.Heading3,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(d.Bold,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(d.Italic,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(d.Underline,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(d.Strikethrough,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(d.List,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(d.ListOrdered,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(d.Highlighter,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(d.Link,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(ml,{}),e.jsx(ul,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(d.Undo,{className:"h-4 w-4"})}),e.jsx(ul,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(d.Redo,{className:"h-4 w-4"})})]}),e.jsx(B.EditorContent,{editor:p,className:Pe("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:t||"",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:t||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=vt,exports.ScrollArea=Qs,exports.ScrollBar=Ks,exports.Select=da,exports.SelectContent=xa,exports.SelectGroup=ca,exports.SelectItem=ga,exports.SelectLabel=fa,exports.SelectScrollDownButton=ha,exports.SelectScrollUpButton=pa,exports.SelectSearch=Ua,exports.SelectSeparator=ba,exports.SelectTrigger=ma,exports.SelectValue=ua,exports.Separator=qe,exports.Sheet=Bi,exports.SheetBody=Ji,exports.SheetClose=Vi,exports.SheetContent=Ki,exports.SheetDescription=eo,exports.SheetFooter=Yi,exports.SheetHeader=Xi,exports.SheetOverlay=Gi,exports.SheetPortal=Hi,exports.SheetTitle=Zi,exports.SheetTrigger=Wi,exports.Sidebar=no,exports.SidebarActionTrigger=Fl,exports.SidebarContent=ho,exports.SidebarFooter=mo,exports.SidebarGroup=xo,exports.SidebarGroupAction=go,exports.SidebarGroupContent=bo,exports.SidebarGroupLabel=fo,exports.SidebarHeader=Dl,exports.SidebarInput=co,exports.SidebarInset=lo,exports.SidebarMenu=vo,exports.SidebarMenuAction=wo,exports.SidebarMenuBadge=Co,exports.SidebarMenuButton=No,exports.SidebarMenuItem=yo,exports.SidebarMenuSkeleton=ko,exports.SidebarMenuSub=So,exports.SidebarMenuSubButton=To,exports.SidebarMenuSubItem=Po,exports.SidebarProvider=ro,exports.SidebarRail=oo,exports.SidebarSeparator=po,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(za,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx(za,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=io,exports.Skeleton=za,exports.Slider=Io,exports.Small=vi,exports.SonnerToaster=ka,exports.Spinner=Ca,exports.SplitButton=function({label:a,onClick:t,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:Pe("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,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,a]}),e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(_e,{variant:n,size:i,disabled:m,className:Pe("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(fs,{align:c,className:"min-w-[160px]",children:r.map(a=>{const t=a.icon;return e.jsxs(gs,{onClick:a.onClick,disabled:a.disabled,className:Pe("destructive"===a.variant&&"text-destructive focus:text-destructive"),children:[t&&e.jsx(t,{className:"mr-2 h-4 w-4"}),a.label]},a.id)})})]})]}):e.jsxs(_e,{variant:n,size:i,disabled:m,onClick:t,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,a]})},exports.Stack=lr,exports.Switch=Ys,exports.TabPageContent=function({children:a,className:t}){return e.jsx("div",{className:Pe("space-y-6",t),children:a})},exports.TabPageHeader=function({title:a,description:t,actions:s,className:r}){return e.jsxs("div",{className:Pe("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:a}),t&&e.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(qe,{})]})},exports.TabPageLayout=function({children:a,className:t}){return e.jsx("div",{className:Pe("flex flex-col h-full",t),children:e.jsx(Qs,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:a})})})},exports.Table=Wt,exports.TableBody=Ht,exports.TableCaption=Jt,exports.TableCell=Xt,exports.TableFooter=Gt,exports.TableHead=Kt,exports.TableHeader=Vt,exports.TableResizeHandle=os,exports.TableRow=Qt,exports.TableRowActions=Os,exports.TableSkeleton=Yt,exports.Tabs=_o,exports.TabsContent=Mo,exports.TabsList=Ao,exports.TabsTrigger=Eo,exports.Textarea=ya,exports.Toaster=ka,exports.Toggle=Do,exports.ToggleGroup=zo,exports.ToggleGroupItem=Lo,exports.TokenManager=Xa,exports.TokenService=$a,exports.Tooltip=ss,exports.TooltipContent=ns,exports.TooltipProvider=ts,exports.TooltipTrigger=rs,exports.TranslationLoader=Or,exports.TruncatedCell=is,exports.VideoEditor=function({value:t,onChange:s,onSubmit:r,onCancel:n,uploadFunction:i,deleteFunction:o,uploadOptions:c}){const{t:u}=g.useTranslation(),[m,p]=a.useState(t||{inputType:"url",controls:!0}),h=a.useRef(null),x=a.useRef(null),{upload:f,uploading:b}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:v,uploading:y}=fd({uploadFunction:i,deleteFunction:o,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),j=a.useMemo(()=>Nd(m.videoUrl||jd(m.embedCode)||""),[m.videoUrl,m.embedCode]),N=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("input_type")}),e.jsxs(da,{value:m.inputType||"url",onValueChange:e=>N("inputType",e),children:[e.jsx(ma,{children:e.jsx(ua,{})}),e.jsxs(xa,{children:[e.jsx(ga,{value:"url",children:u("url")}),e.jsx(ga,{value:"upload",children:u("input_type_upload")}),e.jsx(ga,{value:"embed",children:u("input_type_embed")})]})]})]}),"upload"===m.inputType&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("file")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:h,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await f(a),t={...m,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:m.title||a.name.replace(/\.[^/.]+$/,"")};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?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(Re,{children:u("embed")}),e.jsx(ya,{placeholder:u("embed"),value:m.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("thumbnail")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ee,{type:"url",placeholder:u("thumbnail"),value:m.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await v(a),t={...m,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};p(t),s(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),e.jsx(_e,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:y,children:y?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(Re,{htmlFor:"title",children:u("title")}),e.jsx(Ee,{id:"title",placeholder:u("title"),value:m.title||"",onChange:e=>N("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=>N("autoplay",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{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=>N("controls",e.target.checked),className:"h-4 w-4"}),e.jsx(Re,{htmlFor:"controls",className:"cursor-pointer",children:u("video.controls")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:u("preview")}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const a=m.videoUrl||jd(m.embedCode)||"";if(!a)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:u("no_content_preview")});if("file"===j)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:a}),u("unsupported")]});const t="youtube"===j?bd(a,m.autoplay):yd(a,m.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:m.title||u("video"),src:t,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(_e,{variant:"outline",onClick:n,children:u("cancel")}),e.jsx(_e,{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:a,className:t="",style:s}){const r=a.videoUrl||jd(a.embedCode)||"";if(!r)return null;const n=Nd(r),{t:i}=g.useTranslation();return e.jsx(De,{className:`overflow-hidden my-4 ${t}`,style:s,children:e.jsxs(Oe,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==a.controls,autoPlay:a.autoplay,poster:a.thumbnail,className:"w-full h-auto",playsInline:!0,muted:a.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:a.title||i("video"),src:"youtube"===n?bd(r,a.autoplay):yd(r,a.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),a.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:a.title})})]})})},exports.WizardBreadcrumb=xr,exports.WizardButtons=gr,exports.WizardForm=function({title:t,sections:s,initialData:r,onSubmit:n,onCancel:i,open:o,submitButtonText:l,isLoading:d=!1,usersData:c,showProgressIndicator:u=!0,progressType:m="stepper",validateOnNext:p=!0,allowSkipSections:h=!1,previousButtonText:x,nextButtonText:f,onStepChange:g,onStepValidationFail:b,renderProgressIndicator:v,renderButtons:y,currentStepIndex:j,onCurrentStepChange:N}){const[w,C]=a.useState(0),k=j??w,S=N??C,P=a.useRef(null),[T,I]=a.useState(null),_=a.useCallback(e=>{P.current=e,I(e)},[]),A=a.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:E,errors:M,updateField:R,handleSubmit:D}=Vs(A,r,void 0,o);a.useEffect(()=>{o&&S(0)},[o,S]);const F=a.useCallback(()=>{const e=s[k];if(!e)return!0;const a=e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e),t={};let r=!0;return a.forEach(e=>{const a=E[e.name];if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length)&&(t[e.name]=`${e.label} é obrigatório`,r=!1),e.validation&&"function"==typeof e.validation){const s=e.validation(a,E);s&&(t[e.name]=s,r=!1)}}),!r&&b&&b(k,t),r},[s,k,E,b]),z=a.useCallback(()=>{if(p&&!F())return;const e=k+1;e<s.length&&(S(e),g?.(e,s[e].id))},[k,s,p,F,S,g]),L=a.useCallback(()=>{const e=k-1;e>=0&&(S(e),g?.(e,s[e].id))},[k,s,S,g]),O=a.useCallback(()=>{let e=!0;for(let a=0;a<s.length;a++){s[a].fields.flatMap(e=>"group"===e.type?e.fields||[]:e).forEach(a=>{const t=E[a.name];a.required&&(""===t||null==t||Array.isArray(t)&&0===t.length)&&(e=!1)})}e&&D(n)()},[s,E,D,n]),U=a.useMemo(()=>s.map((e,a)=>({index:a,id:e.id,label:e.label||e.id,isActive:a===k,isCompleted:a<k,isDisabled:e.disabled||!1})),[s,k]),q=0===k,$=k===s.length-1,B=a.useMemo(()=>{if(!u)return null;if(v)return v(k,s.length,s);const a=h?e=>{S(e),g?.(e,s[e].id)}:void 0;switch(m){case"breadcrumb":return e.jsx(xr,{steps:U,currentStepIndex:k,onStepClick:a});case"progressbar":return e.jsx(fr,{steps:U,currentStepIndex:k});default:return e.jsx(hr,{steps:U,currentStepIndex:k,onStepClick:a})}},[u,v,m,U,k,s,h,S,g]),W=a.useMemo(()=>{const a={isFirstStep:q,isLastStep:$,canGoNext:k<s.length-1,canGoPrevious:k>0,isLoading:d,onPrevious:L,onNext:z,onSubmit:O,previousButtonText:x,nextButtonText:f,submitButtonText:l};return y?y(a):e.jsx(gr,{...a})},[q,$,k,s.length,d,L,z,O,x,f,l,y]),V=a=>{const t=(a.computedValue,E[a.name]),s=void 0!==t?t:"",r=M[a.name];switch(a.type){case"group":return e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsx(Re,{className:"text-sm font-medium",children:a.label}),e.jsx("div",{className:Pe("grid gap-4",1===a.columns&&"grid-cols-1",2===a.columns&&"grid-cols-1 md:grid-cols-2",3===a.columns&&"grid-cols-1 md:grid-cols-3",4===a.columns&&"grid-cols-1 md:grid-cols-4",!a.columns&&"grid-cols-1"),children:a.fields?.map(e=>V(e))})]},a.name);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:"number",value:s,onChange:e=>R(a.name,""===e.target.value?"":Number(e.target.value)),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(ya,{id:a.name,value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled,rows:a.rows||3,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(da,{value:s,onValueChange:e=>R(a.name,e),children:[e.jsx(ma,{className:r?"border-destructive":"",children:e.jsx(ua,{placeholder:a.placeholder||`Selecione ${a.label}`})}),e.jsx(xa,{children:a.options?.map(a=>e.jsx(ga,{value:String(a.value),children:a.label},a.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"multiselect":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ua,{options:a.options||[],value:Array.isArray(s)?s:[],onChange:e=>R(a.name,e),placeholder:a.placeholder,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"color":case"color-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Gs,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"icon-picker":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Js,{value:s,onChange:e=>R(a.name,e),label:""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"user-select":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(er,{value:s,onChange:e=>R(a.name,e),placeholder:a.placeholder,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name);case"custom":return a.render?e.jsxs("div",{className:"space-y-2",children:[a.label&&e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.render({value:s,onChange:e=>R(a.name,e),error:r,disabled:a.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name):null;default:return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Re,{htmlFor:a.name,children:[a.label,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ee,{id:a.name,type:a.type||"text",value:s,onChange:e=>R(a.name,e.target.value),placeholder:a.placeholder,disabled:a.disabled||void 0!==a.computedValue,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},a.name)}},H=s[k];return e.jsx($e,{open:o,onOpenChange:i,children:e.jsxs(Qe,{ref:_,className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ke,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:e.jsx(Ye,{className:"text-white",children:t})}),B,e.jsx("div",{className:"space-y-4 py-4",children:H?.fields.map(e=>V(e))}),e.jsx("div",{className:"flex justify-between pt-4 border-t",children:W})]})})},exports.WizardProgressBar=fr,exports.WizardStepper=hr,exports.assets=El,exports.badgeVariants=ja,exports.buildHierarchy=Jl,exports.buttonGroupVariants=bn,exports.buttonVariants=Ie,exports.calculateAspectRatio=wd,exports.cn=Pe,exports.createCrudPage=function(a){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:i,onToggleStatus:o}=a,l=t??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};return e.jsx(cr,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:o,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=hl({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createRoutingHandlers=hl,exports.createService=Mt,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=Mt({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:a,useCrudHook:(t,s)=>Bt({queryKey:e.tableName,service:{...a,getAll:async(e={})=>await a.getAll({...e})},entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=St,exports.deriveNameField=kt,exports.deriveUsernameField=Pt,exports.detectVideoProvider=Nd,exports.emailService=Vl,exports.errorService=Za,exports.extractImageFileName=function(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}},exports.extractVimeoId=vd,exports.extractYouTubeId=gd,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))},exports.flattenTree=Yl,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=Bl,exports.formatDatetime=e=>{if(!e)return"";const a=i.parseISO(e);if(!i.isValid(a))return"Data inválida";return`${a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"America/Sao_Paulo"})} ${a.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,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:mr(e),label:mr(e),...ur(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.getQualiexConfig=Nt,exports.getSupabaseClient=it,exports.handleExternalLink=Se,exports.inputGroupAddonVariants=ii,exports.inputGroupButtonVariants=li,exports.isDevEnvironment=yt,exports.isImageUrl=function(e){const a=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>a.includes(e))},exports.logoSrc=Ml,exports.navigationMenuTriggerStyle=Pi,exports.normalizeVideoUrl=function(e,a,t){switch(a||Nd(e)){case"youtube":return bd(e,t);case"vimeo":return yd(e,t);default:return e}},exports.normalizeVimeoUrl=yd,exports.normalizeYouTubeUrl=bd,exports.parseIframeSrc=jd,exports.placeService=Xl,exports.qualiexApi=ft,exports.resizeKeepingAspect=function(e,a,t,s){const r=wd(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=Tt,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new v.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=Rl,exports.toggleVariants=Ro,exports.translationService=Ar,exports.trimTextFields=Te,exports.useActiveModules=Pl,exports.useAuth=$t,exports.useBaseForm=Vs,exports.useColumnResize=qs,exports.useCreateLeaderMutation=function(){const e="common",{alias:a}=$t(),t=v.useQueryClient(),s=it();return v.useMutation({mutationFn:async t=>{if(!a)throw new Error("Unidade não selecionada");if(t.id_user===t.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",a).eq("id_user",t.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");t.id_leader&&await nd(s,a,e,t.id_user,t.id_leader);const{data:r,error:n}=await s.schema(e).from("leaders").insert({alias:a,id_user:t.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",a]}),l.toast.success("Líder adicionado com sucesso")},onError:e=>{l.toast.error(e.message||"Erro ao adicionar líder")}})},exports.useCreateMultipleLeadersMutation=ad,exports.useCreateSingleLeaderMutation=ed,exports.useCrud=Bt,exports.useDebounce=Cl,exports.useFormField=ta,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Ol();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a,datetimeFormat:t}=Lr();return{formatDatetime:e=>((e,a="dd/MM/yyyy HH:mm")=>{if(!e)return"";const t=i.parseISO(e);return i.isValid(t)?i.format(t,a):"Invalid date"})(e,t,a),formatDate:a=>Bl(a,e),locale:e,timezone:a,datetimeFormat:t}},exports.useLeadershipApi=Zl,exports.useLocale=Lr,exports.useMediaUpload=fd,exports.useModalState=Ol,exports.useNavigation=Nl,exports.usePageMetadata=function(e){const{setMetadata:t,clearMetadata:s}=kr();a.useEffect(()=>(t(e),()=>s()),[e.title,e.subtitle,t,s])},exports.usePageMetadataContext=kr,exports.usePageTitle=wl,exports.usePermissionQuery=Sl,exports.useQualiexUsers=Zs,exports.useRemoveLeaderMutation=sd,exports.useRouteBreadcrumbs=function(){const e=y.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:n?void 0:s,isCurrentPage:n})}),t})()},exports.useRowResize=$s,exports.useSidebar=so,exports.useSidebarResize=zl,exports.useSyncSubordinatesMutation=rd,exports.useUpdateLeaderMutation=td;