forlogic-core 1.16.0 → 1.16.2
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/.note/memory/features/import/attachment-strategy.md +18 -0
- package/README.md +2 -1
- package/dist/README.md +116 -112
- package/dist/auth/services/TokenManager.d.ts +5 -0
- package/dist/bin/pull-docs.js +1 -1
- package/dist/components/modules/ModuleAccessGuard.d.ts +16 -0
- package/dist/components/modules/index.d.ts +2 -0
- package/dist/contexts/ModuleContext.d.ts +34 -0
- package/dist/hooks/useModuleAccess.d.ts +60 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/CoreProviders.d.ts +20 -4
- package/dist/qualiex/services/qualiexApi.d.ts +18 -1
- package/dist/setup.d.ts +2 -0
- package/dist/types.d.ts +58 -0
- package/docs/DESIGN_SYSTEM.md +22 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),d=require("@radix-ui/react-label"),c=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("@radix-ui/react-alert-dialog"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),x=require("@radix-ui/react-dropdown-menu"),g=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),v=require("react-i18next"),w=require("@radix-ui/react-scroll-area"),N=require("@supabase/supabase-js"),y=require("@tanstack/react-query"),j=require("react-router-dom"),C=require("@radix-ui/react-context-menu"),k=require("@radix-ui/react-toggle-group"),S=require("@radix-ui/react-toggle"),_=require("@radix-ui/react-switch"),T=require("i18next"),A=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-accordion"),P=require("@radix-ui/react-avatar"),M=require("react-day-picker"),I=require("vaul"),D=require("@radix-ui/react-hover-card"),R=require("@radix-ui/react-navigation-menu"),L=require("@radix-ui/react-progress"),z=require("@radix-ui/react-radio-group"),F=require("react-resizable-panels"),U=require("@radix-ui/react-slider"),q=require("@radix-ui/react-tabs"),O=require("@radix-ui/react-menubar"),B=require("recharts"),$=require("@tiptap/react"),H=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),W=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("zod"),X=require("@hookform/resolvers");function Z(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var J=Z(t),ee=Z(d),te=Z(c),ae=Z(u),se=Z(m),re=Z(h),ne=Z(f),oe=Z(x),ie=Z(g),le=Z(b),de=Z(w),ce=Z(C),ue=Z(k),me=Z(S),pe=Z(_),he=Z(A),fe=Z(E),xe=Z(P),ge=Z(D),be=Z(R),ve=Z(L),we=Z(z),Ne=Z(F),ye=Z(U),je=Z(q),Ce=Z(O),ke=Z(B);const Se={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"}};function _e(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const Te={date:_e({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:_e({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:_e({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ae={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Ee(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}const Pe={ordinalNumber:(e,t)=>{const a=Number(e),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Ee({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})};function Me(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(o.length)}}}function Ie(e){return(t,a={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(r.length)}}}const De={ordinalNumber:Ie({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},Re={code:"en-US",formatDistance:(e,t,a)=>{let s;const r=Se[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s},formatLong:Te,formatRelative:(e,t,a,s)=>Ae[e],localize:Pe,match:De,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Le={};function ze(){return Le}const Fe=6048e5;function Ue(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function qe(e){const t=Ue(e);return t.setHours(0,0,0,0),t}function Oe(e){const t=Ue(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function Be(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function $e(e){const t=Ue(e),a=function(e,t){const a=qe(e),s=qe(t),r=+a-Oe(a),n=+s-Oe(s);return Math.round((r-n)/864e5)}(t,function(e){const t=Ue(e),a=Be(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function He(e,t){const a=ze(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=Ue(e),n=r.getDay(),o=(n<s?7:0)+n-s;return r.setDate(r.getDate()-o),r.setHours(0,0,0,0),r}function Ve(e){return He(e,{weekStartsOn:1})}function We(e){const t=Ue(e),a=t.getFullYear(),s=Be(e,0);s.setFullYear(a+1,0,4),s.setHours(0,0,0,0);const r=Ve(s),n=Be(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=Ve(n);return t.getTime()>=r.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function Ge(e){const t=Ue(e),a=+Ve(t)-+function(e){const t=We(e),a=Be(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Ve(a)}(t);return Math.round(a/Fe)+1}function Ye(e,t){const a=Ue(e),s=a.getFullYear(),r=ze(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=Be(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=He(o,t),l=Be(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=He(l,t);return a.getTime()>=i.getTime()?s+1:a.getTime()>=d.getTime()?s:s-1}function Qe(e,t){const a=Ue(e),s=+He(a,t)-+function(e,t){const a=ze(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=Ye(e,t),n=Be(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),He(n,t)}(a,t);return Math.round(s/Fe)+1}function Ke(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const Xe={y(e,t){const a=e.getFullYear(),s=a>0?a:1-a;return Ke("yy"===t?s%100:s,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Ke(a+1,2)},d:(e,t)=>Ke(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Ke(e.getHours()%12||12,t.length),H:(e,t)=>Ke(e.getHours(),t.length),m:(e,t)=>Ke(e.getMinutes(),t.length),s:(e,t)=>Ke(e.getSeconds(),t.length),S(e,t){const a=t.length,s=e.getMilliseconds();return Ke(Math.trunc(s*Math.pow(10,a-3)),t.length)}},Ze="midnight",Je="noon",et="morning",tt="afternoon",at="evening",st="night",rt={G:function(e,t,a){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});default:return a.era(s,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),s=t>0?t:1-t;return a.ordinalNumber(s,{unit:"year"})}return Xe.y(e,t)},Y:function(e,t,a,s){const r=Ye(e,s),n=r>0?r:1-r;if("YY"===t){return Ke(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Ke(n,t.length)},R:function(e,t){return Ke(We(e),t.length)},u:function(e,t){return Ke(e.getFullYear(),t.length)},Q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return Ke(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return Ke(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,a){const s=e.getMonth();switch(t){case"M":case"MM":return Xe.M(e,t);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,a){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return Ke(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,a,s){const r=Qe(e,s);return"wo"===t?a.ordinalNumber(r,{unit:"week"}):Ke(r,t.length)},I:function(e,t,a){const s=Ge(e);return"Io"===t?a.ordinalNumber(s,{unit:"week"}):Ke(s,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):Xe.d(e,t)},D:function(e,t,a){const s=$e(e);return"Do"===t?a.ordinalNumber(s,{unit:"dayOfYear"}):Ke(s,t.length)},E:function(e,t,a){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Ke(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Ke(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"});default:return a.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,a){const s=e.getDay(),r=0===s?7:s;switch(t){case"i":return String(r);case"ii":return Ke(r,t.length);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,a){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,a){const s=e.getHours();let r;switch(r=12===s?Je:0===s?Ze:s/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,a){const s=e.getHours();let r;switch(r=s>=17?at:s>=12?tt:s>=4?et:st,t){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return Xe.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):Xe.H(e,t)},K:function(e,t,a){const s=e.getHours()%12;return"Ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},k:function(e,t,a){let s=e.getHours();return 0===s&&(s=24),"ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xe.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):Xe.s(e,t)},S:function(e,t){return Xe.S(e,t)},X:function(e,t,a){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(t){case"X":return ot(s);case"XXXX":case"XX":return it(s);default:return it(s,":")}},x:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"x":return ot(s);case"xxxx":case"xx":return it(s);default:return it(s,":")}},O:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},z:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},t:function(e,t,a){return Ke(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Ke(e.getTime(),t.length)}};function nt(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?a+String(r):a+String(r)+t+Ke(n,2)}function ot(e,t){if(e%60==0){return(e>0?"-":"+")+Ke(Math.abs(e)/60,2)}return it(e,t)}function it(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+Ke(Math.trunc(s/60),2)+t+Ke(s%60,2)}const lt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},dt=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},ct={p:dt,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],s=a[1],r=a[2];if(!r)return lt(e,t);let n;switch(s){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",lt(s,t)).replace("{{time}}",dt(r,t))}},ut=/^D+$/,mt=/^Y+$/,pt=["D","DD","YY","YYYY"];function ht(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const t=Ue(e);return!isNaN(Number(t))}const ft=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gt=/^'([^]*?)'?$/,bt=/''/g,vt=/[a-zA-Z]/;function wt(e,t,a){const s=ze(),r=a?.locale??s.locale??Re,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=Ue(e);if(!ht(i))throw new RangeError("Invalid time value");let l=t.match(xt).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,ct[t])(e,r.formatLong)}return e}).join("").match(ft).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Nt(e)};if(rt[t])return{isToken:!0,value:e};if(t.match(vt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(i,l));const d={firstWeekContainsDate:n,weekStartsOn:o,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!a?.useAdditionalWeekYearTokens&&function(e){return mt.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return ut.test(e)}(n))&&function(e,t,a){const s=function(e,t,a){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(pt.includes(e))throw new RangeError(s)}(n,t,String(e));return(0,rt[n[0]])(i,n,r.localize,d)}).join("")}function Nt(e){const t=e.match(gt);return t?t[1].replace(bt,"'"):e}function yt(e,t,a){const s=o.getDefaultOptions(),r=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??s.locale);return"formatToParts"in r?function(e,t){const a=e.formatToParts(t);for(let s=a.length-1;s>=0;--s)if("timeZoneName"===a[s].type)return a[s].value;return}(r,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(a);return s?s[0].substr(1):""}(r,t)}function jt(e,t){const a=function(e){kt[e]||(kt[e]=_t?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return kt[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),s=[];for(let e=0;e<a.length;e++){const t=Ct[a[e].type];void 0!==t&&(s[t]=parseInt(a[e].value,10))}return s}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(a,e)}const Ct={year:0,month:1,day:2,hour:3,minute:4,second:5};const kt={},St=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),_t="06/25/2014, 00:00:00"===St||"06/25/2014 00:00:00"===St;function Tt(e,t,a,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(s,r,n,o),i}const At=36e5,Et={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Pt(e,t,a){if(!e)return 0;let s,r,n=Et.timezoneZ.exec(e);if(n)return 0;if(n=Et.timezoneHH.exec(e),n)return s=parseInt(n[1],10),It(s)?-s*At:NaN;if(n=Et.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return It(s,e)?(r=Math.abs(s)*At+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Dt[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Dt[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const s=a?t:function(e){return Tt(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),r=Mt(s,e),n=a?r:function(e,t,a){const s=e.getTime();let r=s-t;const n=Mt(new Date(r),a);if(t===n)return t;r-=n-t;const o=Mt(new Date(r),a);if(n===o)return n;return Math.max(n,o)}(t,r,e);return-n}return NaN}function Mt(e,t){const a=jt(e,t),s=Tt(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function It(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const Dt={};const Rt={X:function(e,t,a){const s=Lt(a.timeZone,e);if(0===s)return"Z";switch(t){case"X":return Ut(s);case"XXXX":case"XX":return Ft(s);default:return Ft(s,":")}},x:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"x":return Ut(s);case"xxxx":case"xx":return Ft(s);default:return Ft(s,":")}},O:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return a+String(r);return a+String(r)+t+zt(n,2)}(s,":");default:return"GMT"+Ft(s,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return yt("short",e,a);default:return yt("long",e,a)}}};function Lt(e,t){const a=e?Pt(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function zt(e,t){const a=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<t;)s="0"+s;return a+s}function Ft(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+zt(Math.floor(s/60),2)+t+zt(Math.floor(s%60),2)}function Ut(e,t){if(e%60==0){return(e>0?"-":"+")+zt(Math.abs(e)/60,2)}return Ft(e,t)}function qt(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const Ot=36e5,Bt=6e4,$t={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Ht(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const t={};let a,s=$t.dateTimePattern.exec(e);s?(t.date=s[1],a=s[3]):(s=$t.datePattern.exec(e),s?(t.date=s[1],a=s[2]):(t.date=null,a=e));if(a){const e=$t.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:r,restDateString:n}=function(e,t){if(e){const a=$t.YYY[t],s=$t.YYYYY[t];let r=$t.YYYY.exec(e)||s.exec(e);if(r){const t=r[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(r=$t.YY.exec(e)||a.exec(e),r){const t=r[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(s.date,a),o=function(e,t){if(null===t)return null;let a,s,r;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=$t.MM.exec(e);if(n)return a=new Date(0),s=parseInt(n[1],10)-1,Qt(t,s)?(a.setUTCFullYear(t,s),a):new Date(NaN);if(n=$t.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=Yt(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=$t.MMDD.exec(e),n){a=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return Qt(t,s,e)?(a.setUTCFullYear(t,s,e),a):new Date(NaN)}if(n=$t.Www.exec(e),n)return r=parseInt(n[1],10)-1,Kt(r)?Vt(t,r):new Date(NaN);if(n=$t.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Kt(r,e)?Vt(t,r,e):new Date(NaN)}return null}(n,r);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,r=0;if(s.time&&(r=function(e){let t,a,s=$t.HH.exec(e);if(s)return t=parseFloat(s[1].replace(",",".")),Xt(t)?t%24*Ot:NaN;if(s=$t.HHMM.exec(e),s)return t=parseInt(s[1],10),a=parseFloat(s[2].replace(",",".")),Xt(t,a)?t%24*Ot+a*Bt:NaN;if(s=$t.HHMMSS.exec(e),s){t=parseInt(s[1],10),a=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return Xt(t,a,e)?t%24*Ot+a*Bt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||t.timeZone){if(a=Pt(s.timeZone||t.timeZone,new Date(e+r)),isNaN(a))return new Date(NaN)}else a=qt(new Date(e+r)),a=qt(new Date(e+r+a));return new Date(e+r+a)}return new Date(NaN)}function Vt(e,t,a){t=t||0,a=a||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*t+a+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const Wt=[31,28,31,30,31,30,31,31,30,31,30,31],Gt=[31,29,31,30,31,30,31,31,30,31,30,31];function Yt(e){return e%400==0||e%4==0&&e%100!=0}function Qt(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const s=Yt(e);if(s&&a>Gt[t])return!1;if(!s&&a>Wt[t])return!1}return!0}function Kt(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function Xt(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const Zt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Jt(e,t,a,s){return function(e,t,a={}){const s=(t=String(t)).match(Zt);if(s){const r=Ht(a.originalDate||e,a);t=s.reduce(function(e,t){if("'"===t[0])return e;const s=e.indexOf(t),n="'"===e[s-1],o=e.replace(t,"'"+Rt[t[0]](r,t,a)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},t)}return wt(e,t,a)}(function(e,t,a){const s=Pt(t,e=Ht(e,a),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,t,{timeZone:(s={...s,timeZone:t,originalDate:e}).timeZone}),a,s)}const ea={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"}},ta={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},aa={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"},sa={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"},ra={ordinalNumber:(e,t)=>Number(e)+"º",era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},na={ordinalNumber:Ie({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},oa={code:"es",formatDistance:(e,t,a)=>{let s;const r=ea[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+s:"hace "+s:s},formatLong:ta,formatRelative:(e,t,a,s)=>1!==t.getHours()?sa[e]:aa[e],localize:ra,match:na,options:{weekStartsOn:1,firstWeekContainsDate:1}},ia={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"}},la={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},da={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},ca={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},ua={ordinalNumber:Ie({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},ma={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=ia[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:la,formatRelative:(e,t,a,s)=>{const r=da[e];return"function"==typeof r?r(t):r},localize:ca,match:ua,options:{weekStartsOn:0,firstWeekContainsDate:1}},pa=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],ha=[{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"}],fa=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],xa="pt-BR",ga="dd/MM/yyyy HH:mm",ba="America/Sao_Paulo",va=e=>pa.some(t=>t.value===e),wa=e=>fa.some(t=>t.value===e),Na=()=>{if("undefined"==typeof navigator)return xa;const e=navigator.language;if(va(e))return e;const t=e.split("-")[0],a=pa.find(e=>e.value.startsWith(t));return a?.value||xa},ya=()=>{if("undefined"==typeof Intl)return ba;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return wa(e)?e:ba}catch{return ba}},ja=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||ga),Ca={"pt-BR":ma,"en-US":Re,"es-ES":oa},ka=(e,t=ga,a=ba,s=xa)=>{if(!e)return"";const r=o.parseISO(e);if(!o.isValid(r))return"Data inválida";const n=Ca[s]||ma;try{return Jt(r,a,t,{locale:n})}catch(i){return Jt(r,ba,t,{locale:n})}},Sa=(e,t=xa,a=ba)=>{if(!e)return"";const s=o.parseISO(e);if(!o.isValid(s))return"Data inválida";const r=Ca[t]||ma;try{return Jt(s,a,"PP",{locale:r})}catch(n){return Jt(s,ba,"PP",{locale:r})}};function _a(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info("Link copiado para a área de transferência")})}function Ta(...e){return n.twMerge(r.clsx(e))}const Aa=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Aa);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=Aa(s);return t}return e},Ea=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"}}),Pa=J.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...o},i)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:Ta(Ea({variant:s,size:r,className:t})),ref:i,...o})});Pa.displayName="Button";const Ma=t.forwardRef(({className:t,children:a,variant:s="action",...r},n)=>e.jsx(Pa,{ref:n,variant:s,size:"icon",className:Ta("h-8 w-8",t),...r,children:a||e.jsx(l.EllipsisVertical,{size:16})}));Ma.displayName="ActionButton";const Ia=J.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:Ta("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));Ia.displayName="Input";const Da=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ra=J.forwardRef(({className:t,...a},s)=>e.jsx(ee.Root,{ref:s,className:Ta(Da(),t),...a}));Ra.displayName=ee.Root.displayName;const La=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));La.displayName="Card";const za=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("flex flex-col space-y-1.5 p-6",t),...a}));za.displayName="CardHeader";const Fa=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Ta("text-2xl font-semibold leading-none tracking-tight",t),...a}));Fa.displayName="CardTitle";const Ua=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));Ua.displayName="CardDescription";const qa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("p-6 pt-0",t),...a}));qa.displayName="CardContent";const Oa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("flex items-center p-6 pt-0",t),...a}));Oa.displayName="CardFooter";const Ba=J.forwardRef(({className:t,orientation:a="horizontal",decorative:s=!0,...r},n)=>e.jsx(ae.Root,{ref:n,decorative:s,orientation:a,className:Ta("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...r}));Ba.displayName=ae.Root.displayName;const $a=se.Root,Ha=se.Trigger,Va=se.Portal,Wa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Overlay,{className:Ta("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));Wa.displayName=se.Overlay.displayName;const Ga=J.forwardRef(({className:t,...a},s)=>e.jsxs(Va,{children:[e.jsx(Wa,{}),e.jsx(se.Content,{ref:s,className:Ta("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a})]}));Ga.displayName=se.Content.displayName;const Ya=({className:t,...a})=>e.jsx("div",{className:Ta("flex flex-col space-y-2 text-center sm:text-left",t),...a});Ya.displayName="AlertDialogHeader";const Qa=({className:t,...a})=>e.jsx("div",{className:Ta("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Qa.displayName="AlertDialogFooter";const Ka=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Title,{ref:s,className:Ta("text-lg font-semibold",t),...a}));Ka.displayName=se.Title.displayName;const Xa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Description,{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));Xa.displayName=se.Description.displayName;const Za=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Action,{ref:s,className:Ta(Ea(),t),...a}));Za.displayName=se.Action.displayName;const Ja=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Cancel,{ref:s,className:Ta(Ea({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));Ja.displayName=se.Cancel.displayName;const es=te.Root,ts=te.Trigger,as=te.Portal,ss=te.Close,rs=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{ref:s,className:Ta("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));rs.displayName=te.Overlay.displayName;const ns={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",minWidth:"720px",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},os=J.forwardRef(({className:t,children:a,size:s,variant:r="informative",isDirty:n,customWidth:o,customMinWidth:i,customMaxWidth:d,customHeight:c,customMinHeight:u,customMaxHeight:m,unsavedChangesTitle:p="Alterações não salvas",unsavedChangesDescription:h="Existem alterações não salvas. Deseja sair sem salvar?",cancelText:f="Cancelar",leaveWithoutSavingText:x="Sair sem salvar",style:g,onInteractOutside:b,onEscapeKeyDown:v,...w},N)=>{const[y,j]=J.useState(!1),C=J.useRef(null),k=s??(o||i||d||c||u||m?void 0:"md"),S=k?ns[k]:{},_={...o??S.width?{width:o??S.width}:{},...i??S.minWidth?{minWidth:i??S.minWidth}:{},...d??S.maxWidth?{maxWidth:d??S.maxWidth}:{},...c??S.height?{height:c??S.height}:{},...u??S.minHeight?{minHeight:u??S.minHeight}:{},...m??S.maxHeight?{maxHeight:m??S.maxHeight}:{},...g},T=J.useCallback(e=>{"form"===r&&n?(C.current=e,j(!0)):e()},[r,n]),A="destructive"!==r;return e.jsxs(as,{children:[e.jsx(rs,{}),e.jsxs(te.Content,{ref:N,className:Ta("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),style:_,onInteractOutside:e=>{"form"!==r&&"destructive"!==r?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==r)return"form"===r&&n?(e.preventDefault(),void T(()=>{v?.(e)})):void v?.(e);e.preventDefault()},...w,children:[a,A&&e.jsxs(te.Close,{onClick:e=>{"form"===r&&n&&(e.preventDefault(),T(()=>{const t=e.target.closest("[data-radix-collection-item]");t&&t.click()}))},className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}),e.jsx($a,{open:y,onOpenChange:j,children:e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:p}),e.jsx(Xa,{children:h})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{onClick:()=>{j(!1),C.current=null},children:f}),e.jsx(Za,{onClick:()=>{j(!1),C.current?.(),C.current=null},children:x})]})]})})]})});os.displayName=te.Content.displayName;const is=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Ta("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});is.displayName="DialogHeader";const ls=({className:t,...a})=>e.jsx("div",{className:Ta("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});ls.displayName="DialogBody";const ds=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Ta("flex flex-row justify-end gap-2",t),...s,children:a})]});ds.displayName="DialogFooter";const cs=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Ta("text-lg font-semibold leading-none tracking-tight",t),...a}));cs.displayName=te.Title.displayName;const us=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));us.displayName=te.Description.displayName;const ms=p.FormProvider,ps=J.createContext({}),hs=()=>{const e=J.useContext(ps),t=J.useContext(fs),{getFieldState:a,formState:s}=p.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},fs=J.createContext({}),xs=J.forwardRef(({className:t,...a},s)=>{const r=J.useId();return e.jsx(fs.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Ta("space-y-2",t),...a})})});xs.displayName="FormItem";const gs=J.forwardRef(({className:t,...a},s)=>{const{error:r,formItemId:n}=hs();return e.jsx(Ra,{ref:s,className:Ta(r&&"text-destructive",t),htmlFor:n,...a})});gs.displayName="FormLabel";const bs=J.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=hs();return e.jsx(a.Slot,{ref:s,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...t})});bs.displayName="FormControl";const vs=J.forwardRef(({className:t,...a},s)=>{const{formDescriptionId:r}=hs();return e.jsx("p",{ref:s,id:r,className:Ta("text-sm text-muted-foreground",t),...a})});vs.displayName="FormDescription";const ws=J.forwardRef(({className:t,children:a,...s},r)=>{const{error:n,formMessageId:o}=hs(),i=n?String(n?.message):a;return i?e.jsx("p",{ref:r,id:o,className:Ta("text-sm font-medium text-destructive",t),...s,children:i}):null});ws.displayName="FormMessage";const Ns=re.Root,ys=re.Group,js=re.Value,Cs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Trigger,{ref:r,className:Ta("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(re.Icon,{asChild:!0,children:e.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Cs.displayName=re.Trigger.displayName;const ks=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollUpButton,{ref:s,className:Ta("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));ks.displayName=re.ScrollUpButton.displayName;const Ss=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollDownButton,{ref:s,className:Ta("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Ss.displayName=re.ScrollDownButton.displayName;const _s=J.forwardRef(({className:t,children:a,position:s="popper",container:r,collisionBoundary:n,...o},i)=>e.jsx(re.Portal,{container:r,children:e.jsxs(re.Content,{ref:i,className:Ta("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:n,...o,children:[e.jsx(ks,{}),e.jsx(re.Viewport,{className:Ta("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(Ss,{})]})}));_s.displayName=re.Content.displayName;const Ts=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Label,{ref:s,className:Ta("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));Ts.displayName=re.Label.displayName;const As=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Item,{ref:r,className:Ta("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(re.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),e.jsx(re.ItemText,{children:a})]}));As.displayName=re.Item.displayName;const Es=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Separator,{ref:s,className:Ta("-mx-1 my-1 h-px bg-muted",t),...a}));Es.displayName=re.Separator.displayName;const Ps=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.Root,{ref:s,className:Ta("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(ne.Indicator,{className:Ta("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));Ps.displayName=ne.Root.displayName;const Ms=J.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:Ta("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...a}));Ms.displayName="Textarea";const Is=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"}}),Ds=J.forwardRef(({className:t,variant:a,...s},r)=>e.jsx("div",{ref:r,className:Ta(Is({variant:a}),t),...s}));Ds.displayName="Badge";const Rs={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ls({size:t="md",className:a}){return e.jsx(l.Loader2,{className:Ta("animate-spin text-muted-foreground",Rs[t],a)})}const zs=({...t})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...t}),Fs=oe.Root,Us=oe.Trigger,qs=oe.Group,Os=oe.Portal,Bs=oe.Sub,$s=oe.RadioGroup,Hs=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Ta("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Hs.displayName=oe.SubTrigger.displayName;const Vs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.SubContent,{ref:s,className:Ta("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Vs.displayName=oe.SubContent.displayName;const Ws=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:a,className:Ta("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));Ws.displayName=oe.Content.displayName;const Gs=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Item,{ref:r,className:Ta("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Gs.displayName=oe.Item.displayName;const Ys=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Ta("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Ys.displayName=oe.CheckboxItem.displayName;const Qs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Ta("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Qs.displayName=oe.RadioItem.displayName;const Ks=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Label,{ref:r,className:Ta("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Ks.displayName=oe.Label.displayName;const Xs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.Separator,{ref:s,className:Ta("-mx-1 my-1 h-px bg-muted",t),...a}));Xs.displayName=oe.Separator.displayName;const Zs=({className:t,...a})=>e.jsx("span",{className:Ta("ml-auto text-xs tracking-widest opacity-60",t),...a});Zs.displayName="DropdownMenuShortcut";const Js=({delayDuration:t=300,...a})=>e.jsx(ie.Provider,{delayDuration:t,...a}),er=ie.Root,tr=ie.Trigger,ar=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:a,className:Ta("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));ar.displayName=ie.Content.displayName;const sr=J.forwardRef(({children:t,disabledReason:a,className:s},r)=>{const n=e.jsx(Gs,{ref:r,className:Ta("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:t});return a?e.jsx(Js,{delayDuration:100,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx(ar,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});sr.displayName="DisabledMenuItem";const rr=le.Root,nr=le.Trigger,or=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,container:r,...n},o)=>e.jsx(le.Portal,{container:r,children:e.jsx(le.Content,{ref:o,align:a,sideOffset:s,className:Ta("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));or.displayName=le.Content.displayName;const ir=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));ir.displayName="Command";const lr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Ta("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})}));lr.displayName="CommandInput";const dr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));dr.displayName="CommandList";const cr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("py-6 text-center text-sm text-muted-foreground",t),...a}));cr.displayName="CommandEmpty";const ur=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));ur.displayName="CommandGroup";const mr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("-mx-1 h-px bg-border",t),...a}));mr.displayName="CommandSeparator";const pr=J.forwardRef(({className:t,disabled:a,onSelect:s,value:r,...n},o)=>e.jsx("div",{ref:o,className:Ta("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),"data-disabled":a,onClick:()=>!a&&s?.(r||""),...n}));pr.displayName="CommandItem";const hr=({className:t,...a})=>e.jsx("span",{className:Ta("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function fr({className:t,...a}){return e.jsx("div",{className:Ta("animate-pulse rounded-md bg-muted",t),...a})}hr.displayName="CommandShortcut";const xr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function gr({multiple:a,options:s,value:r,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:d,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:v,onOpen:w,onClose:N}){const[y,j]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),_=t.useMemo(()=>{if(!v)return;let e=v,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[v]),T=t.useMemo(()=>{const e=s.map(e=>({original:e,value:o(e),label:i(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,o,i,g]),A=t.useMemo(()=>{if(!C)return T;const e=xr(C);return T.filter(t=>xr(t.label).includes(e))},[T,C]),E=t.useMemo(()=>T.filter(e=>S.includes(e.value)),[T,S]),P=e=>{j(e),e?w?.():(k(""),N?.())},M=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?S.filter(t=>t!==e):"")},I=b?E.slice(0,b):E,D=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:Ta("space-y-2",x),children:[c&&e.jsxs(Ra,{children:[c,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:y,onOpenChange:P,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":y,"aria-disabled":h,tabIndex:h?-1:0,onKeyDown:e=>{h||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),P(!y))},className:Ta("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",h&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[I.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&M(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),D>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",D]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":y,disabled:h,className:Ta("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:_,collisionBoundary:_,children:e.jsxs(ir,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(lr,{placeholder:p,value:C,onChange:e=>k(e.target.value)}),C&&e.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>k(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(dr,{children:0===s.length?e.jsx(cr,{children:m}):0===A.length?e.jsx(cr,{children:"Nenhum resultado encontrado"}):e.jsx(ur,{children:A.map(t=>e.jsxs(pr,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=S.includes(e)?S.filter(t=>t!==e):[...S,e];n(t)}else n(e),j(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:Ta("mr-2 h-4 w-4",S.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function br({multiple:t=!1,options:a,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:w,sortOptions:N=!0,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k}){const{t:S}=v.useTranslation(),_=a||s||[],T=o||n,A=c||S("select_placeholder","Selecione..."),E=p||S("no_results","Nenhum resultado encontrado"),P=h||S("search_placeholder","Pesquisar...");if(g)return e.jsxs("div",{className:Ta("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const M="string"==typeof b?b:b instanceof Error?b.message:b?S("error_loading","Erro ao carregar"):void 0;return M?e.jsxs("div",{className:Ta("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:M})]})]}):e.jsx(gr,{multiple:t,options:_,value:r||(t?[]:""),onChange:T,getOptionValue:i,getOptionLabel:d,placeholder:A,label:u,icon:m,emptyMessage:E,searchPlaceholder:P,disabled:f,required:x,className:w,sortOptions:N,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k})}const vr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(de.Root,{ref:r,className:Ta("relative overflow-hidden",t),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(wr,{}),e.jsx(de.Corner,{})]}));vr.displayName=de.Root.displayName;const wr=J.forwardRef(({className:t,orientation:a="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:a,className:Ta("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));wr.displayName=de.ScrollAreaScrollbar.displayName;const Nr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function yr(e,t){if(!t)return null;const a=Nr(t),s=[];for(const r of e){const e=Nr(r.label).includes(a),n=r.children?yr(r.children,t):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function jr(e,t){for(const a of e){if(a.value===t)return a.label;if(a.children){const e=jr(a.children,t);if(e)return e}}}function Cr({node:t,level:a,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=t.children&&t.children.length>0,d=n.includes(t.value);return e.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":d,className:Ta("flex items-center gap-1 rounded-sm px-2 py-1.5 text-sm cursor-pointer","hover:bg-accent hover:text-accent-foreground","outline-none"),style:{paddingLeft:8+20*a+"px"},children:[i?e.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted",onClick:e=>{e.stopPropagation(),r(t.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?e.jsx(l.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})}):e.jsx("span",{className:"w-5 shrink-0"}),e.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:e=>{e.stopPropagation(),o(t.value)},children:[e.jsx(l.Check,{className:Ta("h-4 w-4 shrink-0",d?"opacity-100":"opacity-0")}),(()=>{const a=d&&t.iconSelected?t.iconSelected:t.icon;return a?e.jsx(a,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):null})(),e.jsx("span",{className:"truncate",children:t.label})]})]})}function kr({nodes:a,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return e.jsx(e.Fragment,{children:a.map(a=>{const l=r.has(a.value);return e.jsxs(t.Fragment,{children:[e.jsx(Cr,{node:a,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&a.children&&a.children.length>0&&e.jsx(kr,{nodes:a.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},a.value)})})}class Sr{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}}Sr.LARGE_PAYLOAD_THRESHOLD=1e3;const _r="qualiex_access_token",Tr="qualiex_id_token",Ar="supabase_token",Er="oauth_state",Pr="oauth_nonce",Mr="selected_alias",Ir="manual_logout",Dr={setAccessToken:e=>localStorage.setItem(_r,e),getAccessToken:()=>localStorage.getItem(_r),setIdToken:e=>localStorage.setItem(Tr,e),getIdToken:()=>localStorage.getItem(Tr),getSupabaseToken:()=>localStorage.getItem(Ar),setOAuthState:e=>sessionStorage.setItem(Er,e),getOAuthState:()=>sessionStorage.getItem(Er),clearOAuthState:()=>sessionStorage.removeItem(Er),setOAuthNonce:e=>sessionStorage.setItem(Pr,e),getOAuthNonce:()=>sessionStorage.getItem(Pr),clearOAuthNonce:()=>sessionStorage.removeItem(Pr),setSelectedAlias:e=>localStorage.setItem(Mr,e),getSelectedAlias:()=>localStorage.getItem(Mr),clearSelectedAlias:()=>localStorage.removeItem(Mr),generateOAuthState:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Dr.getAccessToken()||!Dr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Ar,e),Dr._clearValidationCache()},areAllTokensValid:()=>{const e=Dr.getAccessToken(),t=Dr.getIdToken();if(!e||!t)return!1;try{const a=Sr.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Dr.getAccessToken(),a=Dr.getIdToken(),s=Dr.getSupabaseToken();return t&&Dr.isTokenExpired(t)&&(localStorage.removeItem(_r),e=!0),a&&Dr.isTokenExpired(a)&&(localStorage.removeItem(Tr),e=!0),s&&Dr.isTokenExpired(s)&&(localStorage.removeItem(Ar),e=!0),e},clearAll:()=>{localStorage.removeItem(_r),localStorage.removeItem(Tr),localStorage.removeItem(Ar),localStorage.removeItem(Mr),localStorage.removeItem(Ir),sessionStorage.removeItem(Er),sessionStorage.removeItem(Pr),Dr._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Ir,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ir),clearManualLogout:()=>localStorage.removeItem(Ir),isTokenExpired:e=>{try{return Sr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Dr._validationCache.isValid=!1,Dr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Dr.getSupabaseToken();if(!e)return!1;if(Dr.isTokenExpired(e))return Dr._clearValidationCache(),Dr._handleExpiredToken(),!1;const t=Date.now();return t-Dr._validationCache.timestamp<Dr._validationCache.cacheValidityMs?Dr._validationCache.isValid:(Dr._validationCache.isValid=!0,Dr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Dr.isSupabaseTokenValid()?Dr.getSupabaseToken():null,_handleExpiredToken:()=>{Dr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Dr.isSupabaseTokenValid())return null;const e=Dr.getSupabaseToken();if(!e)return null;try{const t=Sr.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,s=t.place_id||null,r=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:s,placeName:r,payload:t}}catch(t){return Dr._handleExpiredToken(),null}},getCompanyId:e=>{const t=Dr.getAccessToken();if(t)try{const a=Sr.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}const a=Dr.extractTokenData();if(a?.companyId)return a.companyId;const s=Dr.getIdToken();if(s)try{const t=Sr.parseJwtPayload(s);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}return null},getCurrentCompanyId:()=>{const e=Dr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Dr.getIdToken();if(!e)return[];try{const t=Sr.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};const Rr=new class{constructor(){this.errors=[],this.toastCount=0,this.lastToastTime=0}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),t&&this.shouldShowToast()){const e=this.getErrorTitle(a);i.toast.error(e,{description:a})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){i.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}},Lr=(void 0).VITE_SUPABASE_URL,zr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class Fr{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:zr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return N.createClient(Lr,zr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return Fr.instance||(Fr.instance=new Fr),Fr.instance}getClient(){const e=Dr.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Sr.isTokenExpired(e)}catch(t){return Rr.handleError(t instanceof Error?t:"Supabase - Error validating token",!1),!1}}}function Ur(){return Fr.getInstance().getClient()}class qr{static async generateToken(e,t,a,s=!1){try{if(!s){const e=Dr.getSupabaseToken();if(e&&Dr.isSupabaseTokenValid())return e}const r=Ur(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token?(Dr.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}class Or{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const t=Dr.getAccessToken(),a=Dr.getSelectedAlias();if(!t||!a)return null;const s=await qr.generateToken(t,a,this.onLogoutCallback||void 0,e);return s||null}catch(t){return null}}}Or.regenerationPromise=null,Or.onLogoutCallback=null;class Br{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Dr.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}class $r{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await Or.attemptRegeneration()?(this.isRetrying=!1,!0):(Br.handleError(e),this.isRetrying=!1,!1)}catch(s){return Br.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Dr.getAccessToken();return e?Dr.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."}}}$r.isRetrying=!1;const Hr="ccjfvpnndclajkleyqkc",Vr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Wr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"cdf6c125-ec32-43d1-846b-bb8f90125b90"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Gr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e===Hr?Vr:Wr}function Yr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e!==Hr}const Qr={get oauth(){const e=Gr();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Kr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Xr={debounceDelay:500},Zr=()=>{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},Jr=()=>Gr().qualiexApiUrl,en={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},tn={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},an={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}`}};const sn=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}parseUsersResponse(e,t=""){let a=e;if(e.data)a=e.data;else{if(!Array.isArray(e))return Rr.handleError(`[QualiexApi] Formato de resposta inesperado${t}`,!1),null;a=e}return Array.isArray(a)?a.map(this.mapToQualiexUser):(Rr.handleError(`[QualiexApi] Resposta não é um array${t}`,!1),null)}async fetchUsers(e,t){const a={companyId:t,search:"",filterStatus:"active"};try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t)??[]}catch(s){if(await $r.handleApiError(s))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t," após retry")??[]}catch(r){return Rr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Rr.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return Rr.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),s=new Map;return a.forEach(e=>s.set(e.userId,e)),s}async getUsers(e){const t=Dr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}};function rn(e,t){const a=t||en.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function nn(e,t){const a=t||en.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function on(e,t){const a=t||en.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function ln(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||rn(e.idField),emailField:e.emailField||nn(e.idField),usernameField:e.usernameField||on(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:rn(e),emailField:nn(e),usernameField:on(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const dn=new Map;class cn{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,s=dn.get(a);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await sn.fetchUsers(e,t);return dn.set(a,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,t){const a=new Set;for(const s of e)for(const e of t){const t=s[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const s={...e};for(const r of t){const t=e[r.idField];if(!t)continue;const n=a.get(t);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!Dr.areAllTokensValid())return e;const a=Dr.extractTokenData();if(!a)return e;const{alias:s,companyId:r}=a;if(!s||!r)return e;const n=ln(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(s,r),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return Rr.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}}const un=["responsible_name"],mn=e=>un.includes(e);function pn(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!Dr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Ur().schema(i).from(r)},u=(e,t,a,s)=>{let r=c().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?r=r.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?r=r.not(e,"is",null):"is_null"===t.operator&&(r=r.is(e,null)):null!==t&&(r=r.eq(e,t)))}),r=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(r,e);const i=t.includes(".");return i||mn(t)||(r=r.order(t,{ascending:"asc"===a})),{query:r,isForeignKey:i}},m=async(e,t,a,r,n)=>{const o=ln(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(mn(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const d=await cn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.sort((e,s)=>{const r=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(d,t,a);const u=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a;return{data:e.slice(s,r),pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await cn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,c),h=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(p,o,i),{data:f,error:x,count:g}=await h;if(x)throw new Error(`Error fetching ${r}: ${x.message}`);let b=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const t=ln(s.userIdFields,s.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await c().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=Aa(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,t){const a={...Aa(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}};return p}var hn;const fn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class xn{static async initialize(){try{if(!Dr.hasAllTokens()||!Dr.areAllTokensValid())return Dr.clearExpiredTokens(),{...fn};const e=Dr.getAccessToken(),t=Dr.getIdToken();Dr.clearManualLogout();const a=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),r=this.extractAliasFromAccessToken(e),n=Dr.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=Dr.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);i=t?e:r||s[0]?.alias||null}if(!Dr.isSupabaseTokenValid()&&i&&await Or.attemptRegeneration(),!Dr.isSupabaseTokenValid())return{...fn};let l=null;if(i){const e=Dr.getCompanyId(i),t=s.find(e=>e.alias===i);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}const d=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:a,alias:i,companies:s,selectedUnit:l,userId:a?.id||null,userAlias:a?.id||null,placeId:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{...fn}}}static async loginDev(){try{const e=Ur(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Dr.generateOAuthState();Dr.setOAuthState(e);const t=Dr.generateOAuthNonce();Dr.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(Qr.oauth.authUrl);s.searchParams.set("client_id",Qr.oauth.clientId),s.searchParams.set("response_type",Qr.oauth.responseType),s.searchParams.set("scope",Qr.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),window.location.href=s.toString()}static async processCallback(){try{const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(s&&r){const e=Dr.getAccessToken();e!==s&&Dr.clearAll()}if(Dr.hasAllTokens()){return Dr.getValidSupabaseToken()||await Or.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");Dr.setAccessToken(o),Dr.setIdToken(i),Dr.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)Dr.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Dr.setSelectedAlias(e[0].alias)}if(!await Or.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return Dr.clearOAuthState(),Dr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Dr.setManualLogout(),Dr.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return Sr.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}}hn=xn,Or.setLogoutCallback(()=>{hn.logout()});const gn=e=>e?.placeId||null,bn=e=>e?.placeName||null,vn=t.createContext(void 0),wn=({children:a})=>{const[s,r]=t.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=y.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useCallback(e=>{r(t=>({...t,...e}))},[]),d=t.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),c=t.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),u=t.useCallback(async e=>{try{d(!0);const a=Dr.getAccessToken();if(!a)return;const r=await qr.generateToken(a,e.alias,void 0,!0);if(!r)return;Dr.setSupabaseToken(r),Dr.setSelectedAlias(e.alias);const o=Dr.extractTokenData(),i=o?.alias||e.alias,c=o?.companyId||Dr.getCompanyId(e.alias),u={id:c||e.id,name:e.name,alias:i};let m=null,p=null;if(s.user?.id&&i&&c)try{const e=(await sn.fetchActiveUsersMap(i,c)).get(s.user.id);if(e){const t=(e=>({placeId:gn(e),placeName:bn(e)}))(e);m=t.placeId,p=t.placeName}}catch(t){}l({alias:i,selectedUnit:u,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{d(!1)}},[l,n,d,s.user]),m=t.useCallback(async()=>{const e=await xn.processCallback();if(e){const e=await xn.initialize();e&&e.isAuthenticated&&(l({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:e.selectedUnit,userId:e.userId,userAlias:e.userAlias,placeId:e.placeId,placeName:e.placeName,activePlaceId:e.activePlaceId,activePlaceName:e.activePlaceName}),n&&n.invalidateQueries({queryKey:["permission"]}))}return e},[l,n]),p=t.useCallback(async()=>{xn.logout(),c(),n&&await n.clear()},[c,n]),h=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),x=t.useCallback(()=>{},[]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Dr.areAllTokensValid()||e&&p())},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,p]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await xn.initialize();if(!e)return;t&&t.isAuthenticated?l({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&d(!1)}catch(t){e&&(Br.handleError(t),d(!1))}})(),()=>{e=!1}},[l,d,p]);const g=t.useMemo(()=>({...s,logout:p,processCallback:m,switchUnit:u,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:h,clearSearch:f,refreshData:x}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,p,m,u,o,h,f,x]);return e.jsx(vn.Provider,{value:g,children:a})},Nn=()=>{const e=t.useContext(vn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function yn({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[l,d]=j.useSearchParams(),c=y.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Nn(),{t:h}=v.useTranslation(),f=t.useCallback(t=>{const a=`${e}_${t}`,s=l.get(a);return s||(l.get(t)||"")},[l,e]),x=f("search"),g=f("sortField")||Kr.sorting.defaultField,b=f("sortDirection")||Kr.sorting.defaultDirection,w=parseInt(f("page")||"1"),N=parseInt(f("limit")||String(Kr.pagination.defaultPageSize)),C=x,k=t.useMemo(()=>({search:C,sortField:g,sortDirection:b,page:w,limit:N,...n}),[C,g,b,w,N,n]),S=t.useCallback(()=>a.getAll(k),[a,k]),_=y.useQuery({queryKey:[e,u,m,k],queryFn:S,enabled:!!u&&p});if(!_)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const T=y.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.created(s)),o?.()},onError:e=>{i.toast.error(`${an.error.create(s)}: ${e.message}`)}}),A=y.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.updated(s)),o?.()},onError:e=>{i.toast.error(`${an.error.update(s)}: ${e.message}`)}}),E=y.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.deleted(s))},onError:e=>{i.toast.error(`${an.error.delete(s)}: ${e.message}`)}}),P=t.useCallback(t=>{const a={...Object.fromEntries(l)};Object.entries(t).forEach(([t,s])=>{const r=`${e}_${t}`;""===s||0===s?delete a[r]:a[r]=String(s)}),delete a.sortField,delete a.sortDirection,d(a)},[l,d,e]),M=t.useCallback(e=>{P({search:e,page:1})},[P]),I=t.useCallback(e=>{P({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,P]),D=t.useCallback(e=>{P({page:e})},[P]),R=t.useCallback(e=>{P({limit:e,page:1})},[P]),L=t.useCallback(()=>{const t=Object.fromEntries(l),a=`${e}_`,s=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));d(s)},[d,l,e]),[z,F]=t.useState([]),U=t.useCallback(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),q=t.useCallback(()=>{const e=_?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[_?.data?.data]),O=t.useCallback(()=>{F([])},[]),B=t.useMemo(()=>{const e=_?.data?.data.map(e=>e.id)||[];return e.length>0&&z.length===e.length},[z,_?.data?.data]),$=y.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(h("bulk_delete_success",`${a.length} ${s}(s) deletado(s) com sucesso`)),O()},onError:e=>{i.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),H=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?A.mutate({id:e.id,data:a}):T.mutate({...a,alias:u})},[u,T,A]);return{entities:_?.data?.data||[],pagination:{data:_?.data?.data||[],currentPage:_?.data?.currentPage||1,totalPages:_?.data?.totalPages||1,totalItems:_?.data?.totalItems||0,itemsPerPage:_?.data?.itemsPerPage||Kr.pagination.defaultPageSize,hasNextPage:_?.data?.hasNextPage||!1,hasPreviousPage:_?.data?.hasPreviousPage||!1},isLoading:_?.isLoading??!0,isCreating:T?.isPending??!1,isUpdating:A?.isPending??!1,isDeleting:E?.isPending??!1,error:_?.error||null,searchTerm:x,sortField:g,sortDirection:b,currentPage:w,itemsPerPage:N,queryKey:e,createEntity:T.mutate,updateEntity:(e,t)=>A.mutate({id:e,data:t}),deleteEntity:E.mutate,save:H,handleSearch:M,handleSort:I,handlePageChange:D,handleItemsPerPageChange:R,clearFilters:L,refetch:_.refetch,selectedIds:z,selectItem:U,selectAll:q,clearSelection:O,isAllSelected:B,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}function jn(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.useEffect(()=>{const t=window.matchMedia(e);s(t.matches);const a=e=>{s(e.matches)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),a}function Cn(e=768){return jn(`(max-width: ${e-1}px)`)}const kn=J.forwardRef(({className:t,...a},s)=>e.jsx("table",{ref:s,className:Ta("w-full caption-bottom text-sm table-fixed",t),...a}));kn.displayName="Table";const Sn=J.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:Ta("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));Sn.displayName="TableHeader";const _n=J.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:Ta("[&_tr:last-child]:border-0",t),...a}));_n.displayName="TableBody";const Tn=J.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:Ta("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));Tn.displayName="TableFooter";const An=J.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:Ta("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));An.displayName="TableRow";const En=J.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:Ta("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));En.displayName="TableHead";const Pn=J.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:Ta("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));Pn.displayName="TableCell";const Mn=J.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:Ta("mt-4 text-sm text-muted-foreground",t),...a}));function In({rows:t=5,columns:a=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-20"},a))})},s))})]})})}function Dn({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(La,{children:[e.jsxs(za,{children:[e.jsx(fr,{className:"h-4 w-3/4"}),e.jsx(fr,{className:"h-3 w-1/2"})]}),e.jsx(qa,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-3 w-full"}),e.jsx(fr,{className:"h-3 w-2/3"})]})})]},a))})}Mn.displayName="TableCaption";const Rn={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ln({icon:t,title:a,description:s,action:r,className:n,variant:o="default"}){const i=!!t,l=Rn[o];return e.jsxs("div",{className:Ta("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:i?t:e.jsx(l,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(Pa,{onClick:r.onClick,variant:"outline",children:r.label})]})}function zn({children:t,className:a}){const s=J.useRef(null),[r,n]=J.useState(!1);J.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return s.current&&t.observe(s.current),()=>t.disconnect()},[t]);const o=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${a||""}`,children:t});return r?e.jsx(Js,{delayDuration:300,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:o}),e.jsx(ar,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):o}const Fn=J.forwardRef(({direction:t,onMouseDown:a,isDragging:s,className:r},n)=>{const o="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:Ta("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Ta("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Fn.displayName="TableResizeHandle";const Un=ce.Root,qn=ce.Trigger,On=ce.Group,Bn=ce.Portal,$n=ce.Sub,Hn=ce.RadioGroup,Vn=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(ce.SubTrigger,{ref:n,className:Ta("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Vn.displayName=ce.SubTrigger.displayName;const Wn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.SubContent,{ref:s,className:Ta("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Wn.displayName=ce.SubContent.displayName;const Gn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.Portal,{children:e.jsx(ce.Content,{ref:s,className:Ta("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}));Gn.displayName=ce.Content.displayName;const Yn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ce.Item,{ref:r,className:Ta("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Yn.displayName=ce.Item.displayName;const Qn=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(ce.CheckboxItem,{ref:n,className:Ta("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ce.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Qn.displayName=ce.CheckboxItem.displayName;const Kn=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ce.RadioItem,{ref:r,className:Ta("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ce.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Kn.displayName=ce.RadioItem.displayName;const Xn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ce.Label,{ref:r,className:Ta("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));Xn.displayName=ce.Label.displayName;const Zn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.Separator,{ref:s,className:Ta("-mx-1 my-1 h-px bg-border",t),...a}));Zn.displayName=ce.Separator.displayName;const Jn=({className:t,...a})=>e.jsx("span",{className:Ta("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Jn.displayName="ContextMenuShortcut";const eo=({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const d=[];if(t){const e={icon:l.Edit,label:"Editar",onClick:t};d.push(e)}if(o.forEach(e=>{d.push(e)}),s){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s};d.push(e)}if(n&&a){const e={icon:l.Trash2,label:"Excluir",onClick:a,destructive:!0};d.push(e)}const c="dropdown"===i?Gs:Yn;return e.jsx(e.Fragment,{children:d.map((t,a)=>e.jsxs(c,{onClick:t.onClick,className:Ta("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},to=({onEdit:t,onDelete:a,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(eo,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!a,customActions:o,renderAs:"dropdown"})})]}),ao=150;function so({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,t)=>{r&&(t.preventDefault(),t.stopPropagation(),l(!0),c(e),u.current=t.clientX,m.current=n[e]??ao)},[r,n]);t.useEffect(()=>{if(!i||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(r,Math.min(n,m.current+t));o(e=>{const t={...e,[d]:a};return s?.(t),t})},h=()=>{l(!1),c(null),a&&o(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,d,e,a,s]),t.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}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"}}),no=J.forwardRef(({className:t,variant:a,size:s,...r},n)=>e.jsx(me.Root,{ref:n,className:Ta(ro({variant:a,size:s,className:t})),...r}));no.displayName=me.Root.displayName;const oo=J.createContext({size:"default",variant:"default"}),io=J.forwardRef(({className:t,variant:a,size:s,children:r,...n},o)=>e.jsx(ue.Root,{ref:o,className:Ta("flex items-center justify-center gap-1",t),...n,children:e.jsx(oo.Provider,{value:{variant:a,size:s},children:r})}));io.displayName=ue.Root.displayName;const lo=J.forwardRef(({className:t,children:a,variant:s,size:r,...n},o)=>{const i=J.useContext(oo);return e.jsx(ue.Item,{ref:o,className:Ta(ro({variant:i.variant||s,size:i.size||r}),t),...n,children:a})});lo.displayName=ue.Item.displayName;const co=t.memo(function({onNew:t,newButtonLabel:a,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:d=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:f,viewMode:x,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],className:w}){const N=t&&s||d||h.length>0,y=f||b,j=r&&o;return N||j||y?e.jsxs("div",{className:Ta("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t&&s&&e.jsxs(Pa,{onClick:t,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),d&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",children:["Ações em lote",c>0&&e.jsx(Ds,{variant:"secondary",className:"ml-2",children:c}),e.jsx(l.ChevronDown,{size:16,className:"ml-2"})]})}),e.jsxs(Ws,{align:"start",children:[u.length>0?u.map((t,a)=>{const s=t.icon,r=0===c||t.disabled;return e.jsxs(Gs,{onClick:()=>!r&&t.action([]),disabled:r,className:"destructive"===t.variant?"text-destructive":void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)}):e.jsxs(Gs,{onClick:m,disabled:0===c,className:"text-destructive",children:[e.jsx(l.Trash2,{size:16,className:"mr-2"}),"Excluir"]}),c>0&&e.jsxs(e.Fragment,{children:[e.jsx(Xs,{}),e.jsxs(Gs,{onClick:p,children:[e.jsx(l.X,{size:16,className:"mr-2"}),"Limpar seleção"]})]})]})]}),h.map((t,a)=>{const s=t.icon;return e.jsxs(Pa,{onClick:t.action,variant:t.variant||"outline",disabled:t.disabled,title:t.disabled?t.disabledReason:void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]}),j&&e.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),y&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[f,b&&x&&g&&e.jsx(io,{type:"single",value:x,onValueChange:e=>e&&g(e),size:"sm",children:v.map(t=>{const a=(e=>{switch(e){case"table":return l.Table2;case"list":return l.List;case"grid":return l.LayoutGrid}})(t);return e.jsx(lo,{value:t,"aria-label":"Visualizar como "+("table"===t?"tabela":"list"===t?"lista":"grade"),children:e.jsx(a,{className:"h-4 w-4"})},t)})})]})]}):null}),uo=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(Ps,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),mo=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:f=[],hideActionBar:x,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:N,bulkActions:y=[],onBulkDelete:j,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_=!1,enableColumnResize:T=!0,resizeStorageKey:A})=>{const{setSearchVisible:E}=Nn(),P=Cn(),M=void 0!==x?!x:g;t.useEffect(()=>{if(!b)return E(!0),()=>E(!1)},[E,b]);const{columnWidths:I,isDragging:D,activeColumn:R,handleMouseDown:L}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:A?`${A}-columns`:void 0,enabled:T}),z=t.useMemo(()=>(()=>{if(T)return s.map(e=>{const t=I[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});let e=0;const t=s.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,T,I]),F=m||f.length>0||b||u||C||_,U=M&&F,q=j||(()=>{a.bulkDelete?.(a.selectedIds)});return P?a.isLoading?e.jsx(Dn,{count:3}):0===a.entities.length?e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsx(La,{className:Ta("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsx(qa,{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(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(a=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||d)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(t):e.jsx(to,{onEdit:r?()=>{r(t)}:void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),a.isLoading?e.jsx(In,{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(kn,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),z.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Sn,{children:e.jsxs(An,{children:[u&&e.jsx(En,{className:"w-[50px]",children:e.jsx(uo,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),s.map(t=>{const s=T&&!1!==t.resizable,r=R===String(t.key);return e.jsxs(En,{className:Ta(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>L(String(t.key),e),isDragging:r})]},String(t.key));var n}),e.jsx(En,{className:"w-[50px] text-center",children:"Ações"})]})}),e.jsx(_n,{children:0===a.entities.length?e.jsx(An,{children:e.jsx(Pn,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsxs(An,{className:Ta("cursor-pointer hover:bg-muted/50 relative",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:[u&&e.jsx(Pn,{onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(Pn,{className:"text-center",children:d?d(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]})})})]})};function po(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(t,a);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(d),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},f=()=>{const e=h(d),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(d).find(t=>t.name===e);if(a){const s=p(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const ho=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],fo=({value:t="#3b82f6",onChange:a,label:s,customColorLabel:r="Cor personalizada",presetColorsLabel:n="Cores predefinidas"})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Ra,{children:s}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e.jsx(or,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"color-input",children:r}),e.jsx(Ia,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:n}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ho.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),xo={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},go=({value:a="Star",onChange:s,label:r,searchLabel:n="Pesquisar"})=>{const[o,i]=t.useState(""),d=Object.entries(xo).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),c=xo[a]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Ra,{children:r}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(or,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"icon-search",children:n}),e.jsx(Ia,{id:"icon-search",placeholder:n,value:o,onChange:e=>i(e.target.value)})]}),e.jsx(vr,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:d.map(([t,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(t),title:t,children:e.jsx(r,{className:"h-4 w-4"})},t))})})]})})]})]})},bo=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Root,{className:Ta("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:s,children:e.jsx(pe.Thumb,{className:Ta("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")})}));bo.displayName=pe.Root.displayName;const vo=(e={})=>{const{user:t,alias:a}=Nn(),{enabled:s=!0}=e;return y.useQuery({queryKey:["qualiex-users",a],queryFn:()=>sn.getUsers(a),enabled:s&&!!a&&!!t,staleTime:3e5,retry:2,retryDelay:1e3})},wo=({value:a,onChange:s,multiple:r=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:v})=>{const{data:w=[],isLoading:N,error:y}=vo({enabled:m}),j=t.useMemo(()=>f?w.filter(f):w,[w,f]),C=t.useCallback(e=>{if("custom"===p&&h)return h(e);const t=e.userName||"";switch(p){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[p,h]);return e.jsx(br,{multiple:r,value:a??(r?[]:""),onChange:s,options:j,isLoading:N,error:y,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:C,placeholder:i||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:"Nenhum resultado encontrado",label:n,required:o,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:x,popoverContainer:g,onOpen:b,onClose:v})};function No({title:a,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:d=!1,usersData:c}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,f]=t.useState(null),x=t.useCallback(e=>{p.current=e,f(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:b,errors:v,updateField:w,handleSubmit:N}=po(g,r,void 0,i),y=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[s,b]),j=t.useMemo(()=>{const e=y.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=y.find(e=>!e.disabled);return t?.id||u},[y,u]);t.useEffect(()=>{j!==u&&m(j)},[j,u]);const C=y.find(e=>e.id===j),k=t=>{const a=(t.computedValue,b[t.name]),s=void 0!==a?a:"",r=v[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=a?Ta("space-y-2 w-full",t.wrapperClassName):Ta("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:o,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>k(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(wo,{value:s||"",onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ms,{id:t.name,value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ns,{value:String(s),onValueChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(Cs,{className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options?.map(t=>e.jsx(As,{value:t.value,children:t.label},t.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(br,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"date",value:String(s),onChange:e=>w(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Ta("w-full",r?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>w(t.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fo,{value:s||t.defaultValue||"#3b82f6",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(go,{value:s||t.defaultValue||"Star",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"custom":if(!t.component)return null;const i=t.component,l="function"==typeof t.componentProps?t.componentProps(b):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:s,onChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:r,popoverContainer:h,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,s=""===a?null:Number(a);w(t.name,s)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(Ps,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),e.jsxs(Ra,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(bo,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"text",value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name)}},S=t.useCallback(()=>{if(!C)return null;if(C.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(C.component){const t=C.component;return e.jsx(t,{formData:b,updateField:w,errors:v,users:c,disabled:C.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:C.fields.map(k)})},[C,b,w,v,c,k]),_=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:y.map(t=>e.jsx(Pa,{variant:j===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=y.find(t=>t.id===e);t&&!t.disabled&&m(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):e.jsxs("form",{onSubmit:N(n),className:"space-y-3 md:space-y-4",children:[S(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Pa,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),e.jsx(Pa,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return e.jsx(es,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(os,{ref:x,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(is,{showSeparator:!0,children:[e.jsx(cs,{children:a}),e.jsx(us,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),_]})})}function yo({currentPage:t,totalPages:a,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:d}=v.useTranslation();if(0===s)return null;const c=(t-1)*r+1,u=Math.min(t*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:d("rows_per_page","Linhas por página")}),e.jsxs(Ns,{value:String(r),onValueChange:e=>o(Number(e)),children:[e.jsx(Cs,{className:"h-8 w-[70px]",children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(As,{value:"10",children:"10"}),e.jsx(As,{value:"25",children:"25"}),e.jsx(As,{value:"50",children:"50"}),e.jsx(As,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",d("of","de")," ",s," ",d("items","itens")]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:d("of","de")}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function jo({manager:t}){return e.jsx(yo,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const Co={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ko={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},So={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function _o({children:t,direction:a="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:Ta("flex","column"===a?"flex-col":"flex-row",Co[s],ko[r],So[n],o&&"flex-wrap",i),children:t})}function To({manager:t,filters:a,inline:s=!1}){const{isSearchVisible:r}=Nn(),n=t.searchTerm,o=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!r&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs(Ns,{value:t.value||"",onValueChange:e=>t.onChange?.(e),children:[e.jsx(Cs,{className:"w-[180px]",children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options.map(t=>e.jsx(As,{value:t.value,children:t.label},t.value))})]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...t.props})},`custom-${a}`)}),n&&e.jsxs(Pa,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(_o,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(_o,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function Ao({manager:a,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){a&&a.queryKey;const{setSearchVisible:l}=Nn(),[d,c]=j.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[f,x]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,b]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!d.has(e)&&!d.has(t)){const a=Object.fromEntries(d);a[e]=i.column,a[t]=i.direction,c(a)}}},[]);const v=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,w="function"==typeof a?.deleteEntity?e=>{x({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,N=()=>{x({isOpen:!1,entityId:null,entityName:""})},y=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,C=(s.customActions||[]).map(e=>({label:e.label,icon:e.icon,action:e.action,variant:"destructive"===e.variant?"default":e.variant,disabled:e.disabled,disabledReason:e.disabledReason}));return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&e.jsx(co,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:y,showSearch:s.showSearch,searchValue:a.searchTerm,onSearchChange:a.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:a.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{b({isOpen:!0,count:a.selectedIds.length})},onClearSelection:a.clearSelection,customActions:C,filters:s.filters&&s.filters.length>0?e.jsx(To,{manager:a,filters:s.filters,inline:!0}):void 0}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(a.entities,a)}):e.jsx(mo,{manager:a,columns:s.columns,onEdit:v,onDelete:w,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(jo,{manager:a})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(No,{open:u,title:p?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:p||void 0,onSubmit:e=>{n(e),m(!1),h(null)},onCancel:()=>{m(!1),h(null)},isLoading:a.isLoading,submitButtonText:p?"Atualizar":"Criar"}),e.jsx(es,{open:f.isOpen,onOpenChange:N,children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:f.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(ds,{children:[e.jsx(Pa,{variant:"outline",onClick:N,children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof a?.deleteEntity&&(a.deleteEntity(f.entityId),x({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(es,{open:g.isOpen,onOpenChange:()=>b({isOpen:!1,count:0}),children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(ds,{children:[e.jsx(Pa,{variant:"outline",onClick:()=>b({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),b({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Eo(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Po(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Mo=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"}}),Io={info:l.Info,warning:l.Info,danger:l.AlertTriangle,success:l.CheckCircle},Do=J.forwardRef(({className:t,variant:a="info",showIcon:s=!0,children:r,...n},o)=>{const i=Io[a||"info"];return e.jsxs("div",{ref:o,role:"alert",className:Ta(Mo({variant:a}),t),...n,children:[s&&e.jsx(i,{className:"h-4 w-4"}),r]})});Do.displayName="Alert";const Ro=J.forwardRef(({className:t,...a},s)=>e.jsx("h5",{ref:s,className:Ta("mb-1 font-medium leading-none tracking-tight",t),...a}));Ro.displayName="AlertTitle";const Lo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("text-sm [&_p]:leading-relaxed",t),...a}));Lo.displayName="AlertDescription";const zo=t.createContext(void 0);function Fo({children:a,actions:s}){const[r,n]=t.useState({}),[o,i]=t.useState(s);t.useEffect(()=>{i(s)},[s]);const l=t.useCallback(()=>n({}),[]),d=t.useMemo(()=>({metadata:r,setMetadata:n,clearMetadata:l,headerActions:o,setHeaderActions:i}),[r,l,o]);return e.jsx(zo.Provider,{value:d,children:a})}function Uo(){const e=t.useContext(zo);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var qo={access_denied:{pt:"Acesso negado",en:"Access denied",es:""},actions:{pt:"Ações",en:"Actions",es:"Acciones"},activate:{pt:"Ativar",en:"Activate",es:"Activar"},activate_selected:{pt:"Ativar Selecionados",en:"Activate Selected",es:"Activar Seleccionados"},active:{pt:"Ativo",en:"Active",es:"Activo"},active_employees:{pt:"Colaboradores Ativos",en:"Active Employees",es:"Empleados Activos"},active_plural:{pt:"Ativos",en:"Active",es:"Activos"},add:{pt:"Adicionar",en:"Add",es:"Agregar"},additional_fields:{pt:"Campos Adicionais",en:"Additional Fields",es:"Campos Adicionales"},address:{pt:"Endereço",en:"Address",es:"Dirección"},admin:{pt:"Admin",en:"Admin",es:"Admin"},admin_access:{pt:"Acesso Admin",en:"Admin Access",es:"Acceso Admin"},admin_system:{pt:"Administração do Sistema",en:"System Administration",es:"Administración del Sistema"},admission_date:{pt:"Data de Admissão",en:"Admission Date",es:"Fecha de Admisión"},alignment:{pt:"Alinhamento",en:"Alignment",es:"Alineación"},all:{pt:"Todos",en:"All",es:"Todos"},allow_download:{pt:"Permitir Download",en:"Allow Download",es:"Permitir Descarga"},allowed_formats:{pt:"Formatos permitidos",en:"Allowed formats",es:"Formatos permitidos"},alt:{pt:"Texto Alternativo",en:"Alt Text",es:"Texto Alternativo"},api_response:{pt:"Resposta da API:",en:"API Response:",es:"Respuesta de la API:"},apply_filters:{pt:"Aplicar filtros",en:"Apply filters",es:"Aplicar filtros"},auth_required:{pt:"Autenticação necessária",en:"Authentication required",es:"Autenticación requerida"},autoplay:{pt:"Reprodução Automática",en:"Autoplay",es:"Reproducción Automática"},back:{pt:"Voltar",en:"Back",es:"Volver"},background_color:{pt:"Cor do Fundo",en:"Background Color",es:"Color de Fondo"},birth_date:{pt:"Data de Nascimento",en:"Birth Date",es:"Fecha de Nacimiento"},boolean:{pt:"Booleano",en:"Boolean",es:"Booleano"},bulk_actions:{pt:"Ações em lote",en:"Bulk actions",es:"Acciones masivas"},cancel:{pt:"Cancelar",en:"Cancel",es:"Cancelar"},cancelled:{pt:"Cancelado",en:"Cancelled",es:"Cancelado"},caption:{pt:"Legenda",en:"Caption",es:"Leyenda"},center:{pt:"Centro",en:"Center",es:"Centro"},chatbot:{pt:"Chatbot",en:"Chatbot",es:"Chatbot"},checking_access:{pt:"Verificando acesso...",en:"Checking access...",es:"Verificando acceso..."},choose_file:{pt:"Escolher arquivo",en:"Choose file",es:"Elegir archivo"},city:{pt:"Cidade",en:"City",es:"Ciudad"},clear:{pt:"Limpar",en:"Clear",es:"Limpiar"},clear_filters:{pt:"Limpar filtros",en:"Clear filters",es:"Limpiar filtros"},clear_search:{pt:"Limpar busca",en:"Clear search",es:"Limpiar búsqueda"},clear_selection:{pt:"Limpar seleção",en:"Clear selection",es:"Limpiar selección"},click_to_create_post:{pt:"Clique no botão abaixo para criar um novo post",en:"Click the button below to create a new post",es:"Haga clic en el botón de abajo para crear una nueva publicación"},close:{pt:"Fechar",en:"Close",es:"Cerrar"},collaborator:{pt:"Colaborador",en:"Collaborator",es:"Colaborador"},config:{pt:"Configuração",en:"Configuration",es:"Configuración"},config_info:{pt:"Informações da Configuração",en:"Configuration Info",es:"Información de Configuración"},config_info_description:{pt:"Defina a chave e o valor da configuração",en:"Set the configuration key and value",es:"Defina la clave y el valor de la configuración"},config_key:{pt:"Chave da Configuração",en:"Configuration Key",es:"Clave de Configuración"},configs:{pt:"Configurações",en:"Configurations",es:"Configuraciones"},comments:{pt:"Comentários",en:"Comments",es:"Comentarios"},community:{pt:"Comunidade",en:"Community",es:"Comunidad"},community_posts:{pt:"Posts da comunidade",en:"Community posts",es:"Publicaciones de la comunidad"},companies:{pt:"Empresas",en:"Companies",es:"Empresas"},company:{pt:"Empresa",en:"Company",es:"Empresa"},completed:{pt:"Concluído",en:"Completed",es:"Completado"},confirm:{pt:"Confirmar",en:"Confirm",es:"Confirmar"},confirm_delete:{pt:"Tem certeza que deseja excluir?",en:"Are you sure you want to delete?",es:"¿Está seguro de que desea eliminar?"},confirm_delete_message:{pt:"Esta ação não pode ser desfeita.",en:"This action cannot be undone.",es:"Esta acción no se puede deshacer."},confirm_password:{pt:"Confirmar Senha",en:"Confirm Password",es:"Confirmar Contraseña"},content:{pt:"Conteúdo",en:"Content",es:"Contenido"},content_blocks:{pt:"Blocos de Conteúdo",en:"Content Blocks",es:"Bloques de Contenido"},controls:{pt:"Controles",en:"Controls",es:"Controles"},copy:{pt:"Copiar",en:"Copy",es:"Copiar"},country:{pt:"País",en:"Country",es:"País"},courses:{pt:"Cursos",en:"Courses",es:"Cursos"},create:{pt:"Criar",en:"Create",es:"Crear"},create_first_post_hint:{pt:'Crie seu primeiro post na aba "Criar Post"',en:'Create your first post in the "Create Post" tab',es:'Crea tu primera publicación en la pestaña "Crear Publicación"'},create_post:{pt:"Criar Novo Post",en:"Create New Post",es:"Crear Nueva Publicación"},create_success:{pt:"Criado com sucesso",en:"Created successfully",es:"Creado exitosamente"},create_unit:{pt:"Criar Nova Unidade",en:"Create New Unit",es:"Crear Nueva Unidad"},created_at:{pt:"Criado em",en:"Created at",es:"Creado en"},created_by:{pt:"Criado por",en:"Created by",es:"Creado por"},currency:{pt:"Moeda",en:"Currency",es:"Moneda"},dashboard:{pt:"Dashboard",en:"Dashboard",es:"Panel"},date:{pt:"Data",en:"Date",es:"Fecha"},date_and_time:{pt:"Data e Hora",en:"Date and Time",es:"Fecha y Hora"},date_format:{pt:"Formato de Data",en:"Date Format",es:"Formato de Fecha"},date_time_format:{pt:"Formato de Data/Hora",en:"Date/Time Format",es:"Formato de Fecha/Hora"},deactivate:{pt:"Inativar",en:"Deactivate",es:"Desactivar"},deactivate_selected:{pt:"Inativar Selecionados",en:"Deactivate Selected",es:"Desactivar Seleccionados"},default:{pt:"Padrão",en:"Default",es:"Por Defecto"},delete:{pt:"Excluir",en:"Delete",es:"Eliminar"},delete_confirmation:{pt:"Confirmação de Exclusão",en:"Delete Confirmation",es:"Confirmación de Eliminación"},delete_success:{pt:"Excluído com sucesso",en:"Deleted successfully",es:"Eliminado exitosamente"},deleting:{pt:"Excluindo...",en:"Deleting...",es:"Eliminando..."},department:{pt:"Departamento",en:"Department",es:"Departamento"},description:{pt:"Descrição",en:"Description",es:"Descripción"},deselect_all:{pt:"Desselecionar todos",en:"Deselect all",es:"Deseleccionar todo"},design_system:{pt:"Design System",en:"Design System",es:"Sistema de Diseño"},design_tokens_and_docs:{pt:"Design tokens e documentação",en:"Design tokens and documentation",es:"Tokens de diseño y documentación"},details:{pt:"Detalhes",en:"Details",es:"Detalles"},disabled:{pt:"Desabilitado",en:"Disabled",es:"Deshabilitado"},download:{pt:"Baixar",en:"Download",es:"Descargar"},drag_drop:{pt:"Arraste e solte ou clique para selecionar",en:"Drag and drop or click to select",es:"Arrastre y suelte o haga clic para seleccionar"},duplicate:{pt:"Duplicar",en:"Duplicate",es:"Duplicar"},edit:{pt:"Editar",en:"Edit",es:"Editar"},edit_additional_fields:{pt:"Editar Campos Adicionais",en:"Edit Additional Fields",es:"Editar Campos Adicionales"},editor_hint:{pt:"💡 Dica: Use Ctrl+B (negrito), Ctrl+I (itálico), Ctrl+U (sublinhado) ou clique nos botões.",en:"💡 Hint: Use Ctrl+B (bold), Ctrl+I (italic), Ctrl+U (underline) or click the buttons.",es:"💡 Consejo: Use Ctrl+B (negrita), Ctrl+I (cursiva), Ctrl+U (subrayado) o haga clic en los botones."},education:{pt:"Educação",en:"Education",es:"Educación"},email:{pt:"E-mail",en:"Email",es:"Correo electrónico"},email_placeholder:{pt:"email@empresa.com",en:"email@company.com",es:"email@empresa.com"},embed:{pt:"Código Embed",en:"Embed Code",es:"Código Embed"},employee:{pt:"Colaborador",en:"Employee",es:"Empleado"},employee_activated:{pt:"Colaborador ativado com sucesso",en:"Employee activated successfully",es:"Empleado activado exitosamente"},employee_deactivated:{pt:"Colaborador inativado com sucesso",en:"Employee deactivated successfully",es:"Empleado desactivado exitosamente"},employee_information:{pt:"Informações do Colaborador",en:"Employee Information",es:"Información del Empleado"},employees:{pt:"Colaboradores",en:"Employees",es:"Empleados"},employees_removed:{pt:"{{count}} colaborador(es) removido(s)",en:"{{count}} employee(s) removed",es:"{{count}} empleado(s) eliminado(s)"},empty_description:{pt:"Não há dados para exibir no momento.",en:"There is no data to display at this time.",es:"No hay datos para mostrar en este momento."},empty_title:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},en:{pt:"EN",en:"EN",es:"EN"},enabled:{pt:"Habilitado",en:"Enabled",es:"Habilitado"},enter_full_name:{pt:"Digite o nome completo",en:"Enter full name",es:"Ingrese el nombre completo"},enter_link_url:{pt:"Digite a URL do link:",en:"Enter link URL:",es:"Ingrese la URL del enlace:"},enter_youtube_url:{pt:"Cole a URL do vídeo do YouTube:",en:"Paste YouTube video URL:",es:"Pegue la URL del video de YouTube:"},error:{pt:"Erro",en:"Error",es:"Error"},error_changing_employee_status:{pt:"Erro ao alterar status do colaborador",en:"Error changing employee status",es:"Error al cambiar el estado del empleado"},error_creating:{pt:"Erro ao criar",en:"Error creating",es:"Error al crear"},error_deleting:{pt:"Erro ao excluir",en:"Error deleting",es:"Error al eliminar"},error_loading:{pt:"Erro ao carregar",en:"Error loading",es:"Error al cargar"},error_no_image:{pt:"Nenhuma imagem selecionada",en:"No image selected",es:"Ninguna imagen seleccionada"},error_no_video:{pt:"Nenhum vídeo selecionado",en:"No video selected",es:"Ningún video seleccionado"},error_saving:{pt:"Erro ao salvar",en:"Error saving",es:"Error al guardar"},error_updating:{pt:"Erro ao atualizar",en:"Error updating",es:"Error al actualizar"},es:{pt:"ES",en:"ES",es:"ES"},export:{pt:"Exportar",en:"Export",es:"Exportar"},failed:{pt:"Falhou",en:"Failed",es:"Fallido"},field_name:{pt:"Nome do Campo",en:"Field Name",es:"Nombre del Campo"},field_type:{pt:"Tipo",en:"Type",es:"Tipo"},file:{pt:"Arquivo de Vídeo",en:"Video File",es:"Archivo de Video"},file_upload_error:{pt:"Erro ao enviar arquivo",en:"Error uploading file",es:"Error al cargar el archivo"},file_upload_success:{pt:"Arquivo enviado com sucesso",en:"File uploaded successfully",es:"Archivo cargado exitosamente"},filter:{pt:"Filtrar",en:"Filter",es:"Filtrar"},first_name:{pt:"Nome",en:"First Name",es:"Nombre"},font:{pt:"Fonte",en:"Font",es:"Fuente"},format_html:{pt:"HTML",en:"HTML",es:"HTML"},format_markdown:{pt:"Markdown",en:"Markdown",es:"Markdown"},format_plain:{pt:"Texto Simples",en:"Plain Text",es:"Texto Simple"},format_rich:{pt:"Rich (WYSIWYG)",en:"Rich (WYSIWYG)",es:"Rich (WYSIWYG)"},full_name:{pt:"Nome Completo",en:"Full Name",es:"Nombre Completo"},general_settings:{pt:"Configurações Gerais",en:"General Settings",es:"Configuración General"},height:{pt:"Altura",en:"Height",es:"Altura"},home:{pt:"Início",en:"Home",es:"Inicio"},html_warning:{pt:"⚠️ HTML será sanitizado para segurança",en:"⚠️ HTML will be sanitized for security",es:"⚠️ HTML será sanitizado por seguridad"},identification:{pt:"Identificação",en:"Identification",es:"Identificación"},identification_invalid:{pt:"Identificação inválida",en:"Invalid identification",es:"Identificación inválida"},image:{pt:"Imagem",en:"Image",es:"Imagen"},import:{pt:"Importar",en:"Import",es:"Importar"},inactive:{pt:"Inativo",en:"Inactive",es:"Inactivo"},inactive_plural:{pt:"Inativos",en:"Inactive",es:"Inactivos"},info:{pt:"Informação",en:"Information",es:"Información"},input_type:{pt:"Tipo de Entrada",en:"Input Type",es:"Tipo de Entrada"},input_type_embed:{pt:"Embed",en:"Embed",es:"Incrustar"},input_type_upload:{pt:"Upload",en:"Upload",es:"Cargar"},integration:{pt:"Integração",en:"Integration",es:"Integración"},invalid_date:{pt:"Data inválida",en:"Invalid date",es:"Fecha inválida"},invalid_email:{pt:"E-mail inválido",en:"Invalid email",es:"Correo electrónico inválido"},invalid_file_type:{pt:"Por favor, selecione um arquivo de vídeo",en:"Please select a video file",es:"Por favor, seleccione un archivo de video"},invalid_phone:{pt:"Telefone inválido",en:"Invalid phone",es:"Teléfono inválido"},invalid_youtube_url:{pt:"URL do YouTube inválida. Use o formato: https://www.youtube.com/watch?v=VIDEO_ID",en:"Invalid YouTube URL. Use format: https://www.youtube.com/watch?v=VIDEO_ID",es:"URL de YouTube inválida. Use el formato: https://www.youtube.com/watch?v=VIDEO_ID"},item_details:{pt:"Detalhes do item",en:"Item details",es:"Detalles del elemento"},items:{pt:"itens",en:"items",es:"elementos"},items_per_page:{pt:"Itens por página",en:"Items per page",es:"Elementos por página"},key:{pt:"Chave",en:"Key",es:""},language:{pt:"Idioma",en:"Language",es:"Idioma"},last_10_logins:{pt:"Últimos 10 Logins",en:"Last 10 Logins",es:"Últimos 10 Inicios de Sesión"},last_modification:{pt:"Última Modificação",en:"Last Modification",es:"Última Modificación"},last_name:{pt:"Sobrenome",en:"Last Name",es:"Apellido"},leader:{pt:"Líder",en:"Leader",es:"Líder"},leadership:{pt:"Liderança",en:"Leadership",es:"Liderazgo"},leadership_hierarchy:{pt:"Hierarquia de liderança",en:"Leadership hierarchy",es:"Jerarquía de liderazgo"},left:{pt:"Esquerda",en:"Left",es:"Izquierda"},link_copied:{pt:"Link copiado para a área de transferência",en:"Link copied to clipboard",es:"Enlace copiado al portapapeles"},list:{pt:"Lista",en:"List",es:"Lista"},loading:{pt:"Carregando...",en:"Loading...",es:"Cargando..."},loading_data:{pt:"Carregando dados...",en:"Loading data...",es:"Cargando datos..."},logout:{pt:"Sair",en:"Logout",es:"Cerrar Sesión"},manage_reports:{pt:"Gerenciar relatórios",en:"Manage reports",es:"Gestionar informes"},management:{pt:"Gestão",en:"Management",es:"Gestión"},management_access_control:{pt:"Controle de acesso a gestão",en:"Management access control",es:"Control de acceso a gestión"},management_permission:{pt:"Permissão de Gestão",en:"Management Permission",es:"Permiso de Gestión"},management_permissions:{pt:"Permissões de Gestão",en:"Management Permissions",es:"Permisos de Gestión"},markdown_hint:{pt:"💡 Suporte a: **negrito**, *itálico*, [links](url), parágrafos",en:"💡 Supports: **bold**, *italic*, [links](url), paragraphs",es:"💡 Soporta: **negrita**, *cursiva*, [enlaces](url), párrafos"},max_file_size:{pt:"Tamanho máximo",en:"Maximum size",es:"Tamanho máximo"},migration:{pt:"Migração",en:"Migration",es:""},module:{pt:"Módulo",en:"Module",es:"Módulo"},module_title:{pt:"Título do módulo",en:"Module title",es:"Título del módulo"},modules:{pt:"Módulos",en:"Modules",es:"Módulos"},name:{pt:"Nome",en:"Name",es:"Nombre"},new:{pt:"Novo",en:"New",es:"Nuevo"},new_password:{pt:"Nova Senha",en:"New Password",es:"Nueva Contraseña"},new_value:{pt:"Novo valor",en:"New value",es:"Nuevo valor"},next:{pt:"Próximo",en:"Next",es:"Siguiente"},no:{pt:"Não",en:"No",es:"No"},no_additional_fields:{pt:"Nenhum campo adicional configurado.",en:"No additional fields configured.",es:"No hay campos adicionales configurados."},no_content_preview:{pt:"Nenhum conteúdo para visualizar...",en:"No content to preview...",es:"No hay contenido para previsualizar..."},no_data:{pt:"Nenhum dado disponível",en:"No data available",es:"No hay datos disponibles"},no_file_selected:{pt:"Nenhum arquivo selecionado",en:"No file selected",es:"No se seleccionó ningún archivo"},no_items_found:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},no_logins_registered:{pt:"Nenhum login registrado ainda.",en:"No logins registered yet.",es:"Aún no se han registrado inicios de sesión."},no_options:{pt:"Nenhuma opção disponível",en:"No options available",es:"No hay opciones disponibles"},no_permission_to_access_reports:{pt:"Sem permissão para acessar relatórios",en:"No permission to access reports",es:""},no_posts_found:{pt:"Nenhum post encontrado",en:"No posts found",es:"No se encontraron publicaciones"},no_results:{pt:"Nenhum resultado encontrado",en:"No results found",es:"No se encontraron resultados"},no_title:{pt:"Sem título",en:"No title",es:"Sin título"},notifications:{pt:"Notificações",en:"Notifications",es:"Notificaciones"},nr1:{pt:"Pulso",en:"Pulse",es:"Pulso"},of:{pt:"de",en:"of",es:"de"},old_password:{pt:"Senha Atual",en:"Current Password",es:"Contraseña Actual"},open_external_link:{pt:"Abrir link externo",en:"Open external link",es:"Abrir enlace externo"},open_wiki:{pt:"Abrir Wiki",en:"Open Wiki",es:"Abrir Wiki"},order:{pt:"Ordem",en:"Order",es:"Orden"},overview:{pt:"Visão geral",en:"Overview",es:"Resumen"},page:{pt:"Página",en:"Page",es:"Página"},password:{pt:"Senha",en:"Password",es:"Contraseña"},paste_html_placeholder:{pt:"Cole ou escreva HTML aqui...",en:"Paste or write HTML here...",es:"Pegue o escriba HTML aquí..."},pdi:{pt:"PDI",en:"PDI",es:"PDI"},pending:{pt:"Pendente",en:"Pending",es:"Pendiente"},performance:{pt:"Desempenho",en:"Performance",es:"Desempeño"},permissions:{pt:"Permissões",en:"Permissions",es:"Permisos"},permissions_roles:{pt:"Permissões e Roles",en:"Permissions and Roles",es:"Permisos y Roles"},phone:{pt:"Telefone",en:"Phone",es:"Teléfono"},place:{pt:"Local",en:"Place",es:"Lugar"},placeholder_select:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},places:{pt:"Locais",en:"Places",es:"Lugares"},plain_text_placeholder:{pt:"Digite texto simples aqui...",en:"Enter plain text here...",es:"Ingrese texto simple aquí..."},position:{pt:"Cargo",en:"Position",es:"Cargo"},posts:{pt:"Publicações",en:"Posts",es:"Publicaciones"},preferences:{pt:"Preferências de Internacionalização",en:"Internationalization Preferences",es:"Preferencias de Internacionalización"},preview:{pt:"Preview",en:"Preview",es:"Vista Previa"},previous:{pt:"Anterior",en:"Previous",es:"Anterior"},processing:{pt:"Processando...",en:"Processing...",es:"Procesando..."},profile:{pt:"Perfil",en:"Profile",es:"Perfil"},pt:{pt:"PT",en:"PT",es:"PT"},qualiex_places_hierarchy:{pt:"Hierarquia de locais do Qualiex",en:"Qualiex places hierarchy",es:"Jerarquía de lugares de Qualiex"},recipient_email:{pt:"Email Destinatário",en:"Recipient Email",es:"Correo del Destinatario"},redirecting:{pt:"Redirecionando...",en:"Redirecting...",es:"Redirigiendo..."},refresh_data:{pt:"Atualizar dados",en:"Refresh data",es:"Actualizar datos"},reload:{pt:"Recarregar",en:"Reload",es:"Recargar"},remove:{pt:"Remover",en:"Remove",es:"Eliminar"},remove_confirm:{pt:"Tem certeza que deseja remover?",en:"Are you sure you want to remove?",es:"¿Está seguro de que desea eliminar?"},removing:{pt:"Removendo...",en:"Removing...",es:"Eliminando..."},reports:{pt:"Relatórios",en:"Reports",es:"Informes"},required_field:{pt:"Campo obrigatório",en:"Required field",es:"Campo obligatorio"},restricted_access:{pt:"Acesso restrito",en:"Restricted access",es:"Acceso restringido"},results:{pt:"resultados",en:"results",es:"resultados"},right:{pt:"Direita",en:"Right",es:"Derecha"},role:{pt:"Papel",en:"Role",es:"Rol"},roles:{pt:"Perfis",en:"Roles",es:"Roles"},rows_per_page:{pt:"Registros por página",en:"Rows per page",es:"Registros por página"},save:{pt:"Salvar",en:"Save",es:"Guardar"},save_block:{pt:"Salvar Bloco",en:"Save Block",es:"Guardar Bloque"},save_success:{pt:"Salvo com sucesso",en:"Saved successfully",es:"Guardado exitosamente"},saving:{pt:"Salvando...",en:"Saving...",es:"Guardando..."},search:{pt:"Pesquisar",en:"Search",es:"Buscar"},search_placeholder:{pt:"Pesquisar...",en:"Search...",es:"Buscar..."},search_user:{pt:"Buscar usuário...",en:"Search user...",es:"Buscar usuario..."},searchDateFormat:{pt:"Buscar formato...",en:"Search format...",es:"Buscar formato..."},searchTimezone:{pt:"Buscar fuso horário...",en:"Search timezone...",es:"Buscar zona horaria..."},section:{pt:"Seção",en:"Section",es:"Sección"},select_all:{pt:"Selecionar todos",en:"Select all",es:"Seleccionar todo"},select_collaborator:{pt:"Selecionar Colaborador",en:"Select Collaborator",es:"Seleccionar Colaborador"},select_option:{pt:"Selecione uma opção",en:"Select an option",es:"Seleccione una opción"},select_placeholder:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},selectDateFormat:{pt:"Selecione o formato",en:"Select format",es:"Seleccione el formato"},selectTimezone:{pt:"Selecione o fuso horário",en:"Select timezone",es:"Seleccione la zona horaria"},select_text_for_link:{pt:"Selecione o texto que deseja transformar em link",en:"Select the text you want to turn into a link",es:"Seleccione el texto que desea convertir en enlace"},select_unit_collaborator:{pt:"Selecione um colaborador da unidade",en:"Select a unit collaborator",es:"Seleccione un colaborador de la unidad"},select_user:{pt:"Selecionar Usuário",en:"Select User",es:"Seleccionar Usuario"},select_user_for_admin_access:{pt:"Selecione um usuário para dar acesso admin",en:"Select a user to grant admin access",es:"Seleccione un usuario para dar acceso de administrador"},select_video:{pt:"Selecionar Vídeo",en:"Select Video",es:"Seleccionar Video"},selected:{pt:"selecionado(s)",en:"selected",es:"seleccionado(s)"},selected_count:{pt:"{{count}} selecionado(s)",en:"{{count}} selected",es:"{{count}} seleccionado(s)"},send:{pt:"Enviar",en:"Send",es:"Enviar"},settings:{pt:"Configurações",en:"Settings",es:"Configuración"},settings_summary:{pt:"Resumo das configurações",en:"Settings summary",es:"Resumen de configuración"},showing:{pt:"Mostrando",en:"Showing",es:"Mostrando"},size:{pt:"Tamanho",en:"Size",es:"Tamaño"},skills:{pt:"Habilidades",en:"Skills",es:"Habilidades"},state:{pt:"Estado",en:"State",es:"Estado"},status:{pt:"Status",en:"Status",es:"Estado"},subordinates:{pt:"Subordinados",en:"Subordinates",es:"Subordinados"},success:{pt:"Sucesso",en:"Success",es:"Éxito"},superior:{pt:"Superior Imediato",en:"Immediate Superior",es:"Superior Inmediato"},superior_none:{pt:"Nenhum superior",en:"No superior",es:"Ningún superior"},superior_search:{pt:"Buscar superior...",en:"Search superior...",es:"Buscar superior..."},system_administration:{pt:"Administração do sistema",en:"System administration",es:"Administración del sistema"},system_logs:{pt:"Logs do Sistema",en:"System Logs",es:"Registros del Sistema"},template_variables:{pt:"Variáveis do Template",en:"Template Variables",es:"Variables de Plantilla"},test_email:{pt:"Testar Envio de Email",en:"Test Email Sending",es:"Probar Envío de Correo"},text:{pt:"Texto",en:"Text",es:"Texto"},text_color:{pt:"Cor do Texto",en:"Text Color",es:"Color del Texto"},text_format:{pt:"Formato de Texto",en:"Text Format",es:"Formato de Texto"},thumbnail:{pt:"Thumbnail",en:"Thumbnail",es:"Miniatura"},timezone:{pt:"Fuso Horário",en:"Timezone",es:"Zona Horaria"},title:{pt:"Título",en:"Title",es:"Título"},to:{pt:"até",en:"to",es:"hasta"},total:{pt:"Total",en:"Total",es:"Total"},trainings:{pt:"Treinamentos",en:"Trainings",es:"Capacitaciones"},translation:{pt:"Tradução",en:"Translation",es:"Traducción"},translation_description:{pt:"Informações da tradução",en:"Translation information",es:"Información de la traducción"},translations:{pt:"Traduções",en:"Translations",es:"Traducciones"},type:{pt:"Tipo",en:"Type",es:"Tipo"},type_to_search:{pt:"Digite para pesquisar",en:"Type to search",es:"Escriba para buscar"},unit:{pt:"Unidade",en:"Unit",es:"Unidad"},units:{pt:"Unidades",en:"Units",es:"Unidades"},unsupported:{pt:"Formato não suportado",en:"Unsupported format",es:"Formato no soportado"},update:{pt:"Atualizar",en:"Update",es:"Actualizar"},value:{pt:"Valor",en:"Value",es:"Valor"},update_success:{pt:"Atualizado com sucesso",en:"Updated successfully",es:"Actualizado exitosamente"},updated_at:{pt:"Atualizado em",en:"Updated at",es:"Actualizado en"},updated_by:{pt:"Atualizado por",en:"Updated by",es:"Actualizado por"},updating:{pt:"Atualizando...",en:"Updating...",es:"Actualizando..."},upload:{pt:"Upload",en:"Upload",es:"Cargar"},useSystemDefaults:{pt:"Usar padrão do sistema",en:"Use system defaults",es:"Usar valores del sistema"},uploading:{pt:"Enviando...",en:"Uploading...",es:"Subiendo..."},url:{pt:"URL",en:"URL",es:"URL"},url_placeholder:{pt:"https://exemplo.com/imagem.jpg",en:"https://example.com/image.jpg",es:"https://ejemplo.com/imagen.jpg"},user:{pt:"Usuário",en:"User",es:"Usuario"},user_management:{pt:"Gestão de Usuários",en:"User Management",es:"Gestión de Usuarios"},username:{pt:"Usuário",en:"Username",es:"Usuario"},users:{pt:"Usuários",en:"Users",es:"Usuarios"},video:{pt:"Vídeo",en:"Video",es:"Video"},view:{pt:"Visualizar",en:"View",es:"Visualizar"},view_mode_grid:{pt:"Grade",en:"Grid",es:"Cuadrícula"},view_mode_list:{pt:"Lista",en:"List",es:"Lista"},view_mode_table:{pt:"Tabela",en:"Table",es:"Tabla"},warning:{pt:"Aviso",en:"Warning",es:"Advertencia"},width:{pt:"Largura",en:"Width",es:"Ancho"},yes:{pt:"Sim",en:"Yes",es:"Sí"},zip_code:{pt:"CEP",en:"ZIP Code",es:"Código Postal"}};T.use(v.initReactI18next).init({resources:function(e){const t={},a={},s={};for(const[r,n]of Object.entries(e))t[r]=n.pt||r,a[r]=n.en||n.pt||r,s[r]=n.es||n.pt||r;return{"pt-BR":{translations:t},"en-US":{translations:a},"es-ES":{translations:s}}}(qo),fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e});const Oo=t.createContext(void 0),Bo={locale:xa,timezone:ba,datetimeFormat:ga},$o=async()=>{},Ho=({children:t})=>e.jsx(Oo.Provider,{value:{...Bo,setLocale:$o,setTimezone:$o,setDatetimeFormat:$o,isLoading:!1},children:t}),Vo=()=>{const e=t.useContext(Oo);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},Wo=he.Root,Go=he.CollapsibleTrigger,Yo=he.CollapsibleContent;class Qo extends t.Component{constructor(e){super(e),this.copyErrorDetails=()=>{const e=Rr.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),i.toast.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})},this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if((void 0).DEV)throw e;Rr.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=Rr.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(La,{className:"w-full max-w-2xl",children:[e.jsxs(za,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Fa,{children:"Algo deu errado"})]}),e.jsxs(qa,{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(Wo,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Go,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Yo,{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(vr,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:t.map((t,a)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(Pa,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Pa,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Ko=fe.Root,Xo=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Item,{ref:s,className:Ta("border-b",t),...a}));Xo.displayName="AccordionItem";const Zo=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(fe.Header,{className:"flex",children:e.jsxs(fe.Trigger,{ref:r,className:Ta("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Zo.displayName=fe.Trigger.displayName;const Jo=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(fe.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:Ta("pb-4 pt-0",t),children:a})}));Jo.displayName=fe.Content.displayName;const ei=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Root,{ref:s,className:Ta("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));ei.displayName=xe.Root.displayName;const ti=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Image,{ref:s,className:Ta("aspect-square h-full w-full",t),...a}));ti.displayName=xe.Image.displayName;const ai=J.forwardRef(({className:t,...a},s)=>e.jsx(xe.Fallback,{ref:s,className:Ta("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));ai.displayName=xe.Fallback.displayName;const si=J.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));si.displayName="Breadcrumb";const ri=J.forwardRef(({className:t,...a},s)=>e.jsx("ol",{ref:s,className:Ta("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));ri.displayName="BreadcrumbList";const ni=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Ta("inline-flex items-center gap-1.5",t),...a}));ni.displayName="BreadcrumbItem";const oi=J.forwardRef(({asChild:t,className:s,...r},n)=>{const o=t?a.Slot:"a";return e.jsx(o,{ref:n,className:Ta("transition-colors hover:text-foreground",s),...r})});oi.displayName="BreadcrumbLink";const ii=J.forwardRef(({className:t,...a},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Ta("font-normal text-foreground",t),...a}));ii.displayName="BreadcrumbPage";const li=({children:t,className:a,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Ta("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...s,children:t??e.jsx(l.ChevronRight,{})});li.displayName="BreadcrumbSeparator";const di=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Ta("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});di.displayName="BreadcrumbEllipsis";const ci=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"}}),ui=J.forwardRef(({className:t,orientation:a,...s},r)=>e.jsx("div",{ref:r,className:Ta(ci({orientation:a}),t),...s}));function mi({className:t,classNames:a,showOutsideDays:s=!0,...r}){return e.jsx(M.DayPicker,{showOutsideDays:s,className:Ta("p-3 pointer-events-auto",t),locale:ma,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:Ta(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Ta(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:Ta(Ea({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...a},components:{Chevron:({orientation:t})=>"left"===t?e.jsx(l.ChevronLeft,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}ui.displayName="ButtonGroup",mi.displayName="Calendar";const pi={Root:function({children:t,className:a}){return e.jsx("div",{className:Ta("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:s}){return e.jsx(La,{className:Ta("transition-colors",a&&"cursor-pointer hover:bg-muted/50",s),onClick:a,children:e.jsx(qa,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:s}){return e.jsxs("div",{className:Ta("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const hi=({shouldScaleBackground:t=!0,...a})=>e.jsx(I.Drawer.Root,{shouldScaleBackground:t,...a});hi.displayName="Drawer";const fi=I.Drawer.Trigger,xi=I.Drawer.Portal,gi=I.Drawer.Close,bi=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Overlay,{ref:s,className:Ta("fixed inset-0 z-50 bg-black/80",t),...a}));bi.displayName=I.Drawer.Overlay.displayName;const vi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(xi,{children:[e.jsx(bi,{}),e.jsxs(I.Drawer.Content,{ref:r,className:Ta("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));vi.displayName="DrawerContent";const wi=({className:t,...a})=>e.jsx("div",{className:Ta("grid gap-1.5 p-4 text-center sm:text-left",t),...a});wi.displayName="DrawerHeader";const Ni=({className:t,...a})=>e.jsx("div",{className:Ta("mt-auto flex flex-col gap-2 p-4",t),...a});Ni.displayName="DrawerFooter";const yi=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Title,{ref:s,className:Ta("text-lg font-semibold leading-none tracking-tight",t),...a}));yi.displayName=I.Drawer.Title.displayName;const ji=J.forwardRef(({className:t,...a},s)=>e.jsx(I.Drawer.Description,{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));ji.displayName=I.Drawer.Description.displayName;const Ci={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))]"},ki={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Si=ge.Root,_i=ge.Trigger,Ti=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,...r},n)=>e.jsx(ge.Content,{ref:n,align:a,sideOffset:s,className:Ta("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Ti.displayName=ge.Content.displayName;const Ai=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Ta("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));Ai.displayName="InputGroup";const Ei=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"}}),Pi=J.forwardRef(({className:t,align:a,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Ta(Ei({align:a}),t),...s}));Pi.displayName="InputGroupAddon";const Mi=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"}}),Ii=J.forwardRef(({className:t,size:a,variant:s="ghost",...r},n)=>e.jsx(Pa,{ref:n,"data-slot":"input-group-button",variant:s,className:Ta(Mi({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...r}));Ii.displayName="InputGroupButton";const Di=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-slot":"input-group-control",className:Ta("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Di.displayName="InputGroupInput";const Ri=J.forwardRef(({className:t,...a},s)=>e.jsx(Ms,{ref:s,"data-slot":"input-group-control",className:Ta("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));Ri.displayName="InputGroupTextarea";const Li=J.forwardRef(({className:t,...a},s)=>e.jsx("h1",{ref:s,className:Ta("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));Li.displayName="H1";const zi=J.forwardRef(({className:t,...a},s)=>e.jsx("h2",{ref:s,className:Ta("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));zi.displayName="H2";const Fi=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Ta("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));Fi.displayName="H3";const Ui=J.forwardRef(({className:t,...a},s)=>e.jsx("h4",{ref:s,className:Ta("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));Ui.displayName="H4";const qi=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Ta("leading-7 [&:not(:first-child)]:mt-6",t),...a}));qi.displayName="P";const Oi=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Ta("text-xl text-muted-foreground",t),...a}));Oi.displayName="Lead";const Bi=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Ta("text-lg font-semibold",t),...a}));Bi.displayName="Large";const $i=J.forwardRef(({className:t,...a},s)=>e.jsx("small",{ref:s,className:Ta("text-sm font-medium leading-none",t),...a}));$i.displayName="Small";const Hi=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));Hi.displayName="Muted";const Vi=J.forwardRef(({className:t,...a},s)=>e.jsx("code",{ref:s,className:Ta("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));Vi.displayName="InlineCode";const Wi=J.forwardRef(({className:t,...a},s)=>e.jsx("blockquote",{ref:s,className:Ta("mt-6 border-l-2 pl-6 italic",t),...a}));Wi.displayName="Blockquote";const Gi=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Ta("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));Gi.displayName="List";const Yi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(be.Root,{ref:r,className:Ta("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[a,e.jsx(tl,{})]}));Yi.displayName=be.Root.displayName;const Qi=J.forwardRef(({className:t,...a},s)=>e.jsx(be.List,{ref:s,className:Ta("group flex flex-1 list-none items-center justify-center space-x-1",t),...a}));Qi.displayName=be.List.displayName;const Ki=be.Item,Xi=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"),Zi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(be.Trigger,{ref:r,className:Ta(Xi(),"group",t),...s,children:[a," ",e.jsx(l.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Zi.displayName=be.Trigger.displayName;const Ji=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Content,{ref:s,className:Ta("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",t),...a}));Ji.displayName=be.Content.displayName;const el=be.Link,tl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:Ta("absolute left-0 top-full flex justify-center"),children:e.jsx(be.Viewport,{className:Ta("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",t),ref:s,...a})}));tl.displayName=be.Viewport.displayName;const al=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Indicator,{ref:s,className:Ta("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",t),...a,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));al.displayName=be.Indicator.displayName;const sl=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Ta("mx-auto flex w-full justify-center",t),...a});sl.displayName="Pagination";const rl=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Ta("flex flex-row items-center gap-1",t),...a}));rl.displayName="PaginationContent";const nl=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Ta("",t),...a}));nl.displayName="PaginationItem";const ol=({className:t,isActive:a,size:s="icon",...r})=>e.jsx("a",{"aria-current":a?"page":void 0,className:Ta(Ea({variant:a?"outline":"ghost",size:s}),t),...r});ol.displayName="PaginationLink";const il=({className:t,...a})=>e.jsxs(ol,{"aria-label":"Go to previous page",size:"default",className:Ta("gap-1 pl-2.5",t),...a,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});il.displayName="PaginationPrevious";const ll=({className:t,...a})=>e.jsxs(ol,{"aria-label":"Go to next page",size:"default",className:Ta("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});ll.displayName="PaginationNext";const dl=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:Ta("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});dl.displayName="PaginationEllipsis";const cl=J.forwardRef(({className:t,value:a,...s},r)=>e.jsx(ve.Root,{ref:r,className:Ta("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...s,children:e.jsx(ve.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));cl.displayName=ve.Root.displayName;const ul=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Root,{className:Ta("grid gap-2",t),...a,ref:s}));ul.displayName=we.Root.displayName;const ml=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Item,{ref:s,className:Ta("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(we.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ml.displayName=we.Item.displayName;const pl=Ne.Panel,hl=te.Root,fl=te.Trigger,xl=te.Close,gl=te.Portal,bl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{className:Ta("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));bl.displayName=te.Overlay.displayName;const vl=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"}}),wl=J.forwardRef(({side:t="right",className:a,children:s,...r},n)=>e.jsxs(gl,{children:[e.jsx(bl,{}),e.jsxs(te.Content,{ref:n,className:Ta(vl({side:t}),a),...r,children:[s,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));wl.displayName=te.Content.displayName;const Nl=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Ta("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});Nl.displayName="SheetHeader";const yl=({className:t,...a})=>e.jsx("div",{className:Ta("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});yl.displayName="SheetBody";const jl=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Ta("flex flex-row justify-end gap-2",t),...s,children:a})]});jl.displayName="SheetFooter";const Cl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Ta("text-lg font-semibold text-foreground",t),...a}));Cl.displayName=te.Title.displayName;const kl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Ta("text-sm text-muted-foreground",t),...a}));kl.displayName=te.Description.displayName;const Sl="sidebar:state",_l=J.createContext(null);function Tl(){const e=J.useContext(_l);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Al=J.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=Cn(),[c,u]=J.useState(!1),[m,p]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Sl);return null!==e?"true"===e:t}return t}),h=a??m,f=J.useCallback(e=>{const t="function"==typeof e?e(h):e;s?s(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Sl,String(t))},[s,h]),x=J.useCallback(()=>d?u(e=>!e):f(e=>!e),[d,f,u]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const g=h?"expanded":"collapsed",b=J.useMemo(()=>({state:g,open:h,setOpen:f,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:x}),[g,h,f,d,c,u,x]);return e.jsx(_l.Provider,{value:b,children:e.jsx(Js,{delayDuration:0,children:e.jsx("div",{className:Ta("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4rem",...n},ref:l,...i,children:o})})})});Al.displayName="SidebarProvider";const El=J.forwardRef(({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=Tl();return"none"===s?e.jsx("div",{className:Ta("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?e.jsx(hl,{open:c,onOpenChange:u,...o,children:e.jsxs(wl,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsx(Cl,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:Ta("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Ta("duration-200 fixed inset-y-0 z-30 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col overflow-visible group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});El.displayName="Sidebar";const Pl=J.forwardRef(({className:t,onClick:a,...s},r)=>{const{toggleSidebar:n}=Tl();return e.jsxs(Pa,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ta("h-7 w-7",t),onClick:e=>{a?.(e),n()},...s,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Pl.displayName="SidebarTrigger";const Ml=J.forwardRef(({className:t,...a},s)=>{const{toggleSidebar:r}=Tl();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Ta("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});Ml.displayName="SidebarRail";const Il=J.forwardRef(({className:t,...a},s)=>e.jsx("main",{ref:s,className:Ta("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));Il.displayName="SidebarInset";const Dl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-sidebar":"input",className:Ta("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));Dl.displayName="SidebarInput";const Rl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Ta("flex flex-col gap-2 p-2",t),...a}));Rl.displayName="SidebarHeader";const Ll=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Ta("flex flex-col gap-2 p-2",t),...a}));Ll.displayName="SidebarFooter";const zl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ba,{ref:s,"data-sidebar":"separator",className:Ta("mx-2 w-auto bg-sidebar-border",t),...a}));zl.displayName="SidebarSeparator";const Fl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Ta("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));Fl.displayName="SidebarContent";const Ul=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Ta("relative flex w-full min-w-0 flex-col p-2",t),...a}));Ul.displayName="SidebarGroup";const ql=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:Ta("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r})});ql.displayName="SidebarGroupLabel";const Ol=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:Ta("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r})});Ol.displayName="SidebarGroupAction";const Bl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Ta("w-full text-sm",t),...a}));Bl.displayName="SidebarGroupContent";const $l=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Ta("flex w-full min-w-0 flex-col gap-1",t),...a}));$l.displayName="SidebarMenu";const Hl=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Ta("group/menu-item relative",t),...a}));Hl.displayName="SidebarMenuItem";const Vl=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Wl=J.forwardRef(({asChild:t=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=t?a.Slot:"button",{isMobile:u,state:m}=Tl(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Ta(Vl({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:p}),e.jsx(ar,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Wl.displayName="SidebarMenuButton";const Gl=J.forwardRef(({className:t,asChild:s=!1,showOnHover:r=!1,...n},o)=>{const i=s?a.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Ta("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...n})});Gl.displayName="SidebarMenuAction";const Yl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Ta("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));Yl.displayName="SidebarMenuBadge";const Ql=J.forwardRef(({className:t,showIcon:a=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Ta("rounded-md h-8 flex gap-2 px-2 items-center",t),...s,children:[a&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});Ql.displayName="SidebarMenuSkeleton";const Kl=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Ta("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));Kl.displayName="SidebarMenuSub";const Xl=J.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));Xl.displayName="SidebarMenuSubItem";const Zl=J.forwardRef(({asChild:t=!1,size:s="md",isActive:r,className:n,...o},i)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Ta("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});Zl.displayName="SidebarMenuSubButton";const Jl=J.forwardRef(({className:t,value:a,defaultValue:s,...r},n)=>{const o=a||s||[0];return e.jsxs(ye.Root,{ref:n,value:a,defaultValue:s,className:Ta("relative flex w-full touch-none select-none items-center",t),...r,children:[e.jsx(ye.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(ye.Range,{className:"absolute h-full bg-primary"})}),o.map((t,a)=>e.jsx(ye.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},a))]})});Jl.displayName=ye.Root.displayName;const ed=je.Root,td=J.forwardRef(({className:t,...a},s)=>e.jsx(je.List,{ref:s,className:Ta("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));td.displayName=je.List.displayName;const ad=J.forwardRef(({className:t,...a},s)=>e.jsx(je.Trigger,{ref:s,className:Ta("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));ad.displayName=je.Trigger.displayName;const sd=J.forwardRef(({className:t,...a},s)=>e.jsx(je.Content,{ref:s,className:Ta("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));sd.displayName=je.Content.displayName;const rd=Ce.Menu,nd=Ce.Group,od=Ce.Portal,id=Ce.Sub,ld=Ce.RadioGroup,dd=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Root,{ref:s,className:Ta("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));dd.displayName=Ce.Root.displayName;const cd=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Trigger,{ref:s,className:Ta("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t),...a}));cd.displayName=Ce.Trigger.displayName;const ud=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Ta("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ud.displayName=Ce.SubTrigger.displayName;const md=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.SubContent,{ref:s,className:Ta("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));md.displayName=Ce.SubContent.displayName;const pd=J.forwardRef(({className:t,align:a="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:o,align:a,alignOffset:s,sideOffset:r,className:Ta("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));pd.displayName=Ce.Content.displayName;const hd=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Ta("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));hd.displayName=Ce.Item.displayName;const fd=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Ta("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));fd.displayName=Ce.CheckboxItem.displayName;const xd=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Ta("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));xd.displayName=Ce.RadioItem.displayName;const gd=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Ta("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));gd.displayName=Ce.Label.displayName;const bd=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Separator,{ref:s,className:Ta("-mx-1 my-1 h-px bg-muted",t),...a}));bd.displayName=Ce.Separator.displayName;const vd=({className:t,...a})=>e.jsx("span",{className:Ta("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});vd.displayname="MenubarShortcut";const wd={light:"",dark:".dark"},Nd=J.createContext(null);function yd(){const e=J.useContext(Nd);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const jd=J.forwardRef(({id:t,className:a,children:s,config:r,...n},o)=>{const i=J.useId(),l=`chart-${t||i.replace(/:/g,"")}`;return e.jsx(Nd.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:o,className:Ta("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[e.jsx(Cd,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});jd.displayName="Chart";const Cd=({id:t,config:a})=>{const s=Object.entries(a).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(wd).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${s.map(([t,a])=>{const s=a.theme?.[e]||a.color;return s?` --color-${t}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},kd=ke.Tooltip,Sd=J.forwardRef(({active:t,payload:a,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=yd(),x=J.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,s=Ad(f,t,`${p||t?.dataKey||t?.name||"value"}`),r=p||"string"!=typeof i?s?.label:f[i]?.label||i;return l?e.jsx("div",{className:Ta("font-medium",d),children:l(r,a)}):r?e.jsx("div",{className:Ta("font-medium",d),children:r}):null},[i,l,a,n,d,f,p]);if(!t||!a?.length)return null;const g=1===a.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Ta("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:x,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const s=`${m||t.name||t.dataKey||"value"}`,n=Ad(f,t,s),i=u||t.payload?.fill||t.color;return e.jsx("div",{className:Ta("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==t?.value&&t.name?c(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:Ta("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":i,"--color-border":i}}),e.jsxs("div",{className:Ta("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});Sd.displayName="ChartTooltip";const _d=ke.Legend,Td=J.forwardRef(({className:t,hideIcon:a=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=yd();return s?.length?e.jsx("div",{ref:o,className:Ta("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${n||t.dataKey||"value"}`,r=Ad(i,t,s);return e.jsxs("div",{className:Ta("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!a?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),r?.label]},t.value)})}):null});function Ad(e,t,a){if("object"!=typeof t||null===t)return;const s="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let r=a;return a in t&&"string"==typeof t[a]?r=t[a]:s&&a in s&&"string"==typeof s[a]&&(r=s[a]),r in e?e[r]:e[a]}Td.displayName="ChartLegend";const Ed=({onClick:t,isActive:a,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:s,title:n,className:Ta("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Pd=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Md({image:t,title:a,className:s}){return e.jsx("div",{className:Ta("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:t?e.jsx("img",{src:t,alt:a,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Id({steps:t,currentStepIndex:a,onStepSelect:s,stepLabel:r,className:n}){const o=t.length,i=(a+1)/o*100;return e.jsxs("div",{className:Ta("flex items-center gap-3",n),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",a+1,"/",o,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:t.map((t,r)=>e.jsxs(Gs,{onClick:()=>s(r),className:Ta(r===a&&"bg-accent"),children:[r+1,". ",t.title]},t.id))})]}),e.jsx(cl,{value:i,className:"w-32 h-2"})]})}function Dd({currentStepIndex:t,totalSteps:a,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:d,className:c}){const u=0===t,m=t===a-1;return e.jsxs("div",{className:Ta("flex items-center gap-2",c),children:[!u&&e.jsxs(Pa,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(l.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),e.jsxs(Pa,{onClick:m?n:r,size:"sm",children:[m?d:i,!m&&e.jsx(l.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const Rd=J.forwardRef(({open:t,onOpenChange:a,steps:s,onComplete:r,onStepChange:n,continueButtonText:o="Continuar",backButtonText:i="Voltar",finishButtonText:d="Concluir",stepLabel:c="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==p,w=v?p:g,N=J.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);J.useEffect(()=>{t||v||b(0)},[t,v]);const y=s[w],j=s.length;return y?e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{ref:x,size:u,variant:"informative",className:Ta("p-0 gap-0 overflow-hidden",f),children:[e.jsxs(ss,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(Md,{image:y.image,title:y.title}),e.jsx(cs,{className:"text-xl font-semibold",children:y.title}),e.jsx(us,{className:"text-muted-foreground",children:y.description})]})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(Ba,{}),e.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[m&&j>1?e.jsx(Id,{steps:s,currentStepIndex:w,onStepSelect:e=>{N(e)},stepLabel:c}):e.jsx("div",{}),e.jsx(Dd,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&N(w-1)},onNext:()=>{w<j-1&&N(w+1)},onComplete:()=>{r?.(),a(!1)},backButtonText:i,continueButtonText:o,finishButtonText:d})]})]})]})}):null});Rd.displayName="OnboardingDialog";function Ld({onEdit:a,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:d=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=v.useTranslation(),p=t.useMemo(()=>{const e=[];return a&&o&&e.push({key:"edit",icon:l.Edit,label:m("edit","Editar"),onClick:a,variant:"default"}),r&&e.push({key:"toggle-status",icon:n?l.PowerOff:l.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),d.forEach(t=>{!1!==t.show&&e.push({key:`custom-${t.label}`,icon:t.icon,label:t.label,onClick:t.onClick,variant:t.variant||"default",disabled:t.disabled,disabledReason:t.disabledReason})}),s&&i&&e.push({key:"delete",icon:l.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),e},[a,s,r,n,o,i,d,m]);return 0===p.length?null:"dropdown"===c?e.jsx(Js,{delayDuration:200,children:e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===u?14:16})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(t=>t.disabled?e.jsxs(sr,{disabledReason:t.disabledReason,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key):e.jsxs(Gs,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:p.map(t=>e.jsxs(Pa,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:t.onClick,className:"compact"===u?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===u?14:16}),"compact"!==u&&e.jsx("span",{className:"ml-1",children:t.label})]},t.key))})}function zd(e){const t=j.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}const Fd=t.memo(({variant:a="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:o,companies:i,alias:d,isAuthenticated:c,logout:u,switchUnit:m}=Nn(),p=i?.[0]||null,h=d?i?.find(e=>e.alias===d):p,f=i||[],x=r||h||p||p,g=t.useCallback(e=>{n?n(e):m(e)},[n,m]),b=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===x?.alias),s=t.filter(e=>e.alias!==x?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[f,x?.alias]);if(!c||!o)return null;return"dropdown"===a?e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Ws,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(Bs,{children:[e.jsxs(Hs,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(Vs,{children:b.map(t=>e.jsxs(Gs,{onClick:()=>g(t),className:t.alias===x?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e.jsx(Ds,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):e.jsxs(La,{className:s,children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})}),b.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",b.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(t=>e.jsx(Ds,{variant:t.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(t),children:t.name},t.alias)),b.length>3&&e.jsxs(Ds,{variant:"outline",className:"text-xs",children:["+",b.length-3]})]})]})]}),{}),e.jsx(Ba,{}),e.jsxs(Pa,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Ud=t.createContext({});function qd({children:a,config:s}){const r=t.useMemo(()=>{const e=Yr(),t=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:t}},[s?.navigation,s?.appName]);return e.jsx(Ud.Provider,{value:r,children:a})}function Od(){return t.useContext(Ud)}function Bd(e,t){if(!e)return"Página";const a=e.find(e=>e.path===t);if(a)return a.label;const s=e.find(e=>t.startsWith(e.path+"/"));return s?.label||"Página"}function $d(e,a){const[s,r]=t.useState(e),n=t.useRef(),o=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(o(),n.current=setTimeout(()=>{r(e)},a),o),[e,a,o]),[s,o]}const Hd=t.memo(function({actions:a}){const s=j.useLocation(),{navigation:r,appName:n}=Od(),o=Bd(r,s.pathname),{metadata:i,headerActions:d}=Uo(),{setOpenMobile:c}=Tl(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:f,switchUnit:x}=Nn(),g=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,v]=j.useSearchParams(),[w,N]=t.useState(()=>b.get("search")||""),[y,C]=$d(w,Xr.debounceDelay);t.useEffect(()=>{if(!p)return;const e=new URLSearchParams(b);y?(e.set("search",y),e.set("page","1")):e.delete("search"),v(e)},[y,v,p]);const k=r?.find(e=>e.path===s.pathname)||r?.find(e=>s.pathname.startsWith(e.path+"/")),S=i.title||o,_=i.subtitle||k?.complementaryText||"Detalhes do item";return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Pa,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0",onClick:()=>c(!0),children:e.jsx(l.Menu,{size:20})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:S})}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:_})]}),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(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:w,onChange:e=>(e=>{N(e)})(e.target.value),className:"w-full pl-10 pr-8"}),w&&e.jsx(Pa,{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:()=>{C(),N("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),v(e)},title:"Limpar busca",children:e.jsx(l.X,{size:14})})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(d||a)&&e.jsx("div",{className:"flex items-center gap-2",children:d||a}),(void 0).VITE_WIKI_URL&&e.jsx(Pa,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>_a((void 0).VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(Fd,{variant:"dropdown",selectedUnit:g,onUnitChange:x})})]})]})})}),Vd=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>y.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1});function Wd({className:t}){return e.jsxs("svg",{className:t,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.5 11.7455C0.5 10.2633 2.25695 9.52546 3.36816 10.4399L22.4346 26.1528C23.3588 26.9137 23.229 28.3353 22.1953 28.9301L16.3418 32.2963C15.7961 32.6097 15.1199 32.6098 14.5742 32.2963L1.36133 24.7006C0.832671 24.3966 0.500052 23.8398 0.5 23.2289V11.7455Z",stroke:"currentColor"}),e.jsx("path",{d:"M14.612 0.735352C15.1576 0.421927 15.833 0.421964 16.3786 0.735352L25.3776 5.90723V5.9082C26.5447 6.5808 26.5183 8.24018 25.3298 8.875L25.3307 8.87598L13.9333 14.9697L13.9323 14.9688C13.3016 15.3066 12.5233 15.2301 11.9733 14.7773L4.90302 8.9541C3.97881 8.19317 4.1086 6.77256 5.14227 6.17773L14.612 0.735352Z",stroke:"currentColor"}),e.jsx("path",{d:"M28.1066 9.7966C29.2466 9.18579 30.6895 9.9732 30.6896 11.2937V23.0691C30.6895 23.6825 30.3539 24.2382 29.8264 24.5417L29.8254 24.5427L27.3449 25.9607C26.7486 26.3015 26.0057 26.264 25.4494 25.8747L25.341 25.7917L16.6076 18.5974C15.6649 17.821 15.8224 16.3676 16.8937 15.7937V15.7927L28.1066 9.79758V9.7966Z",stroke:"currentColor"})]})}function Gd({className:t}){return e.jsxs("svg",{className:t,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.524143 8.74979C1.44754 8.74979 2.36325 8.74979 3.30973 8.74979C3.30973 8.90069 3.30973 9.05162 3.30973 9.19497C3.30973 9.79101 3.64061 10.1154 4.24082 10.1154C6.8879 10.1154 9.54268 10.1154 12.1898 10.1154C12.7592 10.1154 13.1286 9.77589 13.1132 9.27793C13.0978 8.8856 12.8054 8.5612 12.3745 8.51594C11.2279 8.38767 10.0736 8.26696 8.91938 8.1387C7.72666 8.01043 6.52625 7.88216 5.33352 7.74635C4.71792 7.67845 4.10232 7.61811 3.48672 7.53511C2.00928 7.32386 0.754978 6.06386 0.547213 4.61526C0.331752 3.10631 1.00122 1.73316 2.34015 0.963593C2.89419 0.646712 3.5021 0.503353 4.14848 0.503353C6.84943 0.503353 9.55038 0.495808 12.2513 0.503353C14.0904 0.510898 15.5448 1.71808 15.8603 3.49865C15.8988 3.7099 15.8988 3.92116 15.9065 4.13996C15.9141 4.2984 15.9065 4.44928 15.9065 4.61526C14.9677 4.61526 14.0443 4.61526 13.0978 4.61526C13.0978 4.44928 13.0978 4.28329 13.0978 4.1173C13.0901 3.58162 12.7592 3.25719 12.2206 3.24965C9.53499 3.24965 6.84943 3.24965 4.17157 3.24965C3.69448 3.24965 3.36359 3.52881 3.30203 3.97396C3.24816 4.3512 3.51749 4.73597 3.90224 4.8265C4.10231 4.87177 4.31008 4.88687 4.51784 4.9095C5.8183 5.05285 7.12645 5.19622 8.42691 5.33957C9.71198 5.48292 10.997 5.63382 12.2898 5.75453C13.1824 5.83753 13.9981 6.08649 14.6906 6.68253C16.1604 7.92742 16.3066 10.2588 14.9984 11.6696C14.2443 12.4845 13.3132 12.8844 12.1975 12.8844C9.5273 12.8844 6.84944 12.8844 4.17927 12.8844C2.55562 12.8844 1.21669 11.9563 0.678043 10.4549C0.539533 9.98715 0.470277 9.38356 0.524143 8.74979Z",stroke:"currentColor"}),e.jsx("path",{d:"M8.21913 24.2393C8.21913 24.2317 8.21913 24.2317 8.21913 24.2393ZM8.21913 24.2393C8.98863 24.2393 9.75812 24.2619 10.5199 24.2317C11.7511 24.1789 12.9285 23.1378 13.067 21.9381C13.1439 21.3119 13.1285 20.6706 13.1131 20.0368C13.067 18.6335 11.8743 17.4339 10.443 17.3962C8.96554 17.3584 7.4881 17.366 6.00296 17.3962C4.70251 17.4263 3.54055 18.4373 3.37896 19.6973C3.29431 20.3462 3.3097 21.0101 3.34048 21.6665C3.40204 23.017 4.58708 24.1789 5.96449 24.2317C6.7186 24.2619 7.46502 24.2393 8.21913 24.2393ZM13.1439 15.427C13.7441 14.8385 14.3367 14.2575 14.9138 13.6917C15.5756 14.333 16.2296 14.9818 16.9222 15.6608C16.8914 15.6759 16.8298 15.7061 16.7837 15.7438C16.2604 16.2493 15.7448 16.7624 15.2216 17.2679C15.1446 17.3434 15.1369 17.4037 15.1908 17.4943C15.7064 18.3845 15.9526 19.3427 15.9295 20.3613C15.9141 20.9799 15.9526 21.6062 15.8603 22.2097C15.5371 24.2846 14.352 25.7332 12.3975 26.5782C11.7126 26.8724 10.9816 26.9931 10.2352 26.9931C8.89629 26.9931 7.56504 26.9931 6.22611 26.9931C3.49438 26.9931 1.20897 25.1899 0.631845 22.5719C0.56259 22.2475 0.524115 21.9155 0.51642 21.5835C0.508725 20.9422 0.470242 20.2933 0.547192 19.6596C0.816518 17.3584 2.08619 15.7967 4.27927 14.9516C4.84101 14.7328 5.42584 14.6347 6.02605 14.6347C7.4958 14.6347 8.96554 14.6272 10.4276 14.6423C11.3279 14.6498 12.1667 14.9064 12.9516 15.3289C13.0131 15.3591 13.067 15.3892 13.1439 15.427Z",stroke:"currentColor"}),e.jsx("path",{d:"M0.508791 28.3813C1.43989 28.3813 2.3633 28.3813 3.2944 28.3813C3.31748 28.4945 3.32516 28.6001 3.35594 28.7058C3.50984 29.2943 4.01772 29.7017 4.63332 29.7319C4.76414 29.7394 4.89496 29.7394 5.02578 29.7394C7.22655 29.7394 9.4273 29.7394 11.6281 29.7394C12.3206 29.7394 12.8439 29.3923 13.0363 28.7963C13.0747 28.668 13.0978 28.5323 13.1286 28.3889C14.0443 28.3889 14.9677 28.3889 15.9142 28.3889C15.9219 28.7435 15.868 29.0906 15.7757 29.4301C15.2986 31.1955 13.6519 32.4782 11.7897 32.4857C9.39653 32.5008 7.01108 32.5083 4.61794 32.4857C2.44025 32.4706 0.624216 30.7353 0.508791 28.6077C0.501096 28.5322 0.508791 28.4643 0.508791 28.3813Z",stroke:"currentColor"})]})}const Yd=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",url:"https://okr.qualiex.com"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",url:"https://competencias.sabergestao.com.br"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",url:"https://desempenho.sabergestao.com.br"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",url:"https://educacao.sabergestao.com.br"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",url:"https://pdi.sabergestao.com.br"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",url:"https://nr1pulso.sabergestao.com.br"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",url:"https://treinamentos.sabergestao.com.br"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]",url:"https://apps1.qualiex.com/action?unitalias={alias}"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]",url:"https://apps1.qualiex.com/audit?unitalias={alias}"},{name:"Configurações v3",description:"Configurações",color:"bg-[#5C6BC0]",url:"https://apps3.qualiex.com/{alias}/common"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]",url:"https://apps1.qualiex.com/shared/dashboard?unitalias=forlogic"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]",url:"https://apps1.qualiex.com/docs?unitalias={alias}"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]",url:"https://apps1.qualiex.com/indicators?unitalias={alias}"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]",url:"https://apps1.qualiex.com/meeting?unitalias={alias}"},{name:"Metrology v3",description:"Gestão de Metrologia",color:"bg-[#afd884]",url:"https://apps3.qualiex.com/{alias}/metrology/"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]",url:"https://apps3.qualiex.com/{alias}/planner/m"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]",url:"https://apps1.qualiex.com/common/reports?unitalias=forlogic"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]",url:"https://apps1.qualiex.com/risks?unitalias={alias}"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]",url:"https://apps1.qualiex.com/staff?unitalias={alias}"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]",url:"https://apps1.qualiex.com/supply?unitalias={alias}"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker1?unitalias={alias}"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker2?unitalias={alias}"}]}];function Qd({module:t,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:Ta("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:t.name}),t.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function Kd(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),s=[];for(let r=0;r<a;r++)for(let n=0;n<t;n++){const t=n*a+r;t<e.length&&s.push(e[t])}return s}function Xd({modules:a,onModuleClick:s,contractedModules:r,onModuleInterest:n}){const o=function(){const[e,a]=t.useState(4);return t.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?a(4):window.matchMedia("(min-width: 768px)").matches?a(3):a(2)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...a].sort((e,t)=>e.name.localeCompare(t.name)),l=void 0!==r,d=l?i.filter(e=>r.includes(e.name)):i,c=l?i.filter(e=>!r.includes(e.name)):[],u=Kd(d,o),m=Kd(c,o),p=(e,t)=>{t?s?.(e):n?.(e)};return e.jsxs("div",{className:"space-y-6",children:[u.length>0&&e.jsx("section",{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(t=>e.jsx(Qd,{module:t,onClick:()=>p(t,!0)},t.name))})}),m.length>0&&e.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(t=>e.jsx(Qd,{module:t,onClick:()=>p(t,!1)},t.name))})]})]})}function Zd({open:a,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:i="https://educa.forlogic.net/",saberGestaoUrl:d="https://sabergestao.com.br/",wikiUrl:c}){const[u,m]=t.useState("qualiex"),[p,h]=t.useState(null),{alias:f}=Nn(),x=e=>{if(r)r(e);else if(e.url){_a(f?e.url.replace(/\{alias\}/g,f):e.url)}},g=e=>{h(e)},b=i||c||"https://educa.forlogic.net/";return e.jsxs(e.Fragment,{children:[e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{size:"lg",className:"overflow-hidden flex flex-col max-h-[85vh]",children:[e.jsx(is,{className:"sr-only",children:e.jsx(cs,{children:"Módulos"})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(ed,{value:u,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(td,{className:"w-fit shrink-0",children:Yd.map(t=>e.jsxs(ad,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),Yd.map(t=>e.jsx(sd,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(Xd,{modules:t.modules,onModuleClick:x,contractedModules:n,onModuleInterest:g})},t.id))]}),e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o ForLogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(Wd,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(Gd,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:c||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})]})]})}),p&&e.jsx(Rd,{open:!!p,onOpenChange:e=>!e&&h(null),steps:(v=p,v.onboardingSteps&&v.onboardingSteps.length>0?v.onboardingSteps.slice(0,3):[{id:"intro",title:`Conheça o ${v.name}`,description:v.description||`O ${v.name} é uma solução completa para otimizar seus processos e aumentar a produtividade da sua equipe.`},{id:"features",title:"Principais Funcionalidades",description:"Automatize processos, gere relatórios detalhados, acompanhe indicadores em tempo real e tenha controle total sobre suas operações."},{id:"cta",title:"Transforme sua Gestão",description:"Fale com um de nossos especialistas e descubra como este módulo pode transformar a gestão da sua empresa."}]),finishButtonText:"Quero conhecer mais",onComplete:()=>{p&&(o?.(p),h(null))}})]});var v}const Jd=`https://${Gr().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,ec={logo:tn.isQualiex?`${Jd}/logo-qualiex.svg`:`${Jd}/logo.svg`,smallLogo:tn.isQualiex?`${Jd}/small-forlogic.svg`:`${Jd}/small.svg`},tc=ec.logo,ac=ec.smallLogo;function sc({open:a,appName:s}){const[r,n]=t.useState(!1);return e.jsxs(Js,{children:[e.jsx(Rl,{className:"p-0 gap-0",children:a?e.jsxs("div",{className:"flex flex-col gap-3 pl-2",children:[e.jsx("div",{className:"flex items-center h-10",children:e.jsx("img",{src:ec.logo,alt:"Logo",className:"h-8 max-w-full object-contain"})}),e.jsxs(Pa,{variant:"secondary",size:"default",className:"h-10 gap-2 px-3 justify-start w-full",onClick:()=>n(!0),children:[e.jsx(l.Grip,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s||"Módulos"})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full gap-3",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-8",children:e.jsx("img",{src:ec.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center h-10 w-8 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>n(!0),children:e.jsx(l.Grip,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:s||"Módulos"})})]})]})}),e.jsx(Zd,{open:r,onOpenChange:n})]})}function rc({config:t,isCollapsed:a=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus}=t;if(!n||0===n.length)return null;const d=(t,s,r=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&s&&e.jsx("span",{className:"truncate",children:s}),!a&&r&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],o=t.icon||i,l=s||t.disabled,c=e.jsx(Pa,{onClick:t.onClick,disabled:l,className:Ta("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(o,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:c}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]}):c}const c=e.jsx(Pa,{disabled:s,className:Ta("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:c}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o})})]}):c}),e.jsx(Ws,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}const nc="forlogic-sidebar-pinned",oc=()=>{try{const e=localStorage.getItem(nc);return!!e&&JSON.parse(e)}catch{return!1}};function ic({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),o?.(r)},r=()=>{u(!1),d(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,o]),t.useEffect(()=>(c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const lc=t.createContext(void 0);function dc(){const e=t.useContext(lc);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function cc({config:a,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{open:i,setOpen:d}=Tl(),c=j.useLocation(),{alias:u,user:m}=Nn(),{appName:p}=Od(),{hasOpenModal:h}=dc(),[f,x]=t.useState(oc),g=r?ic({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:i}):null;t.useEffect(()=>{d(!!f)},[f,d]);const b=e=>c.pathname===e||c.pathname.startsWith(e+"/");return e.jsxs(El,{collapsible:"icon",className:Ta("app-sidebar bg-background border-r border-border py-4",i?"px-3":"px-1.5"),style:g&&i?{width:`${g.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(sc,{open:i,appName:p}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"py-3",children:e.jsx(Js,{children:e.jsx(rc,{config:a.moduleActions,isCollapsed:!i,isDisabled:h})})}),e.jsxs("div",{className:"relative py-5",children:[e.jsx(Ba,{}),e.jsx("div",{className:Ta("absolute top-1/2 -translate-y-1/2 z-[100] hidden md:block",i?"-right-6":"-right-[18px]"),children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{onClick:()=>{const e=!f;x(e),(e=>{try{localStorage.setItem(nc,JSON.stringify(e))}catch{}})(e)},className:"h-6 w-6 flex items-center justify-center rounded-full bg-primary hover:bg-primary/90 shadow-md transition-colors",children:i?e.jsx(l.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:i?"Recolher":"Expandir"})})]})})]}),e.jsx(Fl,{children:s||e.jsx(Ul,{className:"p-0",children:e.jsx(Bl,{children:e.jsx($l,{className:"gap-1",children:e.jsx(Js,{children:a?.navigation?.map((t,a)=>{const s=({item:t,index:a})=>{const r=`${t.path}-${a}-${u??"noalias"}-${m?.id??"nouser"}`,{data:n=!0,isLoading:o}=Vd({key:r,enabled:Boolean(t.permissionCheck&&u&&m?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),d=t.permissionCheck&&!n,c=o?l.Loader2:d?l.Lock:t.icon;d||t.complementaryText;return t.children&&t.children.length>0?i?e.jsx(Wo,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(Hl,{children:[e.jsx(Go,{asChild:!0,children:e.jsx(Wl,{size:"default",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),e.jsx(Yo,{children:e.jsx(Kl,{children:t.children.map((t,a)=>e.jsx(s,{item:t,index:a},t.path))})})]})},t.path):e.jsx(Hl,{children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:Ta("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors cursor-pointer","hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path):e.jsx(Hl,{children:d||o?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:i?e.jsx(Wl,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsx("div",{className:"flex items-center justify-center h-8 w-8 mx-auto rounded-md opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o?"Verificando acesso...":"Acesso restrito"})})]}):i?e.jsx(Wl,{asChild:!0,isActive:b(t.path),size:"default",children:e.jsxs(j.Link,{to:t.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx(j.Link,{to:t.path,className:Ta("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",b(t.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path)};return e.jsx(s,{item:t,index:a},t.path)})})})})})}),r&&g&&i&&e.jsx("div",{ref:g.dragRef,onMouseDown:g.handleMouseDown,className:Ta("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",g.isDragging&&"bg-primary/40")})]})}const uc=t.memo(function({children:a,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||e.jsx(cc,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(qd,{config:r,children:e.jsx(Fo,{children:e.jsx(Al,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"relative z-0 flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(Hd,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:a})]})]})})})})});class mc{static async sendEmail(e){const t=Ur(),{data:a,error:s}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return a}}const pc=mc;function hc({open:a,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:d,currentMemberIds:c=[]}){const[u,m]=t.useState([]),[p,h]=t.useState(!1),[f,x]=t.useState(""),{data:g=[],isLoading:b}=vo({enabled:a}),v=t.useMemo(()=>{let e=[...g];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",s=t.userName?.toLowerCase()||"";return a.localeCompare(s)}),f){const t=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,f]),w=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},N=1===u.length,y=u.length>0;return e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl",variant:"form",children:[e.jsx(is,{showSeparator:!0,children:e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(ls,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{placeholder:"Pesquisar...",value:f,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(vr,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-16 w-full"},a))}):0===v.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:v.map(t=>{const a=t.userId===d,s=c.includes(t.userId||""),r=u.includes(t.userId||"");return e.jsxs("div",{className:Ta("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e.jsx(Ps,{checked:r,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:t.userName}),a&&e.jsx(l.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})})]}),e.jsxs(ds,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&e.jsxs("span",{children:[u.length," selecionado(s)"]})}),N&&o&&e.jsxs(Pa,{onClick:async()=>{if(o&&1===u.length){h(!0);try{await o(u[0],r),m([])}finally{h(!1)}}},disabled:p,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),y&&i&&e.jsxs(Pa,{onClick:async()=>{if(i&&0!==u.length){h(!0);try{await i(u,r),m([])}finally{h(!1)}}},disabled:p,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function fc({place:a,level:s=0,manageAccessConfig:r}){const[n,o]=t.useState(!1),[i,d]=t.useState(!1),c=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Wo,{open:n,onOpenChange:o,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(Go,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:Ta("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Ds,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(Ld,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>d(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx(Yo,{children:a.subPlaces.map(t=>e.jsx(fc,{place:t,level:s+1,manageAccessConfig:r},t.id))})]}),0===s&&e.jsx(Ba,{}),r&&e.jsx(hc,{open:i,onOpenChange:d,placeId:a.id,placeName:a.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(a.id),currentMemberIds:r.getCurrentMemberIds?.(a.id)})]})}const xc=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=t.get(e.id);if(e.parentId){const r=t.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):a.push(s)}else a.push(s)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function gc(e){const t=new Map,a=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};t.set(e.id,s),a.set(e.id_user,s)}),e.forEach(e=>{const r=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(r)}s.push(r)});const r=(e,t)=>{e.level=t,e.children.forEach(e=>r(e,t+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",s=t.name||t.id_user||t.email||"";return a.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function bc(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function vc(){const{alias:e,isAuthenticated:t}=Nn(),a=Dr.getAccessToken(),{data:s=[]}=vo({enabled:!0});return y.useQuery({queryKey:["leadership",e],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Ur(),{data:r,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!r||0===r.length)return[];const o={};s.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=r.map(e=>({...e,name:o[e.id_user]?.name||"[Não encontrado]",email:o[e.id_user]?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=o[e];i.push({id:`virtual-${e}`,alias:r[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e).length})}),gc(i)},enabled:!!a&&!!e&&t&&s.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const wc="common";function Nc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(t.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Sc(a,e,t.id_user,t.id_leader);const{data:r,error:n}=await a.schema(wc).from("leaders").insert({alias:e,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",e]}),i.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function yc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!t.users.length)throw new Error(s("select_at_least_one","Selecione pelo menos um liderado"));const r=t.users.map(e=>e.id_user),{data:n}=await a.schema(wc).from("leaders").select("id_user").eq("alias",e).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(s("users_already_leaders",`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(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Sc(a,e,d.id_user,t.id_leader)}const o=t.users.map(a=>({alias:e,id_user:a.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await a.schema(wc).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_added_success",`${a?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{i.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function jc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await a.schema(wc).from("leaders").select("id_user").eq("id",t.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Sc(a,e,r.id_user,t.id_leader,t.id);const{data:n,error:o}=await a.schema(wc).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Cc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await a.schema(wc).from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function kc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const n=r.map(e=>e.id_user),o=await Promise.all([a.schema(wc).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",t),a.schema(wc).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:i,error:l},{data:d,error:c}]=o;if(l)throw l;if(c)throw c;const u=i||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==t),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const s of f)await Sc(a,e,s.id_user,t,s.id);for(const w of g){if(w.id_user===t)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await Sc(a,e,w.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(a.schema(wc).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",e))}if(f.length){const s=f.map(e=>e.id);b.push(a.schema(wc).from("leaders").update({id_leader:t}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(a=>({alias:e,id_user:a.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(a.schema(wc).from("leaders").insert(s))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:f.length,created:g.length}},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${a.created} adicionados, ${a.updated} atualizados, ${a.unlinked} removidos)`))},onError:e=>{i.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function Sc(e,t,a,s,r){const{data:n,error:o}=await e.schema(wc).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const i=r?n.filter(e=>e.id!==r):n,l=new Set;let d=s;for(;d;){if(l.has(d))throw new Error("Esta associação criaria um ciclo na hierarquia");if(d===a)throw new Error("Esta associação criaria um ciclo na hierarquia");l.add(d);const e=i.find(e=>e.id_user===d);d=e?.id_leader||null}}function _c({leader:t,expandedIds:a,onToggleExpand:s,onEdit:r}){const n=a.has(t.id),o=t.children.length>0,i=32*t.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[o?e.jsx("button",{onClick:()=>s(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),o&&n&&t.children.map(t=>e.jsx(_c,{leader:t,expandedIds:a,onToggleExpand:s,onEdit:r},t.id))]})}var Tc=function(e,t){for(var a={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!a[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];a[o]={message:i.message,type:i.code}}else a[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[o].types,d=l&&l[s.code];a[o]=p.appendErrors(o,t,a,r,d?[].concat(d,s.message):s.message)}e.shift()}return a},Ac=function(e,t,a){return void 0===a&&(a={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](s,t)).then(function(e){return n.shouldUseNativeValidation&&X.validateFieldsNatively({},n),{errors:{},values:a.raw?s:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:X.toNestErrors(Tc(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Ec=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string()).min(1,"Selecione pelo menos um liderado")}),Pc=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string())});function Mc({value:a,onChange:s,excludeUserIds:r=[],error:n}){const{data:o=[],isLoading:i}=vo(),[d,c]=t.useState(""),u=t.useRef(null),m=t.useRef(0),p=o.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=d.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const s=a.includes(e.userId),r=a.includes(t.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",o=t.userName||t.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ia,{placeholder:"Buscar usuário...",value:d,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Buscar usuário..."}):e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ps,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?s(a.filter(t=>t!==e)):s([...a,e]));var e}}),e.jsx(Ra,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.length," selecionado(s)"]}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Ic({leader:a,prefilledLeaderId:s,onSuccess:r}){const{alias:n}=Nn(),o=!!a,i=a?.id.startsWith("virtual-"),d=yc(),c=Nc(),u=jc(),m=kc(),h=Cc(),{data:f=[]}=vc(),{data:x=[]}=vo(),[g,b]=t.useState(""),v=bc(f).map(e=>e.id_user),w=o?bc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],N=p.useForm({resolver:Ac(o?Pc:Ec),defaultValues:{id_leader:s||(o?a?.id_leader:null)||null,id_users:o?w:[]}});t.useEffect(()=>{if(a){const e=bc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);N.reset({id_leader:a.id_leader||null,id_users:e})}else s?N.reset({id_leader:s,id_users:[]}):N.reset({id_leader:null,id_users:[]})},[n,a?.id,a?.id_user,a?.id_leader,s,f]);const y=d.isPending||c.isPending||u.isPending||m.isPending||h.isPending,j=N.watch("id_leader"),C=N.watch("id_users"),k=o?[a.id_user,...v.filter(e=>e!==a.id_user&&!C.includes(e)&&!w.includes(e))]:[j,...v.filter(e=>!C.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:N.handleSubmit(async e=>{try{if(o)if(i){await c.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await u.mutateAsync({id:a.id,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await d.mutateAsync({id_leader:e.id_leader,users:t})}r?.()}catch(t){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Ra,{children:"Líder"}),e.jsx(Ia,{value:x.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Superior Imediato"}),e.jsxs(Ns,{value:j||"none",onValueChange:e=>N.setValue("id_leader","none"===e?null:e),children:[e.jsx(Cs,{children:e.jsx(js,{placeholder:"Selecione..."})}),e.jsxs(_s,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ia,{placeholder:"Buscar superior...",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(vr,{className:"h-[200px]",children:[e.jsx(As,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const t=o?e.userId!==a.id_user:!C.includes(e.userId),s=!g||e.userName?.toLowerCase().includes(g.toLowerCase());return t&&s}).sort((e,t)=>{const a=e.userName||e.userEmail||"",s=t.userName||t.userEmail||"";return a.localeCompare(s)}).map(t=>e.jsx(As,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${n}`),N.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:N.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Subordinados *"}),e.jsx(Mc,{value:C,onChange:e=>N.setValue("id_users",e),excludeUserIds:k,error:N.formState.errors.id_users?.message},`users-multiselect-${n}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Pa,{type:"submit",disabled:y||!o&&0===C.length,children:y&&!h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Atualizando...":"Salvando..."]}):o?"Atualizar":"Criar"}),o&&!j&&0===C.length&&e.jsxs($a,{children:[e.jsx(Ha,{asChild:!0,children:e.jsx(Pa,{type:"button",variant:"destructive",disabled:y,className:"ml-auto",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:"Confirmar remoção"}),e.jsx(Xa,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{children:"Cancelar"}),e.jsx(Za,{onClick:async()=>{if(a)try{await h.mutateAsync(a.id),r?.()}catch(e){}},children:"Remover"})]})]})]})]})]})}function Dc({open:t,onOpenChange:a,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{variant:"form",className:"sm:max-w-[500px]",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:n})}),e.jsx(ls,{children:e.jsx(Ic,{leader:s,prefilledLeaderId:r,onSuccess:()=>a(!1)})})]})})}const Rc="leadership-expanded-nodes",Lc=(e,t)=>{try{localStorage.setItem(`${Rc}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function zc(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:l,onError:d}=e||{};return{upload:async(e,t)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const a={...o,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){const t=a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t);if(!t)throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const s=await r(e,a);return i.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),l?.(s),s}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,t)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,t),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a}}function Fc(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function Uc(e,t){const a=Fc(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function qc(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function Oc(e,t){const a=qc(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function Bc(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function $c(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Hc(e,t){return e/t}function Vc(){const{alias:e}=Nn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let t=!1;return(async()=>{n(!0);try{const a=Ur(),{data:r,error:n}=await a.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();t||s(r)}catch(a){t||s(null)}finally{t||n(!1)}})(),()=>{t=!0}},[e]);const o=t.useCallback(async(t,a)=>{if(!e)throw new Error("Alias not available");const r=Ur(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:t,environment:a,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e]);return{config:a,isLoading:r,saveConfig:o}}const Wc=(void 0).VITE_SUPABASE_URL,Gc=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function Yc(e,t,a){const s=Dr.getSupabaseToken(),r={"Content-Type":"application/json",apikey:Gc};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${Wc}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:t,data:a})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const Qc={async createEnvelopeWithSigner(e){const t="d4sign"===e.provider?"d4sign":"clicksign",a="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await Yc(t,a,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const t="d4sign"===e.provider?"d4sign":"clicksign";return(await Yc(t,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let Kc=null;function Xc(){return window.Clicksign?Promise.resolve():Kc||(Kc=new Promise((e,t)=>{const a=document.createElement("script");a.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",a.onload=()=>e(),a.onerror=()=>t(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(a)}),Kc)}const Zc="clicksign-container";function Jc({signerId:a,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const i=t.useRef(null),[d,c]=t.useState(!0),[u,m]=t.useState(null);return t.useEffect(()=>{let e=!1;return i.current&&(i.current.unmount(),i.current=null),m(null),c(!0),Xc().then(()=>{if(e)return;const t=new window.Clicksign(a);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(Zc),t.on("loaded",function(){c(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const t=e,a=document.getElementById(Zc);a&&t?.data?.height&&(a.style.height=t.data.height+"px")}),t.on("error",function(e){c(!1),n?.(e instanceof Error?e:new Error("Erro no widget de assinatura"))}),t.on("closed",function(){o?.()}),i.current=t}).catch(t=>{e||(m("Falha ao carregar o script de assinatura."),c(!1),n?.(t))}),()=>{e=!0,i.current&&(i.current.unmount(),i.current=null)}},[a,s]),e.jsxs("div",{className:"relative h-full",children:[d&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-destructive",children:u})}),e.jsx("div",{id:Zc,style:{height:"600px"}})]})}function eu({documentKey:a,signerEmail:s,signerName:r,keySigner:n,environment:o,onSign:i,onError:d}){const c=t.useRef(null),[u,m]=t.useState("loading"),[p,h]=t.useState(null),f="production"===o?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",x=(()=>{const e=new URLSearchParams({email:s,display_name:r||"",disable_preview:"0"});return n&&e.set("key_signer",n),`${f}/${a}?${e.toString()}`})(),g=t.useCallback(e=>"signed"===e.data?(m("ready"),void i?.()):"wrong-data"===e.data?(m("error"),h("O signatário reportou dados incorretos."),void d?.(new Error("O signatário reportou dados incorretos"))):void 0,[i,d]);t.useEffect(()=>(window.addEventListener("message",g,!1),()=>{window.removeEventListener("message",g,!1)}),[g]);const b=t.useCallback(()=>{"loading"===u&&m("ready")},[u]);return"error"===u?e.jsxs(Do,{variant:"danger",className:"my-4",children:[e.jsx(Ro,{children:"Erro ao carregar documento"}),e.jsx(Lo,{children:p||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):e.jsxs("div",{className:"relative h-full",children:["loading"===u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("iframe",{ref:c,id:"d4sign-container",src:x,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return v.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return v.useTranslation}}),exports.i18n=T,exports.AUTH_CONFIG=Qr,exports.Accordion=Ko,exports.AccordionContent=Jo,exports.AccordionItem=Xo,exports.AccordionTrigger=Zo,exports.ActionButton=Ma,exports.ActionMenu=Ld,exports.ActionMenuItems=eo,exports.Alert=Do,exports.AlertDescription=Lo,exports.AlertDialog=$a,exports.AlertDialogAction=Za,exports.AlertDialogCancel=Ja,exports.AlertDialogContent=Ga,exports.AlertDialogDescription=Xa,exports.AlertDialogFooter=Qa,exports.AlertDialogHeader=Ya,exports.AlertDialogOverlay=Wa,exports.AlertDialogPortal=Va,exports.AlertDialogTitle=Ka,exports.AlertDialogTrigger=Ha,exports.AlertTitle=Ro,exports.AppHeader=Hd,exports.AppLayout=uc,exports.AppSidebar=cc,exports.AuthErrorInterceptor=Br,exports.AuthProvider=wn,exports.AuthService=xn,exports.Avatar=ei,exports.AvatarFallback=ai,exports.AvatarImage=ti,exports.Badge=Ds,exports.BaseForm=No,exports.Blockquote=Wi,exports.BodyContent=function({breadcrumbs:t,children:a,className:s}){return e.jsxs("div",{className:Ta("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[t&&t.length>0&&e.jsx(si,{className:"mb-4",children:e.jsx(ri,{children:t.map((a,s)=>{const r=s===t.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(li,{}),e.jsx(ni,{children:r||!a.href?e.jsx(ii,{children:a.label}):a.asChild&&a.children?e.jsx(oi,{asChild:!0,children:a.children}):e.jsx(oi,{asChild:!0,children:e.jsx(j.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=si,exports.BreadcrumbEllipsis=di,exports.BreadcrumbItem=ni,exports.BreadcrumbLink=oi,exports.BreadcrumbList=ri,exports.BreadcrumbPage=ii,exports.BreadcrumbSeparator=li,exports.Button=Pa,exports.ButtonGroup=ui,exports.CRUD_CONFIG=Kr,exports.Calendar=mi,exports.CallbackPage=()=>{const{processCallback:a}=Nn(),s=j.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a,s]);const d=async()=>{i(!0),n(null);try{await a()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsxs(Fa,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(Do,{variant:"danger",children:e.jsx(Lo,{children:r})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pa,{onClick:d,disabled:o,className:"flex-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Pa,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(qa,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ls,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=La,exports.CardContent=qa,exports.CardDescription=Ua,exports.CardFooter=Oa,exports.CardHeader=za,exports.CardSkeleton=Dn,exports.CardTitle=Fa,exports.ChartContainer=jd,exports.ChartLegend=_d,exports.ChartLegendContent=Td,exports.ChartStyle=Cd,exports.ChartTooltip=kd,exports.ChartTooltipContent=Sd,exports.Checkbox=Ps,exports.Collapsible=Wo,exports.CollapsibleContent=Yo,exports.CollapsibleTrigger=Go,exports.ColorPicker=fo,exports.ComboTree=function({multiple:a=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:d,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:f,className:x,maxDisplayedBadges:g,popoverContainer:b,onOpen:w,onClose:N}){const{t:y}=v.useTranslation(),[j,C]=t.useState(!1),[k,S]=t.useState(""),[_,T]=t.useState(new Set),A=o||y("select_placeholder","Selecione..."),E=c||y("no_results","Nenhum resultado encontrado"),P=u||y("search_placeholder","Pesquisar..."),M=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=t.useMemo(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),D=t.useMemo(()=>yr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,t){const a=new Set,s=Nr(t);function r(e){if(!e.children||0===e.children.length)return Nr(e.label).includes(s);let t=!1;for(const a of e.children)r(a)&&(t=!0);return t&&a.add(e.value),t||Nr(e.label).includes(s)}for(const n of e)r(n);return a}(s,k):new Set,[s,k]),L=k?R:_,z=t.useCallback(e=>{k||T(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[k]),F=t.useMemo(()=>M.map(e=>({value:e,label:jr(s,e)||e})),[M,s]),U=e=>{C(e),e?w?.():(S(""),N?.())},q=t.useCallback(e=>{if(n)if(a){const t=M.includes(e)?M.filter(t=>t!==e):[...M,e];n(t)}else n(e),C(!1)},[n,a,M]),O=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?M.filter(t=>t!==e):"")},B=g?F.slice(0,g):F,$=g&&F.length>g?F.length-g:0;if(h)return e.jsxs("div",{className:Ta("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const H="string"==typeof f?f:f instanceof Error?f.message:f?y("error_loading","Erro ao carregar"):void 0;return H?e.jsxs("div",{className:Ta("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:H})]})]}):e.jsxs("div",{className:Ta("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:j,onOpenChange:U,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":j,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),U(!j))},className:Ta("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",m&&"pointer-events-none opacity-50 cursor-not-allowed",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),A]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[B.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&O(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>O(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),$>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",$]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":j,disabled:m,className:Ta("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),A]}):e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),F[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(l.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("input",{className:"flex h-10 w-full bg-transparent py-3 px-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",placeholder:P,value:k,onChange:e=>S(e.target.value)}),k&&e.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(vr,{className:"max-h-[300px]",children:e.jsx("div",{role:"tree",className:"p-1",children:0===D.length?e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:y("no_search_results","Nenhum resultado encontrado")}):e.jsx(kr,{nodes:D,level:0,expandedIds:L,onToggleExpand:z,selectedValues:M,onSelect:q})})})]})]})]})},exports.Combobox=br,exports.Command=ir,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(ir,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})}),exports.CommandEmpty=cr,exports.CommandGroup=ur,exports.CommandInput=lr,exports.CommandItem=pr,exports.CommandList=dr,exports.CommandSeparator=mr,exports.CommandShortcut=hr,exports.ContentContainer=function({title:t,subtitle:a,children:s,className:r,hasHeader:n=!0}){const o=t||a;return e.jsxs("div",{className:Ta("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&o&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[t&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:t}),a&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),s&&e.jsx("div",{className:Ta("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Un,exports.ContextMenuCheckboxItem=Qn,exports.ContextMenuContent=Gn,exports.ContextMenuGroup=On,exports.ContextMenuItem=Yn,exports.ContextMenuLabel=Xn,exports.ContextMenuPortal=Bn,exports.ContextMenuRadioGroup=Hn,exports.ContextMenuRadioItem=Kn,exports.ContextMenuSeparator=Zn,exports.ContextMenuShortcut=Jn,exports.ContextMenuSub=$n,exports.ContextMenuSubContent=Wn,exports.ContextMenuSubTrigger=Vn,exports.ContextMenuTrigger=qn,exports.CoreProviders=function({children:a,queryClient:s}){const[r]=t.useState(()=>new y.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),n=s??r;return e.jsx(Qo,{children:e.jsx(v.I18nextProvider,{i18n:T,children:e.jsx(y.QueryClientProvider,{client:n,children:e.jsx(wn,{children:e.jsx(Ho,{children:a})})})})})},exports.CrudActionBar=co,exports.CrudGrid=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l,customRowActions:d,enableBulkActions:c=!1,onNew:u,newButtonLabel:m,showNewButton:p=!0,customActions:h=[],hideActionBar:f,showActionBar:x=!0,showSearch:g=!1,searchValue:b,onSearchChange:v,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:y,filters:j,gridColumns:C=3,renderCard:k,viewMode:S,onViewModeChange:_,listCardRenderer:T,gridCardRenderer:A,showViewToggle:E=!1})=>{const{setSearchVisible:P}=Nn(),M=void 0!==f?!f:x;t.useEffect(()=>{if(!g)return P(!0),()=>P(!1)},[P,g]);const I=u||h.length>0||g||c||j||E,D=y||(()=>{a.bulkDelete?.(a.selectedIds)}),R=S||"grid",L="list"===R,z={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[L?1:C],F=M&&I?e.jsx(co,{onNew:u,newButtonLabel:m,showNewButton:p,showSearch:g,searchValue:b,onSearchChange:v,searchPlaceholder:w,showBulkActions:c,selectedCount:a.selectedIds.length,bulkActions:N,onBulkDelete:D,onClearSelection:a.clearSelection,customActions:h,filters:j,viewMode:R,onViewModeChange:_,showViewToggle:E,availableViewModes:["list","grid"]}):null;return a.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(Dn,{count:6})})]}):0===a.entities.length?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Ta("grid gap-4",z),children:a.entities.map(t=>{const u=(e=>L&&T?T(e):!L&&A?A(e):k?k(e):null)(t);return e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:u?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:u}):e.jsx(La,{className:Ta("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",c&&a.selectedIds.includes(t.id)&&"bg-muted ring-2 ring-primary",L&&"flex-row"),onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:e.jsxs(qa,{className:Ta("p-4",L&&"flex items-center gap-4 w-full"),children:[c&&e.jsx("div",{className:Ta(L?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[c&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>e.jsxs("div",{className:Ta("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})]})]})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id)})})})]})},exports.CrudPageInternal=Ao,exports.CrudPagination=jo,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=v.useTranslation(),d=t||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i("search","Pesquisar"),value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:t},a)),n&&d&&r&&e.jsxs(Pa,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})},exports.CrudPrimitivePagination=yo,exports.CrudPrimitiveTable=function({data:a,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:d,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:w,storageKey:N}){const{t:y}=v.useTranslation(),j=u||y("no_items_found","Nenhum item encontrado"),{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:_}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:w,enabled:b}),T=t.useMemo(()=>{if(b)return s.map(e=>`${C[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return s.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[s,b,C]);return c?e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-12 w-full"},a))})}):0===a.length?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:j})})}):e.jsx("div",{className:"flex-1 overflow-auto "+(k?"select-none":""),children:e.jsxs(kn,{className:m,children:[e.jsx(Sn,{className:"sticky top-0 bg-background z-10",children:e.jsxs(An,{children:[p&&e.jsx(En,{className:"w-[40px]",children:e.jsx(Ps,{checked:g,onCheckedChange:x,"aria-label":y("select_all","Selecionar todos")})}),s.map((t,a)=>{const s=b&&!1!==t.resizable,i=S===String(t.key);return e.jsxs(En,{className:`${t.className||""} relative`,style:{width:T[a]},children:[t.sortable&&o?e.jsxs("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(d=String(t.key),r!==d?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>_(String(t.key),e),isDragging:i})]},String(t.key));var d}),d&&e.jsx(En,{className:"w-[80px] text-right",children:y("actions","Ações")})]})}),e.jsx(_n,{children:a.map(t=>e.jsxs(An,{onClick:()=>i?.(t),className:(i?"cursor-pointer":"")+" relative",children:[p&&e.jsx(Pn,{children:e.jsx(Ps,{checked:h.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`${y("select_all","Selecionar todos")} ${t.id}`})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),d&&e.jsx(Pn,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(t)})]},t.id))})]})})},exports.CrudTable=mo,exports.D4SignWidget=eu,exports.DATETIME_FORMATS=ha,exports.DEFAULT_DATETIME_FORMAT=ga,exports.DEFAULT_LOCALE=xa,exports.DEFAULT_TIMEZONE=ba,exports.DataList=pi,exports.DatePicker=function({date:t,onDateChange:a,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:i}){return e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",disabled:r,className:Ta("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),t?o.format(t,"d 'de' MMMM 'de' yyyy",{locale:ma}):e.jsx("span",{children:s})]})}),e.jsx(or,{className:"w-auto p-0",align:"start",children:e.jsx(mi,{mode:"single",selected:t,onSelect:a,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=es,exports.DialogBody=ls,exports.DialogClose=ss,exports.DialogContent=os,exports.DialogDescription=us,exports.DialogFooter=ds,exports.DialogHeader=is,exports.DialogOverlay=rs,exports.DialogPortal=as,exports.DialogTitle=cs,exports.DialogTrigger=ts,exports.DisabledMenuItem=sr,exports.DocumentSigner=function({file:a,onDocumentSigned:s,onError:r,showEventLog:n=!1}){const{user:o,alias:d}=Nn(),{config:c,isLoading:u}=Vc(),{t:m}=v.useTranslation(),[p,h]=t.useState(null),[f,x]=t.useState(!1),[g,b]=t.useState(null),[w,N]=t.useState("sandbox"),[y,j]=t.useState("clicksign"),[C,k]=t.useState(null),[S,_]=t.useState(null),[T,A]=t.useState(!1),[E,P]=t.useState(0),[M,I]=t.useState(!1),[D,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),F=t.useCallback(e=>{n&&R(t=>[...t,`[${(new Date).toLocaleTimeString()}] ${e}`])},[n]),U=t.useCallback(async e=>{if(h(e),b(null),k(null),_(null),F(`Arquivo selecionado: ${e.name}`),d&&o){x(!0);try{const t=c?.provider??"clicksign";j(t),F(`Provedor resolvido: ${t}`);const a=new FileReader,s=await new Promise((t,s)=>{a.onload=()=>{const e=a.result;t(e)},a.onerror=s,a.readAsDataURL(e)});F(`Criando envelope para assinatura via ${t}...`);const n=await Qc.createEnvelopeWithSigner({alias:d,contentBase64:s,filename:e.name,signerEmail:o.email||"",signerName:o.name||"",provider:t});F(`Envelope criado: ${n.envelope_id}`),k({envelope_id:n.envelope_id,document_id:n.document_id,signer_email:n.signer_email,key_signer:n.signer_id}),N(n.environment),j(n.provider||t),"d4sign"===t?(F("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(n.document_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):n.signer_id?(F(`Signer ID obtido: ${n.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(n.signer_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):(F("AVISO: Nenhum signer ID disponível."),i.toast.error(m("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),r?.(new Error("Signer ID não disponível")))}catch(t){const e=t instanceof Error?t:new Error(m("sign_process_error","Erro ao processar documento")),a=e.message||"";a.includes("MONTHLY_LIMIT_REACHED")?(F("Limite mensal de assinaturas atingido"),i.toast.error(m("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(F(`Erro: ${a}`),i.toast.error(a)),r?.(e)}finally{x(!1)}}},[d,o,F,r,c]);t.useEffect(()=>{a&&d&&o&&!u&&a!==z.current&&(z.current=a,U(a))},[a,d,o,u,U]);const q=t.useCallback(async()=>{if(!C||!d)return;A(!0),P(0),I(!1),F("Buscando documento assinado...");for(let t=1;t<=6;t++){P(t),F(`Tentativa ${t}/6...`);try{const e=await Qc.getSignedDocument({alias:d,envelopeId:C.envelope_id,documentId:C.document_id,provider:y});if(e.download_url)return F("Documento assinado disponível para download"),_(e.download_url),void A(!1)}catch(e){F(`Erro na tentativa ${t}: ${e instanceof Error?e.message:"Erro desconhecido"}`)}t<6&&(F("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}F("Não foi possível obter o documento assinado após 6 tentativas."),A(!1),I(!0)},[C,d,F,y]),O=t.useCallback(async()=>{F("Documento assinado com sucesso!"),i.toast.success(m("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&d&&(s?.({success:!0,provider:y,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:g||"",environment:w}),await q())},[F,s,C,g,d,w,y,q]);if(!d)return e.jsx(La,{className:"border-amber-200 bg-amber-50",children:e.jsx(qa,{className:"flex items-start gap-3 py-6",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800",children:m("sign_auth_required","Autenticação necessária")}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:m("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const B="d4sign"===y?"D4Sign":"Clicksign",$=()=>n&&D.length>0?e.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:D.map((t,a)=>e.jsx("div",{children:t},a))}):null;return C&&!g&&(S||T||M)?e.jsxs("div",{className:"space-y-4",children:[e.jsx(La,{className:"border-green-200 bg-green-50",children:e.jsxs(qa,{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(l.CheckCircle2,{className:"h-12 w-12 text-green-600"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-green-800",children:m("sign_signed_success","Documento assinado com sucesso!")}),e.jsx("p",{className:"text-sm text-green-700 mt-1",children:p?.name})]}),T?e.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),m("sign_preparing_doc","Preparando documento assinado...")," (",m("sign_attempt","tentativa")," ",E,"/6)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_waiting_provider",`Aguardando processamento pelo ${B}...`)})]}):S?e.jsx(Pa,{asChild:!0,variant:"default",className:"gap-2",children:e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.Download,{className:"h-4 w-4"}),m("sign_download_signed","Baixar documento assinado")]})}):M?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),e.jsxs(Pa,{variant:"secondary",className:"gap-2",onClick:q,children:[e.jsx(l.RefreshCw,{className:"h-4 w-4"}),m("sign_try_again","Tentar novamente")]})]}):null]})}),e.jsx($,{})]}):g?e.jsxs("div",{className:"space-y-4",children:["d4sign"===y?e.jsx(eu,{documentKey:g,signerEmail:C?.signer_email||o?.email||"",signerName:o?.name,keySigner:C?.key_signer,environment:w,onSign:O,onError:r}):e.jsx(Jc,{signerId:g,environment:w,onSign:O,onError:r}),e.jsx($,{})]}):a&&(f||u)?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&"application/pdf"===t.type?U(t):i.toast.error(m("sign_select_pdf","Selecione um arquivo PDF"))}}),f?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsx(La,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:e.jsxs(qa,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(l.Upload,{className:"h-8 w-8 text-muted-foreground"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:m("sign_select_pdf","Selecione um arquivo PDF")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),e.jsx($,{})]})},exports.Drawer=hi,exports.DrawerClose=gi,exports.DrawerContent=vi,exports.DrawerDescription=ji,exports.DrawerFooter=Ni,exports.DrawerHeader=wi,exports.DrawerOverlay=bi,exports.DrawerPortal=xi,exports.DrawerTitle=yi,exports.DrawerTrigger=fi,exports.DropdownMenu=Fs,exports.DropdownMenuCheckboxItem=Ys,exports.DropdownMenuContent=Ws,exports.DropdownMenuGroup=qs,exports.DropdownMenuItem=Gs,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=Os,exports.DropdownMenuRadioGroup=$s,exports.DropdownMenuRadioItem=Qs,exports.DropdownMenuSeparator=Xs,exports.DropdownMenuShortcut=Zs,exports.DropdownMenuSub=Bs,exports.DropdownMenuSubContent=Vs,exports.DropdownMenuSubTrigger=Hs,exports.DropdownMenuTrigger=Us,exports.EmailService=mc,exports.EmptyState=Ln,exports.EntitySelect=br,exports.ErrorBoundary=Qo,exports.FilterBar=To,exports.Form=ms,exports.FormControl=bs,exports.FormDescription=vs,exports.FormField=({...t})=>e.jsx(ps.Provider,{value:{name:t.name},children:e.jsx(p.Controller,{...t})}),exports.FormItem=xs,exports.FormLabel=gs,exports.FormMessage=ws,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-4 w-24"}),e.jsx(fr,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(fr,{className:"h-10 w-20"}),e.jsx(fr,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:t,cols:a="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Ta("grid",Ci[a],ki[s],r),children:t})},exports.H1=Li,exports.H2=zi,exports.H3=Fi,exports.H4=Ui,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(fr,{className:"h-8 w-8 rounded-full"}),e.jsx(fr,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fr,{className:"h-8 w-8"}),e.jsx(fr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Si,exports.HoverCardContent=Ti,exports.HoverCardTrigger=_i,exports.IconPicker=go,exports.ImageEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{alignment:"center",allowDownload:!1}),p=t.useRef(null),{upload:h,uploading:f}=zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:u.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await h(t),a={...u,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),u.imageFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",u.imageFile," (",Math.round((u.imageSize||0)/1024)," KB)"]})]}),u.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===u.alignment?"justify-start":"right"===u.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:u.imageUrl,alt:u.alt||"Preview",style:{width:u.width?`${u.width}px`:"auto",height:u.height?`${u.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"caption",children:"Legenda"}),e.jsx(Ms,{id:"caption",placeholder:"Legenda",value:u.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"alt",children:"Texto Alternativo"}),e.jsx(Ia,{id:"alt",placeholder:"Texto Alternativo",value:u.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Alinhamento"}),e.jsxs(Ns,{value:u.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(As,{value:"left",children:"Esquerda"}),e.jsx(As,{value:"center",children:"Centro"}),e.jsx(As,{value:"right",children:"Direita"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"width",children:"Largura"}),e.jsx(Ia,{id:"width",type:"number",placeholder:"px",value:u.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"height",children:"Altura"}),e.jsx(Ia,{id:"height",type:"number",placeholder:"px",value:u.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"allowDownload",checked:u.allowDownload||!1,onCheckedChange:e=>x("allowDownload",!0===e)}),e.jsx(Ra,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.imageUrl?r(u):i.toast.error("Erro",{description:"Nenhuma imagem selecionada"})},disabled:!u.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:s}){if(!t.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${a}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Vi,exports.Input=Ia,exports.InputGroup=Ai,exports.InputGroupAddon=Pi,exports.InputGroupButton=Ii,exports.InputGroupInput=Di,exports.InputGroupTextarea=Ri,exports.LOGO_CONFIG=tn,exports.Label=Ra,exports.Large=Bi,exports.Lead=Oi,exports.LeaderRow=_c,exports.LeadershipDialog=Dc,exports.LeadershipForm=Ic,exports.LeadershipPage=function(){const{alias:a}=Nn(),{data:s,isLoading:r,error:n,refetch:o}=vc(),[i,d]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Rc}-${e}`);if(t)return new Set(JSON.parse(t))}catch(n){}return new Set})(a):new Set),[c,u]=t.useState(!1),[m,p]=t.useState(),[h,f]=t.useState(null),x=(s?bc(s):[]).filter(e=>"[Não encontrado]"!==e.name).length;t.useEffect(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${Rc}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);d(t),Lc(a,t)}}},[s,a]);const g=e=>{d(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),a&&Lc(a,s),s})},b=e=>{p(e),f(null),u(!0)};return r?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})}):n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(Pa,{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(Pa,{size:"sm",onClick:()=>{p(void 0),f(null),u(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=bc(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);d(t),a&&Lc(a,t)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;d(e),a&&Lc(a,e)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(vr,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsx(_c,{leader:t,expandedIds:i,onToggleExpand:g,onEdit:b},t.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(Dc,{open:c,onOpenChange:()=>{u(!1),p(void 0),f(null)},leader:m,prefilledLeaderId:h,title:m?"Editar Nome":h?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=Gi,exports.LoadingState=function({isLoading:t,children:a,className:s,type:r="spinner",size:n="md"}){return t?"overlay"===r?e.jsxs("div",{className:Ta("relative",s),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ls,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Ta("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Ta("flex items-center justify-center py-8",s),children:e.jsx(Ls,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Ho,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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(qa,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Pa,{onClick:async()=>{Zr()?await xn.loginDev():xn.loginProd()},className:"w-full",size:"lg",children:Zr()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=an,exports.MODULES_DATA=Yd,exports.ManageAccessModal=hc,exports.Menubar=dd,exports.MenubarCheckboxItem=fd,exports.MenubarContent=pd,exports.MenubarGroup=nd,exports.MenubarItem=hd,exports.MenubarLabel=gd,exports.MenubarMenu=rd,exports.MenubarPortal=od,exports.MenubarRadioGroup=ld,exports.MenubarRadioItem=xd,exports.MenubarSeparator=bd,exports.MenubarShortcut=vd,exports.MenubarSub=id,exports.MenubarSubContent=md,exports.MenubarSubTrigger=ud,exports.MenubarTrigger=cd,exports.ModalStateProvider=function({children:a}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.delete(e),a})},[]),d=t.useCallback(e=>{o(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:i,unregisterModal:l,setHasOpenModal:d}),[s,c,i,l,d]);return e.jsx(lc.Provider,{value:u,children:a})},exports.ModuleGrid=Xd,exports.ModulesDialog=Zd,exports.MultiSelect=br,exports.Muted=Hi,exports.NavigationMenu=Yi,exports.NavigationMenuContent=Ji,exports.NavigationMenuIndicator=al,exports.NavigationMenuItem=Ki,exports.NavigationMenuLink=el,exports.NavigationMenuList=Qi,exports.NavigationMenuTrigger=Zi,exports.NavigationMenuViewport=tl,exports.NavigationProvider=qd,exports.OnboardingDialog=Rd,exports.P=qi,exports.PROD_PROJECT_ID=Hr,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:s}){const r=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(si,{className:s,children:e.jsx(ri,{children:r.map((t,a)=>{const s=0===a,r=n&&1===a;return e.jsxs(ni,{children:[!s&&e.jsx(li,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(di,{}),e.jsx(li,{})]}),t.isCurrentPage?e.jsx(ii,{children:t.label}):e.jsx(oi,{asChild:!0,children:e.jsx(j.Link,{to:t.href||"/",children:t.label})})]},t.label)})})})},exports.PageMetadataProvider=Fo,exports.Pagination=sl,exports.PaginationContent=rl,exports.PaginationEllipsis=dl,exports.PaginationItem=nl,exports.PaginationLink=ol,exports.PaginationNext=ll,exports.PaginationPrevious=il,exports.PlaceCard=fc,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:s}){return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(fc,{place:t,manageAccessConfig:s},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(l.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=rr,exports.PopoverContent=or,exports.PopoverTrigger=nr,exports.Progress=cl,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:s,isLoading:r}=Nn();if(t.useEffect(()=>{if(r)return;if(s)return;if(Dr.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const n=Zr(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{n?await xn.loginDev():xn.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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(qa,{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:Zr()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=en,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=cn,exports.QualiexErrorInterceptor=$r,exports.QualiexUserField=wo,exports.RadioGroup=ul,exports.RadioGroupItem=ml,exports.ResizableHandle=({withHandle:t,className:a,...s})=>e.jsx(Ne.PanelResizeHandle,{className:Ta("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...s,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(l.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=pl,exports.ResizablePanelGroup=({className:t,...a})=>e.jsx(Ne.PanelGroup,{className:Ta("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),exports.RichTextEditor=({value:a,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:o="300px",showModeToggle:i=!0,showVariableHint:d=!0,className:c})=>{const[u,m]=t.useState("visual"),p=$.useEditor({extensions:[H.configure({heading:{levels:[1,2,3]}}),V,W.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:a||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.useEffect(()=>{p&&a!==p.getHTML()&&p.commands.setContent(a||"")},[a,p]);const h=t.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?p.chain().focus().extendMarkRange("link").setLink({href:t}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Ta("space-y-2",c),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Pa,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),d&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||p?.commands.focus()},children:[e.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(Ed,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(Pd,{}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Pd,{}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Pd,{}),e.jsx(Ed,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(Pd,{}),e.jsx(Ed,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Pd,{}),e.jsx(Ed,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(Ed,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx($.EditorContent,{editor:p,className:Ta("prose prose-sm max-w-none focus:outline-none","[&_.ProseMirror]:p-4","[&_.ProseMirror]:min-h-full","[&_.ProseMirror]:cursor-text","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:o}})]}),"code"===u&&e.jsx("textarea",{value:a||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Xr,exports.SUPPORTED_LOCALES=pa,exports.ScrollArea=vr,exports.ScrollBar=wr,exports.Select=Ns,exports.SelectContent=_s,exports.SelectGroup=ys,exports.SelectItem=As,exports.SelectLabel=Ts,exports.SelectScrollDownButton=Ss,exports.SelectScrollUpButton=ks,exports.SelectSearch=br,exports.SelectSeparator=Es,exports.SelectTrigger=Cs,exports.SelectValue=js,exports.Separator=Ba,exports.Sheet=hl,exports.SheetBody=yl,exports.SheetClose=xl,exports.SheetContent=wl,exports.SheetDescription=kl,exports.SheetFooter=jl,exports.SheetHeader=Nl,exports.SheetOverlay=bl,exports.SheetPortal=gl,exports.SheetTitle=Cl,exports.SheetTrigger=fl,exports.Sidebar=El,exports.SidebarActionTrigger=rc,exports.SidebarContent=Fl,exports.SidebarFooter=Ll,exports.SidebarGroup=Ul,exports.SidebarGroupAction=Ol,exports.SidebarGroupContent=Bl,exports.SidebarGroupLabel=ql,exports.SidebarHeader=sc,exports.SidebarInput=Dl,exports.SidebarInset=Il,exports.SidebarMenu=$l,exports.SidebarMenuAction=Gl,exports.SidebarMenuBadge=Yl,exports.SidebarMenuButton=Wl,exports.SidebarMenuItem=Hl,exports.SidebarMenuSkeleton=Ql,exports.SidebarMenuSub=Kl,exports.SidebarMenuSubButton=Zl,exports.SidebarMenuSubItem=Xl,exports.SidebarProvider=Al,exports.SidebarRail=Ml,exports.SidebarSeparator=zl,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(fr,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(fr,{className:"h-4 w-4"}),e.jsx(fr,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=Pl,exports.SignConfigForm=function({onSaved:a}){const{config:s,isLoading:r,saveConfig:n}=Vc(),{t:o}=v.useTranslation(),[d,c]=t.useState(""),[u,m]=t.useState("sandbox"),[p,h]=t.useState(!1);return t.useEffect(()=>{!r&&s&&(c(s.api_key),m(s.environment))},[s,r]),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[e.jsx(l.CheckCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_configured","Assinatura digital configurada para esta unidade")})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_not_configured","Assinatura digital ainda não configurada para esta unidade")})]}),e.jsxs(La,{children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-base",children:o("sign_config_title","Configuração de Assinatura Digital")})}),e.jsx(qa,{children:e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),d.trim()){h(!0);try{await n(d.trim(),u),i.toast.success(o("sign_config_saved","Configuração de assinatura salva com sucesso")),a?.()}catch(t){i.toast.error(o("sign_config_save_error","Erro ao salvar configuração de assinatura"))}finally{h(!1)}}else i.toast.error(o("sign_api_key_required","Informe a API Key do provedor de assinatura"))},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"sign-api-key",children:"API Key"}),e.jsx(Ia,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder","Insira a API Key do provedor de assinatura"),value:d,onChange:e=>c(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:o("sign_environment","Ambiente")}),e.jsxs(Ns,{value:u,onValueChange:e=>m(e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(As,{value:"sandbox",children:"Sandbox (Testes)"}),e.jsx(As,{value:"production",children:"Produção"})]})]})]}),e.jsxs(Pa,{type:"submit",disabled:p,children:[p&&e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config","Atualizar Configuração"):o("sign_save_config","Salvar Configuração")]})]})})]})]})},exports.SignWidget=Jc,exports.Skeleton=fr,exports.Slider=Jl,exports.Small=$i,exports.SonnerToaster=zs,exports.Spinner=Ls,exports.SplitButton=function({label:t,onClick:a,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:d=!1,menuAlign:c="end",className:u}){const m=i||d;return r.length>0?e.jsxs("div",{className:Ta("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:n,size:o,disabled:m,className:Ta("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Ws,{align:c,className:"min-w-[160px]",children:r.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:Ta("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]}):e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:u,children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]})},exports.Stack=_o,exports.StepSelector=function({currentStep:t,totalSteps:a,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){const d=Array.from({length:a},(e,t)=>t+1),c=e=>!(e<=t)&&(!!n&&!n(e));return e.jsxs("div",{className:Ta("flex items-center gap-3",o),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",t,"/",a,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:d.map(a=>e.jsxs(Gs,{onClick:()=>{var e;(e=a)<t?s(e):n&&!n(e)||s(e)},disabled:c(a),className:Ta("cursor-pointer",a===t&&"bg-muted font-medium",c(a)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),r?.[a-1]||`Etapa ${a}`,a===t&&e.jsx(l.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),e.jsx(cl,{value:t/a*100,className:Ta("h-2",i)})]})},exports.Switch=bo,exports.TIMEZONES=fa,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:Ta("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:s,className:r}){return e.jsxs("div",{className:Ta("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(Ba,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:Ta("flex flex-col h-full",a),children:e.jsx(vr,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=kn,exports.TableBody=_n,exports.TableCaption=Mn,exports.TableCell=Pn,exports.TableFooter=Tn,exports.TableHead=En,exports.TableHeader=Sn,exports.TableResizeHandle=Fn,exports.TableRow=An,exports.TableRowActions=to,exports.TableSkeleton=In,exports.Tabs=ed,exports.TabsContent=sd,exports.TabsList=td,exports.TabsTrigger=ad,exports.Textarea=Ms,exports.Toaster=zs,exports.Toggle=no,exports.ToggleGroup=io,exports.ToggleGroupItem=lo,exports.TokenManager=Dr,exports.TokenService=Sr,exports.Tooltip=er,exports.TooltipContent=ar,exports.TooltipProvider=Js,exports.TooltipTrigger=tr,exports.TruncatedCell=zn,exports.VideoEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{inputType:"url",controls:!0}),p=t.useRef(null),h=t.useRef(null),{upload:f,uploading:x}=zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:b}=zc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),v=t.useMemo(()=>$c(u.videoUrl||Bc(u.embedCode)||""),[u.videoUrl,u.embedCode]),w=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Tipo de entrada"}),e.jsxs(Ns,{value:u.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(As,{value:"url",children:"URL"}),e.jsx(As,{value:"upload",children:"Upload de arquivo"}),e.jsx(As,{value:"embed",children:"Código embed"})]})]})]}),"upload"===u.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Arquivo"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...u,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:u.title||t.name.replace(/\.[^/.]+$/,"")};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),u.videoFile&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",u.videoFile," (",Math.round((u.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===u.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Código embed"}),e.jsx(Ms,{placeholder:"Cole o código embed aqui",value:u.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Thumbnail"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"URL da thumbnail",value:u.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...u,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};m(a),s(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),u.thumbnailFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",u.thumbnailFile]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"title",children:"Título"}),e.jsx(Ia,{id:"title",placeholder:"Título do vídeo",value:u.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"autoplay",checked:u.autoplay||!1,onCheckedChange:e=>w("autoplay",!0===e)}),e.jsx(Ra,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"controls",checked:!1!==u.controls,onCheckedChange:e=>w("controls",!0===e)}),e.jsx(Ra,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=u.videoUrl||Bc(u.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===v)return e.jsxs("video",{controls:!1!==u.controls,autoPlay:u.autoplay,poster:u.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const a="youtube"===v?Uc(t,u.autoplay):Oc(t,u.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:u.title||"Vídeo",src:a,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.videoUrl||u.embedCode?r(u):i.toast.error("Erro",{description:"Nenhum vídeo selecionado"})},disabled:!(u.videoUrl||u.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:s}){const r=t.videoUrl||Bc(t.embedCode)||"";if(!r)return null;const n=$c(r);return e.jsx(La,{className:`overflow-hidden my-4 ${a}`,style:s,children:e.jsxs(qa,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:t.title||"Vídeo",src:"youtube"===n?Uc(r,t.autoplay):Oc(r,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.assets=ec,exports.badgeVariants=Is,exports.buildHierarchy=gc,exports.buttonGroupVariants=ci,exports.buttonVariants=Ea,exports.calculateAspectRatio=Hc,exports.cn=Ta,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=t,l=a??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:o||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton,showNewButton:r.showNewButton,newButtonLabel:r.newButtonLabel,showSearch:r.showSearch,searchPlaceholder:r.searchPlaceholder,showActionBar:r.showActionBar};return e.jsx(Ao,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=zd({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=zd,exports.createService=pn,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=pn({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,s)=>yn({queryKey:e.tableName,service:t,entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.createTranslatedMessages=e=>({success:{created:t=>e("msg_created_success",`${t} criado com sucesso`).replace("{{entity}}",t),updated:t=>e("msg_updated_success",`${t} atualizado com sucesso`).replace("{{entity}}",t),deleted:t=>e("msg_deleted_success",`${t} removido com sucesso`).replace("{{entity}}",t)},error:{create:t=>e("msg_create_error",`Erro ao criar ${t}`).replace("{{entity}}",t),update:t=>e("msg_update_error",`Erro ao atualizar ${t}`).replace("{{entity}}",t),delete:t=>e("msg_delete_error",`Erro ao remover ${t}`).replace("{{entity}}",t),load:t=>e("msg_load_error",`Erro ao carregar ${t}`).replace("{{entity}}",t)}}),exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.deriveEmailField=nn,exports.deriveNameField=rn,exports.deriveUsernameField=on,exports.detectBrowserLocale=Na,exports.detectBrowserPreferences=()=>{const e=Na();return{locale:e,timezone:ya(),datetimeFormat:ja(e)}},exports.detectBrowserTimezone=ya,exports.detectVideoProvider=$c,exports.emailService=pc,exports.errorService=Rr,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractVimeoId=qc,exports.extractYouTubeId=Fc,exports.filterAndPromoteOrphans=function(e,t){const a=e.map(e=>({...e})),s=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let t=e.id_leader;for(;t&&s.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))},exports.findDatetimeFormat=e=>ha.find(t=>t.value===e),exports.findLocale=e=>pa.find(t=>t.value===e),exports.findTimezone=e=>fa.find(t=>t.value===e),exports.flattenTree=bc,exports.formatCurrency=(e,t="BRL",a="pt-BR")=>null==e?"":new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Sa,exports.formatDatetime=ka,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:Po(e),label:Po(e),...Eo(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.getEnvironmentConfig=Gr,exports.getQualiexApiUrl=Jr,exports.getSupabaseClient=Ur,exports.handleExternalLink=_a,exports.inferDatetimeFormat=ja,exports.inputGroupAddonVariants=Ei,exports.inputGroupButtonVariants=Mi,exports.isDevEnvironment=Zr,exports.isDevSupabaseProject=Yr,exports.isImageUrl=function(e){const t=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const a=new URL(e);return t.some(e=>a.pathname.toLowerCase().endsWith(e))}catch{const a=e.toLowerCase();return t.some(e=>a.endsWith(e))}},exports.isValidDatetimeFormat=e=>ha.some(t=>t.value===e),exports.isValidLocale=va,exports.isValidTimezone=wa,exports.loadClicksignScript=Xc,exports.logoSrc=tc,exports.navigationMenuTriggerStyle=Xi,exports.normalizeVideoUrl=function(e,t,a){switch(t||$c(e)){case"youtube":return Uc(e,a);case"vimeo":return Oc(e,a);default:return e}},exports.normalizeVimeoUrl=Oc,exports.normalizeYouTubeUrl=Uc,exports.parseIframeSrc=Bc,exports.placeService=xc,exports.qualiexApi=sn,exports.resizeKeepingAspect=function(e,t,a,s){const r=Hc(e,t);return a&&!s?{width:a,height:Math.round(a/r)}:s&&!a?{width:Math.round(s*r),height:s}:{width:e,height:t}},exports.resolveFieldMappings=ln,exports.resolvePageTitle=Bd,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new y.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.signService=Qc,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=ac,exports.toggleVariants=ro,exports.trimTextFields=Aa,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=Nn();return y.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=Ur(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!Br.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},exports.useAuth=Nn,exports.useBaseForm=po,exports.useColumnResize=so,exports.useCreateMultipleLeadersMutation=yc,exports.useCreateSingleLeaderMutation=Nc,exports.useCrud=yn,exports.useDebounce=$d,exports.useFormField=hs,exports.useHasOpenModal=function(){const{hasOpenModal:e}=dc();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Vo(),a=ga;return{formatDatetime:s=>ka(s,a,t,e),formatDate:a=>Sa(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useIsMobile=Cn,exports.useLeadershipApi=vc,exports.useLocale=Vo,exports.useMediaQuery=jn,exports.useMediaUpload=zc,exports.useModalState=dc,exports.useNavigation=Od,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=Uo(),r=t.useRef({});t.useEffect(()=>(r.current.title===e.title&&r.current.subtitle===e.subtitle||(r.current={title:e.title,subtitle:e.subtitle},a(e)),()=>s()),[e.title,e.subtitle,a,s])},exports.usePageMetadataContext=Uo,exports.usePageTitle=function(){const e=j.useLocation(),{navigation:t}=Od();return Bd(t,e.pathname)},exports.usePermissionQuery=Vd,exports.useQualiexUsers=vo,exports.useRemoveLeaderMutation=Cc,exports.useRouteBreadcrumbs=function(){const e=j.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useRowResize=function({rowIds:e,defaultHeight:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,d]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),f=t.useRef(0),x=t.useCallback(e=>l[e]??a,[l,a]),g=t.useCallback((e,t)=>{i&&(t.preventDefault(),t.stopPropagation(),u(!0),p(e),h.current=t.clientY,f.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(s,Math.min(r,f.current+t));d(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[c,m,s,r,n,o]),t.useEffect(()=>(c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[c]);const b=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}},exports.useSidebar=Tl,exports.useSidebarResize=ic,exports.useSignConfig=Vc,exports.useSyncSubordinatesMutation=kc,exports.useUpdateLeaderMutation=jc,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),f=a.length,x=0===i,g=i===f-1,b=a[i],v=f>1?(i+1)/f*100:100,w=t.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),N=t.useMemo(()=>w(),[w,d]),y=t.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=t.useCallback(e=>{c(t=>({...t,...e}))},[]),C=t.useCallback((e,t)=>{c(a=>({...a,[e]:t}))},[]),k=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),S=t.useCallback(async()=>{if(w()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[w,p,d,n]),_=t.useCallback(async()=>{w()&&!u&&(g?await S():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,S]),T=t.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),A=t.useCallback(e=>{e<0||e>=f||u||(e<=i||e===i+1)&&l(e)},[i,f,u]),E=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:d,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:p,next:_,back:T,goTo:A,canProceed:N,canGoBack:y,setData:j,updateField:C,reset:k,complete:S,setLoading:E,progress:v,stepIndex:i,totalSteps:f}};
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("@radix-ui/react-slot"),s=require("class-variance-authority"),r=require("clsx"),n=require("tailwind-merge"),o=require("date-fns"),i=require("sonner"),l=require("lucide-react"),d=require("@radix-ui/react-label"),c=require("@radix-ui/react-dialog"),u=require("@radix-ui/react-separator"),m=require("@radix-ui/react-alert-dialog"),p=require("react-hook-form"),h=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),x=require("@radix-ui/react-dropdown-menu"),g=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),v=require("react-i18next"),w=require("@radix-ui/react-scroll-area"),N=require("@supabase/supabase-js"),y=require("@tanstack/react-query"),j=require("react-router-dom"),C=require("@radix-ui/react-context-menu"),k=require("@radix-ui/react-toggle-group"),S=require("@radix-ui/react-toggle"),_=require("@radix-ui/react-switch"),A=require("i18next"),T=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),P=require("@radix-ui/react-progress"),M=require("@radix-ui/react-accordion"),I=require("@radix-ui/react-avatar"),D=require("react-day-picker"),R=require("vaul"),L=require("@radix-ui/react-hover-card"),z=require("@radix-ui/react-navigation-menu"),F=require("@radix-ui/react-radio-group"),U=require("react-resizable-panels"),q=require("@radix-ui/react-slider"),O=require("@radix-ui/react-menubar"),B=require("recharts"),$=require("@tiptap/react"),H=require("@tiptap/starter-kit"),V=require("@tiptap/extension-underline"),W=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),Q=require("@tiptap/extension-highlight"),K=require("zod"),X=require("@hookform/resolvers");function Z(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var J=Z(t),ee=Z(d),te=Z(c),ae=Z(u),se=Z(m),re=Z(h),ne=Z(f),oe=Z(x),ie=Z(g),le=Z(b),de=Z(w),ce=Z(C),ue=Z(k),me=Z(S),pe=Z(_),he=Z(T),fe=Z(E),xe=Z(P),ge=Z(M),be=Z(I),ve=Z(L),we=Z(z),Ne=Z(F),ye=Z(U),je=Z(q),Ce=Z(O),ke=Z(B);const Se={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"}};function _e(e){return(t={})=>{const a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}const Ae={date:_e({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:_e({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:_e({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Te={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Ee(e){return(t,a)=>{let s;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,r=a?.width?String(a.width):t;s=e.formattingValues[r]||e.formattingValues[t]}else{const t=e.defaultWidth,r=a?.width?String(a.width):e.defaultWidth;s=e.values[r]||e.values[t]}return s[e.argumentCallback?e.argumentCallback(t):t]}}const Pe={ordinalNumber:(e,t)=>{const a=Number(e),s=a%100;if(s>20||s<10)switch(s%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:Ee({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})};function Me(e){return(t,a={})=>{const s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=t.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a;return}(i,e=>e.test(o)):function(e,t){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=a.valueCallback?a.valueCallback(d):d;return{value:d,rest:t.slice(o.length)}}}function Ie(e){return(t,a={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],n=t.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=a.valueCallback?a.valueCallback(o):o;return{value:o,rest:t.slice(r.length)}}}const De={ordinalNumber:Ie({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},Re={code:"en-US",formatDistance:(e,t,a)=>{let s;const r=Se[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"in "+s:s+" ago":s},formatLong:Ae,formatRelative:(e,t,a,s)=>Te[e],localize:Pe,match:De,options:{weekStartsOn:0,firstWeekContainsDate:1}};let Le={};function ze(){return Le}const Fe=6048e5;function Ue(e){const t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new e.constructor(+e):"number"==typeof e||"[object Number]"===t||"string"==typeof e||"[object String]"===t?new Date(e):new Date(NaN)}function qe(e){const t=Ue(e);return t.setHours(0,0,0,0),t}function Oe(e){const t=Ue(e),a=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return a.setUTCFullYear(t.getFullYear()),+e-+a}function Be(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function $e(e){const t=Ue(e),a=function(e,t){const a=qe(e),s=qe(t),r=+a-Oe(a),n=+s-Oe(s);return Math.round((r-n)/864e5)}(t,function(e){const t=Ue(e),a=Be(e,0);return a.setFullYear(t.getFullYear(),0,1),a.setHours(0,0,0,0),a}(t));return a+1}function He(e,t){const a=ze(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,r=Ue(e),n=r.getDay(),o=(n<s?7:0)+n-s;return r.setDate(r.getDate()-o),r.setHours(0,0,0,0),r}function Ve(e){return He(e,{weekStartsOn:1})}function We(e){const t=Ue(e),a=t.getFullYear(),s=Be(e,0);s.setFullYear(a+1,0,4),s.setHours(0,0,0,0);const r=Ve(s),n=Be(e,0);n.setFullYear(a,0,4),n.setHours(0,0,0,0);const o=Ve(n);return t.getTime()>=r.getTime()?a+1:t.getTime()>=o.getTime()?a:a-1}function Ge(e){const t=Ue(e),a=+Ve(t)-+function(e){const t=We(e),a=Be(e,0);return a.setFullYear(t,0,4),a.setHours(0,0,0,0),Ve(a)}(t);return Math.round(a/Fe)+1}function Ye(e,t){const a=Ue(e),s=a.getFullYear(),r=ze(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=Be(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=He(o,t),l=Be(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=He(l,t);return a.getTime()>=i.getTime()?s+1:a.getTime()>=d.getTime()?s:s-1}function Qe(e,t){const a=Ue(e),s=+He(a,t)-+function(e,t){const a=ze(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,r=Ye(e,t),n=Be(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),He(n,t)}(a,t);return Math.round(s/Fe)+1}function Ke(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const Xe={y(e,t){const a=e.getFullYear(),s=a>0?a:1-a;return Ke("yy"===t?s%100:s,t.length)},M(e,t){const a=e.getMonth();return"M"===t?String(a+1):Ke(a+1,2)},d:(e,t)=>Ke(e.getDate(),t.length),a(e,t){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];default:return"am"===a?"a.m.":"p.m."}},h:(e,t)=>Ke(e.getHours()%12||12,t.length),H:(e,t)=>Ke(e.getHours(),t.length),m:(e,t)=>Ke(e.getMinutes(),t.length),s:(e,t)=>Ke(e.getSeconds(),t.length),S(e,t){const a=t.length,s=e.getMilliseconds();return Ke(Math.trunc(s*Math.pow(10,a-3)),t.length)}},Ze="midnight",Je="noon",et="morning",tt="afternoon",at="evening",st="night",rt={G:function(e,t,a){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"});case"GGGGG":return a.era(s,{width:"narrow"});default:return a.era(s,{width:"wide"})}},y:function(e,t,a){if("yo"===t){const t=e.getFullYear(),s=t>0?t:1-t;return a.ordinalNumber(s,{unit:"year"})}return Xe.y(e,t)},Y:function(e,t,a,s){const r=Ye(e,s),n=r>0?r:1-r;if("YY"===t){return Ke(n%100,2)}return"Yo"===t?a.ordinalNumber(n,{unit:"year"}):Ke(n,t.length)},R:function(e,t){return Ke(We(e),t.length)},u:function(e,t){return Ke(e.getFullYear(),t.length)},Q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return Ke(s,2);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});default:return a.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,a){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return Ke(s,2);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});default:return a.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,a){const s=e.getMonth();switch(t){case"M":case"MM":return Xe.M(e,t);case"Mo":return a.ordinalNumber(s+1,{unit:"month"});case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});default:return a.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,a){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return Ke(s+1,2);case"Lo":return a.ordinalNumber(s+1,{unit:"month"});case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});default:return a.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,a,s){const r=Qe(e,s);return"wo"===t?a.ordinalNumber(r,{unit:"week"}):Ke(r,t.length)},I:function(e,t,a){const s=Ge(e);return"Io"===t?a.ordinalNumber(s,{unit:"week"}):Ke(s,t.length)},d:function(e,t,a){return"do"===t?a.ordinalNumber(e.getDate(),{unit:"date"}):Xe.d(e,t)},D:function(e,t,a){const s=$e(e);return"Do"===t?a.ordinalNumber(s,{unit:"dayOfYear"}):Ke(s,t.length)},E:function(e,t,a){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(n);case"ee":return Ke(n,2);case"eo":return a.ordinalNumber(n,{unit:"day"});case"eee":return a.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"});default:return a.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,a,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(n);case"cc":return Ke(n,t.length);case"co":return a.ordinalNumber(n,{unit:"day"});case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"});default:return a.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,a){const s=e.getDay(),r=0===s?7:s;switch(t){case"i":return String(r);case"ii":return Ke(r,t.length);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return a.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return a.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return a.day(s,{width:"short",context:"formatting"});default:return a.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,a){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});default:return a.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,a){const s=e.getHours();let r;switch(r=12===s?Je:0===s?Ze:s/12>=1?"pm":"am",t){case"b":case"bb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,a){const s=e.getHours();let r;switch(r=s>=17?at:s>=12?tt:s>=4?et:st,t){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});default:return a.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,a){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),a.ordinalNumber(t,{unit:"hour"})}return Xe.h(e,t)},H:function(e,t,a){return"Ho"===t?a.ordinalNumber(e.getHours(),{unit:"hour"}):Xe.H(e,t)},K:function(e,t,a){const s=e.getHours()%12;return"Ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},k:function(e,t,a){let s=e.getHours();return 0===s&&(s=24),"ko"===t?a.ordinalNumber(s,{unit:"hour"}):Ke(s,t.length)},m:function(e,t,a){return"mo"===t?a.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xe.m(e,t)},s:function(e,t,a){return"so"===t?a.ordinalNumber(e.getSeconds(),{unit:"second"}):Xe.s(e,t)},S:function(e,t){return Xe.S(e,t)},X:function(e,t,a){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(t){case"X":return ot(s);case"XXXX":case"XX":return it(s);default:return it(s,":")}},x:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"x":return ot(s);case"xxxx":case"xx":return it(s);default:return it(s,":")}},O:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},z:function(e,t,a){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+nt(s,":");default:return"GMT"+it(s,":")}},t:function(e,t,a){return Ke(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,a){return Ke(e.getTime(),t.length)}};function nt(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?a+String(r):a+String(r)+t+Ke(n,2)}function ot(e,t){if(e%60==0){return(e>0?"-":"+")+Ke(Math.abs(e)/60,2)}return it(e,t)}function it(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+Ke(Math.trunc(s/60),2)+t+Ke(s%60,2)}const lt=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},dt=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},ct={p:dt,P:(e,t)=>{const a=e.match(/(P+)(p+)?/)||[],s=a[1],r=a[2];if(!r)return lt(e,t);let n;switch(s){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",lt(s,t)).replace("{{time}}",dt(r,t))}},ut=/^D+$/,mt=/^Y+$/,pt=["D","DD","YY","YYYY"];function ht(e){if(!function(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;const t=Ue(e);return!isNaN(Number(t))}const ft=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,xt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gt=/^'([^]*?)'?$/,bt=/''/g,vt=/[a-zA-Z]/;function wt(e,t,a){const s=ze(),r=a?.locale??s.locale??Re,n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=Ue(e);if(!ht(i))throw new RangeError("Invalid time value");let l=t.match(xt).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,ct[t])(e,r.formatLong)}return e}).join("").match(ft).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Nt(e)};if(rt[t])return{isToken:!0,value:e};if(t.match(vt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});r.localize.preprocessor&&(l=r.localize.preprocessor(i,l));const d={firstWeekContainsDate:n,weekStartsOn:o,locale:r};return l.map(s=>{if(!s.isToken)return s.value;const n=s.value;(!a?.useAdditionalWeekYearTokens&&function(e){return mt.test(e)}(n)||!a?.useAdditionalDayOfYearTokens&&function(e){return ut.test(e)}(n))&&function(e,t,a){const s=function(e,t,a){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${a}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,a);if(pt.includes(e))throw new RangeError(s)}(n,t,String(e));return(0,rt[n[0]])(i,n,r.localize,d)}).join("")}function Nt(e){const t=e.match(gt);return t?t[1].replace(bt,"'"):e}function yt(e,t,a){const s=o.getDefaultOptions(),r=function(e,t,a){return new Intl.DateTimeFormat(a?[a.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,a.timeZone,a.locale??s.locale);return"formatToParts"in r?function(e,t){const a=e.formatToParts(t);for(let s=a.length-1;s>=0;--s)if("timeZoneName"===a[s].type)return a[s].value;return}(r,t):function(e,t){const a=e.format(t).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(a);return s?s[0].substr(1):""}(r,t)}function jt(e,t){const a=function(e){kt[e]||(kt[e]=_t?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}));return kt[e]}(t);return"formatToParts"in a?function(e,t){try{const a=e.formatToParts(t),s=[];for(let e=0;e<a.length;e++){const t=Ct[a[e].type];void 0!==t&&(s[t]=parseInt(a[e].value,10))}return s}catch(a){if(a instanceof RangeError)return[NaN];throw a}}(a,e):function(e,t){const a=e.format(t),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(a);return[parseInt(s[3],10),parseInt(s[1],10),parseInt(s[2],10),parseInt(s[4],10),parseInt(s[5],10),parseInt(s[6],10)]}(a,e)}const Ct={year:0,month:1,day:2,hour:3,minute:4,second:5};const kt={},St=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),_t="06/25/2014, 00:00:00"===St||"06/25/2014 00:00:00"===St;function At(e,t,a,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,t,a),i.setUTCHours(s,r,n,o),i}const Tt=36e5,Et={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Pt(e,t,a){if(!e)return 0;let s,r,n=Et.timezoneZ.exec(e);if(n)return 0;if(n=Et.timezoneHH.exec(e),n)return s=parseInt(n[1],10),It(s)?-s*Tt:NaN;if(n=Et.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return It(s,e)?(r=Math.abs(s)*Tt+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(Dt[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Dt[e]=!0,!0}catch(t){return!1}}(e)){t=new Date(t||Date.now());const s=a?t:function(e){return At(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),r=Mt(s,e),n=a?r:function(e,t,a){const s=e.getTime();let r=s-t;const n=Mt(new Date(r),a);if(t===n)return t;r-=n-t;const o=Mt(new Date(r),a);if(n===o)return n;return Math.max(n,o)}(t,r,e);return-n}return NaN}function Mt(e,t){const a=jt(e,t),s=At(a[0],a[1]-1,a[2],a[3]%24,a[4],a[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function It(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}const Dt={};const Rt={X:function(e,t,a){const s=Lt(a.timeZone,e);if(0===s)return"Z";switch(t){case"X":return Ut(s);case"XXXX":case"XX":return Ft(s);default:return Ft(s,":")}},x:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"x":return Ut(s);case"xxxx":case"xx":return Ft(s);default:return Ft(s,":")}},O:function(e,t,a){const s=Lt(a.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){const a=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return a+String(r);return a+String(r)+t+zt(n,2)}(s,":");default:return"GMT"+Ft(s,":")}},z:function(e,t,a){switch(t){case"z":case"zz":case"zzz":return yt("short",e,a);default:return yt("long",e,a)}}};function Lt(e,t){const a=e?Pt(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(a))throw new RangeError("Invalid time zone specified: "+e);return a}function zt(e,t){const a=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<t;)s="0"+s;return a+s}function Ft(e,t=""){const a=e>0?"-":"+",s=Math.abs(e);return a+zt(Math.floor(s/60),2)+t+zt(Math.floor(s%60),2)}function Ut(e,t){if(e%60==0){return(e>0?"-":"+")+zt(Math.abs(e)/60,2)}return Ft(e,t)}function qt(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+e-+t}const Ot=36e5,Bt=6e4,$t={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Ht(e,t={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const a=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==a&&1!==a&&0!==a)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);const s=function(e){const t={};let a,s=$t.dateTimePattern.exec(e);s?(t.date=s[1],a=s[3]):(s=$t.datePattern.exec(e),s?(t.date=s[1],a=s[2]):(t.date=null,a=e));if(a){const e=$t.timeZone.exec(a);e?(t.time=a.replace(e[1],""),t.timeZone=e[1].trim()):t.time=a}return t}(e),{year:r,restDateString:n}=function(e,t){if(e){const a=$t.YYY[t],s=$t.YYYYY[t];let r=$t.YYYY.exec(e)||s.exec(e);if(r){const t=r[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(r=$t.YY.exec(e)||a.exec(e),r){const t=r[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(s.date,a),o=function(e,t){if(null===t)return null;let a,s,r;if(!e||!e.length)return a=new Date(0),a.setUTCFullYear(t),a;let n=$t.MM.exec(e);if(n)return a=new Date(0),s=parseInt(n[1],10)-1,Qt(t,s)?(a.setUTCFullYear(t,s),a):new Date(NaN);if(n=$t.DDD.exec(e),n){a=new Date(0);const e=parseInt(n[1],10);return function(e,t){if(t<1)return!1;const a=Yt(e);if(a&&t>366)return!1;if(!a&&t>365)return!1;return!0}(t,e)?(a.setUTCFullYear(t,0,e),a):new Date(NaN)}if(n=$t.MMDD.exec(e),n){a=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return Qt(t,s,e)?(a.setUTCFullYear(t,s,e),a):new Date(NaN)}if(n=$t.Www.exec(e),n)return r=parseInt(n[1],10)-1,Kt(r)?Vt(t,r):new Date(NaN);if(n=$t.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return Kt(r,e)?Vt(t,r,e):new Date(NaN)}return null}(n,r);if(null===o||isNaN(o.getTime()))return new Date(NaN);if(o){const e=o.getTime();let a,r=0;if(s.time&&(r=function(e){let t,a,s=$t.HH.exec(e);if(s)return t=parseFloat(s[1].replace(",",".")),Xt(t)?t%24*Ot:NaN;if(s=$t.HHMM.exec(e),s)return t=parseInt(s[1],10),a=parseFloat(s[2].replace(",",".")),Xt(t,a)?t%24*Ot+a*Bt:NaN;if(s=$t.HHMMSS.exec(e),s){t=parseInt(s[1],10),a=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return Xt(t,a,e)?t%24*Ot+a*Bt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||t.timeZone){if(a=Pt(s.timeZone||t.timeZone,new Date(e+r)),isNaN(a))return new Date(NaN)}else a=qt(new Date(e+r)),a=qt(new Date(e+r+a));return new Date(e+r+a)}return new Date(NaN)}function Vt(e,t,a){t=t||0,a=a||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*t+a+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const Wt=[31,28,31,30,31,30,31,31,30,31,30,31],Gt=[31,29,31,30,31,30,31,31,30,31,30,31];function Yt(e){return e%400==0||e%4==0&&e%100!=0}function Qt(e,t,a){if(t<0||t>11)return!1;if(null!=a){if(a<1)return!1;const s=Yt(e);if(s&&a>Gt[t])return!1;if(!s&&a>Wt[t])return!1}return!0}function Kt(e,t){return!(e<0||e>52)&&(null==t||!(t<0||t>6))}function Xt(e,t,a){return!(e<0||e>=25)&&((null==t||!(t<0||t>=60))&&(null==a||!(a<0||a>=60)))}const Zt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Jt(e,t,a,s){return function(e,t,a={}){const s=(t=String(t)).match(Zt);if(s){const r=Ht(a.originalDate||e,a);t=s.reduce(function(e,t){if("'"===t[0])return e;const s=e.indexOf(t),n="'"===e[s-1],o=e.replace(t,"'"+Rt[t[0]](r,t,a)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},t)}return wt(e,t,a)}(function(e,t,a){const s=Pt(t,e=Ht(e,a),!0),r=new Date(e.getTime()-s),n=new Date(0);return n.setFullYear(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),n.setHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()),n}(e,t,{timeZone:(s={...s,timeZone:t,originalDate:e}).timeZone}),a,s)}const ea={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"}},ta={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},aa={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"},sa={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"},ra={ordinalNumber:(e,t)=>Number(e)+"º",era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},na={ordinalNumber:Ie({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},oa={code:"es",formatDistance:(e,t,a)=>{let s;const r=ea[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),a?.addSuffix?a.comparison&&a.comparison>0?"en "+s:"hace "+s:s},formatLong:ta,formatRelative:(e,t,a,s)=>1!==t.getHours()?sa[e]:aa[e],localize:ra,match:na,options:{weekStartsOn:1,firstWeekContainsDate:1}},ia={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"}},la={date:_e({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:_e({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:_e({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},da={lastWeek:e=>{const t=e.getDay();return"'"+(0===t||6===t?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},ca={ordinalNumber:(e,t)=>{const a=Number(e);return"week"===t?.unit?a+"ª":a+"º"},era:Ee({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Ee({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:Ee({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:Ee({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:Ee({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"})},ua={ordinalNumber:Ie({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Me({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:Me({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:Me({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:Me({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:Me({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"})},ma={code:"pt-BR",formatDistance:(e,t,a)=>{let s;const r=ia[e];return s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",String(t)),a?.addSuffix?a.comparison&&a.comparison>0?"em "+s:"há "+s:s},formatLong:la,formatRelative:(e,t,a,s)=>{const r=da[e];return"function"==typeof r?r(t):r},localize:ca,match:ua,options:{weekStartsOn:0,firstWeekContainsDate:1}},pa=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],ha=[{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"}],fa=[{value:"America/Sao_Paulo",label:"Brasília (UTC-3)",offset:"-03:00"},{value:"America/Noronha",label:"Fernando de Noronha (UTC-2)",offset:"-02:00"},{value:"America/Manaus",label:"Manaus (UTC-4)",offset:"-04:00"},{value:"America/Rio_Branco",label:"Rio Branco (UTC-5)",offset:"-05:00"},{value:"America/Buenos_Aires",label:"Buenos Aires (UTC-3)",offset:"-03:00"},{value:"America/Santiago",label:"Santiago (UTC-4)",offset:"-04:00"},{value:"America/Bogota",label:"Bogotá (UTC-5)",offset:"-05:00"},{value:"America/Mexico_City",label:"Cidade do México (UTC-6)",offset:"-06:00"},{value:"America/New_York",label:"New York (UTC-5)",offset:"-05:00"},{value:"America/Chicago",label:"Chicago (UTC-6)",offset:"-06:00"},{value:"America/Denver",label:"Denver (UTC-7)",offset:"-07:00"},{value:"America/Los_Angeles",label:"Los Angeles (UTC-8)",offset:"-08:00"},{value:"America/Toronto",label:"Toronto (UTC-5)",offset:"-05:00"},{value:"America/Vancouver",label:"Vancouver (UTC-8)",offset:"-08:00"},{value:"Europe/London",label:"Londres (UTC+0)",offset:"+00:00"},{value:"Europe/Lisbon",label:"Lisboa (UTC+0)",offset:"+00:00"},{value:"Europe/Paris",label:"Paris (UTC+1)",offset:"+01:00"},{value:"Europe/Berlin",label:"Berlim (UTC+1)",offset:"+01:00"},{value:"Europe/Madrid",label:"Madrid (UTC+1)",offset:"+01:00"},{value:"Europe/Rome",label:"Roma (UTC+1)",offset:"+01:00"},{value:"Europe/Amsterdam",label:"Amsterdã (UTC+1)",offset:"+01:00"},{value:"Europe/Moscow",label:"Moscou (UTC+3)",offset:"+03:00"},{value:"Asia/Dubai",label:"Dubai (UTC+4)",offset:"+04:00"},{value:"Asia/Kolkata",label:"Mumbai (UTC+5:30)",offset:"+05:30"},{value:"Asia/Singapore",label:"Singapura (UTC+8)",offset:"+08:00"},{value:"Asia/Hong_Kong",label:"Hong Kong (UTC+8)",offset:"+08:00"},{value:"Asia/Shanghai",label:"Xangai (UTC+8)",offset:"+08:00"},{value:"Asia/Tokyo",label:"Tóquio (UTC+9)",offset:"+09:00"},{value:"Asia/Seoul",label:"Seul (UTC+9)",offset:"+09:00"},{value:"Australia/Perth",label:"Perth (UTC+8)",offset:"+08:00"},{value:"Australia/Sydney",label:"Sydney (UTC+10)",offset:"+10:00"},{value:"Pacific/Auckland",label:"Auckland (UTC+12)",offset:"+12:00"},{value:"UTC",label:"UTC (UTC+0)",offset:"+00:00"}],xa="pt-BR",ga="dd/MM/yyyy HH:mm",ba="America/Sao_Paulo",va=e=>pa.some(t=>t.value===e),wa=e=>fa.some(t=>t.value===e),Na=()=>{if("undefined"==typeof navigator)return xa;const e=navigator.language;if(va(e))return e;const t=e.split("-")[0],a=pa.find(e=>e.value.startsWith(t));return a?.value||xa},ya=()=>{if("undefined"==typeof Intl)return ba;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return wa(e)?e:ba}catch{return ba}},ja=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||ga),Ca={"pt-BR":ma,"en-US":Re,"es-ES":oa},ka=(e,t=ga,a=ba,s=xa)=>{if(!e)return"";const r=o.parseISO(e);if(!o.isValid(r))return"Data inválida";const n=Ca[s]||ma;try{return Jt(r,a,t,{locale:n})}catch(i){return Jt(r,ba,t,{locale:n})}},Sa=(e,t=xa,a=ba)=>{if(!e)return"";const s=o.parseISO(e);if(!o.isValid(s))return"Data inválida";const r=Ca[t]||ma;try{return Jt(s,a,"PP",{locale:r})}catch(n){return Jt(s,ba,"PP",{locale:r})}};function _a(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{i.toast.info("Link copiado para a área de transferência")})}function Aa(...e){return n.twMerge(r.clsx(e))}const Ta=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Ta);if("object"==typeof e&&e.constructor===Object){const t={};for(const[a,s]of Object.entries(e))t[a]=Ta(s);return t}return e},Ea=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"}}),Pa=J.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...o},i)=>{const l=n?a.Slot:"button";return e.jsx(l,{className:Aa(Ea({variant:s,size:r,className:t})),ref:i,...o})});Pa.displayName="Button";const Ma=t.forwardRef(({className:t,children:a,variant:s="action",...r},n)=>e.jsx(Pa,{ref:n,variant:s,size:"icon",className:Aa("h-8 w-8",t),...r,children:a||e.jsx(l.EllipsisVertical,{size:16})}));Ma.displayName="ActionButton";const Ia=J.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:Aa("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));Ia.displayName="Input";const Da=s.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ra=J.forwardRef(({className:t,...a},s)=>e.jsx(ee.Root,{ref:s,className:Aa(Da(),t),...a}));Ra.displayName=ee.Root.displayName;const La=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a}));La.displayName="Card";const za=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex flex-col space-y-1.5 p-6",t),...a}));za.displayName="CardHeader";const Fa=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Aa("text-2xl font-semibold leading-none tracking-tight",t),...a}));Fa.displayName="CardTitle";const Ua=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Ua.displayName="CardDescription";const qa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("p-6 pt-0",t),...a}));qa.displayName="CardContent";const Oa=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex items-center p-6 pt-0",t),...a}));Oa.displayName="CardFooter";const Ba=J.forwardRef(({className:t,orientation:a="horizontal",decorative:s=!0,...r},n)=>e.jsx(ae.Root,{ref:n,decorative:s,orientation:a,className:Aa("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",t),...r}));Ba.displayName=ae.Root.displayName;const $a=se.Root,Ha=se.Trigger,Va=se.Portal,Wa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Overlay,{className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));Wa.displayName=se.Overlay.displayName;const Ga=J.forwardRef(({className:t,...a},s)=>e.jsxs(Va,{children:[e.jsx(Wa,{}),e.jsx(se.Content,{ref:s,className:Aa("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a})]}));Ga.displayName=se.Content.displayName;const Ya=({className:t,...a})=>e.jsx("div",{className:Aa("flex flex-col space-y-2 text-center sm:text-left",t),...a});Ya.displayName="AlertDialogHeader";const Qa=({className:t,...a})=>e.jsx("div",{className:Aa("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});Qa.displayName="AlertDialogFooter";const Ka=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Title,{ref:s,className:Aa("text-lg font-semibold",t),...a}));Ka.displayName=se.Title.displayName;const Xa=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Xa.displayName=se.Description.displayName;const Za=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Action,{ref:s,className:Aa(Ea(),t),...a}));Za.displayName=se.Action.displayName;const Ja=J.forwardRef(({className:t,...a},s)=>e.jsx(se.Cancel,{ref:s,className:Aa(Ea({variant:"outline"}),"mt-2 sm:mt-0",t),...a}));Ja.displayName=se.Cancel.displayName;const es=te.Root,ts=te.Trigger,as=te.Portal,ss=te.Close,rs=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{ref:s,className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));rs.displayName=te.Overlay.displayName;const ns={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",minWidth:"720px",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},os=J.forwardRef(({className:t,children:a,size:s,variant:r="informative",isDirty:n,customWidth:o,customMinWidth:i,customMaxWidth:d,customHeight:c,customMinHeight:u,customMaxHeight:m,unsavedChangesTitle:p="Alterações não salvas",unsavedChangesDescription:h="Existem alterações não salvas. Deseja sair sem salvar?",cancelText:f="Cancelar",leaveWithoutSavingText:x="Sair sem salvar",style:g,onInteractOutside:b,onEscapeKeyDown:v,...w},N)=>{const[y,j]=J.useState(!1),C=J.useRef(null),k=s??(o||i||d||c||u||m?void 0:"md"),S=k?ns[k]:{},_={...o??S.width?{width:o??S.width}:{},...i??S.minWidth?{minWidth:i??S.minWidth}:{},...d??S.maxWidth?{maxWidth:d??S.maxWidth}:{},...c??S.height?{height:c??S.height}:{},...u??S.minHeight?{minHeight:u??S.minHeight}:{},...m??S.maxHeight?{maxHeight:m??S.maxHeight}:{},...g},A=J.useCallback(e=>{"form"===r&&n?(C.current=e,j(!0)):e()},[r,n]),T="destructive"!==r;return e.jsxs(as,{children:[e.jsx(rs,{}),e.jsxs(te.Content,{ref:N,className:Aa("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),style:_,onInteractOutside:e=>{"form"!==r&&"destructive"!==r?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==r)return"form"===r&&n?(e.preventDefault(),void A(()=>{v?.(e)})):void v?.(e);e.preventDefault()},...w,children:[a,T&&e.jsxs(te.Close,{onClick:e=>{"form"===r&&n&&(e.preventDefault(),A(()=>{const t=e.target.closest("[data-radix-collection-item]");t&&t.click()}))},className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]}),e.jsx($a,{open:y,onOpenChange:j,children:e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:p}),e.jsx(Xa,{children:h})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{onClick:()=>{j(!1),C.current=null},children:f}),e.jsx(Za,{onClick:()=>{j(!1),C.current?.(),C.current=null},children:x})]})]})})]})});os.displayName=te.Content.displayName;const is=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Aa("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});is.displayName="DialogHeader";const ls=({className:t,...a})=>e.jsx("div",{className:Aa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});ls.displayName="DialogBody";const ds=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Aa("flex flex-row justify-end gap-2",t),...s,children:a})]});ds.displayName="DialogFooter";const cs=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));cs.displayName=te.Title.displayName;const us=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));us.displayName=te.Description.displayName;const ms=p.FormProvider,ps=J.createContext({}),hs=()=>{const e=J.useContext(ps),t=J.useContext(fs),{getFieldState:a,formState:s}=p.useFormContext(),r=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=t;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},fs=J.createContext({}),xs=J.forwardRef(({className:t,...a},s)=>{const r=J.useId();return e.jsx(fs.Provider,{value:{id:r},children:e.jsx("div",{ref:s,className:Aa("space-y-2",t),...a})})});xs.displayName="FormItem";const gs=J.forwardRef(({className:t,...a},s)=>{const{error:r,formItemId:n}=hs();return e.jsx(Ra,{ref:s,className:Aa(r&&"text-destructive",t),htmlFor:n,...a})});gs.displayName="FormLabel";const bs=J.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=hs();return e.jsx(a.Slot,{ref:s,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...t})});bs.displayName="FormControl";const vs=J.forwardRef(({className:t,...a},s)=>{const{formDescriptionId:r}=hs();return e.jsx("p",{ref:s,id:r,className:Aa("text-sm text-muted-foreground",t),...a})});vs.displayName="FormDescription";const ws=J.forwardRef(({className:t,children:a,...s},r)=>{const{error:n,formMessageId:o}=hs(),i=n?String(n?.message):a;return i?e.jsx("p",{ref:r,id:o,className:Aa("text-sm font-medium text-destructive",t),...s,children:i}):null});ws.displayName="FormMessage";const Ns=re.Root,ys=re.Group,js=re.Value,Cs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Trigger,{ref:r,className:Aa("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(re.Icon,{asChild:!0,children:e.jsx(l.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Cs.displayName=re.Trigger.displayName;const ks=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollUpButton,{ref:s,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronUp,{className:"h-4 w-4"})}));ks.displayName=re.ScrollUpButton.displayName;const Ss=J.forwardRef(({className:t,...a},s)=>e.jsx(re.ScrollDownButton,{ref:s,className:Aa("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(l.ChevronDown,{className:"h-4 w-4"})}));Ss.displayName=re.ScrollDownButton.displayName;const _s=J.forwardRef(({className:t,children:a,position:s="popper",container:r,collisionBoundary:n,...o},i)=>e.jsx(re.Portal,{container:r,children:e.jsxs(re.Content,{ref:i,className:Aa("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,collisionBoundary:n,...o,children:[e.jsx(ks,{}),e.jsx(re.Viewport,{className:Aa("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(Ss,{})]})}));_s.displayName=re.Content.displayName;const As=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Label,{ref:s,className:Aa("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));As.displayName=re.Label.displayName;const Ts=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(re.Item,{ref:r,className:Aa("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(re.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),e.jsx(re.ItemText,{children:a})]}));Ts.displayName=re.Item.displayName;const Es=J.forwardRef(({className:t,...a},s)=>e.jsx(re.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Es.displayName=re.Separator.displayName;const Ps=J.forwardRef(({className:t,...a},s)=>e.jsx(ne.Root,{ref:s,className:Aa("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(ne.Indicator,{className:Aa("flex items-center justify-center text-current"),children:e.jsx(l.Check,{className:"h-4 w-4"})})}));Ps.displayName=ne.Root.displayName;const Ms=J.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:Aa("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...a}));Ms.displayName="Textarea";const Is=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"}}),Ds=J.forwardRef(({className:t,variant:a,...s},r)=>e.jsx("div",{ref:r,className:Aa(Is({variant:a}),t),...s}));Ds.displayName="Badge";const Rs={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Ls({size:t="md",className:a}){return e.jsx(l.Loader2,{className:Aa("animate-spin text-muted-foreground",Rs[t],a)})}const zs=({...t})=>e.jsx(i.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:e.jsx(l.CircleCheckIcon,{className:"h-4 w-4"}),info:e.jsx(l.InfoIcon,{className:"h-4 w-4"}),warning:e.jsx(l.TriangleAlertIcon,{className:"h-4 w-4"}),error:e.jsx(l.OctagonXIcon,{className:"h-4 w-4"}),loading:e.jsx(l.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive/10 !border-destructive/10",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...t}),Fs=oe.Root,Us=oe.Trigger,qs=oe.Group,Os=oe.Portal,Bs=oe.Sub,$s=oe.RadioGroup,Hs=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(oe.SubTrigger,{ref:n,className:Aa("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Hs.displayName=oe.SubTrigger.displayName;const Vs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.SubContent,{ref:s,className:Aa("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Vs.displayName=oe.SubContent.displayName;const Ws=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(oe.Portal,{children:e.jsx(oe.Content,{ref:r,sideOffset:a,className:Aa("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground p-1 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));Ws.displayName=oe.Content.displayName;const Gs=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Item,{ref:r,className:Aa("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Gs.displayName=oe.Item.displayName;const Ys=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(oe.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Ys.displayName=oe.CheckboxItem.displayName;const Qs=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(oe.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(oe.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Qs.displayName=oe.RadioItem.displayName;const Ks=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(oe.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Ks.displayName=oe.Label.displayName;const Xs=J.forwardRef(({className:t,...a},s)=>e.jsx(oe.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Xs.displayName=oe.Separator.displayName;const Zs=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest opacity-60",t),...a});Zs.displayName="DropdownMenuShortcut";const Js=({delayDuration:t=300,...a})=>e.jsx(ie.Provider,{delayDuration:t,...a}),er=ie.Root,tr=ie.Trigger,ar=J.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(ie.Content,{ref:r,sideOffset:a,className:Aa("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));ar.displayName=ie.Content.displayName;const sr=J.forwardRef(({children:t,disabledReason:a,className:s},r)=>{const n=e.jsx(Gs,{ref:r,className:Aa("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:t});return a?e.jsx(Js,{delayDuration:100,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:"w-full",children:n})}),e.jsx(ar,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:a})]})}):n});sr.displayName="DisabledMenuItem";const rr=le.Root,nr=le.Trigger,or=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,container:r,...n},o)=>e.jsx(le.Portal,{container:r,children:e.jsx(le.Content,{ref:o,align:a,sideOffset:s,className:Aa("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));or.displayName=le.Content.displayName;const ir=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...a}));ir.displayName="Command";const lr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:e.jsx("input",{ref:s,className:Aa("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...a})}));lr.displayName="CommandInput";const dr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...a}));dr.displayName="CommandList";const cr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("py-6 text-center text-sm text-muted-foreground",t),...a}));cr.displayName="CommandEmpty";const ur=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...a}));ur.displayName="CommandGroup";const mr=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("-mx-1 h-px bg-border",t),...a}));mr.displayName="CommandSeparator";const pr=J.forwardRef(({className:t,disabled:a,onSelect:s,value:r,...n},o)=>e.jsx("div",{ref:o,className:Aa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),"data-disabled":a,onClick:()=>!a&&s?.(r||""),...n}));pr.displayName="CommandItem";const hr=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});function fr({className:t,...a}){return e.jsx("div",{className:Aa("animate-pulse rounded-md bg-muted",t),...a})}hr.displayName="CommandShortcut";const xr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function gr({multiple:a,options:s,value:r,onChange:n,getOptionValue:o,getOptionLabel:i,placeholder:d,label:c,icon:u,emptyMessage:m,searchPlaceholder:p,disabled:h,required:f,className:x,sortOptions:g,maxDisplayedBadges:b,popoverContainer:v,onOpen:w,onClose:N}){const[y,j]=t.useState(!1),[C,k]=t.useState(""),S=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),_=t.useMemo(()=>{if(!v)return;let e=v,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[v]),A=t.useMemo(()=>{const e=s.map(e=>({original:e,value:o(e),label:i(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[s,o,i,g]),T=t.useMemo(()=>{if(!C)return A;const e=xr(C);return A.filter(t=>xr(t.label).includes(e))},[A,C]),E=t.useMemo(()=>A.filter(e=>S.includes(e.value)),[A,S]),P=e=>{j(e),e?w?.():(k(""),N?.())},M=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?S.filter(t=>t!==e):"")},I=b?E.slice(0,b):E,D=b&&E.length>b?E.length-b:0;return e.jsxs("div",{className:Aa("space-y-2",x),children:[c&&e.jsxs(Ra,{children:[c,f&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:y,onOpenChange:P,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":y,"aria-disabled":h,tabIndex:h?-1:0,onKeyDown:e=>{h||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),P(!y))},className:Aa("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",h&&"pointer-events-none opacity-50 cursor-not-allowed",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[I.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&M(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>M(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),D>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",D]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":y,disabled:h,className:Aa("w-full justify-between min-h-10 h-auto",0===E.length&&"text-muted-foreground"),children:[0===E.length?e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),d]}):e.jsxs("span",{className:"flex items-center gap-2",children:[u&&e.jsx(u,{className:"h-4 w-4"}),E[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:_,collisionBoundary:_,children:e.jsxs(ir,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(lr,{placeholder:p,value:C,onChange:e=>k(e.target.value)}),C&&e.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>k(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(dr,{children:0===s.length?e.jsx(cr,{children:m}):0===T.length?e.jsx(cr,{children:"Nenhum resultado encontrado"}):e.jsx(ur,{children:T.map(t=>e.jsxs(pr,{value:t.value,onSelect:()=>(e=>{if(n)if(a){const t=S.includes(e)?S.filter(t=>t!==e):[...S,e];n(t)}else n(e),j(!1)})(t.value),className:"cursor-pointer",children:[e.jsx(l.Check,{className:Aa("mr-2 h-4 w-4",S.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function br({multiple:t=!1,options:a,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:d=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:f=!1,required:x=!1,isLoading:g=!1,error:b,className:w,sortOptions:N=!0,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k}){const{t:S}=v.useTranslation(),_=a||s||[],A=o||n,T=c||S("select_placeholder","Selecione..."),E=p||S("no_results","Nenhum resultado encontrado"),P=h||S("search_placeholder","Pesquisar...");if(g)return e.jsxs("div",{className:Aa("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const M="string"==typeof b?b:b instanceof Error?b.message:b?S("error_loading","Erro ao carregar"):void 0;return M?e.jsxs("div",{className:Aa("space-y-2",w),children:[u&&e.jsxs(Ra,{children:[u,x&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:M})]})]}):e.jsx(gr,{multiple:t,options:_,value:r||(t?[]:""),onChange:A,getOptionValue:i,getOptionLabel:d,placeholder:T,label:u,icon:m,emptyMessage:E,searchPlaceholder:P,disabled:f,required:x,className:w,sortOptions:N,maxDisplayedBadges:y,popoverContainer:j,onOpen:C,onClose:k})}const vr=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(de.Root,{ref:r,className:Aa("relative overflow-hidden",t),...s,children:[e.jsx(de.Viewport,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(wr,{}),e.jsx(de.Corner,{})]}));vr.displayName=de.Root.displayName;const wr=J.forwardRef(({className:t,orientation:a="vertical",...s},r)=>e.jsx(de.ScrollAreaScrollbar,{ref:r,orientation:a,className:Aa("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...s,children:e.jsx(de.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));wr.displayName=de.ScrollAreaScrollbar.displayName;const Nr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function yr(e,t){if(!t)return null;const a=Nr(t),s=[];for(const r of e){const e=Nr(r.label).includes(a),n=r.children?yr(r.children,t):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function jr(e,t){for(const a of e){if(a.value===t)return a.label;if(a.children){const e=jr(a.children,t);if(e)return e}}}function Cr({node:t,level:a,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=t.children&&t.children.length>0,d=n.includes(t.value);return e.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":d,className:Aa("flex items-center gap-1 rounded-sm px-2 py-1.5 text-sm cursor-pointer","hover:bg-accent hover:text-accent-foreground","outline-none"),style:{paddingLeft:8+20*a+"px"},children:[i?e.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted",onClick:e=>{e.stopPropagation(),r(t.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?e.jsx(l.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})}):e.jsx("span",{className:"w-5 shrink-0"}),e.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:e=>{e.stopPropagation(),o(t.value)},children:[e.jsx(l.Check,{className:Aa("h-4 w-4 shrink-0",d?"opacity-100":"opacity-0")}),(()=>{const a=d&&t.iconSelected?t.iconSelected:t.icon;return a?e.jsx(a,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):null})(),e.jsx("span",{className:"truncate",children:t.label})]})]})}function kr({nodes:a,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return e.jsx(e.Fragment,{children:a.map(a=>{const l=r.has(a.value);return e.jsxs(t.Fragment,{children:[e.jsx(Cr,{node:a,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&a.children&&a.children.length>0&&e.jsx(kr,{nodes:a.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},a.value)})})}class Sr{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const a=(4-t.length%4)%4;return t+="=".repeat(a),t}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),t=atob(e),a=new Uint8Array(t.length);for(let r=0;r<t.length;r++)a[r]=t.charCodeAt(r);const s=new TextDecoder("utf-8").decode(a);return JSON.parse(s)}catch(t){try{const e=this.normalizeBase64Url(n),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(a){try{const e=this.normalizeBase64Url(n),t=atob(e);return JSON.parse(t)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,t){const a=[],s=[];try{t.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(t),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";a.push(e),o=!1}const i=Math.floor(Date.now()/1e3);if(n?.exp&&n.exp<i){const e="Access token expirado - pode precisar de refresh";a.push(e),o=!1}if(r.exp&&r.exp<i){const e="ID token expirado - autenticação inválida";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:o,warnings:a,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:a,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:a,errors:s}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}}Sr.LARGE_PAYLOAD_THRESHOLD=1e3;const _r="qualiex_access_token",Ar="qualiex_id_token",Tr="supabase_token",Er="oauth_state",Pr="oauth_nonce",Mr="selected_alias",Ir="manual_logout",Dr={setAccessToken:e=>localStorage.setItem(_r,e),getAccessToken:()=>localStorage.getItem(_r),setIdToken:e=>localStorage.setItem(Ar,e),getIdToken:()=>localStorage.getItem(Ar),getSupabaseToken:()=>localStorage.getItem(Tr),setOAuthState:e=>sessionStorage.setItem(Er,e),getOAuthState:()=>sessionStorage.getItem(Er),clearOAuthState:()=>sessionStorage.removeItem(Er),setOAuthNonce:e=>sessionStorage.setItem(Pr,e),getOAuthNonce:()=>sessionStorage.getItem(Pr),clearOAuthNonce:()=>sessionStorage.removeItem(Pr),setSelectedAlias:e=>localStorage.setItem(Mr,e),getSelectedAlias:()=>localStorage.getItem(Mr),clearSelectedAlias:()=>localStorage.removeItem(Mr),generateOAuthState:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Dr.getAccessToken()||!Dr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Tr,e),Dr._clearValidationCache()},areAllTokensValid:()=>{const e=Dr.getAccessToken(),t=Dr.getIdToken();if(!e||!t)return!1;try{const a=Sr.validateTokens(e,t);return!!a.idTokenValid&&a.idTokenValid}catch(a){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Dr.getAccessToken(),a=Dr.getIdToken(),s=Dr.getSupabaseToken();return t&&Dr.isTokenExpired(t)&&(localStorage.removeItem(_r),e=!0),a&&Dr.isTokenExpired(a)&&(localStorage.removeItem(Ar),e=!0),s&&Dr.isTokenExpired(s)&&(localStorage.removeItem(Tr),e=!0),e},clearAll:()=>{localStorage.removeItem(_r),localStorage.removeItem(Ar),localStorage.removeItem(Tr),localStorage.removeItem(Mr),localStorage.removeItem(Ir),sessionStorage.removeItem(Er),sessionStorage.removeItem(Pr),Dr._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Ir,"true"),isManualLogout:()=>"true"===localStorage.getItem(Ir),clearManualLogout:()=>localStorage.removeItem(Ir),isTokenExpired:e=>{try{return Sr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Dr._validationCache.isValid=!1,Dr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Dr.getSupabaseToken();if(!e)return!1;if(Dr.isTokenExpired(e))return Dr._clearValidationCache(),Dr._handleExpiredToken(),!1;const t=Date.now();return t-Dr._validationCache.timestamp<Dr._validationCache.cacheValidityMs?Dr._validationCache.isValid:(Dr._validationCache.isValid=!0,Dr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Dr.isSupabaseTokenValid()?Dr.getSupabaseToken():null,_handleExpiredToken:()=>{Dr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Dr.isSupabaseTokenValid())return null;const e=Dr.getSupabaseToken();if(!e)return null;try{const t=Sr.parseJwtPayload(e);if(!t)return null;const a=t.alias||t.default||t.user_alias,s=t.place_id||null,r=t.place_name||null;let n=t.company_id;if(!n&&a)for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===a){n=e[7];break}}}return{alias:a,companyId:n,placeId:s,placeName:r,payload:t}}catch(t){return Dr._handleExpiredToken(),null}},getCompanyId:e=>{const t=Dr.getAccessToken();if(t)try{const a=Sr.parseJwtPayload(t);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}const a=Dr.extractTokenData();if(a?.companyId)return a.companyId;const s=Dr.getIdToken();if(s)try{const t=Sr.parseJwtPayload(s);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>7&&t[0]===e)return t[7];if(!e&&t.length>7)return t[7]}}}catch(r){}return null},getCompanyIdInt:e=>{const t=[Dr.getAccessToken(),Dr.getIdToken()];for(const a of t)if(a)try{const t=Sr.parseJwtPayload(a);if(!t)continue;for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const t=s.split(";");if(e&&t.length>1&&t[0]===e)return t[1];if(!e&&t.length>1)return t[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=Dr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Dr.getIdToken();if(!e)return[];try{const t=Sr.parseJwtPayload(e);if(!t)return[];const a=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=t[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&a.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return a}catch{return[]}}};const Rr=new class{constructor(){this.errors=[],this.toastCount=0,this.lastToastTime=0}handleError(e,t=!0){const a="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:a,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),t&&this.shouldShowToast()){const e=this.getErrorTitle(a);i.toast.error(e,{description:a})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){i.toast.success(e,{description:t})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}},Lr=(void 0).VITE_SUPABASE_URL,zr=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class Fr{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:zr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return N.createClient(Lr,zr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return Fr.instance||(Fr.instance=new Fr),Fr.instance}getClient(){const e=Dr.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Sr.isTokenExpired(e)}catch(t){return Rr.handleError(t instanceof Error?t:"Supabase - Error validating token",!1),!1}}}function Ur(){return Fr.getInstance().getClient()}class qr{static async generateToken(e,t,a,s=!1){try{if(!s){const e=Dr.getSupabaseToken();if(e&&Dr.isSupabaseTokenValid())return e}const r=Ur(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(a?.(),null):n?.access_token?(Dr.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&a?.(),null}}}class Or{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(e=!1){if(this.regenerationPromise)return this.regenerationPromise;this.regenerationPromise=this._doRegenerate(e);try{return await this.regenerationPromise}finally{this.regenerationPromise=null}}static async _doRegenerate(e=!1){try{const t=Dr.getAccessToken(),a=Dr.getSelectedAlias();if(!t||!a)return null;const s=await qr.generateToken(t,a,this.onLogoutCallback||void 0,e);return s||null}catch(t){return null}}}Or.regenerationPromise=null,Or.onLogoutCallback=null;class Br{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Dr.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const a=t.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>a.includes(e))}static async wrapAsync(e){try{return await e}catch(t){if(!this.handleError(t))throw t;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}class $r{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,a=e.message||e.toString();if(401===t||a.includes("401")||a.includes("Unauthorized")){this.isRetrying=!0;try{return await Or.attemptRegeneration()?(this.isRetrying=!1,!0):(Br.handleError(e),this.isRetrying=!1,!1)}catch(s){return Br.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Dr.getAccessToken();return e?Dr.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."}}}$r.isRetrying=!1;const Hr="ccjfvpnndclajkleyqkc",Vr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Wr={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"cdf6c125-ec32-43d1-846b-bb8f90125b90"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Gr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e===Hr?Vr:Wr}function Yr(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const t=(void 0).VITE_SUPABASE_URL;t&&(e=new URL(t).hostname.split(".")[0])}catch{}return e!==Hr}const Qr={get oauth(){const e=Gr();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Kr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Xr={debounceDelay:500},Zr=()=>{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},Jr=()=>Gr().qualiexApiUrl,en={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},tn={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},an={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}`}};const sn=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status} ${o.statusText}`);throw e.status=o.status,e.statusCode=o.status,e}return await o.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}parseUsersResponse(e,t=""){let a=e;if(e.data)a=e.data;else{if(!Array.isArray(e))return Rr.handleError(`[QualiexApi] Formato de resposta inesperado${t}`,!1),null;a=e}return Array.isArray(a)?a.map(this.mapToQualiexUser):(Rr.handleError(`[QualiexApi] Resposta não é um array${t}`,!1),null)}async fetchUsers(e,t){const a={companyId:t,search:"",filterStatus:"active"};try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t)??[]}catch(s){if(await $r.handleApiError(s))try{const t=await this.makeApiCall("/api/common/v1/companiesusers",a,e);return this.parseUsersResponse(t," após retry")??[]}catch(r){return Rr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}return Rr.handleError(s instanceof Error?s.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,t,a){try{return(await this.fetchUsers(t,a)).find(t=>t.userId===e)||null}catch(s){return Rr.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const a=await this.fetchUsers(e,t),s=new Map;return a.forEach(e=>s.set(e.userId,e)),s}async getUsers(e){const t=Dr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}async fetchSoftwares(e){try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(Rr.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(t){if(await $r.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/softwares",{},e),a=t?.data||t;return Array.isArray(a)?a.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(a){return Rr.handleError(a instanceof Error?a:"Erro ao buscar softwares após renovação de token",!0),[]}return Rr.handleError(t instanceof Error?t.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,t){try{const a=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},t),s=a?.data||a;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):(Rr.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},t),s=a?.data||a;return Array.isArray(s)?s.map(e=>({associationId:e.associationId||"",userId:e.userId||"",userName:e.userName||"",companyId:e.companyId||"",companyName:e.companyName||"",companyAlias:e.companyAlias||"",companyPhotoDate:e.companyPhotoDate,language:e.language,roleId:e.roleId||"",roleName:e.roleName||"",placeId:e.placeId,placeName:e.placeName,softwares:Array.isArray(e.softwares)?e.softwares:[],functionalities:Array.isArray(e.functionalities)?e.functionalities:[],isQualitfy:e.isQualitfy??!1,isMetroex:e.isMetroex??!1})):[]}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar associações do usuário",!0),[]}}};function rn(e,t){const a=t||en.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function nn(e,t){const a=t||en.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function on(e,t){const a=t||en.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,a):`${e}${a}`}function ln(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||rn(e.idField),emailField:e.emailField||nn(e.idField),usernameField:e.usernameField||on(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:rn(e),emailField:nn(e),usernameField:on(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const dn=new Map;class cn{static async fetchQualiexUsers(e,t){const a=`${t}_${e}`,s=dn.get(a);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await sn.fetchUsers(e,t);return dn.set(a,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,t){const a=new Set;for(const s of e)for(const e of t){const t=s[e.idField];t&&"string"==typeof t&&""!==t.trim()&&a.add(t)}return a}static indexUsers(e){const t=new Map;for(const a of e)a.id&&t.set(a.id,a),a.userId&&t.set(a.userId,a);return t}static enrichEntity(e,t,a){const s={...e};for(const r of t){const t=e[r.idField];if(!t)continue;const n=a.get(t);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{if(!Dr.areAllTokensValid())return e;const a=Dr.extractTokenData();if(!a)return e;const{alias:s,companyId:r}=a;if(!s||!r)return e;const n=ln(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,n).size)return e;const o=await this.fetchQualiexUsers(s,r),i=this.indexUsers(o);return e.map(e=>this.enrichEntity(e,n,i))}catch(a){return Rr.handleError(a instanceof Error?a:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}}const un=["responsible_name"],mn=e=>un.includes(e);function pn(e,t,a){const s="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:a||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!Dr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Ur().schema(i).from(r)},u=(e,t,a,s)=>{let r=c().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?r=r.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?r=r.not(e,"is",null):"is_null"===t.operator&&(r=r.is(e,null)):null!==t&&(r=r.eq(e,t)))}),r=((e,t)=>{if(t&&n.length>0){const a=n.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(a)}return e})(r,e);const i=t.includes(".");return i||mn(t)||(r=r.order(t,{ascending:"asc"===a})),{query:r,isForeignKey:i}},m=async(e,t,a,r,n)=>{const o=ln(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),i=t.includes(".");if(mn(t)||i||o){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},o=await p.getAll(e);if(!o?.data?.length)return o;const d=await cn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.sort((e,s)=>{const r=t.split(".").reduce((e,t)=>e?.[t],e)||"",n=t.split(".").reduce((e,t)=>e?.[t],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===a?o:-o}):((e,t,a)=>[...e].sort((e,s)=>{const r=e[t]||"",n=s[t]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===a?o:-o}))(d,t,a);const u=((e,t=1,a=25)=>{const s=(t-1)*a,r=s+a;return{data:e.slice(s,r),pagination:{currentPage:t,totalPages:Math.ceil(e.length/a),totalItems:e.length,itemsPerPage:a,hasNextPage:r<e.length,hasPreviousPage:t>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await cn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:t,sortField:a,sortDirection:n,page:o,limit:i,additionalFilters:c}=(e=>{const{search:t="",sortField:a="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:t,sortField:a,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(t,a,n,c),h=((e,t,a)=>{const s=(t-1)*a,r=s+a-1;return e.range(s,r)})(p,o,i),{data:f,error:x,count:g}=await h;if(x)throw new Error(`Error fetching ${r}: ${x.message}`);let b=((e,t,a,s)=>{const r=Math.ceil((t||0)/s);return{data:e,currentPage:a,totalPages:r,totalItems:t||0,itemsPerPage:s,hasNextPage:a<r,hasPreviousPage:a>1}})(f||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const t=ln(s.userIdFields,s.userFieldsMapping);return e.some(e=>t.some(t=>e[t.idField]))})(b.data)){const e=await m(b.data,a,n,o,i);if(!Array.isArray(e))return e;b={...b,data:e}}return b},async getById(e){const{data:t,error:a}=await c().select(o||"*").eq("id",e).maybeSingle();if(a)throw new Error(`Error fetching ${r}: ${a.message}`);return t},async create(e){const t=Ta(e),a=Object.entries(t).reduce((e,[t,a])=>(void 0!==a&&(e[t]=a),e),{}),{data:s,error:n}=await c().insert(a).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,t){const a={...Ta(t),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(a).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:a}=await c().update(t).eq("id",e);if(a)throw new Error(`Error soft deleting ${r}: ${a.message}`)}};return p}var hn;const fn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class xn{static async initialize(){try{if(!Dr.hasAllTokens()||!Dr.areAllTokensValid())return Dr.clearExpiredTokens(),{...fn};const e=Dr.getAccessToken(),t=Dr.getIdToken();Dr.clearManualLogout();const a=this.extractUserFromIdToken(t),s=this.extractCompaniesFromIdToken(t),r=this.extractAliasFromAccessToken(e),n=Dr.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=Dr.getSelectedAlias(),t=e&&s.some(t=>t.alias===e);i=t?e:r||s[0]?.alias||null}if(!Dr.isSupabaseTokenValid()&&i&&await Or.attemptRegeneration(),!Dr.isSupabaseTokenValid())return{...fn};let l=null;if(i){const e=Dr.getCompanyId(i),t=s.find(e=>e.alias===i);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}const d=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:a,alias:i,companies:s,selectedUnit:l,userId:a?.id||null,userAlias:a?.id||null,placeId:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{...fn}}}static async loginDev(){try{const e=Ur(),{data:t,error:a}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(a)return!1;if(!t?.access_token||!t?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${t.access_token}&id_token=${t.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e=Dr.generateOAuthState();Dr.setOAuthState(e);const t=Dr.generateOAuthNonce();Dr.setOAuthNonce(t);const a=`${window.location.origin}/callback`,s=new URL(Qr.oauth.authUrl);s.searchParams.set("client_id",Qr.oauth.clientId),s.searchParams.set("response_type",Qr.oauth.responseType),s.searchParams.set("scope",Qr.oauth.scope),s.searchParams.set("redirect_uri",a),s.searchParams.set("state",e),s.searchParams.set("nonce",t),s.searchParams.set("response_mode","fragment"),window.location.href=s.toString()}static async processCallback(){try{const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),a=a=>e.get(a)||t.get(a),s=a("access_token"),r=a("id_token"),n=a("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(s&&r){const e=Dr.getAccessToken();e!==s&&Dr.clearAll()}if(Dr.hasAllTokens()){return Dr.getValidSupabaseToken()||await Or.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");Dr.setAccessToken(o),Dr.setIdToken(i),Dr.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)Dr.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Dr.setSelectedAlias(e[0].alias)}if(!await Or.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return Dr.clearOAuthState(),Dr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Dr.setManualLogout(),Dr.clearAll(),localStorage.removeItem("auth_return_url"),window.location.href="/login"}static decodeToken(e){return Sr.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const a=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const s=t[e].split(";");if(s.length>=4)a.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=t[e].split("|");s&&r&&a.push({id:"",alias:s.trim(),name:r.trim()})}}}),a}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}}hn=xn,Or.setLogoutCallback(()=>{hn.logout()});const gn=e=>e?.placeId||null,bn=e=>e?.placeName||null,vn=t.createContext(void 0),wn=({children:a})=>{const[s,r]=t.useState({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let n=null;try{n=y.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useCallback(e=>{r(t=>({...t,...e}))},[]),d=t.useCallback(e=>{r(t=>({...t,isLoading:e}))},[]),c=t.useCallback(()=>{r({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),u=t.useCallback(async e=>{try{d(!0);const a=Dr.getAccessToken();if(!a)return;const r=await qr.generateToken(a,e.alias,void 0,!0);if(!r)return;Dr.setSupabaseToken(r),Dr.setSelectedAlias(e.alias);const o=Dr.extractTokenData(),i=o?.alias||e.alias,c=o?.companyId||Dr.getCompanyId(e.alias),u={id:c||e.id,name:e.name,alias:i};let m=null,p=null;if(s.user?.id&&i&&c)try{const e=(await sn.fetchActiveUsersMap(i,c)).get(s.user.id);if(e){const t=(e=>({placeId:gn(e),placeName:bn(e)}))(e);m=t.placeId,p=t.placeName}}catch(t){}l({alias:i,selectedUnit:u,placeId:m,placeName:p,activePlaceId:m,activePlaceName:p}),n&&(await n.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{d(!1)}},[l,n,d,s.user]),m=t.useCallback(async()=>{const e=await xn.processCallback();if(e){const e=await xn.initialize();e&&e.isAuthenticated&&(l({user:e.user,companies:e.companies,alias:e.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:e.selectedUnit,userId:e.userId,userAlias:e.userAlias,placeId:e.placeId,placeName:e.placeName,activePlaceId:e.activePlaceId,activePlaceName:e.activePlaceName}),n&&n.invalidateQueries({queryKey:["permission"]}))}return e},[l,n]),p=t.useCallback(async()=>{xn.logout(),c(),n&&await n.clear()},[c,n]),h=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),x=t.useCallback(()=>{},[]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const t=setInterval(()=>{e&&(Dr.areAllTokensValid()||e&&p())},6e5);return()=>{e=!1,clearInterval(t)}},[s.isAuthenticated,p]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await xn.initialize();if(!e)return;t&&t.isAuthenticated?l({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:t.placeId,placeName:t.placeName,activePlaceId:t.activePlaceId,activePlaceName:t.activePlaceName}):e&&d(!1)}catch(t){e&&(Br.handleError(t),d(!1))}})(),()=>{e=!1}},[l,d,p]);const g=t.useMemo(()=>({...s,logout:p,processCallback:m,switchUnit:u,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:h,clearSearch:f,refreshData:x}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,p,m,u,o,h,f,x]);return e.jsx(vn.Provider,{value:g,children:a})},Nn=()=>{const e=t.useContext(vn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function yn({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[l,d]=j.useSearchParams(),c=y.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Nn(),{t:h}=v.useTranslation(),f=t.useCallback(t=>{const a=`${e}_${t}`,s=l.get(a);return s||(l.get(t)||"")},[l,e]),x=f("search"),g=f("sortField")||Kr.sorting.defaultField,b=f("sortDirection")||Kr.sorting.defaultDirection,w=parseInt(f("page")||"1"),N=parseInt(f("limit")||String(Kr.pagination.defaultPageSize)),C=x,k=t.useMemo(()=>({search:C,sortField:g,sortDirection:b,page:w,limit:N,...n}),[C,g,b,w,N,n]),S=t.useCallback(()=>a.getAll(k),[a,k]),_=y.useQuery({queryKey:[e,u,m,k],queryFn:S,enabled:!!u&&p});if(!_)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const A=y.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.created(s)),o?.()},onError:e=>{i.toast.error(`${an.error.create(s)}: ${e.message}`)}}),T=y.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.updated(s)),o?.()},onError:e=>{i.toast.error(`${an.error.update(s)}: ${e.message}`)}}),E=y.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(an.success.deleted(s))},onError:e=>{i.toast.error(`${an.error.delete(s)}: ${e.message}`)}}),P=t.useCallback(t=>{const a={...Object.fromEntries(l)};Object.entries(t).forEach(([t,s])=>{const r=`${e}_${t}`;""===s||0===s?delete a[r]:a[r]=String(s)}),delete a.sortField,delete a.sortDirection,d(a)},[l,d,e]),M=t.useCallback(e=>{P({search:e,page:1})},[P]),I=t.useCallback(e=>{P({sortField:e,sortDirection:g===e&&"asc"===b?"desc":"asc",page:1})},[g,b,P]),D=t.useCallback(e=>{P({page:e})},[P]),R=t.useCallback(e=>{P({limit:e,page:1})},[P]),L=t.useCallback(()=>{const t=Object.fromEntries(l),a=`${e}_`,s=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(a)));d(s)},[d,l,e]),[z,F]=t.useState([]),U=t.useCallback(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),q=t.useCallback(()=>{const e=_?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[_?.data?.data]),O=t.useCallback(()=>{F([])},[]),B=t.useMemo(()=>{const e=_?.data?.data.map(e=>e.id)||[];return e.length>0&&z.length===e.length},[z,_?.data?.data]),$=y.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(t,a)=>{c.invalidateQueries({queryKey:[e]}),i.toast.success(h("bulk_delete_success",`${a.length} ${s}(s) deletado(s) com sucesso`)),O()},onError:e=>{i.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),H=t.useCallback((e,t)=>{const a=t?t(e):e;e.id?T.mutate({id:e.id,data:a}):A.mutate({...a,alias:u})},[u,A,T]);return{entities:_?.data?.data||[],pagination:{data:_?.data?.data||[],currentPage:_?.data?.currentPage||1,totalPages:_?.data?.totalPages||1,totalItems:_?.data?.totalItems||0,itemsPerPage:_?.data?.itemsPerPage||Kr.pagination.defaultPageSize,hasNextPage:_?.data?.hasNextPage||!1,hasPreviousPage:_?.data?.hasPreviousPage||!1},isLoading:_?.isLoading??!0,isCreating:A?.isPending??!1,isUpdating:T?.isPending??!1,isDeleting:E?.isPending??!1,error:_?.error||null,searchTerm:x,sortField:g,sortDirection:b,currentPage:w,itemsPerPage:N,queryKey:e,createEntity:A.mutate,updateEntity:(e,t)=>T.mutate({id:e,data:t}),deleteEntity:E.mutate,save:H,handleSearch:M,handleSort:I,handlePageChange:D,handleItemsPerPageChange:R,clearFilters:L,refetch:_.refetch,selectedIds:z,selectItem:U,selectAll:q,clearSelection:O,isAllSelected:B,bulkDelete:e=>$.mutateAsync(e),isBulkDeleting:$.isPending}}function jn(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.useEffect(()=>{const t=window.matchMedia(e);s(t.matches);const a=e=>{s(e.matches)};return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),a}function Cn(e=768){return jn(`(max-width: ${e-1}px)`)}const kn=J.forwardRef(({className:t,...a},s)=>e.jsx("table",{ref:s,className:Aa("w-full caption-bottom text-sm table-fixed",t),...a}));kn.displayName="Table";const Sn=J.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:Aa("[&_tr]:border-b sticky top-0 z-[1] bg-background",t),...a}));Sn.displayName="TableHeader";const _n=J.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:Aa("[&_tr:last-child]:border-0",t),...a}));_n.displayName="TableBody";const An=J.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:Aa("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));An.displayName="TableFooter";const Tn=J.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:Aa("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",t),...a}));Tn.displayName="TableRow";const En=J.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:Aa("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",t),...a}));En.displayName="TableHead";const Pn=J.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:Aa("px-4 py-3 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",t),...a}));Pn.displayName="TableCell";const Mn=J.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:Aa("mt-4 text-sm text-muted-foreground",t),...a}));function In({rows:t=5,columns:a=4}){return e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"rounded-md border",children:[e.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-24"},a))})}),e.jsx("div",{children:Array.from({length:t}).map((t,s)=>e.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:e.jsx("div",{className:"flex space-x-4",children:Array.from({length:a}).map((t,a)=>e.jsx(fr,{className:"h-4 w-20"},a))})},s))})]})})}function Dn({count:t=3}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:t}).map((t,a)=>e.jsxs(La,{children:[e.jsxs(za,{children:[e.jsx(fr,{className:"h-4 w-3/4"}),e.jsx(fr,{className:"h-3 w-1/2"})]}),e.jsx(qa,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-3 w-full"}),e.jsx(fr,{className:"h-3 w-2/3"})]})})]},a))})}Mn.displayName="TableCaption";const Rn={default:l.FileX,search:l.Search,error:l.AlertCircle};function Ln({icon:t,title:a,description:s,action:r,className:n,variant:o="default"}){const i=!!t,l=Rn[o];return e.jsxs("div",{className:Aa("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:i?t:e.jsx(l,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:a}),s&&e.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&e.jsx(Pa,{onClick:r.onClick,variant:"outline",children:r.label})]})}function zn({children:t,className:a}){const s=J.useRef(null),[r,n]=J.useState(!1);J.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const t=new ResizeObserver(e);return s.current&&t.observe(s.current),()=>t.disconnect()},[t]);const o=e.jsx("div",{ref:s,className:`truncate w-full max-w-full ${a||""}`,children:t});return r?e.jsx(Js,{delayDuration:300,children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:o}),e.jsx(ar,{side:"top",className:"max-w-[400px] break-words",children:t})]})}):o}const Fn=J.forwardRef(({direction:t,onMouseDown:a,isDragging:s,className:r},n)=>{const o="horizontal"===t;return e.jsx("div",{ref:n,onMouseDown:a,className:Aa("absolute z-20 select-none touch-none","transition-colors duration-150",o&&["top-0 right-0 h-full w-2 -mr-1","cursor-col-resize","hover:bg-primary/20","group flex items-center justify-center"],!o&&["bottom-0 left-0 w-full h-2 -mb-1","cursor-row-resize","hover:bg-primary/20","group flex items-center justify-center"],s&&"bg-primary/30",r),children:e.jsx("div",{className:Aa("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Fn.displayName="TableResizeHandle";const Un=ce.Root,qn=ce.Trigger,On=ce.Group,Bn=ce.Portal,$n=ce.Sub,Hn=ce.RadioGroup,Vn=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(ce.SubTrigger,{ref:n,className:Aa("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Vn.displayName=ce.SubTrigger.displayName;const Wn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.SubContent,{ref:s,className:Aa("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Wn.displayName=ce.SubContent.displayName;const Gn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.Portal,{children:e.jsx(ce.Content,{ref:s,className:Aa("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}));Gn.displayName=ce.Content.displayName;const Yn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ce.Item,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Yn.displayName=ce.Item.displayName;const Qn=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(ce.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ce.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Qn.displayName=ce.CheckboxItem.displayName;const Kn=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(ce.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ce.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Kn.displayName=ce.RadioItem.displayName;const Xn=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(ce.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",t),...s}));Xn.displayName=ce.Label.displayName;const Zn=J.forwardRef(({className:t,...a},s)=>e.jsx(ce.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-border",t),...a}));Zn.displayName=ce.Separator.displayName;const Jn=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});Jn.displayName="ContextMenuShortcut";const eo=({onEdit:t,onDelete:a,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const d=[];if(t){const e={icon:l.Edit,label:"Editar",onClick:t};d.push(e)}if(o.forEach(e=>{d.push(e)}),s){const e={icon:r?l.PowerOff:l.Power,label:r?"Inativar":"Ativar",onClick:s};d.push(e)}if(n&&a){const e={icon:l.Trash2,label:"Excluir",onClick:a,destructive:!0};d.push(e)}const c="dropdown"===i?Gs:Yn;return e.jsx(e.Fragment,{children:d.map((t,a)=>e.jsxs(c,{onClick:t.onClick,className:Aa("whitespace-normal cursor-pointer",t.destructive&&"text-destructive focus:text-destructive"),children:[e.jsx(t.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.label]},a))})},to=({onEdit:t,onDelete:a,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:e.jsx(l.EllipsisVertical,{size:12})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:e.jsx(eo,{onEdit:t?e=>{e?.stopPropagation(),t?.()}:void 0,onDelete:a?e=>{e?.stopPropagation(),a?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!a,customActions:o,renderAs:"dropdown"})})]}),ao=150;function so({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,t)=>{r&&(t.preventDefault(),t.stopPropagation(),l(!0),c(e),u.current=t.clientX,m.current=n[e]??ao)},[r,n]);t.useEffect(()=>{if(!i||!d)return;const t=e.find(e=>e.key===d),r=t?.minWidth??60,n=t?.maxWidth??500,p=e=>{const t=e.clientX-u.current,a=Math.max(r,Math.min(n,m.current+t));o(e=>{const t={...e,[d]:a};return s?.(t),t})},h=()=>{l(!1),c(null),a&&o(e=>(localStorage.setItem(a,JSON.stringify(e)),e))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}},[i,d,e,a,s]),t.useEffect(()=>(i?(document.body.style.cursor="col-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[i]);const h=t.useCallback(()=>{const t=e.reduce((e,t)=>(e[t.key]=t.defaultWidth??ao,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}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"}}),no=J.forwardRef(({className:t,variant:a,size:s,...r},n)=>e.jsx(me.Root,{ref:n,className:Aa(ro({variant:a,size:s,className:t})),...r}));no.displayName=me.Root.displayName;const oo=J.createContext({size:"default",variant:"default"}),io=J.forwardRef(({className:t,variant:a,size:s,children:r,...n},o)=>e.jsx(ue.Root,{ref:o,className:Aa("flex items-center justify-center gap-1",t),...n,children:e.jsx(oo.Provider,{value:{variant:a,size:s},children:r})}));io.displayName=ue.Root.displayName;const lo=J.forwardRef(({className:t,children:a,variant:s,size:r,...n},o)=>{const i=J.useContext(oo);return e.jsx(ue.Item,{ref:o,className:Aa(ro({variant:i.variant||s,size:i.size||r}),t),...n,children:a})});lo.displayName=ue.Item.displayName;const co=t.memo(function({onNew:t,newButtonLabel:a,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:d=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:f,viewMode:x,onViewModeChange:g,showViewToggle:b=!1,availableViewModes:v=["table","list","grid"],className:w}){const N=t&&s||d||h.length>0,y=f||b,j=r&&o;return N||j||y?e.jsxs("div",{className:Aa("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t&&s&&e.jsxs(Pa,{onClick:t,children:[e.jsx(l.Plus,{size:16,className:"mr-2"}),a||"Novo"]}),d&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",children:["Ações em lote",c>0&&e.jsx(Ds,{variant:"secondary",className:"ml-2",children:c}),e.jsx(l.ChevronDown,{size:16,className:"ml-2"})]})}),e.jsxs(Ws,{align:"start",children:[u.length>0?u.map((t,a)=>{const s=t.icon,r=0===c||t.disabled;return e.jsxs(Gs,{onClick:()=>!r&&t.action([]),disabled:r,className:"destructive"===t.variant?"text-destructive":void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)}):e.jsxs(Gs,{onClick:m,disabled:0===c,className:"text-destructive",children:[e.jsx(l.Trash2,{size:16,className:"mr-2"}),"Excluir"]}),c>0&&e.jsxs(e.Fragment,{children:[e.jsx(Xs,{}),e.jsxs(Gs,{onClick:p,children:[e.jsx(l.X,{size:16,className:"mr-2"}),"Limpar seleção"]})]})]})]}),h.map((t,a)=>{const s=t.icon;return e.jsxs(Pa,{onClick:t.action,variant:t.variant||"outline",disabled:t.disabled,title:t.disabled?t.disabledReason:void 0,children:[s&&e.jsx(s,{size:16,className:"mr-2"}),t.label]},a)})]}),j&&e.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),y&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[f,b&&x&&g&&e.jsx(io,{type:"single",value:x,onValueChange:e=>e&&g(e),size:"sm",children:v.map(t=>{const a=(e=>{switch(e){case"table":return l.Table2;case"list":return l.List;case"grid":return l.LayoutGrid}})(t);return e.jsx(lo,{value:t,"aria-label":"Visualizar como "+("table"===t?"tabela":"list"===t?"lista":"grade"),children:e.jsx(a,{className:"h-4 w-4"})},t)})})]})]}):null}),uo=t.memo(({checked:t,onCheckedChange:a})=>e.jsx(Ps,{checked:t,onCheckedChange:a}),(e,t)=>e.checked===t.checked),mo=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:f=[],hideActionBar:x,showActionBar:g=!0,showSearch:b=!1,searchValue:v,onSearchChange:w,searchPlaceholder:N,bulkActions:y=[],onBulkDelete:j,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_=!1,enableColumnResize:A=!0,resizeStorageKey:T})=>{const{setSearchVisible:E}=Nn(),P=Cn(),M=void 0!==x?!x:g;t.useEffect(()=>{if(!b)return E(!0),()=>E(!1)},[E,b]);const{columnWidths:I,isDragging:D,activeColumn:R,handleMouseDown:L}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:500,defaultWidth:e.width??e.minWidth??150})),storageKey:T?`${T}-columns`:void 0,enabled:A}),z=t.useMemo(()=>(()=>{if(A)return s.map(e=>{const t=I[String(e.key)]??e.width??e.minWidth??150;return{...e,calculatedWidth:t,style:{width:`${t}px`}}});let e=0;const t=s.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const a=t.minWidth||120,s=t.weight||1;return e+=a,{...t,calculatedWidth:a,weight:s,isFixed:!1}}});return e+=50,t.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[s,A,I]),F=m||f.length>0||b||u||C||_,U=M&&F,q=j||(()=>{a.bulkDelete?.(a.selectedIds)});return P?a.isLoading?e.jsx(Dn,{count:3}):0===a.entities.length?e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),e.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsx(La,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:e.jsx(qa,{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(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1",children:[s.map(a=>e.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||d)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(t):e.jsx(to,{onEdit:r?()=>{r(t)}:void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})]})})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[U&&e.jsx(co,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:b,searchValue:v,onSearchChange:w,searchPlaceholder:N,showBulkActions:u,selectedCount:a.selectedIds.length,bulkActions:y,onBulkDelete:q,onClearSelection:a.clearSelection,customActions:f,filters:C,viewMode:k,onViewModeChange:S,showViewToggle:_}),a.isLoading?e.jsx(In,{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(kn,{className:"table-auto",children:[e.jsxs("colgroup",{children:[u&&e.jsx("col",{style:{width:"50px"}}),z.map((t,a)=>e.jsx("col",{style:t.style},a)),e.jsx("col",{style:{width:"50px"}})]}),e.jsx(Sn,{children:e.jsxs(Tn,{children:[u&&e.jsx(En,{className:"w-[50px]",children:e.jsx(uo,{checked:a.isAllSelected,onCheckedChange:a.selectAll})}),s.map(t=>{const s=A&&!1!==t.resizable,r=R===String(t.key);return e.jsxs(En,{className:Aa(t.className,t.sortable&&"cursor-pointer hover:bg-muted/50","relative"),onClick:t.sortable?()=>a.handleSort(String(t.key)):void 0,children:[e.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),a.sortField!==n?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===a.sortDirection?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>L(String(t.key),e),isDragging:r})]},String(t.key));var n}),e.jsx(En,{className:"w-[50px] text-center",children:"Ações"})]})}),e.jsx(_n,{children:0===a.entities.length?e.jsx(Tn,{children:e.jsx(Pn,{colSpan:u?s.length+2:s.length+1,className:"h-32",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):a.entities.map(t=>e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:e.jsxs(Tn,{className:Aa("cursor-pointer hover:bg-muted/50 relative",u&&a.selectedIds.includes(t.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),u?a.selectItem(t.id):r?.(t)},children:[u&&e.jsx(Pn,{onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"")})},String(a.key))),e.jsx(Pn,{className:"text-center",children:d?d(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:c?c(t):[]})})]})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:c?c(t):[],renderAs:"context"})})]},t.id))})]})})})]})};function po(e,a,s,r){const[n,o]=t.useState({}),[i,l]=t.useState({}),d=t.useMemo(()=>e,[e]),c=e=>e instanceof Date&&!isNaN(e.getTime()),u=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},m=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(a){return u(e)}},p=(e,t,a)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(t,a);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=t=>{const a=[];return t.forEach(t=>{a.push(t),t.fields&&a.push(...e(t.fields))}),a},t=e(d),n={};t.forEach(e=>{let t;if(a&&void 0!==a[e.name]){if(t=a[e.name],null==t&&(t=""),"date"===e.type&&t)if("string"==typeof t){const e=new Date(t);c(e)&&(t=e.toISOString().split("T")[0])}else c(t)&&(t=t.toISOString().split("T")[0])}else t=u(e);n[e.name]=t}),t.forEach(e=>{const t=m(e,n);void 0!==t&&(n[e.name]=t)}),a&&Object.keys(a).forEach(e=>{t.find(t=>t.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...h(e.fields))}),t},f=()=>{const e=h(d),t={};return e.forEach(e=>{const a=p(e,n[e.name],n);a&&(t[e.name]=a)}),l(t),0===Object.keys(t).length};return{formData:n,errors:i,updateField:(e,t)=>{o(a=>{const r={...a,[e]:t},n=((e,t)=>{let a={...t};const s=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...s(e.fields))}),t};return s(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=m(e,a);void 0!==t&&(a={...a,[e.name]:t})}),a})(e,r);return s&&s(n),n}),i[e]&&l(t=>{const a={...t};return delete a[e],a});const a=h(d).find(t=>t.name===e);if(a){const s=p(a,t,n);s&&l(t=>({...t,[e]:s}))}},validateForm:f,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),f()&&e(n)}}}const ho=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],fo=({value:t="#3b82f6",onChange:a,label:s,customColorLabel:r="Cor personalizada",presetColorsLabel:n="Cores predefinidas"})=>e.jsxs("div",{className:"space-y-2",children:[s&&e.jsx(Ra,{children:s}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:t}}),t]})}),e.jsx(or,{className:"w-64",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"color-input",children:r}),e.jsx(Ia,{id:"color-input",type:"color",value:t,onChange:e=>a?.(e.target.value),className:"h-10 w-full"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:n}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:ho.map(t=>e.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:t},onClick:()=>a?.(t),"aria-label":`Selecionar cor ${t}`},t))})]})]})})]})]}),xo={Star:l.Star,Heart:l.Heart,Home:l.Home,User:l.User,Settings:l.Settings,Mail:l.Mail,Phone:l.Phone,Calendar:l.Calendar,MapPin:l.MapPin,Camera:l.Camera,Image:l.Image,Music:l.Music,Video:l.Video,Book:l.Book,Bookmark:l.Bookmark,Search:l.Search,Filter:l.Filter,Edit:l.Edit,Trash2:l.Trash2,Plus:l.Plus,Minus:l.Minus,Check:l.Check,X:l.X,ChevronDown:l.ChevronDown,ChevronUp:l.ChevronUp,ChevronLeft:l.ChevronLeft,ChevronRight:l.ChevronRight,ArrowUp:l.ArrowUp,ArrowDown:l.ArrowDown,ArrowLeft:l.ArrowLeft,ArrowRight:l.ArrowRight,Clock:l.Clock,Bell:l.Bell,AlertCircle:l.AlertCircle,Info:l.Info,HelpCircle:l.HelpCircle,Download:l.Download,Upload:l.Upload,Share:l.Share,Copy:l.Copy,Save:l.Save,FileText:l.FileText,Folder:l.Folder,FolderOpen:l.FolderOpen,Archive:l.Archive,Lock:l.Lock,Unlock:l.Unlock,Eye:l.Eye,EyeOff:l.EyeOff,Shield:l.Shield,Key:l.Key,Zap:l.Zap,Flame:l.Flame,Sparkles:l.Sparkles,Award:l.Award,Trophy:l.Trophy,Target:l.Target},go=({value:a="Star",onChange:s,label:r,searchLabel:n="Pesquisar"})=>{const[o,i]=t.useState(""),d=Object.entries(xo).filter(([e])=>e.toLowerCase().includes(o.toLowerCase())),c=xo[a]||l.Star;return e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(Ra,{children:r}),e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),a]})}),e.jsx(or,{className:"w-80",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Ra,{htmlFor:"icon-search",children:n}),e.jsx(Ia,{id:"icon-search",placeholder:n,value:o,onChange:e=>i(e.target.value)})]}),e.jsx(vr,{className:"h-48",children:e.jsx("div",{className:"grid grid-cols-6 gap-2",children:d.map(([t,r])=>e.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(a===t?"border-primary bg-primary/10":"border-border"),onClick:()=>s?.(t),title:t,children:e.jsx(r,{className:"h-4 w-4"})},t))})})]})})]})]})},bo=J.forwardRef(({className:t,...a},s)=>e.jsx(pe.Root,{className:Aa("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...a,ref:s,children:e.jsx(pe.Thumb,{className:Aa("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")})}));bo.displayName=pe.Root.displayName;const vo=(e={})=>{const{user:t,alias:a}=Nn(),{enabled:s=!0}=e;return y.useQuery({queryKey:["qualiex-users",a],queryFn:()=>sn.getUsers(a),enabled:s&&!!a&&!!t,staleTime:3e5,retry:2,retryDelay:1e3})},wo=({value:a,onChange:s,multiple:r=!1,label:n,required:o,placeholder:i,icon:l,maxDisplayedBadges:d,className:c,disabled:u,enabled:m,displayFormat:p="name",customDisplayFn:h,filterFn:f,sortOptions:x=!0,popoverContainer:g,onOpen:b,onClose:v})=>{const{data:w=[],isLoading:N,error:y}=vo({enabled:m}),j=t.useMemo(()=>f?w.filter(f):w,[w,f]),C=t.useCallback(e=>{if("custom"===p&&h)return h(e);const t=e.userName||"";switch(p){case"name-email":return e.userEmail?`${t} (${e.userEmail})`:t;case"name-role":return e.roleName?`${t} - ${e.roleName}`:t;default:return t}},[p,h]);return e.jsx(br,{multiple:r,value:a??(r?[]:""),onChange:s,options:j,isLoading:N,error:y,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:C,placeholder:i||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:"Nenhum resultado encontrado",label:n,required:o,icon:l,maxDisplayedBadges:d,disabled:u,className:c,sortOptions:x,popoverContainer:g,onOpen:b,onClose:v})};function No({title:a,sections:s,initialData:r,onSubmit:n,onCancel:o,open:i,submitButtonText:l,isLoading:d=!1,usersData:c}){const[u,m]=t.useState(s?.[0]?.id||""),p=t.useRef(null),[h,f]=t.useState(null),x=t.useCallback(e=>{p.current=e,f(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:b,errors:v,updateField:w,handleSubmit:N}=po(g,r,void 0,i),y=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(b):e.disabled||!1})):[],[s,b]),j=t.useMemo(()=>{const e=y.find(e=>e.id===u);if(e&&!e.disabled)return u;const t=y.find(e=>!e.disabled);return t?.id||u},[y,u]);t.useEffect(()=>{j!==u&&m(j)},[j,u]);const C=y.find(e=>e.id===j),k=t=>{const a=(t.computedValue,b[t.name]),s=void 0!==a?a:"",r=v[t.name];switch(t.type){case"group":const a="horizontal"===t.layout,n=a?`flex gap-3 w-full ${t.className||""}`:"space-y-3",o=a?Aa("space-y-2 w-full",t.wrapperClassName):Aa("space-y-2",t.className,t.wrapperClassName);return e.jsxs("div",{className:o,children:[t.label,e.jsx("div",{className:n,children:t.fields?.map(e=>k(e))})]},t.name);case"user-select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(wo,{value:s||"",onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,className:r?"border-destructive":""}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"textarea":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ms,{id:t.name,value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,rows:t.rows,maxLength:t.maxLength,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"select":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ns,{value:String(s),onValueChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,children:[e.jsx(Cs,{className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options?.map(t=>e.jsx(Ts,{value:t.value,children:t.label},t.value))})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"multiselect":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(br,{options:t.options||[],value:Array.isArray(s)?s:[],onChange:e=>w(t.name,e),placeholder:t.placeholder,disabled:t.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"date":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"date",value:String(s),onChange:e=>w(t.name,e.target.value),placeholder:t.placeholder,disabled:t.disabled,className:Aa("w-full",r?"border-destructive":"",t.disabled?"bg-muted cursor-not-allowed":"")}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"color":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"color",value:s||t.defaultValue||"#000000",onChange:e=>w(t.name,e.target.value),className:"h-10"}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"color-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fo,{value:s||t.defaultValue||"#3b82f6",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"icon-picker":return e.jsxs("div",{children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(go,{value:s||t.defaultValue||"Star",onChange:e=>w(t.name,e)}),r&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},t.name);case"custom":if(!t.component)return null;const i=t.component,l="function"==typeof t.componentProps?t.componentProps(b):t.componentProps||{};return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[t.label&&e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(i,{value:s,onChange:e=>{w(t.name,e),t.onValueChange&&t.onValueChange(e)},disabled:t.disabled,error:r,popoverContainer:h,...l}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"number":return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"number",value:null!=s?String(s):"",onChange:e=>{const a=e.target.value,s=""===a?null:Number(a);w(t.name,s)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,min:t.min,step:t.step||"1"}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"checkbox":return e.jsxs("div",{className:`flex items-center space-x-2 ${t.className||""}`,children:[e.jsx(Ps,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),e.jsxs(Ra,{htmlFor:t.name,className:"cursor-pointer",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name);case"switch":return e.jsxs("div",{className:`flex items-center justify-between space-x-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(bo,{id:t.name,checked:!!s,onCheckedChange:e=>w(t.name,e),disabled:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},t.name);default:return e.jsxs("div",{className:`space-y-2 ${t.className||""}`,children:[e.jsxs(Ra,{htmlFor:t.name,children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(Ia,{id:t.name,type:"text",value:s||"",onChange:e=>{w(t.name,e.target.value)},placeholder:t.placeholder,disabled:t.disabled,className:`${r?"border-destructive":""} ${t.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:t.disabled}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]},t.name)}},S=t.useCallback(()=>{if(!C)return null;if(C.disabled)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:e.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(C.component){const t=C.component;return e.jsx(t,{formData:b,updateField:w,errors:v,users:c,disabled:C.disabled})}return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:C.fields.map(k)})},[C,b,w,v,c,k]),_=e.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[y.length>1&&e.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:e.jsx("div",{className:"flex space-x-2",children:y.map(t=>e.jsx(Pa,{variant:j===t.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=y.find(t=>t.id===e);t&&!t.disabled&&m(e)})(t.id),disabled:t.disabled,className:t.disabled?"opacity-50 cursor-not-allowed":"",children:t.title},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):e.jsxs("form",{onSubmit:N(n),className:"space-y-3 md:space-y-4",children:[S(),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(Pa,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),e.jsx(Pa,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return e.jsx(es,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:e.jsxs(os,{ref:x,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[e.jsxs(is,{showSeparator:!0,children:[e.jsx(cs,{children:a}),e.jsx(us,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),_]})})}function yo({currentPage:t,totalPages:a,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:d}=v.useTranslation();if(0===s)return null;const c=(t-1)*r+1,u=Math.min(t*r,s);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:d("rows_per_page","Linhas por página")}),e.jsxs(Ns,{value:String(r),onValueChange:e=>o(Number(e)),children:[e.jsx(Cs,{className:"h-8 w-[70px]",children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"10",children:"10"}),e.jsx(Ts,{value:"25",children:"25"}),e.jsx(Ts,{value:"50",children:"50"}),e.jsx(Ts,{value:"100",children:"100"})]})]})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",d("of","de")," ",s," ",d("items","itens")]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsLeft,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t-1),disabled:1===t,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronLeft,{size:16})}),e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("span",{className:"text-sm text-muted-foreground",children:d("of","de")}),e.jsx("span",{className:"text-sm font-medium",children:a})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(t+1),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronRight,{size:16})}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:()=>n(a),disabled:t===a,className:"h-8 w-8 p-0",children:e.jsx(l.ChevronsRight,{size:16})})]})]})}function jo({manager:t}){return e.jsx(yo,{currentPage:t.pagination.currentPage,totalPages:t.pagination.totalPages,totalItems:t.pagination.totalItems,itemsPerPage:t.pagination.itemsPerPage,onPageChange:t.handlePageChange,onItemsPerPageChange:t.handleItemsPerPageChange,variant:"full"})}const Co={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},ko={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},So={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function _o({children:t,direction:a="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return e.jsx("div",{className:Aa("flex","column"===a?"flex-col":"flex-row",Co[s],ko[r],So[n],o&&"flex-wrap",i),children:t})}function Ao({manager:t,filters:a,inline:s=!1}){const{isSearchVisible:r}=Nn(),n=t.searchTerm,o=e.jsxs(e.Fragment,{children:[a.some(e=>"search"===e.type)&&!r&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:t.searchTerm,onChange:e=>t.handleSearch(e.target.value),className:"pl-10"})]}),a.filter(e=>"select"===e.type&&e.options).map((t,a)=>e.jsxs(Ns,{value:t.value||"",onValueChange:e=>t.onChange?.(e),children:[e.jsx(Cs,{className:"w-[180px]",children:e.jsx(js,{placeholder:t.placeholder})}),e.jsx(_s,{children:t.options.map(t=>e.jsx(Ts,{value:t.value,children:t.label},t.value))})]},`select-${a}`)),a.filter(e=>"custom"===e.type&&e.component).map((t,a)=>{const r=t.component;return e.jsx("div",{className:s?"":"w-full sm:w-auto",children:e.jsx(r,{...t.props})},`custom-${a}`)}),n&&e.jsxs(Pa,{variant:"outline",onClick:t.clearFilters,className:"whitespace-nowrap",children:[e.jsx(l.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?e.jsx("div",{className:"flex items-center gap-2",children:o}):e.jsx(_o,{direction:"column",gap:"md",className:"mb-6",children:e.jsx(_o,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:o})})}function To({manager:a,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){a&&a.queryKey;const{setSearchVisible:l}=Nn(),[d,c]=j.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[f,x]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,b]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&a){const e=`${a.queryKey}_sortField`,t=`${a.queryKey}_sortDirection`;if(!d.has(e)&&!d.has(t)){const a=Object.fromEntries(d);a[e]=i.column,a[t]=i.direction,c(a)}}},[]);const v=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,w="function"==typeof a?.deleteEntity?e=>{x({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,N=()=>{x({isOpen:!1,entityId:null,entityName:""})},y=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,C=(s.customActions||[]).map(e=>({label:e.label,icon:e.icon,action:e.action,variant:"destructive"===e.variant?"default":e.variant,disabled:e.disabled,disabledReason:e.disabledReason}));return e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&e.jsx(co,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:y,showSearch:s.showSearch,searchValue:a.searchTerm,onSearchChange:a.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:a.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{b({isOpen:!0,count:a.selectedIds.length})},onClearSelection:a.clearSelection,customActions:C,filters:s.filters&&s.filters.length>0?e.jsx(Ao,{manager:a,filters:s.filters,inline:!0}):void 0}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?e.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(a.entities,a)}):e.jsx(mo,{manager:a,columns:s.columns,onEdit:v,onDelete:w,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions})}),e.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:e.jsx(jo,{manager:a})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&e.jsx(No,{open:u,title:p?`Editar ${s.entityName}`:`Novo ${s.entityName}`,sections:r,initialData:p||void 0,onSubmit:e=>{n(e),m(!1),h(null)},onCancel:()=>{m(!1),h(null)},isLoading:a.isLoading,submitButtonText:p?"Atualizar":"Criar"}),e.jsx(es,{open:f.isOpen,onOpenChange:N,children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:f.entityName}),". Esta ação não pode ser desfeita."]})}),e.jsxs(ds,{children:[e.jsx(Pa,{variant:"outline",onClick:N,children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{f.entityId&&"function"==typeof a?.deleteEntity&&(a.deleteEntity(f.entityId),x({isOpen:!1,entityId:null,entityName:""}))},disabled:a.isDeleting,children:a.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),e.jsx(es,{open:g.isOpen,onOpenChange:()=>b({isOpen:!1,count:0}),children:e.jsxs(os,{size:"sm",variant:"destructive",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:"Você tem certeza absoluta?"})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",e.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),e.jsxs(ds,{children:[e.jsx(Pa,{variant:"outline",onClick:()=>b({isOpen:!1,count:0}),children:"Cancelar"}),e.jsx(Pa,{variant:"destructive",onClick:()=>{a.bulkDelete?.(a.selectedIds),b({isOpen:!1,count:0})},disabled:a.isBulkDeleting,children:a.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Eo(e,t){const a=e.toLowerCase();return a.includes("email")?{type:"email",required:!0}:a.includes("phone")||a.includes("tel")?{type:"tel"}:a.includes("description")||a.includes("content")||a.includes("notes")?{type:"textarea"}:a.includes("status")||a.includes("type")||a.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Po(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Mo=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"}}),Io={info:l.Info,warning:l.Info,danger:l.AlertTriangle,success:l.CheckCircle},Do=J.forwardRef(({className:t,variant:a="info",showIcon:s=!0,children:r,...n},o)=>{const i=Io[a||"info"];return e.jsxs("div",{ref:o,role:"alert",className:Aa(Mo({variant:a}),t),...n,children:[s&&e.jsx(i,{className:"h-4 w-4"}),r]})});Do.displayName="Alert";const Ro=J.forwardRef(({className:t,...a},s)=>e.jsx("h5",{ref:s,className:Aa("mb-1 font-medium leading-none tracking-tight",t),...a}));Ro.displayName="AlertTitle";const Lo=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("text-sm [&_p]:leading-relaxed",t),...a}));Lo.displayName="AlertDescription";const zo=t.createContext(void 0);function Fo({children:a,actions:s}){const[r,n]=t.useState({}),[o,i]=t.useState(s);t.useEffect(()=>{i(s)},[s]);const l=t.useCallback(()=>n({}),[]),d=t.useMemo(()=>({metadata:r,setMetadata:n,clearMetadata:l,headerActions:o,setHeaderActions:i}),[r,l,o]);return e.jsx(zo.Provider,{value:d,children:a})}function Uo(){const e=t.useContext(zo);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var qo={access_denied:{pt:"Acesso negado",en:"Access denied",es:""},actions:{pt:"Ações",en:"Actions",es:"Acciones"},activate:{pt:"Ativar",en:"Activate",es:"Activar"},activate_selected:{pt:"Ativar Selecionados",en:"Activate Selected",es:"Activar Seleccionados"},active:{pt:"Ativo",en:"Active",es:"Activo"},active_employees:{pt:"Colaboradores Ativos",en:"Active Employees",es:"Empleados Activos"},active_plural:{pt:"Ativos",en:"Active",es:"Activos"},add:{pt:"Adicionar",en:"Add",es:"Agregar"},additional_fields:{pt:"Campos Adicionais",en:"Additional Fields",es:"Campos Adicionales"},address:{pt:"Endereço",en:"Address",es:"Dirección"},admin:{pt:"Admin",en:"Admin",es:"Admin"},admin_access:{pt:"Acesso Admin",en:"Admin Access",es:"Acceso Admin"},admin_system:{pt:"Administração do Sistema",en:"System Administration",es:"Administración del Sistema"},admission_date:{pt:"Data de Admissão",en:"Admission Date",es:"Fecha de Admisión"},alignment:{pt:"Alinhamento",en:"Alignment",es:"Alineación"},all:{pt:"Todos",en:"All",es:"Todos"},allow_download:{pt:"Permitir Download",en:"Allow Download",es:"Permitir Descarga"},allowed_formats:{pt:"Formatos permitidos",en:"Allowed formats",es:"Formatos permitidos"},alt:{pt:"Texto Alternativo",en:"Alt Text",es:"Texto Alternativo"},api_response:{pt:"Resposta da API:",en:"API Response:",es:"Respuesta de la API:"},apply_filters:{pt:"Aplicar filtros",en:"Apply filters",es:"Aplicar filtros"},auth_required:{pt:"Autenticação necessária",en:"Authentication required",es:"Autenticación requerida"},autoplay:{pt:"Reprodução Automática",en:"Autoplay",es:"Reproducción Automática"},back:{pt:"Voltar",en:"Back",es:"Volver"},background_color:{pt:"Cor do Fundo",en:"Background Color",es:"Color de Fondo"},birth_date:{pt:"Data de Nascimento",en:"Birth Date",es:"Fecha de Nacimiento"},boolean:{pt:"Booleano",en:"Boolean",es:"Booleano"},bulk_actions:{pt:"Ações em lote",en:"Bulk actions",es:"Acciones masivas"},cancel:{pt:"Cancelar",en:"Cancel",es:"Cancelar"},cancelled:{pt:"Cancelado",en:"Cancelled",es:"Cancelado"},caption:{pt:"Legenda",en:"Caption",es:"Leyenda"},center:{pt:"Centro",en:"Center",es:"Centro"},chatbot:{pt:"Chatbot",en:"Chatbot",es:"Chatbot"},checking_access:{pt:"Verificando acesso...",en:"Checking access...",es:"Verificando acceso..."},choose_file:{pt:"Escolher arquivo",en:"Choose file",es:"Elegir archivo"},city:{pt:"Cidade",en:"City",es:"Ciudad"},clear:{pt:"Limpar",en:"Clear",es:"Limpiar"},clear_filters:{pt:"Limpar filtros",en:"Clear filters",es:"Limpiar filtros"},clear_search:{pt:"Limpar busca",en:"Clear search",es:"Limpiar búsqueda"},clear_selection:{pt:"Limpar seleção",en:"Clear selection",es:"Limpiar selección"},click_to_create_post:{pt:"Clique no botão abaixo para criar um novo post",en:"Click the button below to create a new post",es:"Haga clic en el botón de abajo para crear una nueva publicación"},close:{pt:"Fechar",en:"Close",es:"Cerrar"},collaborator:{pt:"Colaborador",en:"Collaborator",es:"Colaborador"},config:{pt:"Configuração",en:"Configuration",es:"Configuración"},config_info:{pt:"Informações da Configuração",en:"Configuration Info",es:"Información de Configuración"},config_info_description:{pt:"Defina a chave e o valor da configuração",en:"Set the configuration key and value",es:"Defina la clave y el valor de la configuración"},config_key:{pt:"Chave da Configuração",en:"Configuration Key",es:"Clave de Configuración"},configs:{pt:"Configurações",en:"Configurations",es:"Configuraciones"},comments:{pt:"Comentários",en:"Comments",es:"Comentarios"},community:{pt:"Comunidade",en:"Community",es:"Comunidad"},community_posts:{pt:"Posts da comunidade",en:"Community posts",es:"Publicaciones de la comunidad"},companies:{pt:"Empresas",en:"Companies",es:"Empresas"},company:{pt:"Empresa",en:"Company",es:"Empresa"},completed:{pt:"Concluído",en:"Completed",es:"Completado"},confirm:{pt:"Confirmar",en:"Confirm",es:"Confirmar"},confirm_delete:{pt:"Tem certeza que deseja excluir?",en:"Are you sure you want to delete?",es:"¿Está seguro de que desea eliminar?"},confirm_delete_message:{pt:"Esta ação não pode ser desfeita.",en:"This action cannot be undone.",es:"Esta acción no se puede deshacer."},confirm_password:{pt:"Confirmar Senha",en:"Confirm Password",es:"Confirmar Contraseña"},content:{pt:"Conteúdo",en:"Content",es:"Contenido"},content_blocks:{pt:"Blocos de Conteúdo",en:"Content Blocks",es:"Bloques de Contenido"},controls:{pt:"Controles",en:"Controls",es:"Controles"},copy:{pt:"Copiar",en:"Copy",es:"Copiar"},country:{pt:"País",en:"Country",es:"País"},courses:{pt:"Cursos",en:"Courses",es:"Cursos"},create:{pt:"Criar",en:"Create",es:"Crear"},create_first_post_hint:{pt:'Crie seu primeiro post na aba "Criar Post"',en:'Create your first post in the "Create Post" tab',es:'Crea tu primera publicación en la pestaña "Crear Publicación"'},create_post:{pt:"Criar Novo Post",en:"Create New Post",es:"Crear Nueva Publicación"},create_success:{pt:"Criado com sucesso",en:"Created successfully",es:"Creado exitosamente"},create_unit:{pt:"Criar Nova Unidade",en:"Create New Unit",es:"Crear Nueva Unidad"},created_at:{pt:"Criado em",en:"Created at",es:"Creado en"},created_by:{pt:"Criado por",en:"Created by",es:"Creado por"},currency:{pt:"Moeda",en:"Currency",es:"Moneda"},dashboard:{pt:"Dashboard",en:"Dashboard",es:"Panel"},date:{pt:"Data",en:"Date",es:"Fecha"},date_and_time:{pt:"Data e Hora",en:"Date and Time",es:"Fecha y Hora"},date_format:{pt:"Formato de Data",en:"Date Format",es:"Formato de Fecha"},date_time_format:{pt:"Formato de Data/Hora",en:"Date/Time Format",es:"Formato de Fecha/Hora"},deactivate:{pt:"Inativar",en:"Deactivate",es:"Desactivar"},deactivate_selected:{pt:"Inativar Selecionados",en:"Deactivate Selected",es:"Desactivar Seleccionados"},default:{pt:"Padrão",en:"Default",es:"Por Defecto"},delete:{pt:"Excluir",en:"Delete",es:"Eliminar"},delete_confirmation:{pt:"Confirmação de Exclusão",en:"Delete Confirmation",es:"Confirmación de Eliminación"},delete_success:{pt:"Excluído com sucesso",en:"Deleted successfully",es:"Eliminado exitosamente"},deleting:{pt:"Excluindo...",en:"Deleting...",es:"Eliminando..."},department:{pt:"Departamento",en:"Department",es:"Departamento"},description:{pt:"Descrição",en:"Description",es:"Descripción"},deselect_all:{pt:"Desselecionar todos",en:"Deselect all",es:"Deseleccionar todo"},design_system:{pt:"Design System",en:"Design System",es:"Sistema de Diseño"},design_tokens_and_docs:{pt:"Design tokens e documentação",en:"Design tokens and documentation",es:"Tokens de diseño y documentación"},details:{pt:"Detalhes",en:"Details",es:"Detalles"},disabled:{pt:"Desabilitado",en:"Disabled",es:"Deshabilitado"},download:{pt:"Baixar",en:"Download",es:"Descargar"},drag_drop:{pt:"Arraste e solte ou clique para selecionar",en:"Drag and drop or click to select",es:"Arrastre y suelte o haga clic para seleccionar"},duplicate:{pt:"Duplicar",en:"Duplicate",es:"Duplicar"},edit:{pt:"Editar",en:"Edit",es:"Editar"},edit_additional_fields:{pt:"Editar Campos Adicionais",en:"Edit Additional Fields",es:"Editar Campos Adicionales"},editor_hint:{pt:"💡 Dica: Use Ctrl+B (negrito), Ctrl+I (itálico), Ctrl+U (sublinhado) ou clique nos botões.",en:"💡 Hint: Use Ctrl+B (bold), Ctrl+I (italic), Ctrl+U (underline) or click the buttons.",es:"💡 Consejo: Use Ctrl+B (negrita), Ctrl+I (cursiva), Ctrl+U (subrayado) o haga clic en los botones."},education:{pt:"Educação",en:"Education",es:"Educación"},email:{pt:"E-mail",en:"Email",es:"Correo electrónico"},email_placeholder:{pt:"email@empresa.com",en:"email@company.com",es:"email@empresa.com"},embed:{pt:"Código Embed",en:"Embed Code",es:"Código Embed"},employee:{pt:"Colaborador",en:"Employee",es:"Empleado"},employee_activated:{pt:"Colaborador ativado com sucesso",en:"Employee activated successfully",es:"Empleado activado exitosamente"},employee_deactivated:{pt:"Colaborador inativado com sucesso",en:"Employee deactivated successfully",es:"Empleado desactivado exitosamente"},employee_information:{pt:"Informações do Colaborador",en:"Employee Information",es:"Información del Empleado"},employees:{pt:"Colaboradores",en:"Employees",es:"Empleados"},employees_removed:{pt:"{{count}} colaborador(es) removido(s)",en:"{{count}} employee(s) removed",es:"{{count}} empleado(s) eliminado(s)"},empty_description:{pt:"Não há dados para exibir no momento.",en:"There is no data to display at this time.",es:"No hay datos para mostrar en este momento."},empty_title:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},en:{pt:"EN",en:"EN",es:"EN"},enabled:{pt:"Habilitado",en:"Enabled",es:"Habilitado"},enter_full_name:{pt:"Digite o nome completo",en:"Enter full name",es:"Ingrese el nombre completo"},enter_link_url:{pt:"Digite a URL do link:",en:"Enter link URL:",es:"Ingrese la URL del enlace:"},enter_youtube_url:{pt:"Cole a URL do vídeo do YouTube:",en:"Paste YouTube video URL:",es:"Pegue la URL del video de YouTube:"},error:{pt:"Erro",en:"Error",es:"Error"},error_changing_employee_status:{pt:"Erro ao alterar status do colaborador",en:"Error changing employee status",es:"Error al cambiar el estado del empleado"},error_creating:{pt:"Erro ao criar",en:"Error creating",es:"Error al crear"},error_deleting:{pt:"Erro ao excluir",en:"Error deleting",es:"Error al eliminar"},error_loading:{pt:"Erro ao carregar",en:"Error loading",es:"Error al cargar"},error_no_image:{pt:"Nenhuma imagem selecionada",en:"No image selected",es:"Ninguna imagen seleccionada"},error_no_video:{pt:"Nenhum vídeo selecionado",en:"No video selected",es:"Ningún video seleccionado"},error_saving:{pt:"Erro ao salvar",en:"Error saving",es:"Error al guardar"},error_updating:{pt:"Erro ao atualizar",en:"Error updating",es:"Error al actualizar"},es:{pt:"ES",en:"ES",es:"ES"},export:{pt:"Exportar",en:"Export",es:"Exportar"},failed:{pt:"Falhou",en:"Failed",es:"Fallido"},field_name:{pt:"Nome do Campo",en:"Field Name",es:"Nombre del Campo"},field_type:{pt:"Tipo",en:"Type",es:"Tipo"},file:{pt:"Arquivo de Vídeo",en:"Video File",es:"Archivo de Video"},file_upload_error:{pt:"Erro ao enviar arquivo",en:"Error uploading file",es:"Error al cargar el archivo"},file_upload_success:{pt:"Arquivo enviado com sucesso",en:"File uploaded successfully",es:"Archivo cargado exitosamente"},filter:{pt:"Filtrar",en:"Filter",es:"Filtrar"},first_name:{pt:"Nome",en:"First Name",es:"Nombre"},font:{pt:"Fonte",en:"Font",es:"Fuente"},format_html:{pt:"HTML",en:"HTML",es:"HTML"},format_markdown:{pt:"Markdown",en:"Markdown",es:"Markdown"},format_plain:{pt:"Texto Simples",en:"Plain Text",es:"Texto Simple"},format_rich:{pt:"Rich (WYSIWYG)",en:"Rich (WYSIWYG)",es:"Rich (WYSIWYG)"},full_name:{pt:"Nome Completo",en:"Full Name",es:"Nombre Completo"},general_settings:{pt:"Configurações Gerais",en:"General Settings",es:"Configuración General"},height:{pt:"Altura",en:"Height",es:"Altura"},home:{pt:"Início",en:"Home",es:"Inicio"},html_warning:{pt:"⚠️ HTML será sanitizado para segurança",en:"⚠️ HTML will be sanitized for security",es:"⚠️ HTML será sanitizado por seguridad"},identification:{pt:"Identificação",en:"Identification",es:"Identificación"},identification_invalid:{pt:"Identificação inválida",en:"Invalid identification",es:"Identificación inválida"},image:{pt:"Imagem",en:"Image",es:"Imagen"},import:{pt:"Importar",en:"Import",es:"Importar"},inactive:{pt:"Inativo",en:"Inactive",es:"Inactivo"},inactive_plural:{pt:"Inativos",en:"Inactive",es:"Inactivos"},info:{pt:"Informação",en:"Information",es:"Información"},input_type:{pt:"Tipo de Entrada",en:"Input Type",es:"Tipo de Entrada"},input_type_embed:{pt:"Embed",en:"Embed",es:"Incrustar"},input_type_upload:{pt:"Upload",en:"Upload",es:"Cargar"},integration:{pt:"Integração",en:"Integration",es:"Integración"},invalid_date:{pt:"Data inválida",en:"Invalid date",es:"Fecha inválida"},invalid_email:{pt:"E-mail inválido",en:"Invalid email",es:"Correo electrónico inválido"},invalid_file_type:{pt:"Por favor, selecione um arquivo de vídeo",en:"Please select a video file",es:"Por favor, seleccione un archivo de video"},invalid_phone:{pt:"Telefone inválido",en:"Invalid phone",es:"Teléfono inválido"},invalid_youtube_url:{pt:"URL do YouTube inválida. Use o formato: https://www.youtube.com/watch?v=VIDEO_ID",en:"Invalid YouTube URL. Use format: https://www.youtube.com/watch?v=VIDEO_ID",es:"URL de YouTube inválida. Use el formato: https://www.youtube.com/watch?v=VIDEO_ID"},item_details:{pt:"Detalhes do item",en:"Item details",es:"Detalles del elemento"},items:{pt:"itens",en:"items",es:"elementos"},items_per_page:{pt:"Itens por página",en:"Items per page",es:"Elementos por página"},key:{pt:"Chave",en:"Key",es:""},language:{pt:"Idioma",en:"Language",es:"Idioma"},last_10_logins:{pt:"Últimos 10 Logins",en:"Last 10 Logins",es:"Últimos 10 Inicios de Sesión"},last_modification:{pt:"Última Modificação",en:"Last Modification",es:"Última Modificación"},last_name:{pt:"Sobrenome",en:"Last Name",es:"Apellido"},leader:{pt:"Líder",en:"Leader",es:"Líder"},leadership:{pt:"Liderança",en:"Leadership",es:"Liderazgo"},leadership_hierarchy:{pt:"Hierarquia de liderança",en:"Leadership hierarchy",es:"Jerarquía de liderazgo"},left:{pt:"Esquerda",en:"Left",es:"Izquierda"},link_copied:{pt:"Link copiado para a área de transferência",en:"Link copied to clipboard",es:"Enlace copiado al portapapeles"},list:{pt:"Lista",en:"List",es:"Lista"},loading:{pt:"Carregando...",en:"Loading...",es:"Cargando..."},loading_data:{pt:"Carregando dados...",en:"Loading data...",es:"Cargando datos..."},logout:{pt:"Sair",en:"Logout",es:"Cerrar Sesión"},manage_reports:{pt:"Gerenciar relatórios",en:"Manage reports",es:"Gestionar informes"},management:{pt:"Gestão",en:"Management",es:"Gestión"},management_access_control:{pt:"Controle de acesso a gestão",en:"Management access control",es:"Control de acceso a gestión"},management_permission:{pt:"Permissão de Gestão",en:"Management Permission",es:"Permiso de Gestión"},management_permissions:{pt:"Permissões de Gestão",en:"Management Permissions",es:"Permisos de Gestión"},markdown_hint:{pt:"💡 Suporte a: **negrito**, *itálico*, [links](url), parágrafos",en:"💡 Supports: **bold**, *italic*, [links](url), paragraphs",es:"💡 Soporta: **negrita**, *cursiva*, [enlaces](url), párrafos"},max_file_size:{pt:"Tamanho máximo",en:"Maximum size",es:"Tamanho máximo"},migration:{pt:"Migração",en:"Migration",es:""},module:{pt:"Módulo",en:"Module",es:"Módulo"},module_title:{pt:"Título do módulo",en:"Module title",es:"Título del módulo"},modules:{pt:"Módulos",en:"Modules",es:"Módulos"},name:{pt:"Nome",en:"Name",es:"Nombre"},new:{pt:"Novo",en:"New",es:"Nuevo"},new_password:{pt:"Nova Senha",en:"New Password",es:"Nueva Contraseña"},new_value:{pt:"Novo valor",en:"New value",es:"Nuevo valor"},next:{pt:"Próximo",en:"Next",es:"Siguiente"},no:{pt:"Não",en:"No",es:"No"},no_additional_fields:{pt:"Nenhum campo adicional configurado.",en:"No additional fields configured.",es:"No hay campos adicionales configurados."},no_content_preview:{pt:"Nenhum conteúdo para visualizar...",en:"No content to preview...",es:"No hay contenido para previsualizar..."},no_data:{pt:"Nenhum dado disponível",en:"No data available",es:"No hay datos disponibles"},no_file_selected:{pt:"Nenhum arquivo selecionado",en:"No file selected",es:"No se seleccionó ningún archivo"},no_items_found:{pt:"Nenhum item encontrado",en:"No items found",es:"No se encontraron elementos"},no_logins_registered:{pt:"Nenhum login registrado ainda.",en:"No logins registered yet.",es:"Aún no se han registrado inicios de sesión."},no_options:{pt:"Nenhuma opção disponível",en:"No options available",es:"No hay opciones disponibles"},no_permission_to_access_reports:{pt:"Sem permissão para acessar relatórios",en:"No permission to access reports",es:""},no_posts_found:{pt:"Nenhum post encontrado",en:"No posts found",es:"No se encontraron publicaciones"},no_results:{pt:"Nenhum resultado encontrado",en:"No results found",es:"No se encontraron resultados"},no_title:{pt:"Sem título",en:"No title",es:"Sin título"},notifications:{pt:"Notificações",en:"Notifications",es:"Notificaciones"},nr1:{pt:"Pulso",en:"Pulse",es:"Pulso"},of:{pt:"de",en:"of",es:"de"},old_password:{pt:"Senha Atual",en:"Current Password",es:"Contraseña Actual"},open_external_link:{pt:"Abrir link externo",en:"Open external link",es:"Abrir enlace externo"},open_wiki:{pt:"Abrir Wiki",en:"Open Wiki",es:"Abrir Wiki"},order:{pt:"Ordem",en:"Order",es:"Orden"},overview:{pt:"Visão geral",en:"Overview",es:"Resumen"},page:{pt:"Página",en:"Page",es:"Página"},password:{pt:"Senha",en:"Password",es:"Contraseña"},paste_html_placeholder:{pt:"Cole ou escreva HTML aqui...",en:"Paste or write HTML here...",es:"Pegue o escriba HTML aquí..."},pdi:{pt:"PDI",en:"PDI",es:"PDI"},pending:{pt:"Pendente",en:"Pending",es:"Pendiente"},performance:{pt:"Desempenho",en:"Performance",es:"Desempeño"},permissions:{pt:"Permissões",en:"Permissions",es:"Permisos"},permissions_roles:{pt:"Permissões e Roles",en:"Permissions and Roles",es:"Permisos y Roles"},phone:{pt:"Telefone",en:"Phone",es:"Teléfono"},place:{pt:"Local",en:"Place",es:"Lugar"},placeholder_select:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},places:{pt:"Locais",en:"Places",es:"Lugares"},plain_text_placeholder:{pt:"Digite texto simples aqui...",en:"Enter plain text here...",es:"Ingrese texto simple aquí..."},position:{pt:"Cargo",en:"Position",es:"Cargo"},posts:{pt:"Publicações",en:"Posts",es:"Publicaciones"},preferences:{pt:"Preferências de Internacionalização",en:"Internationalization Preferences",es:"Preferencias de Internacionalización"},preview:{pt:"Preview",en:"Preview",es:"Vista Previa"},previous:{pt:"Anterior",en:"Previous",es:"Anterior"},processing:{pt:"Processando...",en:"Processing...",es:"Procesando..."},profile:{pt:"Perfil",en:"Profile",es:"Perfil"},pt:{pt:"PT",en:"PT",es:"PT"},qualiex_places_hierarchy:{pt:"Hierarquia de locais do Qualiex",en:"Qualiex places hierarchy",es:"Jerarquía de lugares de Qualiex"},recipient_email:{pt:"Email Destinatário",en:"Recipient Email",es:"Correo del Destinatario"},redirecting:{pt:"Redirecionando...",en:"Redirecting...",es:"Redirigiendo..."},refresh_data:{pt:"Atualizar dados",en:"Refresh data",es:"Actualizar datos"},reload:{pt:"Recarregar",en:"Reload",es:"Recargar"},remove:{pt:"Remover",en:"Remove",es:"Eliminar"},remove_confirm:{pt:"Tem certeza que deseja remover?",en:"Are you sure you want to remove?",es:"¿Está seguro de que desea eliminar?"},removing:{pt:"Removendo...",en:"Removing...",es:"Eliminando..."},reports:{pt:"Relatórios",en:"Reports",es:"Informes"},required_field:{pt:"Campo obrigatório",en:"Required field",es:"Campo obligatorio"},restricted_access:{pt:"Acesso restrito",en:"Restricted access",es:"Acceso restringido"},results:{pt:"resultados",en:"results",es:"resultados"},right:{pt:"Direita",en:"Right",es:"Derecha"},role:{pt:"Papel",en:"Role",es:"Rol"},roles:{pt:"Perfis",en:"Roles",es:"Roles"},rows_per_page:{pt:"Registros por página",en:"Rows per page",es:"Registros por página"},save:{pt:"Salvar",en:"Save",es:"Guardar"},save_block:{pt:"Salvar Bloco",en:"Save Block",es:"Guardar Bloque"},save_success:{pt:"Salvo com sucesso",en:"Saved successfully",es:"Guardado exitosamente"},saving:{pt:"Salvando...",en:"Saving...",es:"Guardando..."},search:{pt:"Pesquisar",en:"Search",es:"Buscar"},search_placeholder:{pt:"Pesquisar...",en:"Search...",es:"Buscar..."},search_user:{pt:"Buscar usuário...",en:"Search user...",es:"Buscar usuario..."},searchDateFormat:{pt:"Buscar formato...",en:"Search format...",es:"Buscar formato..."},searchTimezone:{pt:"Buscar fuso horário...",en:"Search timezone...",es:"Buscar zona horaria..."},section:{pt:"Seção",en:"Section",es:"Sección"},select_all:{pt:"Selecionar todos",en:"Select all",es:"Seleccionar todo"},select_collaborator:{pt:"Selecionar Colaborador",en:"Select Collaborator",es:"Seleccionar Colaborador"},select_option:{pt:"Selecione uma opção",en:"Select an option",es:"Seleccione una opción"},select_placeholder:{pt:"Selecione...",en:"Select...",es:"Seleccionar..."},selectDateFormat:{pt:"Selecione o formato",en:"Select format",es:"Seleccione el formato"},selectTimezone:{pt:"Selecione o fuso horário",en:"Select timezone",es:"Seleccione la zona horaria"},select_text_for_link:{pt:"Selecione o texto que deseja transformar em link",en:"Select the text you want to turn into a link",es:"Seleccione el texto que desea convertir en enlace"},select_unit_collaborator:{pt:"Selecione um colaborador da unidade",en:"Select a unit collaborator",es:"Seleccione un colaborador de la unidad"},select_user:{pt:"Selecionar Usuário",en:"Select User",es:"Seleccionar Usuario"},select_user_for_admin_access:{pt:"Selecione um usuário para dar acesso admin",en:"Select a user to grant admin access",es:"Seleccione un usuario para dar acceso de administrador"},select_video:{pt:"Selecionar Vídeo",en:"Select Video",es:"Seleccionar Video"},selected:{pt:"selecionado(s)",en:"selected",es:"seleccionado(s)"},selected_count:{pt:"{{count}} selecionado(s)",en:"{{count}} selected",es:"{{count}} seleccionado(s)"},send:{pt:"Enviar",en:"Send",es:"Enviar"},settings:{pt:"Configurações",en:"Settings",es:"Configuración"},settings_summary:{pt:"Resumo das configurações",en:"Settings summary",es:"Resumen de configuración"},showing:{pt:"Mostrando",en:"Showing",es:"Mostrando"},size:{pt:"Tamanho",en:"Size",es:"Tamaño"},skills:{pt:"Habilidades",en:"Skills",es:"Habilidades"},state:{pt:"Estado",en:"State",es:"Estado"},status:{pt:"Status",en:"Status",es:"Estado"},subordinates:{pt:"Subordinados",en:"Subordinates",es:"Subordinados"},success:{pt:"Sucesso",en:"Success",es:"Éxito"},superior:{pt:"Superior Imediato",en:"Immediate Superior",es:"Superior Inmediato"},superior_none:{pt:"Nenhum superior",en:"No superior",es:"Ningún superior"},superior_search:{pt:"Buscar superior...",en:"Search superior...",es:"Buscar superior..."},system_administration:{pt:"Administração do sistema",en:"System administration",es:"Administración del sistema"},system_logs:{pt:"Logs do Sistema",en:"System Logs",es:"Registros del Sistema"},template_variables:{pt:"Variáveis do Template",en:"Template Variables",es:"Variables de Plantilla"},test_email:{pt:"Testar Envio de Email",en:"Test Email Sending",es:"Probar Envío de Correo"},text:{pt:"Texto",en:"Text",es:"Texto"},text_color:{pt:"Cor do Texto",en:"Text Color",es:"Color del Texto"},text_format:{pt:"Formato de Texto",en:"Text Format",es:"Formato de Texto"},thumbnail:{pt:"Thumbnail",en:"Thumbnail",es:"Miniatura"},timezone:{pt:"Fuso Horário",en:"Timezone",es:"Zona Horaria"},title:{pt:"Título",en:"Title",es:"Título"},to:{pt:"até",en:"to",es:"hasta"},total:{pt:"Total",en:"Total",es:"Total"},trainings:{pt:"Treinamentos",en:"Trainings",es:"Capacitaciones"},translation:{pt:"Tradução",en:"Translation",es:"Traducción"},translation_description:{pt:"Informações da tradução",en:"Translation information",es:"Información de la traducción"},translations:{pt:"Traduções",en:"Translations",es:"Traducciones"},type:{pt:"Tipo",en:"Type",es:"Tipo"},type_to_search:{pt:"Digite para pesquisar",en:"Type to search",es:"Escriba para buscar"},unit:{pt:"Unidade",en:"Unit",es:"Unidad"},units:{pt:"Unidades",en:"Units",es:"Unidades"},unsupported:{pt:"Formato não suportado",en:"Unsupported format",es:"Formato no soportado"},update:{pt:"Atualizar",en:"Update",es:"Actualizar"},value:{pt:"Valor",en:"Value",es:"Valor"},update_success:{pt:"Atualizado com sucesso",en:"Updated successfully",es:"Actualizado exitosamente"},updated_at:{pt:"Atualizado em",en:"Updated at",es:"Actualizado en"},updated_by:{pt:"Atualizado por",en:"Updated by",es:"Actualizado por"},updating:{pt:"Atualizando...",en:"Updating...",es:"Actualizando..."},upload:{pt:"Upload",en:"Upload",es:"Cargar"},useSystemDefaults:{pt:"Usar padrão do sistema",en:"Use system defaults",es:"Usar valores del sistema"},uploading:{pt:"Enviando...",en:"Uploading...",es:"Subiendo..."},url:{pt:"URL",en:"URL",es:"URL"},url_placeholder:{pt:"https://exemplo.com/imagem.jpg",en:"https://example.com/image.jpg",es:"https://ejemplo.com/imagen.jpg"},user:{pt:"Usuário",en:"User",es:"Usuario"},user_management:{pt:"Gestão de Usuários",en:"User Management",es:"Gestión de Usuarios"},username:{pt:"Usuário",en:"Username",es:"Usuario"},users:{pt:"Usuários",en:"Users",es:"Usuarios"},video:{pt:"Vídeo",en:"Video",es:"Video"},view:{pt:"Visualizar",en:"View",es:"Visualizar"},view_mode_grid:{pt:"Grade",en:"Grid",es:"Cuadrícula"},view_mode_list:{pt:"Lista",en:"List",es:"Lista"},view_mode_table:{pt:"Tabela",en:"Table",es:"Tabla"},warning:{pt:"Aviso",en:"Warning",es:"Advertencia"},width:{pt:"Largura",en:"Width",es:"Ancho"},yes:{pt:"Sim",en:"Yes",es:"Sí"},zip_code:{pt:"CEP",en:"ZIP Code",es:"Código Postal"}};A.use(v.initReactI18next).init({resources:function(e){const t={},a={},s={};for(const[r,n]of Object.entries(e))t[r]=n.pt||r,a[r]=n.en||n.pt||r,s[r]=n.es||n.pt||r;return{"pt-BR":{translations:t},"en-US":{translations:a},"es-ES":{translations:s}}}(qo),fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"translations",ns:["translations"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e});const Oo=t.createContext(void 0),Bo={locale:xa,timezone:ba,datetimeFormat:ga},$o=async()=>{},Ho=({children:t})=>e.jsx(Oo.Provider,{value:{...Bo,setLocale:$o,setTimezone:$o,setDatetimeFormat:$o,isLoading:!1},children:t}),Vo=()=>{const e=t.useContext(Oo);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},Wo=t.createContext({moduleAlias:null});function Go({moduleAlias:t=null,children:a}){return e.jsx(Wo.Provider,{value:{moduleAlias:t},children:a})}function Yo(){return t.useContext(Wo)}const Qo=he.Root,Ko=he.CollapsibleTrigger,Xo=he.CollapsibleContent;class Zo extends t.Component{constructor(e){super(e),this.copyErrorDetails=()=>{const e=Rr.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),i.toast.success("Detalhes copiados!",{description:"Os detalhes do erro foram copiados para a área de transferência."})},this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if((void 0).DEV)throw e;Rr.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=Rr.getErrors().slice(0,2);return e.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:e.jsxs(La,{className:"w-full max-w-2xl",children:[e.jsxs(za,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(l.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),e.jsx(Fa,{children:"Algo deu errado"})]}),e.jsxs(qa,{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(Qo,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[e.jsx(Ko,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),e.jsxs(Xo,{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(vr,{className:"h-32 w-full rounded border bg-muted p-2",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),e.jsx("div",{className:"space-y-2",children:t.map((t,a)=>e.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[a+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),e.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),e.jsxs(Pa,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[e.jsx(l.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),e.jsx(Pa,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const Jo=fe.Root,ei=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.List,{ref:s,className:Aa("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...a}));ei.displayName=fe.List.displayName;const ti=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Trigger,{ref:s,className:Aa("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...a}));ti.displayName=fe.Trigger.displayName;const ai=J.forwardRef(({className:t,...a},s)=>e.jsx(fe.Content,{ref:s,className:Aa("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a}));ai.displayName=fe.Content.displayName;const si=J.forwardRef(({className:t,value:a,...s},r)=>e.jsx(xe.Root,{ref:r,className:Aa("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...s,children:e.jsx(xe.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));function ri({image:t,title:a,className:s}){return e.jsx("div",{className:Aa("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:t?e.jsx("img",{src:t,alt:a,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function ni({steps:t,currentStepIndex:a,onStepSelect:s,stepLabel:r,className:n}){const o=t.length,i=(a+1)/o*100;return e.jsxs("div",{className:Aa("flex items-center gap-3",n),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",a+1,"/",o,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:t.map((t,r)=>e.jsxs(Gs,{onClick:()=>s(r),className:Aa(r===a&&"bg-accent"),children:[r+1,". ",t.title]},t.id))})]}),e.jsx(si,{value:i,className:"w-32 h-2"})]})}function oi({currentStepIndex:t,totalSteps:a,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:d,className:c}){const u=0===t,m=t===a-1;return e.jsxs("div",{className:Aa("flex items-center gap-2",c),children:[!u&&e.jsxs(Pa,{variant:"outline",onClick:s,size:"sm",children:[e.jsx(l.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),e.jsxs(Pa,{onClick:m?n:r,size:"sm",children:[m?d:i,!m&&e.jsx(l.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}si.displayName=xe.Root.displayName;const ii=J.forwardRef(({open:t,onOpenChange:a,steps:s,onComplete:r,onStepChange:n,continueButtonText:o="Continuar",backButtonText:i="Voltar",finishButtonText:d="Concluir",stepLabel:c="Etapa",size:u="md",showProgressIndicator:m=!0,currentStepIndex:p,onCurrentStepChange:h,className:f},x)=>{const[g,b]=J.useState(0),v=void 0!==p,w=v?p:g,N=J.useCallback(e=>{v?h?.(e):b(e),n?.(e)},[v,h,n]);J.useEffect(()=>{t||v||b(0)},[t,v]);const y=s[w],j=s.length;return y?e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{ref:x,size:u,variant:"informative",className:Aa("p-0 gap-0 overflow-hidden",f),children:[e.jsxs(ss,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Fechar"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(ri,{image:y.image,title:y.title}),e.jsx(cs,{className:"text-xl font-semibold",children:y.title}),e.jsx(us,{className:"text-muted-foreground",children:y.description})]})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(Ba,{}),e.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[m&&j>1?e.jsx(ni,{steps:s,currentStepIndex:w,onStepSelect:e=>{N(e)},stepLabel:c}):e.jsx("div",{}),e.jsx(oi,{currentStepIndex:w,totalSteps:j,onBack:()=>{w>0&&N(w-1)},onNext:()=>{w<j-1&&N(w+1)},onComplete:()=>{r?.(),a(!1)},backButtonText:i,continueButtonText:o,finishButtonText:d})]})]})]})}):null});function li({className:t}){return e.jsxs("svg",{className:t,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.5 11.7455C0.5 10.2633 2.25695 9.52546 3.36816 10.4399L22.4346 26.1528C23.3588 26.9137 23.229 28.3353 22.1953 28.9301L16.3418 32.2963C15.7961 32.6097 15.1199 32.6098 14.5742 32.2963L1.36133 24.7006C0.832671 24.3966 0.500052 23.8398 0.5 23.2289V11.7455Z",stroke:"currentColor"}),e.jsx("path",{d:"M14.612 0.735352C15.1576 0.421927 15.833 0.421964 16.3786 0.735352L25.3776 5.90723V5.9082C26.5447 6.5808 26.5183 8.24018 25.3298 8.875L25.3307 8.87598L13.9333 14.9697L13.9323 14.9688C13.3016 15.3066 12.5233 15.2301 11.9733 14.7773L4.90302 8.9541C3.97881 8.19317 4.1086 6.77256 5.14227 6.17773L14.612 0.735352Z",stroke:"currentColor"}),e.jsx("path",{d:"M28.1066 9.7966C29.2466 9.18579 30.6895 9.9732 30.6896 11.2937V23.0691C30.6895 23.6825 30.3539 24.2382 29.8264 24.5417L29.8254 24.5427L27.3449 25.9607C26.7486 26.3015 26.0057 26.264 25.4494 25.8747L25.341 25.7917L16.6076 18.5974C15.6649 17.821 15.8224 16.3676 16.8937 15.7937V15.7927L28.1066 9.79758V9.7966Z",stroke:"currentColor"})]})}function di({className:t}){return e.jsxs("svg",{className:t,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M0.524143 8.74979C1.44754 8.74979 2.36325 8.74979 3.30973 8.74979C3.30973 8.90069 3.30973 9.05162 3.30973 9.19497C3.30973 9.79101 3.64061 10.1154 4.24082 10.1154C6.8879 10.1154 9.54268 10.1154 12.1898 10.1154C12.7592 10.1154 13.1286 9.77589 13.1132 9.27793C13.0978 8.8856 12.8054 8.5612 12.3745 8.51594C11.2279 8.38767 10.0736 8.26696 8.91938 8.1387C7.72666 8.01043 6.52625 7.88216 5.33352 7.74635C4.71792 7.67845 4.10232 7.61811 3.48672 7.53511C2.00928 7.32386 0.754978 6.06386 0.547213 4.61526C0.331752 3.10631 1.00122 1.73316 2.34015 0.963593C2.89419 0.646712 3.5021 0.503353 4.14848 0.503353C6.84943 0.503353 9.55038 0.495808 12.2513 0.503353C14.0904 0.510898 15.5448 1.71808 15.8603 3.49865C15.8988 3.7099 15.8988 3.92116 15.9065 4.13996C15.9141 4.2984 15.9065 4.44928 15.9065 4.61526C14.9677 4.61526 14.0443 4.61526 13.0978 4.61526C13.0978 4.44928 13.0978 4.28329 13.0978 4.1173C13.0901 3.58162 12.7592 3.25719 12.2206 3.24965C9.53499 3.24965 6.84943 3.24965 4.17157 3.24965C3.69448 3.24965 3.36359 3.52881 3.30203 3.97396C3.24816 4.3512 3.51749 4.73597 3.90224 4.8265C4.10231 4.87177 4.31008 4.88687 4.51784 4.9095C5.8183 5.05285 7.12645 5.19622 8.42691 5.33957C9.71198 5.48292 10.997 5.63382 12.2898 5.75453C13.1824 5.83753 13.9981 6.08649 14.6906 6.68253C16.1604 7.92742 16.3066 10.2588 14.9984 11.6696C14.2443 12.4845 13.3132 12.8844 12.1975 12.8844C9.5273 12.8844 6.84944 12.8844 4.17927 12.8844C2.55562 12.8844 1.21669 11.9563 0.678043 10.4549C0.539533 9.98715 0.470277 9.38356 0.524143 8.74979Z",stroke:"currentColor"}),e.jsx("path",{d:"M8.21913 24.2393C8.21913 24.2317 8.21913 24.2317 8.21913 24.2393ZM8.21913 24.2393C8.98863 24.2393 9.75812 24.2619 10.5199 24.2317C11.7511 24.1789 12.9285 23.1378 13.067 21.9381C13.1439 21.3119 13.1285 20.6706 13.1131 20.0368C13.067 18.6335 11.8743 17.4339 10.443 17.3962C8.96554 17.3584 7.4881 17.366 6.00296 17.3962C4.70251 17.4263 3.54055 18.4373 3.37896 19.6973C3.29431 20.3462 3.3097 21.0101 3.34048 21.6665C3.40204 23.017 4.58708 24.1789 5.96449 24.2317C6.7186 24.2619 7.46502 24.2393 8.21913 24.2393ZM13.1439 15.427C13.7441 14.8385 14.3367 14.2575 14.9138 13.6917C15.5756 14.333 16.2296 14.9818 16.9222 15.6608C16.8914 15.6759 16.8298 15.7061 16.7837 15.7438C16.2604 16.2493 15.7448 16.7624 15.2216 17.2679C15.1446 17.3434 15.1369 17.4037 15.1908 17.4943C15.7064 18.3845 15.9526 19.3427 15.9295 20.3613C15.9141 20.9799 15.9526 21.6062 15.8603 22.2097C15.5371 24.2846 14.352 25.7332 12.3975 26.5782C11.7126 26.8724 10.9816 26.9931 10.2352 26.9931C8.89629 26.9931 7.56504 26.9931 6.22611 26.9931C3.49438 26.9931 1.20897 25.1899 0.631845 22.5719C0.56259 22.2475 0.524115 21.9155 0.51642 21.5835C0.508725 20.9422 0.470242 20.2933 0.547192 19.6596C0.816518 17.3584 2.08619 15.7967 4.27927 14.9516C4.84101 14.7328 5.42584 14.6347 6.02605 14.6347C7.4958 14.6347 8.96554 14.6272 10.4276 14.6423C11.3279 14.6498 12.1667 14.9064 12.9516 15.3289C13.0131 15.3591 13.067 15.3892 13.1439 15.427Z",stroke:"currentColor"}),e.jsx("path",{d:"M0.508791 28.3813C1.43989 28.3813 2.3633 28.3813 3.2944 28.3813C3.31748 28.4945 3.32516 28.6001 3.35594 28.7058C3.50984 29.2943 4.01772 29.7017 4.63332 29.7319C4.76414 29.7394 4.89496 29.7394 5.02578 29.7394C7.22655 29.7394 9.4273 29.7394 11.6281 29.7394C12.3206 29.7394 12.8439 29.3923 13.0363 28.7963C13.0747 28.668 13.0978 28.5323 13.1286 28.3889C14.0443 28.3889 14.9677 28.3889 15.9142 28.3889C15.9219 28.7435 15.868 29.0906 15.7757 29.4301C15.2986 31.1955 13.6519 32.4782 11.7897 32.4857C9.39653 32.5008 7.01108 32.5083 4.61794 32.4857C2.44025 32.4706 0.624216 30.7353 0.508791 28.6077C0.501096 28.5322 0.508791 28.4643 0.508791 28.3813Z",stroke:"currentColor"})]})}ii.displayName="OnboardingDialog";const ci=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",url:"https://okr.qualiex.com"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",url:"https://competencias.sabergestao.com.br"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",url:"https://desempenho.sabergestao.com.br"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",url:"https://educacao.sabergestao.com.br"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",url:"https://pdi.sabergestao.com.br"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",url:"https://nr1pulso.sabergestao.com.br"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",url:"https://treinamentos.sabergestao.com.br"}]},{id:"classico",label:"Clássicos",modules:[{name:"Action",description:"Planos de ação",color:"bg-[#fbe356]",url:"https://apps1.qualiex.com/action?unitalias={alias}"},{name:"Audit",description:"Gestão de auditorias",color:"bg-[#ca76b5]",url:"https://apps1.qualiex.com/audit?unitalias={alias}"},{name:"Configurações v3",description:"Configurações",color:"bg-[#5C6BC0]",url:"https://apps3.qualiex.com/{alias}/common"},{name:"Dashboards v1",description:"Dashboards",color:"bg-[#EC407A]",url:"https://apps1.qualiex.com/shared/dashboard?unitalias=forlogic"},{name:"Docs v1",description:"Gestão de Documentos",color:"bg-[#58b4db]",url:"https://apps1.qualiex.com/docs?unitalias={alias}"},{name:"Indicators",description:"Gestão de Indicadores",color:"bg-[#f91b1d]",url:"https://apps1.qualiex.com/indicators?unitalias={alias}"},{name:"Meeting",description:"Gestão de reuniões",color:"bg-[#96c2c1]",url:"https://apps1.qualiex.com/meeting?unitalias={alias}"},{name:"Metrology v3",description:"Gestão de Metrologia",color:"bg-[#afd884]",url:"https://apps3.qualiex.com/{alias}/metrology/"},{name:"Planner",description:"Planejamento estratégico",color:"bg-[#4dc6f4]",url:"https://apps3.qualiex.com/{alias}/planner/m"},{name:"Relatórios v1",description:"Relatórios",color:"bg-[#FFA726]",url:"https://apps1.qualiex.com/common/reports?unitalias=forlogic"},{name:"Risks",description:"Gestão de riscos",color:"bg-[#ef7b9e]",url:"https://apps1.qualiex.com/risks?unitalias={alias}"},{name:"Staff",description:"Avaliação de competências",color:"bg-[#0978d6]",url:"https://apps1.qualiex.com/staff?unitalias={alias}"},{name:"Supply",description:"Avaliação de fornecedores",color:"bg-[#8276b7]",url:"https://apps1.qualiex.com/supply?unitalias={alias}"},{name:"Tracker1",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker1?unitalias={alias}"},{name:"Tracker2",description:"Gestão de ocorrências",color:"bg-[#fe883b]",url:"https://apps1.qualiex.com/tracker2?unitalias={alias}"}]}];function ui({module:t,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[e.jsx("div",{className:Aa("w-4 h-4 rounded-sm shrink-0 mt-0.5",t.color)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:t.name}),t.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.description})]})]})}function mi(e,t){if(0===e.length)return e;const a=Math.ceil(e.length/t),s=[];for(let r=0;r<a;r++)for(let n=0;n<t;n++){const t=n*a+r;t<e.length&&s.push(e[t])}return s}function pi({modules:a,onModuleClick:s,contractedModules:r,onModuleInterest:n}){const o=function(){const[e,a]=t.useState(4);return t.useEffect(()=>{const e=()=>{window.matchMedia("(min-width: 1280px)").matches?a(4):window.matchMedia("(min-width: 768px)").matches?a(3):a(2)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...a].sort((e,t)=>e.name.localeCompare(t.name)),l=void 0!==r,d=l?i.filter(e=>r.includes(e.name)):i,c=l?i.filter(e=>!r.includes(e.name)):[],u=mi(d,o),m=mi(c,o),p=(e,t)=>{t?s?.(e):n?.(e)};return e.jsxs("div",{className:"space-y-6",children:[u.length>0&&e.jsx("section",{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(t=>e.jsx(ui,{module:t,onClick:()=>p(t,!0)},t.name))})}),m.length>0&&e.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(t=>e.jsx(ui,{module:t,onClick:()=>p(t,!1)},t.name))})]})]})}function hi({open:a,onOpenChange:s,onModuleClick:r,contractedModules:n,onModuleInterest:o,educaUrl:i="https://educa.forlogic.net/",saberGestaoUrl:d="https://sabergestao.com.br/",wikiUrl:c}){const[u,m]=t.useState("qualiex"),[p,h]=t.useState(null),{alias:f}=Nn(),x=e=>{if(r)r(e);else if(e.url){_a(f?e.url.replace(/\{alias\}/g,f):e.url)}},g=e=>{h(e)},b=i||c||"https://educa.forlogic.net/";return e.jsxs(e.Fragment,{children:[e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{size:"lg",className:"overflow-hidden flex flex-col max-h-[85vh]",children:[e.jsx(is,{className:"sr-only",children:e.jsx(cs,{children:"Módulos"})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(Jo,{value:u,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[e.jsx(ei,{className:"w-fit shrink-0",children:ci.map(t=>e.jsxs(ti,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),ci.map(t=>e.jsx(ai,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(pi,{modules:t.modules,onModuleClick:x,contractedModules:n,onModuleInterest:g})},t.id))]}),e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o ForLogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(li,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(di,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:c||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})]})]})}),p&&e.jsx(ii,{open:!!p,onOpenChange:e=>!e&&h(null),steps:(v=p,v.onboardingSteps&&v.onboardingSteps.length>0?v.onboardingSteps.slice(0,3):[{id:"intro",title:`Conheça o ${v.name}`,description:v.description||`O ${v.name} é uma solução completa para otimizar seus processos e aumentar a produtividade da sua equipe.`},{id:"features",title:"Principais Funcionalidades",description:"Automatize processos, gere relatórios detalhados, acompanhe indicadores em tempo real e tenha controle total sobre suas operações."},{id:"cta",title:"Transforme sua Gestão",description:"Fale com um de nossos especialistas e descubra como este módulo pode transformar a gestão da sua empresa."}]),finishButtonText:"Quero conhecer mais",onComplete:()=>{p&&(o?.(p),h(null))}})]});var v}const fi=18e5,xi=6e5;function gi(e){const{moduleAlias:a}=Yo(),{alias:s,user:r,isAuthenticated:n}=Nn(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:d=[],isLoading:c}=y.useQuery({queryKey:["qualiex-softwares",s],queryFn:()=>sn.fetchSoftwares(s),enabled:l,staleTime:fi,gcTime:36e5}),{data:u=[],isLoading:m}=y.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>sn.fetchUserAssociations(i,s),enabled:l,staleTime:xi,gcTime:12e5}),p=t.useMemo(()=>{const e=new Map;return d.forEach(t=>e.set(t.alias,t.id)),e},[d]),h=t.useMemo(()=>s&&0!==u.length?u.find(e=>e.companyAlias===s)??null:null,[u,s]),f=t.useCallback(e=>{if(!h)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const t=p.get(e);return void 0!==t&&h.softwares.includes(t)})},[h,p]);return{hasAccess:t.useMemo(()=>!o||f(o),[o,f]),isLoading:l&&(c||m),role:t.useMemo(()=>h?{id:h.roleId,name:h.roleName}:null,[h]),association:h,hasAccessTo:f,softwares:d}}function bi({children:a,contractedModules:s,onModuleClick:r,educaUrl:n="https://educa.forlogic.net/",saberGestaoUrl:o="https://sabergestao.com.br/",wikiUrl:i}){const{hasAccess:d,isLoading:c}=gi(),{user:u,alias:m,companies:p,isAuthenticated:h,isLoading:f,logout:x,switchUnit:g}=Nn(),b=t.useMemo(()=>p?.length?m&&p.find(e=>e.alias===m)||p[0]:null,[p,m]),v=t.useMemo(()=>{if(!p?.length)return[];const e=new Map;p.forEach(t=>e.set(t.alias,t));const t=Array.from(e.values()),a=t.find(e=>e.alias===b?.alias),s=t.filter(e=>e.alias!==b?.alias).sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"}));return a?[a,...s]:s},[p,b?.alias]),w=t.useCallback(e=>{g(e)},[g]);if(f||!h)return e.jsx(e.Fragment,{children:a});if(c)return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(Ls,{size:"lg"})});if(d)return e.jsx(e.Fragment,{children:a});const N=e=>{if(r)r(e);else if(e.url){_a(m?e.url.replace(/\{alias\}/g,m):e.url)}},y=n||i||"https://educa.forlogic.net/";return e.jsx(es,{open:!0,modal:!0,children:e.jsxs(os,{size:"lg",variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[e.jsxs(is,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(cs,{children:"Parece que você não tem acesso a essa página"}),e.jsx(us,{children:"Selecione um módulo para continuar navegando!"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[v.length>1&&e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[e.jsx(l.Building2,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:b?.name||"Unidade"}),e.jsx(l.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Ws,{align:"end",className:"max-h-[300px] overflow-auto",children:v.map(t=>e.jsxs(Gs,{onClick:()=>w(t),className:t.alias===b?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t.name}),t.alias===b?.alias&&e.jsx(Ds,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},t.alias))})]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"gap-2",children:[e.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-3 w-3"})]})}),e.jsxs(Ws,{align:"end",children:[e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsx("p",{className:"text-sm font-medium",children:u?.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b?.name})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:x,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs(Jo,{defaultValue:"qualiex",className:"flex-1 flex flex-col min-h-0",children:[e.jsx(ei,{className:"w-fit shrink-0",children:ci.map(t=>e.jsxs(ti,{value:t.id,children:[t.label,e.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",t.modules.length,")"]})]},t.id))}),ci.map(t=>e.jsx(ai,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:e.jsx(pi,{modules:t.modules,onModuleClick:N,contractedModules:s})},t.id))]}),e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-white",children:"Aprenda a usar o Qualiex"}),e.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-white underline underline-offset-2 hover:opacity-80 mt-2",children:["Conheça o ForLogic Educa",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(li,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Conheça o Saber Gestão"}),e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(di,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[e.jsxs("div",{className:"relative z-10",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),e.jsxs("a",{href:i||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",e.jsx(l.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),e.jsx(l.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})]})]})})}const vi=ge.Root,wi=J.forwardRef(({className:t,...a},s)=>e.jsx(ge.Item,{ref:s,className:Aa("border-b",t),...a}));wi.displayName="AccordionItem";const Ni=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(ge.Header,{className:"flex",children:e.jsxs(ge.Trigger,{ref:r,className:Aa("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ni.displayName=ge.Trigger.displayName;const yi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsx(ge.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:Aa("pb-4 pt-0",t),children:a})}));yi.displayName=ge.Content.displayName;const ji=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Root,{ref:s,className:Aa("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));ji.displayName=be.Root.displayName;const Ci=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Image,{ref:s,className:Aa("aspect-square h-full w-full",t),...a}));Ci.displayName=be.Image.displayName;const ki=J.forwardRef(({className:t,...a},s)=>e.jsx(be.Fallback,{ref:s,className:Aa("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));ki.displayName=be.Fallback.displayName;const Si=J.forwardRef(({...t},a)=>e.jsx("nav",{ref:a,"aria-label":"breadcrumb",...t}));Si.displayName="Breadcrumb";const _i=J.forwardRef(({className:t,...a},s)=>e.jsx("ol",{ref:s,className:Aa("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...a}));_i.displayName="BreadcrumbList";const Ai=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Aa("inline-flex items-center gap-1.5",t),...a}));Ai.displayName="BreadcrumbItem";const Ti=J.forwardRef(({asChild:t,className:s,...r},n)=>{const o=t?a.Slot:"a";return e.jsx(o,{ref:n,className:Aa("transition-colors hover:text-foreground",s),...r})});Ti.displayName="BreadcrumbLink";const Ei=J.forwardRef(({className:t,...a},s)=>e.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Aa("font-normal text-foreground",t),...a}));Ei.displayName="BreadcrumbPage";const Pi=({children:t,className:a,...s})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Aa("[&>svg]:h-3.5 [&>svg]:w-3.5",a),...s,children:t??e.jsx(l.ChevronRight,{})});Pi.displayName="BreadcrumbSeparator";const Mi=({className:t,...a})=>e.jsxs("span",{role:"presentation","aria-hidden":"true",className:Aa("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Mais"})]});Mi.displayName="BreadcrumbEllipsis";const Ii=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"}}),Di=J.forwardRef(({className:t,orientation:a,...s},r)=>e.jsx("div",{ref:r,className:Aa(Ii({orientation:a}),t),...s}));function Ri({className:t,classNames:a,showOutsideDays:s=!0,...r}){return e.jsx(D.DayPicker,{showOutsideDays:s,className:Aa("p-3 pointer-events-auto",t),locale:ma,classNames:{months:"relative flex flex-col gap-4 sm:flex-row",month:"flex flex-col gap-4",month_caption:"flex h-9 w-full items-center justify-center px-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1 px-1",button_previous:Aa(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Aa(Ea({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal w-9",week:"mt-2 flex w-full",day:"group/day relative h-9 w-9 select-none p-0 text-center text-sm [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md focus-within:relative focus-within:z-20",day_button:Aa(Ea({variant:"ghost"}),"h-9 w-9 p-0 font-normal transition-none aria-selected:opacity-100"),range_start:"bg-accent rounded-l-md",range_end:"bg-accent rounded-r-md",range_middle:"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground",selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground rounded-md",today:"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...a},components:{Chevron:({orientation:t})=>"left"===t?e.jsx(l.ChevronLeft,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})},...r})}Di.displayName="ButtonGroup",Ri.displayName="Calendar";const Li={Root:function({children:t,className:a}){return e.jsx("div",{className:Aa("space-y-4",a),children:t})},Item:function({children:t,onClick:a,className:s}){return e.jsx(La,{className:Aa("transition-colors",a&&"cursor-pointer hover:bg-muted/50",s),onClick:a,children:e.jsx(qa,{className:"p-4",children:t})})},Field:function({label:t,value:a,className:s}){return e.jsxs("div",{className:Aa("flex justify-between items-center text-sm",s),children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[t,":"]}),e.jsx("span",{className:"text-foreground",children:a})]})}};const zi=({shouldScaleBackground:t=!0,...a})=>e.jsx(R.Drawer.Root,{shouldScaleBackground:t,...a});zi.displayName="Drawer";const Fi=R.Drawer.Trigger,Ui=R.Drawer.Portal,qi=R.Drawer.Close,Oi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Overlay,{ref:s,className:Aa("fixed inset-0 z-50 bg-black/80",t),...a}));Oi.displayName=R.Drawer.Overlay.displayName;const Bi=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ui,{children:[e.jsx(Oi,{}),e.jsxs(R.Drawer.Content,{ref:r,className:Aa("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",t),...s,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));Bi.displayName="DrawerContent";const $i=({className:t,...a})=>e.jsx("div",{className:Aa("grid gap-1.5 p-4 text-center sm:text-left",t),...a});$i.displayName="DrawerHeader";const Hi=({className:t,...a})=>e.jsx("div",{className:Aa("mt-auto flex flex-col gap-2 p-4",t),...a});Hi.displayName="DrawerFooter";const Vi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Title,{ref:s,className:Aa("text-lg font-semibold leading-none tracking-tight",t),...a}));Vi.displayName=R.Drawer.Title.displayName;const Wi=J.forwardRef(({className:t,...a},s)=>e.jsx(R.Drawer.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Wi.displayName=R.Drawer.Description.displayName;const Gi={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))]"},Yi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Qi=ve.Root,Ki=ve.Trigger,Xi=J.forwardRef(({className:t,align:a="center",sideOffset:s=4,...r},n)=>e.jsx(ve.Content,{ref:n,align:a,sideOffset:s,className:Aa("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Xi.displayName=ve.Content.displayName;const Zi=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-slot":"input-group",className:Aa("flex min-w-0 items-center rounded-md border border-input bg-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background","has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50","has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:opacity-50",t),...a}));Zi.displayName="InputGroup";const Ji=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"}}),el=J.forwardRef(({className:t,align:a,...s},r)=>e.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Aa(Ji({align:a}),t),...s}));el.displayName="InputGroupAddon";const tl=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"}}),al=J.forwardRef(({className:t,size:a,variant:s="ghost",...r},n)=>e.jsx(Pa,{ref:n,"data-slot":"input-group-button",variant:s,className:Aa(tl({size:a}),"rounded-none first:rounded-l-md last:rounded-r-md",t),...r}));al.displayName="InputGroupButton";const sl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));sl.displayName="InputGroupInput";const rl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ms,{ref:s,"data-slot":"input-group-control",className:Aa("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",t),...a}));rl.displayName="InputGroupTextarea";const nl=J.forwardRef(({className:t,...a},s)=>e.jsx("h1",{ref:s,className:Aa("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",t),...a}));nl.displayName="H1";const ol=J.forwardRef(({className:t,...a},s)=>e.jsx("h2",{ref:s,className:Aa("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",t),...a}));ol.displayName="H2";const il=J.forwardRef(({className:t,...a},s)=>e.jsx("h3",{ref:s,className:Aa("scroll-m-20 text-2xl font-semibold tracking-tight",t),...a}));il.displayName="H3";const ll=J.forwardRef(({className:t,...a},s)=>e.jsx("h4",{ref:s,className:Aa("scroll-m-20 text-xl font-semibold tracking-tight",t),...a}));ll.displayName="H4";const dl=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("leading-7 [&:not(:first-child)]:mt-6",t),...a}));dl.displayName="P";const cl=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-xl text-muted-foreground",t),...a}));cl.displayName="Lead";const ul=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:Aa("text-lg font-semibold",t),...a}));ul.displayName="Large";const ml=J.forwardRef(({className:t,...a},s)=>e.jsx("small",{ref:s,className:Aa("text-sm font-medium leading-none",t),...a}));ml.displayName="Small";const pl=J.forwardRef(({className:t,...a},s)=>e.jsx("p",{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));pl.displayName="Muted";const hl=J.forwardRef(({className:t,...a},s)=>e.jsx("code",{ref:s,className:Aa("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",t),...a}));hl.displayName="InlineCode";const fl=J.forwardRef(({className:t,...a},s)=>e.jsx("blockquote",{ref:s,className:Aa("mt-6 border-l-2 pl-6 italic",t),...a}));fl.displayName="Blockquote";const xl=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Aa("my-6 ml-6 list-disc [&>li]:mt-2",t),...a}));xl.displayName="List";const gl=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(we.Root,{ref:r,className:Aa("relative z-10 flex max-w-max flex-1 items-center justify-center",t),...s,children:[a,e.jsx(Cl,{})]}));gl.displayName=we.Root.displayName;const bl=J.forwardRef(({className:t,...a},s)=>e.jsx(we.List,{ref:s,className:Aa("group flex flex-1 list-none items-center justify-center space-x-1",t),...a}));bl.displayName=we.List.displayName;const vl=we.Item,wl=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"),Nl=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(we.Trigger,{ref:r,className:Aa(wl(),"group",t),...s,children:[a," ",e.jsx(l.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));Nl.displayName=we.Trigger.displayName;const yl=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Content,{ref:s,className:Aa("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",t),...a}));yl.displayName=we.Content.displayName;const jl=we.Link,Cl=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:Aa("absolute left-0 top-full flex justify-center"),children:e.jsx(we.Viewport,{className:Aa("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",t),ref:s,...a})}));Cl.displayName=we.Viewport.displayName;const kl=J.forwardRef(({className:t,...a},s)=>e.jsx(we.Indicator,{ref:s,className:Aa("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",t),...a,children:e.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));kl.displayName=we.Indicator.displayName;const Sl=({className:t,...a})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Aa("mx-auto flex w-full justify-center",t),...a});Sl.displayName="Pagination";const _l=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,className:Aa("flex flex-row items-center gap-1",t),...a}));_l.displayName="PaginationContent";const Al=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,className:Aa("",t),...a}));Al.displayName="PaginationItem";const Tl=({className:t,isActive:a,size:s="icon",...r})=>e.jsx("a",{"aria-current":a?"page":void 0,className:Aa(Ea({variant:a?"outline":"ghost",size:s}),t),...r});Tl.displayName="PaginationLink";const El=({className:t,...a})=>e.jsxs(Tl,{"aria-label":"Go to previous page",size:"default",className:Aa("gap-1 pl-2.5",t),...a,children:[e.jsx(l.ChevronLeft,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});El.displayName="PaginationPrevious";const Pl=({className:t,...a})=>e.jsxs(Tl,{"aria-label":"Go to next page",size:"default",className:Aa("gap-1 pr-2.5",t),...a,children:[e.jsx("span",{children:"Next"}),e.jsx(l.ChevronRight,{className:"h-4 w-4"})]});Pl.displayName="PaginationNext";const Ml=({className:t,...a})=>e.jsxs("span",{"aria-hidden":!0,className:Aa("flex h-9 w-9 items-center justify-center",t),...a,children:[e.jsx(l.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Ml.displayName="PaginationEllipsis";const Il=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Root,{className:Aa("grid gap-2",t),...a,ref:s}));Il.displayName=Ne.Root.displayName;const Dl=J.forwardRef(({className:t,...a},s)=>e.jsx(Ne.Item,{ref:s,className:Aa("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(Ne.Indicator,{className:"flex items-center justify-center",children:e.jsx(l.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Dl.displayName=Ne.Item.displayName;const Rl=ye.Panel,Ll=te.Root,zl=te.Trigger,Fl=te.Close,Ul=te.Portal,ql=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Overlay,{className:Aa("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a,ref:s}));ql.displayName=te.Overlay.displayName;const Ol=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"}}),Bl=J.forwardRef(({side:t="right",className:a,children:s,...r},n)=>e.jsxs(Ul,{children:[e.jsx(ql,{}),e.jsxs(te.Content,{ref:n,className:Aa(Ol({side:t}),a),...r,children:[s,e.jsxs(te.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(l.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bl.displayName=te.Content.displayName;const $l=({className:t,showSeparator:a=!1,children:s,...r})=>e.jsxs("div",{className:Aa("flex flex-col flex-shrink-0",t),...r,children:[e.jsx("div",{className:"flex flex-col text-left",children:s}),a&&e.jsx(Ba,{className:"mt-2"})]});$l.displayName="SheetHeader";const Hl=({className:t,...a})=>e.jsx("div",{className:Aa("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",t),...a});Hl.displayName="SheetBody";const Vl=({className:t,children:a,...s})=>e.jsxs("div",{className:"flex-shrink-0 pt-4",children:[e.jsx(Ba,{className:"mb-4"}),e.jsx("div",{className:Aa("flex flex-row justify-end gap-2",t),...s,children:a})]});Vl.displayName="SheetFooter";const Wl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Title,{ref:s,className:Aa("text-lg font-semibold text-foreground",t),...a}));Wl.displayName=te.Title.displayName;const Gl=J.forwardRef(({className:t,...a},s)=>e.jsx(te.Description,{ref:s,className:Aa("text-sm text-muted-foreground",t),...a}));Gl.displayName=te.Description.displayName;const Yl="sidebar:state",Ql=J.createContext(null);function Kl(){const e=J.useContext(Ql);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Xl=J.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=Cn(),[c,u]=J.useState(!1),[m,p]=J.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Yl);return null!==e?"true"===e:t}return t}),h=a??m,f=J.useCallback(e=>{const t="function"==typeof e?e(h):e;s?s(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Yl,String(t))},[s,h]),x=J.useCallback(()=>d?u(e=>!e):f(e=>!e),[d,f,u]);J.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const g=h?"expanded":"collapsed",b=J.useMemo(()=>({state:g,open:h,setOpen:f,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:x}),[g,h,f,d,c,u,x]);return e.jsx(Ql.Provider,{value:b,children:e.jsx(Js,{delayDuration:0,children:e.jsx("div",{className:Aa("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",r),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4rem",...n},ref:l,...i,children:o})})})});Xl.displayName="SidebarProvider";const Zl=J.forwardRef(({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=Kl();return"none"===s?e.jsx("div",{className:Aa("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?e.jsx(Ll,{open:c,onOpenChange:u,...o,children:e.jsxs(Bl,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden sidebar-mobile",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsx(Wl,{className:"sr-only",children:"Menu de Navegação"}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:Aa("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:Aa("duration-200 fixed inset-y-0 z-30 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col overflow-visible group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:n})})]})});Zl.displayName="Sidebar";const Jl=J.forwardRef(({className:t,onClick:a,...s},r)=>{const{toggleSidebar:n}=Kl();return e.jsxs(Pa,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Aa("h-7 w-7",t),onClick:e=>{a?.(e),n()},...s,children:[e.jsx(l.PanelLeft,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Jl.displayName="SidebarTrigger";const ed=J.forwardRef(({className:t,...a},s)=>{const{toggleSidebar:r}=Kl();return e.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Aa("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});ed.displayName="SidebarRail";const td=J.forwardRef(({className:t,...a},s)=>e.jsx("main",{ref:s,className:Aa("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));td.displayName="SidebarInset";const ad=J.forwardRef(({className:t,...a},s)=>e.jsx(Ia,{ref:s,"data-sidebar":"input",className:Aa("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));ad.displayName="SidebarInput";const sd=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"header",className:Aa("flex flex-col gap-2 p-2",t),...a}));sd.displayName="SidebarHeader";const rd=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"footer",className:Aa("flex flex-col gap-2 p-2",t),...a}));rd.displayName="SidebarFooter";const nd=J.forwardRef(({className:t,...a},s)=>e.jsx(Ba,{ref:s,"data-sidebar":"separator",className:Aa("mx-2 w-auto bg-sidebar-border",t),...a}));nd.displayName="SidebarSeparator";const od=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"content",className:Aa("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));od.displayName="SidebarContent";const id=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group",className:Aa("relative flex w-full min-w-0 flex-col p-2",t),...a}));id.displayName="SidebarGroup";const ld=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"div";return e.jsx(o,{ref:n,"data-sidebar":"group-label",className:Aa("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r})});ld.displayName="SidebarGroupLabel";const dd=J.forwardRef(({className:t,asChild:s=!1,...r},n)=>{const o=s?a.Slot:"button";return e.jsx(o,{ref:n,"data-sidebar":"group-action",className:Aa("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r})});dd.displayName="SidebarGroupAction";const cd=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"group-content",className:Aa("w-full text-sm",t),...a}));cd.displayName="SidebarGroupContent";const ud=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu",className:Aa("flex w-full min-w-0 flex-col gap-1",t),...a}));ud.displayName="SidebarMenu";const md=J.forwardRef(({className:t,...a},s)=>e.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Aa("group/menu-item relative",t),...a}));md.displayName="SidebarMenuItem";const pd=s.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary/10 data-[active=true]:font-medium data-[active=true]:text-primary data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),hd=J.forwardRef(({asChild:t=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=t?a.Slot:"button",{isMobile:u,state:m}=Kl(),p=e.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:Aa(pd({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:p}),e.jsx(ar,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});hd.displayName="SidebarMenuButton";const fd=J.forwardRef(({className:t,asChild:s=!1,showOnHover:r=!1,...n},o)=>{const i=s?a.Slot:"button";return e.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Aa("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...n})});fd.displayName="SidebarMenuAction";const xd=J.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Aa("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));xd.displayName="SidebarMenuBadge";const gd=J.forwardRef(({className:t,showIcon:a=!1,...s},r)=>{const n=J.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return e.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Aa("rounded-md h-8 flex gap-2 px-2 items-center",t),...s,children:[a&&e.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});gd.displayName="SidebarMenuSkeleton";const bd=J.forwardRef(({className:t,...a},s)=>e.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Aa("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));bd.displayName="SidebarMenuSub";const vd=J.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));vd.displayName="SidebarMenuSubItem";const wd=J.forwardRef(({asChild:t=!1,size:s="md",isActive:r,className:n,...o},i)=>{const l=t?a.Slot:"a";return e.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:Aa("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===s&&"text-xs","md"===s&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});wd.displayName="SidebarMenuSubButton";const Nd=J.forwardRef(({className:t,value:a,defaultValue:s,...r},n)=>{const o=a||s||[0];return e.jsxs(je.Root,{ref:n,value:a,defaultValue:s,className:Aa("relative flex w-full touch-none select-none items-center",t),...r,children:[e.jsx(je.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(je.Range,{className:"absolute h-full bg-primary"})}),o.map((t,a)=>e.jsx(je.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},a))]})});Nd.displayName=je.Root.displayName;const yd=Ce.Menu,jd=Ce.Group,Cd=Ce.Portal,kd=Ce.Sub,Sd=Ce.RadioGroup,_d=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Root,{ref:s,className:Aa("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",t),...a}));_d.displayName=Ce.Root.displayName;const Ad=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Trigger,{ref:s,className:Aa("flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t),...a}));Ad.displayName=Ce.Trigger.displayName;const Td=J.forwardRef(({className:t,inset:a,children:s,...r},n)=>e.jsxs(Ce.SubTrigger,{ref:n,className:Aa("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",t),...r,children:[s,e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Td.displayName=Ce.SubTrigger.displayName;const Ed=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.SubContent,{ref:s,className:Aa("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));Ed.displayName=Ce.SubContent.displayName;const Pd=J.forwardRef(({className:t,align:a="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:o,align:a,alignOffset:s,sideOffset:r,className:Aa("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Pd.displayName=Ce.Content.displayName;const Md=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Item,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...s}));Md.displayName=Ce.Item.displayName;const Id=J.forwardRef(({className:t,children:a,checked:s,...r},n)=>e.jsxs(Ce.CheckboxItem,{ref:n,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:s,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Check,{className:"h-4 w-4"})})}),a]}));Id.displayName=Ce.CheckboxItem.displayName;const Dd=J.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Ce.RadioItem,{ref:r,className:Aa("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ce.ItemIndicator,{children:e.jsx(l.Circle,{className:"h-2 w-2 fill-current"})})}),a]}));Dd.displayName=Ce.RadioItem.displayName;const Rd=J.forwardRef(({className:t,inset:a,...s},r)=>e.jsx(Ce.Label,{ref:r,className:Aa("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...s}));Rd.displayName=Ce.Label.displayName;const Ld=J.forwardRef(({className:t,...a},s)=>e.jsx(Ce.Separator,{ref:s,className:Aa("-mx-1 my-1 h-px bg-muted",t),...a}));Ld.displayName=Ce.Separator.displayName;const zd=({className:t,...a})=>e.jsx("span",{className:Aa("ml-auto text-xs tracking-widest text-muted-foreground",t),...a});zd.displayname="MenubarShortcut";const Fd={light:"",dark:".dark"},Ud=J.createContext(null);function qd(){const e=J.useContext(Ud);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Od=J.forwardRef(({id:t,className:a,children:s,config:r,...n},o)=>{const i=J.useId(),l=`chart-${t||i.replace(/:/g,"")}`;return e.jsx(Ud.Provider,{value:{config:r},children:e.jsxs("div",{"data-chart":l,ref:o,className:Aa("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",a),...n,children:[e.jsx(Bd,{id:l,config:r}),e.jsx(ke.ResponsiveContainer,{children:s})]})})});Od.displayName="Chart";const Bd=({id:t,config:a})=>{const s=Object.entries(a).filter(([,e])=>e.theme||e.color);return s.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Fd).map(([e,a])=>`\n${a} [data-chart=${t}] {\n${s.map(([t,a])=>{const s=a.theme?.[e]||a.color;return s?` --color-${t}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},$d=ke.Tooltip,Hd=J.forwardRef(({active:t,payload:a,className:s,indicator:r="dot",hideLabel:n=!1,hideIndicator:o=!1,label:i,labelFormatter:l,labelClassName:d,formatter:c,color:u,nameKey:m,labelKey:p},h)=>{const{config:f}=qd(),x=J.useMemo(()=>{if(n||!a?.length)return null;const[t]=a,s=Gd(f,t,`${p||t?.dataKey||t?.name||"value"}`),r=p||"string"!=typeof i?s?.label:f[i]?.label||i;return l?e.jsx("div",{className:Aa("font-medium",d),children:l(r,a)}):r?e.jsx("div",{className:Aa("font-medium",d),children:r}):null},[i,l,a,n,d,f,p]);if(!t||!a?.length)return null;const g=1===a.length&&"dot"!==r;return e.jsxs("div",{ref:h,className:Aa("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:x,e.jsx("div",{className:"grid gap-1.5",children:a.map((t,a)=>{const s=`${m||t.name||t.dataKey||"value"}`,n=Gd(f,t,s),i=u||t.payload?.fill||t.color;return e.jsx("div",{className:Aa("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===r&&"items-center"),children:c&&void 0!==t?.value&&t.name?c(t.value,t.name,t,a,t.payload):e.jsxs(e.Fragment,{children:[n?.icon?e.jsx(n.icon,{}):!o&&e.jsx("div",{className:Aa("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":"dot"===r,"w-1":"line"===r,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===r,"my-0.5":g&&"dashed"===r}),style:{"--color-bg":i,"--color-border":i}}),e.jsxs("div",{className:Aa("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[g?x:null,e.jsx("span",{className:"text-muted-foreground",children:n?.label||t.name})]}),void 0!==t.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof t.value?t.value.toLocaleString():t.value})]})]})},t.dataKey||a)})})]})});Hd.displayName="ChartTooltip";const Vd=ke.Legend,Wd=J.forwardRef(({className:t,hideIcon:a=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=qd();return s?.length?e.jsx("div",{ref:o,className:Aa("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",t),children:s.map(t=>{const s=`${n||t.dataKey||"value"}`,r=Gd(i,t,s);return e.jsxs("div",{className:Aa("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!a?e.jsx(r.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:t.color}}),r?.label]},t.value)})}):null});function Gd(e,t,a){if("object"!=typeof t||null===t)return;const s="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0;let r=a;return a in t&&"string"==typeof t[a]?r=t[a]:s&&a in s&&"string"==typeof s[a]&&(r=s[a]),r in e?e[r]:e[a]}Wd.displayName="ChartLegend";const Yd=({onClick:t,isActive:a,disabled:s,children:r,title:n})=>e.jsx("button",{type:"button",onClick:t,disabled:s,title:n,className:Aa("p-1.5 rounded hover:bg-muted transition-colors",a?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Qd=()=>e.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Kd({onEdit:a,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:d=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=v.useTranslation(),p=t.useMemo(()=>{const e=[];return a&&o&&e.push({key:"edit",icon:l.Edit,label:m("edit","Editar"),onClick:a,variant:"default"}),r&&e.push({key:"toggle-status",icon:n?l.PowerOff:l.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),d.forEach(t=>{!1!==t.show&&e.push({key:`custom-${t.label}`,icon:t.icon,label:t.label,onClick:t.onClick,variant:t.variant||"default",disabled:t.disabled,disabledReason:t.disabledReason})}),s&&i&&e.push({key:"delete",icon:l.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),e},[a,s,r,n,o,i,d,m]);return 0===p.length?null:"dropdown"===c?e.jsx(Js,{delayDuration:200,children:e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:e.jsx(l.EllipsisVertical,{size:"compact"===u?14:16})})}),e.jsx(Ws,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(t=>t.disabled?e.jsxs(sr,{disabledReason:t.disabledReason,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key):e.jsxs(Gs,{onClick:t.onClick,className:"destructive"===t.variant?"text-destructive":"",children:[t.icon&&e.jsx(t.icon,{className:"mr-2 h-4 w-4"}),t.label]},t.key))})]})}):e.jsx("div",{className:"flex items-center gap-1",children:p.map(t=>e.jsxs(Pa,{variant:"destructive"===t.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:t.onClick,className:"compact"===u?"h-7 px-2":"",children:[t.icon&&e.jsx(t.icon,{size:"compact"===u?14:16}),"compact"!==u&&e.jsx("span",{className:"ml-1",children:t.label})]},t.key))})}function Xd(e){const t=j.useNavigate();return{onNew:()=>{const a=e.newPath||`${e.basePath}/new`;t(a)},onEdit:a=>{const s=e.editPath?e.editPath.replace(":id",a.id):`${e.basePath}/${a.id}/edit`;t(s)}}}const Zd=t.memo(({variant:a="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{user:o,companies:i,alias:d,isAuthenticated:c,logout:u,switchUnit:m}=Nn(),p=i?.[0]||null,h=d?i?.find(e=>e.alias===d):p,f=i||[],x=r||h||p||p,g=t.useCallback(e=>{n?n(e):m(e)},[n,m]),b=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),a=t.find(e=>e.alias===x?.alias),s=t.filter(e=>e.alias!==x?.alias);return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),a?[a,...s]:s},[f,x?.alias]);if(!c||!o)return null;return"dropdown"===a?e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:"ghost",className:`h-auto p-2 ${s}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:o.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?.name||"N/A"})]}),e.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-4 w-4 text-primary-foreground"})}),e.jsx(l.ChevronDown,{className:"h-4 w-4"})]})})}),e.jsxs(Ws,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[e.jsxs(Bs,{children:[e.jsxs(Hs,{children:[e.jsx(l.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),e.jsx(Vs,{children:b.map(t=>e.jsxs(Gs,{onClick:()=>g(t),className:t.alias===x?.alias?"bg-muted":"",children:[e.jsx(l.Building2,{className:"mr-2 h-4 w-4"}),t.name,t.alias===x?.alias&&e.jsx(Ds,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},t.alias))})]}),e.jsx(Xs,{}),e.jsxs(Gs,{onClick:u,children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):e.jsxs(La,{className:s,children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-lg",children:"Informações do Usuário"})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:e.jsx(l.User,{className:"h-5 w-5 text-primary-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",x?.name||"N/A"]})]})]}),x&&e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:x.name})]})}),b.length>1&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",b.length]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[b.slice(0,3).map(t=>e.jsx(Ds,{variant:t.alias===x?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>g(t),children:t.name},t.alias)),b.length>3&&e.jsxs(Ds,{variant:"outline",className:"text-xs",children:["+",b.length-3]})]})]})]}),{}),e.jsx(Ba,{}),e.jsxs(Pa,{variant:"outline",onClick:u,size:"sm",className:"w-full",children:[e.jsx(l.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Jd=t.createContext({});function ec({children:a,config:s}){const r=t.useMemo(()=>{const e=Yr(),t=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:t}},[s?.navigation,s?.appName]);return e.jsx(Jd.Provider,{value:r,children:a})}function tc(){return t.useContext(Jd)}function ac(e,t){if(!e)return"Página";const a=e.find(e=>e.path===t);if(a)return a.label;const s=e.find(e=>t.startsWith(e.path+"/"));return s?.label||"Página"}function sc(e,a){const[s,r]=t.useState(e),n=t.useRef(),o=t.useCallback(()=>{n.current&&(clearTimeout(n.current),n.current=void 0)},[]);return t.useEffect(()=>(o(),n.current=setTimeout(()=>{r(e)},a),o),[e,a,o]),[s,o]}const rc=t.memo(function({actions:a}){const s=j.useLocation(),{navigation:r,appName:n}=tc(),o=ac(r,s.pathname),{metadata:i,headerActions:d}=Uo(),{setOpenMobile:c}=Kl(),{companies:u,alias:m,isSearchVisible:p,clearSearch:h,refreshData:f,switchUnit:x}=Nn(),g=m?u?.find(e=>e.alias===m)||u?.[0]||null:u?.[0]||null,[b,v]=j.useSearchParams(),[w,N]=t.useState(()=>b.get("search")||""),[y,C]=sc(w,Xr.debounceDelay);t.useEffect(()=>{if(!p)return;const e=new URLSearchParams(b);y?(e.set("search",y),e.set("page","1")):e.delete("search"),v(e)},[y,v,p]);const k=r?.find(e=>e.path===s.pathname)||r?.find(e=>s.pathname.startsWith(e.path+"/")),S=i.title||o,_=i.subtitle||k?.complementaryText||"Detalhes do item";return e.jsx("header",{className:"bg-background border-b border-border px-2 md:px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Pa,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0",onClick:()=>c(!0),children:e.jsx(l.Menu,{size:20})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:S})}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:_})]}),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(l.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(Ia,{placeholder:"Pesquisar",value:w,onChange:e=>(e=>{N(e)})(e.target.value),className:"w-full pl-10 pr-8"}),w&&e.jsx(Pa,{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:()=>{C(),N("");const e=new URLSearchParams(b);e.delete("search"),e.delete("page"),v(e)},title:"Limpar busca",children:e.jsx(l.X,{size:14})})]}),e.jsx(Pa,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:e.jsx(l.RefreshCw,{size:14})})]}),e.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(d||a)&&e.jsx("div",{className:"flex items-center gap-2",children:d||a}),(void 0).VITE_WIKI_URL&&e.jsx(Pa,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>_a((void 0).VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),e.jsx("div",{className:"text-sm",children:e.jsx(Zd,{variant:"dropdown",selectedUnit:g,onUnitChange:x})})]})]})})}),nc=({key:e,enabled:t,checkFn:a,staleTime:s=3e5,gcTime:r=6e5})=>y.useQuery({queryKey:["permission",e],queryFn:a,enabled:t,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1}),oc=`https://${Gr().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,ic={logo:tn.isQualiex?`${oc}/logo-qualiex.svg`:`${oc}/logo.svg`,smallLogo:tn.isQualiex?`${oc}/small-forlogic.svg`:`${oc}/small.svg`},lc=ic.logo,dc=ic.smallLogo;function cc({open:a,appName:s}){const[r,n]=t.useState(!1);return e.jsxs(Js,{children:[e.jsx(sd,{className:"p-0 gap-0",children:a?e.jsxs("div",{className:"flex flex-col gap-3 pl-2",children:[e.jsx("div",{className:"flex items-center h-10",children:e.jsx("img",{src:ic.logo,alt:"Logo",className:"h-8 max-w-full object-contain"})}),e.jsxs(Pa,{variant:"secondary",size:"default",className:"h-10 gap-2 px-3 justify-start w-full",onClick:()=>n(!0),children:[e.jsx(l.Grip,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s||"Módulos"})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center w-full gap-3",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-8",children:e.jsx("img",{src:ic.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})}),e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center h-10 w-8 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>n(!0),children:e.jsx(l.Grip,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:s||"Módulos"})})]})]})}),e.jsx(hi,{open:r,onOpenChange:n})]})}function uc({config:t,isCollapsed:a=!1,isDisabled:s=!1,className:r}){const{actions:n,triggerLabel:o="Criar",triggerIcon:i=l.Plus}=t;if(!n||0===n.length)return null;const d=(t,s,r=!1)=>e.jsxs(e.Fragment,{children:[t,!a&&s&&e.jsx("span",{className:"truncate",children:s}),!a&&r&&e.jsx(l.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(n.length>1)){const t=n[0],o=t.icon||i,l=s||t.disabled,c=e.jsx(Pa,{onClick:t.onClick,disabled:l,className:Aa("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(o,{className:"h-4 w-4 shrink-0"}),t.label)});return a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:c}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]}):c}const c=e.jsx(Pa,{disabled:s,className:Aa("w-full gap-2 justify-start",a&&"justify-center px-2",r),variant:"outline",size:"default",children:d(e.jsx(i,{className:"h-4 w-4 shrink-0"}),o,!0)});return e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:a?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:c}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o})})]}):c}),e.jsx(Ws,{align:"start",side:a?"right":"bottom",className:"w-56 bg-popover",children:n.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:"cursor-pointer",children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})}const mc="forlogic-sidebar-pinned",pc=()=>{try{const e=localStorage.getItem(mc);return!!e&&JSON.parse(e)}catch{return!1}};function hc({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=240,storageKey:n="sidebar-width",onResize:o,isOpen:i=!0}={}){const[l,d]=t.useState(()=>{if("undefined"==typeof window)return r;const e=localStorage.getItem(n);return e?parseInt(e):r}),[c,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(i?e.style.setProperty("--sidebar-width",`${l}px`):e.style.setProperty("--sidebar-width","240px"))},[l,i]);const p=t.useCallback(e=>{e.preventDefault(),u(!0)},[]);return t.useEffect(()=>{if(!c)return;const t=t=>{let r;r="left"===e?window.innerWidth-t.clientX:t.clientX,r=Math.max(a,Math.min(s,r)),d(r),o?.(r)},r=()=>{u(!1),d(e=>(localStorage.setItem(n,e.toString()),e))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r)}},[c,e,a,s,l,n,o]),t.useEffect(()=>(c?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[c,e]),{width:l,isDragging:c,dragRef:m,handleMouseDown:p}}const fc=t.createContext(void 0);function xc(){const e=t.useContext(fc);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function gc({config:a,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{open:i,setOpen:d}=Kl(),c=j.useLocation(),{alias:u,user:m}=Nn(),{appName:p}=tc(),{hasOpenModal:h}=xc(),[f,x]=t.useState(pc),g=r?hc({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:i}):null;t.useEffect(()=>{d(!!f)},[f,d]);const b=e=>c.pathname===e||c.pathname.startsWith(e+"/");return e.jsxs(Zl,{collapsible:"icon",className:Aa("app-sidebar bg-background border-r border-border py-4",i?"px-3":"px-1.5"),style:g&&i?{width:`${g.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[e.jsx(cc,{open:i,appName:p}),a?.moduleActions&&a.moduleActions.actions.length>0&&e.jsx("div",{className:"py-3",children:e.jsx(Js,{children:e.jsx(uc,{config:a.moduleActions,isCollapsed:!i,isDisabled:h})})}),e.jsxs("div",{className:"relative py-5",children:[e.jsx(Ba,{}),e.jsx("div",{className:Aa("absolute top-1/2 -translate-y-1/2 z-[100] hidden md:block",i?"-right-6":"-right-[18px]"),children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("button",{onClick:()=>{const e=!f;x(e),(e=>{try{localStorage.setItem(mc,JSON.stringify(e))}catch{}})(e)},className:"h-6 w-6 flex items-center justify-center rounded-full bg-primary hover:bg-primary/90 shadow-md transition-colors",children:i?e.jsx(l.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):e.jsx(l.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:i?"Recolher":"Expandir"})})]})})]}),e.jsx(od,{children:s||e.jsx(id,{className:"p-0",children:e.jsx(cd,{children:e.jsx(ud,{className:"gap-1",children:e.jsx(Js,{children:a?.navigation?.map((t,a)=>{const s=({item:t,index:a})=>{const r=`${t.path}-${a}-${u??"noalias"}-${m?.id??"nouser"}`,{data:n=!0,isLoading:o}=nc({key:r,enabled:Boolean(t.permissionCheck&&u&&m?.id),checkFn:t.permissionCheck||(()=>Promise.resolve(!0))}),d=t.permissionCheck&&!n,c=o?l.Loader2:d?l.Lock:t.icon;d||t.complementaryText;return t.children&&t.children.length>0?i?e.jsx(Qo,{defaultOpen:!0,className:"group/collapsible",children:e.jsxs(md,{children:[e.jsx(Ko,{asChild:!0,children:e.jsx(hd,{size:"default",children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label}),e.jsx(l.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),e.jsx(Xo,{children:e.jsx(bd,{children:t.children.map((t,a)=>e.jsx(s,{item:t,index:a},t.path))})})]})},t.path):e.jsx(md,{children:e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx("div",{className:Aa("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors cursor-pointer","hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path):e.jsx(md,{children:d||o?e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:i?e.jsx(hd,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsx("div",{className:"flex items-center justify-center h-8 w-8 mx-auto rounded-md opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:e.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:o?"Verificando acesso...":"Acesso restrito"})})]}):i?e.jsx(hd,{asChild:!0,isActive:b(t.path),size:"default",children:e.jsxs(j.Link,{to:t.path,className:"flex w-full items-center gap-3",children:[e.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:e.jsx(c,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium sidebar-text",children:t.label})]})}):e.jsxs(er,{children:[e.jsx(tr,{asChild:!0,children:e.jsx(j.Link,{to:t.path,className:Aa("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",b(t.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsx(ar,{side:"right",children:e.jsx("p",{children:t.label})})]})},t.path)};return e.jsx(s,{item:t,index:a},t.path)})})})})})}),r&&g&&i&&e.jsx("div",{ref:g.dragRef,onMouseDown:g.handleMouseDown,className:Aa("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",g.isDragging&&"bg-primary/40")})]})}const bc=t.memo(function({children:a,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||e.jsx(gc,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return e.jsx(ec,{config:r,children:e.jsx(Fo,{children:e.jsx(Xl,{defaultOpen:!1,style:i,children:e.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[o,e.jsxs("main",{className:"relative z-0 flex-1 flex flex-col h-screen overflow-hidden",children:[n&&e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:e.jsx(rc,{})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-muted/30",children:a})]})]})})})})});class vc{static async sendEmail(e){const t=Ur(),{data:a,error:s}=await t.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return a}}const wc=vc;function Nc({open:a,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:d,currentMemberIds:c=[]}){const[u,m]=t.useState([]),[p,h]=t.useState(!1),[f,x]=t.useState(""),{data:g=[],isLoading:b}=vo({enabled:a}),v=t.useMemo(()=>{let e=[...g];if(e.sort((e,t)=>{const a=e.userName?.toLowerCase()||"",s=t.userName?.toLowerCase()||"";return a.localeCompare(s)}),f){const t=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,f]),w=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},N=1===u.length,y=u.length>0;return e.jsx(es,{open:a,onOpenChange:s,children:e.jsxs(os,{className:"max-w-2xl",variant:"form",children:[e.jsx(is,{showSeparator:!0,children:e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),e.jsxs(ls,{children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{placeholder:"Pesquisar...",value:f,onChange:e=>x(e.target.value),className:"pl-9"})]}),e.jsx(vr,{className:"h-[400px] pr-4",children:b?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-16 w-full"},a))}):0===v.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(l.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):e.jsx("div",{className:"space-y-2",children:v.map(t=>{const a=t.userId===d,s=c.includes(t.userId||""),r=u.includes(t.userId||"");return e.jsxs("div",{className:Aa("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>w(t.userId||""),children:[e.jsx(Ps,{checked:r,onCheckedChange:()=>w(t.userId||""),onClick:e=>e.stopPropagation()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:t.userName}),a&&e.jsx(l.Crown,{className:"h-4 w-4 text-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.userEmail})]}),(a||s)&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a?"Gestor":"Membro"})]},t.userId)})})})]}),e.jsxs(ds,{className:"flex gap-2 sm:gap-2",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&e.jsxs("span",{children:[u.length," selecionado(s)"]})}),N&&o&&e.jsxs(Pa,{onClick:async()=>{if(o&&1===u.length){h(!0);try{await o(u[0],r),m([])}finally{h(!1)}}},disabled:p,variant:"outline",children:[e.jsx(l.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),y&&i&&e.jsxs(Pa,{onClick:async()=>{if(i&&0!==u.length){h(!0);try{await i(u,r),m([])}finally{h(!1)}}},disabled:p,children:[e.jsx(l.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function yc({place:a,level:s=0,manageAccessConfig:r}){const[n,o]=t.useState(!1),[i,d]=t.useState(!1),c=a.subPlaces&&a.subPlaces.length>0,u=a.isActive??!0,m=a.usersCount??0;return e.jsxs("div",{children:[e.jsxs(Qo,{open:n,onOpenChange:o,children:[e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*s+1+"rem"},children:[c?e.jsxs(Ko,{className:"flex items-center gap-2 flex-1",children:[e.jsx(l.ChevronRight,{className:Aa("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",a.subPlaces.length,")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-4 shrink-0"}),e.jsx(l.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:a.name})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(l.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:m})]}),e.jsx(Ds,{variant:u?"default":"secondary",className:"text-xs",children:u?"Ativo":"Inativo"}),r&&e.jsx(Kd,{customActions:[{label:"Gerenciar Acessos",icon:l.Settings,onClick:()=>d(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),c&&e.jsx(Xo,{children:a.subPlaces.map(t=>e.jsx(yc,{place:t,level:s+1,manageAccessConfig:r},t.id))})]}),0===s&&e.jsx(Ba,{}),r&&e.jsx(Nc,{open:i,onOpenChange:d,placeId:a.id,placeName:a.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(a.id),currentMemberIds:r.getCurrentMemberIds?.(a.id)})]})}const jc=new class{get baseUrl(){return Jr()}async makeApiCall(e,t,a){const s=$r.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=Dr.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!a||""===a.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{n.searchParams.append(e,t)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":a}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const t=new Map,a=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=t.get(e.id);if(e.parentId){const r=t.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):a.push(s)}else a.push(s)}),a}async getPlaces(e,t){try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(a){if(await $r.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),s=a.data||a||[];return this.buildHierarchy(s)}catch(s){return Rr.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return Rr.handleError(a instanceof Error?a.message:"Erro ao buscar locais",!0),[]}}};function Cc(e){const t=new Map,a=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};t.set(e.id,s),a.set(e.id_user,s)}),e.forEach(e=>{const r=t.get(e.id);if(e.id_leader){const t=a.get(e.id_leader);if(t)return void t.children.push(r)}s.push(r)});const r=(e,t)=>{e.level=t,e.children.forEach(e=>r(e,t+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,t)=>{const a=e.name||e.id_user||e.email||"",s=t.name||t.id_user||t.email||"";return a.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function kc(e){const t=[],a=e=>{t.push(e),e.children.forEach(a)};return e.forEach(a),t}function Sc(){const{alias:e,isAuthenticated:t}=Nn(),a=Dr.getAccessToken(),{data:s=[]}=vo({enabled:!0});return y.useQuery({queryKey:["leadership",e],queryFn:async()=>{if(!a||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Ur(),{data:r,error:n}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(n)throw new Error("Erro ao buscar hierarquia de liderança");if(!r||0===r.length)return[];const o={};s.forEach(e=>{o[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const i=r.map(e=>({...e,name:o[e.id_user]?.name||"[Não encontrado]",email:o[e.id_user]?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e.id_user).length})),l=new Set(r.map(e=>e.id_user));return new Set(r.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=o[e];i.push({id:`virtual-${e}`,alias:r[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||"[Não encontrado]",email:t?.email||"",subordinatesCount:r.filter(t=>t.id_leader===e).length})}),Cc(i)},enabled:!!a&&!!e&&t&&s.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const _c="common";function Ac(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(t.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Ic(a,e,t.id_user,t.id_leader);const{data:r,error:n}=await a.schema(_c).from("leaders").insert({alias:e,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",e]}),i.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function Tc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!t.users.length)throw new Error(s("select_at_least_one","Selecione pelo menos um liderado"));const r=t.users.map(e=>e.id_user),{data:n}=await a.schema(_c).from("leaders").select("id_user").eq("alias",e).in("id_user",r).eq("is_removed",!1);if(n&&n.length>0){const e=n.map(e=>e.id_user);throw new Error(s("users_already_leaders",`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(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Ic(a,e,d.id_user,t.id_leader)}const o=t.users.map(a=>({alias:e,id_user:a.id_user,id_leader:t.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await a.schema(_c).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_added_success",`${a?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{i.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function Ec(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await a.schema(_c).from("leaders").select("id_user").eq("id",t.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===t.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));t.id_leader&&await Ic(a,e,r.id_user,t.id_leader,t.id);const{data:n,error:o}=await a.schema(_c).from("leaders").update({id_leader:t.id_leader}).eq("id",t.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Pc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async t=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await a.schema(_c).from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{i.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function Mc(){const{alias:e}=Nn(),t=y.useQueryClient(),a=Ur(),{t:s}=v.useTranslation();return y.useMutation({mutationFn:async({leaderUserId:t,selectedUsers:r})=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const n=r.map(e=>e.id_user),o=await Promise.all([a.schema(_c).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",t),a.schema(_c).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).in("id_user",n.length?n:["__none__"])]),[{data:i,error:l},{data:d,error:c}]=o;if(l)throw l;if(c)throw c;const u=i||[],m=d||[],p=new Set(n),h=u.filter(e=>!p.has(e.id_user)),f=m.filter(e=>e.id_leader!==t),x=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!x.has(e.id_user));for(const s of f)await Ic(a,e,s.id_user,t,s.id);for(const w of g){if(w.id_user===t)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await Ic(a,e,w.id_user,t)}const b=[];if(h.length){const t=h.map(e=>e.id);b.push(a.schema(_c).from("leaders").update({is_removed:!0}).in("id",t).eq("alias",e))}if(f.length){const s=f.map(e=>e.id);b.push(a.schema(_c).from("leaders").update({id_leader:t}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(a=>({alias:e,id_user:a.id_user,id_leader:t,is_active:!0,is_removed:!1}));b.push(a.schema(_c).from("leaders").insert(s))}const v=(await Promise.all(b)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:h.length,updated:f.length,created:g.length}},onSuccess:a=>{t.invalidateQueries({queryKey:["leadership",e]}),i.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${a.created} adicionados, ${a.updated} atualizados, ${a.unlinked} removidos)`))},onError:e=>{i.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function Ic(e,t,a,s,r){const{data:n,error:o}=await e.schema(_c).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const i=r?n.filter(e=>e.id!==r):n,l=new Set;let d=s;for(;d;){if(l.has(d))throw new Error("Esta associação criaria um ciclo na hierarquia");if(d===a)throw new Error("Esta associação criaria um ciclo na hierarquia");l.add(d);const e=i.find(e=>e.id_user===d);d=e?.id_leader||null}}function Dc({leader:t,expandedIds:a,onToggleExpand:s,onEdit:r}){const n=a.has(t.id),o=t.children.length>0,i=32*t.level;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[o?e.jsx("button",{onClick:()=>s(t.id),className:"p-1 hover:bg-accent rounded",children:n?e.jsx(l.ChevronDown,{className:"h-4 w-4"}):e.jsx(l.ChevronRight,{className:"h-4 w-4"})}):e.jsx("div",{className:"w-6"}),e.jsx(l.User,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>{r(t)},className:"font-medium hover:text-primary hover:underline text-left",children:t.name||t.id_user||t.email})]})}),e.jsx("td",{className:"py-3 px-4 text-center",children:e.jsx("span",{className:"text-sm",children:t.subordinatesCount||0})})]}),o&&n&&t.children.map(t=>e.jsx(Dc,{leader:t,expandedIds:a,onToggleExpand:s,onEdit:r},t.id))]})}var Rc=function(e,t){for(var a={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!a[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];a[o]={message:i.message,type:i.code}}else a[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=a[o].types,d=l&&l[s.code];a[o]=p.appendErrors(o,t,a,r,d?[].concat(d,s.message):s.message)}e.shift()}return a},Lc=function(e,t,a){return void 0===a&&(a={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===a.mode?"parse":"parseAsync"](s,t)).then(function(e){return n.shouldUseNativeValidation&&X.validateFieldsNatively({},n),{errors:{},values:a.raw?s:e}})}catch(l){return o(l)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:X.toNestErrors(Rc(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const zc=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string()).min(1,"Selecione pelo menos um liderado")}),Fc=K.z.object({id_leader:K.z.string().nullable(),id_users:K.z.array(K.z.string())});function Uc({value:a,onChange:s,excludeUserIds:r=[],error:n}){const{data:o=[],isLoading:i}=vo(),[d,c]=t.useState(""),u=t.useRef(null),m=t.useRef(0),p=o.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=d.toLowerCase(),a=e.userName?.toLowerCase().includes(t);return a}).sort((e,t)=>{const s=a.includes(e.userId),r=a.includes(t.userId);if(s&&!r)return-1;if(!s&&r)return 1;const n=e.userName||e.userEmail||"",o=t.userName||t.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[p]),i?e.jsxs("div",{className:"flex items-center justify-center p-4",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ia,{placeholder:"Buscar usuário...",value:d,onChange:e=>c(e.target.value)}),e.jsx("div",{ref:u,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===p.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Buscar usuário..."}):e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ps,{id:t.userId,checked:a.includes(t.userId),onCheckedChange:()=>{return e=t.userId,u.current&&(m.current=u.current.scrollTop),void(a.includes(e)?s(a.filter(t=>t!==e)):s([...a,e]));var e}}),e.jsx(Ra,{htmlFor:t.userId,className:"flex-1 cursor-pointer",children:t.userName||t.userEmail})]},t.userId))})}),a.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.length," selecionado(s)"]}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function qc({leader:a,prefilledLeaderId:s,onSuccess:r}){const{alias:n}=Nn(),o=!!a,i=a?.id.startsWith("virtual-"),d=Tc(),c=Ac(),u=Ec(),m=Mc(),h=Pc(),{data:f=[]}=Sc(),{data:x=[]}=vo(),[g,b]=t.useState(""),v=kc(f).map(e=>e.id_user),w=o?kc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user):[],N=p.useForm({resolver:Lc(o?Fc:zc),defaultValues:{id_leader:s||(o?a?.id_leader:null)||null,id_users:o?w:[]}});t.useEffect(()=>{if(a){const e=kc(f).filter(e=>e.id_leader===a.id_user).map(e=>e.id_user);N.reset({id_leader:a.id_leader||null,id_users:e})}else s?N.reset({id_leader:s,id_users:[]}):N.reset({id_leader:null,id_users:[]})},[n,a?.id,a?.id_user,a?.id_leader,s,f]);const y=d.isPending||c.isPending||u.isPending||m.isPending||h.isPending,j=N.watch("id_leader"),C=N.watch("id_users"),k=o?[a.id_user,...v.filter(e=>e!==a.id_user&&!C.includes(e)&&!w.includes(e))]:[j,...v.filter(e=>!C.includes(e))].filter(Boolean);return e.jsxs("form",{onSubmit:N.handleSubmit(async e=>{try{if(o)if(i){await c.mutateAsync({id_user:a.id_user,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{await u.mutateAsync({id:a.id,id_leader:e.id_leader});const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await m.mutateAsync({leaderUserId:a.id_user,selectedUsers:t})}else{const t=x.filter(t=>e.id_users.includes(t.userId)).map(e=>({id_user:e.userId}));await d.mutateAsync({id_leader:e.id_leader,users:t})}r?.()}catch(t){}}),className:"space-y-4",children:[o&&e.jsxs("div",{children:[e.jsx(Ra,{children:"Líder"}),e.jsx(Ia,{value:x.find(e=>e.userId===a.id_user)?.userName||a.name||a.id_user,disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Superior Imediato"}),e.jsxs(Ns,{value:j||"none",onValueChange:e=>N.setValue("id_leader","none"===e?null:e),children:[e.jsx(Cs,{children:e.jsx(js,{placeholder:"Selecione..."})}),e.jsxs(_s,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:e.jsx(Ia,{placeholder:"Buscar superior...",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),e.jsxs(vr,{className:"h-[200px]",children:[e.jsx(Ts,{value:"none",children:"[Nenhum]"}),x.filter(e=>{const t=o?e.userId!==a.id_user:!C.includes(e.userId),s=!g||e.userName?.toLowerCase().includes(g.toLowerCase());return t&&s}).sort((e,t)=>{const a=e.userName||e.userEmail||"",s=t.userName||t.userEmail||"";return a.localeCompare(s)}).map(t=>e.jsx(Ts,{value:t.userId,children:t.userName},t.userId))]})]})]},`superior-select-${n}`),N.formState.errors.id_leader&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:N.formState.errors.id_leader.message})]}),e.jsxs("div",{children:[e.jsx(Ra,{children:"Subordinados *"}),e.jsx(Uc,{value:C,onChange:e=>N.setValue("id_users",e),excludeUserIds:k,error:N.formState.errors.id_users?.message},`users-multiselect-${n}`)]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Pa,{type:"submit",disabled:y||!o&&0===C.length,children:y&&!h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Atualizando...":"Salvando..."]}):o?"Atualizar":"Criar"}),o&&!j&&0===C.length&&e.jsxs($a,{children:[e.jsx(Ha,{asChild:!0,children:e.jsx(Pa,{type:"button",variant:"destructive",disabled:y,className:"ml-auto",children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),e.jsxs(Ga,{children:[e.jsxs(Ya,{children:[e.jsx(Ka,{children:"Confirmar remoção"}),e.jsx(Xa,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),e.jsxs(Qa,{children:[e.jsx(Ja,{children:"Cancelar"}),e.jsx(Za,{onClick:async()=>{if(a)try{await h.mutateAsync(a.id),r?.()}catch(e){}},children:"Remover"})]})]})]})]})]})}function Oc({open:t,onOpenChange:a,leader:s,prefilledLeaderId:r,title:n}){return e.jsx(es,{open:t,onOpenChange:a,children:e.jsxs(os,{variant:"form",className:"sm:max-w-[500px]",children:[e.jsx(is,{showSeparator:!0,children:e.jsx(cs,{children:n})}),e.jsx(ls,{children:e.jsx(qc,{leader:s,prefilledLeaderId:r,onSuccess:()=>a(!1)})})]})})}const Bc="leadership-expanded-nodes",$c=(e,t)=>{try{localStorage.setItem(`${Bc}-${e}`,JSON.stringify(Array.from(t)))}catch(a){}};function Hc(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:l,onError:d}=e||{};return{upload:async(e,t)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const a={...o,...t};if(a.maxSize&&e.size>a.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(a.maxSize/1024/1024)}MB`);if(a.allowedTypes){const t=a.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t);if(!t)throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${a.allowedTypes.join(", ")}`)}const s=await r(e,a);return i.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),l?.(s),s}catch(a){const e=a instanceof Error?a:new Error("Erro ao fazer upload");throw i.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,t)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw i.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,t),i.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(a){throw i.toast.error("Erro",{description:"Erro ao remover o arquivo"}),a}},uploading:a}}function Vc(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const a of t){const t=e.match(a);if(t)return t[1]}return null}function Wc(e,t){const a=Vc(e);if(!a)return e;return`https://www.youtube.com/embed/${a}${t?"?autoplay=1&mute=1":""}`}function Gc(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function Yc(e,t){const a=Gc(e);if(!a)return e;return`https://player.vimeo.com/video/${a}${t?"?autoplay=1&muted=1":""}`}function Qc(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function Kc(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function Xc(e,t){return e/t}function Zc(){const{alias:e}=Nn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let t=!1;return(async()=>{n(!0);try{const a=Ur(),{data:r,error:n}=await a.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();t||s(r)}catch(a){t||s(null)}finally{t||n(!1)}})(),()=>{t=!0}},[e]);const o=t.useCallback(async(t,a)=>{if(!e)throw new Error("Alias not available");const r=Ur(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:t,environment:a,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e]);return{config:a,isLoading:r,saveConfig:o}}const Jc=(void 0).VITE_SUPABASE_URL,eu=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function tu(e,t,a){const s=Dr.getSupabaseToken(),r={"Content-Type":"application/json",apikey:eu};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${Jc}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:t,data:a})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const au={async createEnvelopeWithSigner(e){const t="d4sign"===e.provider?"d4sign":"clicksign",a="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await tu(t,a,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const t="d4sign"===e.provider?"d4sign":"clicksign";return(await tu(t,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let su=null;function ru(){return window.Clicksign?Promise.resolve():su||(su=new Promise((e,t)=>{const a=document.createElement("script");a.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",a.onload=()=>e(),a.onerror=()=>t(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(a)}),su)}const nu="clicksign-container";function ou({signerId:a,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const i=t.useRef(null),[d,c]=t.useState(!0),[u,m]=t.useState(null);return t.useEffect(()=>{let e=!1;return i.current&&(i.current.unmount(),i.current=null),m(null),c(!0),ru().then(()=>{if(e)return;const t=new window.Clicksign(a);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(nu),t.on("loaded",function(){c(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const t=e,a=document.getElementById(nu);a&&t?.data?.height&&(a.style.height=t.data.height+"px")}),t.on("error",function(e){c(!1),n?.(e instanceof Error?e:new Error("Erro no widget de assinatura"))}),t.on("closed",function(){o?.()}),i.current=t}).catch(t=>{e||(m("Falha ao carregar o script de assinatura."),c(!1),n?.(t))}),()=>{e=!0,i.current&&(i.current.unmount(),i.current=null)}},[a,s]),e.jsxs("div",{className:"relative h-full",children:[d&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-destructive",children:u})}),e.jsx("div",{id:nu,style:{height:"600px"}})]})}function iu({documentKey:a,signerEmail:s,signerName:r,keySigner:n,environment:o,onSign:i,onError:d}){const c=t.useRef(null),[u,m]=t.useState("loading"),[p,h]=t.useState(null),f="production"===o?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",x=(()=>{const e=new URLSearchParams({email:s,display_name:r||"",disable_preview:"0"});return n&&e.set("key_signer",n),`${f}/${a}?${e.toString()}`})(),g=t.useCallback(e=>"signed"===e.data?(m("ready"),void i?.()):"wrong-data"===e.data?(m("error"),h("O signatário reportou dados incorretos."),void d?.(new Error("O signatário reportou dados incorretos"))):void 0,[i,d]);t.useEffect(()=>(window.addEventListener("message",g,!1),()=>{window.removeEventListener("message",g,!1)}),[g]);const b=t.useCallback(()=>{"loading"===u&&m("ready")},[u]);return"error"===u?e.jsxs(Do,{variant:"danger",className:"my-4",children:[e.jsx(Ro,{children:"Erro ao carregar documento"}),e.jsx(Lo,{children:p||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):e.jsxs("div",{className:"relative h-full",children:["loading"===u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(l.Loader2,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),e.jsx("iframe",{ref:c,id:"d4sign-container",src:x,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return i.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return v.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return v.useTranslation}}),exports.i18n=A,exports.AUTH_CONFIG=Qr,exports.Accordion=vi,exports.AccordionContent=yi,exports.AccordionItem=wi,exports.AccordionTrigger=Ni,exports.ActionButton=Ma,exports.ActionMenu=Kd,exports.ActionMenuItems=eo,exports.Alert=Do,exports.AlertDescription=Lo,exports.AlertDialog=$a,exports.AlertDialogAction=Za,exports.AlertDialogCancel=Ja,exports.AlertDialogContent=Ga,exports.AlertDialogDescription=Xa,exports.AlertDialogFooter=Qa,exports.AlertDialogHeader=Ya,exports.AlertDialogOverlay=Wa,exports.AlertDialogPortal=Va,exports.AlertDialogTitle=Ka,exports.AlertDialogTrigger=Ha,exports.AlertTitle=Ro,exports.AppHeader=rc,exports.AppLayout=bc,exports.AppSidebar=gc,exports.AuthErrorInterceptor=Br,exports.AuthProvider=wn,exports.AuthService=xn,exports.Avatar=ji,exports.AvatarFallback=ki,exports.AvatarImage=Ci,exports.Badge=Ds,exports.BaseForm=No,exports.Blockquote=fl,exports.BodyContent=function({breadcrumbs:t,children:a,className:s}){return e.jsxs("div",{className:Aa("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[t&&t.length>0&&e.jsx(Si,{className:"mb-4",children:e.jsx(_i,{children:t.map((a,s)=>{const r=s===t.length-1;return e.jsxs(J.Fragment,{children:[s>0&&e.jsx(Pi,{}),e.jsx(Ai,{children:r||!a.href?e.jsx(Ei,{children:a.label}):a.asChild&&a.children?e.jsx(Ti,{asChild:!0,children:a.children}):e.jsx(Ti,{asChild:!0,children:e.jsx(j.Link,{to:a.href||"/",children:a.label})})})]},`${a.label}-${s}`)})})}),e.jsx("div",{className:"space-y-6",children:a})]})},exports.Breadcrumb=Si,exports.BreadcrumbEllipsis=Mi,exports.BreadcrumbItem=Ai,exports.BreadcrumbLink=Ti,exports.BreadcrumbList=_i,exports.BreadcrumbPage=Ei,exports.BreadcrumbSeparator=Pi,exports.Button=Pa,exports.ButtonGroup=Di,exports.CRUD_CONFIG=Kr,exports.Calendar=Ri,exports.CallbackPage=()=>{const{processCallback:a}=Nn(),s=j.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await a()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");localStorage.removeItem("auth_return_url"),s(e||"/",{replace:!0})}else n("Falha na autenticação. Tente novamente.")}catch(e){localStorage.removeItem("auth_return_url"),n(e?.message||"Erro durante a autenticação. Tente novamente.")}})()},[a,s]);const d=async()=>{i(!0),n(null);try{await a()||n("Falha na autenticação. Tente novamente.")}catch(e){n(e?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsxs(Fa,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[e.jsx(l.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),e.jsxs(qa,{className:"space-y-4",children:[e.jsx(Do,{variant:"danger",children:e.jsx(Lo,{children:r})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pa,{onClick:d,disabled:o,className:"flex-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{size:"sm",className:"mr-2"}),"Tentando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),e.jsx(Pa,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:e.jsxs(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),e.jsxs(qa,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ls,{size:"lg"})}),e.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=La,exports.CardContent=qa,exports.CardDescription=Ua,exports.CardFooter=Oa,exports.CardHeader=za,exports.CardSkeleton=Dn,exports.CardTitle=Fa,exports.ChartContainer=Od,exports.ChartLegend=Vd,exports.ChartLegendContent=Wd,exports.ChartStyle=Bd,exports.ChartTooltip=$d,exports.ChartTooltipContent=Hd,exports.Checkbox=Ps,exports.Collapsible=Qo,exports.CollapsibleContent=Xo,exports.CollapsibleTrigger=Ko,exports.ColorPicker=fo,exports.ComboTree=function({multiple:a=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:d,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:f,className:x,maxDisplayedBadges:g,popoverContainer:b,onOpen:w,onClose:N}){const{t:y}=v.useTranslation(),[j,C]=t.useState(!1),[k,S]=t.useState(""),[_,A]=t.useState(new Set),T=o||y("select_placeholder","Selecione..."),E=c||y("no_results","Nenhum resultado encontrado"),P=u||y("search_placeholder","Pesquisar..."),M=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),I=t.useMemo(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const a=window.getComputedStyle(e),s=a.overflowY||a.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),D=t.useMemo(()=>yr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,t){const a=new Set,s=Nr(t);function r(e){if(!e.children||0===e.children.length)return Nr(e.label).includes(s);let t=!1;for(const a of e.children)r(a)&&(t=!0);return t&&a.add(e.value),t||Nr(e.label).includes(s)}for(const n of e)r(n);return a}(s,k):new Set,[s,k]),L=k?R:_,z=t.useCallback(e=>{k||A(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[k]),F=t.useMemo(()=>M.map(e=>({value:e,label:jr(s,e)||e})),[M,s]),U=e=>{C(e),e?w?.():(S(""),N?.())},q=t.useCallback(e=>{if(n)if(a){const t=M.includes(e)?M.filter(t=>t!==e):[...M,e];n(t)}else n(e),C(!1)},[n,a,M]),O=(e,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(a?M.filter(t=>t!==e):"")},B=g?F.slice(0,g):F,$=g&&F.length>g?F.length-g:0;if(h)return e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(fr,{className:"h-10 w-full"})]});const H="string"==typeof f?f:f instanceof Error?f.message:f?y("error_loading","Erro ao carregar"):void 0;return H?e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:H})]})]}):e.jsxs("div",{className:Aa("space-y-2",x),children:[i&&e.jsxs(Ra,{children:[i,p&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{open:j,onOpenChange:U,modal:!1,children:[e.jsx(nr,{asChild:!0,children:a?e.jsxs("div",{role:"combobox","aria-expanded":j,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),U(!j))},className:Aa("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","min-h-10 h-auto cursor-pointer",m&&"pointer-events-none opacity-50 cursor-not-allowed",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),T]}):e.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[B.map(t=>e.jsxs(Ds,{variant:"secondary",className:"gap-1 pr-1",children:[t.label,e.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:e=>{"Enter"===e.key&&O(t.value,e)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>O(t.value,e),children:e.jsx(l.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},t.value)),$>0&&e.jsxs(Ds,{variant:"outline",className:"gap-1",children:["+",$]})]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):e.jsxs(Pa,{variant:"outline",role:"combobox","aria-expanded":j,disabled:m,className:Aa("w-full justify-between min-h-10 h-auto",0===F.length&&"text-muted-foreground"),children:[0===F.length?e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),T]}):e.jsxs("span",{className:"flex items-center gap-2",children:[d&&e.jsx(d,{className:"h-4 w-4"}),F[0]?.label]}),e.jsx(l.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(or,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:I,collisionBoundary:I,children:[e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(l.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("input",{className:"flex h-10 w-full bg-transparent py-3 px-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",placeholder:P,value:k,onChange:e=>S(e.target.value)}),k&&e.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:e.jsx(l.X,{className:"h-3.5 w-3.5"})})]}),e.jsx(vr,{className:"max-h-[300px]",children:e.jsx("div",{role:"tree",className:"p-1",children:0===D.length?e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:y("no_search_results","Nenhum resultado encontrado")}):e.jsx(kr,{nodes:D,level:0,expandedIds:L,onToggleExpand:z,selectedValues:M,onSelect:q})})})]})]})]})},exports.Combobox=br,exports.Command=ir,exports.CommandDialog=({children:t,...a})=>e.jsx("div",{...a,children:e.jsx(ir,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})}),exports.CommandEmpty=cr,exports.CommandGroup=ur,exports.CommandInput=lr,exports.CommandItem=pr,exports.CommandList=dr,exports.CommandSeparator=mr,exports.CommandShortcut=hr,exports.ContentContainer=function({title:t,subtitle:a,children:s,className:r,hasHeader:n=!0}){const o=t||a;return e.jsxs("div",{className:Aa("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-hidden",r),children:[n&&o&&e.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[t&&e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:t}),a&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:a})]}),s&&e.jsx("div",{className:Aa("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Un,exports.ContextMenuCheckboxItem=Qn,exports.ContextMenuContent=Gn,exports.ContextMenuGroup=On,exports.ContextMenuItem=Yn,exports.ContextMenuLabel=Xn,exports.ContextMenuPortal=Bn,exports.ContextMenuRadioGroup=Hn,exports.ContextMenuRadioItem=Kn,exports.ContextMenuSeparator=Zn,exports.ContextMenuShortcut=Jn,exports.ContextMenuSub=$n,exports.ContextMenuSubContent=Wn,exports.ContextMenuSubTrigger=Vn,exports.ContextMenuTrigger=qn,exports.CoreProviders=function({children:a,queryClient:s,moduleAlias:r,moduleAccessGuardProps:n}){const[o]=t.useState(()=>new y.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),i=s??o;return e.jsx(Zo,{children:e.jsx(v.I18nextProvider,{i18n:A,children:e.jsx(y.QueryClientProvider,{client:i,children:e.jsx(wn,{children:e.jsx(Ho,{children:e.jsx(Go,{moduleAlias:r,children:e.jsx(bi,{...n,children:a})})})})})})})},exports.CrudActionBar=co,exports.CrudGrid=({manager:a,columns:s,onEdit:r,onView:n,onToggleStatus:o,onDelete:i,renderActions:l,customRowActions:d,enableBulkActions:c=!1,onNew:u,newButtonLabel:m,showNewButton:p=!0,customActions:h=[],hideActionBar:f,showActionBar:x=!0,showSearch:g=!1,searchValue:b,onSearchChange:v,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:y,filters:j,gridColumns:C=3,renderCard:k,viewMode:S,onViewModeChange:_,listCardRenderer:A,gridCardRenderer:T,showViewToggle:E=!1})=>{const{setSearchVisible:P}=Nn(),M=void 0!==f?!f:x;t.useEffect(()=>{if(!g)return P(!0),()=>P(!1)},[P,g]);const I=u||h.length>0||g||c||j||E,D=y||(()=>{a.bulkDelete?.(a.selectedIds)}),R=S||"grid",L="list"===R,z={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"}[L?1:C],F=M&&I?e.jsx(co,{onNew:u,newButtonLabel:m,showNewButton:p,showSearch:g,searchValue:b,onSearchChange:v,searchPlaceholder:w,showBulkActions:c,selectedCount:a.selectedIds.length,bulkActions:N,onBulkDelete:D,onClearSelection:a.clearSelection,customActions:h,filters:j,viewMode:R,onViewModeChange:_,showViewToggle:E,availableViewModes:["list","grid"]}):null;return a.isLoading?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(Dn,{count:6})})]}):0===a.entities.length?e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Ln,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[F,e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:Aa("grid gap-4",z),children:a.entities.map(t=>{const u=(e=>L&&A?A(e):!L&&T?T(e):k?k(e):null)(t);return e.jsxs(Un,{children:[e.jsx(qn,{asChild:!0,children:u?e.jsx("div",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:u}):e.jsx(La,{className:Aa("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",c&&a.selectedIds.includes(t.id)&&"bg-muted ring-2 ring-primary",L&&"flex-row"),onClick:e=>{e.stopPropagation(),c?a.selectItem(t.id):r?.(t)},children:e.jsxs(qa,{className:Aa("p-4",L&&"flex items-center gap-4 w-full"),children:[c&&e.jsx("div",{className:Aa(L?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:s.map(a=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key)))}),(r||n||l)&&e.jsx("div",{onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[c&&e.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:e.jsx(uo,{checked:a.selectedIds.includes(t.id),onCheckedChange:()=>a.selectItem(t.id)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.map((a,r)=>e.jsxs("div",{className:Aa("flex justify-between items-start gap-2",r!==s.length-1&&"mb-2"),children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[a.header,":"]}),e.jsx("div",{className:"text-sm text-foreground text-right truncate",children:a.render?a.render(t):String(t[a.key]??"")})]},String(a.key))),(r||n||l)&&e.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(t):e.jsx(to,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,customActions:d?d(t):[]})})]})]})]})})}),e.jsx(Gn,{className:"w-[160px]",children:e.jsx(eo,{onEdit:r?()=>r(t):void 0,onDelete:i?()=>i(t):void 0,onToggleStatus:o?()=>o(t):void 0,isActive:t.is_actived,canDelete:!!i,customActions:d?d(t):[],renderAs:"context"})})]},t.id)})})})]})},exports.CrudPageInternal=To,exports.CrudPagination=jo,exports.CrudPrimitiveFilterBar=function({searchValue:t="",onSearchChange:a,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=v.useTranslation(),d=t||s.length>0;return e.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[a&&e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ia,{type:"text",placeholder:i("search","Pesquisar"),value:t,onChange:e=>a(e.target.value),className:"pl-9 h-9"})]}),s.map((t,a)=>e.jsx("div",{className:"vertical"===o?"w-full":"",children:t},a)),n&&d&&r&&e.jsxs(Pa,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[e.jsx(l.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})},exports.CrudPrimitivePagination=yo,exports.CrudPrimitiveTable=function({data:a,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:d,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:f,onSelectAll:x,isAllSelected:g=!1,enableColumnResize:b=!0,onColumnResize:w,storageKey:N}){const{t:y}=v.useTranslation(),j=u||y("no_items_found","Nenhum item encontrado"),{columnWidths:C,isDragging:k,activeColumn:S,handleMouseDown:_}=so({columns:s.map(e=>({key:String(e.key),minWidth:e.minWidth??60,maxWidth:e.maxWidth??500,defaultWidth:e.width??e.minWidth??150})),storageKey:N?`${N}-columns`:void 0,onResize:w,enabled:b}),A=t.useMemo(()=>{if(b)return s.map(e=>`${C[String(e.key)]??e.width??e.minWidth??150}px`);const e=s.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return s.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const a=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${a}%)`:`${a}%`})},[s,b,C]);return c?e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((t,a)=>e.jsx(fr,{className:"h-12 w-full"},a))})}):0===a.length?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:j})})}):e.jsx("div",{className:"flex-1 overflow-auto "+(k?"select-none":""),children:e.jsxs(kn,{className:m,children:[e.jsx(Sn,{className:"sticky top-0 bg-background z-10",children:e.jsxs(Tn,{children:[p&&e.jsx(En,{className:"w-[40px]",children:e.jsx(Ps,{checked:g,onCheckedChange:x,"aria-label":y("select_all","Selecionar todos")})}),s.map((t,a)=>{const s=b&&!1!==t.resizable,i=S===String(t.key);return e.jsxs(En,{className:`${t.className||""} relative`,style:{width:A[a]},children:[t.sortable&&o?e.jsxs("button",{onClick:()=>o(String(t.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[t.header,(d=String(t.key),r!==d?e.jsx(l.ArrowUpDown,{size:14,className:"ml-1 opacity-50"}):"asc"===n?e.jsx(l.ArrowUp,{size:14,className:"ml-1"}):e.jsx(l.ArrowDown,{size:14,className:"ml-1"}))]}):e.jsx("span",{className:"font-medium",children:t.header}),s&&e.jsx(Fn,{direction:"horizontal",onMouseDown:e=>_(String(t.key),e),isDragging:i})]},String(t.key));var d}),d&&e.jsx(En,{className:"w-[80px] text-right",children:y("actions","Ações")})]})}),e.jsx(_n,{children:a.map(t=>e.jsxs(Tn,{onClick:()=>i?.(t),className:(i?"cursor-pointer":"")+" relative",children:[p&&e.jsx(Pn,{children:e.jsx(Ps,{checked:h.includes(t.id),onCheckedChange:()=>f?.(t.id),onClick:e=>e.stopPropagation(),"aria-label":`${y("select_all","Selecionar todos")} ${t.id}`})}),s.map(a=>e.jsx(Pn,{className:a.className,children:e.jsx(zn,{children:a.render?a.render(t):String(t[a.key]??"-")})},String(a.key))),d&&e.jsx(Pn,{className:"text-right",onClick:e=>e.stopPropagation(),children:d(t)})]},t.id))})]})})},exports.CrudTable=mo,exports.D4SignWidget=iu,exports.DATETIME_FORMATS=ha,exports.DEFAULT_DATETIME_FORMAT=ga,exports.DEFAULT_LOCALE=xa,exports.DEFAULT_TIMEZONE=ba,exports.DataList=Li,exports.DatePicker=function({date:t,onDateChange:a,placeholder:s="Selecione uma data",disabled:r=!1,className:n,disabledDates:i}){return e.jsxs(rr,{children:[e.jsx(nr,{asChild:!0,children:e.jsxs(Pa,{variant:"outline",disabled:r,className:Aa("w-full justify-start text-left font-normal",!t&&"text-muted-foreground",n),children:[e.jsx(l.Calendar,{className:"mr-2 h-4 w-4"}),t?o.format(t,"d 'de' MMMM 'de' yyyy",{locale:ma}):e.jsx("span",{children:s})]})}),e.jsx(or,{className:"w-auto p-0",align:"start",children:e.jsx(Ri,{mode:"single",selected:t,onSelect:a,disabled:i,initialFocus:!0,className:"pointer-events-auto"})})]})},exports.Dialog=es,exports.DialogBody=ls,exports.DialogClose=ss,exports.DialogContent=os,exports.DialogDescription=us,exports.DialogFooter=ds,exports.DialogHeader=is,exports.DialogOverlay=rs,exports.DialogPortal=as,exports.DialogTitle=cs,exports.DialogTrigger=ts,exports.DisabledMenuItem=sr,exports.DocumentSigner=function({file:a,onDocumentSigned:s,onError:r,showEventLog:n=!1}){const{user:o,alias:d}=Nn(),{config:c,isLoading:u}=Zc(),{t:m}=v.useTranslation(),[p,h]=t.useState(null),[f,x]=t.useState(!1),[g,b]=t.useState(null),[w,N]=t.useState("sandbox"),[y,j]=t.useState("clicksign"),[C,k]=t.useState(null),[S,_]=t.useState(null),[A,T]=t.useState(!1),[E,P]=t.useState(0),[M,I]=t.useState(!1),[D,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),F=t.useCallback(e=>{n&&R(t=>[...t,`[${(new Date).toLocaleTimeString()}] ${e}`])},[n]),U=t.useCallback(async e=>{if(h(e),b(null),k(null),_(null),F(`Arquivo selecionado: ${e.name}`),d&&o){x(!0);try{const t=c?.provider??"clicksign";j(t),F(`Provedor resolvido: ${t}`);const a=new FileReader,s=await new Promise((t,s)=>{a.onload=()=>{const e=a.result;t(e)},a.onerror=s,a.readAsDataURL(e)});F(`Criando envelope para assinatura via ${t}...`);const n=await au.createEnvelopeWithSigner({alias:d,contentBase64:s,filename:e.name,signerEmail:o.email||"",signerName:o.name||"",provider:t});F(`Envelope criado: ${n.envelope_id}`),k({envelope_id:n.envelope_id,document_id:n.document_id,signer_email:n.signer_email,key_signer:n.signer_id}),N(n.environment),j(n.provider||t),"d4sign"===t?(F("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(n.document_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):n.signer_id?(F(`Signer ID obtido: ${n.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(n.signer_id),i.toast.success(m("sign_doc_sent","Documento enviado! Assine abaixo."))):(F("AVISO: Nenhum signer ID disponível."),i.toast.error(m("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),r?.(new Error("Signer ID não disponível")))}catch(t){const e=t instanceof Error?t:new Error(m("sign_process_error","Erro ao processar documento")),a=e.message||"";a.includes("MONTHLY_LIMIT_REACHED")?(F("Limite mensal de assinaturas atingido"),i.toast.error(m("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(F(`Erro: ${a}`),i.toast.error(a)),r?.(e)}finally{x(!1)}}},[d,o,F,r,c]);t.useEffect(()=>{a&&d&&o&&!u&&a!==z.current&&(z.current=a,U(a))},[a,d,o,u,U]);const q=t.useCallback(async()=>{if(!C||!d)return;T(!0),P(0),I(!1),F("Buscando documento assinado...");for(let t=1;t<=6;t++){P(t),F(`Tentativa ${t}/6...`);try{const e=await au.getSignedDocument({alias:d,envelopeId:C.envelope_id,documentId:C.document_id,provider:y});if(e.download_url)return F("Documento assinado disponível para download"),_(e.download_url),void T(!1)}catch(e){F(`Erro na tentativa ${t}: ${e instanceof Error?e.message:"Erro desconhecido"}`)}t<6&&(F("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}F("Não foi possível obter o documento assinado após 6 tentativas."),T(!1),I(!0)},[C,d,F,y]),O=t.useCallback(async()=>{F("Documento assinado com sucesso!"),i.toast.success(m("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&d&&(s?.({success:!0,provider:y,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:g||"",environment:w}),await q())},[F,s,C,g,d,w,y,q]);if(!d)return e.jsx(La,{className:"border-amber-200 bg-amber-50",children:e.jsx(qa,{className:"flex items-start gap-3 py-6",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-amber-800",children:m("sign_auth_required","Autenticação necessária")}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:m("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const B="d4sign"===y?"D4Sign":"Clicksign",$=()=>n&&D.length>0?e.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:D.map((t,a)=>e.jsx("div",{children:t},a))}):null;return C&&!g&&(S||A||M)?e.jsxs("div",{className:"space-y-4",children:[e.jsx(La,{className:"border-green-200 bg-green-50",children:e.jsxs(qa,{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(l.CheckCircle2,{className:"h-12 w-12 text-green-600"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-green-800",children:m("sign_signed_success","Documento assinado com sucesso!")}),e.jsx("p",{className:"text-sm text-green-700 mt-1",children:p?.name})]}),A?e.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Loader2,{className:"h-4 w-4 animate-spin"}),m("sign_preparing_doc","Preparando documento assinado...")," (",m("sign_attempt","tentativa")," ",E,"/6)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_waiting_provider",`Aguardando processamento pelo ${B}...`)})]}):S?e.jsx(Pa,{asChild:!0,variant:"default",className:"gap-2",children:e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.Download,{className:"h-4 w-4"}),m("sign_download_signed","Baixar documento assinado")]})}):M?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),e.jsxs(Pa,{variant:"secondary",className:"gap-2",onClick:q,children:[e.jsx(l.RefreshCw,{className:"h-4 w-4"}),m("sign_try_again","Tentar novamente")]})]}):null]})}),e.jsx($,{})]}):g?e.jsxs("div",{className:"space-y-4",children:["d4sign"===y?e.jsx(iu,{documentKey:g,signerEmail:C?.signer_email||o?.email||"",signerName:o?.name,keySigner:C?.key_signer,environment:w,onSign:O,onError:r}):e.jsx(ou,{signerId:g,environment:w,onSign:O,onError:r}),e.jsx($,{})]}):a&&(f||u)?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&"application/pdf"===t.type?U(t):i.toast.error(m("sign_select_pdf","Selecione um arquivo PDF"))}}),f?e.jsx(La,{children:e.jsxs(qa,{className:"flex items-center justify-center gap-3 py-10",children:[e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"font-medium",children:m("sign_sending_doc","Enviando documento para assinatura...")})]})}):e.jsx(La,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:e.jsxs(qa,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[e.jsx(l.Upload,{className:"h-8 w-8 text-muted-foreground"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:m("sign_select_pdf","Selecione um arquivo PDF")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),e.jsx($,{})]})},exports.Drawer=zi,exports.DrawerClose=qi,exports.DrawerContent=Bi,exports.DrawerDescription=Wi,exports.DrawerFooter=Hi,exports.DrawerHeader=$i,exports.DrawerOverlay=Oi,exports.DrawerPortal=Ui,exports.DrawerTitle=Vi,exports.DrawerTrigger=Fi,exports.DropdownMenu=Fs,exports.DropdownMenuCheckboxItem=Ys,exports.DropdownMenuContent=Ws,exports.DropdownMenuGroup=qs,exports.DropdownMenuItem=Gs,exports.DropdownMenuLabel=Ks,exports.DropdownMenuPortal=Os,exports.DropdownMenuRadioGroup=$s,exports.DropdownMenuRadioItem=Qs,exports.DropdownMenuSeparator=Xs,exports.DropdownMenuShortcut=Zs,exports.DropdownMenuSub=Bs,exports.DropdownMenuSubContent=Vs,exports.DropdownMenuSubTrigger=Hs,exports.DropdownMenuTrigger=Us,exports.EmailService=vc,exports.EmptyState=Ln,exports.EntitySelect=br,exports.ErrorBoundary=Zo,exports.FilterBar=Ao,exports.Form=ms,exports.FormControl=bs,exports.FormDescription=vs,exports.FormField=({...t})=>e.jsx(ps.Provider,{value:{name:t.name},children:e.jsx(p.Controller,{...t})}),exports.FormItem=xs,exports.FormLabel=gs,exports.FormMessage=ws,exports.FormSkeleton=function({fields:t=4}){return e.jsxs("div",{className:"space-y-4",children:[Array.from({length:t}).map((t,a)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(fr,{className:"h-4 w-24"}),e.jsx(fr,{className:"h-10 w-full"})]},a)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(fr,{className:"h-10 w-20"}),e.jsx(fr,{className:"h-10 w-20"})]})]})},exports.Grid=function({children:t,cols:a="auto-fit",gap:s="md",className:r}){return e.jsx("div",{className:Aa("grid",Gi[a],Yi[s],r),children:t})},exports.H1=nl,exports.H2=ol,exports.H3=il,exports.H4=ll,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(fr,{className:"h-8 w-8 rounded-full"}),e.jsx(fr,{className:"h-6 w-32"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fr,{className:"h-8 w-8"}),e.jsx(fr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Qi,exports.HoverCardContent=Xi,exports.HoverCardTrigger=Ki,exports.IconPicker=go,exports.ImageEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{alignment:"center",allowDownload:!1}),p=t.useRef(null),{upload:h,uploading:f}=Hc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),x=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:u.imageUrl||"",onChange:e=>x("imageUrl",e.target.value),className:"flex-1"}),o&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await h(t),a={...u,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),u.imageFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",u.imageFile," (",Math.round((u.imageSize||0)/1024)," KB)"]})]}),u.imageUrl&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:e.jsx("div",{className:"flex "+("left"===u.alignment?"justify-start":"right"===u.alignment?"justify-end":"justify-center"),children:e.jsx("img",{src:u.imageUrl,alt:u.alt||"Preview",style:{width:u.width?`${u.width}px`:"auto",height:u.height?`${u.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"caption",children:"Legenda"}),e.jsx(Ms,{id:"caption",placeholder:"Legenda",value:u.caption||"",onChange:e=>x("caption",e.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"alt",children:"Texto Alternativo"}),e.jsx(Ia,{id:"alt",placeholder:"Texto Alternativo",value:u.alt||"",onChange:e=>x("alt",e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Alinhamento"}),e.jsxs(Ns,{value:u.alignment||"center",onValueChange:e=>x("alignment",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"left",children:"Esquerda"}),e.jsx(Ts,{value:"center",children:"Centro"}),e.jsx(Ts,{value:"right",children:"Direita"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"width",children:"Largura"}),e.jsx(Ia,{id:"width",type:"number",placeholder:"px",value:u.width||"",onChange:e=>x("width",e.target.value?Number(e.target.value):void 0)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"height",children:"Altura"}),e.jsx(Ia,{id:"height",type:"number",placeholder:"px",value:u.height||"",onChange:e=>x("height",e.target.value?Number(e.target.value):void 0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"allowDownload",checked:u.allowDownload||!1,onCheckedChange:e=>x("allowDownload",!0===e)}),e.jsx(Ra,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.imageUrl?r(u):i.toast.error("Erro",{description:"Nenhuma imagem selecionada"})},disabled:!u.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:t,className:a="",style:s}){if(!t.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[t.alignment||"center"];return e.jsx("div",{className:`flex ${r} my-4 ${a}`,style:s,children:e.jsxs("div",{className:"space-y-2 max-w-full",children:[e.jsx("img",{src:t.imageUrl,alt:t.alt||"",style:{width:t.width?`${t.width}px`:"auto",height:t.height?`${t.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),t.caption&&e.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:t.caption}),t.allowDownload&&t.imageUrl&&e.jsxs("a",{href:t.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[e.jsx(l.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=hl,exports.Input=Ia,exports.InputGroup=Zi,exports.InputGroupAddon=el,exports.InputGroupButton=al,exports.InputGroupInput=sl,exports.InputGroupTextarea=rl,exports.LOGO_CONFIG=tn,exports.Label=Ra,exports.Large=ul,exports.Lead=cl,exports.LeaderRow=Dc,exports.LeadershipDialog=Oc,exports.LeadershipForm=qc,exports.LeadershipPage=function(){const{alias:a}=Nn(),{data:s,isLoading:r,error:n,refetch:o}=Sc(),[i,d]=t.useState(()=>a?(e=>{try{const t=localStorage.getItem(`${Bc}-${e}`);if(t)return new Set(JSON.parse(t))}catch(n){}return new Set})(a):new Set),[c,u]=t.useState(!1),[m,p]=t.useState(),[h,f]=t.useState(null),x=(s?kc(s):[]).filter(e=>"[Não encontrado]"!==e.name).length;t.useEffect(()=>{if(s&&s.length>0&&a){if(!localStorage.getItem(`${Bc}-${a}`)){const e=s.map(e=>e.id),t=new Set(e);d(t),$c(a,t)}}},[s,a]);const g=e=>{d(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),a&&$c(a,s),s})},b=e=>{p(e),f(null),u(!0)};return r?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(l.RefreshCw,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})}):n?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),e.jsx(Pa,{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(Pa,{size:"sm",onClick:()=>{p(void 0),f(null),u(!0)},children:[e.jsx(l.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{if(!s)return;const e=kc(s).filter(e=>e.children.length>0).map(e=>e.id),t=new Set(e);d(t),a&&$c(a,t)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronDown,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),e.jsxs(Pa,{variant:"outline",size:"sm",onClick:()=>{const e=new Set;d(e),a&&$c(a,e)},disabled:!s||0===s.length,children:[e.jsx(l.ChevronRight,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[e.jsx(l.Users,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium",children:[x," usuário",1!==x?"s":""," associado",1!==x?"s":""]})]})})]})}),s&&0!==s.length?e.jsx(vr,{className:"flex-1",children:e.jsx("div",{children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),e.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsx(Dc,{leader:t,expandedIds:i,onToggleExpand:g,onEdit:b},t.id))})]})})}):e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),e.jsx(Oc,{open:c,onOpenChange:()=>{u(!1),p(void 0),f(null)},leader:m,prefilledLeaderId:h,title:m?"Editar Nome":h?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${a}`)]})},exports.List=xl,exports.LoadingState=function({isLoading:t,children:a,className:s,type:r="spinner",size:n="md"}){return t?"overlay"===r?e.jsxs("div",{className:Aa("relative",s),children:[a,e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsx(Ls,{size:n})})]}):"skeleton"===r?e.jsx("div",{className:Aa("animate-pulse",s),children:e.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):e.jsx("div",{className:Aa("flex items-center justify-center py-8",s),children:e.jsx(Ls,{size:n})}):e.jsx(e.Fragment,{children:a})},exports.LocaleProvider=Ho,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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),e.jsxs(qa,{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),e.jsx(Pa,{onClick:async()=>{Zr()?await xn.loginDev():xn.loginProd()},className:"w-full",size:"lg",children:Zr()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),exports.MESSAGES=an,exports.MODULES_DATA=ci,exports.ManageAccessModal=Nc,exports.Menubar=_d,exports.MenubarCheckboxItem=Id,exports.MenubarContent=Pd,exports.MenubarGroup=jd,exports.MenubarItem=Md,exports.MenubarLabel=Rd,exports.MenubarMenu=yd,exports.MenubarPortal=Cd,exports.MenubarRadioGroup=Sd,exports.MenubarRadioItem=Dd,exports.MenubarSeparator=Ld,exports.MenubarShortcut=zd,exports.MenubarSub=kd,exports.MenubarSubContent=Ed,exports.MenubarSubTrigger=Td,exports.MenubarTrigger=Ad,exports.ModalStateProvider=function({children:a}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.add(e),a})},[]),l=t.useCallback(e=>{r(t=>{const a=new Set(t);return a.delete(e),a})},[]),d=t.useCallback(e=>{o(e)},[]),c=t.useMemo(()=>s.size>0||n,[s,n]),u=t.useMemo(()=>({openModals:s,hasOpenModal:c,registerModal:i,unregisterModal:l,setHasOpenModal:d}),[s,c,i,l,d]);return e.jsx(fc.Provider,{value:u,children:a})},exports.ModuleAccessGuard=bi,exports.ModuleGrid=pi,exports.ModuleProvider=Go,exports.ModulesDialog=hi,exports.MultiSelect=br,exports.Muted=pl,exports.NavigationMenu=gl,exports.NavigationMenuContent=yl,exports.NavigationMenuIndicator=kl,exports.NavigationMenuItem=vl,exports.NavigationMenuLink=jl,exports.NavigationMenuList=bl,exports.NavigationMenuTrigger=Nl,exports.NavigationMenuViewport=Cl,exports.NavigationProvider=ec,exports.OnboardingDialog=ii,exports.P=dl,exports.PROD_PROJECT_ID=Hr,exports.PageBreadcrumb=function({items:t,maxItems:a=3,className:s}){const r=t.length>a?[t[0],...t.slice(-(a-1))]:t,n=t.length>a;return e.jsx(Si,{className:s,children:e.jsx(_i,{children:r.map((t,a)=>{const s=0===a,r=n&&1===a;return e.jsxs(Ai,{children:[!s&&e.jsx(Pi,{}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Mi,{}),e.jsx(Pi,{})]}),t.isCurrentPage?e.jsx(Ei,{children:t.label}):e.jsx(Ti,{asChild:!0,children:e.jsx(j.Link,{to:t.href||"/",children:t.label})})]},t.label)})})})},exports.PageMetadataProvider=Fo,exports.Pagination=Sl,exports.PaginationContent=_l,exports.PaginationEllipsis=Ml,exports.PaginationItem=Al,exports.PaginationLink=Tl,exports.PaginationNext=Pl,exports.PaginationPrevious=El,exports.PlaceCard=yc,exports.PlacesList=function({places:t,isLoading:a,manageAccessConfig:s}){return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):t&&0!==t.length?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),t.map(t=>e.jsx(yc,{place:t,manageAccessConfig:s},t.id))]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[e.jsx(l.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=rr,exports.PopoverContent=or,exports.PopoverTrigger=nr,exports.Progress=si,exports.ProtectedRoute=({children:a})=>{const{isAuthenticated:s,isLoading:r}=Nn();if(t.useEffect(()=>{if(r)return;if(s)return;if(Dr.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const n=Zr(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{n?await xn.loginDev():xn.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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Carregando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Processando..."})}),e.jsxs(qa,{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(La,{className:"w-full max-w-md",children:[e.jsx(za,{className:"text-center",children:e.jsx(Fa,{className:"text-xl font-semibold",children:"Iniciando..."})}),e.jsxs(qa,{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:Zr()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return e.jsx(e.Fragment,{children:a})},exports.QUALIEX_CONFIG=en,exports.QUERY_KEYS={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]},exports.QualiexEnrichmentService=cn,exports.QualiexErrorInterceptor=$r,exports.QualiexUserField=wo,exports.RadioGroup=Il,exports.RadioGroupItem=Dl,exports.ResizableHandle=({withHandle:t,className:a,...s})=>e.jsx(ye.PanelResizeHandle,{className:Aa("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...s,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsx(l.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=Rl,exports.ResizablePanelGroup=({className:t,...a})=>e.jsx(ye.PanelGroup,{className:Aa("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...a}),exports.RichTextEditor=({value:a,onChange:s,disabled:r,placeholder:n="Escreva o conteúdo aqui...",minHeight:o="300px",showModeToggle:i=!0,showVariableHint:d=!0,className:c})=>{const[u,m]=t.useState("visual"),p=$.useEditor({extensions:[H.configure({heading:{levels:[1,2,3]}}),V,W.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,Q.configure({multicolor:!0})],content:a||"",editable:!r,onUpdate:({editor:e})=>{s(e.getHTML())}});J.useEffect(()=>{p&&a!==p.getHTML()&&p.commands.setContent(a||"")},[a,p]);const h=t.useCallback(()=>{if(!p)return;const e=p.getAttributes("link").href,t=window.prompt("URL",e);null!==t&&(""!==t?p.chain().focus().extendMarkRange("link").setLink({href:t}).run():p.chain().focus().extendMarkRange("link").unsetLink().run())},[p]);return p?e.jsxs("div",{className:Aa("space-y-2",c),children:[i&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Pa,{type:"button",size:"sm",variant:"visual"===u?"default":"outline",onClick:()=>m("visual"),disabled:r,children:[e.jsx(l.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"code"===u?"default":"outline",onClick:()=>m("code"),disabled:r,children:[e.jsx(l.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),e.jsxs(Pa,{type:"button",size:"sm",variant:"preview"===u?"default":"outline",onClick:()=>m("preview"),disabled:r,children:[e.jsx(l.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),d&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===u&&e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||p?.commands.focus()},children:[e.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(Yd,{onClick:()=>p.chain().focus().toggleHeading({level:1}).run(),isActive:p.isActive("heading",{level:1}),disabled:r,title:"Título 1",children:e.jsx(l.Heading1,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleHeading({level:2}).run(),isActive:p.isActive("heading",{level:2}),disabled:r,title:"Título 2",children:e.jsx(l.Heading2,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleHeading({level:3}).run(),isActive:p.isActive("heading",{level:3}),disabled:r,title:"Título 3",children:e.jsx(l.Heading3,{className:"h-4 w-4"})}),e.jsx(Qd,{}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleBold().run(),isActive:p.isActive("bold"),disabled:r,title:"Negrito",children:e.jsx(l.Bold,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleItalic().run(),isActive:p.isActive("italic"),disabled:r,title:"Itálico",children:e.jsx(l.Italic,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleUnderline().run(),isActive:p.isActive("underline"),disabled:r,title:"Sublinhado",children:e.jsx(l.Underline,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleStrike().run(),isActive:p.isActive("strike"),disabled:r,title:"Riscado",children:e.jsx(l.Strikethrough,{className:"h-4 w-4"})}),e.jsx(Qd,{}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleBulletList().run(),isActive:p.isActive("bulletList"),disabled:r,title:"Lista",children:e.jsx(l.List,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleOrderedList().run(),isActive:p.isActive("orderedList"),disabled:r,title:"Lista Ordenada",children:e.jsx(l.ListOrdered,{className:"h-4 w-4"})}),e.jsx(Qd,{}),e.jsx(Yd,{onClick:()=>p.chain().focus().toggleHighlight().run(),isActive:p.isActive("highlight"),disabled:r,title:"Destacar",children:e.jsx(l.Highlighter,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:h,isActive:p.isActive("link"),disabled:r,title:"Link",children:e.jsx(l.Link,{className:"h-4 w-4"})}),e.jsx(Qd,{}),e.jsx(Yd,{onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),disabled:r,title:"Limpar Formatação",children:e.jsx(l.RemoveFormatting,{className:"h-4 w-4"})}),e.jsx(Qd,{}),e.jsx(Yd,{onClick:()=>p.chain().focus().undo().run(),disabled:r||!p.can().undo(),title:"Desfazer",children:e.jsx(l.Undo,{className:"h-4 w-4"})}),e.jsx(Yd,{onClick:()=>p.chain().focus().redo().run(),disabled:r||!p.can().redo(),title:"Refazer",children:e.jsx(l.Redo,{className:"h-4 w-4"})})]}),e.jsx($.EditorContent,{editor:p,className:Aa("prose prose-sm max-w-none focus:outline-none","[&_.ProseMirror]:p-4","[&_.ProseMirror]:min-h-full","[&_.ProseMirror]:cursor-text","[&_.ProseMirror]:outline-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"),style:{minHeight:o}})]}),"code"===u&&e.jsx("textarea",{value:a||"",onChange:e=>s(e.target.value),disabled:r,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:o},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===u&&e.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:o},children:e.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:a||`<p class="text-muted-foreground">${n}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Xr,exports.SUPPORTED_LOCALES=pa,exports.ScrollArea=vr,exports.ScrollBar=wr,exports.Select=Ns,exports.SelectContent=_s,exports.SelectGroup=ys,exports.SelectItem=Ts,exports.SelectLabel=As,exports.SelectScrollDownButton=Ss,exports.SelectScrollUpButton=ks,exports.SelectSearch=br,exports.SelectSeparator=Es,exports.SelectTrigger=Cs,exports.SelectValue=js,exports.Separator=Ba,exports.Sheet=Ll,exports.SheetBody=Hl,exports.SheetClose=Fl,exports.SheetContent=Bl,exports.SheetDescription=Gl,exports.SheetFooter=Vl,exports.SheetHeader=$l,exports.SheetOverlay=ql,exports.SheetPortal=Ul,exports.SheetTitle=Wl,exports.SheetTrigger=zl,exports.Sidebar=Zl,exports.SidebarActionTrigger=uc,exports.SidebarContent=od,exports.SidebarFooter=rd,exports.SidebarGroup=id,exports.SidebarGroupAction=dd,exports.SidebarGroupContent=cd,exports.SidebarGroupLabel=ld,exports.SidebarHeader=cc,exports.SidebarInput=ad,exports.SidebarInset=td,exports.SidebarMenu=ud,exports.SidebarMenuAction=fd,exports.SidebarMenuBadge=xd,exports.SidebarMenuButton=hd,exports.SidebarMenuItem=md,exports.SidebarMenuSkeleton=gd,exports.SidebarMenuSub=bd,exports.SidebarMenuSubButton=wd,exports.SidebarMenuSubItem=vd,exports.SidebarProvider=Xl,exports.SidebarRail=ed,exports.SidebarSeparator=nd,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(fr,{className:"h-8 w-32 mb-6"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(fr,{className:"h-4 w-4"}),e.jsx(fr,{className:"h-4 w-20"})]},a))})]})})},exports.SidebarTrigger=Jl,exports.SignConfigForm=function({onSaved:a}){const{config:s,isLoading:r,saveConfig:n}=Zc(),{t:o}=v.useTranslation(),[d,c]=t.useState(""),[u,m]=t.useState("sandbox"),[p,h]=t.useState(!1);return t.useEffect(()=>{!r&&s&&(c(s.api_key),m(s.environment))},[s,r]),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-4",children:[s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[e.jsx(l.CheckCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_configured","Assinatura digital configurada para esta unidade")})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[e.jsx(l.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{children:o("sign_not_configured","Assinatura digital ainda não configurada para esta unidade")})]}),e.jsxs(La,{children:[e.jsx(za,{children:e.jsx(Fa,{className:"text-base",children:o("sign_config_title","Configuração de Assinatura Digital")})}),e.jsx(qa,{children:e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),d.trim()){h(!0);try{await n(d.trim(),u),i.toast.success(o("sign_config_saved","Configuração de assinatura salva com sucesso")),a?.()}catch(t){i.toast.error(o("sign_config_save_error","Erro ao salvar configuração de assinatura"))}finally{h(!1)}}else i.toast.error(o("sign_api_key_required","Informe a API Key do provedor de assinatura"))},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"sign-api-key",children:"API Key"}),e.jsx(Ia,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder","Insira a API Key do provedor de assinatura"),value:d,onChange:e=>c(e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:o("sign_environment","Ambiente")}),e.jsxs(Ns,{value:u,onValueChange:e=>m(e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"sandbox",children:"Sandbox (Testes)"}),e.jsx(Ts,{value:"production",children:"Produção"})]})]})]}),e.jsxs(Pa,{type:"submit",disabled:p,children:[p&&e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config","Atualizar Configuração"):o("sign_save_config","Salvar Configuração")]})]})})]})]})},exports.SignWidget=ou,exports.Skeleton=fr,exports.Slider=Nd,exports.Small=ml,exports.SonnerToaster=zs,exports.Spinner=Ls,exports.SplitButton=function({label:t,onClick:a,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:d=!1,menuAlign:c="end",className:u}){const m=i||d;return r.length>0?e.jsxs("div",{className:Aa("inline-flex rounded-md shadow-sm",u),children:[e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:"rounded-r-none border-r-0 focus:z-10",children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]}),e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(Pa,{variant:n,size:o,disabled:m,className:Aa("rounded-l-none focus:z-10",{sm:"w-7 min-w-7 px-0",default:"w-8 min-w-8 px-0",lg:"w-9 min-w-9 px-0"}[o]),"aria-label":"Mais opções",children:e.jsx(l.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),e.jsx(Ws,{align:c,className:"min-w-[160px]",children:r.map(t=>{const a=t.icon;return e.jsxs(Gs,{onClick:t.onClick,disabled:t.disabled,className:Aa("destructive"===t.variant&&"text-destructive focus:text-destructive"),children:[a&&e.jsx(a,{className:"mr-2 h-4 w-4"}),t.label]},t.id)})})]})]}):e.jsxs(Pa,{variant:n,size:o,disabled:m,onClick:a,className:u,children:[d?e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?e.jsx(s,{className:"mr-2 h-4 w-4"}):null,t]})},exports.Stack=_o,exports.StepSelector=function({currentStep:t,totalSteps:a,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){const d=Array.from({length:a},(e,t)=>t+1),c=e=>!(e<=t)&&(!!n&&!n(e));return e.jsxs("div",{className:Aa("flex items-center gap-3",o),children:[e.jsxs(Fs,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(Pa,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",t,"/",a,e.jsx(l.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Ws,{align:"start",children:d.map(a=>e.jsxs(Gs,{onClick:()=>{var e;(e=a)<t?s(e):n&&!n(e)||s(e)},disabled:c(a),className:Aa("cursor-pointer",a===t&&"bg-muted font-medium",c(a)&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[a,"."]}),r?.[a-1]||`Etapa ${a}`,a===t&&e.jsx(l.Check,{className:"h-4 w-4 ml-auto"})]},a))})]}),e.jsx(si,{value:t/a*100,className:Aa("h-2",i)})]})},exports.Switch=bo,exports.TIMEZONES=fa,exports.TabPageContent=function({children:t,className:a}){return e.jsx("div",{className:Aa("space-y-6",a),children:t})},exports.TabPageHeader=function({title:t,description:a,actions:s,className:r}){return e.jsxs("div",{className:Aa("space-y-4",r),children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t}),a&&e.jsx("p",{className:"text-muted-foreground text-sm",children:a})]}),s&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),e.jsx(Ba,{})]})},exports.TabPageLayout=function({children:t,className:a}){return e.jsx("div",{className:Aa("flex flex-col h-full",a),children:e.jsx(vr,{className:"flex-1",children:e.jsx("div",{className:"space-y-6 p-6",children:t})})})},exports.Table=kn,exports.TableBody=_n,exports.TableCaption=Mn,exports.TableCell=Pn,exports.TableFooter=An,exports.TableHead=En,exports.TableHeader=Sn,exports.TableResizeHandle=Fn,exports.TableRow=Tn,exports.TableRowActions=to,exports.TableSkeleton=In,exports.Tabs=Jo,exports.TabsContent=ai,exports.TabsList=ei,exports.TabsTrigger=ti,exports.Textarea=Ms,exports.Toaster=zs,exports.Toggle=no,exports.ToggleGroup=io,exports.ToggleGroupItem=lo,exports.TokenManager=Dr,exports.TokenService=Sr,exports.Tooltip=er,exports.TooltipContent=ar,exports.TooltipProvider=Js,exports.TooltipTrigger=tr,exports.TruncatedCell=zn,exports.VideoEditor=function({value:a,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:d,uploadOptions:c}){const[u,m]=t.useState(a||{inputType:"url",controls:!0}),p=t.useRef(null),h=t.useRef(null),{upload:f,uploading:x}=Hc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:b}=Hc({uploadFunction:o,deleteFunction:d,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),v=t.useMemo(()=>Kc(u.videoUrl||Qc(u.embedCode)||""),[u.videoUrl,u.embedCode]),w=(e,t)=>{const a={...u,[e]:t};m(a),s(a)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Tipo de entrada"}),e.jsxs(Ns,{value:u.inputType||"url",onValueChange:e=>w("inputType",e),children:[e.jsx(Cs,{children:e.jsx(js,{})}),e.jsxs(_s,{children:[e.jsx(Ts,{value:"url",children:"URL"}),e.jsx(Ts,{value:"upload",children:"Upload de arquivo"}),e.jsx(Ts,{value:"embed",children:"Código embed"})]})]})]}),"upload"===u.inputType&&o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Arquivo"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:p,type:"file",accept:"video/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await f(t),a={...u,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:u.title||t.name.replace(/\.[^/.]+$/,"")};m(a),s(a)}catch(a){}finally{p.current&&(p.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>p.current?.click(),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),u.videoFile&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",u.videoFile," (",Math.round((u.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===u.inputType&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Código embed"}),e.jsx(Ms,{placeholder:"Cole o código embed aqui",value:u.embedCode||"",onChange:e=>w("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Thumbnail"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ia,{type:"url",placeholder:"URL da thumbnail",value:u.thumbnail||"",onChange:e=>w("thumbnail",e.target.value),className:"flex-1"}),e.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];if(t)try{const e=await g(t),a={...u,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};m(a),s(a)}catch(a){}finally{h.current&&(h.current.value="")}},className:"hidden"}),e.jsx(Pa,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),u.thumbnailFile&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",u.thumbnailFile]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{htmlFor:"title",children:"Título"}),e.jsx(Ia,{id:"title",placeholder:"Título do vídeo",value:u.title||"",onChange:e=>w("title",e.target.value)})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"autoplay",checked:u.autoplay||!1,onCheckedChange:e=>w("autoplay",!0===e)}),e.jsx(Ra,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{id:"controls",checked:!1!==u.controls,onCheckedChange:e=>w("controls",!0===e)}),e.jsx(Ra,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ra,{children:"Preview"}),e.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=u.videoUrl||Qc(u.embedCode)||"";if(!t)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===v)return e.jsxs("video",{controls:!1!==u.controls,autoPlay:u.autoplay,poster:u.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[e.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const a="youtube"===v?Wc(t,u.autoplay):Yc(t,u.autoplay);return e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:u.title||"Vídeo",src:a,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Pa,{variant:"outline",onClick:n,children:"Cancelar"}),e.jsx(Pa,{onClick:()=>{u.videoUrl||u.embedCode?r(u):i.toast.error("Erro",{description:"Nenhum vídeo selecionado"})},disabled:!(u.videoUrl||u.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:a="",style:s}){const r=t.videoUrl||Qc(t.embedCode)||"";if(!r)return null;const n=Kc(r);return e.jsx(La,{className:`overflow-hidden my-4 ${a}`,style:s,children:e.jsxs(qa,{className:"p-0",children:["file"===n?e.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[e.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{title:t.title||"Vídeo",src:"youtube"===n?Wc(r,t.autoplay):Yc(r,t.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.title&&e.jsx("div",{className:"p-4",children:e.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.assets=ic,exports.badgeVariants=Is,exports.buildHierarchy=Cc,exports.buttonGroupVariants=Ii,exports.buttonVariants=Ea,exports.calculateAspectRatio=Xc,exports.cn=Aa,exports.createCrudPage=function(t){return({manager:a})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=t,l=a??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:o||r.onEdit,onNew:r.onNew,useCustomRouting:r.useCustomRouting,hideNewButton:r.hideNewButton,showNewButton:r.showNewButton,newButtonLabel:r.newButtonLabel,showSearch:r.showSearch,searchPlaceholder:r.searchPlaceholder,showActionBar:r.showActionBar};return e.jsx(To,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,t){const a=Xd({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:a.onNew,onEdit:a.onEdit}},exports.createRoutingHandlers=Xd,exports.createService=pn,exports.createSimpleSaveHandler=function(e,t,a){return s=>{if(s.id){const t=a(s);e.updateEntity(s.id,t)}else{const a=t(s);e.createEntity(a)}}},exports.createSimpleService=function(e){const t=pn({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:t,useCrudHook:(a,s)=>yn({queryKey:e.tableName,service:t,entityName:e.entityName,additionalFilters:a,onSuccess:s})}},exports.createTranslatedMessages=e=>({success:{created:t=>e("msg_created_success",`${t} criado com sucesso`).replace("{{entity}}",t),updated:t=>e("msg_updated_success",`${t} atualizado com sucesso`).replace("{{entity}}",t),deleted:t=>e("msg_deleted_success",`${t} removido com sucesso`).replace("{{entity}}",t)},error:{create:t=>e("msg_create_error",`Erro ao criar ${t}`).replace("{{entity}}",t),update:t=>e("msg_update_error",`Erro ao atualizar ${t}`).replace("{{entity}}",t),delete:t=>e("msg_delete_error",`Erro ao remover ${t}`).replace("{{entity}}",t),load:t=>e("msg_load_error",`Erro ao carregar ${t}`).replace("{{entity}}",t)}}),exports.debounce=(e,t)=>{let a;return(...s)=>{clearTimeout(a),a=setTimeout(()=>e(...s),t)}},exports.deriveEmailField=nn,exports.deriveNameField=rn,exports.deriveUsernameField=on,exports.detectBrowserLocale=Na,exports.detectBrowserPreferences=()=>{const e=Na();return{locale:e,timezone:ya(),datetimeFormat:ja(e)}},exports.detectBrowserTimezone=ya,exports.detectVideoProvider=Kc,exports.emailService=wc,exports.errorService=Rr,exports.extractImageFileName=function(e){try{const t=new URL(e),a=t.pathname.split("/");return a[a.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}},exports.extractVimeoId=Gc,exports.extractYouTubeId=Vc,exports.filterAndPromoteOrphans=function(e,t){const a=e.map(e=>({...e})),s=new Set(a.filter(e=>!t.has(e.id_user)).map(e=>e.id_user));return a.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let t=e.id_leader;for(;t&&s.has(t);){const e=a.find(e=>e.id_user===t);t=e?.id_leader||null}e.id_leader=t}}),a.filter(e=>t.has(e.id_user))},exports.findDatetimeFormat=e=>ha.find(t=>t.value===e),exports.findLocale=e=>pa.find(t=>t.value===e),exports.findTimezone=e=>fa.find(t=>t.value===e),exports.flattenTree=kc,exports.formatCurrency=(e,t="BRL",a="pt-BR")=>null==e?"":new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Sa,exports.formatDatetime=ka,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.generateCrudConfig=function(e,t,a={}){const s=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const a=t[e],r={key:e,header:Po(e),label:Po(e),...Eo(e,a),sortable:!0,searchable:"string"==typeof a};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...a}},exports.getEnvironmentConfig=Gr,exports.getQualiexApiUrl=Jr,exports.getSupabaseClient=Ur,exports.handleExternalLink=_a,exports.inferDatetimeFormat=ja,exports.inputGroupAddonVariants=Ji,exports.inputGroupButtonVariants=tl,exports.isDevEnvironment=Zr,exports.isDevSupabaseProject=Yr,exports.isImageUrl=function(e){const t=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const a=new URL(e);return t.some(e=>a.pathname.toLowerCase().endsWith(e))}catch{const a=e.toLowerCase();return t.some(e=>a.endsWith(e))}},exports.isValidDatetimeFormat=e=>ha.some(t=>t.value===e),exports.isValidLocale=va,exports.isValidTimezone=wa,exports.loadClicksignScript=ru,exports.logoSrc=lc,exports.navigationMenuTriggerStyle=wl,exports.normalizeVideoUrl=function(e,t,a){switch(t||Kc(e)){case"youtube":return Wc(e,a);case"vimeo":return Yc(e,a);default:return e}},exports.normalizeVimeoUrl=Yc,exports.normalizeYouTubeUrl=Wc,exports.parseIframeSrc=Qc,exports.placeService=jc,exports.qualiexApi=sn,exports.resizeKeepingAspect=function(e,t,a,s){const r=Xc(e,t);return a&&!s?{width:a,height:Math.round(a/r)}:s&&!a?{width:Math.round(s*r),height:s}:{width:e,height:t}},exports.resolveFieldMappings=ln,exports.resolvePageTitle=ac,exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new y.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.signService=au,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=dc,exports.toggleVariants=ro,exports.trimTextFields=Ta,exports.useActiveModules=(e={})=>{const{enabled:t=!0}=e,{alias:a}=Nn();return y.useQuery({queryKey:["active-modules",a],queryFn:async()=>{if(!a)return[];const e=Ur(),{data:t,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",a).eq("status","active").order("name");if(s){if(!Br.handleError(s))throw s;return[]}return t||[]},enabled:t&&!!a})},exports.useAuth=Nn,exports.useBaseForm=po,exports.useColumnResize=so,exports.useCreateMultipleLeadersMutation=Tc,exports.useCreateSingleLeaderMutation=Ac,exports.useCrud=yn,exports.useDebounce=sc,exports.useFormField=hs,exports.useHasOpenModal=function(){const{hasOpenModal:e}=xc();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:t}=Vo(),a=ga;return{formatDatetime:s=>ka(s,a,t,e),formatDate:a=>Sa(a,e,t),locale:e,timezone:t,datetimeFormat:a}},exports.useIsMobile=Cn,exports.useLeadershipApi=Sc,exports.useLocale=Vo,exports.useMediaQuery=jn,exports.useMediaUpload=Hc,exports.useModalState=xc,exports.useModuleAccess=gi,exports.useModuleConfig=Yo,exports.useNavigation=tc,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=Uo(),r=t.useRef({});t.useEffect(()=>(r.current.title===e.title&&r.current.subtitle===e.subtitle||(r.current={title:e.title,subtitle:e.subtitle},a(e)),()=>s()),[e.title,e.subtitle,a,s])},exports.usePageMetadataContext=Uo,exports.usePageTitle=function(){const e=j.useLocation(),{navigation:t}=tc();return ac(t,e.pathname)},exports.usePermissionQuery=nc,exports.useQualiexUsers=vo,exports.useRemoveLeaderMutation=Pc,exports.useRouteBreadcrumbs=function(){const e=j.useLocation();return(()=>{const t=e.pathname.split("/").filter(Boolean),a=[{label:"Exemplos",href:"/"}];let s="";return t.forEach((e,r)=>{s+=`/${e}`;const n=r===t.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");a.push({label:o,href:n?void 0:s,isCurrentPage:n})}),a})()},exports.useRowResize=function({rowIds:e,defaultHeight:a=48,minHeight:s=32,maxHeight:r=120,storageKey:n,onResize:o,enabled:i=!0}){const[l,d]=t.useState(()=>{if(!i||"undefined"==typeof window)return{};if(n){const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{}}return{}}),[c,u]=t.useState(!1),[m,p]=t.useState(null),h=t.useRef(0),f=t.useRef(0),x=t.useCallback(e=>l[e]??a,[l,a]),g=t.useCallback((e,t)=>{i&&(t.preventDefault(),t.stopPropagation(),u(!0),p(e),h.current=t.clientY,f.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const t=e.clientY-h.current,a=Math.max(s,Math.min(r,f.current+t));d(e=>{const t={...e,[m]:a};return o?.(t),t})},t=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[c,m,s,r,n,o]),t.useEffect(()=>(c?(document.body.style.cursor="row-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect=""),()=>{document.body.style.cursor="",document.body.style.userSelect=""}),[c]);const b=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:b,getRowHeight:x}},exports.useSidebar=Kl,exports.useSidebarResize=hc,exports.useSignConfig=Zc,exports.useSyncSubordinatesMutation=Mc,exports.useUpdateLeaderMutation=Ec,exports.useWizard=function(e){const{steps:a,initialStep:s=0,initialData:r={},onComplete:n,onCancel:o}=e,[i,l]=t.useState(s),[d,c]=t.useState(r),[u,m]=t.useState(!1),[p,h]=t.useState(!1),f=a.length,x=0===i,g=i===f-1,b=a[i],v=f>1?(i+1)/f*100:100,w=t.useCallback(()=>!b?.canProceed||b.canProceed(),[b]),N=t.useMemo(()=>w(),[w,d]),y=t.useMemo(()=>!x&&!b?.disableBack,[x,b]),j=t.useCallback(e=>{c(t=>({...t,...e}))},[]),C=t.useCallback((e,t)=>{c(a=>({...a,[e]:t}))},[]),k=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),S=t.useCallback(async()=>{if(w()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[w,p,d,n]),_=t.useCallback(async()=>{w()&&!u&&(g?await S():l(e=>Math.min(e+1,f-1)))},[w,u,g,f,S]),A=t.useCallback(()=>{y&&!u&&l(e=>Math.max(e-1,0))},[y,u]),T=t.useCallback(e=>{e<0||e>=f||u||(e<=i||e===i+1)&&l(e)},[i,f,u]),E=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:b,data:d,isFirstStep:x,isLastStep:g,isLoading:u,isCompleting:p,next:_,back:A,goTo:T,canProceed:N,canGoBack:y,setData:j,updateField:C,reset:k,complete:S,setLoading:E,progress:v,stepIndex:i,totalSteps:f}};
|