forlogic-core 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/supabase/legacyKeyGuard.d.ts +19 -0
- package/docs/STORAGE_BUCKETS.md +163 -96
- package/docs/SUPABASE_SECRETS.md +122 -0
- package/docs/WORKSPACE_KNOWLEDGE.md +34 -0
- package/docs/design-system/patterns/feature-flags.md +57 -0
- package/docs/design-system/patterns/vite-tailwind-setup.md +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("i18next"),a=require("react/jsx-runtime"),t=require("react"),s=require("@radix-ui/react-slot"),r=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("@radix-ui/react-alert-dialog"),h=require("react-hook-form"),x=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),g=require("@radix-ui/react-dropdown-menu"),v=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),y=require("react-i18next"),j=require("@supabase/supabase-js"),w=require("@tanstack/react-query"),N=require("react-router-dom"),_=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-toggle-group"),k=require("@radix-ui/react-toggle"),S=require("@radix-ui/react-scroll-area"),T=require("@radix-ui/react-switch"),P=require("@radix-ui/react-collapsible"),D=require("@radix-ui/react-tabs"),E=require("@radix-ui/react-accordion"),A=require("@radix-ui/react-avatar"),I=require("react-day-picker"),M=require("vaul"),F=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"),U=require("react-resizable-panels"),O=require("@radix-ui/react-slider"),V=require("@radix-ui/react-menubar"),B=require("recharts"),q=require("@tiptap/react"),$=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),Y=require("@tiptap/extension-color"),K=require("@tiptap/extension-highlight"),Q=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),J=require("zod"),Z=require("@hookform/resolvers");function ee(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var ae=ee(t),te=ee(d),se=ee(c),re=ee(u),ne=ee(m),oe=ee(p),ie=ee(x),le=ee(f),de=ee(g),ce=ee(v),ue=ee(b),me=ee(_),pe=ee(C),he=ee(k),xe=ee(S),fe=ee(T),ge=ee(P),ve=ee(D),be=ee(E),ye=ee(A),je=ee(F),we=ee(R),Ne=ee(L),_e=ee(z),Ce=ee(U),ke=ee(O),Se=ee(V),Te=ee(B);const Pe="ccjfvpnndclajkleyqkc",De={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},Ee={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Ae(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e===Pe?De:Ee}function Ie(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e!==Pe}const Me={get oauth(){const e=Ae();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Fe={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Re={debounceDelay:500},Le=()=>{const e=window.location.origin,a=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&a||(void 0).DEV},ze=()=>Le(),Ue=Le,Oe=()=>Ae().qualiexApiUrl,Ve={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Be={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},qe={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}`}},$e=`https://${Ae().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,We={logo:Be.isQualiex?`${$e}/logo-qualiex-white.svg`:`${$e}/saber-gestao-white.png`,smallLogo:Be.isQualiex?`${$e}/logo-forlogic-white.svg`:`${$e}/small.svg`,favicon:`${$e}/favicon.png`},He=We.logo,Ge=We.smallLogo;if("undefined"!=typeof document){document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(e=>e.remove());const e=document.createElement("link");e.rel="icon",e.type="image/png",e.href=We.favicon,document.head.appendChild(e)}const Ye={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 Ke(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Qe={date:Ke({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ke({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:Ke({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Xe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Je(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Ze(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(i,e=>e.test(o)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(o.length)}}}function ea(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[0],n=a.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=t.valueCallback?t.valueCallback(o):o;return{value:o,rest:a.slice(r.length)}}}const aa={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Ye[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:Qe,formatRelative:(e,a,t,s)=>Xe[e],localize:{ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Je({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};let ta={};function sa(){return ta}const ra=6048e5;function na(e){const a=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===a?new e.constructor(+e):"number"==typeof e||"[object Number]"===a||"string"==typeof e||"[object String]"===a?new Date(e):new Date(NaN)}function oa(e){const a=na(e);return a.setHours(0,0,0,0),a}function ia(e){const a=na(e),t=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return t.setUTCFullYear(a.getFullYear()),+e-+t}function la(e,a){return e instanceof Date?new e.constructor(a):new Date(a)}function da(e){const a=na(e),t=function(e,a){const t=oa(e),s=oa(a),r=+t-ia(t),n=+s-ia(s);return Math.round((r-n)/864e5)}(a,function(e){const a=na(e),t=la(e,0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}(a));return t+1}function ca(e,a){const t=sa(),s=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=na(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 ua(e){return ca(e,{weekStartsOn:1})}function ma(e){const a=na(e),t=a.getFullYear(),s=la(e,0);s.setFullYear(t+1,0,4),s.setHours(0,0,0,0);const r=ua(s),n=la(e,0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);const o=ua(n);return a.getTime()>=r.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function pa(e){const a=na(e),t=+ua(a)-+function(e){const a=ma(e),t=la(e,0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),ua(t)}(a);return Math.round(t/ra)+1}function ha(e,a){const t=na(e),s=t.getFullYear(),r=sa(),n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=la(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=ca(o,a),l=la(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=ca(l,a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function xa(e,a){const t=na(e),s=+ca(t,a)-+function(e,a){const t=sa(),s=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=ha(e,a),n=la(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),ca(n,a)}(t,a);return Math.round(s/ra)+1}function fa(e,a){return(e<0?"-":"")+Math.abs(e).toString().padStart(a,"0")}const ga={y(e,a){const t=e.getFullYear(),s=t>0?t:1-t;return fa("yy"===a?s%100:s,a.length)},M(e,a){const t=e.getMonth();return"M"===a?String(t+1):fa(t+1,2)},d:(e,a)=>fa(e.getDate(),a.length),a(e,a){const t=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return"am"===t?"a.m.":"p.m."}},h:(e,a)=>fa(e.getHours()%12||12,a.length),H:(e,a)=>fa(e.getHours(),a.length),m:(e,a)=>fa(e.getMinutes(),a.length),s:(e,a)=>fa(e.getSeconds(),a.length),S(e,a){const t=a.length,s=e.getMilliseconds();return fa(Math.trunc(s*Math.pow(10,t-3)),a.length)}},va="midnight",ba="noon",ya="morning",ja="afternoon",wa="evening",Na="night",_a={G:function(e,a,t){const s=e.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(s,{width:"abbreviated"});case"GGGGG":return t.era(s,{width:"narrow"});default:return t.era(s,{width:"wide"})}},y:function(e,a,t){if("yo"===a){const a=e.getFullYear(),s=a>0?a:1-a;return t.ordinalNumber(s,{unit:"year"})}return ga.y(e,a)},Y:function(e,a,t,s){const r=ha(e,s),n=r>0?r:1-r;if("YY"===a){return fa(n%100,2)}return"Yo"===a?t.ordinalNumber(n,{unit:"year"}):fa(n,a.length)},R:function(e,a){return fa(ma(e),a.length)},u:function(e,a){return fa(e.getFullYear(),a.length)},Q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"Q":return String(s);case"QQ":return fa(s,2);case"Qo":return t.ordinalNumber(s,{unit:"quarter"});case"QQQ":return t.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(s,{width:"narrow",context:"formatting"});default:return t.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"q":return String(s);case"qq":return fa(s,2);case"qo":return t.ordinalNumber(s,{unit:"quarter"});case"qqq":return t.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(s,{width:"narrow",context:"standalone"});default:return t.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,a,t){const s=e.getMonth();switch(a){case"M":case"MM":return ga.M(e,a);case"Mo":return t.ordinalNumber(s+1,{unit:"month"});case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}},L:function(e,a,t){const s=e.getMonth();switch(a){case"L":return String(s+1);case"LL":return fa(s+1,2);case"Lo":return t.ordinalNumber(s+1,{unit:"month"});case"LLL":return t.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(s,{width:"narrow",context:"standalone"});default:return t.month(s,{width:"wide",context:"standalone"})}},w:function(e,a,t,s){const r=xa(e,s);return"wo"===a?t.ordinalNumber(r,{unit:"week"}):fa(r,a.length)},I:function(e,a,t){const s=pa(e);return"Io"===a?t.ordinalNumber(s,{unit:"week"}):fa(s,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getDate(),{unit:"date"}):ga.d(e,a)},D:function(e,a,t){const s=da(e);return"Do"===a?t.ordinalNumber(s,{unit:"dayOfYear"}):fa(s,a.length)},E:function(e,a,t){const s=e.getDay();switch(a){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},e:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"e":return String(n);case"ee":return fa(n,2);case"eo":return t.ordinalNumber(n,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"c":return String(n);case"cc":return fa(n,a.length);case"co":return t.ordinalNumber(n,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(e,a,t){const s=e.getDay(),r=0===s?7:s;switch(a){case"i":return String(r);case"ii":return fa(r,a.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},a:function(e,a,t){const s=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(s,{width:"narrow",context:"formatting"});default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,a,t){const s=e.getHours();let r;switch(r=12===s?ba:0===s?va:s/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,a,t){const s=e.getHours();let r;switch(r=s>=17?wa:s>=12?ja:s>=4?ya:Na,a){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,a,t){if("ho"===a){let a=e.getHours()%12;return 0===a&&(a=12),t.ordinalNumber(a,{unit:"hour"})}return ga.h(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getHours(),{unit:"hour"}):ga.H(e,a)},K:function(e,a,t){const s=e.getHours()%12;return"Ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},k:function(e,a,t){let s=e.getHours();return 0===s&&(s=24),"ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):ga.m(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getSeconds(),{unit:"second"}):ga.s(e,a)},S:function(e,a){return ga.S(e,a)},X:function(e,a,t){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(a){case"X":return ka(s);case"XXXX":case"XX":return Sa(s);default:return Sa(s,":")}},x:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"x":return ka(s);case"xxxx":case"xx":return Sa(s);default:return Sa(s,":")}},O:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},z:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},t:function(e,a,t){return fa(Math.trunc(e.getTime()/1e3),a.length)},T:function(e,a,t){return fa(e.getTime(),a.length)}};function Ca(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?t+String(r):t+String(r)+a+fa(n,2)}function ka(e,a){if(e%60==0){return(e>0?"-":"+")+fa(Math.abs(e)/60,2)}return Sa(e,a)}function Sa(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+fa(Math.trunc(s/60),2)+a+fa(s%60,2)}const Ta=(e,a)=>{switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},Pa=(e,a)=>{switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},Da={p:Pa,P:(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return Ta(e,a);let n;switch(s){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Ta(s,a)).replace("{{time}}",Pa(r,a))}},Ea=/^D+$/,Aa=/^Y+$/,Ia=["D","DD","YY","YYYY"];function Ma(e){if(!(a=e,a instanceof Date||"object"==typeof a&&"[object Date]"===Object.prototype.toString.call(a)||"number"==typeof e))return!1;var a;const t=na(e);return!isNaN(Number(t))}const Fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ra=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,La=/^'([^]*?)'?$/,za=/''/g,Ua=/[a-zA-Z]/;function Oa(e,a,t){const s=sa(),r=t?.locale??s.locale??aa,n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=na(e);if(!Ma(i))throw new RangeError("Invalid time value");let l=a.match(Ra).map(e=>{const a=e[0];if("p"===a||"P"===a){return(0,Da[a])(e,r.formatLong)}return e}).join("").match(Fa).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const a=e[0];if("'"===a)return{isToken:!1,value:Va(e)};if(_a[a])return{isToken:!0,value:e};if(a.match(Ua))throw new RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");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;(!t?.useAdditionalWeekYearTokens&&function(e){return Aa.test(e)}(n)||!t?.useAdditionalDayOfYearTokens&&function(e){return Ea.test(e)}(n))&&function(e,a,t){const s=function(e,a,t){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${a}\`) for formatting ${s} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,a,t);if(Ia.includes(e))throw new RangeError(s)}(n,a,String(e));return(0,_a[n[0]])(i,n,r.localize,d)}).join("")}function Va(e){const a=e.match(La);return a?a[1].replace(za,"'"):e}function Ba(e,a,t){const s=i.getDefaultOptions(),r=function(e,a,t){return new Intl.DateTimeFormat(t?[t.code,"en-US"]:void 0,{timeZone:a,timeZoneName:e})}(e,t.timeZone,t.locale??s.locale);return"formatToParts"in r?function(e,a){const t=e.formatToParts(a);for(let s=t.length-1;s>=0;--s)if("timeZoneName"===t[s].type)return t[s].value;return}(r,a):function(e,a){const t=e.format(a).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(t);return s?s[0].substr(1):""}(r,a)}function qa(e,a){const t=function(e){Wa[e]||(Wa[e]=Ga?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 Wa[e]}(a);return"formatToParts"in t?function(e,a){try{const t=e.formatToParts(a),s=[];for(let e=0;e<t.length;e++){const a=$a[t[e].type];void 0!==a&&(s[a]=parseInt(t[e].value,10))}return s}catch(t){if(t instanceof RangeError)return[NaN];throw t}}(t,e):function(e,a){const t=e.format(a),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(t);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)]}(t,e)}const $a={year:0,month:1,day:2,hour:3,minute:4,second:5};const Wa={},Ha=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")),Ga="06/25/2014, 00:00:00"===Ha||"06/25/2014 00:00:00"===Ha;function Ya(e,a,t,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,a,t),i.setUTCHours(s,r,n,o),i}const Ka=36e5,Qa={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Xa(e,a,t){if(!e)return 0;let s,r,n=Qa.timezoneZ.exec(e);if(n)return 0;if(n=Qa.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Za(s)?-s*Ka:NaN;if(n=Qa.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Za(s,e)?(r=Math.abs(s)*Ka+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(et[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),et[e]=!0,!0}catch(a){return!1}}(e)){a=new Date(a||Date.now());const s=t?a:function(e){return Ya(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(a),r=Ja(s,e),n=t?r:function(e,a,t){const s=e.getTime();let r=s-a;const n=Ja(new Date(r),t);if(a===n)return a;r-=n-a;const o=Ja(new Date(r),t);if(n===o)return n;return Math.max(n,o)}(a,r,e);return-n}return NaN}function Ja(e,a){const t=qa(e,a),s=Ya(t[0],t[1]-1,t[2],t[3]%24,t[4],t[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function Za(e,a){return-23<=e&&e<=23&&(null==a||0<=a&&a<=59)}const et={};const at={X:function(e,a,t){const s=tt(t.timeZone,e);if(0===s)return"Z";switch(a){case"X":return nt(s);case"XXXX":case"XX":return rt(s);default:return rt(s,":")}},x:function(e,a,t){const s=tt(t.timeZone,e);switch(a){case"x":return nt(s);case"xxxx":case"xx":return rt(s);default:return rt(s,":")}},O:function(e,a,t){const s=tt(t.timeZone,e);switch(a){case"O":case"OO":case"OOO":return"GMT"+function(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return t+String(r);return t+String(r)+a+st(n,2)}(s,":");default:return"GMT"+rt(s,":")}},z:function(e,a,t){switch(a){case"z":case"zz":case"zzz":return Ba("short",e,t);default:return Ba("long",e,t)}}};function tt(e,a){const t=e?Xa(e,a,!0)/6e4:a?.getTimezoneOffset()??0;if(Number.isNaN(t))throw new RangeError("Invalid time zone specified: "+e);return t}function st(e,a){const t=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<a;)s="0"+s;return t+s}function rt(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+st(Math.floor(s/60),2)+a+st(Math.floor(s%60),2)}function nt(e,a){if(e%60==0){return(e>0?"-":"+")+st(Math.abs(e)/60,2)}return rt(e,a)}function ot(e){const a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),+e-+a}const it=36e5,lt=6e4,dt={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 ct(e,a={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const t=null==a.additionalDigits?2:Number(a.additionalDigits);if(2!==t&&1!==t&&0!==t)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 a={};let t,s=dt.dateTimePattern.exec(e);s?(a.date=s[1],t=s[3]):(s=dt.datePattern.exec(e),s?(a.date=s[1],t=s[2]):(a.date=null,t=e));if(t){const e=dt.timeZone.exec(t);e?(a.time=t.replace(e[1],""),a.timeZone=e[1].trim()):a.time=t}return a}(e),{year:r,restDateString:n}=function(e,a){if(e){const t=dt.YYY[a],s=dt.YYYYY[a];let r=dt.YYYY.exec(e)||s.exec(e);if(r){const a=r[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(r=dt.YY.exec(e)||t.exec(e),r){const a=r[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}}return{year:null}}(s.date,t),o=function(e,a){if(null===a)return null;let t,s,r;if(!e||!e.length)return t=new Date(0),t.setUTCFullYear(a),t;let n=dt.MM.exec(e);if(n)return t=new Date(0),s=parseInt(n[1],10)-1,xt(a,s)?(t.setUTCFullYear(a,s),t):new Date(NaN);if(n=dt.DDD.exec(e),n){t=new Date(0);const e=parseInt(n[1],10);return function(e,a){if(a<1)return!1;const t=ht(e);if(t&&a>366)return!1;if(!t&&a>365)return!1;return!0}(a,e)?(t.setUTCFullYear(a,0,e),t):new Date(NaN)}if(n=dt.MMDD.exec(e),n){t=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return xt(a,s,e)?(t.setUTCFullYear(a,s,e),t):new Date(NaN)}if(n=dt.Www.exec(e),n)return r=parseInt(n[1],10)-1,ft(r)?ut(a,r):new Date(NaN);if(n=dt.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return ft(r,e)?ut(a,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 t,r=0;if(s.time&&(r=function(e){let a,t,s=dt.HH.exec(e);if(s)return a=parseFloat(s[1].replace(",",".")),gt(a)?a%24*it:NaN;if(s=dt.HHMM.exec(e),s)return a=parseInt(s[1],10),t=parseFloat(s[2].replace(",",".")),gt(a,t)?a%24*it+t*lt:NaN;if(s=dt.HHMMSS.exec(e),s){a=parseInt(s[1],10),t=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return gt(a,t,e)?a%24*it+t*lt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||a.timeZone){if(t=Xa(s.timeZone||a.timeZone,new Date(e+r)),isNaN(t))return new Date(NaN)}else t=ot(new Date(e+r)),t=ot(new Date(e+r+t));return new Date(e+r+t)}return new Date(NaN)}function ut(e,a,t){a=a||0,t=t||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*a+t+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const mt=[31,28,31,30,31,30,31,31,30,31,30,31],pt=[31,29,31,30,31,30,31,31,30,31,30,31];function ht(e){return e%400==0||e%4==0&&e%100!=0}function xt(e,a,t){if(a<0||a>11)return!1;if(null!=t){if(t<1)return!1;const s=ht(e);if(s&&t>pt[a])return!1;if(!s&&t>mt[a])return!1}return!0}function ft(e,a){return!(e<0||e>52)&&(null==a||!(a<0||a>6))}function gt(e,a,t){return!(e<0||e>=25)&&((null==a||!(a<0||a>=60))&&(null==t||!(t<0||t>=60)))}const vt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function bt(e,a,t,s){return function(e,a,t={}){const s=(a=String(a)).match(vt);if(s){const r=ct(t.originalDate||e,t);a=s.reduce(function(e,a){if("'"===a[0])return e;const s=e.indexOf(a),n="'"===e[s-1],o=e.replace(a,"'"+at[a[0]](r,a,t)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},a)}return Oa(e,a,t)}(function(e,a,t){const s=Xa(a,e=ct(e,t),!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,a,{timeZone:(s={...s,timeZone:a,originalDate:e}).timeZone}),t,s)}const yt={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"}},jt={date:Ke({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:Ke({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ke({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},wt={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"},Nt={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"},_t={code:"es",formatDistance:(e,a,t)=>{let s;const r=yt[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:jt,formatRelative:(e,a,t,s)=>1!==a.getHours()?Nt[e]:wt[e],localize:{ordinalNumber:(e,a)=>Number(e)+"º",era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:1,firstWeekContainsDate:1}},Ct={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"}},kt={date:Ke({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:Ke({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ke({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},St={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Tt={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Ct[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:kt,formatRelative:(e,a,t,s)=>{const r=St[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Pt=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Dt=[{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"}],Et=[{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"}],At="pt-BR",It="dd/MM/yyyy HH:mm",Mt="America/Sao_Paulo",Ft=e=>Pt.some(a=>a.value===e),Rt=e=>Et.some(a=>a.value===e),Lt=()=>{if("undefined"==typeof navigator)return At;const e=navigator.language;if(Ft(e))return e;const a=e.split("-")[0],t=Pt.find(e=>e.value.startsWith(a));return t?.value||At},zt=()=>{if("undefined"==typeof Intl)return Mt;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Rt(e)?e:Mt}catch{return Mt}},Ut=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||It),Ot={"pt-BR":Tt,"en-US":aa,"es-ES":_t},Vt=(e,a=It,t=Mt,s=At)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=Ot[s]||Tt;try{return bt(r,t,a,{locale:n})}catch(o){return bt(r,Mt,a,{locale:n})}},Bt=(e,a=At,t=Mt)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=Ot[a]||Tt;try{return bt(s,t,"PP",{locale:r})}catch(n){return bt(s,Mt,"PP",{locale:r})}};function qt(e){const a=e.replace("#",""),t=3===a.length?a.split("").map(e=>e+e).join(""):a;return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function $t(e,a=.1){const{r:t,g:s,b:r}=qt(e);return`rgba(${t}, ${s}, ${r}, ${a})`}function Wt(e){const{r:a,g:t,b:s}=qt(e),[r,n,o]=[a,t,s].map(e=>{const a=e/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return.2126*r+.7152*n+.0722*o}function Ht(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function Gt(e,a){return a?e.replace(/\{alias\}/g,a):e}function Yt(...e){return o.twMerge(n.clsx(e))}const Kt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Kt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Kt(s);return a}return e},Qt=r.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-lg",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"}}),Xt=ae.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},i)=>{const l=n?s.Slot:"button";return a.jsx(l,{className:Yt(Qt({variant:t,size:r,className:e})),ref:i,...o})});Xt.displayName="Button";const Jt=t.forwardRef(({className:e,children:t,variant:s="action",...r},n)=>a.jsx(Xt,{ref:n,variant:s,size:"icon",className:Yt("h-8 w-8",e),...r,children:t||a.jsx(d.EllipsisVertical,{size:16})}));Jt.displayName="ActionButton";const Zt=ae.forwardRef(({className:e,type:t,showCharCount:s,maxLength:r,onChange:n,...o},i)=>{const[l,d]=ae.useState(0);ae.useEffect(()=>{"string"==typeof o.value?d(o.value.length):"string"==typeof o.defaultValue&&d(o.defaultValue.length)},[o.value,o.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("input",{type:t,className:Yt("flex h-10 w-full rounded-lg 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 hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors md:text-sm",e),ref:i,maxLength:r,onChange:e=>{d(e.target.value.length),n?.(e)},...o}),s&&r&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",r]})]})});Zt.displayName="Input";const es=r.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),as=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Root,{ref:s,className:Yt(es(),e),...t}));as.displayName=se.Root.displayName;const ts=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ts.displayName="Card";const ss=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex flex-col space-y-1.5 p-6",e),...t}));ss.displayName="CardHeader";const rs=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Yt("text-2xl font-semibold leading-none tracking-tight",e),...t}));rs.displayName="CardTitle";const ns=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));ns.displayName="CardDescription";const os=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("p-6 pt-0",e),...t}));os.displayName="CardContent";const is=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex items-center p-6 pt-0",e),...t}));is.displayName="CardFooter";const ls=ae.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...r},n)=>a.jsx(ne.Root,{ref:n,decorative:s,orientation:t,className:Yt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ls.displayName=ne.Root.displayName;const ds=oe.Root,cs=oe.Trigger,us=oe.Portal,ms=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Overlay,{className:Yt("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",e),...t,ref:s}));ms.displayName=oe.Overlay.displayName;const ps=ae.forwardRef(({className:e,...t},s)=>a.jsxs(us,{children:[a.jsx(ms,{}),a.jsx(oe.Content,{ref:s,className:Yt("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",e),...t})]}));ps.displayName=oe.Content.displayName;const hs=({className:e,...t})=>a.jsx("div",{className:Yt("flex flex-col space-y-2 text-center sm:text-left",e),...t});hs.displayName="AlertDialogHeader";const xs=({className:e,...t})=>a.jsx("div",{className:Yt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xs.displayName="AlertDialogFooter";const fs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Title,{ref:s,className:Yt("text-lg font-semibold",e),...t}));fs.displayName=oe.Title.displayName;const gs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));gs.displayName=oe.Description.displayName;const vs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Action,{ref:s,className:Yt(Qt(),e),...t}));vs.displayName=oe.Action.displayName;const bs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Cancel,{ref:s,className:Yt(Qt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));bs.displayName=oe.Cancel.displayName;const ys=re.Root,js=re.Trigger,ws=re.Portal,Ns=re.Close,_s=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{ref:s,className:Yt("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",e),...t}));_s.displayName=re.Overlay.displayName;const Cs={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},ks=ae.forwardRef(({className:t,children:s,size:r,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:c,customHeight:u,customMinHeight:m,customMaxHeight:p,unsavedChangesTitle:h=e.t("unsaved_changes"),unsavedChangesDescription:x=e.t("unsaved_changes_description"),cancelText:f=e.t("cancel"),leaveWithoutSavingText:g=e.t("leave_without_saving"),style:v,onInteractOutside:b,onEscapeKeyDown:y,...j},w)=>{const[N,_]=ae.useState(!1),C=ae.useRef(null),k=ae.useRef(!1),S=r??(i||l||c||u||m||p?void 0:"md"),T=S?Cs[S]:{},P={...i??T.width?{width:i??T.width}:{},...l??T.minWidth?{minWidth:l??T.minWidth}:{},...c??T.maxWidth?{maxWidth:c??T.maxWidth}:{},...u??T.height?{height:u??T.height}:{},...m??T.minHeight?{minHeight:m??T.minHeight}:{},...p??T.maxHeight?{maxHeight:p??T.maxHeight}:{},...v},D=ae.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),E=ae.useRef(null),A="destructive"!==n;if("development"===process.env.NODE_ENV&&s){const e=ae.Children.toArray(s);e.some(e=>ae.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>ae.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return a.jsxs(ws,{children:[a.jsx(_s,{}),a.jsxs(re.Content,{ref:w,className:Yt("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border-0 border-l-[10px] border-l-primary 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 max-sm:!w-[calc(100vw-2rem)] max-sm:!h-[calc(100dvh-2rem)] max-sm:!min-w-0 max-sm:!min-h-0 max-sm:!max-w-none max-sm:!max-h-none max-sm:p-4",t),style:P,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void D(()=>{k.current=!0,E.current?.click()})):void y?.(e);e.preventDefault()},...j,children:[s,A&&a.jsxs(re.Close,{ref:E,onClick:e=>{k.current?k.current=!1:"form"===n&&o&&(e.preventDefault(),D(()=>{k.current=!0,E.current?.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]}),a.jsx(ds,{open:N,onOpenChange:_,children:a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:h}),a.jsx(gs,{children:x})]}),a.jsxs(xs,{children:[a.jsx(bs,{onClick:()=>{_(!1),C.current=null},children:f}),a.jsx(vs,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});ks.displayName=re.Content.displayName;const Ss=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Yt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Ss.displayName="DialogHeader";const Ts=({className:e,...t})=>a.jsx("div",{className:Yt("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...t});Ts.displayName="DialogBody";const Ps=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Yt("flex flex-row justify-end gap-2",e),...s,children:t})]});Ps.displayName="DialogFooter";const Ds=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Yt("text-xl font-semibold leading-none tracking-tight",e),...t}));Ds.displayName=re.Title.displayName;const Es=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Es.displayName=re.Description.displayName;const As=h.FormProvider,Is=ae.createContext({}),Ms=()=>{const e=ae.useContext(Is),a=ae.useContext(Fs),{getFieldState:t,formState:s}=h.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},Fs=ae.createContext({}),Rs=ae.forwardRef(({className:e,...t},s)=>{const r=ae.useId();return a.jsx(Fs.Provider,{value:{id:r},children:a.jsx("div",{ref:s,className:Yt("space-y-1.5",e),...t})})});Rs.displayName="FormItem";const Ls=ae.forwardRef(({className:e,...t},s)=>{const{error:r,formItemId:n}=Ms();return a.jsx(as,{ref:s,className:Yt(r&&"text-destructive",e),htmlFor:n,...t})});Ls.displayName="FormLabel";const zs=ae.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=Ms();return a.jsx(s.Slot,{ref:t,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...e})});zs.displayName="FormControl";const Us=ae.forwardRef(({className:e,...t},s)=>{const{formDescriptionId:r}=Ms();return a.jsx("p",{ref:s,id:r,className:Yt("text-sm text-muted-foreground",e),...t})});Us.displayName="FormDescription";const Os=ae.forwardRef(({className:e,children:t,...s},r)=>{const{error:n,formMessageId:o}=Ms(),i=n?String(n?.message):t;return i?a.jsx("p",{ref:r,id:o,className:Yt("text-sm font-medium text-destructive",e),...s,children:i}):null});Os.displayName="FormMessage";const Vs=ie.Root,Bs=ie.Group,qs=ie.Value,$s=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Trigger,{ref:r,className:Yt("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors [&>span]:line-clamp-1",e),...s,children:[t,a.jsx(ie.Icon,{asChild:!0,children:a.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));$s.displayName=ie.Trigger.displayName;const Ws=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollUpButton,{ref:s,className:Yt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronUp,{className:"h-4 w-4"})}));Ws.displayName=ie.ScrollUpButton.displayName;const Hs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollDownButton,{ref:s,className:Yt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronDown,{className:"h-4 w-4"})}));Hs.displayName=ie.ScrollDownButton.displayName;const Gs=ae.forwardRef(({className:e,children:t,position:s="popper",container:r,collisionBoundary:n,...o},i)=>a.jsx(ie.Portal,{container:r,children:a.jsxs(ie.Content,{ref:i,className:Yt("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",e),position:s,collisionBoundary:n,...o,children:[a.jsx(Ws,{}),a.jsx(ie.Viewport,{className:Yt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(Hs,{})]})}));Gs.displayName=ie.Content.displayName;const Ys=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.Label,{ref:s,className:Yt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ys.displayName=ie.Label.displayName;const Ks=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Item,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(ie.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),a.jsx(ie.ItemText,{children:t})]}));Ks.displayName=ie.Item.displayName;const Qs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));Qs.displayName=ie.Separator.displayName;const Xs=ae.forwardRef(({className:e,...t},s)=>a.jsx(le.Root,{ref:s,className:Yt("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",e),...t,children:a.jsx(le.Indicator,{className:Yt("flex items-center justify-center text-current"),children:a.jsx(d.Check,{className:"h-4 w-4"})})}));Xs.displayName=le.Root.displayName;const Js=ae.forwardRef(({className:e,showCharCount:t,maxLength:s,onChange:r,...n},o)=>{const[i,l]=ae.useState(0);ae.useEffect(()=>{"string"==typeof n.value?l(n.value.length):"string"==typeof n.defaultValue&&l(n.defaultValue.length)},[n.value,n.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("textarea",{className:Yt("flex min-h-[80px] w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",e),ref:o,maxLength:s,onChange:e=>{l(e.target.value.length),r?.(e)},...n}),t&&s&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",s]})]})});Js.displayName="Textarea";const Zs=r.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"}}),er=ae.forwardRef(({className:e,variant:t,...s},r)=>a.jsx("div",{ref:r,className:Yt(Zs({variant:t}),e),...s}));er.displayName="Badge";const ar={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function tr({size:e="md",className:t}){return a.jsx(d.Loader2,{className:Yt("animate-spin text-muted-foreground",ar[e],t)})}function sr({isLoading:e,children:t,className:s,type:r="spinner",size:n="md"}){return e?"overlay"===r?a.jsxs("div",{className:Yt("relative",s),children:[t,a.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:a.jsx(tr,{size:n})})]}):"skeleton"===r?a.jsx("div",{className:Yt("animate-pulse",s),children:a.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):a.jsx("div",{className:Yt("flex items-center justify-center py-8",s),children:a.jsx(tr,{size:n})}):a.jsx(a.Fragment,{children:t})}const rr=({...e})=>a.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:a.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:a.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:a.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:a.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:a.jsx(d.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive-light !border-destructive-light",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...e}),nr=de.Root,or=de.Trigger,ir=de.Group,lr=de.Portal,dr=de.Sub,cr=de.RadioGroup,ur=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(de.SubTrigger,{ref:n,className:Yt("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ur.displayName=de.SubTrigger.displayName;const mr=ae.forwardRef(({className:e,...t},s)=>a.jsx(de.SubContent,{ref:s,className:Yt("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",e),...t}));mr.displayName=de.SubContent.displayName;const pr=ae.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(de.Portal,{children:a.jsx(de.Content,{ref:r,sideOffset:t,className:Yt("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",e),...s})}));pr.displayName=de.Content.displayName;const hr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Item,{ref:r,className:Yt("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));hr.displayName=de.Item.displayName;const xr=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(de.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));xr.displayName=de.CheckboxItem.displayName;const fr=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(de.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fr.displayName=de.RadioItem.displayName;const gr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));gr.displayName=de.Label.displayName;const vr=ae.forwardRef(({className:e,...t},s)=>a.jsx(de.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));vr.displayName=de.Separator.displayName;const br=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest opacity-60",e),...t});br.displayName="DropdownMenuShortcut";const yr=({delayDuration:e=300,...t})=>a.jsx(ce.Provider,{delayDuration:e,...t}),jr=ce.Root,wr=ce.Trigger,Nr=ae.forwardRef(({className:e,sideOffset:t=4,container:s,...r},n)=>a.jsx(ce.Portal,{container:s,children:a.jsx(ce.Content,{ref:n,sideOffset:t,className:Yt("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",e),...r})}));Nr.displayName=ce.Content.displayName;const _r=ae.forwardRef(({children:e,disabledReason:t,className:s},r)=>{const n=a.jsx(hr,{ref:r,className:Yt("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return t?a.jsx(yr,{delayDuration:100,children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:"w-full",children:n})}),a.jsx(Nr,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:t})]})}):n});_r.displayName="DisabledMenuItem";const Cr=ue.Root,kr=ue.Trigger,Sr=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,container:r,...n},o)=>a.jsx(ue.Portal,{container:r,children:a.jsx(ue.Content,{ref:o,align:t,sideOffset:s,className:Yt("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",e),...n})}));Sr.displayName=ue.Content.displayName;const Tr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tr.displayName="Command";const Pr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:a.jsx("input",{ref:s,className:Yt("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",e),...t})}));Pr.displayName="CommandInput";const Dr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Dr.displayName="CommandList";const Er=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("py-6 text-center text-sm text-muted-foreground",e),...t}));Er.displayName="CommandEmpty";const Ar=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("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",e),...t}));Ar.displayName="CommandGroup";const Ir=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("-mx-1 h-px bg-border",e),...t}));Ir.displayName="CommandSeparator";const Mr=ae.forwardRef(({className:e,disabled:t,onSelect:s,value:r,...n},o)=>a.jsx("div",{ref:o,className:Yt("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",e),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Mr.displayName="CommandItem";const Fr=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function Rr({className:e,...t}){return a.jsx("div",{className:Yt("animate-pulse rounded-md bg-muted",e),...t})}Fr.displayName="CommandShortcut";const Lr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function zr({multiple:s,options:r,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x,required:f,className:g,sortOptions:v,maxDisplayedBadges:b,popoverContainer:y,onOpen:j,onClose:w,clearable:N}){const[_,C]=t.useState(!1),[k,S]=t.useState(""),T=t.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),P=t.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),D=t.useMemo(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),E=t.useMemo(()=>{if(!k)return D;const e=Lr(k);return D.filter(a=>Lr(a.label).includes(e))},[D,k]),A=t.useMemo(()=>D.filter(e=>T.includes(e.value)),[D,T]),I=e=>{C(e),e?j?.():(S(""),w?.())},M=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(s?T.filter(a=>a!==e):"")},F=b?A.slice(0,b):A,R=b&&A.length>b?A.length-b:0;return a.jsxs("div",{className:Yt("space-y-2",g),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:_,onOpenChange:I,modal:!1,children:[s?a.jsx(kr,{asChild:!0,children:a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":x,tabIndex:x?-1:0,onKeyDown:e=>{x||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),I(!_))},className:Yt("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",x&&"pointer-events-none opacity-50 cursor-not-allowed",0===A.length&&"text-muted-foreground"),children:[0===A.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[F.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&M(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>M(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),R>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",R]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:x,className:Yt("flex-1 justify-between min-h-10 h-auto",0===A.length&&"text-muted-foreground"),children:[0===A.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),A[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),N&&A.length>0&&a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",disabled:x,className:"h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground",onClick:e=>M("",e),title:"Limpar seleção",children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:P,collisionBoundary:P,children:a.jsxs(Tr,{children:[a.jsxs("div",{className:"relative",children:[a.jsx(Pr,{placeholder:h,value:k,onChange:e=>S(e.target.value)}),k&&a.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:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx(Dr,{children:0===r.length?a.jsx(Er,{children:p}):0===E.length?a.jsx(Er,{children:e.t("no_results")}):a.jsx(Ar,{children:E.map(e=>a.jsxs(Mr,{value:e.value,onSelect:()=>(e=>{if(o)if(s){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];o(a)}else o(e),C(!1)})(e.value),className:"cursor-pointer",children:[a.jsx(d.Check,{className:Yt("mr-2 h-4 w-4",T.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})]})]})}function Ur({multiple:e=!1,options:t,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:g=!1,error:v,className:b,sortOptions:j=!0,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C,clearable:k=!0}){const{t:S}=y.useTranslation(),T=t||s||[],P=o||n,D=c||S("select_placeholder","Selecione..."),E=p||S("no_results",S("no_results")),A=h||S("search_placeholder","Pesquisar...");if(g)return a.jsxs("div",{className:Yt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const I="string"==typeof v?v:v instanceof Error?v.message:v?S("error_loading",S("error_loading")):void 0;return I?a.jsxs("div",{className:Yt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:I})]})]}):a.jsx(zr,{multiple:e,options:T,value:r||(e?[]:""),onChange:P,getOptionValue:i,getOptionLabel:l,placeholder:D,label:u,icon:m,emptyMessage:E,searchPlaceholder:A,disabled:x,required:f,className:b,sortOptions:j,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C,clearable:k})}const Or=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Vr(e,a){if(!a)return null;const t=Or(a),s=[];for(const r of e){const e=Or(r.label).includes(t),n=r.children?Vr(r.children,a):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function Br(e,a){for(const t of e){if(t.value===a)return t.label;if(t.children){const e=Br(t.children,a);if(e)return e}}}function qr({node:e,level:t,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=e.children&&e.children.length>0,l=n.includes(e.value);return a.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":l,className:Yt("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*t+"px"},children:[a.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:a=>{a.stopPropagation(),o(e.value)},children:[a.jsx(d.Check,{className:Yt("h-4 w-4 shrink-0",l?"opacity-100":"opacity-0")}),(()=>{const t=l?e.iconSelected??(s?e.iconOpen:null)??e.icon:s?e.iconOpen??e.icon:e.icon;return t?a.jsx(t,{className:Yt("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),a.jsx("span",{className:"truncate",children:e.label})]}),i&&a.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:a=>{a.stopPropagation(),r(e.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?a.jsx(d.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function $r({nodes:e,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return a.jsx(a.Fragment,{children:e.map(e=>{const l=r.has(e.value);return a.jsxs(t.Fragment,{children:[a.jsx(qr,{node:e,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&e.children&&e.children.length>0&&a.jsx($r,{nodes:e.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},e.value)})})}function Wr({multiple:e=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:v,onOpen:b,onClose:j,defaultExpanded:w=!0}){const{t:N}=y.useTranslation(),[_,C]=t.useState(!1),[k,S]=t.useState(""),[T,P]=t.useState(()=>w?function(e){const a=new Set;return function e(t){for(const s of t)s.children&&s.children.length>0&&(a.add(s.value),e(s.children))}(e),a}(s):new Set),D=o||N("select_placeholder","Selecione..."),E=c||N("no_results",N("no_results")),A=u||N("search_placeholder","Pesquisar..."),I=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),M=t.useMemo(()=>{if(!v)return;let e=v,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[v]),F=t.useMemo(()=>Vr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,a){const t=new Set,s=Or(a);function r(e){if(!e.children||0===e.children.length)return Or(e.label).includes(s);let a=!1;for(const t of e.children)r(t)&&(a=!0);return a&&t.add(e.value),a||Or(e.label).includes(s)}for(const n of e)r(n);return t}(s,k):new Set,[s,k]),L=k?R:T,z=t.useCallback(e=>{k||P(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[k]),U=t.useMemo(()=>I.map(e=>({value:e,label:Br(s,e)||e})),[I,s]),O=e=>{C(e),e?b?.():(S(""),j?.())},V=t.useCallback(a=>{if(n)if(e){const e=I.includes(a)?I.filter(e=>e!==a):[...I,a];n(e)}else n(a),C(!1)},[n,e,I]),B=(a,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(e?I.filter(e=>e!==a):"")},q=g?U.slice(0,g):U,$=g&&U.length>g?U.length-g:0;if(h)return a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const W="string"==typeof x?x:x instanceof Error?x.message:x?N("error_loading",N("error_loading")):void 0;return W?a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:W})]})]}):a.jsxs("div",{className:Yt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:_,onOpenChange:O,modal:!1,children:[a.jsx(kr,{asChild:!0,children:e?a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),O(!_))},className:Yt("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===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[q.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&B(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>B(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),$>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",$]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:m,className:Yt("w-full justify-between min-h-10 h-auto font-normal",0===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),D]}):a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),U[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:M,collisionBoundary:M,children:[a.jsxs("div",{className:"flex items-center border-b px-3",children:[a.jsx(d.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.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:A,value:k,onChange:e=>S(e.target.value)}),k&&a.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx("div",{className:"max-h-[300px] overflow-y-auto overflow-x-hidden",children:a.jsx("div",{role:"tree",className:"p-1",children:0===F.length?a.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?E:N("no_search_results",N("no_results"))}):a.jsx($r,{nodes:F,level:0,expandedIds:L,onToggleExpand:z,selectedValues:I,onSelect:V})})})]})]})]})}class Hr{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.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";t.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:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}}Hr.LARGE_PAYLOAD_THRESHOLD=1e3;const Gr="qualiex_access_token",Yr="qualiex_id_token",Kr="supabase_token",Qr="oauth_state",Xr="oauth_nonce",Jr="selected_alias",Zr="manual_logout",en="supabase_project_id",an={setAccessToken:e=>localStorage.setItem(Gr,e),getAccessToken:()=>localStorage.getItem(Gr),setIdToken:e=>localStorage.setItem(Yr,e),getIdToken:()=>localStorage.getItem(Yr),getSupabaseToken:()=>localStorage.getItem(Kr),setOAuthState:e=>sessionStorage.setItem(Qr,e),getOAuthState:()=>sessionStorage.getItem(Qr),clearOAuthState:()=>sessionStorage.removeItem(Qr),setOAuthNonce:e=>sessionStorage.setItem(Xr,e),getOAuthNonce:()=>sessionStorage.getItem(Xr),clearOAuthNonce:()=>sessionStorage.removeItem(Xr),setSelectedAlias:e=>localStorage.setItem(Jr,e),getSelectedAlias:()=>localStorage.getItem(Jr),clearSelectedAlias:()=>localStorage.removeItem(Jr),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!an.getAccessToken()||!an.getIdToken()),checkProjectMismatch:()=>{const e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)return!1;const a=localStorage.getItem(en);return a&&a!==e?(an.clearAll(),localStorage.setItem(en,e),!0):(a||localStorage.setItem(en,e),!1)},setSupabaseToken:e=>{localStorage.setItem(Kr,e),an._clearValidationCache()},areAllTokensValid:()=>{const e=an.getAccessToken(),a=an.getIdToken();if(!e||!a)return!1;try{const t=Hr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=an.getAccessToken(),t=an.getIdToken(),s=an.getSupabaseToken();return a&&an.isTokenExpired(a)&&(localStorage.removeItem(Gr),e=!0),t&&an.isTokenExpired(t)&&(localStorage.removeItem(Yr),e=!0),s&&an.isTokenExpired(s)&&(localStorage.removeItem(Kr),e=!0),e},clearAll:()=>{localStorage.removeItem(Gr),localStorage.removeItem(Yr),localStorage.removeItem(Kr),localStorage.removeItem(Jr),localStorage.removeItem(Zr),sessionStorage.removeItem(Qr),sessionStorage.removeItem(Xr),an._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Zr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Zr),clearManualLogout:()=>localStorage.removeItem(Zr),isTokenExpired:e=>{try{return Hr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{an._validationCache.isValid=!1,an._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=an.getSupabaseToken();if(!e)return!1;if(an.isTokenExpired(e))return an._clearValidationCache(),an._handleExpiredToken(),!1;const a=Date.now();return a-an._validationCache.timestamp<an._validationCache.cacheValidityMs?an._validationCache.isValid:(an._validationCache.isValid=!0,an._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>an.isSupabaseTokenValid()?an.getSupabaseToken():null,_handleExpiredToken:()=>{an.clearAll()},extractTokenData:()=>{if(!an.isSupabaseTokenValid())return null;const e=an.getSupabaseToken();if(!e)return null;try{const a=Hr.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return an._handleExpiredToken(),null}},getCompanyId:e=>{const a=an.getAccessToken();if(a)try{const t=Hr.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=an.extractTokenData();if(t?.companyId)return t.companyId;const s=an.getIdToken();if(s)try{const a=Hr.parseJwtPayload(s);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCompanyIdInt:e=>{const a=[an.getAccessToken(),an.getIdToken()];for(const t of a)if(t)try{const a=Hr.parseJwtPayload(t);if(!a)continue;for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>1&&a[0]===e)return a[1];if(!e&&a.length>1)return a[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=an.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=an.getIdToken();if(!e)return[];try{const a=Hr.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};const tn=new class{constructor(){this.errors=[],this.toastCount=0,this.lastToastTime=0}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);l.toast.error(e,{description:t})}}getErrorTitle(a){const t=a.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?e.t("error_session_expired"):t.includes("token")||t.includes("autenticação")?e.t("error_authentication"):t.includes("api")||t.includes("network")?e.t("error_connection"):"Erro"}success(e,a){l.toast.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}},sn=(void 0).VITE_SUPABASE_URL,rn=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;class nn{constructor(){this.currentToken=null,this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:rn};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return j.createClient(sn,rn,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,a)}})}static getInstance(){return nn.instance||(nn.instance=new nn),nn.instance}getClient(){const e=an.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Hr.isTokenExpired(e)}catch(a){return tn.handleError(a instanceof Error?a:"Supabase - Error validating token",!1),!1}}}function on(){return nn.getInstance().getClient()}class ln{static async generateToken(e,a,t,s=!1){try{if(!s){const e=an.getSupabaseToken();if(e&&an.isSupabaseTokenValid())return e}const r=on(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token?(an.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}class dn{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 a=an.getAccessToken(),t=an.getSelectedAlias();if(!a||!t)return null;const s=await ln.generateToken(a,t,this.onLogoutCallback||void 0,e);return s||null}catch(a){return null}}}dn.regenerationPromise=null,dn.onLogoutCallback=null;class cn{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(an.clearAll(),window.location.href="/login",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}class un{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await dn.attemptRegeneration()?(this.isRetrying=!1,!0):(cn.handleError(e),this.isRetrying=!1,!1)}catch(s){return cn.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=an.getAccessToken();return e?an.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."}}}un.isRetrying=!1;const mn=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=un.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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){let a;return a="boolean"==typeof e.isActive?e.isActive:"boolean"==typeof e.active?e.active:"string"!=typeof e.status||"active"===e.status.toLowerCase(),{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,isActive:a}}parseUsersResponse(e,a=""){let t=e;if(e.data)t=e.data;else{if(!Array.isArray(e))return tn.handleError(`[QualiexApi] Formato de resposta inesperado${a}`,!1),null;t=e}return Array.isArray(t)?t.map(e=>this.mapToQualiexUser(e)):(tn.handleError(`[QualiexApi] Resposta não é um array${a}`,!1),null)}async fetchUsers(e,a,t="active"){const s={companyId:a,search:"",filterStatus:t};try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a)??[]}catch(r){if(await un.handleApiError(r))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a," após retry")??[]}catch(n){return tn.handleError(n instanceof Error?n:"Erro ao buscar usuários após renovação de token",!0),[]}return tn.handleError(r instanceof Error?r.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return tn.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a,"active"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async fetchAllUsersMap(e,a){const t=await this.fetchUsers(e,a,"all"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async getUsers(e,a="active"){const t=an.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId,a):[]}async fetchSoftwares(e){try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(tn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(a){if(await un.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(t){return tn.handleError(t instanceof Error?t:"Erro ao buscar softwares após renovação de token",!0),[]}return tn.handleError(a instanceof Error?a.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,a){try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;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})):(tn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(t){if(await un.handleApiError(t))try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;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 tn.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar associações do usuário",!0),[]}}};function pn(e,a){const t=a||Ve.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function hn(e,a){const t=a||Ve.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function xn(e,a){const t=a||Ve.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function fn(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||pn(e.idField),emailField:e.emailField||hn(e.idField),usernameField:e.usernameField||xn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:pn(e),emailField:hn(e),usernameField:xn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const gn=new Map;class vn{static async fetchQualiexUsers(e,a){const t=`${a}_${e}_all`,s=gn.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await mn.fetchUsers(e,a,"all");return gn.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!an.areAllTokensValid())return e;const t=an.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=fn(a.userIdFields,a.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(t){return tn.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}}const bn=["responsible_name"],yn=e=>bn.includes(e);function jn(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!an.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return on().schema(i).from(r)},u=(e,a,t,s)=>{let r=c().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const i=a.includes(".");return i||yn(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:i}},m=async(e,a,t,r,n)=>{const o=fn(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),i=a.includes(".");if(yn(a)||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 vn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?o:-o}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?o:-o}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t;return{data:e.slice(s,r),pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await vn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:o,limit:i,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let v=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const a=fn(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await m(v.data,t,n,o,i);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(o||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Kt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Kt(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}};return p}var wn;const Nn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class _n{static async initialize(){try{if(an.checkProjectMismatch())return{...Nn};if(!an.hasAllTokens()||!an.areAllTokensValid())return an.clearExpiredTokens(),{...Nn};const e=an.getAccessToken(),a=an.getIdToken();an.clearManualLogout();const t=this.extractUserFromIdToken(a,e),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=an.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=an.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);i=a?e:r||s[0]?.alias||null}if(!an.isSupabaseTokenValid()&&i&&await dn.attemptRegeneration(),!an.isSupabaseTokenValid())return{...Nn};let l=null;if(i){const e=an.getCompanyId(i),a=s.find(e=>e.alias===i);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}const d=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:t,alias:i,companies:s,selectedUnit:l,userId:t?.id||null,userAlias:t?.id||null,placeId:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{...Nn}}}static async loginDev(){try{const e=on(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e="Lw==";an.setOAuthState(e);const a=an.generateOAuthNonce();an.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(Me.oauth.authUrl);s.searchParams.set("client_id",Me.oauth.clientId),s.searchParams.set("response_type",Me.oauth.responseType),s.searchParams.set("scope",Me.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),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),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(s&&r){const e=an.getAccessToken();e!==s&&an.clearAll()}if(an.hasAllTokens()){return an.getValidSupabaseToken()||await dn.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");an.setAccessToken(o),an.setIdToken(i),an.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)an.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");an.setSelectedAlias(e[0].alias)}if(!await dn.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return an.clearOAuthState(),an.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){an.setManualLogout(),an.clearAll(),localStorage.removeItem("auth_return_url"),sessionStorage.clear();try{if("caches"in window){const e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}catch{}window.location.href="/login"}static decodeToken(e){return Hr.parseJwtPayload(e)}static extractUserFromIdToken(e,a){const t=this.decodeToken(e);if(!t)return null;const s=a?this.decodeToken(a):null;return{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier,isSysAdmin:"1"===s?.admin}}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}}wn=_n,dn.setLogoutCallback(()=>{wn.logout()});const Cn=e=>e?.placeId||null,kn=e=>e?.placeName||null,Sn=t.createContext(void 0),Tn=({children:e})=>{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=w.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useRef(0),d=t.useCallback(e=>{r(a=>({...a,...e}))},[]),c=t.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),u=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})},[]),m=t.useCallback(async e=>{if(e.alias===s.alias)return;const a=++l.current;try{const r=an.getAccessToken();if(!r)return;const o=await ln.generateToken(r,e.alias,void 0,!0);if(l.current!==a)return;if(!o)return;an.setSupabaseToken(o),an.setSelectedAlias(e.alias);const i=an.extractTokenData(),c=i?.alias||e.alias,u=i?.companyId||an.getCompanyId(e.alias),m={id:u||e.id,name:e.name,alias:c};let p=null,h=null;if(s.user?.id&&c&&u)try{const e=await mn.fetchActiveUsersMap(c,u);if(l.current!==a)return;const t=e.get(s.user.id);if(t){const e=(e=>({placeId:Cn(e),placeName:kn(e)}))(t);p=e.placeId,h=e.placeName}}catch(t){}if(l.current!==a)return;d({alias:c,selectedUnit:m,placeId:p,placeName:h,activePlaceId:p,activePlaceName:h}),n&&await n.clear()}catch(t){}},[d,n,s.user,s.alias]),p=t.useCallback(async()=>{const e=await _n.processCallback();if(e){const e=await _n.initialize();e&&e.isAuthenticated&&(d({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},[d,n]),h=t.useCallback(async()=>{await _n.logout(),u(),n&&await n.clear()},[u,n]),x=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),g=t.useCallback(()=>{n&&n.invalidateQueries()},[n]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(async()=>{if(e)if(an.areAllTokensValid()){if(!an.isSupabaseTokenValid())try{await dn.attemptRegeneration()||e&&h()}catch(a){e&&h()}}else e&&h()},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,h]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await _n.initialize();if(!e)return;a&&a.isAuthenticated?d({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&c(!1)}catch(a){e&&(cn.handleError(a),c(!1))}})(),()=>{e=!1}},[d,c,h]);const v=t.useMemo(()=>({...s,logout:h,processCallback:p,switchUnit:m,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:x,clearSearch:f,refreshData:g}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,h,p,m,o,x,f,g]);return a.jsx(Sn.Provider,{value:v,children:e})},Pn=()=>{const e=t.useContext(Sn);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Dn({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[i,d]=N.useSearchParams(),c=w.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=Pn(),{t:h}=y.useTranslation(),x=t.useCallback(a=>{const t=`${e}_${a}`,s=i.get(t);return s||(i.get(a)||"")},[i,e]),f=x("search"),g=x("sortField")||Fe.sorting.defaultField,v=x("sortDirection")||Fe.sorting.defaultDirection,b=parseInt(x("page")||"1"),j=parseInt(x("limit")||String(Fe.pagination.defaultPageSize)),_=f,C=t.useMemo(()=>({search:_,sortField:g,sortDirection:v,page:b,limit:j,...n}),[_,g,v,b,j,n]),k=t.useCallback(()=>a.getAll(C),[a,C]),S=w.useQuery({queryKey:[e,u,m,C],queryFn:k,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const T=w.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.created(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.create(s)}: ${e.message}`)}}),P=w.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.updated(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.update(s)}: ${e.message}`)}}),D=w.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.deleted(s))},onError:e=>{l.toast.error(`${qe.error.delete(s)}: ${e.message}`)}}),E=t.useCallback(a=>{const t={...Object.fromEntries(i)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[i,d,e]),A=t.useCallback(e=>{E({search:e,page:1})},[E]),I=t.useCallback(e=>{E({sortField:e,sortDirection:g===e&&"asc"===v?"desc":"asc",page:1})},[g,v,E]),M=t.useCallback(e=>{E({page:e})},[E]),F=t.useCallback(e=>{E({limit:e,page:1})},[E]),R=t.useCallback(()=>{const a=Object.fromEntries(i),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,i,e]),[L,z]=t.useState([]),U=t.useCallback(e=>{z(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),O=t.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(a=>a.length===e.length?[]:e)},[S?.data?.data]),V=t.useCallback(()=>{z([])},[]),B=t.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&L.length===e.length},[L,S?.data?.data]),q=w.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${t.length} ${s}(s) deletado(s) com sucesso`)),V()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=t.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):T.mutate({...t,alias:u})},[u,T,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Fe.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:T?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:D?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:v,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:T.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:D.mutate,save:$,handleSearch:A,handleSort:I,handlePageChange:M,handleItemsPerPageChange:F,clearFilters:R,refetch:S.refetch,selectedIds:L,selectItem:U,selectAll:O,clearSelection:V,isAllSelected:B,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}function En(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.useEffect(()=>{const a=window.matchMedia(e);s(a.matches);const t=e=>{s(e.matches)};return a.addEventListener("change",t),()=>a.removeEventListener("change",t)},[e]),a}function An(e=768){return En(`(max-width: ${e-1}px)`)}const In=ae.forwardRef(({className:e,...t},s)=>a.jsx("table",{ref:s,className:Yt("w-full caption-bottom text-[13px] table-fixed",e),...t}));In.displayName="Table";const Mn=ae.forwardRef(({className:e,...t},s)=>a.jsx("thead",{ref:s,className:Yt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));Mn.displayName="TableHeader";const Fn=ae.forwardRef(({className:e,...t},s)=>a.jsx("tbody",{ref:s,className:Yt("[&_tr:last-child]:border-0",e),...t}));Fn.displayName="TableBody";const Rn=ae.forwardRef(({className:e,...t},s)=>a.jsx("tfoot",{ref:s,className:Yt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Rn.displayName="TableFooter";const Ln=ae.forwardRef(({className:e,...t},s)=>a.jsx("tr",{ref:s,className:Yt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...t}));Ln.displayName="TableRow";const zn=ae.forwardRef(({className:e,...t},s)=>a.jsx("th",{ref:s,className:Yt("h-9 px-4 py-2 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));zn.displayName="TableHead";const Un=ae.forwardRef(({className:e,...t},s)=>a.jsx("td",{ref:s,className:Yt("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...t}));Un.displayName="TableCell";const On=ae.forwardRef(({className:e,...t},s)=>a.jsx("caption",{ref:s,className:Yt("mt-4 text-sm text-muted-foreground",e),...t}));function Vn({rows:e=5,columns:t=4}){return a.jsx("div",{className:"w-full",children:a.jsxs("div",{className:"rounded-md border",children:[a.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-24"},t))})}),a.jsx("div",{children:Array.from({length:e}).map((e,s)=>a.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-20"},t))})},s))})]})})}function Bn({count:e=3}){return a.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>a.jsxs(ts,{children:[a.jsxs(ss,{children:[a.jsx(Rr,{className:"h-4 w-3/4"}),a.jsx(Rr,{className:"h-3 w-1/2"})]}),a.jsx(os,{children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-3 w-full"}),a.jsx(Rr,{className:"h-3 w-2/3"})]})})]},t))})}On.displayName="TableCaption";const qn={default:d.FileX,search:d.Search,error:d.AlertCircle};function $n({icon:e,title:t,description:s,action:r,className:n,variant:o="default"}){const{t:i}=y.useTranslation(),l=!!e,d=qn[o];return a.jsxs("div",{className:Yt("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[a.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:a.jsx(d,{className:"h-8 w-8 text-muted-foreground"})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&a.jsx(Xt,{onClick:r.onClick,variant:"outline",children:r.label})]})}function Wn({children:e,className:t}){const s=ae.useRef(null),[r,n]=ae.useState(!1);ae.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[e]);const o=a.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:e});return r?a.jsx(yr,{delayDuration:300,children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:o}),a.jsx(Nr,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const Hn=ae.forwardRef(({direction:e,onMouseDown:t,isDragging:s,className:r},n)=>{const o="horizontal"===e;return a.jsx("div",{ref:n,onMouseDown:t,className:Yt("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:a.jsx("div",{className:Yt("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Hn.displayName="TableResizeHandle";const Gn=me.Root,Yn=me.Trigger,Kn=me.Group,Qn=me.Portal,Xn=me.Sub,Jn=me.RadioGroup,Zn=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(me.SubTrigger,{ref:n,className:Yt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Zn.displayName=me.SubTrigger.displayName;const eo=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.SubContent,{ref:s,className:Yt("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",e),...t}));eo.displayName=me.SubContent.displayName;const ao=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Portal,{children:a.jsx(me.Content,{ref:s,className:Yt("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",e),...t})}));ao.displayName=me.Content.displayName;const to=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Item,{ref:r,className:Yt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));to.displayName=me.Item.displayName;const so=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(me.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));so.displayName=me.CheckboxItem.displayName;const ro=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(me.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ro.displayName=me.RadioItem.displayName;const no=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...s}));no.displayName=me.Label.displayName;const oo=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-border",e),...t}));oo.displayName=me.Separator.displayName;const io=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});io.displayName="ContextMenuShortcut";const lo=({onEdit:e,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=y.useTranslation(),c=[];if(e){const a={icon:d.Edit,label:l("edit"),onClick:e};c.push(a)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("ap_delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===i?hr:to;return a.jsx(a.Fragment,{children:c.map((e,t)=>a.jsxs(u,{onClick:e.onClick,className:Yt("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[a.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},t))})},co=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:a.jsx(d.EllipsisVertical,{size:12})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:a.jsx(lo,{onEdit:e?a=>{a?.stopPropagation(),e?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:o,renderAs:"dropdown"})})]}),uo=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>{const{t:i}=y.useTranslation();return a.jsx(yr,{delayDuration:200,children:a.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e()},children:a.jsx(d.Pencil,{size:14})})}),a.jsx(Nr,{children:i("edit")})]}),o.map((e,t)=>{const s=e.icon;return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e.onClick()},children:a.jsx(s,{size:14})})}),a.jsx(Nr,{children:e.label})]},t)}),r&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),r()},children:n?a.jsx(d.ToggleRight,{size:14}):a.jsx(d.ToggleLeft,{size:14})})}),a.jsx(Nr,{children:n?"Inativar":"Ativar"})]}),t&&s&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),t()},children:a.jsx(d.Trash2,{size:14})})}),a.jsx(Nr,{children:i("ap_delete")})]})]})})},mo=150;function po({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??mo,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??mo,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??mo)},[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 a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));o(e=>{const a={...e,[d]:t};return s?.(a),a})},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,a)=>(e[a.key]=a.defaultWidth??mo,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}const ho=r.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"}}),xo=ae.forwardRef(({className:e,variant:t,size:s,...r},n)=>a.jsx(he.Root,{ref:n,className:Yt(ho({variant:t,size:s,className:e})),...r}));xo.displayName=he.Root.displayName;const fo=ae.createContext({size:"default",variant:"default"}),go=ae.forwardRef(({className:e,variant:t,size:s,children:r,...n},o)=>a.jsx(pe.Root,{ref:o,className:Yt("flex items-center justify-center gap-1",e),...n,children:a.jsx(fo.Provider,{value:{variant:t,size:s},children:r})}));go.displayName=pe.Root.displayName;const vo=ae.forwardRef(({className:e,children:t,variant:s,size:r,...n},o)=>{const i=ae.useContext(fo);return a.jsx(pe.Item,{ref:o,className:Yt(ho({variant:i.variant||s,size:i.size||r}),e),...n,children:t})});vo.displayName=pe.Item.displayName;const bo=t.memo(function({onNew:e,newButtonLabel:t,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:v=!1,availableViewModes:b=["table","list","grid"],rightSlot:j,className:w}){const{t:N}=y.useTranslation(),_=c>0,C=e&&s||h.length>0,k=x||v||j,S=r&&o;return C||S||k||l&&_?a.jsxs("div",{className:Yt("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&s&&a.jsxs(Xt,{onClick:e,children:[a.jsx(d.Plus,{size:16,className:"mr-2"}),t||"Novo"]}),h.map((e,t)=>{const s=e.icon;return a.jsxs(Xt,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[s&&a.jsx(s,{size:16,className:"mr-2"}),e.label]},t)})]}),l&&_&&a.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[a.jsx(er,{variant:"secondary",className:"mr-1 tabular-nums",children:c}),a.jsxs(yr,{delayDuration:200,children:[u.length>0?u.map((e,t)=>{const s=e.icon,r=e.disabled;return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:r,onClick:()=>e.action([]),children:s?a.jsx(s,{size:16}):a.jsx("span",{className:"text-xs",children:e.label[0]})})}),a.jsx(Nr,{children:e.label})]},t)}):a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:a.jsx(d.Trash2,{size:16})})}),a.jsx(Nr,{children:N("ap_delete")})]}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:a.jsx(d.X,{size:16})})}),a.jsx(Nr,{children:N("clear_selection")})]})]})]}),S&&a.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:a.jsxs("div",{className:"relative w-full",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&a.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,v&&f&&g&&a.jsx(go,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:b.map(e=>{const t=(e=>{switch(e){case"table":return d.Table2;case"list":return d.List;case"grid":return d.LayoutGrid}})(e);return a.jsx(vo,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:a.jsx(t,{className:"h-4 w-4"})},e)})}),j]})]}):null}),yo=t.memo(({checked:e,onCheckedChange:t})=>a.jsx(Xs,{checked:e,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function jo(e){try{const a=localStorage.getItem(e);if(!a)return null;const t=JSON.parse(a);let s=t.groupByColumns||[];return 0===s.length&&t.groupByColumn&&(s=[t.groupByColumn]),{hiddenColumns:new Set(t.hiddenColumns||[]),columnOrder:t.columnOrder||[],groupByColumns:s}}catch{return null}}function wo({columns:e,storageKey:a,enabled:s=!0,defaultHiddenColumns:r}){const n=t.useMemo(()=>e.map(e=>String(e.key)),[e]),o=t.useMemo(()=>new Set(r??[]),[r]),[i,l]=t.useState(()=>{if(!s)return o;if(!a)return o;const e=jo(a);return e?.hiddenColumns??o}),[d,c]=t.useState(()=>{if(!s||!a)return n;const e=jo(a)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=t.useState(()=>s&&a?jo(a)?.groupByColumns??[]:[]),[p,h]=t.useState(new Set);t.useEffect(()=>{s&&a&&function(e,a){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(a.hiddenColumns),columnOrder:a.columnOrder,groupByColumns:a.groupByColumns}))}catch{}}(a,{hiddenColumns:i,columnOrder:d,groupByColumns:u})},[i,d,u,a,s]),t.useEffect(()=>{const a=new Set(e.map(e=>String(e.key))),t=new Set(d),s=[...a].filter(e=>!t.has(e));s.length>0&&c(e=>[...e.filter(e=>a.has(e)),...s])},[e]);const x=t.useCallback(e=>i.has(e),[i]),f=t.useCallback(e=>{l(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),g=t.useCallback(()=>{l(new Set)},[]),v=t.useCallback(()=>{if(l(o),c(n),m([]),h(new Set),a)try{localStorage.removeItem(a)}catch{}},[n,o,a]),b=t.useCallback((e,a)=>{c(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s})},[]),y=t.useCallback(e=>{h(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),j=t.useCallback(e=>{m(e),h(new Set)},[]),w=t.useCallback(e=>{m(a=>a.includes(e)?a:[...a,e])},[]),N=t.useCallback(e=>{m(a=>a.filter(a=>a!==e)),h(a=>{const t=new Set;for(const s of a)s.includes(`${e}:`)||t.add(s);return t})},[]),_=t.useCallback((e,a)=>{m(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s}),h(new Set)},[]),C=u[0]??null,k=t.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=t.useMemo(()=>{if(!s)return e;const a=new Map(e.map(e=>[String(e.key),e]));return d.filter(e=>!i.has(e)&&a.has(e)).map(e=>a.get(e))},[e,d,i,s]),T=t.useCallback(e=>{if(0===u.length)return[{groupKey:"__all__",groupValue:"",items:e,count:e.length,level:0}];return function e(a,t,s,r){if(0===t.length)return[{groupKey:r||"__leaf__",groupValue:"",items:a,count:a.length,level:s}];const[n,...o]=t,i=new Map;for(const l of a){const e=String(l[n]??"(vazio)");i.has(e)||i.set(e,[]),i.get(e).push(l)}return Array.from(i.entries()).map(([a,t])=>{const i=r?`${r}|${n}:${a}`:`${n}:${a}`,l=o.length>0?e(t,o,s+1,i):void 0;return{groupKey:i,groupValue:a,items:t,count:t.length,level:s,children:l}})}(e,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:v,columnOrder:d,reorderColumns:b,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:j,addGroupByColumn:w,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:T,collapsedGroups:p,toggleGroupCollapse:y}}function No({enabled:e=!1,onReorder:a}){const[s,r]=t.useState(null),[n,o]=t.useState(null),i=t.useCallback(()=>{r(null),o(null)},[]),l=t.useCallback((t,n)=>({draggable:e,onDragStart:a=>{e&&(r(t),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setData("text/plain",String(t)),n&&a.dataTransfer.setData("application/column-key",n))},onDragOver:a=>{e&&null!==s&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDragEnter:a=>{e&&null!==s&&(a.preventDefault(),o(t))},onDrop:r=>{r.preventDefault(),e&&null!==s&&s!==t?(a(s,t),i()):i()},onDragEnd:()=>{i()}}),[e,s,a,i]);return t.useMemo(()=>({dragFromIndex:s,dragOverIndex:n,isDragging:null!==s,getDragProps:l}),[s,n,l])}function _o({columns:e,columnOrder:s,isColumnHidden:r,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:c,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=y.useTranslation(),[f,g]=t.useState(null),[v,b]=t.useState(null),j=t.useRef(null),w=new Map(e.map(e=>[String(e.key),e])),N=s.filter(e=>w.has(e)).map(e=>w.get(e)),_=()=>{j.current=null,g(null),b(null)};N.some(e=>r(String(e.key)));const C=N.every(e=>!r(String(e.key)));return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"icon",className:"h-8 w-8",children:a.jsx(d.Columns3,{size:16})})}),a.jsxs(Sr,{className:"w-[260px] p-0",align:"end",children:[a.jsx("div",{className:"px-3 py-2 border-b",children:a.jsx("span",{className:"text-sm font-medium",children:"Colunas"})}),a.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:a.jsx(yr,{delayDuration:300,children:N.map((e,t)=>{const s=String(e.key),o=r(s),h=!1!==e.hideable,y=!0===e.groupable,w=u.includes(s)||l===s;return a.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{j.current=e,g(e)})(t),onDragOver:e=>((e,a)=>{e.preventDefault(),b(a)})(e,t),onDrop:()=>(e=>{null!==j.current&&j.current!==e&&i(j.current,e),j.current=null,g(null),b(null)})(t),onDragEnd:_,className:Yt("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===t&&"opacity-50",v===t&&"border-t-2 border-primary"),children:[a.jsx(d.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),a.jsx(Xs,{checked:!o,onCheckedChange:()=>h&&n(s),disabled:!h,className:"shrink-0"}),a.jsx("span",{className:Yt("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),y&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Yt("h-6 w-6 shrink-0",w&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),w?p?p(s):c?.(null):m?m(s):c?.(s)},children:a.jsx(d.Group,{size:14})})}),a.jsx(Nr,{children:x(w?"remove_grouping":"group_by_column")})]})]},s)})})}),a.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:C?()=>N.filter(e=>!1!==e.hideable).forEach(e=>n(String(e.key))):o,children:x(C?"deselect_all":"select_all_columns")}),h&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:"Redefinir padrão"})]})]})]})}function Co({columns:e,groupByColumns:s,addGroupByColumn:r,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=t.useState(!1),[c,u]=t.useState(null),[m,p]=t.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=s.length>0;return a.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",l(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{e.preventDefault(),l(!1);if(Array.from(e.dataTransfer.types).includes("application/group-chip-index"))return;const a=e.dataTransfer.getData("application/column-key");if(a&&!s.includes(a)){const e=h.get(a);e&&e.groupable&&r(a)}},className:Yt("flex items-center gap-2 px-4 py-2 min-h-[40px] border-b transition-colors",i&&"bg-primary/5 border-primary/30",!f&&"text-muted-foreground"),children:[a.jsx(d.Group,{size:14,className:"shrink-0 text-muted-foreground"}),a.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?s.map((e,s)=>{const r=h.get(e);if(!r)return null;const i=c===s,l=m===s&&c!==s;return a.jsxs(t.Fragment,{children:[s>0&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),a.jsxs(er,{variant:"secondary",className:Yt("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"ring-2 ring-primary"),draggable:!0,onDragStart:e=>((e,a)=>{e.stopPropagation(),e.dataTransfer.setData("application/group-chip-index",String(a)),e.dataTransfer.effectAllowed="move",u(a)})(e,s),onDragOver:e=>((e,a)=>{e.preventDefault(),e.stopPropagation(),p(a)})(e,s),onDrop:e=>((e,a)=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer.getData("application/group-chip-index");if(""!==t){const e=parseInt(t,10);isNaN(e)||e===a||o(e,a)}u(null),p(null)})(e,s),onDragEnd:x,children:[r.header,a.jsx("button",{onClick:a=>{a.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:a.jsx(d.X,{size:12})})]})]},e)}):a.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const ko=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:v,showActionBar:b=!0,showSearch:j=!1,searchValue:w,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D=!1,enableColumnResize:E=!0,resizeStorageKey:A,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:F,enableGrouping:R=!1,enableExpandableRows:L=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:V=!1,hideActionsColumn:B=!1})=>{const{t:q}=y.useTranslation(),{setSearchVisible:$}=Pn(),W=An(),[H,G]=t.useState(()=>V&&L?new Set(s.entities.map(e=>e.id)):new Set),Y=void 0!==U,K=Y?new Set(U):H,Q=t.useCallback(e=>{Y&&O?O(e):G(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[Y,O]),X=void 0!==v?!v:b;t.useEffect(()=>{if(!j)return $(!0),()=>$(!1)},[$,j]);const J=wo({columns:r,storageKey:M,enabled:I,defaultHiddenColumns:F}),Z=No({enabled:I,onReorder:J.reorderColumns}),ee=I?J.visibleColumns:r,{columnWidths:ae,isDragging:te,activeColumn:se,handleMouseDown:re}=po({columns:ee.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:E}),ne=t.useMemo(()=>(()=>{if(E){const e=ee.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return ee.map((t,s)=>({...t,calculatedWidth:e[s],style:{width:e[s]/a*100+"%"}}))}let e=0;const a=ee.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[ee,E,ae]),oe=h||g.length>0||j||m||S||D||I,ie=X&&oe,le=k||(()=>{s.bulkDelete?.(s.selectedIds)}),de=e=>a.jsx(Un,{className:"text-center",children:c?c(e):"inline"===p?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:a.jsx(uo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}),ce=e=>a.jsx(ao,{className:"w-[160px]",children:a.jsx(lo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:u?u(e):[],renderAs:"context"})}),ue=I?a.jsx(_o,{columns:r,columnOrder:J.columnOrder,isColumnHidden:J.isColumnHidden,toggleColumn:J.toggleColumn,showAllColumns:J.showAllColumns,resetColumns:J.resetColumns,reorderColumns:J.reorderColumns,groupByColumn:R?J.groupByColumn:void 0,setGroupByColumn:R?J.setGroupByColumn:void 0,groupByColumns:R?J.groupByColumns:void 0,addGroupByColumn:R?J.addGroupByColumn:void 0,removeGroupByColumn:R?J.removeGroupByColumn:void 0}):void 0;if(W)return s.isLoading?a.jsx(Bn,{count:3}):0===s.entities.length?a.jsx($n,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(bo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:j,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),a.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:s.entities.map(e=>a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:a.jsx(ts,{className:Yt("overflow-hidden cursor-pointer hover:bg-muted/50",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:a.jsx(os,{className:"p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[m&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1",children:[ee.map(t=>a.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||c)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):a.jsx(co,{onEdit:n?()=>{n(e)}:void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})})]})]})})})}),ce(e)]},e.id))})]});const me=R&&J.groupByColumns.length>0?J.getGroupedData(s.entities):null,pe=null!==me,he=(L?1:0)+(m?1:0)+ee.length+(B?0:1),xe=e=>{const r=L&&K.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:a.jsxs(Ln,{className:Yt("cursor-pointer hover:bg-muted/50 relative",("inline"===p||B)&&"group",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:[L&&a.jsx(Un,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),Q(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":q(r?"collapse_row":"expand_row"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&a.jsx(Un,{onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),ee.map(t=>a.jsx(Un,{className:t.className,children:a.jsx(Wn,{children:t.render?t.render(e):String(e[t.key]??"")})},String(t.key))),!B&&de(e)]})}),ce(e)]}),r&&z&&a.jsx(Ln,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Un,{colSpan:he,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},fe=(e,s)=>{const{t:r}=y.useTranslation();return e.map(e=>{const r=J.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return a.jsxs(t.Fragment,{children:[a.jsx(Ln,{className:Yt("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>J.toggleGroupCollapse(e.groupKey),children:a.jsx(Un,{colSpan:s,className:"py-2 px-4",children:a.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[r?a.jsx(d.ChevronRight,{size:16}):a.jsx(d.ChevronDown,{size:16}),a.jsx("span",{children:e.groupValue}),a.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!r&&(e.children?fe(e.children,s):e.items.map(xe))]},e.groupKey)})};return a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(bo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:j,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:D}),s.isLoading?a.jsx(Vn,{rows:5,columns:ee.length}):a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[R&&a.jsx(Co,{columns:r,groupByColumns:J.groupByColumns,addGroupByColumn:J.addGroupByColumn,removeGroupByColumn:J.removeGroupByColumn,reorderGroupByColumns:J.reorderGroupByColumns}),a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs(In,{className:"table-fixed w-full",children:[a.jsxs("colgroup",{children:[L&&a.jsx("col",{style:{width:"40px"}}),m&&a.jsx("col",{style:{width:"50px"}}),ne.map((e,t)=>a.jsx("col",{style:e.style},t)),!B&&a.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),a.jsx(Mn,{children:a.jsxs(Ln,{children:[L&&a.jsx(zn,{className:"w-[40px]"}),m&&a.jsx(zn,{className:"w-[50px]",children:a.jsx(yo,{checked:s.isAllSelected,onCheckedChange:s.selectAll})}),ee.map((e,t)=>{const r=E&&!1!==e.resizable,n=se===String(e.key),o=I?Z.getDragProps(t,String(e.key)):{},i=Z.dragFromIndex===t,l=Z.dragOverIndex===t&&Z.dragFromIndex!==t;return a.jsxs(zn,{className:Yt(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&Z.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>s.handleSort(String(e.key)):void 0,...o,children:[a.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(c=String(e.key),s.sortField!==c?null:"asc"===s.sortDirection?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),r&&a.jsx(Hn,{direction:"horizontal",onMouseDown:a=>re(String(e.key),a),isDragging:n})]},String(e.key));var c}),!B&&a.jsx(zn,{className:"w-[50px] text-center",children:ue||e.t("actions")})]})}),a.jsx(Fn,{children:0===s.entities.length?a.jsx(Ln,{children:a.jsx(Un,{colSpan:he,className:"h-32",children:a.jsx($n,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):pe?fe(me,he):s.entities.map(xe)})]})})]})]})};function So(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,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},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 a=m(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{t.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:i,updateField:(e,a)=>{o(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),i[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const To=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Po=({value:e="#3b82f6",onChange:t,label:s,customColorLabel:r,presetColorsLabel:n})=>{const{t:o}=y.useTranslation(),i=r??o("custom_color"),l=n??o("preset_colors");return a.jsxs("div",{className:"space-y-2",children:[s&&a.jsx(as,{children:s}),a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[a.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),a.jsx(Sr,{className:"w-64",children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx(as,{htmlFor:"color-input",children:i}),a.jsx(Zt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),a.jsxs("div",{children:[a.jsx(as,{children:l}),a.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:To.map(e=>a.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]})},Do=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(xe.Root,{ref:r,className:Yt("relative overflow-hidden",e),...s,children:[a.jsx(xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(Eo,{}),a.jsx(xe.Corner,{})]}));Do.displayName=xe.Root.displayName;const Eo=ae.forwardRef(({className:e,orientation:t="vertical",...s},r)=>a.jsx(xe.ScrollAreaScrollbar,{ref:r,orientation:t,className:Yt("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...s,children:a.jsx(xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Eo.displayName=xe.ScrollAreaScrollbar.displayName;const Ao=[{name:"alarm",filled:!1},{name:"account_box",filled:!0},{name:"announcement",filled:!0},{name:"assessment",filled:!0},{name:"assignment",filled:!0},{name:"bookmark",filled:!0},{name:"build",filled:!0},{name:"change_history",filled:!1},{name:"credit_card",filled:!1},{name:"date_range",filled:!0},{name:"extension",filled:!0},{name:"face",filled:!0},{name:"favorite",filled:!0},{name:"store",filled:!0},{name:"group_work",filled:!0},{name:"home",filled:!0},{name:"label",filled:!0},{name:"lightbulb_2",filled:!1},{name:"list",filled:!0},{name:"line_weight",filled:!0},{name:"question_answer",filled:!0},{name:"mode_heat",filled:!0},{name:"reorder",filled:!0},{name:"warning",filled:!0},{name:"room",filled:!0},{name:"settings",filled:!0},{name:"shopping_cart",filled:!0},{name:"work",filled:!0},{name:"star_rate",filled:!0},{name:"monetization_on",filled:!0},{name:"view_list",filled:!0},{name:"visibility",filled:!0},{name:"error",filled:!0},{name:"equalizer",filled:!0},{name:"release_alert",filled:!0},{name:"mic",filled:!0},{name:"videocam",filled:!0},{name:"call",filled:!0},{name:"chat",filled:!0},{name:"chat_bubble",filled:!0},{name:"email",filled:!0},{name:"link",filled:!0},{name:"report",filled:!0},{name:"flag",filled:!0},{name:"attach_file",filled:!0},{name:"attachment",filled:!0},{name:"attach_money",filled:!0},{name:"bubble_chart",filled:!0},{name:"folder",filled:!0},{name:"business",filled:!0},{name:"device_hub",filled:!0},{name:"flash_on",filled:!0},{name:"image",filled:!0},{name:"lens",filled:!0},{name:"photo_camera",filled:!0},{name:"style",filled:!0},{name:"view_compact",filled:!0},{name:"wb_incandescent",filled:!0},{name:"directions_bus",filled:!0},{name:"directions_car",filled:!0},{name:"flight",filled:!0},{name:"hotel",filled:!0},{name:"local_offer",filled:!0},{name:"restaurant",filled:!0},{name:"restaurant_menu",filled:!0},{name:"local_shipping",filled:!0},{name:"all_inclusive",filled:!0},{name:"business_center",filled:!0},{name:"notifications",filled:!0},{name:"share",filled:!0}];function Io({name:e,filled:t,className:s}){return a.jsx("span",{className:`material-symbols-outlined ${s??""}`,style:t?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Mo=({value:e=null,onChange:s,label:r,noIconLabel:n="SEM ÍCONE"})=>{const[o,i]=t.useState(!1),l=e?(c=e,Ao.find(e=>e.name===c)):null;var c;const u=e=>{s?.(e),i(!1)};return a.jsxs("div",{className:"space-y-2",children:[r&&a.jsx(as,{children:r}),a.jsxs(Cr,{open:o,onOpenChange:i,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"justify-start text-left font-normal gap-2",children:[l?a.jsx(Io,{name:l.name,filled:l.filled,className:"text-xl text-muted-foreground"}):a.jsx("span",{className:"text-muted-foreground text-sm",children:n}),a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),a.jsx(Sr,{className:"w-72 p-3",align:"start",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Do,{className:"h-64",children:a.jsx("div",{className:"grid grid-cols-7 gap-1",children:Ao.map(t=>a.jsx("button",{type:"button",className:"flex items-center justify-center p-1.5 rounded hover:bg-accent transition-colors "+(e===t.name?"bg-primary/10 text-primary":"text-muted-foreground"),onClick:()=>u(t.name),title:t.name,children:a.jsx(Io,{name:t.name,filled:t.filled,className:"text-2xl"})},t.name))})}),a.jsx("button",{type:"button",className:"w-full py-2 text-sm font-semibold text-foreground hover:bg-accent rounded transition-colors border-t pt-3",onClick:()=>u(null),children:n})]})})]})]})},Fo=ae.forwardRef(({className:e,...t},s)=>a.jsx(fe.Root,{className:Yt("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",e),...t,ref:s,children:a.jsx(fe.Thumb,{className:Yt("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")})}));Fo.displayName=fe.Root.displayName;const Ro=(e={})=>{const{user:a,alias:t}=Pn(),{enabled:s=!0,status:r="active"}=e;return w.useQuery({queryKey:["qualiex-users",t,r],queryFn:()=>mn.getUsers(t,r),enabled:s&&!!t&&!!a,staleTime:3e5,retry:2,retryDelay:1e3})},Lo=({value:s,onChange:r,multiple:n=!1,label:o,required:i,placeholder:l,icon:d,maxDisplayedBadges:c,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:v,onOpen:b,onClose:j})=>{const{t:w}=y.useTranslation(),{data:N=[],isLoading:_,error:C}=Ro({enabled:p}),[k,S]=t.useState(new Map),T=t.useMemo(()=>s?Array.isArray(s)?s.filter(Boolean):[s].filter(Boolean):[],[s]),P=t.useMemo(()=>{if(0===T.length||0===N.length)return"";const e=new Set(N.map(e=>e.userId||e.id||""));return T.filter(a=>a&&!e.has(a)&&!k.has(a)).sort().join(",")},[T,N,k]);t.useEffect(()=>{if(!P)return;const e=P.split(",");let a=!1;const t=an.extractTokenData();return t?.alias&&t?.companyId?(mn.fetchUsers(t.alias,t.companyId,"all").then(t=>{a||S(a=>{const s=new Map(a);for(const r of e){const e=t.find(e=>e.userId===r||e.id===r);e&&s.set(r,{...e,isActive:e.isActive??!1})}return s})}).catch(()=>{}),()=>{a=!0}):void 0},[P]);const D=t.useMemo(()=>f?N.filter(f):N,[N,f]),E=t.useMemo(()=>{if(0===T.length)return D;const a=new Set(D.map(e=>e.userId||e.id||"")),t=T.filter(e=>e&&!a.has(e));if(0===t.length)return D;const s=t.map(a=>{const t=k.get(a);return t||{userId:a,id:a,userName:e.t("inactive_user"),userEmail:"",isActive:!1}});return[...D,...s]},[D,T,k]),A=t.useCallback(a=>{let t;if("custom"===h&&x)t=x(a);else{const e=a.userName||"";switch(h){case"name-email":t=a.userEmail?`${e} (${a.userEmail})`:e;break;case"name-role":t=a.roleName?`${e} - ${a.roleName}`:e;break;default:t=e}}return!1===a.isActive?`${t} (${e.t("inactive")})`:t},[h,x]);return a.jsx(Ur,{multiple:n,value:s??(n?[]:""),onChange:r,options:E,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:A,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:w("no_results"),label:o,required:i,icon:d,maxDisplayedBadges:c,disabled:m,className:u,sortOptions:g,popoverContainer:v,onOpen:b,onClose:j})};function zo({title:e,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,x]=t.useState(null),f=t.useCallback(e=>{p.current=e,x(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:v,errors:b,updateField:y,handleSubmit:j}=So(g,r,void 0,i),w=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(v):e.disabled||!1})):[],[s,v]),N=t.useMemo(()=>{const e=w.find(e=>e.id===u);if(e&&!e.disabled)return u;const a=w.find(e=>!e.disabled);return a?.id||u},[w,u]);t.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=w.find(e=>e.id===N),C=e=>{const t=(e.computedValue,v[e.name]),s=void 0!==t?t:"",r=b[e.name];switch(e.type){case"group":const t="horizontal"===e.layout,n=t?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=t?Yt("space-y-2 w-full",e.wrapperClassName):Yt("space-y-2",e.className,e.wrapperClassName);return a.jsxs("div",{className:o,children:[e.label,a.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Lo,{value:s||"",onChange:a=>y(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-destructive":""}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"textarea":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Js,{id:e.name,value:s||"",onChange:a=>{y(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Vs,{value:String(s),onValueChange:a=>{y(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[a.jsx($s,{className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options?.map(e=>a.jsx(Ks,{value:e.value,children:e.label},e.value))})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"multiselect":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Ur,{options:e.options||[],value:Array.isArray(s)?s:[],onChange:a=>y(e.name,a),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"date":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"date",value:String(s),onChange:a=>y(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Yt("w-full",r?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"color":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"color",value:s||e.defaultValue||"#000000",onChange:a=>y(e.name,a.target.value),className:"h-10"}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Po,{value:s||e.defaultValue||"#3b82f6",onChange:a=>y(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Mo,{value:s||e.defaultValue||null,onChange:a=>y(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(v):e.componentProps||{};return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(i,{value:s,onChange:a=>{y(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,error:r,popoverContainer:h,...l}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"number":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"number",value:null!=s?String(s):"",onChange:a=>{const t=a.target.value,s=""===t?null:Number(t);y(e.name,s)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"checkbox":return a.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[a.jsx(Xs,{id:e.name,checked:!!s,onCheckedChange:a=>y(e.name,a),disabled:e.disabled}),a.jsxs(as,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"switch":return a.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Fo,{id:e.name,checked:!!s,onCheckedChange:a=>y(e.name,a),disabled:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},e.name);default:return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"text",value:s||"",onChange:a=>{y(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name)}},k=t.useCallback(()=>{if(!_)return null;if(_.disabled)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:a.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),a.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Complete as informações obrigatórias na seção i18n.t('ap_general_info') para acessar esta seção."})]});if(_.component){const e=_.component;return a.jsx(e,{formData:v,updateField:y,errors:b,users:c,disabled:_.disabled})}return a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,v,y,b,c,C]),S=a.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[w.length>1&&a.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:a.jsx("div",{className:"flex space-x-2",children:w.map(e=>a.jsx(Xt,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=w.find(a=>a.id===e);a&&!a.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):a.jsxs("form",{onSubmit:j(n),className:"space-y-3 md:space-y-4",children:[k(),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Xt,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return a.jsx(ys,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:a.jsxs(ks,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a.jsxs(Ss,{showSeparator:!0,children:[a.jsx(Ds,{children:e}),a.jsx(Es,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Uo({currentPage:e,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=y.useTranslation();if(0===s)return null;const c=(e-1)*r+1,u=Math.min(e*r,s);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),a.jsxs(Vs,{value:String(r),onValueChange:e=>o(Number(e)),children:[a.jsx($s,{className:"h-8 w-[70px]",children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"10",children:"10"}),a.jsx(Ks,{value:"25",children:"25"}),a.jsx(Ks,{value:"50",children:"50"}),a.jsx(Ks,{value:"100",children:"100"})]})]})]})}),a.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",l("of","de")," ",s," ",l("items","itens")]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsLeft,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronLeft,{size:16})}),a.jsxs("div",{className:"flex items-center gap-1 px-2",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),a.jsx("span",{className:"text-sm font-medium",children:t})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronRight,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsRight,{size:16})})]})]})}function Oo({manager:e}){return a.jsx(Uo,{currentPage:e.pagination.currentPage,totalPages:e.pagination.totalPages,totalItems:e.pagination.totalItems,itemsPerPage:e.pagination.itemsPerPage,onPageChange:e.handlePageChange,onItemsPerPageChange:e.handleItemsPerPageChange,variant:"full"})}const Vo={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Bo={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},qo={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function $o({children:e,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return a.jsx("div",{className:Yt("flex","column"===t?"flex-col":"flex-row",Vo[s],Bo[r],qo[n],o&&"flex-wrap",i),children:e})}function Wo({manager:e,filters:t,inline:s=!1}){const{t:r}=y.useTranslation(),{isSearchVisible:n}=Pn(),o=e.searchTerm,i=a.jsxs(a.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:e.searchTerm,onChange:a=>e.handleSearch(a.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>a.jsxs(Vs,{value:e.value||"",onValueChange:a=>e.onChange?.(a),children:[a.jsx($s,{className:"w-[180px]",children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options.map(e=>a.jsx(Ks,{value:e.value,children:e.label},e.value))})]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return a.jsx("div",{className:s?"":"w-full sm:w-auto",children:a.jsx(r,{...e.props})},`custom-${t}`)}),o&&a.jsxs(Xt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[a.jsx(d.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?a.jsx("div",{className:"flex items-center gap-2",children:i}):a.jsx($o,{direction:"column",gap:"md",className:"mb-6",children:a.jsx($o,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function Ho({manager:e,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=Pn(),[d,c]=N.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[x,f]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,v]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&e){const a=`${e.queryKey}_sortField`,t=`${e.queryKey}_sortDirection`;if(!d.has(a)&&!d.has(t)){const e=Object.fromEntries(d);e[a]=i.column,e[t]=i.direction,c(e)}}},[]);const b=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,y="function"==typeof e?.deleteEntity?e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,j=()=>{f({isOpen:!1,entityId:null,entityName:""})},w=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,_=(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 a.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&a.jsx(bo,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:w,showSearch:s.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:_,filters:s.filters&&s.filters.length>0?a.jsx(Wo,{manager:e,filters:s.filters,inline:!0}):void 0}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?a.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(e.entities,e)}):a.jsx(ko,{manager:e,columns:s.columns,onEdit:b,onDelete:y,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:s.defaultHiddenColumns})}),a.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:a.jsx(Oo,{manager:e})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&a.jsx(zo,{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:e.isLoading,submitButtonText:p?"Atualizar":"Criar"}),a.jsx(ys,{open:x.isOpen,onOpenChange:j,children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:x.entityName}),". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:j,children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{x.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(x.entityId),f({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),a.jsx(ys,{open:g.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Go(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function Yo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Ko(e={}){const{paramName:a="alias"}=e,s=N.useParams(),{alias:r,companies:n}=Pn(),o=s[a]||null;return t.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,a=!!e;return{urlAlias:o,isAliasMismatch:a&&o!==r,isValidAlias:a,isMissing:!1,matchedCompany:e}},[o,r,n])}const Qo=r.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"}}),Xo={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},Jo=ae.forwardRef(({className:e,variant:t="info",showIcon:s=!0,children:r,...n},o)=>{const i=Xo[t||"info"];return a.jsxs("div",{ref:o,role:"alert",className:Yt(Qo({variant:t}),e),...n,children:[s&&a.jsx(i,{className:"h-4 w-4"}),r]})});Jo.displayName="Alert";const Zo=ae.forwardRef(({className:e,...t},s)=>a.jsx("h5",{ref:s,className:Yt("mb-1 font-medium leading-none tracking-tight",e),...t}));Zo.displayName="AlertTitle";const ei=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("text-sm [&_p]:leading-relaxed",e),...t}));ei.displayName="AlertDescription";const ai=t.createContext(void 0);function ti({children:e,actions:s}){const{t:r}=y.useTranslation(),[n,o]=t.useState({}),[i,l]=t.useState(s);t.useEffect(()=>{l(s)},[s]);const d=t.useCallback(()=>o({}),[]),c=t.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:d,headerActions:i,setHeaderActions:l}),[n,d,i]);return a.jsx(ai.Provider,{value:c,children:e})}function si(){const e=t.useContext(ai);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var ri={actions:"Ações",activate:"Ativar",add_first_item:"Adicione seu primeiro item para começar",add_item:"Adicionar Item",advanced_filter:"Filtro avançado",all:"Todos",allow:"Permitir",allowed_items:"Itens permitidos",also_discover:"Conheça também",alt_text:"Texto Alternativo",anonymous:"Anônimo",ap_action_plan:"Plano de Ação",ap_action_type:"Tipo de Ação",ap_add:"Adicionar",ap_add_comment_placeholder:"Adicionar comentário...",ap_add_cost:"Adicionar custo",ap_add_predecessor:"Adicionar predecessor",ap_attachments:"Anexos",ap_belongs_to:"Pertence a",ap_cause:"Causa",ap_change_status:"Alterar Status",ap_checker:"Verificador",ap_clear:"Limpar",ap_comments:"Comentários",ap_cost_description:"Descrição do custo",ap_costs:"Custos",ap_delete:"Excluir",ap_description:"Descrição",ap_description_placeholder:"Descreva o plano de ação",ap_duration_days:"Duração (dias)",ap_edit_progress:"Editar Progresso",ap_end_date:"Data de Término",ap_estimated_cost:"Custo Estimado",ap_file_duplicate:"Arquivo duplicado",ap_file_upload_error:"Erro ao enviar arquivo",ap_general:"Geral",ap_general_info:"Informações Gerais",ap_history:"Histórico",ap_justification:"Justificativa",ap_justification_placeholder:"Justificativa do plano de ação",ap_name:"Nome",ap_new_action:"Nova Ação",ap_no_attachments:"Nenhum anexo",ap_no_comments:"Nenhum comentário",ap_no_costs:"Nenhum custo registrado",ap_no_history:"Nenhum registro no histórico",ap_no_predecessors:"Nenhum predecessor adicionado",ap_no_progress:"Sem dados de progresso disponíveis",ap_overall_progress:"Progresso geral",ap_place:"Local",ap_plan_name_placeholder:"Nome do plano de ação",ap_predecessors:"Predecessores",ap_priority:"Prioridade",ap_priority_high:"Alta",ap_priority_low:"Baixa",ap_priority_medium:"Média",ap_progress:"Progresso",ap_progress_comment_placeholder:"Adicione um comentário sobre o progresso",ap_progress_percent:"Progresso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progresso",ap_reporting:"Reportando...",ap_reports_history:"Histórico de reportes",ap_responsible:"Responsável",ap_select_action:"Selecione uma ação",ap_select_cause:"Selecione a causa",ap_select_checker:"Selecione o verificador",ap_select_date:"Selecione a data",ap_select_parent:"Selecione a ação pai",ap_select_place:"Selecione o local",ap_select_priority:"Selecione a prioridade",ap_select_responsible:"Selecione o responsável",ap_select_type:"Selecione o tipo",ap_start_date:"Data de Início",ap_status_canceled:"Cancelada",ap_status_done:"Concluída",ap_status_effectiveness_check:"Verificação de eficácia",ap_status_running:"Em andamento",ap_status_suspended:"Suspensa",ap_status_waiting_start:"Aguardando início",ap_time_label:"Tempo",ap_time_spent:"Tempo gasto (HH:MM)",ap_total_cost:"Custo total realizado",ap_total_time:"Tempo total",ap_type_corrective:"Corretiva",ap_type_immediate:"Imediata",ap_type_improvement:"Oportunidade de Melhoria",ap_type_preventive:"Preventiva",ap_type_standardization:"Padronização",ap_value:"Valor (R$)",ap_via_app:"Via app",approval_approve:"Aprovar",approval_execute_action:"Executar ação",approval_opinion:"Parecer *",approval_read_less:"Ler menos",approval_read_more:"Ler mais",approval_reprove_radio:"Reprovar e retornar para etapa",approval_search_approver:"Buscar aprovador...",approval_select_approver:"Selecionar aprovador",approval_select_approver_placeholder:"Selecione um aprovador...",approval_select_step:"Selecione a etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuários",audit_description:"Descrição",audit_esign:"Assinatura eletrônica",audit_not_informed:"Não informado",audit_references:"Referências",audit_security:"Segurança",audit_trail:"Trilha de Auditoria",auth_error:"Erro durante a autenticação. Tente novamente.",auth_failed:"Falha na autenticação. Tente novamente.",auto_login:"Fazendo login automático...",back:"Voltar",bulk_delete_error:"Erro ao excluir itens em lote",bulk_delete_success:"Itens excluídos com sucesso",cancel:"Cancelar",change_photo:"Trocar foto",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse_row:"Recolher linha",columns:"Colunas",conclude:"Concluir",confirm_removal:"Confirmar remoção",could_not_load_info:"Não foi possível carregar as informações",current:"Atual",custom_color:"Cor personalizada",dashboard_advanced_filter:"Filtro avançado",dashboard_all_access:"Todos os colaboradores terão acesso",dashboard_average:"Média",dashboard_code:"Código",dashboard_distinct_count:"Contagem distinta",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Sair do fullscreen",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabela",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Meus dashboards",dashboard_new:"Novo Dashboard",dashboard_no_data:"A consulta não retornou itens para o seu perfil.",dashboard_no_refresh:"Não atualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"Não compartilhado",dashboard_only_mine:"Somente meus",dashboard_only_overdue:"Somente atrasados",dashboard_only_responsible:"Somente o responsável terá acesso",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remover favorito",dashboard_responsible:"Responsável",dashboard_select_groups:"Selecione grupos, locais e colaboradores específicos",dashboard_shared_unit:"Compartilhado com todos os colaboradores da unidade",dashboard_status:"Situação",dashboard_title:"Título",dashboard_wait_refresh:"Aguarde para atualizar novamente",dashboard_work_done:"Trabalho executado",dashboard_work_planned:"Trabalho planejado",deactivate:"Inativar",deselect_all:"Deselecionar todas",dev_login:"Login Desenvolvimento",download:"Download",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nome",electronic_signature:"Assinatura Eletrônica",embed_code:"Código embed",embedded_content:"Embedded content",enter_code:"Digite o código",enter_password:"Digite sua senha",error_authentication:"Erro de Autenticação",error_connection:"Erro de Conexão",error_copied_clipboard:"Os detalhes do erro foram copiados para a área de transferência.",error_loading:"Erro ao carregar",error_loading_data:"Erro ao carregar dados",error_session_expired:"Sessão Expirada",error_token_expired:"Token de autenticação expirado. Faça login novamente.",esign_code_description:"Um código de verificação foi enviado para o seu e-mail. Insira o código abaixo para confirmar a operação.",esign_code_error:"Erro ao validar o código. Tente novamente.",esign_invalid_code:"Código inválido. Tente novamente.",esign_invalid_password:"Senha incorreta. Tente novamente.",esign_password_description:"Digite sua senha para confirmar a operação.",esign_password_error:"Erro ao validar a senha. Tente novamente.",esign_resend_error:"Erro ao reenviar o código.",expand_row:"Expandir linha",expiration_date:"Data de expiração",file_error:"Erro no arquivo",file_upload:"Upload de arquivo",go_to_next_page:"Ir para próxima página",go_to_previous_page:"Ir para página anterior",group_by_column:"Agrupar por esta coluna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descrição da imagem",import_flows:"Fluxos de Importação",import_manage:"Gerencie seus fluxos de importação",inactive:"inativo",inactive_user:"[Usuário inativo]",input_type:"Tipo de entrada",invalid_form:"Formulário inválido. Preencha todos os campos obrigatórios.",italic:"Itálico",item_details:"Detalhes do item",items:"itens",items_per_page:"Itens por página",know_saber_gestao:"Conheça o Saber Gestão",know_staff:"Conheça Staff",language:"Idioma",last_update:"Última atualização",leader:"Líder",leader_create_error:"Erro ao criar líder",leader_not_found:"Líder não encontrado",leader_promoted_success:"Líder promovido com sucesso",leader_remove_error:"Erro ao remover líder",leader_removed_success:"Líder removido com sucesso",leader_update_error:"Erro ao atualizar líder",leader_updated_success:"Líder atualizado com sucesso",leadership_add_root:"Adicionar Líder Raiz",leadership_add_subordinate:"Adicionar Liderado",leadership_cycle_error:"Esta associação criaria um ciclo na hierarquia",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Imediato",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_hierarchy:"Nenhuma hierarquia de liderança encontrada.",leadership_no_members:"Nenhum membro na equipe",leadership_no_user_selected:"Nenhum usuário selecionado",leadership_no_users_available:"Nenhum usuário disponível",leadership_no_users_found:"Nenhum usuário encontrado",leadership_remove_team:"Remover da equipe",leadership_select_subordinates:"Selecione pelo menos um liderado",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",mind_map_add_child:"Adicionar filho",mind_map_add_sibling:"Adicionar irmão",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar tudo",mind_map_delete_node:"Excluir nó",mind_map_expand_all:"Expandir tudo",mind_map_export_image:"Exportar como imagem",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar à tela",mind_map_redo:"Refazer",mind_map_undo:"Desfazer",mind_map_zoom_in:"Aproximar",mind_map_zoom_out:"Afastar",modules:"Módulos",more_options:"Mais opções",msg_create_error:"Erro ao criar registro",msg_created_success:"Registro criado com sucesso",msg_delete_error:"Erro ao excluir registro",msg_deleted_success:"Registro excluído com sucesso",msg_load_error:"Erro ao carregar dados",msg_update_error:"Erro ao atualizar registro",msg_updated_success:"Registro atualizado com sucesso",new_document:"Novo Documento",new_folder:"Nova Pasta",new_item:"Novo Item",next:"Próximo",no_access_page:"Parece que você não tem acesso a essa página",no_data_to_display:"Não há dados para exibir no momento.",no_errors_recorded:"Nenhum erro registrado",no_image_selected:"Nenhuma imagem selecionada",no_item_selected:"Nenhum item selecionado",no_items_found:"Nenhum item encontrado",no_items_found_empty:"Nenhum item encontrado",no_place_found:"Nenhum local encontrado",no_place_selected:"Sem local",no_products:"Sem produtos",no_reports_found:"Nenhum relatório encontrado",no_results:"Nenhum resultado encontrado",no_search_results:"Nenhum resultado para a busca",no_video_selected:"Nenhum vídeo selecionado",not_authenticated:"Não autenticado",not_available:"Não disponível",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Cole o código embed aqui",permissions:"Permissões",preset_colors:"Cores predefinidas",preview:"Visualizar",redirecting_auth:"Redirecionando para autenticação...",refresh_data:"Atualizar dados",remove:"Remover",remove_grouping:"Remover agrupamento",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",restricted_access:"Acesso restrito",rows_per_page:"Registros por página",save:"Salvar",save_as_draft:"Salvar como Rascunho",save_as_template:"Salvar como Modelo",saving:"Salvando...",search:"Pesquisar",search_placeholder:"Pesquisar...",search_report_placeholder:"Buscar relatório...",search_user_placeholder:"Buscar usuário...",select_all:"Selecionar todos",select_all_columns:"Selecionar todas",select_all_items:"Selecionar todos",select_at_least_one:"Selecione pelo menos um item",select_at_least_one_item:"Selecione ao menos um item",select_date:"Selecione uma data",select_file_format:"Selecione o formato do arquivo",select_items_to_add:"Selecione itens para adicionar...",select_placeholder:"Selecione...",selected:"Selecionados",session_expired:"Sua sessão expirou. Você será redirecionado para fazer login novamente.",sign_access_error:"Erro ao acessar serviço de assinatura",sign_api_key_info:"Informe a API Key do provedor de assinatura",sign_api_key_input:"Insira a API Key do provedor de assinatura",sign_api_key_placeholder:"Insira a chave de API",sign_api_key_required:"Chave de API obrigatória",sign_attempt:"Tentativa de assinatura",sign_auth_required:"Autenticação necessária para assinar",sign_click_to_select:"Clique para selecionar documento",sign_config_save_err:"Erro ao salvar configuração de assinatura",sign_config_save_error:"Erro ao salvar configuração de assinatura",sign_config_saved:"Configuração de assinatura salva",sign_config_saved_success:"Configuração de assinatura salva com sucesso",sign_configured:"Assinatura configurada",sign_configured_unit:"Assinatura digital configurada para esta unidade",sign_digital_config:"Configuração de Assinatura Digital",sign_doc_available:"Documento assinado disponível para download",sign_doc_load_error:"Erro ao carregar documento",sign_doc_process_error:"Erro ao processar documento",sign_doc_sent:"Documento enviado para assinatura",sign_download_signed:"Baixar documento assinado",sign_email_fallback:"E-mail de fallback para assinatura",sign_environment:"Ambiente de assinatura",sign_fetch_failed:"Falha ao buscar documento assinado",sign_file_not_allowed:"Extensão de arquivo não permitida",sign_file_type_not_allowed:"Tipo de arquivo não permitido",sign_incorrect_data:"O signatário reportou dados incorretos.",sign_login_required:"Login necessário para assinar",sign_login_to_sign:"Faça login para utilizar a assinatura digital.",sign_monthly_limit:"Limite mensal de assinaturas atingido",sign_no_access:"Não foi possível obter o acesso para assinatura. Tente novamente.",sign_not_configured:"Assinatura não configurada",sign_not_configured_unit:"Assinatura digital ainda não configurada para esta unidade",sign_preparing_doc:"Preparando documento para assinatura",sign_process_error:"Erro ao processar assinatura",sign_save_config:"Salvar configuração",sign_save_config_btn:"Salvar Configuração",sign_select_pdf:"Selecione um arquivo PDF",sign_sending_doc:"Enviando documento para assinatura",sign_signed_success:"Documento assinado com sucesso",sign_signer_unavailable:"Signer ID não disponível",sign_try_again:"Tentar novamente",sign_update_config:"Atualizar configuração",sign_update_config_btn:"Atualizar Configuração",sign_waiting_provider:"Aguardando provedor de assinatura",sign_widget_error:"Erro no widget de assinatura",something_went_wrong:"Algo deu errado",state:"Estado",status:"Status",status_completed:"Concluído",status_error:"Erro",status_expired:"Expirado",status_processing:"Processando",status_waiting:"Aguardando",steps:"Etapas",subordinates_add_error:"Erro ao adicionar subordinados",subordinates_added_success:"Subordinados adicionados com sucesso",subordinates_sync_error:"Erro ao sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados com sucesso",team_all_groups:"Todos os grupos",terms_confirm_reading:"Confirmar leitura",terms_confirmation_available:"Confirmação disponível em",terms_of_use:"Termos de Uso",terms_read_agree:"Li e concordo",terms_see_later:"Ver depois",terms_updated:"Termos de Uso Atualizados",terms_view:"Visualizar termo de uso",terms_view_short:"View term",try_adjust_search:"Tente ajustar sua busca",try_again:"Tentar Novamente",unit_not_selected:"Nenhuma unidade selecionada",unknown_error:"Erro desconhecido",unsaved_changes:"Alterações não salvas",unsaved_changes_description:"Existem alterações não salvas. Deseja sair sem salvar?",updates:"Atualizações",user:"Usuário",user_info:"Informações do Usuário",user_photo:"Foto do usuário",users_already_leaders:"Usuários já são líderes",verification_code:"Código de verificação",video:"Vídeo",video_title:"Título do vídeo",view_report:"Visualizar relatório",want_to_know_more:"Quero conhecer mais",write_content_here:"Escreva o conteúdo aqui..."},ni={actions:"Actions",activate:"Activate",add_first_item:"Add your first item to get started",add_item:"Add Item",advanced_filter:"Advanced filter",all:"All",allow:"Allow",allowed_items:"Allowed items",also_discover:"Also discover",alt_text:"Alternative Text",anonymous:"Anonymous",ap_action_plan:"Action Plan",ap_action_type:"Action type",ap_add:"Add",ap_add_comment_placeholder:"Add a comment...",ap_add_cost:"Add cost",ap_add_predecessor:"Add predecessor",ap_attachments:"Attachments",ap_belongs_to:"Belongs to",ap_cause:"Cause",ap_change_status:"Change Status",ap_checker:"Checker",ap_clear:"Clear",ap_comments:"Comments",ap_cost_description:"Cost description",ap_costs:"Costs",ap_delete:"Delete",ap_description:"Description",ap_description_placeholder:"Describe the action plan",ap_duration_days:"Duration (days)",ap_edit_progress:"Edit Progress",ap_end_date:"End date",ap_estimated_cost:"Estimated cost",ap_file_duplicate:"Duplicate file",ap_file_upload_error:"Error uploading file",ap_general:"General",ap_general_info:"General Information",ap_history:"History",ap_justification:"Justification",ap_justification_placeholder:"Action plan justification",ap_name:"Name",ap_new_action:"New Action",ap_no_attachments:"No attachments",ap_no_comments:"No comments",ap_no_costs:"No costs recorded",ap_no_history:"No history records",ap_no_predecessors:"No predecessors added",ap_no_progress:"No progress data available",ap_overall_progress:"Overall progress",ap_place:"Place",ap_plan_name_placeholder:"Action plan name",ap_predecessors:"Predecessors",ap_priority:"Priority",ap_priority_high:"High",ap_priority_low:"Low",ap_priority_medium:"Medium",ap_progress:"Progress",ap_progress_comment_placeholder:"Add a comment about the progress",ap_progress_percent:"Progress (%)",ap_report:"Report",ap_report_progress:"Report progress",ap_reporting:"Reporting...",ap_reports_history:"Reports history",ap_responsible:"Responsible",ap_select_action:"Select an action",ap_select_cause:"Select cause",ap_select_checker:"Select checker",ap_select_date:"Select date",ap_select_parent:"Select parent action",ap_select_place:"Select place",ap_select_priority:"Select priority",ap_select_responsible:"Select responsible",ap_select_type:"Select type",ap_start_date:"Start date",ap_status_canceled:"Canceled",ap_status_done:"Completed",ap_status_effectiveness_check:"Effectiveness check",ap_status_running:"In progress",ap_status_suspended:"Suspended",ap_status_waiting_start:"Waiting to start",ap_time_label:"Time",ap_time_spent:"Time spent (HH:MM)",ap_total_cost:"Total realized cost",ap_total_time:"Total time",ap_type_corrective:"Corrective",ap_type_immediate:"Immediate",ap_type_improvement:"Improvement Opportunity",ap_type_preventive:"Preventive",ap_type_standardization:"Standardization",ap_value:"Value",ap_via_app:"Via app",approval_approve:"Approve",approval_execute_action:"Execute action",approval_opinion:"Opinion *",approval_read_less:"Read less",approval_read_more:"Read more",approval_reprove_radio:"Reject and return to step",approval_search_approver:"Search approver...",approval_select_approver:"Select approver",approval_select_approver_placeholder:"Select an approver...",approval_select_step:"Select the step",approval_step_label:"Step",approval_user_group:"User group",audit_description:"Description",audit_esign:"Electronic signature",audit_not_informed:"Not informed",audit_references:"References",audit_security:"Security",audit_trail:"Audit Trail",auth_error:"Error during authentication. Try again.",auth_failed:"Authentication failed. Try again.",auto_login:"Logging in automatically...",back:"Back",bulk_delete_error:"Error deleting items in bulk",bulk_delete_success:"Items deleted successfully",cancel:"Cancel",change_photo:"Change photo",cannot_be_own_leader:"A leader cannot be their own superior",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",current:"Current",custom_color:"Custom color",dashboard_advanced_filter:"Advanced filter",dashboard_all_access:"All collaborators will have access",dashboard_average:"Average",dashboard_code:"Code",dashboard_distinct_count:"Distinct count",dashboard_edit:"Edit Dashboard",dashboard_exit_fullscreen:"Exit fullscreen",dashboard_export_chart:"Export chart",dashboard_export_table:"Export table",dashboard_max_value:"Maximum value",dashboard_min_value:"Minimum value",dashboard_my:"My dashboards",dashboard_new:"New Dashboard",dashboard_no_data:"The query returned no items for your profile.",dashboard_no_refresh:"Do not refresh",dashboard_normal_page:"Normal page",dashboard_not_shared:"Not shared",dashboard_only_mine:"Only mine",dashboard_only_overdue:"Only overdue",dashboard_only_responsible:"Only the responsible will have access",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remove favorite",dashboard_responsible:"Responsible",dashboard_select_groups:"Select groups, places and specific collaborators",dashboard_shared_unit:"Shared with all unit collaborators",dashboard_status:"Status",dashboard_title:"Title",dashboard_wait_refresh:"Wait to refresh again",dashboard_work_done:"Work done",dashboard_work_planned:"Work planned",deactivate:"Deactivate",deselect_all:"Deselect all",dev_login:"Development Login",download:"Download",edit:"Edit",edit_profile:"Edit Profile",edit_name:"Edit Name",electronic_signature:"Electronic Signature",embed_code:"Embed code",embedded_content:"Embedded content",enter_code:"Enter the code",enter_password:"Enter your password",error_authentication:"Authentication Error",error_connection:"Connection Error",error_copied_clipboard:"Error details were copied to the clipboard.",error_loading:"Error loading",error_loading_data:"Error loading data",error_session_expired:"Session Expired",error_token_expired:"Authentication token expired. Please log in again.",esign_code_description:"A verification code was sent to your email. Enter the code below to confirm the operation.",esign_code_error:"Error validating code. Try again.",esign_invalid_code:"Invalid code. Try again.",esign_invalid_password:"Incorrect password. Try again.",esign_password_description:"Enter your password to confirm the operation.",esign_password_error:"Error validating password. Try again.",esign_resend_error:"Error resending code.",expand_row:"Expand row",expiration_date:"Expiration date",file_error:"File error",file_upload:"File upload",go_to_next_page:"Go to next page",go_to_previous_page:"Go to previous page",group_by_column:"Group by this column",heading_1:"Heading 1",heading_2:"Heading 2",heading_3:"Heading 3",image_description:"Image description",import_flows:"Import Flows",import_manage:"Manage your import flows",inactive:"inactive",inactive_user:"[Inactive user]",input_type:"Input type",invalid_form:"Invalid form. Fill in all required fields.",italic:"Italic",item_details:"Item details",items:"items",items_per_page:"Items per page",know_saber_gestao:"Discover Saber Gestão",know_staff:"Discover Staff",language:"Language",last_update:"Last update",leader:"Leader",leader_create_error:"Error creating leader",leader_not_found:"Leader not found",leader_promoted_success:"Leader promoted successfully",leader_remove_error:"Error removing leader",leader_removed_success:"Leader removed successfully",leader_update_error:"Error updating leader",leader_updated_success:"Leader updated successfully",leadership_add_root:"Add Root Leader",leadership_add_subordinate:"Add Subordinate",leadership_cycle_error:"This association would create a cycle in the hierarchy",leadership_define_leader:"Define Leader",leadership_immediate_superior:"Immediate Superior",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_hierarchy:"No leadership hierarchy found.",leadership_no_members:"No team members",leadership_no_user_selected:"No user selected",leadership_no_users_available:"No users available",leadership_no_users_found:"No users found",leadership_remove_team:"Remove from team",leadership_select_subordinates:"Select at least one subordinate",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",mind_map_add_child:"Add child",mind_map_add_sibling:"Add sibling",mind_map_aria_label:"Mind map",mind_map_collapse_all:"Collapse all",mind_map_delete_node:"Delete node",mind_map_expand_all:"Expand all",mind_map_export_image:"Export as image",mind_map_export_json:"Export as JSON",mind_map_fit_to_screen:"Fit to screen",mind_map_redo:"Redo",mind_map_undo:"Undo",mind_map_zoom_in:"Zoom in",mind_map_zoom_out:"Zoom out",modules:"Modules",more_options:"More options",msg_create_error:"Error creating record",msg_created_success:"Record created successfully",msg_delete_error:"Error deleting record",msg_deleted_success:"Record deleted successfully",msg_load_error:"Error loading data",msg_update_error:"Error updating record",msg_updated_success:"Record updated successfully",new_document:"New Document",new_folder:"New Folder",new_item:"New Item",next:"Next",no_access_page:"It seems you don't have access to this page",no_data_to_display:"No data to display at this time.",no_errors_recorded:"No errors recorded",no_image_selected:"No image selected",no_item_selected:"No item selected",no_items_found:"No items found",no_items_found_empty:"No items found",no_place_found:"No place found",no_place_selected:"No place",no_products:"No products",no_reports_found:"No reports found",no_results:"No results found",no_search_results:"No results for the search",no_video_selected:"No video selected",not_authenticated:"Not authenticated",not_available:"Not available",of:"of",open_popover:"Open Popover",open_wiki:"Open Wiki",ordered_list:"Ordered List",page:"Page",paste_embed_code:"Paste the embed code here",permissions:"Permissions",preset_colors:"Preset colors",preview:"Preview",redirecting_auth:"Redirecting to authentication...",refresh_data:"Refresh data",remove:"Remove",remove_grouping:"Remove grouping",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",restricted_access:"Restricted access",rows_per_page:"Rows per page",save:"Save",save_as_draft:"Save as Draft",save_as_template:"Save as Template",saving:"Saving...",search:"Search",search_placeholder:"Search...",search_report_placeholder:"Search report...",search_user_placeholder:"Search user...",select_all:"Select all",select_all_columns:"Select all",select_all_items:"Select all",select_at_least_one:"Select at least one item",select_at_least_one_item:"Select at least one item",select_date:"Select a date",select_file_format:"Select the file format",select_items_to_add:"Select items to add...",select_placeholder:"Select...",selected:"Selected",session_expired:"Your session has expired. You will be redirected to log in again.",sign_access_error:"Error accessing signature service",sign_api_key_info:"Enter the signature provider API Key",sign_api_key_input:"Enter the signature provider API Key",sign_api_key_placeholder:"Enter API key",sign_api_key_required:"API key is required",sign_attempt:"Signature attempt",sign_auth_required:"Authentication required to sign",sign_click_to_select:"Click to select document",sign_config_save_err:"Error saving signature configuration",sign_config_save_error:"Error saving signature configuration",sign_config_saved:"Signature configuration saved",sign_config_saved_success:"Signature configuration saved successfully",sign_configured:"Signature configured",sign_configured_unit:"Digital signature configured for this unit",sign_digital_config:"Digital Signature Configuration",sign_doc_available:"Signed document available for download",sign_doc_load_error:"Error loading document",sign_doc_process_error:"Error processing document",sign_doc_sent:"Document sent for signature",sign_download_signed:"Download signed document",sign_email_fallback:"Signature fallback email",sign_environment:"Signature environment",sign_fetch_failed:"Failed to fetch signed document",sign_file_not_allowed:"File extension not allowed",sign_file_type_not_allowed:"File type not allowed",sign_incorrect_data:"The signer reported incorrect data.",sign_login_required:"Login required to sign",sign_login_to_sign:"Log in to use the digital signature.",sign_monthly_limit:"Monthly signature limit reached",sign_no_access:"Could not obtain access for signing. Try again.",sign_not_configured:"Signature not configured",sign_not_configured_unit:"Digital signature not yet configured for this unit",sign_preparing_doc:"Preparing document for signature",sign_process_error:"Error processing signature",sign_save_config:"Save configuration",sign_save_config_btn:"Save Configuration",sign_select_pdf:"Select a PDF file",sign_sending_doc:"Sending document for signature",sign_signed_success:"Document signed successfully",sign_signer_unavailable:"Signer ID not available",sign_try_again:"Try again",sign_update_config:"Update configuration",sign_update_config_btn:"Update Configuration",sign_waiting_provider:"Waiting for signature provider",sign_widget_error:"Signature widget error",something_went_wrong:"Something went wrong",state:"State",status:"Status",status_completed:"Completed",status_error:"Error",status_expired:"Expired",status_processing:"Processing",status_waiting:"Waiting",steps:"Steps",subordinates_add_error:"Error adding subordinates",subordinates_added_success:"Subordinates added successfully",subordinates_sync_error:"Error syncing subordinates",subordinates_synced_success:"Subordinates synced successfully",team_all_groups:"All groups",terms_confirm_reading:"Confirm reading",terms_confirmation_available:"Confirmation available at",terms_of_use:"Terms of Use",terms_read_agree:"I have read and agree",terms_see_later:"See later",terms_updated:"Terms of Use Updated",terms_view:"View terms of use",terms_view_short:"View term",try_adjust_search:"Try adjusting your search",try_again:"Try Again",unit_not_selected:"No unit selected",unknown_error:"Unknown error",unsaved_changes:"Unsaved changes",unsaved_changes_description:"There are unsaved changes. Do you want to leave without saving?",updates:"Updates",user:"User",user_info:"User Information",user_photo:"User photo",users_already_leaders:"Users are already leaders",verification_code:"Verification code",video:"Video",video_title:"Video title",view_report:"View report",want_to_know_more:"I want to know more",write_content_here:"Write content here..."},oi={actions:"Acciones",activate:"Activar",add_first_item:"Agregue su primer elemento para comenzar",add_item:"Agregar Elemento",advanced_filter:"Filtro avanzado",all:"Todos",allow:"Permitir",allowed_items:"Elementos permitidos",also_discover:"Conozca también",alt_text:"Texto Alternativo",anonymous:"Anónimo",ap_action_plan:"Plan de Acción",ap_action_type:"Tipo de acción",ap_add:"Agregar",ap_add_comment_placeholder:"Agregar comentario...",ap_add_cost:"Agregar costo",ap_add_predecessor:"Agregar predecesor",ap_attachments:"Anexos",ap_belongs_to:"Pertenece a",ap_cause:"Causa",ap_change_status:"Cambiar Estado",ap_checker:"Verificador",ap_clear:"Limpiar",ap_comments:"Comentarios",ap_cost_description:"Descripción del costo",ap_costs:"Costos",ap_delete:"Eliminar",ap_description:"Descripción",ap_description_placeholder:"Describa el plan de acción",ap_duration_days:"Duración (días)",ap_edit_progress:"Editar Progreso",ap_end_date:"Fecha de finalización",ap_estimated_cost:"Costo estimado",ap_file_duplicate:"Archivo duplicado",ap_file_upload_error:"Error al subir archivo",ap_general:"General",ap_general_info:"Información General",ap_history:"Historial",ap_justification:"Justificación",ap_justification_placeholder:"Justificación del plan de acción",ap_name:"Nombre",ap_new_action:"Nueva Acción",ap_no_attachments:"Sin anexos",ap_no_comments:"Sin comentarios",ap_no_costs:"Ningún costo registrado",ap_no_history:"Sin registros en el historial",ap_no_predecessors:"Sin predecesores agregados",ap_no_progress:"Sin datos de progreso disponibles",ap_overall_progress:"Progreso general",ap_place:"Lugar",ap_plan_name_placeholder:"Nombre del plan de acción",ap_predecessors:"Predecesores",ap_priority:"Prioridad",ap_priority_high:"Alta",ap_priority_low:"Baja",ap_priority_medium:"Media",ap_progress:"Progreso",ap_progress_comment_placeholder:"Agregue un comentario sobre el progreso",ap_progress_percent:"Progreso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progreso",ap_reporting:"Reportando...",ap_reports_history:"Historial de reportes",ap_responsible:"Responsable",ap_select_action:"Seleccione una acción",ap_select_cause:"Seleccione la causa",ap_select_checker:"Seleccione el verificador",ap_select_date:"Seleccione la fecha",ap_select_parent:"Seleccione la acción padre",ap_select_place:"Seleccione el lugar",ap_select_priority:"Seleccione la prioridad",ap_select_responsible:"Seleccione el responsable",ap_select_type:"Seleccione el tipo",ap_start_date:"Fecha de inicio",ap_status_canceled:"Cancelada",ap_status_done:"Completada",ap_status_effectiveness_check:"Verificación de eficacia",ap_status_running:"En progreso",ap_status_suspended:"Suspendida",ap_status_waiting_start:"Esperando inicio",ap_time_label:"Tiempo",ap_time_spent:"Tiempo dedicado (HH:MM)",ap_total_cost:"Costo total realizado",ap_total_time:"Tiempo total",ap_type_corrective:"Correctiva",ap_type_immediate:"Inmediata",ap_type_improvement:"Oportunidad de Mejora",ap_type_preventive:"Preventiva",ap_type_standardization:"Estandarización",ap_value:"Valor",ap_via_app:"Vía app",approval_approve:"Aprobar",approval_execute_action:"Ejecutar acción",approval_opinion:"Opinión *",approval_read_less:"Leer menos",approval_read_more:"Leer más",approval_reprove_radio:"Rechazar y retornar a etapa",approval_search_approver:"Buscar aprobador...",approval_select_approver:"Seleccionar aprobador",approval_select_approver_placeholder:"Seleccione un aprobador...",approval_select_step:"Seleccione la etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuarios",audit_description:"Descripción",audit_esign:"Firma electrónica",audit_not_informed:"No informado",audit_references:"Referencias",audit_security:"Seguridad",audit_trail:"Pista de Auditoría",auth_error:"Error durante la autenticación. Intente de nuevo.",auth_failed:"Fallo en la autenticación. Intente de nuevo.",auto_login:"Iniciando sesión automáticamente...",back:"Volver",bulk_delete_error:"Error al eliminar elementos en lote",bulk_delete_success:"Elementos eliminados exitosamente",cancel:"Cancelar",change_photo:"Cambiar foto",cannot_be_own_leader:"Un líder no puede ser su propio superior",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",current:"Actual",custom_color:"Color personalizado",dashboard_advanced_filter:"Filtro avanzado",dashboard_all_access:"Todos los colaboradores tendrán acceso",dashboard_average:"Promedio",dashboard_code:"Código",dashboard_distinct_count:"Conteo distinto",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Salir de pantalla completa",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabla",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Mis dashboards",dashboard_new:"Nuevo Dashboard",dashboard_no_data:"La consulta no devolvió elementos para su perfil.",dashboard_no_refresh:"No actualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"No compartido",dashboard_only_mine:"Solo míos",dashboard_only_overdue:"Solo atrasados",dashboard_only_responsible:"Solo el responsable tendrá acceso",dashboard_open_query:"Abrir consulta",dashboard_remove_favorite:"Quitar favorito",dashboard_responsible:"Responsable",dashboard_select_groups:"Seleccione grupos, lugares y colaboradores específicos",dashboard_shared_unit:"Compartido con todos los colaboradores de la unidad",dashboard_status:"Situación",dashboard_title:"Título",dashboard_wait_refresh:"Espere para actualizar nuevamente",dashboard_work_done:"Trabajo ejecutado",dashboard_work_planned:"Trabajo planificado",deactivate:"Desactivar",deselect_all:"Deseleccionar todas",dev_login:"Login Desarrollo",download:"Descargar",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nombre",electronic_signature:"Firma Electrónica",embed_code:"Código embed",embedded_content:"Contenido embebido",enter_code:"Ingrese el código",enter_password:"Ingrese su contraseña",error_authentication:"Error de Autenticación",error_connection:"Error de Conexión",error_copied_clipboard:"Los detalles del error se copiaron al portapapeles.",error_loading:"Error al cargar",error_loading_data:"Error al cargar datos",error_session_expired:"Sesión Expirada",error_token_expired:"Token de autenticación expirado. Inicie sesión nuevamente.",esign_code_description:"Un código de verificación fue enviado a su correo. Ingrese el código a continuación para confirmar la operación.",esign_code_error:"Error al validar el código. Intente de nuevo.",esign_invalid_code:"Código inválido. Intente de nuevo.",esign_invalid_password:"Contraseña incorrecta. Intente de nuevo.",esign_password_description:"Ingrese su contraseña para confirmar la operación.",esign_password_error:"Error al validar la contraseña. Intente de nuevo.",esign_resend_error:"Error al reenviar el código.",expand_row:"Expandir fila",expiration_date:"Fecha de expiración",file_error:"Error en el archivo",file_upload:"Subir archivo",go_to_next_page:"Ir a la página siguiente",go_to_previous_page:"Ir a la página anterior",group_by_column:"Agrupar por esta columna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descripción de la imagen",import_flows:"Flujos de Importación",import_manage:"Gestione sus flujos de importación",inactive:"inactivo",inactive_user:"[Usuario inactivo]",input_type:"Tipo de entrada",invalid_form:"Formulario inválido. Complete todos los campos obligatorios.",italic:"Itálica",item_details:"Detalles del elemento",items:"elementos",items_per_page:"Elementos por página",know_saber_gestao:"Conozca Saber Gestión",know_staff:"Conozca Staff",language:"Idioma",last_update:"Última actualización",leader:"Líder",leader_create_error:"Error al crear líder",leader_not_found:"Líder no encontrado",leader_promoted_success:"Líder promovido exitosamente",leader_remove_error:"Error al eliminar líder",leader_removed_success:"Líder eliminado exitosamente",leader_update_error:"Error al actualizar líder",leader_updated_success:"Líder actualizado exitosamente",leadership_add_root:"Agregar Líder Raíz",leadership_add_subordinate:"Agregar Subordinado",leadership_cycle_error:"Esta asociación crearía un ciclo en la jerarquía",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Inmediato",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_hierarchy:"No se encontró jerarquía de liderazgo.",leadership_no_members:"Ningún miembro en el equipo",leadership_no_user_selected:"Ningún usuario seleccionado",leadership_no_users_available:"Ningún usuario disponible",leadership_no_users_found:"Ningún usuario encontrado",leadership_remove_team:"Quitar del equipo",leadership_select_subordinates:"Seleccione al menos un subordinado",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",mind_map_add_child:"Agregar hijo",mind_map_add_sibling:"Agregar hermano",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar todo",mind_map_delete_node:"Eliminar nodo",mind_map_expand_all:"Expandir todo",mind_map_export_image:"Exportar como imagen",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar a la pantalla",mind_map_redo:"Rehacer",mind_map_undo:"Deshacer",mind_map_zoom_in:"Acercar",mind_map_zoom_out:"Alejar",modules:"Módulos",more_options:"Más opciones",msg_create_error:"Error al crear registro",msg_created_success:"Registro creado exitosamente",msg_delete_error:"Error al eliminar registro",msg_deleted_success:"Registro eliminado exitosamente",msg_load_error:"Error al cargar datos",msg_update_error:"Error al actualizar registro",msg_updated_success:"Registro actualizado exitosamente",new_document:"Nuevo Documento",new_folder:"Nueva Carpeta",new_item:"Nuevo Elemento",next:"Siguiente",no_access_page:"Parece que no tienes acceso a esta página",no_data_to_display:"No hay datos para mostrar en este momento.",no_errors_recorded:"Sin errores registrados",no_image_selected:"Ninguna imagen seleccionada",no_item_selected:"Ningún elemento seleccionado",no_items_found:"No se encontraron elementos",no_items_found_empty:"Ningún elemento encontrado",no_place_found:"Ningún lugar encontrado",no_place_selected:"Sin lugar",no_products:"Sin productos",no_reports_found:"Ningún informe encontrado",no_results:"No se encontraron resultados",no_search_results:"Sin resultados para la búsqueda",no_video_selected:"Ningún vídeo seleccionado",not_authenticated:"No autenticado",not_available:"No disponible",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Pegue el código embed aquí",permissions:"Permisos",preset_colors:"Colores predefinidos",preview:"Vista previa",redirecting_auth:"Redirigiendo a autenticación...",refresh_data:"Actualizar datos",remove:"Eliminar",remove_grouping:"Quitar agrupación",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",restricted_access:"Acceso restringido",rows_per_page:"Registros por página",save:"Guardar",save_as_draft:"Guardar como Borrador",save_as_template:"Guardar como Plantilla",saving:"Guardando...",search:"Buscar",search_placeholder:"Buscar...",search_report_placeholder:"Buscar informe...",search_user_placeholder:"Buscar usuario...",select_all:"Seleccionar todo",select_all_columns:"Seleccionar todas",select_all_items:"Seleccionar todos",select_at_least_one:"Seleccione al menos un elemento",select_at_least_one_item:"Seleccione al menos un elemento",select_date:"Seleccione una fecha",select_file_format:"Seleccione el formato del archivo",select_items_to_add:"Seleccione elementos para agregar...",select_placeholder:"Seleccionar...",selected:"Seleccionados",session_expired:"Su sesión ha expirado. Será redirigido para iniciar sesión nuevamente.",sign_access_error:"Error al acceder al servicio de firma",sign_api_key_info:"Ingrese la API Key del proveedor de firma",sign_api_key_input:"Ingrese la API Key del proveedor de firma",sign_api_key_placeholder:"Ingrese la clave de API",sign_api_key_required:"Clave de API obligatoria",sign_attempt:"Intento de firma",sign_auth_required:"Autenticación requerida para firmar",sign_click_to_select:"Haga clic para seleccionar documento",sign_config_save_err:"Error al guardar configuración de firma",sign_config_save_error:"Error al guardar configuración de firma",sign_config_saved:"Configuración de firma guardada",sign_config_saved_success:"Configuración de firma guardada exitosamente",sign_configured:"Firma configurada",sign_configured_unit:"Firma digital configurada para esta unidad",sign_digital_config:"Configuración de Firma Digital",sign_doc_available:"Documento firmado disponible para descarga",sign_doc_load_error:"Error al cargar documento",sign_doc_process_error:"Error al procesar documento",sign_doc_sent:"Documento enviado para firma",sign_download_signed:"Descargar documento firmado",sign_email_fallback:"Correo de respaldo para firma",sign_environment:"Ambiente de firma",sign_fetch_failed:"Error al obtener documento firmado",sign_file_not_allowed:"Extensión de archivo no permitida",sign_file_type_not_allowed:"Tipo de archivo no permitido",sign_incorrect_data:"El firmante reportó datos incorrectos.",sign_login_required:"Inicio de sesión requerido para firmar",sign_login_to_sign:"Inicie sesión para usar la firma digital.",sign_monthly_limit:"Límite mensual de firmas alcanzado",sign_no_access:"No se pudo obtener acceso para firma. Intente de nuevo.",sign_not_configured:"Firma no configurada",sign_not_configured_unit:"Firma digital aún no configurada para esta unidad",sign_preparing_doc:"Preparando documento para firma",sign_process_error:"Error al procesar firma",sign_save_config:"Guardar configuración",sign_save_config_btn:"Guardar Configuración",sign_select_pdf:"Seleccione un archivo PDF",sign_sending_doc:"Enviando documento para firma",sign_signed_success:"Documento firmado exitosamente",sign_signer_unavailable:"ID del firmante no disponible",sign_try_again:"Intentar de nuevo",sign_update_config:"Actualizar configuración",sign_update_config_btn:"Actualizar Configuración",sign_waiting_provider:"Esperando proveedor de firma",sign_widget_error:"Error en el widget de firma",something_went_wrong:"Algo salió mal",state:"Estado",status:"Estado",status_completed:"Completado",status_error:"Error",status_expired:"Expirado",status_processing:"Procesando",status_waiting:"Esperando",steps:"Etapas",subordinates_add_error:"Error al agregar subordinados",subordinates_added_success:"Subordinados agregados exitosamente",subordinates_sync_error:"Error al sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados exitosamente",team_all_groups:"Todos los grupos",terms_confirm_reading:"Confirmar lectura",terms_confirmation_available:"Confirmación disponible en",terms_of_use:"Términos de Uso",terms_read_agree:"He leído y acepto",terms_see_later:"Ver después",terms_updated:"Términos de Uso Actualizados",terms_view:"Ver términos de uso",terms_view_short:"Ver término",try_adjust_search:"Intente ajustar su búsqueda",try_again:"Intentar de Nuevo",unit_not_selected:"Ninguna unidad seleccionada",unknown_error:"Error desconocido",unsaved_changes:"Cambios sin guardar",unsaved_changes_description:"Hay cambios sin guardar. ¿Desea salir sin guardar?",updates:"Actualizaciones",user:"Usuario",user_info:"Información del Usuario",user_photo:"Foto del usuario",users_already_leaders:"Los usuarios ya son líderes",verification_code:"Código de verificación",video:"Video",video_title:"Título del vídeo",view_report:"Ver informe",want_to_know_more:"Quiero conocer más",write_content_here:"Escriba el contenido aquí..."};const ii="true"===(void 0).VITE_I18N_DEBUG_MODE;function li(a,t){e.addResourceBundle(a,"app",t,!0,!0)}ii&&e.use({type:"postProcessor",name:"debugKeys",process:(e,a)=>`🔑 ${Array.isArray(a)?a[0]:a}`}),e.use(y.initReactI18next).init({resources:{"pt-BR":{core:ri},"en-US":{core:ni},"es-ES":{core:oi}},fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"app",fallbackNS:"core",ns:["core"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e,postProcess:ii?["debugKeys"]:[]});const di=t.createContext(void 0),ci={locale:At,timezone:Mt,datetimeFormat:It},ui=async()=>{},mi=({children:e})=>a.jsx(di.Provider,{value:{...ci,setLocale:ui,setTimezone:ui,setDatetimeFormat:ui,isLoading:!1},children:e}),pi=()=>{const e=t.useContext(di);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},hi=t.createContext({moduleAlias:null});function xi({moduleAlias:e=null,children:t}){return a.jsx(hi.Provider,{value:{moduleAlias:e},children:t})}function fi(){return t.useContext(hi)}const gi=ge.Root,vi=ge.CollapsibleTrigger,bi=ge.CollapsibleContent;class yi extends t.Component{constructor(a){super(a),this.copyErrorDetails=()=>{const a=tn.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||e.t("unknown_error")}\n\nStack Trace:\n${this.state.error?.stack||e.t("not_available")}\n\n=== ÚLTIMOS ERROS ===\n${a.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(t),l.toast.success("Detalhes copiados!",{description:e.t("error_copied_clipboard")})},this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if((void 0).DEV)throw e;tn.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=tn.getErrors().slice(0,2);return a.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:a.jsxs(ts,{className:"w-full max-w-2xl",children:[a.jsxs(ss,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),a.jsx(rs,{children:e.t("something_went_wrong")})]}),a.jsxs(os,{className:"space-y-4",children:[a.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a.jsxs(gi,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[a.jsx(vi,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a.jsxs(bi,{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a.jsxs("div",{className:"text-sm space-y-2",children:[a.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&a.jsx(Do,{className:"h-32 w-full rounded border bg-muted p-2",children:a.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a.jsxs("div",{className:"pt-3 border-t",children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),a.jsx("div",{className:"space-y-2",children:t.map((e,t)=>a.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),a.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),a.jsxs(Xt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),a.jsx(Xt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const ji=ve.Root,wi=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.List,{ref:s,className:Yt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));wi.displayName=ve.List.displayName;const Ni=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.Trigger,{ref:s,className:Yt("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",e),...t}));Ni.displayName=ve.Trigger.displayName;const _i=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.Content,{ref:s,className:Yt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function Ci({className:e}){return a.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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 ki({className:e}){return a.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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"})]})}_i.displayName=ve.Content.displayName;const Si={init(e){!function(e){try{return void function(e,a,t,s,r,n,o){a.getElementById("clarity-script")||(e[t]=e[t]||function(){(e[t].q=e[t].q||[]).push(arguments)},(n=a.createElement(s)).async=1,n.src="https://www.clarity.ms/tag/"+r+"?ref=npm",n.id="clarity-script",(o=a.getElementsByTagName(s)[0]).parentNode.insertBefore(n,o))}(window,document,"clarity","script",e)}catch(a){return}}(e)},setTag(e,a){window.clarity("set",e,a)},identify(e,a,t,s){window.clarity("identify",e,a,t,s)},consent(e=!0){window.clarity("consent",e)},consentV2(e={ad_Storage:"granted",analytics_Storage:"granted"}){window.clarity("consentv2",e)},upgrade(e){window.clarity("upgrade",e)},event(e){window.clarity("event",e)}},Ti="forlogic_";function Pi(){return"undefined"!=typeof window&&"function"==typeof window.clarity}function Di(){return"undefined"!=typeof window&&"piggyback"===window.__forlogicClarityMode}function Ei(e){return Di()?`${Ti}${e}`:e}function Ai(e){return Di()?`${Ti}${e}`:e}function Ii(e){try{e()}catch(a){(void 0).DEV}}function Mi(e){for(const[a,t]of Object.entries(e))null!=t&&""!==t&&Si.setTag(Ai(a),t)}function Fi({module:e,isContracted:a,sourceModule:t,alias:s}){Pi()&&Ii(()=>{Mi({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:String(a),source_module:t,alias:s}),Si.event(Ei("module_menu_click"))})}function Ri({module:e,sourceModule:a,alias:t}){Pi()&&Ii(()=>{Mi({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:"false",source_module:a,alias:t}),Si.event(Ei("module_interest_click"))})}function Li({resource:e,sourceModule:a,alias:t}){Pi()&&Ii(()=>{Mi({footer_resource:e,source_module:a,alias:t}),Si.event(Ei("module_footer_click"))})}function zi({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:t="https://sabergestao.com.br/",wikiUrl:s,alias:r,sourceModule:n}){const{t:o}=y.useTranslation(),i=Gt(e||s||"https://educacao.sabergestao.com.br/{alias}/fe",r),l=e=>{Li({resource:e,sourceModule:n,alias:r})};return a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[a.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-white",children:o("learn_qualiex")}),a.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("educa"),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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(Ci,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:o("know_saber_gestao")}),a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("saber-gestao"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(ki,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),a.jsxs("a",{href:s||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",onClick:()=>l("wiki"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(d.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}const Ui=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",softwareAlias:"analysis",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",softwareAlias:"decisions",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",softwareAlias:"audit",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",softwareAlias:"common",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",softwareAlias:"docs",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",softwareAlias:"flow",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",softwareAlias:"suppliers",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",softwareAlias:"mapping",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",softwareAlias:"metrology",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",softwareAlias:"occurrences",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",softwareAlias:"okr",url:"https://okr.qualiex.com/{alias}"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",softwareAlias:"plans",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",softwareAlias:"suppliers-portal",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",softwareAlias:"risks",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",softwareAlias:"competencies",url:"https://competencias.sabergestao.com.br/{alias}"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br/{alias}"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br/{alias}"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br/{alias}"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br/{alias}"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",softwareAlias:"staff",url:"https://treinamentos.sabergestao.com.br/{alias}"}]},{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={alias}"},{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={alias}"},{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 Oi({module:e,onClick:t}){return a.jsxs("button",{type:"button",onClick:t,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[a.jsx("div",{className:Yt("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&a.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function Vi(e,a){if(0===e.length)return e;const t=Math.ceil(e.length/a),s=[];for(let r=0;r<t;r++)for(let n=0;n<a;n++){const a=n*t+r;a<e.length&&s.push(e[a])}return s}function Bi({modules:e,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):window.matchMedia("(min-width: 640px)").matches?a(2):a(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...e].sort((e,a)=>e.name.localeCompare(a.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=Vi(d,o),m=Vi(c,o),p=(e,a)=>{a?s?.(e):n?.(e)};return a.jsxs("div",{className:"space-y-6",children:[u.length>0&&a.jsx("section",{children:a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(e=>a.jsx(Oi,{module:e,onClick:()=>p(e,!0)},e.name))})}),m.length>0&&a.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(e=>a.jsx(Oi,{module:e,onClick:()=>p(e,!1)},e.name))})]})]})}function qi({onModuleClick:e,contractedModules:s,onModuleInterest:r,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:d,sourceModule:c}){const[u,m]=t.useState("qualiex"),p=e=>{Ri({module:e,sourceModule:c,alias:d}),window.open(n,"_blank","noopener,noreferrer"),r?.(e)};return a.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[a.jsxs(ji,{value:u,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[a.jsx(wi,{className:"w-fit shrink-0",children:Ui.map(e=>a.jsxs(Ni,{value:e.id,children:[e.label,a.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),Ui.map(t=>a.jsx(_i,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:a.jsx(Bi,{modules:t.modules,onModuleClick:a=>{return r=a,n=t.id,Fi({module:r,isContracted:"qualiex"!==n||!s||s.includes(r.name),sourceModule:c,alias:d}),void e?.(r);var r,n},contractedModules:"qualiex"===t.id?s:void 0,onModuleInterest:p})},t.id))]}),a.jsx(zi,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:d,sourceModule:c})]})}const $i={analysis:12,decisions:13,audit:1,common:0,competencies:23,performance:24,docs:17,education:25,flow:7,suppliers:15,"suppliers-portal":16,mapping:11,metrology:8,control:18,msa:21,occurrences:3,okr:26,pdi:27,plans:6,"strategy-extension":14,pulse:28,boards:10,risks:4,fmea:20,staff:19,"control-plan":22},Wi=6e5;function Hi(e){const{moduleAlias:a}=fi(),{alias:s,user:r,isAuthenticated:n}=Pn(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:d=[],isLoading:c}=w.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>mn.fetchUserAssociations(i,s),enabled:l,staleTime:Wi,gcTime:12e5}),u=t.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),m=t.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const a=$i[e];return void 0!==a&&u.softwares.includes(a)})},[u]);return{hasAccess:t.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&c,role:t.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}function Gi(e){const{association:a}=Hi();return t.useMemo(()=>{if(e)return e;if(!a?.softwares)return;const t=a.softwares,s=Ui.find(e=>"qualiex"===e.id);return s?s.modules.filter(e=>{if(!e.softwareAlias)return!1;const a=$i[e.softwareAlias];return void 0!==a&&t.includes(a)}).map(e=>e.name):void 0},[e,a])}function Yi({open:e,onOpenChange:t,onModuleClick:s,contractedModules:r,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:d}){const{alias:c}=Pn(),u=Gi(r);return a.jsx(ys,{open:e,onOpenChange:t,children:a.jsxs(ks,{size:"lg",className:"overflow-hidden flex flex-col",children:[a.jsx(Ss,{className:"sr-only",children:a.jsx(Ds,{children:"Módulos"})}),a.jsx(qi,{onModuleClick:e=>{s?s(e):e.url&&Ht(Gt(e.url,c||void 0))},contractedModules:u,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:c||void 0,sourceModule:d})]})})}function Ki({open:s,onOpenChange:r,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:c,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:v=!0,size:b="lg",children:j,sourceModule:w}){const{t:N}=y.useTranslation(),_=t.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(a=>e.set(a.alias,a));const a=Array.from(e.values()),t=a.find(e=>e.alias===m),s=a.filter(e=>e.alias!==m).sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"}));return t?[t,...s]:s},[u,m]);return a.jsx(ys,{open:s,onOpenChange:v?void 0:r,children:a.jsxs(ks,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:v?e=>e.preventDefault():void 0,onEscapeKeyDown:v?e=>e.preventDefault():void 0,children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[a.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[a.jsx(Ds,{children:N("no_access_page")}),a.jsx(Es,{children:"Selecione um módulo para continuar navegando!"})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.length>1&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[a.jsx(d.Building2,{className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),a.jsx(d.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),a.jsx(pr,{align:"end",className:"max-h-[300px] overflow-auto",children:_.map(e=>a.jsxs(hr,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&a.jsx(er,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-2",children:[a.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:a.jsx(d.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),a.jsx(d.ChevronDown,{className:"h-3 w-3"})]})}),a.jsxs(pr,{align:"end",children:[a.jsxs("div",{className:"px-2 py-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:h,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),j?a.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[a.jsx("div",{className:"flex-1",children:j}),a.jsx(zi,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]}):a.jsx(qi,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]})})}function Qi(e,a){const{t:t}=y.useTranslation();return a.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a)}function Xi({children:e,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:d,accessDeniedRoutes:c,sourceModule:u}){const{t:m}=y.useTranslation(),{hasAccess:p,isLoading:h,association:x}=Hi(),{user:f,alias:g,companies:v,isAuthenticated:b,isLoading:j,logout:w,switchUnit:N}=Pn(),_=Gi(s),C=t.useMemo(()=>v?.length?g&&v.find(e=>e.alias===g)||v[0]:null,[v,g]),k=t.useMemo(()=>v?.length?v.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[v]),S=t.useCallback(e=>{const a=v?.find(a=>a.alias===e.alias);if(!a)return;const{pathname:t,search:s,hash:r}=window.location;if(g){const e=t.split("/"),n=e.indexOf(g);if(n>=0)return e[n]=a.alias,void(window.location.href=e.join("/")+s+r)}N(a)},[g,N,v]),T=t.useCallback(e=>{r?r(e):e.url&&Ht(Gt(e.url,g||void 0))},[r,g]),P=t.useMemo(()=>{if(!c)return;const e=window.location.pathname,a=Object.keys(c).find(a=>Qi(e,[a]));return a?c[a]:void 0},[c]);return j||!b||d?.length&&Qi(window.location.pathname,d)?a.jsx(a.Fragment,{children:e}):h?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsx(tr,{size:"lg"})}):p?a.jsx(a.Fragment,{children:e}):a.jsx(Ki,{open:!0,onModuleClick:T,contractedModules:_,onModuleInterest:n,userName:f?.name,unitName:C?.name,units:k,currentAlias:g||void 0,onUnitChange:S,onLogout:w,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:u,blocking:!0,children:P})}let Ji=!1;function Zi(){if(Ji||"undefined"==typeof document)return;Ji=!0;for(const a of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=a,a.includes("gstatic")&&(e.crossOrigin="anonymous"),document.head.appendChild(e)}const e=["https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap","https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"];for(const a of e)if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=a,document.head.appendChild(e)}}function el({projectId:e,mode:a="auto"}){const{user:s,alias:r,isAuthenticated:n}=Pn();t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&e&&!ze()&&!window.__forlogicClarityOwned)if("function"!=typeof window.clarity)try{Si.init(e),window.__forlogicClarityOwned=!0,window.__forlogicClarityMode="owned"}catch(t){(void 0).DEV,window.__forlogicClarityMode="inactive"}else window.__forlogicClarityMode="piggyback"},[e,a]),t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&n&&s&&"function"==typeof window.clarity)try{const e=s.email||s.identifier||"anonymous";Si.identify(e,void 0,"modules-menu",s.name||void 0),r&&Si.setTag("alias",r),"boolean"==typeof s.isSysAdmin&&Si.setTag("isSysAdmin",String(s.isSysAdmin))}catch(e){(void 0).DEV}},[s,r,n,a])}function al({projectId:e,mode:a}){return el({projectId:e,mode:a}),null}const tl=be.Root,sl=ae.forwardRef(({className:e,...t},s)=>a.jsx(be.Item,{ref:s,className:Yt("border-b",e),...t}));sl.displayName="AccordionItem";const rl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Header,{className:"flex",children:a.jsxs(be.Trigger,{ref:r,className:Yt("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));rl.displayName=be.Trigger.displayName;const nl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:a.jsx("div",{className:Yt("pb-4 pt-0",e),children:t})}));nl.displayName=be.Content.displayName;const ol=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Root,{ref:s,className:Yt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));ol.displayName=ye.Root.displayName;const il=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Image,{ref:s,className:Yt("aspect-square h-full w-full",e),...t}));il.displayName=ye.Image.displayName;const ll=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Fallback,{ref:s,className:Yt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));ll.displayName=ye.Fallback.displayName;const dl=ae.forwardRef(({...e},t)=>a.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));dl.displayName="Breadcrumb";const cl=ae.forwardRef(({className:e,...t},s)=>a.jsx("ol",{ref:s,className:Yt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));cl.displayName="BreadcrumbList";const ul=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Yt("inline-flex items-center gap-1.5",e),...t}));ul.displayName="BreadcrumbItem";const ml=ae.forwardRef(({asChild:e,className:t,...r},n)=>{const o=e?s.Slot:"a";return a.jsx(o,{ref:n,className:Yt("transition-colors hover:text-foreground",t),...r})});ml.displayName="BreadcrumbLink";const pl=ae.forwardRef(({className:e,...t},s)=>a.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Yt("font-normal text-foreground",e),...t}));pl.displayName="BreadcrumbPage";const hl=({children:e,className:t,...s})=>a.jsx("li",{role:"presentation","aria-hidden":"true",className:Yt("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:e??a.jsx(d.ChevronRight,{})});hl.displayName="BreadcrumbSeparator";const xl=({className:e,...t})=>a.jsxs("span",{role:"presentation","aria-hidden":"true",className:Yt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Mais"})]});xl.displayName="BreadcrumbEllipsis";const fl=r.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"}}),gl=ae.forwardRef(({className:e,orientation:t,...s},r)=>a.jsx("div",{ref:r,className:Yt(fl({orientation:t}),e),...s}));function vl({className:e,classNames:t,showOutsideDays:s=!0,...r}){return a.jsx(I.DayPicker,{showOutsideDays:s,className:Yt("p-3 pointer-events-auto",e),locale:Tt,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:Yt(Qt({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Yt(Qt({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:Yt(Qt({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",...t},components:{Chevron:({orientation:e})=>"left"===e?a.jsx(d.ChevronLeft,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}gl.displayName="ButtonGroup",vl.displayName="Calendar";const bl={Root:function({children:e,className:t}){return a.jsx("div",{className:Yt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:s}){return a.jsx(ts,{className:Yt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:a.jsx(os,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:s}){return a.jsxs("div",{className:Yt("flex justify-between items-center text-sm",s),children:[a.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),a.jsx("span",{className:"text-foreground",children:t})]})}};function yl({date:e,onDateChange:t,placeholder:s,disabled:r=!1,className:n,disabledDates:o}){const{t:l}=y.useTranslation(),c=s??l("select_date");return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",disabled:r,className:Yt("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[a.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:Tt}):a.jsx("span",{children:c})]})}),a.jsx(Sr,{className:"w-auto p-0",align:"start",children:a.jsx(vl,{mode:"single",selected:e,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const jl=({shouldScaleBackground:e=!0,...t})=>a.jsx(M.Drawer.Root,{shouldScaleBackground:e,...t});jl.displayName="Drawer";const wl=M.Drawer.Trigger,Nl=M.Drawer.Portal,_l=M.Drawer.Close,Cl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Overlay,{ref:s,className:Yt("fixed inset-0 z-50 bg-black/80",e),...t}));Cl.displayName=M.Drawer.Overlay.displayName;const kl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(Nl,{children:[a.jsx(Cl,{}),a.jsxs(M.Drawer.Content,{ref:r,className:Yt("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...s,children:[a.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));kl.displayName="DrawerContent";const Sl=({className:e,...t})=>a.jsx("div",{className:Yt("grid gap-1.5 p-4 text-center sm:text-left",e),...t});Sl.displayName="DrawerHeader";const Tl=({className:e,...t})=>a.jsx("div",{className:Yt("mt-auto flex flex-col gap-2 p-4",e),...t});Tl.displayName="DrawerFooter";const Pl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Title,{ref:s,className:Yt("text-lg font-semibold leading-none tracking-tight",e),...t}));Pl.displayName=M.Drawer.Title.displayName;const Dl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Dl.displayName=M.Drawer.Description.displayName;const El={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))]"},Al={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Il=je.Root,Ml=je.Trigger,Fl=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,...r},n)=>a.jsx(je.Content,{ref:n,align:t,sideOffset:s,className:Yt("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",e),...r}));Fl.displayName=je.Content.displayName;const Rl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-slot":"input-group",className:Yt("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",e),...t}));Rl.displayName="InputGroup";const Ll=r.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"}}),zl=ae.forwardRef(({className:e,align:t,...s},r)=>a.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Yt(Ll({align:t}),e),...s}));zl.displayName="InputGroupAddon";const Ul=r.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"}}),Ol=ae.forwardRef(({className:e,size:t,variant:s="ghost",...r},n)=>a.jsx(Xt,{ref:n,"data-slot":"input-group-button",variant:s,className:Yt(Ul({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...r}));Ol.displayName="InputGroupButton";const Vl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-slot":"input-group-control",className:Yt("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Vl.displayName="InputGroupInput";const Bl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Js,{ref:s,"data-slot":"input-group-control",className:Yt("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Bl.displayName="InputGroupTextarea";const ql=ae.forwardRef(({className:e,...t},s)=>a.jsx("h1",{ref:s,className:Yt("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...t}));ql.displayName="H1";const $l=ae.forwardRef(({className:e,...t},s)=>a.jsx("h2",{ref:s,className:Yt("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...t}));$l.displayName="H2";const Wl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Yt("scroll-m-20 text-2xl font-semibold tracking-tight",e),...t}));Wl.displayName="H3";const Hl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h4",{ref:s,className:Yt("scroll-m-20 text-xl font-semibold tracking-tight",e),...t}));Hl.displayName="H4";const Gl=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("leading-7 [&:not(:first-child)]:mt-6",e),...t}));Gl.displayName="P";const Yl=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-xl text-muted-foreground",e),...t}));Yl.displayName="Lead";const Kl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Yt("text-lg font-semibold",e),...t}));Kl.displayName="Large";const Ql=ae.forwardRef(({className:e,...t},s)=>a.jsx("small",{ref:s,className:Yt("text-sm font-medium leading-none",e),...t}));Ql.displayName="Small";const Xl=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Xl.displayName="Muted";const Jl=ae.forwardRef(({className:e,...t},s)=>a.jsx("code",{ref:s,className:Yt("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...t}));Jl.displayName="InlineCode";const Zl=ae.forwardRef(({className:e,...t},s)=>a.jsx("blockquote",{ref:s,className:Yt("mt-6 border-l-2 pl-6 italic",e),...t}));Zl.displayName="Blockquote";const ed=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Yt("my-6 ml-6 list-disc [&>li]:mt-2",e),...t}));ed.displayName="List";const ad=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Root,{ref:r,className:Yt("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...s,children:[t,a.jsx(ld,{})]}));ad.displayName=we.Root.displayName;const td=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.List,{ref:s,className:Yt("group flex flex-1 list-none items-center justify-center space-x-1",e),...t}));td.displayName=we.List.displayName;const sd=we.Item,rd=r.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"),nd=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Trigger,{ref:r,className:Yt(rd(),"group",e),...s,children:[t," ",a.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));nd.displayName=we.Trigger.displayName;const od=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.Content,{ref:s,className:Yt("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 ",e),...t}));od.displayName=we.Content.displayName;const id=we.Link,ld=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:Yt("absolute left-0 top-full flex justify-center"),children:a.jsx(we.Viewport,{className:Yt("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)]",e),ref:s,...t})}));ld.displayName=we.Viewport.displayName;const dd=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.Indicator,{ref:s,className:Yt("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",e),...t,children:a.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));dd.displayName=we.Indicator.displayName;const cd=({className:e,...t})=>a.jsx("nav",{role:"navigation","aria-label":"pagination",className:Yt("mx-auto flex w-full justify-center",e),...t});cd.displayName="Pagination";const ud=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Yt("flex flex-row items-center gap-1",e),...t}));ud.displayName="PaginationContent";const md=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Yt("",e),...t}));md.displayName="PaginationItem";const pd=({className:e,isActive:t,size:s="icon",...r})=>a.jsx("a",{"aria-current":t?"page":void 0,className:Yt(Qt({variant:t?"outline":"ghost",size:s}),e),...r});pd.displayName="PaginationLink";const hd=({className:t,...s})=>a.jsxs(pd,{"aria-label":e.t("go_to_previous_page"),size:"default",className:Yt("gap-1 pl-2.5",t),...s,children:[a.jsx(d.ChevronLeft,{className:"h-4 w-4"}),a.jsx("span",{children:"Previous"})]});hd.displayName="PaginationPrevious";const xd=({className:t,...s})=>a.jsxs(pd,{"aria-label":e.t("go_to_next_page"),size:"default",className:Yt("gap-1 pr-2.5",t),...s,children:[a.jsx("span",{children:"Next"}),a.jsx(d.ChevronRight,{className:"h-4 w-4"})]});xd.displayName="PaginationNext";const fd=({className:e,...t})=>a.jsxs("span",{"aria-hidden":!0,className:Yt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"More pages"})]});fd.displayName="PaginationEllipsis";const gd=ae.forwardRef(({className:e,value:t,...s},r)=>a.jsx(Ne.Root,{ref:r,className:Yt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:a.jsx(Ne.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));gd.displayName=Ne.Root.displayName;const vd=ae.forwardRef(({className:e,...t},s)=>a.jsx(_e.Root,{className:Yt("grid gap-2",e),...t,ref:s}));vd.displayName=_e.Root.displayName;const bd=ae.forwardRef(({className:e,...t},s)=>a.jsx(_e.Item,{ref:s,className:Yt("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",e),...t,children:a.jsx(_e.Indicator,{className:"flex items-center justify-center",children:a.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));bd.displayName=_e.Item.displayName;const yd=Ce.Panel,jd=re.Root,wd=re.Trigger,Nd=re.Close,_d=re.Portal,Cd=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{className:Yt("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",e),...t,ref:s}));Cd.displayName=re.Overlay.displayName;const kd=r.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"}}),Sd=ae.forwardRef(({side:e="right",className:t,children:s,...r},n)=>a.jsxs(_d,{children:[a.jsx(Cd,{}),a.jsxs(re.Content,{ref:n,className:Yt(kd({side:e}),t),...r,children:[s,a.jsxs(re.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Sd.displayName=re.Content.displayName;const Td=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Yt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Td.displayName="SheetHeader";const Pd=({className:e,...t})=>a.jsx("div",{className:Yt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...t});Pd.displayName="SheetBody";const Dd=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Yt("flex flex-row justify-end gap-2",e),...s,children:t})]});Dd.displayName="SheetFooter";const Ed=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Yt("text-lg font-semibold text-foreground",e),...t}));Ed.displayName=re.Title.displayName;const Ad=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Yt("text-sm text-muted-foreground",e),...t}));Ad.displayName=re.Description.displayName;const Id="sidebar:state",Md=ae.createContext(null);function Fd(){const e=ae.useContext(Md);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Rd=ae.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=An(),[c,u]=ae.useState(!1),[m,p]=ae.useState(()=>{if("undefined"!=typeof window){const a=localStorage.getItem(Id);return null!==a?"true"===a:e}return e}),h=t??m,x=ae.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem(Id,String(a))},[s,h]),f=ae.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,x,u]);ae.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);const g=h?"expanded":"collapsed",v=ae.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:f}),[g,h,x,d,c,u,f]);return a.jsx(Md.Provider,{value:v,children:a.jsx(yr,{delayDuration:0,children:a.jsx("div",{className:Yt("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})})})});Rd.displayName="SidebarProvider";const Ld=ae.forwardRef(({side:e="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=Fd();return"none"===s?a.jsx("div",{className:Yt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?a.jsx(jd,{open:c,onOpenChange:u,...o,children:a.jsxs(Sd,{"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:e,children:[a.jsx(Ed,{className:"sr-only",children:"Menu de Navegação"}),a.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):a.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":e,children:[a.jsx("div",{className:Yt("duration-200 relative h-[calc(100svh-var(--header-height,0px))] w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),a.jsx("div",{className:Yt("duration-200 fixed z-30 hidden w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","top-[var(--header-height,0px)] h-[calc(100svh-var(--header-height,0px))]","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:a.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})})]})});Ld.displayName="Sidebar";const zd=ae.forwardRef(({className:e,onClick:t,...s},r)=>{const{toggleSidebar:n}=Fd();return a.jsxs(Xt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Yt("h-7 w-7",e),onClick:e=>{t?.(e),n()},...s,children:[a.jsx(d.PanelLeft,{}),a.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});zd.displayName="SidebarTrigger";const Ud=ae.forwardRef(({className:e,...t},s)=>{const{toggleSidebar:r}=Fd();return a.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Yt("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",e),...t})});Ud.displayName="SidebarRail";const Od=ae.forwardRef(({className:e,...t},s)=>a.jsx("main",{ref:s,className:Yt("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",e),...t}));Od.displayName="SidebarInset";const Vd=ae.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-sidebar":"input",className:Yt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Vd.displayName="SidebarInput";const Bd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"header",className:Yt("flex flex-col gap-2 p-2",e),...t}));Bd.displayName="SidebarHeader";const qd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"footer",className:Yt("flex flex-col gap-2 p-2",e),...t}));qd.displayName="SidebarFooter";const $d=ae.forwardRef(({className:e,...t},s)=>a.jsx(ls,{ref:s,"data-sidebar":"separator",className:Yt("mx-2 w-auto bg-sidebar-border",e),...t}));$d.displayName="SidebarSeparator";const Wd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"content",className:Yt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Wd.displayName="SidebarContent";const Hd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group",className:Yt("relative flex w-full min-w-0 flex-col p-2",e),...t}));Hd.displayName="SidebarGroup";const Gd=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"div";return a.jsx(o,{ref:n,"data-sidebar":"group-label",className:Yt("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",e),...r})});Gd.displayName="SidebarGroupLabel";const Yd=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"button";return a.jsx(o,{ref:n,"data-sidebar":"group-action",className:Yt("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",e),...r})});Yd.displayName="SidebarGroupAction";const Kd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group-content",className:Yt("w-full text-sm",e),...t}));Kd.displayName="SidebarGroupContent";const Qd=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu",className:Yt("flex w-full min-w-0 flex-col gap-1",e),...t}));Qd.displayName="SidebarMenu";const Xd=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Yt("group/menu-item relative",e),...t}));Xd.displayName="SidebarMenuItem";const Jd=r.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"}}),Zd=ae.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=e?s.Slot:"button",{isMobile:u,state:m}=Fd(),p=a.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":t,className:Yt(Jd({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:p}),a.jsx(Nr,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});Zd.displayName="SidebarMenuButton";const ec=ae.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...n},o)=>{const i=t?s.Slot:"button";return a.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Yt("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",e),...n})});ec.displayName="SidebarMenuAction";const ac=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Yt("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",e),...t}));ac.displayName="SidebarMenuBadge";const tc=ae.forwardRef(({className:e,showIcon:t=!1,...s},r)=>{const n=ae.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Yt("rounded-md h-8 flex gap-2 px-2 items-center",e),...s,children:[t&&a.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),a.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});tc.displayName="SidebarMenuSkeleton";const sc=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Yt("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",e),...t}));sc.displayName="SidebarMenuSub";const rc=ae.forwardRef(({...e},t)=>a.jsx("li",{ref:t,...e}));rc.displayName="SidebarMenuSubItem";const nc=ae.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:n,...o},i)=>{const l=e?s.Slot:"a";return a.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:Yt("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"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});nc.displayName="SidebarMenuSubButton";const oc=ae.forwardRef(({className:e,value:t,defaultValue:s,...r},n)=>{const o=t||s||[0];return a.jsxs(ke.Root,{ref:n,value:t,defaultValue:s,className:Yt("relative flex w-full touch-none select-none items-center",e),...r,children:[a.jsx(ke.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:a.jsx(ke.Range,{className:"absolute h-full bg-primary"})}),o.map((e,t)=>a.jsx(ke.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},t))]})});oc.displayName=ke.Root.displayName;const ic=Se.Menu,lc=Se.Group,dc=Se.Portal,cc=Se.Sub,uc=Se.RadioGroup,mc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Root,{ref:s,className:Yt("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...t}));mc.displayName=Se.Root.displayName;const pc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Trigger,{ref:s,className:Yt("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",e),...t}));pc.displayName=Se.Trigger.displayName;const hc=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(Se.SubTrigger,{ref:n,className:Yt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));hc.displayName=Se.SubTrigger.displayName;const xc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.SubContent,{ref:s,className:Yt("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",e),...t}));xc.displayName=Se.SubContent.displayName;const fc=ae.forwardRef(({className:e,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>a.jsx(Se.Portal,{children:a.jsx(Se.Content,{ref:o,align:t,alignOffset:s,sideOffset:r,className:Yt("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",e),...n})}));fc.displayName=Se.Content.displayName;const gc=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Item,{ref:r,className:Yt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));gc.displayName=Se.Item.displayName;const vc=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(Se.CheckboxItem,{ref:n,className:Yt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));vc.displayName=Se.CheckboxItem.displayName;const bc=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(Se.RadioItem,{ref:r,className:Yt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));bc.displayName=Se.RadioItem.displayName;const yc=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Label,{ref:r,className:Yt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));yc.displayName=Se.Label.displayName;const jc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Separator,{ref:s,className:Yt("-mx-1 my-1 h-px bg-muted",e),...t}));jc.displayName=Se.Separator.displayName;const wc=({className:e,...t})=>a.jsx("span",{className:Yt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});wc.displayname="MenubarShortcut";const Nc={light:"",dark:".dark"},_c=ae.createContext(null);function Cc(){const e=ae.useContext(_c);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const kc=ae.forwardRef(({id:e,className:t,children:s,config:r,...n},o)=>{const i=ae.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return a.jsx(_c.Provider,{value:{config:r},children:a.jsxs("div",{"data-chart":l,ref:o,className:Yt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",t),...n,children:[a.jsx(Sc,{id:l,config:r}),a.jsx(Te.ResponsiveContainer,{children:s})]})})});kc.displayName="Chart";const Sc=({id:e,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?a.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Nc).map(([a,t])=>`\n${t} [data-chart=${e}] {\n${s.map(([e,t])=>{const s=t.theme?.[a]||t.color;return s?` --color-${e}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Tc=Te.Tooltip,Pc=ae.forwardRef(({active:e,payload:t,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:x}=Cc(),f=ae.useMemo(()=>{if(n||!t?.length)return null;const[e]=t,s=Ac(x,e,`${p||e?.dataKey||e?.name||"value"}`),r=p||"string"!=typeof i?s?.label:x[i]?.label||i;return l?a.jsx("div",{className:Yt("font-medium",d),children:l(r,t)}):r?a.jsx("div",{className:Yt("font-medium",d),children:r}):null},[i,l,t,n,d,x,p]);if(!e||!t?.length)return null;const g=1===t.length&&"dot"!==r;return a.jsxs("div",{ref:h,className:Yt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:f,a.jsx("div",{className:"grid gap-1.5",children:t.map((e,t)=>{const s=`${m||e.name||e.dataKey||"value"}`,n=Ac(x,e,s),i=u||e.payload?.fill||e.color;return a.jsx("div",{className:Yt("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!==e?.value&&e.name?c(e.value,e.name,e,t,e.payload):a.jsxs(a.Fragment,{children:[n?.icon?a.jsx(n.icon,{}):!o&&a.jsx("div",{className:Yt("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}}),a.jsxs("div",{className:Yt("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[a.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,a.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&a.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||t)})})]})});Pc.displayName="ChartTooltip";const Dc=Te.Legend,Ec=ae.forwardRef(({className:e,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=Cc();return s?.length?a.jsx("div",{ref:o,className:Yt("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",e),children:s.map(e=>{const s=`${n||e.dataKey||"value"}`,r=Ac(i,e,s);return a.jsxs("div",{className:Yt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?a.jsx(r.icon,{}):a.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),r?.label]},e.value)})}):null});function Ac(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}Ec.displayName="ChartLegend";const Ic=({onClick:e,isActive:t,disabled:s,children:r,title:n})=>a.jsx("button",{type:"button",onClick:e,disabled:s,title:n,className:Yt("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),Mc=()=>a.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Fc({image:e,title:t,className:s}){return a.jsx("div",{className:Yt("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:e?a.jsx("img",{src:e,alt:t,className:"w-full h-full object-cover"}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Rc({steps:e,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const{t:o}=y.useTranslation(),i=e.length,l=(t+1)/i*100;return a.jsxs("div",{className:Yt("flex items-center gap-3",n),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",i,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:e.map((e,r)=>a.jsxs(hr,{onClick:()=>s(r),className:Yt(r===t&&"bg-accent"),children:[r+1,". ",e.title]},e.id))})]}),a.jsx(gd,{value:l,className:"w-32 h-2"})]})}function Lc({currentStepIndex:e,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:c}){const{t:u}=y.useTranslation(),m=0===e,p=e===t-1;return a.jsxs("div",{className:Yt("flex items-center gap-2",c),children:[!m&&a.jsxs(Xt,{variant:"outline",onClick:s,size:"sm",children:[a.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),a.jsxs(Xt,{onClick:p?n:r,size:"sm",children:[p?l:i,!p&&a.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const zc=ae.forwardRef(({open:t,onOpenChange:s,steps:r,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:c="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[v,b]=ae.useState(0),y=void 0!==h,j=y?h:v,w=ae.useCallback(e=>{y?x?.(e):b(e),o?.(e)},[y,x,o]);ae.useEffect(()=>{t||y||b(0)},[t,y]);const N=r[j],_=r.length;return N?a.jsx(ys,{open:t,onOpenChange:s,children:a.jsxs(ks,{ref:g,size:m,variant:"informative",className:Yt("p-0 gap-0 overflow-hidden",f),children:[a.jsxs(Ns,{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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Fechar"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx(Fc,{image:N.image,title:N.title}),a.jsx(Ds,{className:"text-xl font-semibold",children:N.title}),a.jsx(Es,{className:"text-muted-foreground",children:N.description})]})}),a.jsxs("div",{className:"flex-shrink-0",children:[a.jsx(ls,{}),a.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?a.jsx(Rc,{steps:r,currentStepIndex:j,onStepSelect:e=>{w(e)},stepLabel:u}):a.jsx("div",{}),a.jsx(Lc,{currentStepIndex:j,totalSteps:_,onBack:()=>{j>0&&w(j-1)},onNext:()=>{j<_-1&&w(j+1)},onComplete:()=>{n?.(),s(!1)},backButtonText:l,continueButtonText:i,finishButtonText:c})]})]})]})}):null});function Uc({label:e,onClick:t,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:c="end",className:u}){const{t:m}=y.useTranslation(),p=i||l;if(!(r.length>0))return a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:u,children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]});return a.jsxs("div",{className:Yt("inline-flex rounded-md shadow-sm",u),children:[a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:n,size:o,disabled:p,className:Yt("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":m("more_options"),children:a.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),a.jsx(pr,{align:c,className:"min-w-[160px]",children:r.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:Yt("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}var Oc;zc.displayName="OnboardingDialog",exports.ExportFormat=void 0,(Oc=exports.ExportFormat||(exports.ExportFormat={})).CSV="csv",Oc.PDF="pdf",Oc.XLSX="xlsx",Oc.PNG="png",Oc.JPEG="jpeg",Oc.SVG="svg";const Vc=[{value:exports.ExportFormat.CSV,label:"CSV",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.XLSX,label:"XLSX",icon:a.jsx(d.FileSpreadsheet,{className:"h-5 w-5"})}],Bc=[{value:exports.ExportFormat.PNG,label:"PNG",icon:a.jsx(d.Image,{className:"h-5 w-5"})},{value:exports.ExportFormat.JPEG,label:"JPEG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.SVG,label:"SVG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})}];const qc=t.forwardRef(({value:e,onChange:s,onTimeChange:r,label:n,error:o,format:i="24h",className:l,id:c,...u},m)=>{const p=c??ae.useId(),h=t.useCallback(e=>{const a=e.target.value;s?.(a),r?.(a)},[s,r]),x=t.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return a.jsxs("div",{className:Yt("grid gap-1.5",l),children:[n&&a.jsx(as,{htmlFor:p,children:n}),a.jsxs("div",{className:"relative",children:[a.jsx(Zt,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:Yt("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),a.jsx(d.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})});function $c({currentStep:e,totalSteps:t,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){ae.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:t},(e,a)=>a+1),c=a=>!(a<=e)&&(!!n&&!n(a));return a.jsxs("div",{className:Yt("flex items-center gap-3",o),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",t,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:l.map(t=>a.jsxs(hr,{onClick:()=>{var a;(a=t)<e?s(a):n&&!n(a)||s(a)},disabled:c(t),className:Yt("cursor-pointer",t===e&&"bg-muted font-medium",c(t)&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("span",{className:"mr-2 text-muted-foreground",children:[t,"."]}),r?.[t-1]||`Etapa ${t}`,t===e&&a.jsx(d.Check,{className:"h-4 w-4 ml-auto"})]},t))})]}),a.jsx(gd,{value:e/t*100,className:Yt("h-2",i)})]})}function Wc(e){const a=an.getAccessToken(),t={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},"un-alias":e};if(a)try{const e=JSON.parse(atob(a.split(".")[1]));e.sub&&(t["x-waf-rate"]=btoa(e.sub))}catch{}return t}async function Hc(e,a,t){let s=await fetch(e,a);if(401===s.status){if(await un.handleApiError({status:401})){const r={...a,headers:Wc(t)};s=await fetch(e,r)}}return s}function Gc(e){const[a,s]=t.useState([]),[r,n]=t.useState(0),[o,i]=t.useState(!1);t.useEffect(()=>{if(!e)return;let a=!1;const t=`${Oe().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const r=Wc(e),o=await Hc(t,{method:"GET",headers:r},e);if(!o.ok)return;const i=await o.json();!a&&i.data?.[0]&&(s(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(r){}finally{a||i(!1)}}(),()=>{a=!0}},[e]);const l=t.useCallback(async()=>{if(!e||r<=0||0===a.length)return;const t=a[0].id,s=`${Oe().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const a=Wc(e),r=JSON.stringify({id:t,idUpdateType:3});await Hc(s,{method:"POST",headers:a,body:r},e)}catch(o){}},[e,r,a]);return{updates:a,badgeCount:r,loading:o,markAsVisualized:l}}qc.displayName="Timepicker";const Yc=t.forwardRef(({updates:t,badgeCount:s,onOpen:r,onViewAll:n},o)=>{const i=void 0===t,l=Pn(),c=l?.alias??null,u=Gc(i?c:null),m=i?u.updates??[]:t,p=i?u.badgeCount??0:s??0,h=r??(i?u.markAsVisualized:void 0),x=n??(i&&c?()=>{const e=`https://apps4.qualiex.com/common/${c}/up/view`;window.open(e,"_blank","noopener,noreferrer")}:void 0);return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{ref:o,variant:"ghost",size:"sm",className:"relative h-9 w-9 p-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:h,title:e.t("updates"),children:[a.jsx(d.Coffee,{className:"h-7 w-7"}),p>0&&a.jsx("span",{className:"absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:p>99?"99+":p})]})}),a.jsxs(Sr,{align:"end",className:"w-80 p-0",children:[a.jsx("div",{className:"border-b border-border px-4 py-3",children:a.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),a.jsx("div",{className:"max-h-72 overflow-y-auto",children:m.length>0?a.jsx("ul",{className:"divide-y divide-border",children:m.map(e=>a.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:x,children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[a.jsx(d.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),a.jsx("div",{className:"border-t border-border px-4 py-2",children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:x,children:["Ver todas as atualizações",a.jsx(d.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});var Kc,Qc;Yc.displayName="UpdatesNotification",exports.FileViewerType=void 0,(Kc=exports.FileViewerType||(exports.FileViewerType={}))[Kc.none=0]="none",Kc[Kc.image=1]="image",Kc[Kc.video=2]="video",Kc[Kc.audio=3]="audio",Kc[Kc.wopi=4]="wopi",Kc[Kc.onlineEditor=5]="onlineEditor",Kc[Kc.report=6]="report",exports.FilePrintType=void 0,(Qc=exports.FilePrintType||(exports.FilePrintType={}))[Qc.SimplePrint=0]="SimplePrint",Qc[Qc.ManagedCopy=1]="ManagedCopy",Qc[Qc.NonManagedCopy=2]="NonManagedCopy";const Xc={".jpg":exports.FileViewerType.image,".jpeg":exports.FileViewerType.image,".png":exports.FileViewerType.image,".bmp":exports.FileViewerType.image,".gif":exports.FileViewerType.image,".svg":exports.FileViewerType.image,".webp":exports.FileViewerType.image,".wav":exports.FileViewerType.audio,".mp3":exports.FileViewerType.audio,".mp4":exports.FileViewerType.video,".webm":exports.FileViewerType.video,".ogg":exports.FileViewerType.video,".pdf":exports.FileViewerType.wopi,".ods":exports.FileViewerType.wopi,".xls":exports.FileViewerType.wopi,".xlsb":exports.FileViewerType.wopi,".xlsm":exports.FileViewerType.wopi,".xlsx":exports.FileViewerType.wopi,".doc":exports.FileViewerType.wopi,".docm":exports.FileViewerType.wopi,".docx":exports.FileViewerType.wopi,".dot":exports.FileViewerType.wopi,".dotm":exports.FileViewerType.wopi,".dotx":exports.FileViewerType.wopi,".odt":exports.FileViewerType.wopi,".odp":exports.FileViewerType.wopi,".pot":exports.FileViewerType.wopi,".potm":exports.FileViewerType.wopi,".potx":exports.FileViewerType.wopi,".pps":exports.FileViewerType.wopi,".ppsm":exports.FileViewerType.wopi,".ppsx":exports.FileViewerType.wopi,".ppt":exports.FileViewerType.wopi,".pptm":exports.FileViewerType.wopi,".pptx":exports.FileViewerType.wopi,".gdocs":exports.FileViewerType.onlineEditor,".gsheets":exports.FileViewerType.onlineEditor};function Jc(e){const{t:a}=y.useTranslation();return e?Xc[e.toLowerCase()]??exports.FileViewerType.none:exports.FileViewerType.none}const Zc={".pdf":"wv/wordviewerframe.aspx?PdfMode=1&",".xls":"x/_layouts/xlviewerinternal.aspx?",".xlsb":"x/_layouts/xlviewerinternal.aspx?",".xlsm":"x/_layouts/xlviewerinternal.aspx?",".xlsx":"x/_layouts/xlviewerinternal.aspx?",".ods":"x/_layouts/xlviewerinternal.aspx?",".doc":"wv/wordviewerframe.aspx?",".docm":"wv/wordviewerframe.aspx?",".docx":"wv/wordviewerframe.aspx?",".dot":"wv/wordviewerframe.aspx?",".dotm":"wv/wordviewerframe.aspx?",".dotx":"wv/wordviewerframe.aspx?",".odt":"wv/wordviewerframe.aspx?",".ppt":"p/PowerPointFrame.aspx?",".pptm":"p/PowerPointFrame.aspx?",".pptx":"p/PowerPointFrame.aspx?",".pot":"p/PowerPointFrame.aspx?",".potm":"p/PowerPointFrame.aspx?",".potx":"p/PowerPointFrame.aspx?",".pps":"p/PowerPointFrame.aspx?",".ppsm":"p/PowerPointFrame.aspx?",".ppsx":"p/PowerPointFrame.aspx?",".odp":"p/PowerPointFrame.aspx?"};function eu(e){const{t:a}=y.useTranslation();return Zc[e?.toLowerCase()]||""}function au(e){const{t:a}=y.useTranslation(),t=e%60;return`${Math.floor(e/60)}min ${t<10?"0":""}${t}`}function tu({open:e,onOpenChange:s,url:r,title:n,className:o,minHeight:i="250px"}){const{t:l}=y.useTranslation(),c=t.useCallback(()=>{s(!1)},[s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&c()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,c]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[a.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&a.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]}),a.jsx("iframe",{src:r,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function su({term:s,open:r,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:c=e.t("terms_read_agree")}){const u=t.useMemo(()=>s.file?function(e,a=""){const{t:t}=y.useTranslation(),s=atob(e),r=[];for(let o=0;o<s.length;o+=512){const e=s.slice(o,o+512),a=new Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t);r.push(new Uint8Array(a))}const n=new Blob(r,{type:a});return URL.createObjectURL(n)}(s.file,s.type):null,[s.file,s.type]),m=t.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=t.useCallback(()=>{s.hasUserSignature?m():o?.(s.id)},[s,o,m]),h=!i&&!s.hasUserSignature&&o;return a.jsx(ys,{open:r,onOpenChange:e=>!e&&m(),children:a.jsxs(ks,{className:Yt("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[a.jsx(d.FileText,{className:"h-5 w-5 text-primary"}),l]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsx(Xt,{size:"sm",onClick:p,children:c}),a.jsx(Xt,{variant:"ghost",size:"icon",onClick:m,children:a.jsx(d.X,{className:"h-4 w-4"})})]})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s.file&&u?a.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function ru(e){const{t:a}=y.useTranslation();return e.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join("")}function nu(e){const{t:a}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function ou(e){const{t:a}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function iu(e){const{t:a}=y.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.allowedIds?.forEach(e=>t.add(e)),s.inheritedIds?.forEach(e=>t.add(e));return t}var lu;exports.ReportRequestStatus=void 0,(lu=exports.ReportRequestStatus||(exports.ReportRequestStatus={}))[lu.WaitingProcessing=1]="WaitingProcessing",lu[lu.Processing=2]="Processing",lu[lu.Completed=3]="Completed",lu[lu.Error=4]="Error",lu[lu.Expired=5]="Expired";const du={report:e.t("report"),status:e.t("status"),requestDate:e.t("request_date"),lastUpdate:e.t("last_update"),expirationDate:e.t("expiration_date"),viewReport:e.t("view_report"),searchPlaceholder:e.t("search_report_placeholder"),noResults:e.t("no_reports_found"),statusWaiting:e.t("status_waiting"),statusProcessing:e.t("status_processing"),statusCompleted:e.t("status_completed"),statusError:e.t("status_error"),statusExpired:e.t("status_expired")};function cu(e){const{t:a}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function uu(e){const{t:a}=y.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const mu={sm:{badge:"px-1.5 py-0.5 text-[11px] gap-1",icon:14},md:{badge:"px-2.5 py-1 text-xs gap-1.5",icon:16},lg:{badge:"px-3 py-1.5 text-sm gap-2",icon:18}};function pu({label:e,color:t,icon:s,showIcon:r,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const d=mu[n],c=r??!!s;return a.jsxs("span",{className:Yt("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",d.badge,l),style:(()=>{switch(o){case"outline":return{color:t,borderColor:$t(t,.3),backgroundColor:"transparent"};case"ghost":return{color:t,backgroundColor:"transparent"};default:return{color:t,backgroundColor:i||$t(t,.1)}}})(),children:[c&&s&&a.jsx(s,{size:d.icon,strokeWidth:2}),e]})}var hu,xu,fu,gu,vu,bu,yu,ju,wu,Nu,_u,Cu,ku,Su,Tu,Pu,Du,Eu,Au,Iu,Mu,Fu,Ru,Lu,zu;exports.AggregationType=void 0,(hu=exports.AggregationType||(exports.AggregationType={})).Count="valuecount",hu.Sum="sum",hu.Average="average",hu.DistinctCount="valuecount_distict",hu.Max="max",hu.Min="min",exports.AnalysisFunctionality=void 0,(exports.AnalysisFunctionality||(exports.AnalysisFunctionality={})).ViewAllAnalysis="nes3j6wn",exports.DashboardFunctionality=void 0,(xu=exports.DashboardFunctionality||(exports.DashboardFunctionality={})).RegisterDashboards="EeKs7CYA",xu.RemoveDashboards="3GKZYOQ9",xu.ViewAllDashboards="wYBdQNvZ",xu.EditDashboards="bMFcbwv4",exports.DashboardListType=void 0,(fu=exports.DashboardListType||(exports.DashboardListType={}))[fu.Default=1]="Default",fu[fu.Compact=2]="Compact",exports.DashboardPageTime=void 0,(gu=exports.DashboardPageTime||(exports.DashboardPageTime={}))[gu.FiveSeconds=1]="FiveSeconds",gu[gu.TenSeconds=2]="TenSeconds",gu[gu.FifteenSeconds=3]="FifteenSeconds",gu[gu.ThirtySeconds=4]="ThirtySeconds",gu[gu.OneMinute=5]="OneMinute",gu[gu.ThreeMinutes=6]="ThreeMinutes",gu[gu.FiveMinutes=7]="FiveMinutes",gu[gu.TenMinutes=8]="TenMinutes",exports.DashboardPanelDimension=void 0,(vu=exports.DashboardPanelDimension||(exports.DashboardPanelDimension={}))[vu.Day=1]="Day",vu[vu.Month=2]="Month",vu[vu.Year=3]="Year",exports.DashboardPanelOrderByType=void 0,(bu=exports.DashboardPanelOrderByType||(exports.DashboardPanelOrderByType={}))[bu.Ascending=1]="Ascending",bu[bu.Descending=2]="Descending",exports.DashboardPanelOrderBy=void 0,(yu=exports.DashboardPanelOrderBy||(exports.DashboardPanelOrderBy={}))[yu.Label=1]="Label",yu[yu.Value=2]="Value",exports.DashboardPanelPeriod=void 0,(ju=exports.DashboardPanelPeriod||(exports.DashboardPanelPeriod={}))[ju.LastSevenDays=1]="LastSevenDays",ju[ju.LastWeek=2]="LastWeek",ju[ju.LastMonth=3]="LastMonth",ju[ju.PreviousQuarter=4]="PreviousQuarter",ju[ju.PreviousSemester=5]="PreviousSemester",ju[ju.LastYear=6]="LastYear",ju[ju.SpecificPeriod=7]="SpecificPeriod",ju[ju.CurrentMonth=8]="CurrentMonth",ju[ju.CurrentSemester=9]="CurrentSemester",ju[ju.CurrentWeek=10]="CurrentWeek",ju[ju.CurrentYear=11]="CurrentYear",exports.DashboardPanelType=void 0,(wu=exports.DashboardPanelType||(exports.DashboardPanelType={}))[wu.Text=1]="Text",wu[wu.Area=2]="Area",wu[wu.Bar=3]="Bar",wu[wu.Column=4]="Column",wu[wu.StackedColumn=5]="StackedColumn",wu[wu.Line=6]="Line",wu[wu.List=7]="List",wu[wu.Numeric=8]="Numeric",wu[wu.Pareto=9]="Pareto",wu[wu.Pie=10]="Pie",wu[wu.RiskMatrix=11]="RiskMatrix",wu[wu.Burndown=12]="Burndown",wu[wu.PerformanceColumns=13]="PerformanceColumns",wu[wu.EvolutionLine=14]="EvolutionLine",exports.DashboardUpdateTime=void 0,(Nu=exports.DashboardUpdateTime||(exports.DashboardUpdateTime={}))[Nu.NotUpdate=1]="NotUpdate",Nu[Nu.FiveMinutes=2]="FiveMinutes",Nu[Nu.TenMinutes=3]="TenMinutes",Nu[Nu.FifteenMinutes=4]="FifteenMinutes",Nu[Nu.ThirtyMinutes=5]="ThirtyMinutes",Nu[Nu.OneHour=6]="OneHour",exports.DashboardViewType=void 0,(_u=exports.DashboardViewType||(exports.DashboardViewType={}))[_u.NormalPage=1]="NormalPage",_u[_u.Carousel=2]="Carousel",exports.DashboardFormTab=void 0,(Cu=exports.DashboardFormTab||(exports.DashboardFormTab={}))[Cu.General=0]="General",Cu[Cu.Share=1]="Share",exports.DashboardShareType=void 0,(ku=exports.DashboardShareType||(exports.DashboardShareType={}))[ku.NotShared=1]="NotShared",ku[ku.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",ku[ku.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.DashboardLanguage=void 0,(Su=exports.DashboardLanguage||(exports.DashboardLanguage={})).PtBr="pt-br",Su.EnUs="en",Su.EsEs="es",exports.MatrixViewType=void 0,(Tu=exports.MatrixViewType||(exports.MatrixViewType={}))[Tu.Quantity=0]="Quantity",Tu[Tu.AllRisksList=1]="AllRisksList",exports.PanelItemsPerPanel=void 0,(Pu=exports.PanelItemsPerPanel||(exports.PanelItemsPerPanel={}))[Pu.Five=5]="Five",Pu[Pu.Ten=10]="Ten",Pu[Pu.Fifteen=15]="Fifteen",Pu[Pu.Twenty=20]="Twenty",Pu[Pu.All=0]="All",Pu[Pu.Custom=-1]="Custom",exports.PanelSortType=void 0,(Du=exports.PanelSortType||(exports.PanelSortType={}))[Du.AlphabeticalAsc=1]="AlphabeticalAsc",Du[Du.AlphabeticalDesc=2]="AlphabeticalDesc",Du[Du.CountAsc=3]="CountAsc",Du[Du.CountDesc=4]="CountDesc",Du[Du.DateAsc=5]="DateAsc",Du[Du.DateDesc=6]="DateDesc",exports.PanelState=void 0,(Eu=exports.PanelState||(exports.PanelState={}))[Eu.Loading=0]="Loading",Eu[Eu.Loaded=1]="Loaded",Eu[Eu.Error=3]="Error",Eu[Eu.NoData=4]="NoData",Eu[Eu.Unavailable=5]="Unavailable",exports.VisualizationType=void 0,(Au=exports.VisualizationType||(exports.VisualizationType={}))[Au.Quantity=1]="Quantity",Au[Au.Percentage=2]="Percentage",Au[Au.QuantityPercentage=3]="QuantityPercentage",exports.PlanType=void 0,(Iu=exports.PlanType||(exports.PlanType={}))[Iu.Program=1]="Program",Iu[Iu.Project=2]="Project",Iu[Iu.Action=3]="Action",Iu[Iu.PerformanceProject=4]="PerformanceProject",Iu[Iu.PerformanceAction=5]="PerformanceAction",exports.QueriesContextType=void 0,(Mu=exports.QueriesContextType||(exports.QueriesContextType={})).OccurrenceActionPlans="xebGnSSq",Mu.OccurrenceGeneral="UFws4AvH",Mu.PlansActionPlans="Kux6CcVC",Mu.PlansProgramProjects="UWjrp6Dw",Mu.PlansIdeas="3g7vNm2w",Mu.RisksGeneral="PZ4b6FhP",Mu.RisksActionPlans="xZErDg57",Mu.RisksAnalysis="UxsioMbH",Mu.RisksIncidences="gNt5IJ2F",Mu.MetrologyGeneral="4MfEPbRY",Mu.MetrologyActivities="hdFM9XQW",Mu.MetrologyServiceOrders="cIrVPdMv",Mu.DecisionsGeneral="CopsnHDB",Mu.DecisionsItems="qLFAayjx",Mu.DecisionsActionPlans="RiQFpxdb",Mu.FlowGeneral="AFV98JoG",Mu.AuditGeneral="gON8LJPi",Mu.AuditPlans="SsCNVOvr",Mu.AuditPlansItems="OpPkCCFm",Mu.AuditActionPlans="P1oGePhh",Mu.CommonGeneral="VVfEzgMQ",Mu.ActionPlans="C6Z4MgGa",Mu.SuppliersEvaluations="fSCeS4mH",Mu.SuppliersGeneral="8qPThkrD",Mu.SuppliersEvaluationsCriteria="RiSIStdY",Mu.SuppliersDocuments="Riua4jMa",Mu.SuppliersMaterialsServices="UpEkatXH",Mu.DocumentsGeneral="FRhhEX2J",Mu.DocumentsPhysicalCopies="PZLtJ23h",Mu.DocumentsObsolete="XDjbga14",Mu.FmeaGeneral="aPwf4uPr",Mu.FmeaActionPlans="vQ8PMrVX",exports.QueriesShareType=void 0,(Fu=exports.QueriesShareType||(exports.QueriesShareType={}))[Fu.NotShared=1]="NotShared",Fu[Fu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",Fu[Fu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.QuickFilterDashboard=void 0,(Ru=exports.QuickFilterDashboard||(exports.QuickFilterDashboard={}))[Ru.All=1]="All",Ru[Ru.OnlyMine=2]="OnlyMine",Ru[Ru.Favorites=3]="Favorites",exports.RiskCriticality=void 0,(Lu=exports.RiskCriticality||(exports.RiskCriticality={}))[Lu.Current=1]="Current",Lu[Lu.Inherent=2]="Inherent",exports.PaletteType=void 0,(zu=exports.PaletteType||(exports.PaletteType={}))[zu.Default=1]="Default",zu[zu.Pastel=2]="Pastel",zu[zu.Vibrant=3]="Vibrant",zu[zu.Earth=4]="Earth",zu[zu.Ocean=5]="Ocean",zu[zu.Floral=6]="Floral",zu[zu.Night=7]="Night",zu[zu.Winter=8]="Winter",zu[zu.Spring=9]="Spring",zu[zu.Summer=10]="Summer",zu[zu.Fall=11]="Fall",zu[zu.Gray=12]="Gray",zu[zu.Brown=13]="Brown",zu[zu.Blue=14]="Blue",zu[zu.Yellow=15]="Yellow",zu[zu.Green=16]="Green",zu[zu.Purple=17]="Purple",zu[zu.Orange=18]="Orange",zu[zu.Pink=19]="Pink",zu[zu.Red=20]="Red";const Uu={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},Ou=["total_calibration_cost","total_verification_cost","total_maintenance_cost","last_calibration_cost","last_verification_cost","last_maintenance_cost","total_cost","total_reported_cost","estimated_cost","last_report_cost_reported_cost","occurrence_reported_cost","task_estimated_cost"],Vu=["link","link_risk","risk_link","link_group","group_link","link_occurrence","occurrence_link","link_audit","link_project","link_program","link_ideia","flow_link","decision_link","link_supplier","auditing_link","fmea_link"];function Bu(e){if(!e)return 0;const[a,t]=e.split("/"),s=Uu[a?.toLowerCase()]??0;return 12*(parseInt(t)||0)+s}function qu(e){const a=e.split("/"),t=a[a.length-1];return`${a.slice(0,-1).join("/")}/${encodeURIComponent(t.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function $u(e){for(const a of Vu)if(e[a])return e[a];return null}function Wu(e){const a=[];for(const t of Object.keys(e)){const s=e[t];null!=s&&(s instanceof Date?a.push(`${t}=${s.toISOString()}`):Array.isArray(s)?s.forEach(e=>{a.push(...Wu({[t]:e}))}):"string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s||a.push(`${t}=${s}`))}return a}const Hu=/^-?\d+(,\d{3})*(\.\d+)?$/;const Gu=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const Yu=new Set([exports.DashboardPanelType.Text]),Ku=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.Numeric,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]),Qu=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]);function Xu({config:e,viewOnly:s=!1,complement:r,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:c,className:u}){const{t:m}=y.useTranslation(),[p,h]=t.useState(e.onlyMine??!1),x=Yu.has(e.typeId),f=!Ku.has(e.typeId),g=!Qu.has(e.typeId),v=t.useMemo(()=>{if(!e.jsonRules||e.typeId===exports.DashboardPanelType.PerformanceColumns)return!1;try{const a=JSON.parse(e.jsonRules);return a?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),b=t.useMemo(()=>o?.(e)??"#",[o,e]),j=t.useCallback(()=>{const e=!p;h(e),c?.(e)},[p,c]),w=[];return p&&w.push(m("dashboard_only_mine")),e.onlyLate&&w.push(m("dashboard_only_overdue")),v&&w.push(m("dashboard_advanced_filter")),a.jsxs("div",{className:Yt("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&r,a.jsxs("div",{className:"flex min-w-0 flex-col",children:[a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:e.title})}),a.jsx(Nr,{children:e.title})]}),w.length>0&&a.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:w.join(" | ")})]}),"after-title"===n&&r]}),!s&&a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&r,a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",children:a.jsx(d.MoreVertical,{className:"h-3.5 w-3.5"})})}),a.jsxs(pr,{align:"end",className:"w-48",children:[e.canUpdate&&a.jsxs(hr,{onClick:()=>e.onEdit?.(e.id),children:[a.jsx(d.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&a.jsxs(hr,{onClick:i,children:[a.jsx(d.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&a.jsxs(hr,{disabled:e.noData,onClick:l,children:[a.jsx(d.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&a.jsxs(hr,{disabled:!e.openQueryEnabled,onClick:()=>window.open(b,"_blank"),children:[a.jsx(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:j,children:[p&&a.jsx(d.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&a.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>e.onDuplicate?.(e.id),children:[a.jsx(d.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),a.jsxs(hr,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[a.jsx(d.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&r]})]})}function Ju({config:e,queryUrl:t,className:s}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),a.jsxs("p",{className:"mt-2 text-xs",children:[t&&a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),t&&e.canUpdate&&a.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function Zu({panelType:e,className:t}){const s=e===exports.DashboardPanelType.Burndown;return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-2 p-4",t),children:[a.jsx(tr,{className:"h-10 w-10 text-muted-foreground/40"}),s&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function em({hasRemovedColumn:t=!1,className:s}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),a.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function am({onRemove:e,className:t}){return a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",t),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&a.jsx("p",{className:"mt-2 text-xs",children:a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const tm={[exports.AggregationType.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[exports.AggregationType.Sum]:"Sum",[exports.AggregationType.Average]:e.t("dashboard_average"),[exports.AggregationType.DistinctCount]:e.t("dashboard_distinct_count"),[exports.AggregationType.Max]:e.t("dashboard_max_value"),[exports.AggregationType.Min]:e.t("dashboard_min_value")};function sm({config:e,state:t,value:s,label:r,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:d,className:c}){const{t:u}=y.useTranslation(),m=r??tm[e.aggregationType??""]??"",p=function(e,a){if(null==e)return"—";const t=Ou.includes(a.field),s=a.aggregationType===exports.AggregationType.Count||a.aggregationType===exports.AggregationType.DistinctCount;return t&&!s?Gu.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?s?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(s,e);return a.jsxs("div",{className:Yt("flex h-full flex-col",c),children:[a.jsx(Xu,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:d}),t===exports.PanelState.Loading&&a.jsx(Zu,{}),t===exports.PanelState.Loaded&&a.jsxs("div",{className:Yt("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[a.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&a.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),t===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:l}),t===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function rm({config:e,state:t,htmlContent:s,viewOnly:r=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const d=s??e.textTypeString??"";return a.jsxs("div",{className:Yt("flex h-full flex-col",l),children:[a.jsx(Xu,{config:e,viewOnly:r,onRefresh:n,queryUrlBuilder:i}),t===exports.PanelState.Loading&&a.jsx(Zu,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:d}}),t===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:o})]})}function nm({config:e,state:s,data:r=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=t.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=t.useCallback(e=>{if(i)i(e);else if(m){const a=$u(e);a&&window.open(qu(a),"_blank")}},[i,m]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Xu,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Zu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:a.jsx("tr",{children:h.map(e=>a.jsx("th",{className:"px-2 py-1.5 text-left text-xs font-medium text-muted-foreground whitespace-nowrap border-b",children:e.header||e.columnLabel||e.columnName},e.columnName))})}),a.jsx("tbody",{children:r.map((e,t)=>{const s=m&&!!$u(e);return a.jsx("tr",{className:Yt("border-b border-border/50 transition-colors hover:bg-muted/30",(s||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(t=>a.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:t.render?t.render(e[t.columnName],e):om(e[t.columnName],t)},t.columnName))},t)})})]})}),s===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function om(e,a){return null==e?"":e instanceof Date?"datetime"===a.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const im=["hsl(var(--primary))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3"];function lm({config:e,variant:s,state:r,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:d,viewOnly:c=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:im,v=t.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),b="bar"===s,y="stacked-column"===s,j=t.useMemo(()=>{if(d)return e=>d.replace("{value}",e.toLocaleString("pt-BR"))},[d]);return a.jsxs("div",{className:Yt("flex h-full flex-col",f),children:[a.jsx(Xu,{config:e,viewOnly:c,onRefresh:m,onExport:p,queryUrlBuilder:x}),r===exports.PanelState.Loading&&a.jsx(Zu,{}),r===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:dm({variant:s,data:n,series:v,colors:g,categoryKey:l,isHorizontalBar:b,isStacked:y,yAxisTickFormatter:j,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),r===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),r===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:h}),r===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function dm({variant:e,data:t,series:s,colors:r,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:d,onPointClick:c}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=a.jsx(B.XAxis,{dataKey:o?void 0:n,type:o?"number":"category",...u,angle:o?0:-45,textAnchor:o?"middle":"end",height:o?void 0:60,tickFormatter:o?l:void 0}),p=a.jsx(B.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=a.jsx(B.Tooltip,{formatter:d,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=s.length>1?a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=c?(e,a)=>c(t[a],a):void 0;return"bar"===e||"column"===e||"stacked-column"===e?a.jsxs(B.BarChart,{data:t,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||r[t%r.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:c?"pointer":void 0},e.dataKey))]}):"area"===e?a.jsxs(B.AreaChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>{const s=e.color||r[t%r.length];return a.jsx(B.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:s,fill:s,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:c?"pointer":void 0}},e.dataKey)})]}):a.jsxs(B.LineChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||r[t%r.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:c?"pointer":void 0}},e.dataKey))]})}const cm=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function um({config:e,state:s,data:r=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:cm,h=t.useMemo(()=>r.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[r]),x=t.useMemo(()=>h.reduce((e,a)=>e+(a.value??0),0),[h]);return a.jsxs("div",{className:Yt("flex h-full flex-col",m),children:[a.jsx(Xu,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(Zu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.PieChart,{children:[a.jsx(B.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:a})=>`${e??""}: ${(100*(a??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,a)=>i(r[a],a):void 0,cursor:i?"pointer":void 0,children:h.map((e,t)=>a.jsx(B.Cell,{fill:p[t%p.length]},t))}),a.jsx(B.Tooltip,{formatter:e=>{const a="number"==typeof e?e:0,t=x>0?(a/x*100).toFixed(1):"0";return`${a.toLocaleString("pt-BR")} (${t}%)`}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),s===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function mm({config:e,state:s,data:r=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:d,onExport:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=t.useMemo(()=>{const e=[...r].sort((e,a)=>(a.value??0)-(e.value??0)),a=e.reduce((e,a)=>e+(a.value??0),0);let t=0;return e.map(e=>(t+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:a>0?Math.round(t/a*100):0}))},[r]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Xu,{config:e,viewOnly:i,onRefresh:d,onExport:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Zu,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),a.jsx(B.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:(e,a)=>"% Acumulado"===a?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,a)=>l(r[a],a):void 0,cursor:l?"pointer":void 0}),a.jsx(B.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),s===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function pm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:d,queryUrl:c,queryUrlBuilder:u,className:m}){const{t:p}=y.useTranslation(),h=r??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return a.jsxs("div",{className:Yt("flex h-full flex-col",m),children:[a.jsx(Xu,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:u}),t===exports.PanelState.Loading&&a.jsx(Zu,{panelType:exports.DashboardPanelType.Burndown}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.AreaChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),a.jsx(B.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),t===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:c}),t===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function hm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=y.useTranslation(),x=r??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Xu,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:m}),t===exports.PanelState.Loading&&a.jsx(Zu,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.BarChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),a.jsx(B.Tooltip,{formatter:e=>"number"==typeof e?`${e}%`:e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:d?(e,a)=>d(s[a],a):void 0,cursor:d?"pointer":void 0}),a.jsx(B.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),t===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:u}),t===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}function xm({config:e,state:s,rule:r,risks:n=[],matrixViewType:o=exports.MatrixViewType.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=t.useMemo(()=>[...r?.parametersY??[]].sort((e,a)=>a.position-e.position),[r?.parametersY]),x=r?.parametersX??[],f=t.useMemo(()=>{const e={};return n.forEach(a=>{const t=`${a.parameterYPosition}-${a.parameterXPosition}`;e[t]||(e[t]=[]),e[t].push(a)}),e},[n]);return a.jsxs("div",{className:Yt("flex h-full flex-col",p),children:[a.jsx(Xu,{config:e,viewOnly:i,onRefresh:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(Zu,{}),s===exports.PanelState.Loaded&&r&&a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:r.name_y})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex mb-1",children:[a.jsx("div",{className:"w-16 shrink-0"}),a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.threat_strategy_type_name}),!r.disable_opportunities&&a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.opportunity_strategy_type_name})]}),h.map((e,t)=>a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0 flex items-center justify-center border border-border/50 text-xs font-medium p-1 text-center",children:e.name}),x.map((s,n)=>{const i=((e,a)=>f[`${a.position}-${e.position}`]??[])(s,e),c=((e,a)=>r?.colorMatrix?.[a]?.[e]??"hsl(var(--muted))")(n,t);return a.jsxs("div",{className:Yt("flex-1 min-w-[60px] min-h-[40px] border border-border/50 flex flex-col items-center justify-center gap-0.5 p-1",(l||d)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:c},onClick:()=>i.length>0&&l?.(s,e,i),children:[o===exports.MatrixViewType.Quantity&&i.length>0&&a.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===exports.MatrixViewType.AllRisksList&&i.map(e=>a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:a=>{a.stopPropagation(),d?.(e)},children:e.code})}),a.jsxs(Nr,{className:"max-w-[250px]",children:[a.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&a.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",a.jsx("strong",{children:e.analysisDate})]}),e.strategy&&a.jsxs("p",{className:"text-xs",children:["Estratégia: ",a.jsx("strong",{children:e.strategy})]}),e.resultName&&a.jsxs("p",{className:"text-xs",children:["Criticidade: ",a.jsx("strong",{style:{backgroundColor:c},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},s.position)})]},e.position)),a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>a.jsx("div",{className:"flex-1 min-w-[60px] border border-border/50 text-xs font-medium p-1 text-center",children:e.name},e.position))]}),a.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:r.name_x})]})]})}),s===exports.PanelState.NoData&&a.jsx(em,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(Ju,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(am,{onRemove:()=>e.onRemove?.(e.id)})]})}const fm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:a,y:t}=e;return"translate3d("+(a?Math.round(a):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:a,scaleY:t}=e;return"scaleX("+a+") scaleY("+t+")"}},Transform:{toString(e){if(e)return[fm.Translate.toString(e),fm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:a,duration:t,easing:s}=e;return a+" "+t+"ms "+s}}});function gm(e){switch(Number(e)){case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Numeric:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.Text:return{x:1,y:1};default:return{x:2,y:2}}}function vm({panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:p}=X.useSortable({id:e.id,disabled:!o}),h=t.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*r+(e.sizeY-1)*n+"px",transform:fm.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,s,r,n,u,m,p]);return a.jsxs("div",{ref:c,style:h,className:Yt("rounded-lg border border-border bg-card shadow-sm overflow-hidden","transition-shadow duration-200",p&&"shadow-lg ring-2 ring-primary/20"),...l,children:[a.jsx("div",{className:Yt("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?d:{}}),a.jsx("div",{className:"h-full",children:i})]})}function bm({panels:e,columns:s=8,cellHeight:r=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:d,className:c}){const[u,m]=t.useState(e);t.useMemo(()=>{m(e)},[e]);const p=Q.useSensors(Q.useSensor(Q.PointerSensor,{activationConstraint:{distance:8}})),h=t.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=t.useMemo(()=>u.map(e=>e.id),[u]),f=t.useCallback(e=>{const{active:a,over:t}=e;if(!t||a.id===t.id)return;const s=u.findIndex(e=>e.id===a.id),r=u.findIndex(e=>e.id===t.id);if(-1===s||-1===r)return;const n=[...u],o={...n[s]},i={...n[r]},l=o.col,c=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=c,n[s]=o,n[r]=i,m(n),d?.(n)},[u,d]),g=t.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gridTemplateRows:`repeat(${h}, ${r}px)`,gap:`${n}px`}),[s,h,r,n]);return 0===u.length?a.jsxs("div",{className:Yt("flex flex-col items-center justify-center py-16 text-center",c),children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):a.jsx(Q.DndContext,{sensors:p,collisionDetection:Q.closestCenter,onDragEnd:f,children:a.jsx(X.SortableContext,{items:x,strategy:X.rectSortingStrategy,children:a.jsx("div",{style:g,className:Yt("relative w-full",i&&"bg-muted/30",c),children:u.map(e=>a.jsx(vm,{panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const ym={[exports.DashboardPanelType.Bar]:"bar",[exports.DashboardPanelType.Column]:"column",[exports.DashboardPanelType.StackedColumn]:"stacked-column",[exports.DashboardPanelType.Area]:"area",[exports.DashboardPanelType.Line]:"line",[exports.DashboardPanelType.EvolutionLine]:"evolution-line"};function jm({config:e,state:t,data:s,numericValue:r,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:d,matrixRule:c,matrixRisks:u,onPanelClick:m}){const p=ym[e.typeId];if(p)return a.jsx(lm,{config:e,variant:p,state:t,data:o,series:i});switch(e.typeId){case exports.DashboardPanelType.Numeric:return a.jsx(sm,{config:e,state:t,value:r});case exports.DashboardPanelType.Text:return a.jsx(rm,{config:e,state:t});case exports.DashboardPanelType.List:return a.jsx(nm,{config:e,state:t,data:s,columns:n??[]});case exports.DashboardPanelType.Pie:return a.jsx(um,{config:e,state:t,data:s});case exports.DashboardPanelType.Pareto:return a.jsx(mm,{config:e,state:t,data:s});case exports.DashboardPanelType.Burndown:return a.jsx(pm,{config:e,state:t,data:l});case exports.DashboardPanelType.PerformanceColumns:return a.jsx(hm,{config:e,state:t,data:d});case exports.DashboardPanelType.RiskMatrix:return a.jsx(xm,{config:e,state:t,rule:c,risks:u??[]});default:return a.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:["Tipo de painel não suportado (",e.typeId,")"]})}}function wm({dashboard:e,panels:s,pages:r,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:d,onRefresh:c,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:v,onLayoutChange:b,onPageChange:j,toolbarActions:w,className:N}){const{t:_}=y.useTranslation(),[C,k]=t.useState(!1),S=e.idViewType===exports.DashboardViewType.Carousel,T=t.useMemo(()=>s,[s,S,n]),P=t.useMemo(()=>T.map(e=>{const a=gm(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:a.x,minSizeY:a.y}}),[T]),D=t.useCallback(e=>({id:e.id,title:e.titlePtBr||e.titleEnUs||e.titleEsEs,typeId:e.typeId,queryId:e.queryId,queryContextId:e.queryContextId,queryTitle:e.queryTitle,querySelectedColumns:e.querySelectedColumns,field:e.field??"",fieldType:e.fieldType??"",fieldAuxAxis:e.fieldAuxAxis,fieldAuxAxisType:e.fieldAuxAxisType,aggregationType:e.aggregationType,textTypeString:e.textTypeString,referenceDate:e.referenceDate,period:e.period,initialDate:e.initialDate,finalDate:e.finalDate,dimension:e.dimension,yAxis:e.yAxis,yAxisType:e.yAxisType,orderBy:e.orderBy,orderByType:e.orderByType,secondaryGrouping:e.secondaryGrouping,secondaryGroupingType:e.secondaryGroupingType,onlyLate:e.onlyLate,jsonRules:e.jsonRules,ignoreRules:e.ignoreRules,visualizationType:e.visualizationType,sortType:e.sortType,itemsPerPanel:e.itemsPerPanel,secondaryItemsPerPanel:e.secondaryItemsPerPanel,matrixViewRule:e.matrixViewRule,listPanelColumns:e.listPanelColumns,listPanelListType:e.listPanelListType,paletteId:e.paletteId,hexColors:e.hexColors,showNotInformedData:e.showNotInformedData,fieldAnalysisRule:e.fieldAnalysisRule,fieldCriticality:e.fieldCriticality,fieldPlansType:e.fieldPlansType,fieldPlansSelected:e.fieldPlansSelected,fieldPlansBurndown:e.fieldPlansBurndown,fieldPlansBurndownGroup:e.fieldPlansBurndownGroup,analysisCriteriaId:e.analysisCriteriaId,analysisCriteriaParameter:e.analysisCriteriaParameter,evolutionSecondaryGrouping:e.evolutionSecondaryGrouping,canUpdate:o,hasRemovedColumn:e.hasRemovedColumn,panelSize:{x:e.sizeX,y:e.sizeY},onEdit:f,onRemove:g,onDuplicate:v}),[o,f,g,v]),E=t.useCallback(()=>{C||l||(k(!0),c?.(),setTimeout(()=>k(!1),3e4))},[C,l,c]),A=t.useCallback(e=>{const t=T.find(a=>a.id===e);if(!t)return null;const s=D(t),r=d?.(e)??{state:exports.PanelState.Loaded};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Xu,{config:s,onRefresh:()=>{}}),a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(jm,{config:s,...r})})]})},[T,D,d,o,f,g,v]);return a.jsxs("div",{className:Yt("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&a.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[w,c&&a.jsx("button",{onClick:E,disabled:C||l,className:Yt("inline-flex items-center justify-center rounded-md p-2 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors","disabled:opacity-50 disabled:pointer-events-none"),title:C?_("dashboard_wait_refresh"):"Atualizar",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m0 0a9 9 0 0 1 9-9m-9 9a9 9 0 0 0 9 9"})})}),u&&a.jsx("button",{onClick:u,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:i?_("dashboard_exit_fullscreen"):"Fullscreen",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?a.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"}):a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),o&&!i&&h&&a.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:"Compartilhar",children:a.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&a.jsx("button",{onClick:m,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:e.isFavorite?_("dashboard_remove_favorite"):"Favoritar",children:a.jsx("svg",{className:Yt("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})]})]}),S&&r&&r.length>1&&a.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:r.map(e=>a.jsx("button",{onClick:()=>j?.(e.id),className:Yt("px-3 py-1.5 text-sm rounded-md whitespace-nowrap transition-colors",n===e.id?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:e.name||`Dashboard ${e.position}`},e.id))}),o&&!i&&x&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsxs("button",{onClick:x,className:Yt("inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:a.jsx(bm,{panels:P,allowDragging:o,showGridLines:o,renderPanel:A,onLayoutChange:b})})]})}function Nm(e,a=exports.DashboardLanguage.PtBr){const{t:t}=y.useTranslation();switch(a){case exports.DashboardLanguage.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case exports.DashboardLanguage.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function _m(e){const{t:a}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const Cm=[{value:exports.QuickFilterDashboard.All,label:"Todos"},{value:exports.QuickFilterDashboard.OnlyMine,label:e.t("dashboard_my")},{value:exports.QuickFilterDashboard.Favorites,label:"Favoritos"}];function km({dashboards:e,limit:s,isLoading:r=!1,language:n=exports.DashboardLanguage.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:d,onEdit:c,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:v,toolbarExtra:b,className:j}){const{t:w}=y.useTranslation(),[N,_]=t.useState(""),[C,k]=t.useState(exports.QuickFilterDashboard.All),[S,T]=t.useState(null),P=t.useCallback(e=>{_(e),g?.(e)},[g]),D=t.useCallback(e=>{k(e),v?.(e)},[v]),E=t.useMemo(()=>{let a=e;if(N){const e=N.toLowerCase();a=a.filter(a=>a.code?.toLowerCase().includes(e)||Nm(a,n).toLowerCase().includes(e)||a.responsibleName?.toLowerCase().includes(e))}switch(C){case exports.QuickFilterDashboard.OnlyMine:break;case exports.QuickFilterDashboard.Favorites:a=a.filter(e=>e.isFavorite)}return a},[e,N,C,n]);return a.jsxs("div",{className:Yt("flex flex-col h-full",j),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),s&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.countDashboards,"/",s.maxDashboards,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.3-4.3"})]}),a.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>P(e.target.value),className:Yt("h-9 w-48 rounded-md border border-input bg-background pl-9 pr-3 text-sm","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")})]}),b,o&&h&&a.jsxs("button",{onClick:h,className:Yt("inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),a.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:Cm.map(e=>a.jsx("button",{onClick:()=>D(e.value),disabled:r,className:Yt("px-3 py-1.5 text-sm rounded-md transition-colors",C===e.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground","disabled:opacity-50"),children:e.label},e.value))}),r&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!r&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:a.jsxs("tr",{children:[a.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),a.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),a.jsx("th",{className:"w-12 px-3 py-2"})]})}),a.jsxs("tbody",{children:[0===E.length&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),E.map(e=>a.jsxs("tr",{onClick:()=>d?.(e),className:Yt("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsx("svg",{className:Yt("h-4 w-4",e.isFavorite?"fill-yellow-400 text-yellow-400":"text-muted-foreground"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),a.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:Nm(e,n)}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),a.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:_m(e.lastModified)}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("span",{className:Yt("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",e.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),children:e.isActive?"Ativo":"Inativo"})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"5",r:"1"}),a.jsx("circle",{cx:"12",cy:"12",r:"1"}),a.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(null)}),a.jsxs("div",{className:"absolute right-0 top-8 z-50 min-w-[160px] rounded-md border border-border bg-popover shadow-md py-1",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"my-1 border-t border-border"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),p?.(e)},className:"w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-destructive/10 transition-colors",children:"Remover"})]})]})]})]})})]},e.id))]})]})})]})}const Sm=[{value:exports.DashboardUpdateTime.NotUpdate,label:e.t("dashboard_no_refresh")},{value:exports.DashboardUpdateTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardUpdateTime.TenMinutes,label:"10 minutos"},{value:exports.DashboardUpdateTime.FifteenMinutes,label:"15 minutos"},{value:exports.DashboardUpdateTime.ThirtyMinutes,label:"30 minutos"},{value:exports.DashboardUpdateTime.OneHour,label:"1 hora"}],Tm=[{value:exports.DashboardViewType.NormalPage,label:e.t("dashboard_normal_page")},{value:exports.DashboardViewType.Carousel,label:"Carrossel"}],Pm=[{value:exports.DashboardPageTime.FiveSeconds,label:"5 segundos"},{value:exports.DashboardPageTime.TenSeconds,label:"10 segundos"},{value:exports.DashboardPageTime.FifteenSeconds,label:"15 segundos"},{value:exports.DashboardPageTime.ThirtySeconds,label:"30 segundos"},{value:exports.DashboardPageTime.OneMinute,label:"1 minuto"},{value:exports.DashboardPageTime.ThreeMinutes,label:"3 minutos"},{value:exports.DashboardPageTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardPageTime.TenMinutes,label:"10 minutos"}],Dm=[{value:exports.DashboardShareType.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:exports.DashboardShareType.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],Em=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function Am({dashboard:e,initialTab:s=exports.DashboardFormTab.General,isSaving:r=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:d=[],onSave:c,onCancel:u,className:m}){const{t:p}=y.useTranslation(),h=!!e,[x,f]=t.useState(s),[g,v]=t.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[b,j]=t.useState(e?.titlePtBr??""),[w,N]=t.useState(e?.titleEnUs??""),[_,C]=t.useState(e?.titleEsEs??""),[k,S]=t.useState(e?.responsibleId??""),[T,P]=t.useState(e?.isActive??!0),[D,E]=t.useState(e?.idUpdateTime??exports.DashboardUpdateTime.NotUpdate),[A,I]=t.useState(e?.idViewType??exports.DashboardViewType.NormalPage),[M,F]=t.useState(e?.idPageTime??exports.DashboardPageTime.FifteenSeconds),[R,L]=t.useState(e?.idShare??exports.DashboardShareType.NotShared),[z,U]=t.useState(e?.groups??[]),[O,V]=t.useState(e?.places??[]),[B,q]=t.useState(e?.collaborators??[]),$=A===exports.DashboardViewType.Carousel,W=g["pt-br"]||g.en||g.es,H=t.useMemo(()=>!!W&&(!(g["pt-br"]&&!b.trim())&&(!(g.en&&!w.trim())&&!(g.es&&!_.trim()))),[W,g,b,w,_]),G=t.useCallback(e=>{v(a=>({...a,[e]:!a[e]}))},[]),Y=t.useCallback(()=>{H&&!r&&c?.({titlePtBr:g["pt-br"]?b:"",titleEnUs:g.en?w:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:T,idUpdateTime:D,idViewType:A,idPageTime:$?M:null,idShare:R,groups:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?z:[],places:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?B:[]})},[H,r,c,g,b,w,_,k,T,D,A,M,$,R,z,O,B]);return a.jsxs("div",{className:Yt("flex flex-col h-full bg-background",m),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&a.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),a.jsxs("button",{onClick:Y,disabled:!H||r,className:Yt("inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors","disabled:opacity-50 disabled:pointer-events-none"),children:[r?a.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),a.jsxs("div",{className:"flex border-b border-border bg-card",children:[a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.General),className:Yt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.Share),className:Yt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),a.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===exports.DashboardFormTab.General&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),a.jsx("div",{className:"flex gap-2",children:Em.map(e=>a.jsx("button",{onClick:()=>G(e.key),className:Yt("px-3 py-1 text-xs rounded-md border transition-colors",g[e.key]?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:bg-accent"),children:e.label},e.key))}),!W&&a.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),a.jsx("input",{value:b,onChange:e=>j(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[b.length,"/200"]})]}),g.en&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),a.jsx("input",{value:w,onChange:e=>N(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[w.length,"/200"]})]}),g.es&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),a.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),a.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:[a.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),a.jsx("select",{value:D,onChange:e=>E(Number(e.target.value)),disabled:n,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:Sm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),a.jsxs("div",{className:"flex items-center gap-3 h-10",children:[a.jsx("button",{onClick:()=>P(!T),disabled:e?.isGeneralViewUse,className:Yt("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",T?"bg-primary":"bg-muted","disabled:opacity-50"),children:a.jsx("span",{className:Yt("inline-block h-4 w-4 rounded-full bg-white transition-transform",T?"translate-x-6":"translate-x-1")})}),a.jsx("span",{className:"text-sm text-foreground",children:T?"Ativo":"Inativo"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),a.jsx("select",{value:A,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:Tm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),a.jsx("select",{value:M??"",onChange:e=>F(Number(e.target.value)),className:Yt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:Pm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===exports.DashboardFormTab.Share&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[a.jsxs("svg",{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("path",{d:"M12 8h.01"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),a.jsx("div",{className:"space-y-3",children:Dm.map(t=>a.jsxs("label",{className:Yt("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",R===t.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[a.jsx("input",{type:"radio",name:"shareType",value:t.value,checked:R===t.value,onChange:()=>L(t.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:t.label}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]})]},t.value))}),R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators&&a.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),a.jsx("select",{multiple:!0,value:z,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);U(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:i.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),a.jsx("select",{multiple:!0,value:O,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);V(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:l.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",B.length,")"]}),a.jsx("select",{multiple:!0,value:B,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);q(a)},className:Yt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:d.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function Im(){return`n_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Mm(e,a){return{id:a?.id??Im(),text:e,children:a?.children,collapsed:a?.collapsed,color:a?.color,icon:a?.icon,note:a?.note,side:a?.side}}function Fm(e,a){if(e.id===a)return{node:e,parent:null};const t=[];for(const s of e.children??[])t.push({node:s,parent:e});for(;t.length;){const e=t.pop();if(e.node.id===a)return{node:e.node,parent:e.parent};for(const a of e.node.children??[])t.push({node:a,parent:e.node})}return null}function Rm(e,a){const t=a(e);return t.children?.length?{...t,children:t.children.map(e=>Rm(e,a))}:t}function Lm(e,a,t){return Rm(e,e=>e.id===a?t(e):e)}function zm(e){return{left:(e.children??[]).filter(e=>"left"===e.side).length,right:(e.children??[]).filter(e=>"left"!==e.side).length}}function Um(e,a,t){const s=Mm(t||"");let r=s.id;const n=Rm(e,t=>{if(t.id!==a)return t;let n=s;if(t.id===e.id){const a=zm(e);n={...n,side:a.left<=a.right?"left":"right"}}else n={...n,side:t.side};return r=n.id,{...t,collapsed:!1,children:[...t.children??[],n]}});return{root:n,newId:r}}function Om(e,a,t){if(e.id===a)return Um(e,a,t);const s=Fm(e,a);if(!s||!s.parent)return{root:e,newId:a};const r=s.parent,n=Mm(t||"",{side:s.node.side}),o=n.id,i=Rm(e,e=>{if(e.id!==r.id)return e;const t=(e.children??[]).findIndex(e=>e.id===a),s=[...e.children??[]];return s.splice(t+1,0,n),{...e,children:s}});return{root:i,newId:o}}function Vm(e,a){if(e.id===a)return{root:e,nextSelectedId:a};const t=Fm(e,a);if(!t||!t.parent)return{root:e,nextSelectedId:null};const s=t.parent,r=s.children??[],n=r.findIndex(e=>e.id===a),o=r[n+1]?.id??r[n-1]?.id??s.id,i=Rm(e,e=>e.id!==s.id?e:{...e,children:(e.children??[]).filter(e=>e.id!==a)});return{root:i,nextSelectedId:o}}function Bm(e,a,t){if(a===t)return e;if(a===e.id)return e;if(function(e,a,t){const s=Fm(e,a);return!!s&&!!Fm(s.node,t)}(e,a,t))return e;const s=Fm(e,a);if(!s)return e;const r=(()=>{if(t===e.id){const a=zm(e);return{...s.node,side:a.left<=a.right?"left":"right"}}const a=Fm(e,t)?.node;return{...s.node,side:a?.side}})(),n=Rm(e,e=>e.children?.length&&e.children.some(e=>e.id===a)?{...e,children:e.children.filter(e=>e.id!==a)}:e);return Rm(n,e=>e.id!==t?e:{...e,collapsed:!1,children:[...e.children??[],r]})}function qm(e,a){return Lm(e,a,e=>({...e,collapsed:!e.collapsed}))}function $m(e,a){return Rm(e,t=>t.children?.length?t.id===e.id&&a?t:{...t,collapsed:a}:t)}function Wm(e){const{value:a,defaultValue:s,onChange:r,readOnly:n}=e,o=void 0!==a,[i,l]=t.useState(()=>s??a??Mm("Mapa Mental",{id:"root"})),d=o?a:i,[c,u]=t.useState(d.id),m=t.useRef([]),p=t.useRef([]),h=t.useCallback((e,a)=>{n||(m.current.push(a),m.current.length>50&&m.current.shift(),p.current=[],o||l(e),r?.(e))},[o,r,n]),x=t.useCallback((e,a)=>{const t=Lm(d,e,e=>({...e,text:a}));h(t,d)},[d,h]),f=t.useCallback((e,a)=>{const t=Lm(d,e,e=>({...e,...a}));h(t,d)},[d,h]),g=t.useCallback((e,a="")=>{const{root:t,newId:s}=Um(d,e,a);return h(t,d),u(s),s},[d,h]),v=t.useCallback((e,a="")=>{const{root:t,newId:s}=Om(d,e,a);return h(t,d),u(s),s},[d,h]),b=t.useCallback(e=>{const{root:a,nextSelectedId:t}=Vm(d,e);a!==d&&(h(a,d),u(t))},[d,h]),y=t.useCallback((e,a)=>{const t=Bm(d,e,a);t!==d&&h(t,d)},[d,h]),j=t.useCallback(e=>{const a=Fm(d,e);if(!a||!a.node.children?.length)return;const t=qm(d,e);h(t,d)},[d,h]),w=t.useCallback(()=>{h($m(d,!1),d)},[d,h]),N=t.useCallback(()=>{h($m(d,!0),d)},[d,h]),_=t.useCallback(()=>{const e=m.current.pop();e&&(p.current.push(d),o||l(e),r?.(e))},[d,o,r]),C=t.useCallback(()=>{const e=p.current.pop();e&&(m.current.push(d),o||l(e),r?.(e))},[d,o,r]),k=m.current.length>0,S=p.current.length>0,T=t.useMemo(()=>c?Fm(d,c)?.node??null:null,[d,c]),P=t.useCallback(e=>{h(e,d)},[d,h]);return{root:d,setRoot:P,selectedId:c,selectedNode:T,setSelectedId:u,renameNode:x,updateNodeProps:f,addChild:g,addSibling:v,removeNode:b,moveNode:y,toggleNode:j,expandAll:w,collapseAll:N,undo:_,redo:C,canUndo:k,canRedo:S}}const Hm=180,Gm=80,Ym=16,Km=60;function Qm(e){const a=(e.collapsed?[]:e.children??[]).map(Qm);if(!a.length)return{node:e,visibleChildren:a,height:44};const t=a.reduce((e,a)=>e+a.height,0)+Ym*(a.length-1);return{node:e,visibleChildren:a,height:Math.max(44,t)}}function Xm(e,a,t,s,r,n,o){const i=[],l={node:e.node,parent:a,x:t,y:s,width:180,height:44,side:r,depth:n,visibleChildren:i};if(o.push(l),!e.visibleChildren.length)return l;let d=s+22-(e.visibleChildren.reduce((e,a)=>e+a.height,0)+Ym*(e.visibleChildren.length-1))/2;for(const c of e.visibleChildren){const a="right"===r?t+180+Gm:t-Gm-Hm,s=d+c.height/2-22,l=Xm(c,e.node,a,s,r,n+1,o);i.push(l),d+=c.height+Ym}return l}function Jm(e){return t.useMemo(()=>function(e){const a=e.collapsed?[]:e.children??[],t=a.filter(e=>"left"!==e.side).map(Qm),s=a.filter(e=>"left"===e.side).map(Qm),r=t.reduce((e,a)=>e+a.height,0)+Ym*Math.max(0,t.length-1),n=s.reduce((e,a)=>e+a.height,0)+Ym*Math.max(0,s.length-1),o=Math.max(r,n,56),i=e=>e.visibleChildren.length?1+Math.max(...e.visibleChildren.map(i)):0,l=t.length?Math.max(...t.map(i))+1:0,d=260*(s.length?Math.max(...s.map(i))+1:0),c=220+260*l+d+120,u=o+120,m=Km+d,p=[],h={node:e,parent:null,x:m,y:Km+o/2-28,width:220,height:56,side:"root",depth:0,visibleChildren:[]};p.push(h);let x=Km+o/2-r/2;for(const v of t){const a=x+v.height/2-22,t=Xm(v,e,m+220+Gm,a,"right",1,p);h.visibleChildren.push(t),x+=v.height+Ym}let f=Km+o/2-n/2;for(const v of s){const a=f+v.height/2-22,t=Xm(v,e,m-Gm-Hm,a,"left",1,p);h.visibleChildren.push(t),f+=v.height+Ym}const g=new Map(p.map(e=>[e.node.id,e]));return{nodes:p,byId:g,width:c,height:u}}(e),[e])}function Zm(e,a){const{layout:t,selectedId:s,setSelectedId:r}=a;if(!s)return void r(t.nodes[0]?.node.id??null);const n=t.byId.get(s);if(!n)return;if("left"===e||"right"===e){if("root"===n.side){const a=n.visibleChildren.find(a=>a.side===e);return void(a&&r(a.node.id))}if(e===n.side){const e=n.visibleChildren[Math.floor(n.visibleChildren.length/2)];e&&r(e.node.id)}else n.parent&&r(n.parent.id);return}if(!n.parent)return;const o=t.byId.get(n.parent.id);if(!o)return;const i=o.visibleChildren.filter(e=>e.side===n.side),l=i.findIndex(e=>e.node.id===s),d="up"===e?i[l-1]:i[l+1];d&&r(d.node.id)}const ep=({layout:e,selected:t,editing:s,readOnly:r,onSelect:n,onStartEditing:o,onFinishEditing:i,onToggle:l,onDragStart:c,onDragOver:u,onDragLeave:m,onDrop:p,isDropTarget:h,renderNodeContent:x})=>{const f=e.node,g="root"===e.side,v=(b=f.icon)?te[b]??null:null;var b;const y=!!f.children?.length,j=ae.useRef(null),[w,N]=ae.useState(f.text);ae.useEffect(()=>{if(s){N(f.text);const e=window.setTimeout(()=>{j.current?.focus(),j.current?.select()},0);return()=>window.clearTimeout(e)}},[s,f.text]);const _=()=>{i(w.trim()||f.text)},C=f.color;return a.jsxs("div",{role:"treeitem","aria-selected":t,"aria-expanded":y?!f.collapsed:void 0,tabIndex:t?0:-1,"data-node-id":f.id,draggable:!r&&!g&&!s,onDragStart:c,onDragOver:u,onDragLeave:m,onDrop:p,onClick:e=>{e.stopPropagation(),n()},onDoubleClick:e=>{e.stopPropagation(),r||o()},className:Yt("absolute flex items-center gap-2 rounded-lg border bg-card text-card-foreground px-3 select-none transition-shadow","shadow-sm hover:shadow-md cursor-pointer",g&&"font-semibold border-primary/40 bg-primary text-primary-foreground",t&&!g&&"ring-2 ring-primary ring-offset-1",t&&g&&"ring-2 ring-primary-foreground/60 ring-offset-1",h&&"ring-2 ring-accent border-accent"),style:{left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:C},children:[v&&a.jsx(v,{className:Yt("h-4 w-4 shrink-0",g&&"text-primary-foreground")}),a.jsx("div",{className:"flex-1 min-w-0",children:s?a.jsx("input",{ref:j,value:w,onChange:e=>N(e.target.value),onBlur:_,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),_()):"Escape"===e.key?(e.preventDefault(),i(null)):e.stopPropagation()},className:Yt("w-full bg-transparent outline-none text-sm",g&&"text-primary-foreground placeholder:text-primary-foreground/60")}):x?a.jsx("div",{className:"text-sm truncate",children:x(f)}):a.jsx("div",{className:"text-sm truncate",children:f.text||a.jsx("span",{className:"opacity-50",children:"—"})})}),f.note&&!s&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{type:"button",onClick:e=>e.stopPropagation(),className:Yt("shrink-0 rounded p-0.5 hover:bg-muted/40",g&&"hover:bg-primary-foreground/10"),"aria-label":f.note,children:a.jsx(d.FileText,{className:"h-3.5 w-3.5 opacity-70"})})}),a.jsx(Nr,{className:"max-w-xs whitespace-pre-line",children:f.note})]}),y&&a.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},className:Yt("shrink-0 rounded-full border bg-background text-foreground h-5 w-5 flex items-center justify-center -mr-1","shadow-sm hover:bg-muted transition-colors",g&&"border-primary-foreground/30"),"aria-label":f.collapsed?"Expandir":"Colapsar",children:f.collapsed?a.jsx(d.Plus,{className:"h-3 w-3"}):"left"===e.side?a.jsx(d.ChevronRight,{className:"h-3 w-3 rotate-180"}):"right"===e.side?a.jsx(d.ChevronRight,{className:"h-3 w-3"}):a.jsx(d.Minus,{className:"h-3 w-3"})})]})},ap=({parent:e,child:t})=>{const s=t.x+t.width/2<e.x+e.width/2,r=s?e.x:e.x+e.width,n=e.y+e.height/2,o=s?t.x+t.width:t.x,i=t.y+t.height/2,l=(r+o)/2,d=`M ${r} ${n} C ${l} ${n}, ${l} ${i}, ${o} ${i}`;return a.jsx("path",{d:d,fill:"none",stroke:"hsl(var(--border))",strokeWidth:2,strokeLinecap:"round"})},tp=({label:e,icon:t,onClick:s,disabled:r})=>a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",onClick:s,disabled:r,"aria-label":e,className:"h-8 w-8",children:t})}),a.jsx(Nr,{children:e})]}),sp=e=>{const{t:t}=y.useTranslation();return a.jsxs("div",{className:"flex items-center gap-1 border-b bg-card px-2 py-1.5",children:[a.jsx(tp,{label:t("mind_map_add_child"),icon:a.jsx(d.CornerDownRight,{className:"h-4 w-4"}),onClick:e.onAddChild,disabled:!e.canAddChild}),a.jsx(tp,{label:t("mind_map_add_sibling"),icon:a.jsx(d.Plus,{className:"h-4 w-4"}),onClick:e.onAddSibling,disabled:!e.canAddSibling}),a.jsx(tp,{label:t("mind_map_delete_node"),icon:a.jsx(d.Trash2,{className:"h-4 w-4"}),onClick:e.onDelete,disabled:!e.canDelete}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(tp,{label:t("mind_map_expand_all"),icon:a.jsx(d.ChevronsUpDown,{className:"h-4 w-4"}),onClick:e.onExpandAll}),a.jsx(tp,{label:t("mind_map_collapse_all"),icon:a.jsx(d.ChevronsDownUp,{className:"h-4 w-4"}),onClick:e.onCollapseAll}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(tp,{label:t("mind_map_zoom_out"),icon:a.jsx(d.ZoomOut,{className:"h-4 w-4"}),onClick:e.onZoomOut}),a.jsx(tp,{label:t("mind_map_zoom_in"),icon:a.jsx(d.ZoomIn,{className:"h-4 w-4"}),onClick:e.onZoomIn}),a.jsx(tp,{label:t("mind_map_fit_to_screen"),icon:a.jsx(d.Maximize2,{className:"h-4 w-4"}),onClick:e.onFit}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(tp,{label:t("mind_map_undo"),icon:a.jsx(d.Undo2,{className:"h-4 w-4"}),onClick:e.onUndo,disabled:!e.canUndo}),a.jsx(tp,{label:t("mind_map_redo"),icon:a.jsx(d.Redo2,{className:"h-4 w-4"}),onClick:e.onRedo,disabled:!e.canRedo}),a.jsx("div",{className:"flex-1"}),a.jsx(tp,{label:t("mind_map_export_json"),icon:a.jsx(d.Download,{className:"h-4 w-4"}),onClick:e.onExportJson}),a.jsx(tp,{label:t("mind_map_export_image"),icon:a.jsx(d.Image,{className:"h-4 w-4"}),onClick:e.onExportImage})]})};function rp(e){return JSON.stringify(e,null,2)}function np(e){if(!e||"object"!=typeof e)throw new Error("Invalid mind map node: not an object");const a=e;if("string"!=typeof a.text)throw new Error('Invalid mind map node: missing "text"');const t=Array.isArray(a.children)?a.children.map(e=>np(e)):void 0;return Mm(a.text,{id:"string"==typeof a.id?a.id:void 0,collapsed:"boolean"==typeof a.collapsed?a.collapsed:void 0,color:"string"==typeof a.color?a.color:void 0,icon:"string"==typeof a.icon?a.icon:void 0,note:"string"==typeof a.note?a.note:void 0,side:"left"===a.side||"right"===a.side?a.side:void 0,children:t})}function op({data:e,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:v=!0,onColumnResize:b,enableColumnReorder:j=!1,onReorderColumns:w,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:T=!1,rowActionsVariant:P="default",hideActionsColumn:D=!1,actionsHeaderContent:E}){const{t:A}=y.useTranslation(),I=u||A("no_items_found",A("no_items_found_empty")),[M,F]=t.useState(()=>T?new Set(e.map(e=>e.id)):new Set),R=void 0!==k,L=R?new Set(k):M,z=t.useCallback(e=>{R&&S?S(e):F(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[R,S]),{columnWidths:U,isDragging:O,activeColumn:V,handleMouseDown:B}=po({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:b,enabled:v}),q=No({enabled:j&&!!w,onReorder:w??(()=>{})}),$=t.useMemo(()=>{if(v){const e=s.map(e=>U[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return e.map(e=>e/a*100+"%")}const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[s,v,U]);if(c)return a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))})});if(0===e.length)return a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"text-center text-muted-foreground",children:a.jsx("p",{children:I})})});const W=l&&!D,H=(p?1:0)+(_?1:0)+s.length+(W?1:0);return a.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:a.jsxs(In,{className:Yt("table-fixed w-full",m),children:[a.jsx(Mn,{className:"sticky top-0 bg-background z-10",children:a.jsxs(Ln,{children:[_&&a.jsx(zn,{className:"w-[40px]"}),p&&a.jsx(zn,{className:"w-[40px]",children:a.jsx(Xs,{checked:g,onCheckedChange:f,"aria-label":A("select_all","Selecionar todos")})}),s.map((e,t)=>{const s=v&&!1!==e.resizable,i=V===String(e.key),l=j&&!!w,c=l?q.getDragProps(t):{},u=q.dragFromIndex===t,m=q.dragOverIndex===t&&q.dragFromIndex!==t;return a.jsxs(zn,{className:Yt(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&q.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[t]},...c,children:[!1!==e.sortable&&o?a.jsxs("button",{onClick:()=>o(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(p=String(e.key),r!==p?null:"asc"===n?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):a.jsx("span",{className:"font-medium",children:e.header}),s&&a.jsx(Hn,{direction:"horizontal",onMouseDown:a=>B(String(e.key),a),isDragging:i})]},String(e.key));var p}),W&&a.jsx(zn,{className:"w-[80px] text-right",children:E??A("actions","Ações")})]})}),a.jsx(Fn,{children:e.map(e=>{const r=_&&L.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Ln,{onClick:()=>i?.(e),className:Yt(i?"cursor-pointer":"","relative","inline"===P&&"group"),children:[_&&a.jsx(Un,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":r?A("collapse_row","Recolher linha"):A("expand_row","Expandir linha"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&a.jsx(Un,{children:a.jsx(Xs,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${A("select_all","Selecionar todos")} ${e.id}`})}),s.map(t=>a.jsx(Un,{className:t.className,children:a.jsx(Wn,{children:t.render?t.render(e):String(e[t.key]??"-")})},String(t.key))),W&&a.jsx(Un,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===P?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),r&&C&&a.jsx(Ln,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Un,{colSpan:H,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function ip({onEdit:e,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=y.useTranslation(),p=t.useMemo(()=>{const a=[];return e&&o&&a.push({key:"edit",icon:d.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),r&&a.push({key:"toggle-status",icon:n?d.PowerOff:d.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),l.forEach(e=>{!1!==e.show&&a.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),s&&i&&a.push({key:"delete",icon:d.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),a},[e,s,r,n,o,i,l,m]);return 0===p.length?null:"dropdown"===c?a.jsx(yr,{delayDuration:200,children:a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:a.jsx(d.EllipsisVertical,{size:"compact"===u?14:16})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?a.jsxs(_r,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):a.jsxs(hr,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):a.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>a.jsxs(Xt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&a.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&a.jsx("span",{className:"ml-1",children:e.label})]},e.key))})}function lp({searchValue:e="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=y.useTranslation(),l=e||s.length>0;return a.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((e,t)=>a.jsx("div",{className:"vertical"===o?"w-full":"",children:e},t)),n&&l&&r&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[a.jsx(d.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function dp(e,a){const{t:t}=y.useTranslation(),s=new Set;function r(e){if(e)for(const a of e)s.add(a.id),r(a.children)}return function e(t){for(const s of t){if(s.id===a)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),s}function cp({children:e,itemId:t,enableDrag:s,onDragStartCell:r,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return a.jsx(Un,{draggable:s,onDragStart:s?e=>r(t,e):void 0,onDragEnd:s?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(t,e)},className:l,children:e})}function up({item:e,level:t,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j,dragCount:w}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*t,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),T=g===e.id&&f!==e.id,P=p?.has(e.id)??!1,D={itemId:e.id,enableDrag:x,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j};return a.jsxs(a.Fragment,{children:[a.jsxs(Ln,{className:Yt(l&&"cursor-pointer",k&&"group",S&&"opacity-40",T&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[a.jsx(cp,{...D,children:a.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&a.jsx(Xs,{checked:P,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&a.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?a.jsx("button",{onClick:a=>{a.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?a.jsx(d.ChevronDown,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})}):a.jsx("div",{className:"w-6 shrink-0"}),n??a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"truncate",children:String(e[r]??e.id)}),f===e.id&&w&&w>1&&a.jsx("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary px-1.5 py-0 text-xs font-semibold text-primary-foreground",children:w})]})}),s.map(s=>{const r=e[s.key],n=s.render?s.render(e,t):null!=r?String(r):"—";return a.jsx(cp,{...D,className:Yt("text-center",s.className),children:s.hoverContent?a.jsxs(Il,{openDelay:200,children:[a.jsx(Ml,{asChild:!0,children:a.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),a.jsx(Fl,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:s.hoverContent(e)})]}):n},String(s.key))}),c&&a.jsx(cp,{...D,className:"text-right",children:a.jsx("div",{onClick:e=>e.stopPropagation(),className:Yt("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:c(e)})})]}),_&&N&&e.children.map(e=>a.jsx(up,{item:e,level:t+1,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j,dragCount:w},e.id))]})}function mp({onDrop:t,isDragOver:s,onDragOver:r,onDragLeave:n,label:o}){return a.jsxs("div",{className:Yt("absolute top-0 left-0 right-0 z-10 flex items-center justify-center gap-2 py-2 px-4 border-2 border-dashed rounded-md text-sm transition-colors mx-2 mt-2",s?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:r,onDragEnter:r,onDragLeave:n,onDrop:t,children:[a.jsx(d.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function pp({data:s,columns:r,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:v,selectedIds:b,onSelectItem:j,onSelectAll:w,isAllSelected:N,enableRowDrag:_,onMoveNode:C,onMoveNodes:k,rootDropLabel:S,actionsWidth:T=20,nameMinWidth:P=200}){const[D,E]=t.useState(null),[A,I]=t.useState(null),[M,F]=t.useState(!1),[R,L]=t.useState(1),z=t.useRef(null),U=t.useRef([]),O=t.useRef(null),V=t.useMemo(()=>new Set(b??[]),[b]),B=t.useMemo(()=>{if(!D||!s)return new Set;const e=U.current.length>0?U.current:[D],a=function(e,a){const{t:t}=y.useTranslation(),s=new Set;for(const r of a)dp(e,r).forEach(e=>s.add(e));return s}(s,e);return e.forEach(e=>a.add(e)),a},[D,s]),q=t.useRef(B);q.current=B;const $=t.useCallback(()=>{z.current=null,U.current=[],O.current=null,E(null),I(null),F(!1),L(1)},[]),W=t.useCallback((e,a)=>{e.length>1&&k?k(e,a):1===e.length&&C?.(e[0],a)},[C,k]),H=t.useCallback((e,a)=>{const t=V.has(e)&&V.size>1?Array.from(V):[e];z.current=e,U.current=t,O.current=null,E(e),L(t.length),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t))},[V]),G=t.useCallback((e,a)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",q.current.has(e)?I(null):(O.current=e,I(e))},[]),Y=t.useCallback((e,a)=>{a.preventDefault(),a.stopPropagation();const t=q.current.has(e)?O.current:e;if(!t)return void $();let s=U.current;if(0===s.length){try{const e=a.dataTransfer.getData("application/x-tree-ids");if(e){const a=JSON.parse(e);Array.isArray(a)&&a.length>0&&(s=a)}}catch{}if(0===s.length){const e=a.dataTransfer.getData("text/plain");e&&(s=[e])}}0===s.length||s.includes(t)||W(s,t),$()},[W,$]),K=t.useCallback(e=>{e.preventDefault(),e.stopPropagation();let a=U.current;if(0===a.length){try{const t=e.dataTransfer.getData("application/x-tree-ids");if(t){const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(a=e)}}catch{}if(0===a.length){const t=e.dataTransfer.getData("text/plain");t&&(a=[t])}}0!==a.length?(W(a,null),$()):$()},[W,$]),Q=t.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",F(!0)},[]),X=t.useCallback(e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[_]),J=t.useCallback(e=>{if(!_)return;const a=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),t=a?.dataset?.treeRowId??O.current;t&&Y(t,e)},[_,Y]);if(x)return a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!s||0===s.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[a.jsx(d.User,{className:"h-10 w-10 text-muted-foreground/50"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const Z=null!==D;return a.jsxs("div",{className:Yt("border rounded-lg overflow-hidden relative",g),onDragOver:X,onDrop:J,onDragLeave:_?e=>{const a=e.relatedTarget;a&&e.currentTarget.contains(a)||(I(null),F(!1))}:void 0,children:[_&&Z&&a.jsx(mp,{onDrop:K,isDragOver:M,onDragOver:Q,onDragLeave:()=>F(!1),label:S}),a.jsxs(In,{children:[a.jsx(Mn,{children:a.jsxs(Ln,{children:[a.jsx(zn,{className:"text-left",style:{minWidth:P},children:a.jsxs("div",{className:"flex items-center gap-2",children:[v&&a.jsx(Xs,{checked:N??!1,onCheckedChange:()=>w?.()}),o]})}),r.map(e=>a.jsx(zn,{className:Yt("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&a.jsx(zn,{className:"text-right",style:{width:T},children:p})]})}),a.jsx(Fn,{children:s.map(e=>a.jsx(up,{item:e,level:0,columns:r,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:v,selectedIds:V,onSelectItem:j,enableRowDrag:_,draggedId:D,dragOverId:A,onDragStartCell:H,onDragEndCell:$,onDragOverCell:G,onDropCell:Y,dragCount:R},e.id))})]})]})}function hp(e){const a=N.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const xp=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],fp=({open:e,onOpenChange:s,user:r,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:l}=y.useTranslation(),c=t.useRef(null),[u,m]=t.useState(null),[p,h]=t.useState(l.language||"pt-BR"),x=u||n,f=e=>{e||(m(null),h(l.language||"pt-BR")),s(e)};return a.jsx(ys,{open:e,onOpenChange:f,children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i("edit_profile","Editar Perfil")})}),a.jsxs("div",{className:"space-y-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"relative flex-shrink-0",children:a.jsxs(ol,{className:"w-24 h-24",children:[x&&a.jsx(il,{src:x,alt:r.name||""}),a.jsx(ll,{className:"bg-primary text-primary-foreground font-semibold text-2xl",children:o})]})}),a.jsxs("div",{className:"space-y-1",children:[r.name&&a.jsx("p",{className:"text-base font-semibold",children:r.name}),r.email&&a.jsx("p",{className:"text-sm text-muted-foreground",children:r.email}),a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>c.current?.click(),children:[a.jsx(d.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),a.jsx("input",{ref:c,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const a=e.target.files?.[0];if(!a)return;const t=URL.createObjectURL(a);m(t)}})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("language","Idioma")}),a.jsxs(Vs,{value:p,onValueChange:h,children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsx(Gs,{children:xp.map(e=>a.jsx(Ks,{value:e.value,children:e.label},e.value))})]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>f(!1),children:i("cancel","Cancelar")}),a.jsx(Xt,{onClick:()=>{p!==l.language&&l.changeLanguage(p),s(!1)},children:i("save","Salvar")})]})]})})},gp="true"===(void 0).VITE_SHOW_EDIT_PROFILE,vp=t.memo(({variant:e="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{t:o}=y.useTranslation(),{user:i,companies:l,alias:c,isAuthenticated:u,logout:m,switchUnit:p}=Pn(),{role:h}=Hi(),x=h?.name||null,f=l?.[0]||null,g=c?l?.find(e=>e.alias===c):f,v=l||[],b=r||g||f||f,j=t.useMemo(()=>{if(!i?.id)return null;const e=(new Date).toISOString().slice(0,10);return`https://login-api.qualiex.com/api/Users/Photo/${i.id}/${e}/1?size=48`},[i?.id]),w=t.useMemo(()=>{if(!i?.name)return"";const e=i.name.trim().split(/\s+/);return 1===e.length?e[0].charAt(0).toUpperCase():(e[0].charAt(0)+e[e.length-1].charAt(0)).toUpperCase()},[i?.name]),N=t.useCallback(e=>{n?n(e):p(e)},[n,p]),_=t.useMemo(()=>{if(!v?.length)return[];const e=new Map;v.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===b?.alias),s=a.filter(e=>e.alias!==b?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[v,b?.alias]),[C,k]=t.useState(!1);if(!u||!i)return null;return"dropdown"===e?a.jsxs(a.Fragment,{children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${s}`,children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("div",{className:"hidden md:block text-right",children:[a.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),a.jsx("p",{className:"text-xs text-primary-foreground/70",children:b?.name||"N/A"})]}),a.jsxs(ol,{className:"w-8 h-8 border border-primary-foreground/30",children:[j&&a.jsx(il,{src:j,alt:i.name||o("user_photo")}),a.jsx(ll,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:w||a.jsx(d.User,{className:"h-4 w-4"})})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),a.jsxs(pr,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a.jsxs(dr,{children:[a.jsxs(ur,{children:[a.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),a.jsx(mr,{children:_.map(e=>a.jsxs(hr,{onClick:()=>N(e),className:e.alias===b?.alias?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===b?.alias&&a.jsx(er,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),gp&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>k(!0),children:[a.jsx(d.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:m,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),gp&&a.jsx(fp,{open:C,onOpenChange:k,user:i,userPhotoUrl:j,userInitials:w})]}):a.jsxs(ts,{className:s,children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-lg",children:o("user_info")})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsxs(ol,{className:"w-10 h-10",children:[j&&a.jsx(il,{src:j,alt:i.name||o("user_photo")}),a.jsx(ll,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:w||a.jsx(d.User,{className:"h-5 w-5"})})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",b?.name||"N/A"]})]})]}),b&&a.jsx("div",{className:"mt-3",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:b.name})]})}),_.length>1&&a.jsxs("div",{className:"mt-2",children:[a.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",_.length]}),a.jsxs("div",{className:"flex flex-wrap gap-1",children:[_.slice(0,3).map(e=>a.jsx(er,{variant:e.alias===b?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>N(e),children:e.name},e.alias)),_.length>3&&a.jsxs(er,{variant:"outline",className:"text-xs",children:["+",_.length-3]})]})]})]}),{}),a.jsx(ls,{}),a.jsxs(Xt,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),bp=t.createContext({});function yp({children:e,config:s}){const r=t.useMemo(()=>{const e=Ie(),a=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:a}},[s?.navigation,s?.appName]);return a.jsx(bp.Provider,{value:r,children:e})}function jp(){return t.useContext(bp)}function wp(e,a){if(!e)return"";const t=e.find(e=>e.path===a);if(t)return t.label;const s=e.find(e=>a.startsWith(e.path+"/"));return s?.label||""}function Np(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]}function _p({appName:e}){const[s,r]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between w-[258px]",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>r(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&a.jsx("button",{className:"min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground/80 hover:text-primary-foreground/60 transition-colors leading-tight py-1",onClick:()=>r(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]}),a.jsx(Yi,{open:s,onOpenChange:r})]})}const Cp=t.memo(function({actions:s}){const r=N.useLocation(),n=N.useNavigate(),{navigation:o,appName:i}=jp(),l=wp(o,r.pathname),{metadata:c,headerActions:u}=si(),{setOpenMobile:m}=Fd(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:v}=Pn(),b=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[y,j]=N.useSearchParams(),w=t.useCallback(e=>{const{pathname:a,search:t,hash:s}=r;if(h){const r=a.split("/"),o=r.indexOf(h);if(o>=0)return r[o]=e.alias,void n(r.join("/")+t+s)}v(e)},[h,r,n,v]),[_,C]=t.useState(()=>y.get("search")||""),[k,S]=Np(_,Re.debounceDelay);t.useEffect(()=>{if(!x)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),j(e)},[k,j,x]);const T=o?.find(e=>e.path===r.pathname)||o?.find(e=>r.pathname.startsWith(e.path+"/")),P=c.title||l,D=c.subtitle||T?.complementaryText||"";return a.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:()=>m(!0),children:a.jsx(d.Menu,{size:20})}),a.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:a.jsx(_p,{appName:i})}),a.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),a.jsxs("div",{className:"flex-shrink-0",children:[c.breadcrumbs&&c.breadcrumbs.length>0&&a.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:c.breadcrumbs.map((e,t)=>a.jsxs("span",{className:"flex items-center gap-1",children:[t>0&&a.jsx(d.ChevronRight,{className:"h-3 w-3"}),e.href?a.jsx(N.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):a.jsx("span",{children:e.label})]},t))}),a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:P})}),D&&a.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:D})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:_,onChange:e=>{return a=e.target.value,void C(a);var a},className:"w-full pl-10 pr-8"}),_&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-primary-foreground/10 text-primary-foreground/60",onClick:()=>{S(),C("");const e=new URLSearchParams(y);e.delete("search"),e.delete("page"),j(e)},title:e.t("clear_search"),children:a.jsx(d.X,{size:14})})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0 bg-primary-foreground/20 border-primary-foreground/30 text-primary-foreground hover:bg-primary-foreground/30 hover:text-primary-foreground",title:e.t("refresh_data"),children:a.jsx(d.RefreshCw,{size:14})})]}),a.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||s)&&a.jsx("div",{className:"flex items-center gap-2",children:u||s}),(void 0).VITE_WIKI_URL&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>Ht((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),a.jsx(Yc,{}),a.jsx("div",{className:"text-sm",children:a.jsx(vp,{variant:"dropdown",selectedUnit:b,onUnitChange:w})})]})]})})}),kp=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>w.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1});function Sp({config:e,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{t:n}=y.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=d.Plus,variant:c="button"}=e;if(!o||0===o.length)return null;if("split-button"===c){const e=o[0],n=e.icon||l,i=o.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(t){const t=a.jsx(Xt,{onClick:e.onClick,disabled:s||e.disabled,className:Yt("justify-center px-2 w-full",r),variant:"outline",size:"default",children:a.jsx(n,{className:"h-4 w-4 shrink-0"})});return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:t}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})}return a.jsx(Uc,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:s||e.disabled,className:Yt("w-full",r),menuAlign:"start"})}const u=(e,s,r=!1)=>a.jsxs(a.Fragment,{children:[e,!t&&s&&a.jsx("span",{className:"truncate",children:s}),!t&&r&&a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=s||e.disabled,d=a.jsx(Xt,{onClick:e.onClick,disabled:i,className:Yt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return t?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:d}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]}):d}const m=a.jsx(Xt,{disabled:s,className:Yt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:t?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:m}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:i})})]}):m}),a.jsx(pr,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const Tp="forlogic-sidebar-pinned",Pp=()=>{try{const e=localStorage.getItem(Tp);return!!e&&JSON.parse(e)}catch{return!1}};function Dp({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=290,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","290px"))},[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 Ep=t.createContext(void 0);function Ap(){const e=t.useContext(Ep);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Ip({config:e,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=y.useTranslation(),{open:l,setOpen:c,setOpenMobile:u}=Fd(),m=N.useLocation(),{alias:p,user:h}=Pn(),{appName:x}=jp(),{hasOpenModal:f}=Ap(),[g,v]=t.useState(Pp),b=An(),j=!!b||l,w=t.useCallback(()=>{b&&u(!1)},[b,u]),_=r?Dp({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;t.useEffect(()=>{c(!!g)},[g,c]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return a.jsxs(Ld,{collapsible:"icon",className:Yt("app-sidebar bg-background border-r border-border flex flex-col",j?"px-3":"px-1.5"),style:_&&j?{width:`${_.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&a.jsx("div",{className:"py-3",children:a.jsx(yr,{children:a.jsx(Sp,{config:e.moduleActions,isCollapsed:!j,isDisabled:f})})}),a.jsx(Wd,{className:Yt(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:s||a.jsx(Hd,{className:"p-0",children:a.jsx(Kd,{children:a.jsx(Qd,{className:"gap-1",children:a.jsx(yr,{children:e?.navigation?.map((e,t)=>{if("separator"===e.type)return a.jsx($d,{className:"my-2"},`sep-${t}`);const s=({item:e,index:t})=>{const r=`${e.path}-${t}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=kp({key:r,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,c=o?d.Loader2:l?d.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?j?a.jsx(gi,{defaultOpen:!0,className:"group/collapsible",children:a.jsxs(Xd,{children:[a.jsx(vi,{asChild:!0,children:a.jsx(Zd,{size:"default",children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label}),a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),a.jsx(bi,{children:a.jsx(sc,{children:e.children.map((e,t)=>a.jsx(s,{item:e,index:t},e.path))})})]})},e.path):a.jsx(Xd,{children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:Yt("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:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path):a.jsx(Xd,{children:l||o?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:j?a.jsx(Zd,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.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:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):j?a.jsx(Zd,{asChild:!0,isActive:C(e.path),size:"default",children:a.jsxs(N.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:w,children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(N.Link,{to:e.path,onClick:w,className:Yt("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",C(e.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path)};return a.jsx(s,{item:e,index:t},e.path)})})})})})}),!b&&a.jsx("div",{className:Yt("mt-auto pb-4 pt-2 flex",l?"justify-end":"justify-center"),children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{id:"btn-expand-side-nav",onClick:()=>{const e=!g;v(e),(e=>{try{localStorage.setItem(Tp,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:l?a.jsx(d.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),r&&_&&j&&a.jsx("div",{ref:_.dragRef,onMouseDown:_.handleMouseDown,className:Yt("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-['']",_.isDragging&&"bg-primary/40")})]})}const Mp=t.memo(function({children:e,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||a.jsx(Ip,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),l=t.useRef(null),d=t.useRef(null),c=t.useCallback(()=>{if(l.current&&d.current){const e=l.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return t.useEffect(()=>{c();const e=new ResizeObserver(c);return l.current&&e.observe(l.current),()=>e.disconnect()},[c]),a.jsx(yp,{config:r,children:a.jsx(ti,{children:a.jsx(Rd,{defaultOpen:!1,style:i,children:a.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&a.jsx("div",{ref:l,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:a.jsx(Cp,{})}),a.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[o,a.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class Fp{static async sendEmail(e){const a=on(),{data:t,error:s}=await a.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return t}}const Rp=Fp;function Lp({open:e,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=y.useTranslation(),[m,p]=t.useState([]),[h,x]=t.useState(!1),[f,g]=t.useState(""),{data:v=[],isLoading:b}=Ro({enabled:e}),j=t.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},N=1===m.length,_=m.length>0;return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"max-w-2xl",variant:"form",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),a.jsxs(Ts,{children:[a.jsxs("div",{className:"relative mb-4",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{placeholder:"Pesquisar...",value:f,onChange:e=>g(e.target.value),className:"pl-9"})]}),a.jsx(Do,{className:"h-[400px] pr-4",children:b?a.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-16 w-full"},t))}):0===j.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:u(f?"leadership_no_users_found":"leadership_no_users_available")})]}):a.jsx("div",{className:"space-y-2",children:j.map(e=>{const t=e.userId===l,s=c.includes(e.userId||""),r=m.includes(e.userId||"");return a.jsxs("div",{className:Yt("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(e.userId||""),children:[a.jsx(Xs,{checked:r,onCheckedChange:()=>w(e.userId||""),onClick:e=>e.stopPropagation()}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium",children:e.userName}),t&&a.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||s)&&a.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})})]}),a.jsxs(Ps,{className:"flex gap-2 sm:gap-2",children:[a.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&a.jsxs("span",{children:[m.length," selecionado(s)"]})}),N&&o&&a.jsxs(Xt,{onClick:async()=>{if(o&&1===m.length){x(!0);try{await o(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[a.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),_&&i&&a.jsxs(Xt,{onClick:async()=>{if(i&&0!==m.length){x(!0);try{await i(m,r),p([])}finally{x(!1)}}},disabled:h,children:[a.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function zp({place:e,level:s=0,manageAccessConfig:r}){const{t:n}=y.useTranslation(),[o,i]=t.useState(!1),[l,c]=t.useState(!1),u=e.subPlaces&&e.subPlaces.length>0,m=e.isActive??!0,p=e.usersCount??0;return a.jsxs("div",{children:[a.jsxs(gi,{open:o,onOpenChange:i,children:[a.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:[u?a.jsxs(vi,{className:"flex items-center gap-2 flex-1",children:[a.jsx(d.ChevronRight,{className:Yt("h-4 w-4 transition-transform shrink-0",o&&"rotate-90")}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):a.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a.jsx("div",{className:"w-4 shrink-0"}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:p})]}),a.jsx(er,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),r&&a.jsx(ip,{customActions:[{label:n("manage_access"),icon:d.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),u&&a.jsx(bi,{children:e.subPlaces.map(e=>a.jsx(zp,{place:e,level:s+1,manageAccessConfig:r},e.id))})]}),0===s&&a.jsx(ls,{}),r&&a.jsx(Lp,{open:l,onOpenChange:c,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}const Up=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=un.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await un.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return tn.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function Op(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function Vp(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Bp(){const{alias:a,isAuthenticated:t}=Pn(),s=an.getAccessToken(),{data:r=[]}=Ro({enabled:!0,status:"all"});return w.useQuery({queryKey:["leadership",a],queryFn:async()=>{if(!s||!a)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=on(),{data:n,error:o}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",a);if(o)throw new Error("Erro ao buscar hierarquia de liderança");if(!n||0===n.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const l=n.map(a=>{const t=n.filter(e=>e.id_leader===a.id_user);return{...a,name:i[a.id_user]?.name||e.t("inactive_user"),email:i[a.id_user]?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))}}),d=new Set(n.map(e=>e.id_user));return new Set(n.filter(e=>e.id_leader&&!d.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e],t=n.filter(a=>a.id_leader===e);l.push({id:`virtual-${e}`,alias:n[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:a?.name||"[Usuário inativo]",email:a?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))})}),Op(l)},enabled:!!s&&!!a&&t&&r.length>0})}(void 0).VITE_SUPABASE_URL,(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;const qp="common";function $p(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(a.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Kp(t,e,a.id_user,a.id_leader);const{data:r,error:n}=await t.schema(qp).from("leaders").insert({alias:e,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function Wp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!a.users.length)throw new Error(s("select_at_least_one",s("leadership_select_subordinates")));const r=a.users.map(e=>e.id_user),{data:n}=await t.schema(qp).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 a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Kp(t,e,d.id_user,a.id_leader)}const o=a.users.map(t=>({alias:e,id_user:t.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await t.schema(qp).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_added_success",`${t?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{l.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function Hp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await t.schema(qp).from("leaders").select("id_user").eq("id",a.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Kp(t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await t.schema(qp).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Gp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await t.schema(qp).from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function Yp(){const{alias:e}=Pn(),a=w.useQueryClient(),t=on(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async({leaderUserId:a,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([t.schema(qp).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",a),t.schema(qp).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)),x=m.filter(e=>e.id_leader!==a),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const s of x)await Kp(t,e,s.id_user,a,s.id);for(const y of g){if(y.id_user===a)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await Kp(t,e,y.id_user,a)}const v=[];if(h.length){const a=h.map(e=>e.id);v.push(t.schema(qp).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",e))}if(x.length){const s=x.map(e=>e.id);v.push(t.schema(qp).from("leaders").update({id_leader:a}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(t=>({alias:e,id_user:t.id_user,id_leader:a,is_active:!0,is_removed:!1}));v.push(t.schema(qp).from("leaders").insert(s))}const b=(await Promise.all(v)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${t.created} adicionados, ${t.updated} atualizados, ${t.unlinked} removidos)`))},onError:e=>{l.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function Kp(a,t,s,r,n){const{data:o,error:i}=await a.schema(qp).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error(e.t("leadership_cycle_error"));if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const a=l.find(e=>e.id_user===c);c=a?.id_leader||null}}var Qp=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!t[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];t[o]={message:i.message,type:i.code}}else t[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[o].types,d=l&&l[s.code];t[o]=h.appendErrors(o,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},Xp=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&Z.validateFieldsNatively({},n),{errors:{},values:t.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:Z.toNestErrors(Qp(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const Jp=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string()).min(1,e.t("leadership_select_subordinates"))}),Zp=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string())});function eh({value:s,onChange:r,excludeUserIds:n=[],error:o}){const{data:i=[],isLoading:l}=Ro(),[c,u]=t.useState(""),m=t.useRef(null),p=t.useRef(0),h=i.filter(e=>!n.includes(e.userId||"")).filter(e=>{const a=c.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const t=s.includes(e.userId),r=s.includes(a.userId);if(t&&!r)return-1;if(!t&&r)return 1;const n=e.userName||e.userEmail||"",o=a.userName||a.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{m.current&&p.current>0&&(m.current.scrollTop=p.current)},[h]),l?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),a.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Zt,{placeholder:e.t("search_user_placeholder"),value:c,onChange:e=>u(e.target.value)}),a.jsx("div",{ref:m,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===h.length?a.jsx("p",{className:"text-sm text-muted-foreground",children:e.t("search_user_placeholder")}):a.jsx("div",{className:"space-y-2",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Xs,{id:e.userId,checked:s.includes(e.userId),onCheckedChange:()=>{return a=e.userId,m.current&&(p.current=m.current.scrollTop),void(s.includes(a)?r(s.filter(e=>e!==a)):r([...s,a]));var a}}),a.jsx(as,{htmlFor:e.userId,className:"flex-1 cursor-pointer",children:e.userName||e.userEmail})]},e.userId))})}),s.length>0&&a.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," selecionado(s)"]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})}function ah({leader:s,prefilledLeaderId:r,onSuccess:n}){const{t:o}=y.useTranslation(),{alias:i}=Pn(),l=!!s,c=s?.id.startsWith("virtual-"),u=Wp(),m=$p(),p=Hp(),x=Yp(),f=Gp(),{data:g=[]}=Bp(),{data:v=[]}=Ro(),[b,j]=t.useState(""),w=Vp(g).map(e=>e.id_user),N=l?Vp(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user):[],_=h.useForm({resolver:Xp(l?Zp:Jp),defaultValues:{id_leader:r||(l?s?.id_leader:null)||null,id_users:l?N:[]}});t.useEffect(()=>{if(s){const e=Vp(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user);_.reset({id_leader:s.id_leader||null,id_users:e})}else r?_.reset({id_leader:r,id_users:[]}):_.reset({id_leader:null,id_users:[]})},[i,s?.id,s?.id_user,s?.id_leader,r,g]);const C=u.isPending||m.isPending||p.isPending||x.isPending||f.isPending,k=_.watch("id_leader"),S=_.watch("id_users"),T=l?[s.id_user,...w.filter(e=>e!==s.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...w.filter(e=>!S.includes(e))].filter(Boolean);return a.jsxs("form",{onSubmit:_.handleSubmit(async e=>{try{if(l)if(c){await m.mutateAsync({id_user:s.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{await p.mutateAsync({id:s.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}n?.()}catch(a){}}),className:"space-y-4",children:[l&&a.jsxs("div",{children:[a.jsx(as,{children:e.t("leader")}),a.jsx(Zt,{value:v.find(e=>e.userId===s.id_user)?.userName||s.name||e.t("inactive_user"),disabled:!0,className:"bg-muted"})]}),a.jsxs("div",{children:[a.jsx(as,{children:o("leadership_immediate_superior")}),a.jsxs(Vs,{value:k||"none",onValueChange:e=>_.setValue("id_leader","none"===e?null:e),children:[a.jsx($s,{children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:a.jsx(Zt,{placeholder:"Buscar superior...",value:b,onChange:e=>j(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a.jsxs(Do,{className:"h-[200px]",children:[a.jsx(Ks,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=l?e.userId!==s.id_user:!S.includes(e.userId),t=!b||e.userName?.toLowerCase().includes(b.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(e=>a.jsx(Ks,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${i}`),_.formState.errors.id_leader&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:_.formState.errors.id_leader.message})]}),a.jsxs("div",{children:[a.jsx(as,{children:"Subordinados *"}),a.jsx(eh,{value:S,onChange:e=>_.setValue("id_users",e),excludeUserIds:T,error:_.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx(Xt,{type:"submit",disabled:C||!l&&0===S.length,children:C&&!f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Atualizando...":"Salvando..."]}):l?"Atualizar":"Criar"}),l&&!k&&0===S.length&&a.jsxs(ds,{children:[a.jsx(cs,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"destructive",disabled:C,className:"ml-auto",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:o("confirm_removal")}),a.jsx(gs,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),a.jsxs(xs,{children:[a.jsx(bs,{children:o("cancel")}),a.jsx(vs,{onClick:async()=>{if(s)try{await f.mutateAsync(s.id),n?.()}catch(e){}},children:o("remove")})]})]})]})]})]})}function th({open:e,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return a.jsx(ys,{open:e,onOpenChange:t,children:a.jsxs(ks,{variant:"form",className:"sm:max-w-[500px]",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Ds,{children:n})}),a.jsx(Ts,{children:a.jsx(ah,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})})]})})}const sh="leadership-expanded-nodes",rh=(e,a)=>{const{t:t}=y.useTranslation();try{localStorage.setItem(`${sh}-${e}`,JSON.stringify(Array.from(a)))}catch{}};function nh(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:d}=e||{};return{upload:async(e,a)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const t={...o,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await r(e,t);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a}}function oh(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function ih(e,a){const t=oh(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function lh(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function dh(e,a){const t=lh(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function ch(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function uh(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function mh(e,a){return e/a}function ph(){const{alias:e}=Pn(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let a=!1;return(async()=>{n(!0);try{const t=on(),{data:r,error:n}=await t.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();a||s(r)}catch(t){a||s(null)}finally{a||n(!1)}})(),()=>{a=!0}},[e]);return{config:a,isLoading:r,saveConfig:t.useCallback(async(a,t)=>{if(!e)throw new Error("Alias not available");const r=on(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:a,environment:t,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e])}}const hh=(void 0).VITE_SUPABASE_URL,xh=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;async function fh(e,a,t){const s=an.getSupabaseToken(),r={"Content-Type":"application/json",apikey:xh};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${hh}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:a,data:t})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const gh={async createEnvelopeWithSigner(e){const a="d4sign"===e.provider?"d4sign":"clicksign",t="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await fh(a,t,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const a="d4sign"===e.provider?"d4sign":"clicksign";return(await fh(a,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let vh=null;function bh(){return window.Clicksign?Promise.resolve():vh||(vh=new Promise((e,a)=>{const t=document.createElement("script");t.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",t.onload=()=>e(),t.onerror=()=>a(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(t)}),vh)}const yh="clicksign-container";function jh({signerId:e,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const{t:i}=y.useTranslation(),l=t.useRef(null),[c,u]=t.useState(!0),[m,p]=t.useState(null);return t.useEffect(()=>{let a=!1;return l.current&&(l.current.unmount(),l.current=null),p(null),u(!0),bh().then(()=>{if(a)return;const t=new window.Clicksign(e);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(yh),t.on("loaded",function(){u(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const a=e,t=document.getElementById(yh);t&&a?.data?.height&&(t.style.height=a.data.height+"px")}),t.on("error",function(e){u(!1),n?.(e instanceof Error?e:new Error(i("sign_widget_error")))}),t.on("closed",function(){o?.()}),l.current=t}).catch(e=>{a||(p("Falha ao carregar o script de assinatura."),u(!1),n?.(e))}),()=>{a=!0,l.current&&(l.current.unmount(),l.current=null)}},[e,s]),a.jsxs("div",{className:"relative h-full",children:[c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx("p",{className:"text-sm text-destructive",children:m})}),a.jsx("div",{id:yh,style:{height:"600px"}})]})}function wh({documentKey:s,signerEmail:r,signerName:n,keySigner:o,environment:i,onSign:l,onError:c}){const u=t.useRef(null),[m,p]=t.useState("loading"),[h,x]=t.useState(null),f="production"===i?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",g=(()=>{const e=new URLSearchParams({email:r,display_name:n||"",disable_preview:"0"});return o&&e.set("key_signer",o),`${f}/${s}?${e.toString()}`})(),v=t.useCallback(a=>"signed"===a.data?(p("ready"),void l?.()):"wrong-data"===a.data?(p("error"),x(e.t("sign_incorrect_data")),void c?.(new Error(e.t("sign_incorrect_data")))):void 0,[l,c]);t.useEffect(()=>(window.addEventListener("message",v,!1),()=>{window.removeEventListener("message",v,!1)}),[v]);const b=t.useCallback(()=>{"loading"===m&&p("ready")},[m]);return"error"===m?a.jsxs(Jo,{variant:"danger",className:"my-4",children:[a.jsx(Zo,{children:e.t("sign_doc_load_error")}),a.jsx(ei,{children:h||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):a.jsxs("div",{className:"relative h-full",children:["loading"===m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),a.jsx("iframe",{ref:u,id:"d4sign-container",src:g,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}var Nh,_h,Ch,kh,Sh;exports.ETaskPlanStatus=void 0,(Nh=exports.ETaskPlanStatus||(exports.ETaskPlanStatus={}))[Nh.waitingStart=1]="waitingStart",Nh[Nh.running=2]="running",Nh[Nh.effectivenessCheck=3]="effectivenessCheck",Nh[Nh.done=4]="done",Nh[Nh.suspended=5]="suspended",Nh[Nh.canceled=6]="canceled",exports.ETaskPlanPriority=void 0,(_h=exports.ETaskPlanPriority||(exports.ETaskPlanPriority={}))[_h.low=0]="low",_h[_h.medium=1]="medium",_h[_h.high=2]="high",exports.ETaskPlanAssociationType=void 0,(Ch=exports.ETaskPlanAssociationType||(exports.ETaskPlanAssociationType={}))[Ch.plan=2]="plan",Ch[Ch.occurrence=3]="occurrence",Ch[Ch.risk=4]="risk",Ch[Ch.decisions=5]="decisions",Ch[Ch.audit=6]="audit",Ch[Ch.strategyExtension=7]="strategyExtension",Ch[Ch.standardization=8]="standardization",Ch[Ch.supplier=9]="supplier",Ch[Ch.auditItems=10]="auditItems",exports.ETaskPlanTypeProgress=void 0,(kh=exports.ETaskPlanTypeProgress||(exports.ETaskPlanTypeProgress={}))[kh.currentProgress=1]="currentProgress",kh[kh.cumulativeProgress=2]="cumulativeProgress",exports.EAttachmentItemStatus=void 0,(Sh=exports.EAttachmentItemStatus||(exports.EAttachmentItemStatus={})).uploading="uploading",Sh.waiting="waiting",Sh.done="done",Sh.error="error",Sh.canceled="canceled",Sh.duplicateItem="duplicateItem";const Th={[exports.ETaskPlanStatus.waitingStart]:"#D6D6D6",[exports.ETaskPlanStatus.running]:"#DAE9F4",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB29",[exports.ETaskPlanStatus.done]:"#DDEECA",[exports.ETaskPlanStatus.suspended]:"#FFF2D6",[exports.ETaskPlanStatus.canceled]:"#F4433629"},Ph={[exports.ETaskPlanStatus.waitingStart]:"#666666",[exports.ETaskPlanStatus.running]:"#1B75BB",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB",[exports.ETaskPlanStatus.done]:"#4CAF50",[exports.ETaskPlanStatus.suspended]:"#FF9800",[exports.ETaskPlanStatus.canceled]:"#F44336"},Dh={[exports.ETaskPlanStatus.waitingStart]:"waiting-start",[exports.ETaskPlanStatus.running]:"running",[exports.ETaskPlanStatus.effectivenessCheck]:"effectiveness-check",[exports.ETaskPlanStatus.done]:"done",[exports.ETaskPlanStatus.suspended]:"suspended",[exports.ETaskPlanStatus.canceled]:"canceled"};function Eh(){return{[exports.ETaskPlanStatus.waitingStart]:e.t("ap_status_waiting_start"),[exports.ETaskPlanStatus.running]:e.t("ap_status_running"),[exports.ETaskPlanStatus.effectivenessCheck]:e.t("ap_status_effectiveness_check"),[exports.ETaskPlanStatus.done]:e.t("ap_status_done"),[exports.ETaskPlanStatus.suspended]:e.t("ap_status_suspended"),[exports.ETaskPlanStatus.canceled]:e.t("ap_status_canceled")}}const Ah=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return Eh()[a]}});const Ih=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const Mh=[{id:exports.ETaskPlanPriority.low,label:"Baixa",color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:"Média",color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:"Alta",color:"#F44336"}],Fh=[exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.canceled],Rh=[exports.ETaskPlanStatus.waitingStart,exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.suspended];function Lh(e){const{actionPlan:a,isNew:s=!1,config:r,onSave:n,onCancel:o,onDelete:i,onChangeStatus:l}=e,[d,c]=t.useState({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});t.useEffect(()=>{a&&c(e=>({...e,formData:a,isFormDisabled:r?.disableFields||Fh.includes(a.statusId)}))},[a,r?.disableFields]),t.useEffect(()=>{c(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const u=t.useCallback((e,a)=>{c(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=t.useCallback(e=>{c(a=>({...a,activeTab:e}))},[]),p=t.useCallback(async()=>{if(n){c(e=>({...e,isSaving:!0}));try{await n(d.formData)}finally{c(e=>({...e,isSaving:!1}))}}},[n,d.formData]),h=t.useCallback(async e=>{if(l&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await l(d.formData.id,e)}finally{c(e=>({...e,isLoading:!1}))}}},[l,d.formData.id]),x=t.useCallback(async()=>{if(i&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await i(d.formData.id)}finally{c(e=>({...e,isLoading:!1}))}}},[i,d.formData.id]);return{formData:d.formData,isLoading:d.isLoading,isSaving:d.isSaving,activeTab:d.activeTab,isFormDisabled:d.isFormDisabled,updateField:u,setActiveTab:m,save:p,changeStatus:h,remove:x,cancel:o}}const zh={[exports.ETaskPlanStatus.waitingStart]:{label:"",color:"#8B7355",icon:d.Clock},[exports.ETaskPlanStatus.running]:{label:"",color:"#2E7D5B",icon:d.Play},[exports.ETaskPlanStatus.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:d.ShieldCheck},[exports.ETaskPlanStatus.done]:{label:"",color:"#3D7A40",icon:d.CheckCircle2},[exports.ETaskPlanStatus.suspended]:{label:"",color:"#6B7280",icon:d.Pause},[exports.ETaskPlanStatus.canceled]:{label:"",color:"#B44A4A",icon:d.X}};function Uh({status:e,labels:t,className:s,size:r,showIcon:n,variant:o}){const i=Eh(),l=zh[e];if(!l)return null;const d=t?.[e]||i[e]||"";return a.jsx(pu,{label:d,color:l.color,icon:l.icon,size:r,showIcon:n,variant:o,className:s})}function Oh({formData:e,updateField:s,disabled:r=!1,users:n=[],places:o=[],actionTypes:i,causes:l=[],parentActions:d=[],config:c}){const{t:u}=y.useTranslation(),m=c?.requiredFields,p=i||Ih,h=e=>{if(c?.hiddenFields?.includes(e))return!1;if(c?.visibleFields&&c.visibleFields.length>0)return c.visibleFields.includes(e);const a=`${e}Visible`;return!m||!(a in m)||!1!==m[a]},x=e=>m?!!m[e]:"name"===e,f=t.useMemo(()=>{if(e.startDate&&e.endDate){const a=new Date(e.startDate),t=new Date(e.endDate).getTime()-a.getTime();return Math.max(0,Math.ceil(t/864e5))}return e.duration||0},[e.startDate,e.endDate,e.duration]);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),a.jsx(Zt,{value:e.name||"",onChange:e=>s("name",e.target.value),maxLength:500,disabled:r,placeholder:u("ap_plan_name_placeholder")})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("responsibleWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a.jsxs(Vs,{value:e.responsibleId||"",onValueChange:e=>s("responsibleId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_responsible")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ks,{value:e.id,children:e.name},e.id))})]})]}),h("checkerWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a.jsxs(Vs,{value:e.checkerId||"",onValueChange:e=>s("checkerId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_checker")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ks,{value:e.id,children:e.name},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("place")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a.jsxs(Vs,{value:e.placeId||"",onValueChange:e=>s("placeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_place")})}),a.jsx(Gs,{children:Vh(o).map(e=>a.jsx(Ks,{value:e.id,children:e.name},e.id))})]})]}),h("planType")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a.jsxs(Vs,{value:e.typeId||"",onValueChange:e=>s("typeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_type")})}),a.jsx(Gs,{children:p.map(e=>a.jsx(Ks,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("priority")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a.jsxs(Vs,{value:e.priorityType?.toString()||"",onValueChange:e=>s("priorityType",Number(e)),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_priority")})}),a.jsx(Gs,{children:Mh.map(e=>a.jsx(Ks,{value:e.id.toString(),children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})},e.id))})]})]}),d.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_belongs_to")}),a.jsxs(Vs,{value:e.parentId||"",onValueChange:e=>s("parentId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_parent")})}),a.jsx(Gs,{children:d.map(e=>a.jsx(Ks,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[h("startDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),a.jsx(yl,{date:e.startDate?new Date(e.startDate):void 0,onDateChange:e=>s("startDate",e||null),disabled:r,placeholder:u("ap_select_date")})]}),h("endDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),a.jsx(yl,{date:e.endDate?new Date(e.endDate):void 0,onDateChange:e=>s("endDate",e||null),disabled:r,placeholder:u("ap_select_date"),disabledDates:e.startDate?a=>a<new Date(e.startDate):void 0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_duration_days")}),a.jsx(Zt,{type:"number",value:f,disabled:!0,className:"bg-muted"})]})]}),h("estimatedCost")&&a.jsxs("div",{className:"space-y-2 max-w-xs",children:[a.jsx(as,{className:Yt(x("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:e.estimatedCost||"",onChange:e=>s("estimatedCost",Number(e.target.value)),disabled:r,className:"pl-9",placeholder:"0,00"})]})]}),h("cause")&&l.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Causa"}),a.jsxs(Vs,{value:e.causeId||"",onValueChange:e=>s("causeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_cause")})}),a.jsx(Gs,{children:l.map(e=>a.jsx(Ks,{value:e.id,children:e.label},e.id))})]})]}),h("description")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),a.jsx(Js,{value:e.description||"",onChange:e=>s("description",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_description_placeholder")})]}),h("justification")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Yt(x("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),a.jsx(Js,{value:e.justification||"",onChange:e=>s("justification",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_justification_placeholder")})]})]})}function Vh(e,a=0){const t=[];for(const s of e)t.push({...s,depth:a}),s.children?.length&&t.push(...Vh(s.children,a+1));return t}function Bh(e){const{progress:a,onReportProgress:s,onEditProgress:r,onDeleteProgress:n}=e,[o,i]=t.useState(!1),[l,d]=t.useState(null),c=!!a&&Rh.includes(a.status),u=t.useCallback(async e=>{if(s&&a){i(!0);try{const t=100===e.percentProgress;await s({id:a.id,...e,conclude:t})}finally{i(!1)}}},[s,a]),m=t.useCallback(async e=>{if(r){i(!0);try{await r(e)}finally{i(!1),d(null)}}},[r]),p=t.useCallback(async e=>{if(n){i(!0);try{await n(e)}finally{i(!1)}}},[n]);return{progress:a,canReportProgress:c,isSubmitting:o,editingReport:l,setEditingReport:d,reportProgress:u,editProgress:m,deleteProgress:p}}function qh(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let s=parseInt(a)||0,r=parseInt(t)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,s=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,s=parseInt(a.substring(2,4))||0,t+=Math.floor(s/60),s%=60):(t=parseInt(a)||0,s=0),`${t.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}function $h(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let s=parseInt(t)||0,r=parseInt(e)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}function Wh(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function Hh({open:e,onOpenChange:s,report:r,onSave:n,isSubmitting:o=!1}){const{t:i}=y.useTranslation(),[l,d]=t.useState(r?.percentProgress||0),[c,u]=t.useState(r?.timeProgress||""),[m,p]=t.useState(r?.comments||""),h=l!==(r?.percentProgress??0)||c!==(r?.timeProgress??"")||m!==(r?.comments??"");t.useEffect(()=>{r&&(d(r.percentProgress),u(r.timeProgress||""),p(r.comments||""))},[r]);return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:h,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i("ap_edit_progress")})}),a.jsxs("div",{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:l,onChange:e=>d(Number(e.target.value))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_time_spent")}),a.jsx(Zt,{value:c,onChange:e=>u(e.target.value),onBlur:()=>u(qh(c)||""),placeholder:"00:00"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_comments")}),a.jsx(Js,{value:m,onChange:e=>p(e.target.value),rows:3,maxLength:4e3})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>s(!1),disabled:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{r&&n({...r,percentProgress:l,timeProgress:qh(c)||"00:00",comments:m})},disabled:o,children:o?"Salvando...":"Salvar"})]})]})})}function Gh(e){const{t:s}=y.useTranslation(),{progress:r,canReportProgress:n,isSubmitting:o,editingReport:i,setEditingReport:l,reportProgress:d,editProgress:c,deleteProgress:u}=Bh(e),[m,p]=t.useState(""),[h,x]=t.useState(""),[f,g]=t.useState("");if(!r)return a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const v=Wh(r.percentProgress),b=!m,j=!m&&!h&&!f;return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium",children:s("ap_overall_progress")}),a.jsxs("span",{className:"font-semibold",style:{color:v||void 0},children:[r.percentProgress,"%"]})]}),a.jsx(gd,{value:r.percentProgress,className:"h-3"}),r.timeProgress&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",$h(r.timeProgress)]})]}),n&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_report_progress")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:m,onChange:e=>p(e.target.value),placeholder:"0"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_time_spent")}),a.jsx(Zt,{value:h,onChange:e=>x(e.target.value),onBlur:()=>x(qh(h)||""),placeholder:"00:00"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_comments")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),rows:3,maxLength:4e3,placeholder:s("ap_progress_comment_placeholder")})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>{p(""),x(""),g("")},disabled:j||o,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{const e=Number(m);(e||0===e)&&(await d({percentProgress:e,timeProgress:qh(h)||"00:00",comments:f}),p(""),x(""),g(""))},disabled:b||o,children:o?"Reportando...":"Reportar"})]})]}),r.reports.length>0&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_reports_history")}),a.jsx("div",{className:"space-y-2",children:r.reports.map(e=>a.jsx(Yh,{report:e,onEdit:()=>l(e),onDelete:()=>u(e.id),disabled:!n},e.id))})]}),a.jsx(Hh,{open:!!i,onOpenChange:e=>!e&&l(null),report:i,onSave:c,isSubmitting:o})]})}function Yh({report:t,onEdit:s,onDelete:r,disabled:n}){const o=t.date?new Date(t.date):null,i=Wh(t.percentProgress);return a.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:t.userName}),o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:o.toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("span",{style:{color:i||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a.jsxs("span",{children:["Tempo: ",$h(t.timeProgress)]})]}),t.comments&&a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[a.jsx(hr,{onClick:s,children:e.t("edit")}),a.jsx(hr,{className:"text-destructive",onClick:r,children:e.t("ap_delete")})]})]})]})}function Kh({predecessors:e=[],availablePredecessors:s=[],onAdd:r,onRemove:n,disabled:o=!1}){const{t:i}=y.useTranslation(),[l,c]=t.useState(""),u=s.filter(a=>!e.some(e=>e.predecessorId===a.id));return a.jsxs("div",{className:"space-y-6 p-1",children:[!o&&u.length>0&&a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx(as,{children:i("ap_add_predecessor")}),a.jsxs(Vs,{value:l,onValueChange:c,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:i("ap_select_action")})}),a.jsx(Gs,{children:u.map(e=>a.jsx(Ks,{value:e.id,children:e.label},e.id))})]})]}),a.jsxs(Xt,{size:"sm",onClick:()=>{l&&r&&(r(l),c(""))},disabled:!l,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[e.predecessorCode&&a.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.predecessorCode}),a.jsx("span",{className:"text-sm font-medium",children:e.predecessorName}),null!=e.predecessorStatus&&a.jsx(Uh,{status:e.predecessorStatus})]}),!o&&n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.predecessorId),children:"Remover"})})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function Qh({costs:e=[],onAdd:s,onEdit:r,onDelete:n,disabled:o=!1}){const{t:i}=y.useTranslation(),[l,c]=t.useState(""),[u,m]=t.useState(""),p=e.reduce((e,a)=>e+(a.value||0),0);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:i("ap_total_cost")}),a.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",p.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!o&&s&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:i("ap_add_cost")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Descrição"}),a.jsx(Zt,{value:l,onChange:e=>c(e.target.value),placeholder:i("ap_cost_description")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Valor (R$)"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:u,onChange:e=>m(e.target.value),placeholder:"0,00"})]})]}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(Xt,{size:"sm",onClick:()=>{l&&u&&s&&(s({description:l,value:Number(u),date:(new Date).toISOString()}),c(""),m(""))},disabled:!l||!u,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:e.description}),e.date&&a.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",e.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!o&&(r||n)&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[r&&a.jsx(hr,{onClick:()=>r(e),children:i("edit")}),n&&a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.id),children:i("ap_delete")})]})]})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function Xh({comments:e=[],currentUserId:s,onAdd:r,onEdit:n,onDelete:o,disabled:i=!1,maxLength:l=4e3}){const{t:c}=y.useTranslation(),[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(null),[g,v]=t.useState(""),b=()=>{f(null),v("")};return a.jsxs("div",{className:"space-y-6 p-1",children:[!i&&r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(Js,{value:u,onChange:e=>m(e.target.value),placeholder:c("ap_add_comment_placeholder"),maxLength:l,rows:3}),a.jsxs("div",{className:"flex items-center justify-between",children:[l&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length,"/",l]}),a.jsxs("div",{className:"flex gap-2 ml-auto",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!u||p,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{if(u.trim()&&r){h(!0);try{await r(u),m("")}finally{h(!1)}}},disabled:!u.trim()||p,children:p?"Enviando...":"Comentar"})]})]})]}),a.jsxs("div",{className:"space-y-1",children:[e.length>0?a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"text-sm font-medium",children:c("ap_comments")}),a.jsx(er,{variant:"info",className:"text-[10px] px-1.5 py-0",children:e.length})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),e.map(e=>a.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.userEmail}),a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:Jh(e.dateEdited||e.dateCreation)}),e.dateEdited&&a.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),x===e.id?a.jsxs("div",{className:"space-y-2",children:[a.jsx(Js,{value:g,onChange:e=>v(e.target.value),maxLength:l,rows:3}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:b,disabled:p,children:"Cancelar"}),a.jsx(Xt,{size:"sm",onClick:()=>(async e=>{if(g.trim()&&n){h(!0);try{await n({...e,text:g,stringText:g}),f(null),v("")}finally{h(!1)}}})(e),disabled:!g.trim()||p,children:p?"Salvando...":"Salvar"})]})]}):a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.stringText||e.text})]}),!i&&s===e.userId&&x!==e.id&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&a.jsx(hr,{onClick:()=>(e=>{f(e.id),v(e.stringText||e.text)})(e),children:c("edit")}),o&&a.jsx(hr,{className:"text-destructive",onClick:()=>(async e=>{if(o){h(!0);try{await o(e)}finally{h(!1)}}})(e.id),children:"Excluir"})]})]})]},e.id))]})]})}function Jh(e){const{t:a}=y.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function Zh({history:e=[],isLoading:t=!1}){const{t:s}=y.useTranslation();return t?a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===e.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:s("ap_no_history")})]}):a.jsx("div",{className:"p-1",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),a.jsx("div",{className:"space-y-0",children:e.map((e,t)=>a.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[a.jsx("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:e.icon?a.jsx("span",{className:"text-xs text-primary",children:e.icon}):a.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium",children:e.translateEvent||e.eventName}),e.eventDescription&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.eventDescription})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-xs font-medium truncate block",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:e.userEmail})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Calendar,{className:"h-3 w-3"}),a.jsx("span",{children:ex(e.date)})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),a.jsx("span",{children:ax(e.date)})]}),e.isMobileRequest&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Smartphone,{className:"h-3 w-3"}),a.jsx("span",{children:s("ap_via_app")})]})]})]})]},e.id))})]})})}function ex(e){const{t:a}=y.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function ax(e){const{t:a}=y.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function tx({attachments:e=[],onUpload:s,onDelete:r,onRename:n,onDownload:o,onView:i,disabled:l=!1}){const{t:c}=y.useTranslation(),u=t.useRef(null),[m,p]=t.useState(null),[h,x]=t.useState(""),f=async e=>{h.trim()&&n&&(await n(e.id,h),p(null),x(""))},g=()=>{p(null),x("")};return a.jsxs("div",{className:"space-y-4 p-1",children:[!l&&s&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&s){for(let e=0;e<a.length;e++){const t=a.item(e);t&&s(t)}u.current&&(u.current.value="")}}}),a.jsxs(Xt,{size:"sm",onClick:()=>u.current?.click(),children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-lg border bg-card p-3",e.status===exports.EAttachmentItemStatus.error&&"border-destructive/50 bg-destructive/5",e.status===exports.EAttachmentItemStatus.canceled&&"opacity-50"),children:[a.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:a.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:e.extension.replace(".","").substring(0,4)})}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[m===e.id?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:h,onChange:e=>x(e.target.value),onKeyDown:a=>{"Enter"===a.key&&f(e),"Escape"===a.key&&g()},autoFocus:!0}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:g,children:c("cancel")}),a.jsx(Xt,{size:"sm",onClick:()=>f(e),children:c("save")})]}):a.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>i?.(e.id),children:e.name}),(e.status===exports.EAttachmentItemStatus.uploading||e.status===exports.EAttachmentItemStatus.waiting)&&a.jsx(gd,{value:e.progress||0,className:"h-1.5"}),e.status===exports.EAttachmentItemStatus.error&&a.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),e.status===exports.EAttachmentItemStatus.duplicateItem&&a.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),e.status===exports.EAttachmentItemStatus.canceled&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[e.status===exports.EAttachmentItemStatus.done&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:sx(e.size)}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&!l&&a.jsx(hr,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");p(e.id),x(a)})(e),children:"Renomear"}),i&&a.jsx(hr,{onClick:()=>i(e.id),children:"Visualizar"}),o&&a.jsx(hr,{onClick:()=>o(e.id),children:"Download"}),r&&!l&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsx(hr,{className:"text-destructive",onClick:()=>r(e.id),children:"Excluir"})]})]})]})]}),e.status===exports.EAttachmentItemStatus.uploading&&a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>r?.(e.id),children:"Cancelar"})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function sx(e){const{t:a}=y.useTranslation();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}const rx=["application/x-msdownload","application/x-msdos-program","application/x-executable","application/x-javascript","application/javascript","text/javascript","text/vbscript","application/sql","application/x-sh","application/x-shellscript","application/hta","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12"];function nx(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const a=e/1024;if(a<1024)return`${Math.round(a)} KB`;const t=a/1024;if(t<1024)return`${Math.round(t)} MB`;const s=t/1024;return Math.round(100*s)/100+" GB"}function ox(e){const a=e.lastIndexOf(".");return-1===a?"":e.substring(a+1).toLowerCase()}var ix,lx,dx;function cx(e){switch(e.type){case exports.ECustomFormFieldType.text:return e.textValue;case exports.ECustomFormFieldType.number:return e.numberValue;case exports.ECustomFormFieldType.date:return e.dateValue;case exports.ECustomFormFieldType.time:return e.timeValue;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:return e.itemsValue;case exports.ECustomFormFieldType.questions:return e.questionsValue;case exports.ECustomFormFieldType.readOnlyText:return e.textValue;default:return null}}function ux(e,a){if(!a)return!0;const t=null!=cx(e)&&""!==cx(e)&&!(Array.isArray(cx(e))&&0===cx(e).length);return!1!==e.isActive||t}function mx({field:e}){return a.jsxs("div",{className:"space-y-1",children:[e.name&&a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function px({field:e,readOnly:t,onChange:s}){const r=e.config,n=r?.multiline??!1,o=t||e.readOnly,i=a=>{s?.({...e,textValue:a})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?a.jsx(Js,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):a.jsx(Zt,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function hx({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"date",value:n,onChange:a=>{return t=a.target.value,void s?.({...e,dateValue:t||void 0});var t},placeholder:e.placeholder,disabled:r})]})}function xx({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e=>{if(!e)return;const[a,t]=e.split(":").map(Number);return 60*a+t};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"time",value:(e=>{if(null==e)return"";const a=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`})(e.timeValue),onChange:a=>s?.({...e,timeValue:n(a.target.value)}),placeholder:e.placeholder,disabled:r})]})}function fx({field:e,readOnly:s,onChange:r}){const n=e.config,o=n?.multiple??!1,i=s||e.readOnly,[l,c]=t.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const a={value:crypto.randomUUID(),text:l.trim()};r?.({...e,itemsValue:[...u,a]}),c("")};if(!o){const t=u[0]?.text||"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:t,onChange:a=>(a=>{const t={value:a,text:a};r?.({...e,itemsValue:a?[t]:[]})})(a.target.value),placeholder:e.placeholder||"https://",disabled:i}),t&&a.jsx(Xt,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:a.jsx(d.ExternalLink,{className:"h-4 w-4"})})})]})]})}return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:l,onChange:e=>c(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),a.jsx(Xt,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:a.jsx(d.Plus,{className:"h-4 w-4"})})]}),u.length>0&&a.jsx("div",{className:"space-y-1",children:u.map((t,s)=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("a",{href:t.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:t.text}),!i&&a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(a=>{const t=u.filter((e,t)=>t!==a);r?.({...e,itemsValue:t})})(s),children:a.jsx(d.Trash2,{className:"h-3 w-3"})})]},t.value))})]})}function gx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=null!=r?.decimals&&r.decimals>0?(1/Math.pow(10,r.decimals)).toString():"1";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"number",value:e.numberValue??"",onChange:a=>(a=>{if(""===a)return void s?.({...e,numberValue:void 0});const t=parseFloat(a);isNaN(t)||s?.({...e,numberValue:t})})(a.target.value),placeholder:e.placeholder,disabled:n,min:r?.min,max:r?.max,step:o}),null!=r?.min&&null!=r?.max&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",r.min," | Max: ",r.max]})]})}function vx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=e.itemsValue?.[0]?.value||"",d=a=>{const t=i.find(e=>e.value===a);if(!t)return;const r={value:t.value,text:t.text,isActive:t.isActive};s?.({...e,itemsValue:[r]})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===exports.EFieldViewMode.dropdown&&a.jsxs(Vs,{value:l,onValueChange:d,disabled:n,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.placeholder||"Selecione..."})}),a.jsx(Gs,{children:i.map(e=>a.jsxs(Ks,{value:e.value,children:[e.text,!1===e.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===exports.EFieldViewMode.radio||o===exports.EFieldViewMode.buttons)&&a.jsx(vd,{value:l,onValueChange:d,disabled:n,className:Yt(o===exports.EFieldViewMode.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bd,{value:t.value,id:`${e.id}-${t.value}`}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))}),!n&&l&&!e.required&&a.jsx("button",{type:"button",onClick:()=>{s?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function bx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(t=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[a.jsx("span",{className:"text-xs",children:t.text}),!n&&a.jsx("button",{type:"button",onClick:()=>(a=>{const t=(e.itemsValue||[]).filter(e=>e.value!==a);s?.({...e,itemsValue:t})})(t.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:a.jsx(d.X,{className:"h-3 w-3"})})]},t.value))}),!n&&a.jsx("div",{className:Yt(o===exports.EFieldViewMode.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:`${e.id}-${t.value}`,checked:l.has(t.value),onCheckedChange:()=>(a=>{const t=e.itemsValue||[],r=t.some(e=>e.value===a.value)?t.filter(e=>e.value!==a.value):[...t,{value:a.value,text:a.text,isActive:a.isActive}];s?.({...e,itemsValue:r})})(t),disabled:n}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))})]})}function yx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.questions||[],i=r?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.name}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Yt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx("div",{className:"border rounded-md overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50",children:[a.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>a.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),a.jsx("tbody",{children:o.map((t,r)=>a.jsxs("tr",{className:Yt(r<o.length-1&&"border-b"),children:[a.jsx("td",{className:"p-2 text-muted-foreground",children:t.text}),i.map(r=>{return a.jsx("td",{className:"text-center p-2",children:a.jsx(vd,{value:(o=t.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:a=>((a,t,r,n)=>{const o={questionValue:a,questionText:t,optionValue:r,optionText:n},i=l.filter(e=>e.questionValue!==a);i.push(o),s?.({...e,questionsValue:i})})(t.value,t.text,a,r.text),disabled:n,className:"flex justify-center",children:a.jsx(bd,{value:r.value,id:`${e.id}-${t.value}-${r.value}`})})},r.value);var o})]},t.value))})]})})]})}function jx({field:e,readOnly:t,onChange:s}){const r={field:e,readOnly:t,onChange:s};switch(e.type){case exports.ECustomFormFieldType.readOnlyText:return a.jsx(mx,{...r});case exports.ECustomFormFieldType.text:return a.jsx(px,{...r});case exports.ECustomFormFieldType.date:return a.jsx(hx,{...r});case exports.ECustomFormFieldType.time:return a.jsx(xx,{...r});case exports.ECustomFormFieldType.url:return a.jsx(fx,{...r});case exports.ECustomFormFieldType.number:return a.jsx(gx,{...r});case exports.ECustomFormFieldType.singleSelection:return a.jsx(vx,{...r});case exports.ECustomFormFieldType.multiSelection:return a.jsx(bx,{...r});case exports.ECustomFormFieldType.questions:return a.jsx(yx,{...r});default:return null}}function wx({queryParams:e,events:s,softwares:r,users:n=[],permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},isLoading:i=!1,onFilter:l,onReset:c,onExport:u,onSoftwareChange:m}){const[p,h]=t.useState(e.softwareId),[x,f]=t.useState(e.eventId),[g,v]=t.useState(e.userId||"all"),[b,y]=t.useState(Nx(e.startDate)),[j,w]=t.useState(Nx(e.endDate)),N=t.useCallback(e=>{const a=parseInt(e);h(a),m?.(a)},[m]),_=t.useCallback(()=>{l({...e,softwareId:p,eventId:x,userId:"all"===g?void 0:g,startDate:new Date(b),endDate:new Date(j),software:r.find(e=>e.id===p)?.software||e.software,event:s.find(e=>e.id===x)?.name||e.event})},[e,p,x,g,b,j,r,s,l]),C=t.useCallback(()=>{const a=new Date;a.setHours(0,0,0,0),y(Nx(a)),w(Nx(a)),f(e.eventId),o.viewAllEvents&&v("all"),c?.()},[e.eventId,o.viewAllEvents,c]),k=o.viewOnlyMyEvents&&!o.viewAllEvents,S=p&&x&&b&&j;return a.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsxs("div",{className:"flex flex-col gap-1 min-w-[180px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Módulo *"}),a.jsxs(Vs,{value:String(p),onValueChange:N,disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Ks,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Evento *"}),a.jsxs(Vs,{value:String(x),onValueChange:e=>f(parseInt(e)),disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:s.map(e=>a.jsx(Ks,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Usuário *"}),a.jsxs(Vs,{value:g,onValueChange:v,disabled:i||k,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"all",className:"text-xs",children:"Todos"}),n.map(e=>a.jsx(Ks,{value:e.id,className:"text-xs",children:e.name},e.id))]})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"De *"}),a.jsx(Zt,{type:"date",value:b,onChange:e=>y(e.target.value),className:"h-8 text-xs",max:j,disabled:i})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Até *"}),a.jsx(Zt,{type:"date",value:j,onChange:e=>w(e.target.value),className:"h-8 text-xs",min:b,disabled:i})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsxs(Xt,{variant:"outline",size:"sm",onClick:C,disabled:i,children:[a.jsx(d.RotateCcw,{className:"h-3.5 w-3.5 mr-1"}),"Limpar"]}),o.download&&u&&a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>u("xlsx"),disabled:i,children:[a.jsx(d.Download,{className:"h-3.5 w-3.5 mr-1"}),"Exportar"]}),a.jsxs(Xt,{size:"sm",onClick:_,disabled:i||!S,children:[a.jsx(d.Filter,{className:"h-3.5 w-3.5 mr-1"}),"Filtrar"]})]})]})}function Nx(e){return(e instanceof Date?e:new Date(e)).toISOString().split("T")[0]}function _x(e,a,t,s="Anônimo"){return e.map(e=>({...e,translatedSoftware:kx(e.software,t),user:e.userEmail||e.userName||s,translatedEvent:Cx(e.eventName,a),date:new Date(e.dateTime)})).sort((e,a)=>(a.date?.getTime()??0)-(e.date?.getTime()??0))}function Cx(e,a){const t=a.find(a=>a.name===e);return t?.translation||e}function kx(e,a){const t=e.includes(".")?e.split(".").pop():e,s=a.find(e=>e.software===t);return s?.translation||t}function Sx(e,a){const t=[],s={...Mx,...a?.labels},r=e.eventName;t.push({name:s.event,value:r});const n=e.entities?.[0];if(n&&(t.push({name:s.entityName,value:Tx(n)}),n.description&&t.push({name:s.description,value:n.description}),n.justification&&t.push({name:s.justification,value:n.justification}),n.statusName&&t.push({name:s.status,value:n.statusName}),n.equipmentType&&t.push({name:s.type,value:n.equipmentType}),n.extra?.length)){[...new Set(n.extra.map(e=>e.property))].forEach(e=>{const a=n.extra.filter(a=>a.property===e).map(e=>e.value||"").join(", ");t.push({name:Ax(e),value:a})})}e.entities?.forEach(e=>{e.data?.forEach(e=>{if("Removed"===e.property)return;if(""===e.newValue&&!e.tagTranslate)return;const n=Px(e,r,a?.translateProperty),o=Dx(e,null,r,s,a);o&&t.push({name:n,value:o})})}),e.entities?.forEach(e=>{if(e.association?.length){const a=e.association.filter(e=>""!==e.id).map(e=>{const a=Tx(e);return`(${e.softwareName||e.type}) ${a}`});a.length&&t.push({name:s.references,value:a.join(", ")})}}),n?.isElectronicSigned&&t.push({name:s.security,value:"🛡️ "+s.electronicSigned}),t.push({name:s.accomplishedBy,value:e.userName?`${e.userName} (${e.userEmail})`:e.userEmail});const o=a?.formatDate?a.formatDate(e.dateTime):Ix(e.dateTime);return t.push({name:s.accomplishedIn,value:o}),t}function Tx(e){return e.code&&e.name&&e.code!==e.name?`${e.code} ${e.name}`:e.name||e.code||""}function Px(e,a,t){if(e.propertyCustomName)return e.propertyCustomName;const s=Ax(e.property);return t?t(a,s):s}function Dx(e,a,t,s,r){if(e.propertyResource||(e.propertyResource=a?`${a.propertyResource}.${e.property}`:e.property),e.children?.length){if(e.newValue){const a=Px(e,t,r?.translateProperty),n=function(e,a){switch(e.state){case"Added":return a.stateAdded;case"Modified":return e.children?.some(e=>"Removed"===e.property)?a.stateRemoved:a.stateModified;default:return""}}(e,s);let o=`${a}: "${Ex(e,"newValue",s,r)}" ${n}`;const i=e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,Dx(a,e,t,s,r)));return i.some(Boolean)&&(o+="\n"+i.filter(Boolean).join("\n")),o}return e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,Dx(a,e,t,s,r))).filter(Boolean).join("\n")}if("Removed"===e.property)return"";if("Modified"===e.state){const n=Ex(e,"oldValue",s,r),o=Ex(e,"newValue",s,r);return`${a?Px(e,t,r?.translateProperty)+": ":""}${s.changedFrom} "${n}" ${s.changedTo} "${o}"`}const n=Ex(e,"newValue",s,r);return a?`${Px(e,t,r?.translateProperty)}: ${n}`:n}function Ex(e,a,t,s){const r=e[a];return null==r||""===r?"Modified"===e.state||"Added"===e.state||"Unchanged"===e.state?t.uninformed:"":"string"==typeof r&&function(e){if("string"!=typeof e)return!1;if(!/^\d{4}[-/]\d{2}[-/]\d{2}/.test(e))return!1;const a=new Date(e);return!isNaN(a.getTime())}(r)?s?.formatDate?s.formatDate(r):Ix(r):String(r)}function Ax(e){return e.replace(/([A-Z])/g,(e,a,t)=>`${t>0?"-":""}${a.toLowerCase()}`)}function Ix(e){try{return new Date(e).toLocaleString()}catch{return e}}exports.ECustomFormFieldType=void 0,(ix=exports.ECustomFormFieldType||(exports.ECustomFormFieldType={}))[ix.readOnlyText=1]="readOnlyText",ix[ix.text=2]="text",ix[ix.date=3]="date",ix[ix.time=4]="time",ix[ix.url=5]="url",ix[ix.number=6]="number",ix[ix.singleSelection=7]="singleSelection",ix[ix.multiSelection=8]="multiSelection",ix[ix.questions=9]="questions",exports.EFieldViewMode=void 0,(lx=exports.EFieldViewMode||(exports.EFieldViewMode={}))[lx.dropdown=1]="dropdown",lx[lx.buttons=2]="buttons",lx[lx.radio=3]="radio",lx[lx.checkbox=4]="checkbox",exports.ESelectionFieldDataSource=void 0,(dx=exports.ESelectionFieldDataSource||(exports.ESelectionFieldDataSource={}))[dx.custom=1]="custom",dx[dx.users=2]="users",dx[dx.usersLists=3]="usersLists";const Mx={event:"Evento",entityName:"Item",description:e.t("audit_description"),justification:"Justificativa",status:"Status",type:"Tipo",references:e.t("audit_references"),security:e.t("audit_security"),electronicSigned:e.t("audit_esign"),accomplishedBy:"Realizado por",accomplishedIn:"Realizado em",changedFrom:"de",changedTo:"para",uninformed:e.t("audit_not_informed"),stateAdded:"(adicionado)",stateModified:"(modificado)",stateRemoved:"(removido)"};function Fx({documentId:e,onFetchDetails:s,onClose:r,labels:n,translateProperty:o,translatePropertyValue:i,formatDate:l}){const[c,u]=t.useState(!1),[m,p]=t.useState([]),[h,x]=t.useState(null),f=t.useCallback(async e=>{u(!0),x(null);try{const a=Sx(await s(e),{translateProperty:o,translatePropertyValue:i,formatDate:l,labels:n});p(a)}catch(a){x("Erro ao carregar detalhes da trilha de auditoria."),p([])}finally{u(!1)}},[s,o,i,l,n]);return t.useEffect(()=>{e&&f(e)},[e,f]),e?a.jsxs("div",{className:"flex flex-col h-full bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Detalhes da Auditoria"}),a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:c?a.jsxs("div",{className:"flex items-center justify-center p-6",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando detalhes..."})]}):h?a.jsx("div",{className:"p-6 text-sm text-destructive",children:h}):a.jsx("table",{className:"w-full text-xs",children:a.jsx("tbody",{children:m.map((e,t)=>a.jsxs("tr",{className:t%2==0?"bg-background":"bg-muted/20",children:[a.jsx("td",{className:"px-4 py-2.5 font-semibold text-foreground whitespace-nowrap align-top w-[180px] border-b border-border/50",children:e.name}),a.jsx("td",{className:"px-4 py-2.5 text-muted-foreground break-words border-b border-border/50",children:a.jsx("span",{dangerouslySetInnerHTML:{__html:e.value.replace(/\n/g,"<br />")}})})]},t))})})})]}):null}function Rx({open:s,onOpenChange:r,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:d=[],setDefaultApproverOnInit:c=!0,onSubmit:u}){const[m,p]=t.useState(!0),[h,x]=t.useState(c&&n.length>0?n[0].id:null),[f,g]=t.useState(o),v=e=>{p(e),e&&!c?x(null):!e&&!c&&n.length>0&&x(n[0].id)},b=f!==o||!m;return a.jsx(ys,{open:s,onOpenChange:r,children:a.jsxs(ks,{className:"sm:max-w-[480px]",variant:"form",isDirty:b,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:i})}),a.jsxs("div",{className:"space-y-4",children:[d.length>0&&a.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:d.map((e,t)=>a.jsx("p",{dangerouslySetInnerHTML:{__html:e}},t))}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>v(!0),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>v(!1),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:"Etapa"}),a.jsxs(Vs,{value:h??void 0,onValueChange:x,disabled:m,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.t("approval_select_step")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ks,{value:e.id,children:e.name},e.id))})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.t("approval_opinion")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!f.trim())return void l.toast.error("Formulário inválido. Preencha todos os campos obrigatórios.");const e=m?null:n.find(e=>e.id===h);u({approved:m,returnStepId:m?null:h,returnType:e?.type??null,observation:f})},disabled:!b,children:"Concluir"})]})]})})}function Lx({open:e,onOpenChange:s,approvers:r,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=y.useTranslation(),[d,c]=t.useState(null),u=t.useMemo(()=>{const e=new Set(o);return r.filter(a=>!e.has(a.id))},[r,o]),m=t.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!d,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:l("approval_select_approver")})}),a.jsx(sr,{isLoading:n,type:"spinner",children:a.jsx("div",{className:"space-y-4",children:a.jsx(Ur,{options:m,value:d??void 0,onValueChange:e=>c("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!d)return;const e=u.find(e=>e.id===d);e&&i(e)},disabled:!d||n,children:"Concluir"})]})]})})}function zx(e){const{t:a}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function Ux({text:e,maxLength:s=130}){const{t:r}=y.useTranslation(),[n,o]=t.useState(!1);return e.length<=s?a.jsx("span",{children:e}):a.jsxs("span",{children:[n?e:`${e.substring(0,s)}... `,a.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:r(n?"approval_read_less":"approval_read_more")})]})}function Ox({approver:e}){if(1===e.type&&e.approverId)return a.jsxs(ol,{className:"h-9 w-9 shrink-0",children:[a.jsx(il,{src:e.photoUrl,alt:e.name}),a.jsx(ll,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const t=2===e.type?d.Users:3===e.type?d.MapPin:d.User;return a.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:a.jsx(t,{className:"h-4 w-4 text-background"})})}function Vx({approver:e}){return e.date?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[a.jsx(d.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:zx(e.date)}),1!==e.type&&e.approvedUsername&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[a.jsx(d.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:zx(e.returnDate)})]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function Bx({approver:e}){const{t:t}=y.useTranslation(),s=1!==e.type||e.approverId?e.name:"A definir";return a.jsxs("div",{children:[2===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:t("approval_user_group")}),3===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),a.jsx("p",{className:"text-sm font-medium break-words",children:s}),a.jsx(Vx,{approver:e})]})}var qx;exports.ApprovalFlowReturnStep=void 0,(qx=exports.ApprovalFlowReturnStep||(exports.ApprovalFlowReturnStep={}))[qx.ApprovalFlow=1]="ApprovalFlow",qx[qx.Association=2]="Association",exports.i18n=e,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return y.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return y.useTranslation}}),exports.AUTH_CONFIG=Me,exports.AccessDeniedDialog=Ki,exports.Accordion=tl,exports.AccordionContent=nl,exports.AccordionItem=sl,exports.AccordionTrigger=rl,exports.ActionButton=Jt,exports.ActionMenu=Jt,exports.ActionMenuItems=lo,exports.ActionPlanAttachmentsTab=tx,exports.ActionPlanCommentsTab=Xh,exports.ActionPlanCostTab=Qh,exports.ActionPlanGeneralTab=Oh,exports.ActionPlanHistoryTab=Zh,exports.ActionPlanPage=function(e){const{formData:t,isLoading:s,isSaving:r,activeTab:n,isFormDisabled:o,updateField:i,setActiveTab:l,save:c,changeStatus:u,remove:m,cancel:p}=Lh(e),{t:h}=y.useTranslation(),{isNew:x=!1,config:f,users:g,places:v,actionTypes:b,causes:j,parentActions:w,progress:N,predecessors:_,availablePredecessors:C,costs:k,comments:S,history:T,attachments:P,attachmentsSlot:D,commentsSlot:E,historySlot:A,onAddPredecessor:I,onRemovePredecessor:M,onAddCost:F,onEditCost:R,onDeleteCost:L,onAddComment:z,onEditComment:U,onDeleteComment:O,onUploadAttachment:V,onDeleteAttachment:B,onRenameAttachment:q,onDownloadAttachment:$,onViewAttachment:W}=e;if(s&&!t.id)return a.jsx(sr,{isLoading:!0,children:a.jsx("div",{})});const H=function(e){const{t:a}=y.useTranslation();if(!e)return[];return{[exports.ETaskPlanStatus.waitingStart]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.running]:[exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.effectivenessCheck]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.done]:[exports.ETaskPlanStatus.running],[exports.ETaskPlanStatus.suspended]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.canceled]:[exports.ETaskPlanStatus.waitingStart]}[e]||[]}(t.statusId);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[p&&a.jsx(Xt,{variant:"ghost",size:"icon",onClick:p,children:a.jsx(d.ArrowLeft,{className:"h-4 w-4"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:x?h("ap_new_action"):t.name||h("ap_action_plan")}),!x&&t.statusId&&a.jsx(Uh,{status:t.statusId})]}),t.code&&a.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:t.code})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!x&&H.length>0&&!o&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"sm",children:"Alterar Status"})}),a.jsx(pr,{align:"end",children:H.map(e=>a.jsx(hr,{onClick:()=>u(e),children:Ah[e]},e))})]}),!x&&e.onDelete&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",children:a.jsx(d.MoreVertical,{className:"h-4 w-4"})})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:m,children:"Excluir"})})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a.jsxs(ji,{value:n,onValueChange:l,children:[a.jsxs(wi,{className:"mb-6",children:[a.jsx(Ni,{value:"general",children:"Geral"}),!x&&a.jsx(Ni,{value:"progress",children:"Progresso"}),!x&&f?.enablePredecessors&&a.jsx(Ni,{value:"predecessors",children:h("ap_predecessors")}),!x&&f?.enableCosts&&a.jsx(Ni,{value:"costs",children:"Custos"}),!x&&f?.enableAttachments&&a.jsx(Ni,{value:"attachments",children:h("ap_attachments")}),!x&&f?.enableComments&&a.jsx(Ni,{value:"comments",children:h("ap_comments")}),!x&&f?.enableHistory&&a.jsx(Ni,{value:"history",children:"Histórico"})]}),a.jsx(_i,{value:"general",children:a.jsx(Oh,{formData:t,updateField:i,disabled:o,users:g,places:v,actionTypes:b,causes:j,parentActions:w,config:f})}),!x&&a.jsx(_i,{value:"progress",children:a.jsx(Gh,{...e})}),!x&&f?.enablePredecessors&&a.jsx(_i,{value:"predecessors",children:a.jsx(Kh,{predecessors:_,availablePredecessors:C,onAdd:I,onRemove:M,disabled:o})}),!x&&f?.enableCosts&&a.jsx(_i,{value:"costs",children:a.jsx(Qh,{costs:k,onAdd:F,onEdit:R,onDelete:L,disabled:o})}),!x&&f?.enableAttachments&&a.jsx(_i,{value:"attachments",children:D||a.jsx(tx,{attachments:P,onUpload:V,onDelete:B,onRename:q,onDownload:$,onView:W,disabled:o})}),!x&&f?.enableComments&&a.jsx(_i,{value:"comments",children:E||a.jsx(Xh,{comments:S,onAdd:z,onEdit:U,onDelete:O,disabled:o})}),!x&&f?.enableHistory&&a.jsx(_i,{value:"history",children:A||a.jsx(Zh,{history:T})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&a.jsx(Xt,{variant:"outline",onClick:p,disabled:r,children:"Cancelar"}),a.jsx(Xt,{onClick:c,disabled:r||o,children:r?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=Kh,exports.ActionPlanProgressDialog=Hh,exports.ActionPlanProgressTab=Gh,exports.ActionPlanStatusBadge=Uh,exports.Alert=Jo,exports.AlertDescription=ei,exports.AlertDialog=ds,exports.AlertDialogAction=vs,exports.AlertDialogCancel=bs,exports.AlertDialogContent=ps,exports.AlertDialogDescription=gs,exports.AlertDialogFooter=xs,exports.AlertDialogHeader=hs,exports.AlertDialogOverlay=ms,exports.AlertDialogPortal=us,exports.AlertDialogTitle=fs,exports.AlertDialogTrigger=cs,exports.AlertTitle=Zo,exports.AliasRedirect=function(){const{alias:e}=Pn(),{pathname:t,search:s,hash:r}=N.useLocation();return e?a.jsx(N.Navigate,{to:`/${e}${t}${s}${r}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:s="alias"}){const r=N.useNavigate(),n=N.useLocation(),o=N.useParams(),{alias:i,isAuthenticated:l,isLoading:d,switchUnit:c}=Pn(),{urlAlias:u,isAliasMismatch:m,isValidAlias:p,isMissing:h,matchedCompany:x}=Ko({paramName:s}),[f,g]=t.useState(!1),v=t.useRef(!1),b=s in o,y=t.useCallback(e=>{const a=o[s],{pathname:t,search:r,hash:i}=n;if(a){const s=t.split("/"),n=s.findIndex(e=>e===a);if(n>=0)return s[n]=e,s.join("/")+r+i}return`/${e}${"/"===t?"":t}${r}${i}`},[o,s,n]);return t.useEffect(()=>{if(b&&!d&&l&&i&&!v.current)if(h)r(y(i),{replace:!0});else if(!u||p){if(m&&x&&!v.current){(async()=>{v.current=!0,g(!0);try{await c(x)}catch(e){i&&r(y(i),{replace:!0})}finally{v.current=!1,g(!1)}})()}}else r(y(i),{replace:!0})},[b,d,l,i,h,u,p,m,x,c,y,r]),d||!l?a.jsx(a.Fragment,{children:e}):f?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(tr,{size:"lg"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):a.jsx(a.Fragment,{children:e})},exports.AppHeader=Cp,exports.AppLayout=Mp,exports.AppSidebar=Ip,exports.ApprovalSidenav=function({config:e,isLoading:s=!1,onClose:r,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:c=!1}){const{t:u}=y.useTranslation(),[m,p]=t.useState(!1),[h,x]=t.useState(!1),[f,g]=t.useState(""),[v,b]=t.useState(""),[j,w]=t.useState(!1),[N,_]=t.useState(""),C=s||m,k=t.useCallback((e,a)=>{g(e),b(a??""),x(!0)},[]),S=t.useCallback(async a=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...a}))return k(f,a.observation),void p(!1);r(),p(!1)},[e.associationId,f,n,r,k]),T=t.useCallback(e=>{_(e),w(!0)},[]),P=t.useCallback(async a=>{w(!1),p(!0),await o(e.associationId,N,a),await(i?.(e.associationId)),p(!1)},[e.associationId,N,o,i]),D=e.approvalFlowSteps.find(e=>e.isCurrentStep)?.approvers.filter(e=>1===e.type&&e.approverId).map(e=>e.approverId)??[],E=(a,t)=>e.canApprove&&a.isCurrentStep&&t.approverId&&!t.date&&t.canApprove,A=(a,t)=>!e.flowReproved&&a.isCurrentStep&&1===t.type&&t.canApprove&&(!t.approverId||t.isToBeDefined);return a.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[a.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[a.jsx(Xt,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0",children:a.jsx(d.X,{className:"h-5 w-5"})}),a.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?a.jsx(sr,{isLoading:!0,type:"spinner",className:"flex-1",children:a.jsx("div",{})}):a.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&a.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,t)=>a.jsx("div",{className:Yt("flex items-center gap-1.5 text-sm",e.color&&"rounded-lg px-2 py-1"),style:e.color?{color:e.color,backgroundColor:e.backgroundColor}:void 0,children:e.title?`${e.title}: ${e.value}`:e.value},t))}),a.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(t=>a.jsxs("div",{className:Yt("space-y-2",(!t.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[a.jsxs("p",{className:"font-semibold text-sm",children:[t.index,". Etapa: ",t.name]}),t.description&&a.jsx("p",{className:"text-sm text-muted-foreground break-words",children:a.jsx(Ux,{text:t.description})}),t.returnDate&&a.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.returnUserName," em ",zx(t.returnDate)]})]}),t.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:a.jsx(Ux,{text:t.returnObservation})})]}),t.approvers.map(e=>a.jsxs("div",{className:"p-2 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx(Ox,{approver:e}),a.jsx(Bx,{approver:e})]}),E(t,e)&&a.jsx(Xt,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),A(t,e)&&a.jsx(Xt,{size:"sm",variant:"outline",onClick:()=>T(e.id),children:"Selecionar"})]}),e.observation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Ux,{text:e.observation})}),e.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Ux,{text:e.returnObservation})})]},e.id))]},t.id))]}),a.jsx(Rx,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:v,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),a.jsx(Lx,{open:j,onOpenChange:w,approvers:l,isLoading:c,ignoreUserIds:D,onSubmit:P})]})},exports.ApproveDialog=Rx,exports.AuditTrailDetails=Fx,exports.AuditTrailFilter=wx,exports.AuditTrailPage=function({title:s,softwares:r,softwareId:n,permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},callbacks:i,limit:l=2e3,currentUserId:c,labels:u,formatDate:m,anonymousLabel:p=e.t("anonymous")}){const{t:h}=y.useTranslation();s??h("audit_trail");const[x,f]=t.useState(!0),[g,v]=t.useState([]),[b,j]=t.useState([]),[w,N]=t.useState([]),[_,C]=t.useState(null),[k,S]=t.useState(!1),T=t.useRef(null),P=new Date;P.setHours(0,0,0,0);const[D,E]=t.useState({software:r.find(e=>e.id===n)?.software||"",softwareId:n,event:"All",eventId:1,startDate:P,endDate:P,limit:l,softwares:r,userId:o.viewOnlyMyEvents&&!o.viewAllEvents?c:void 0});t.useEffect(()=>{(async()=>{f(!0);try{const[e,a]=await Promise.all([i.onFetchEvents(D.softwareId),i.onFetchUsers?.()??Promise.resolve([])]);j(e),N(a),await A(D,e)}catch(e){}finally{f(!1)}})()},[]);const A=t.useCallback(async(e,a)=>{try{const t=_x((await i.onFetchTrails(e)).data,a||b,r,p);v(t)}catch(t){}},[i,b,r,p]),I=t.useCallback(async e=>{f(!0),E(e);try{await A(e)}finally{f(!1)}},[A]),M=t.useCallback(async e=>{try{const a=await i.onFetchEvents(e);j(a)}catch(a){}},[i]),F=t.useCallback(e=>{C(e.documentId),S(!0)},[]),R=t.useCallback(()=>{S(!1),C(null)},[]),L=t.useCallback(async()=>{const e={...D,startDate:P,endDate:P,eventId:1,userId:o.viewAllEvents?void 0:c};E(e),f(!0);try{await A(e)}finally{f(!1)}},[D,A]),z=t.useCallback(e=>{i.onExport?.(e,g)},[i,g]),U=t.useCallback(e=>{try{return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}},[]);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"p-3",children:a.jsx(wx,{queryParams:D,events:b,softwares:r,users:w,permissions:o,isLoading:x,onFilter:I,onReset:L,onExport:o.download?z:void 0,onSoftwareChange:M})}),a.jsxs("div",{className:"flex flex-1 min-h-0 relative",children:[a.jsxs("div",{className:Yt("flex-1 overflow-auto transition-all duration-300",k?"mr-[400px]":""),children:[x?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando trilha de auditoria..."})]}):0===g.length?a.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground",children:[a.jsx(d.FileText,{className:"h-12 w-12 mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"Nenhum registro encontrado"}),a.jsx("p",{className:"text-xs mt-1",children:"Ajuste os filtros e tente novamente"})]}):a.jsxs("table",{className:"w-full text-xs border-collapse",children:[a.jsx("thead",{className:"sticky top-0 z-10",children:a.jsxs("tr",{className:"bg-muted/60 border-b border-border",children:[a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Layers,{className:"h-3 w-3"}),"Módulo"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),"Data"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.User,{className:"h-3 w-3"}),"Usuário"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.FileText,{className:"h-3 w-3"}),"Evento"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"px-3 py-2 w-10"})]})}),a.jsx("tbody",{children:g.map((e,t)=>a.jsxs("tr",{onClick:()=>F(e),className:Yt("cursor-pointer border-b border-border/50 transition-colors","hover:bg-accent/50",_===e.documentId&&"bg-accent",t%2==0?"bg-background":"bg-muted/10"),children:[a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedSoftware}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",children:e.date?U(e.date.toISOString()):"—"}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.user}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedEvent}),a.jsx("td",{className:"px-3 py-2 text-foreground truncate max-w-[200px]",title:e.entityName,children:e.entityName}),a.jsx("td",{className:"px-3 py-2",children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.documentId||t))})]}),!x&&g.length>0&&a.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border bg-muted/20",children:[g.length," registro",1!==g.length?"s":""]})]}),a.jsx("div",{ref:T,className:Yt("fixed right-0 top-0 h-full w-[400px] border-l border-border bg-background shadow-lg z-30","transition-transform duration-300 ease-in-out",k?"translate-x-0":"translate-x-full"),children:k&&a.jsx(Fx,{documentId:_,onFetchDetails:i.onFetchDetails,onClose:R,labels:u,translateProperty:i.translateProperty,translatePropertyValue:i.translatePropertyValue,formatDate:m||U})})]})]})},exports.AuthErrorInterceptor=cn,exports.AuthProvider=Tn,exports.AuthService=_n,exports.AutoComplete=Ur,exports.Avatar=ol,exports.AvatarFallback=ll,exports.AvatarImage=il,exports.Badge=er,exports.BaseForm=zo,exports.Blockquote=Zl,exports.BodyContent=function({breadcrumbs:e,children:t,className:s}){return a.jsxs("div",{className:Yt("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[e&&e.length>0&&a.jsx(dl,{className:"mb-4",children:a.jsx(cl,{children:e.map((t,s)=>{const r=s===e.length-1;return a.jsxs(ae.Fragment,{children:[s>0&&a.jsx(hl,{}),a.jsx(ul,{children:r||!t.href?a.jsx(pl,{children:t.label}):t.asChild&&t.children?a.jsx(ml,{asChild:!0,children:t.children}):a.jsx(ml,{asChild:!0,children:a.jsx(N.Link,{to:t.href||"/",children:t.label})})})]},`${t.label}-${s}`)})})}),a.jsx("div",{className:"space-y-6",children:t})]})},exports.Breadcrumb=dl,exports.BreadcrumbEllipsis=xl,exports.BreadcrumbItem=ul,exports.BreadcrumbLink=ml,exports.BreadcrumbList=cl,exports.BreadcrumbPage=pl,exports.BreadcrumbSeparator=hl,exports.BurndownPanel=pm,exports.Button=Xt,exports.ButtonGroup=gl,exports.CLOSED_STATUSES=Fh,exports.CRUD_CONFIG=Fe,exports.CURRENCY_FIELDS=Ou,exports.Calendar=vl,exports.CallbackPage=()=>{const{processCallback:e}=Pn(),s=N.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await e()){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(a){localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e,s]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(a){n(a?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsxs(rs,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[a.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(Jo,{variant:"danger",children:a.jsx(ei,{children:r})}),a.jsx("div",{className:"text-sm text-muted-foreground",children:a.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Xt,{onClick:l,disabled:o,className:"flex-1",children:o?a.jsxs(a.Fragment,{children:[a.jsx(tr,{size:"sm",className:"mr-2"}),"Tentando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),a.jsx(Xt,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(tr,{size:"lg"})}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=ts,exports.CardContent=os,exports.CardDescription=ns,exports.CardFooter=is,exports.CardHeader=ss,exports.CardSkeleton=Bn,exports.CardTitle=rs,exports.CartesianPanel=lm,exports.ChartContainer=kc,exports.ChartLegend=Dc,exports.ChartLegendContent=Ec,exports.ChartStyle=Sc,exports.ChartTooltip=Tc,exports.ChartTooltipContent=Pc,exports.Checkbox=Xs,exports.Collapsible=gi,exports.CollapsibleContent=bi,exports.CollapsibleTrigger=vi,exports.ColorPicker=Po,exports.ColumnSettingsPopover=_o,exports.ComboTree=Wr,exports.Combobox=Ur,exports.Command=Tr,exports.CommandDialog=({children:e,...t})=>a.jsx("div",{...t,children:a.jsx(Tr,{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:e})}),exports.CommandEmpty=Er,exports.CommandGroup=Ar,exports.CommandInput=Pr,exports.CommandItem=Mr,exports.CommandList=Dr,exports.CommandSeparator=Ir,exports.CommandShortcut=Fr,exports.ContentContainer=function({title:e,subtitle:t,children:s,className:r,hasHeader:n=!0}){const o=e||t;return a.jsxs("div",{className:Yt("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",r),children:[n&&o&&a.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&a.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),t&&a.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),s&&a.jsx("div",{className:Yt("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Gn,exports.ContextMenuCheckboxItem=so,exports.ContextMenuContent=ao,exports.ContextMenuGroup=Kn,exports.ContextMenuItem=to,exports.ContextMenuLabel=no,exports.ContextMenuPortal=Qn,exports.ContextMenuRadioGroup=Jn,exports.ContextMenuRadioItem=ro,exports.ContextMenuSeparator=oo,exports.ContextMenuShortcut=io,exports.ContextMenuSub=Xn,exports.ContextMenuSubContent=eo,exports.ContextMenuSubTrigger=Zn,exports.ContextMenuTrigger=Yn,exports.CoreProviders=function({children:s,queryClient:r,moduleAlias:n,moduleAccessGuardProps:o,appTranslations:i,clarityProjectId:l,clarityMode:d="auto"}){Zi();const[c]=t.useState(()=>new w.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),u=r??c;t.useEffect(()=>{if(i)for(const[e,a]of Object.entries(i))li(e,a)},[i]);const m={sourceModule:n,...o};return a.jsx(yi,{children:a.jsx(y.I18nextProvider,{i18n:e,children:a.jsx(w.QueryClientProvider,{client:u,children:a.jsxs(Tn,{children:[a.jsx(al,{projectId:l,mode:d}),a.jsx(mi,{children:a.jsx(xi,{moduleAlias:n,children:a.jsx(Xi,{...m,children:s})})})]})})})})},exports.CrudActionBar=bo,exports.CrudActionMenu=ip,exports.CrudGrid=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:v=!1,searchValue:b,onSearchChange:j,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:T,onViewModeChange:P,listCardRenderer:D,gridCardRenderer:E,showViewToggle:A=!1})=>{const{setSearchVisible:I}=Pn(),M=void 0!==f?!f:g;t.useEffect(()=>{if(!v)return I(!0),()=>I(!1)},[I,v]);const F=m||x.length>0||v||u||C||A,R=_||(()=>{s.bulkDelete?.(s.selectedIds)}),L=T||"grid",z="list"===L,U={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"}[z?1:k],O=M&&F?a.jsx(bo,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:v,searchValue:b,onSearchChange:j,searchPlaceholder:w,showBulkActions:u,selectedCount:s.selectedIds.length,bulkActions:N,onBulkDelete:R,onClearSelection:s.clearSelection,customActions:x,filters:C,viewMode:L,onViewModeChange:P,showViewToggle:A,availableViewModes:["list","grid"]}):null;return s.isLoading?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx(Bn,{count:6})})]}):0===s.entities.length?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx($n,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx("div",{className:Yt("grid gap-4",U),children:s.entities.map(e=>{const t=(e=>{const{t:a}=y.useTranslation();return z&&D?D(e):!z&&E?E(e):S?S(e):null})(e);return a.jsxs(Gn,{children:[a.jsx(Yn,{asChild:!0,children:t?a.jsx("div",{className:"cursor-pointer",onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:t}):a.jsx(ts,{className:Yt("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&s.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:a.jsxs(os,{className:Yt("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&a.jsx("div",{className:Yt(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),z?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:r.map(t=>a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key)))}),(n||o||d)&&a.jsx("div",{onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[u&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(yo,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[r.map((t,s)=>a.jsxs("div",{className:Yt("flex justify-between items-start gap-2",s!==r.length-1&&"mb-2"),children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||d)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(co,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]})]})]})})}),a.jsx(ao,{className:"w-[160px]",children:a.jsx(lo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:c?c(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=Ho,exports.CrudPagination=Oo,exports.CrudPrimitiveFilterBar=lp,exports.CrudPrimitivePagination=Uo,exports.CrudPrimitiveTable=op,exports.CrudTable=ko,exports.CustomFormFields=function({fields:e,readOnly:s=!1,hideInactiveWithoutValue:r=!1,onChange:n,onFieldChange:o}){const i=t.useCallback(a=>{if(o?.(a),n){const t=e.map(e=>e.id===a.id?a:e);n(t)}},[e,n,o]),l=e.filter(e=>ux(e,r));return 0===l.length?null:a.jsx("div",{className:"space-y-4",children:l.map(e=>a.jsx(jx,{field:e,readOnly:s,onChange:i},e.id))})},exports.D4SignWidget=wh,exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=Dt,exports.DEFAULT_ACTION_TYPES=Ih,exports.DEFAULT_DATETIME_FORMAT=It,exports.DEFAULT_LOCALE=At,exports.DEFAULT_TIMEZONE=Mt,exports.DashboardForm=Am,exports.DashboardGeneralView=function({dashboards:e,limit:s,generalView:r,language:n=exports.DashboardLanguage.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:d=!1,canEditStandard:c=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:v=!1,onOpen:b,onBackToList:y,onRefresh:j,onRefreshList:w,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:T,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onSearch:M,onQuickFilterChange:F,onSetGeneralView:R,viewState:L,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:V}){const[B,q]=t.useState({mode:"list"}),$=L??B,W=t.useCallback(e=>{z?z(e):q(e)},[z]),H=t.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,Y]=t.useState(!1),[K,Q]=t.useState(m[0]?.id);t.useEffect(()=>{m.length>0&&!K&&Q(m[0]?.id)},[m,K]),t.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==exports.DashboardViewType.Carousel||m.length<=1)return;const e=function(e){switch(e){case exports.DashboardPageTime.FiveSeconds:return 5e3;case exports.DashboardPageTime.TenSeconds:return 1e4;case exports.DashboardPageTime.FifteenSeconds:return 15e3;case exports.DashboardPageTime.ThirtySeconds:return 3e4;case exports.DashboardPageTime.OneMinute:return 6e4;case exports.DashboardPageTime.ThreeMinutes:return 18e4;case exports.DashboardPageTime.FiveMinutes:return 3e5;case exports.DashboardPageTime.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),a=setInterval(()=>{Q(e=>{const a=(m.findIndex(a=>a.id===e)+1)%m.length;return m[a]?.id})},e);return()=>clearInterval(a)},[$,H,m]);const X=t.useCallback(e=>{W({mode:"view",dashboardId:e.id}),Q(void 0),b?.(e)},[W,b]),J=t.useCallback(()=>{W({mode:"list"}),Y(!1),y?.()},[W,y]),Z=t.useCallback(()=>{W({mode:"create"})},[W]),ee=t.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),ae=t.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),te=t.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),se=t.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),re=t.useCallback(()=>{H&&N?.(H)},[H,N]),ne=t.useCallback(()=>{H&&ee(H)},[H,ee]),oe=t.useCallback(()=>{H&&ae(H)},[H,ae]);return a.jsxs("div",{className:Yt("flex flex-col h-full",V),children:["list"===$.mode&&a.jsx(km,{dashboards:e,limit:s,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:d,onOpen:X,onEdit:ee,onShare:ae,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:w,onSearch:M,onQuickFilterChange:F,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[!G&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),r?.dashboardId===H.id&&a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:[a.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),a.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&R&&r?.dashboardId!==H.id&&a.jsx("button",{onClick:()=>R(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),a.jsx(wm,{dashboard:H,panels:u,pages:m,activePageId:K,canEdit:l||c&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:j,onToggleFullscreen:()=>Y(e=>!e),onToggleFavorite:re,onEdit:ne,onShare:oe,onAddPanel:P,onEditPanel:D,onRemovePanel:E,onDuplicatePanel:A,onLayoutChange:I,onPageChange:Q,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),a.jsx(Am,{users:h,groups:x,places:f,collaborators:g,isSaving:v,onSave:te,onCancel:se,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),a.jsx(Am,{dashboard:H,initialTab:"share"===$.mode?exports.DashboardFormTab.Share:exports.DashboardFormTab.General,users:h,groups:x,places:f,collaborators:g,isSaving:v,isQualitfy:!!H.isStandard&&!c,onSave:te,onCancel:se,className:"flex-1"})]})]})},exports.DashboardGrid=bm,exports.DashboardList=km,exports.DashboardPanelRenderer=jm,exports.DashboardView=wm,exports.DataFilterBar=lp,exports.DataList=bl,exports.DataPagination=Uo,exports.DataTable=op,exports.DatePicker=yl,exports.Dialog=ys,exports.DialogBody=Ts,exports.DialogClose=Ns,exports.DialogContent=ks,exports.DialogDescription=Es,exports.DialogFooter=Ps,exports.DialogHeader=Ss,exports.DialogOverlay=_s,exports.DialogPortal=ws,exports.DialogTitle=Ds,exports.DialogTrigger=js,exports.DialogWizard=function({open:t,onOpenChange:s,currentStep:r,onStepChange:n,steps:o,canGoToStep:i,children:l,title:c,description:u,onSave:m,saveLabel:p=e.t("save"),nextLabel:h=e.t("next"),backLabel:x=e.t("back"),variant:f="form",isDirty:g,size:v="lg",unsavedChangesTitle:b,unsavedChangesDescription:j,cancelText:w,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:T}=y.useTranslation(),P=o.length,D=r>=P,E=r<=1;return a.jsx(ys,{open:t,onOpenChange:s,children:a.jsxs(ks,{size:v,variant:f,isDirty:g,unsavedChangesTitle:b,unsavedChangesDescription:j,cancelText:w,leaveWithoutSavingText:N,className:Yt("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[a.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[a.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),a.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,t)=>{const s=t+1,o=s===r,l=(e=>e<r)(s),c=(u=s)<=r||!i||i(u);var u;return a.jsxs("button",{type:"button",onClick:()=>(e=>{e!==r&&(e<r?n(e):i&&!i(e)||n(e))})(s),disabled:!c,className:Yt("flex items-center gap-2 py-3 px-2 rounded-md text-left transition-colors text-xs",o&&"bg-primary-foreground/20 font-semibold",!o&&c&&"hover:bg-primary-foreground/10 cursor-pointer",!c&&"opacity-40 cursor-not-allowed"),children:[a.jsx("span",{className:Yt("flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold flex-shrink-0 transition-colors",o&&"bg-primary-foreground text-primary",l&&!o&&"bg-primary-foreground/30 text-primary-foreground",!o&&!l&&"border-2 border-primary-foreground/40 text-primary-foreground/60"),children:l&&!o?a.jsx(d.Check,{className:"h-3.5 w-3.5"}):s}),a.jsx("span",{className:Yt("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},s)})})]}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[a.jsxs(Ss,{className:"p-6 pb-0",children:[a.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",r," de ",P]}),a.jsx(Ds,{children:c}),u&&a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),a.jsx(Ts,{className:"px-6",children:l}),!k&&a.jsx(Ps,{className:"px-6 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("div",{className:"flex items-center gap-2",children:S}),a.jsxs("div",{className:"flex items-center gap-2",children:[!E&&a.jsx(Xt,{variant:"outline",onClick:()=>n(r-1),children:x}),D?a.jsx(Xt,{onClick:m,disabled:C,children:p}):a.jsx(Xt,{onClick:()=>n(r+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=_r,exports.DocumentSigner=function({file:s,onDocumentSigned:r,onError:n,showEventLog:o=!1}){const{user:i,alias:c}=Pn(),{config:u,isLoading:m}=ph(),{t:p}=y.useTranslation(),[h,x]=t.useState(null),[f,g]=t.useState(!1),[v,b]=t.useState(null),[j,w]=t.useState("sandbox"),[N,_]=t.useState("clicksign"),[C,k]=t.useState(null),[S,T]=t.useState(null),[P,D]=t.useState(!1),[E,A]=t.useState(0),[I,M]=t.useState(!1),[F,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),U=t.useCallback(e=>{o&&R(a=>[...a,`[${(new Date).toLocaleTimeString()}] ${e}`])},[o]),O=t.useCallback(async a=>{if(x(a),b(null),k(null),T(null),U(`Arquivo selecionado: ${a.name}`),c&&i){g(!0);try{const t=u?.provider??"clicksign";_(t),U(`Provedor resolvido: ${t}`);const s=new FileReader,r=await new Promise((e,t)=>{s.onload=()=>{const a=s.result;e(a)},s.onerror=t,s.readAsDataURL(a)});U(`Criando envelope para assinatura via ${t}...`);const o=await gh.createEnvelopeWithSigner({alias:c,contentBase64:r,filename:a.name,signerEmail:i.email||"",signerName:i.name||"",provider:t});U(`Envelope criado: ${o.envelope_id}`),k({envelope_id:o.envelope_id,document_id:o.document_id,signer_email:o.signer_email,key_signer:o.signer_id}),w(o.environment),_(o.provider||t),"d4sign"===t?(U("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(o.document_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):o.signer_id?(U(`Signer ID obtido: ${o.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(o.signer_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):(U(e.t("sign_signer_unavailable")),l.toast.error(p("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),n?.(new Error(p("sign_signer_unavailable"))))}catch(t){const a=t instanceof Error?t:new Error(p("sign_process_error",p("sign_doc_process_error"))),s=a.message||"";s.includes("MONTHLY_LIMIT_REACHED")?(U(e.t("sign_monthly_limit")),l.toast.error(p("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(U(`Erro: ${s}`),l.toast.error(s)),n?.(a)}finally{g(!1)}}},[c,i,U,n,u]);t.useEffect(()=>{s&&c&&i&&!m&&s!==z.current&&(z.current=s,O(s))},[s,c,i,m,O]);const V=t.useCallback(async()=>{if(!C||!c)return;D(!0),A(0),M(!1),U("Buscando documento assinado...");for(let t=1;t<=6;t++){A(t),U(`Tentativa ${t}/6...`);try{const a=await gh.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:N});if(a.download_url)return U(e.t("sign_doc_available")),T(a.download_url),void D(!1)}catch(a){U(`Erro na tentativa ${t}: ${a instanceof Error?a.message:p("unknown_error")}`)}t<6&&(U("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}U(e.t("sign_fetch_failed")),D(!1),M(!0)},[C,c,U,N]),B=t.useCallback(async()=>{U("Documento assinado com sucesso!"),l.toast.success(p("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(r?.({success:!0,provider:N,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:v||"",environment:j}),await V())},[U,r,C,v,c,j,N,V]);if(!c)return a.jsx(ts,{className:"border-amber-200 bg-amber-50",children:a.jsx(os,{className:"flex items-start gap-3 py-6",children:a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-amber-800",children:p("sign_auth_required","Autenticação necessária")}),a.jsx("p",{className:"text-sm text-amber-700 mt-1",children:p("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const q="d4sign"===N?"D4Sign":"Clicksign",$=()=>o&&F.length>0?a.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:F.map((e,t)=>a.jsx("div",{children:e},t))}):null;return C&&!v&&(S||P||I)?a.jsxs("div",{className:"space-y-4",children:[a.jsx(ts,{className:"border-green-200 bg-green-50",children:a.jsxs(os,{className:"flex flex-col items-center gap-4 py-8",children:[a.jsx(d.CheckCircle2,{className:"h-12 w-12 text-green-600"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-lg font-semibold text-green-800",children:p("sign_signed_success","Documento assinado com sucesso!")}),a.jsx("p",{className:"text-sm text-green-700 mt-1",children:h?.name})]}),P?a.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),p("sign_preparing_doc","Preparando documento assinado...")," (",p("sign_attempt","tentativa")," ",E,"/6)"]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_waiting_provider",`Aguardando processamento pelo ${q}...`)})]}):S?a.jsx(Xt,{asChild:!0,variant:"default",className:"gap-2",children:a.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(d.Download,{className:"h-4 w-4"}),p("sign_download_signed","Baixar documento assinado")]})}):I?a.jsxs("div",{className:"text-center space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),a.jsxs(Xt,{variant:"secondary",className:"gap-2",onClick:V,children:[a.jsx(d.RefreshCw,{className:"h-4 w-4"}),p("sign_try_again","Tentar novamente")]})]}):null]})}),a.jsx($,{})]}):v?a.jsxs("div",{className:"space-y-4",children:["d4sign"===N?a.jsx(wh,{documentKey:v,signerEmail:C?.signer_email||i?.email||"",signerName:i?.name,keySigner:C?.key_signer,environment:j,onSign:B,onError:n}):a.jsx(jh,{signerId:v,environment:j,onSign:B,onError:n}),a.jsx($,{})]}):s&&(f||m)?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const a=e.target.files?.[0];a&&"application/pdf"===a.type?O(a):l.toast.error(p("sign_select_pdf","Selecione um arquivo PDF"))}}),f?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsx(ts,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:a.jsxs(os,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[a.jsx(d.Upload,{className:"h-8 w-8 text-muted-foreground"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"font-medium",children:p("sign_select_pdf","Selecione um arquivo PDF")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),a.jsx($,{})]})},exports.Drawer=jl,exports.DrawerClose=_l,exports.DrawerContent=kl,exports.DrawerDescription=Dl,exports.DrawerFooter=Tl,exports.DrawerHeader=Sl,exports.DrawerOverlay=Cl,exports.DrawerPortal=Nl,exports.DrawerTitle=Pl,exports.DrawerTrigger=wl,exports.DropdownMenu=nr,exports.DropdownMenuCheckboxItem=xr,exports.DropdownMenuContent=pr,exports.DropdownMenuGroup=ir,exports.DropdownMenuItem=hr,exports.DropdownMenuLabel=gr,exports.DropdownMenuPortal=lr,exports.DropdownMenuRadioGroup=cr,exports.DropdownMenuRadioItem=fr,exports.DropdownMenuSeparator=vr,exports.DropdownMenuShortcut=br,exports.DropdownMenuSub=dr,exports.DropdownMenuSubContent=mr,exports.DropdownMenuSubTrigger=ur,exports.DropdownMenuTrigger=or,exports.ElectronicSignatureDialog=function({open:s,onOpenChange:r,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:c=8,title:u=e.t("electronic_signature"),description:m,confirmLabel:p=e.t("conclude"),cancelLabel:h=e.t("cancel"),resendLabel:x=e.t("resend_code"),errorMessage:f}){const g="password"===i,v=g?e.t("esign_password_description"):e.t("esign_code_description"),b=m??v,[y,j]=t.useState(""),[w,N]=t.useState(!1),[_,C]=t.useState(!1),[k,S]=t.useState(null),T=t.useCallback(async()=>{if(y.trim()){N(!0),S(null);try{await n(y)?(j(""),r(!1)):S(f??(g?e.t("esign_invalid_password"):e.t("esign_invalid_code")))}catch{S(f??(g?e.t("esign_password_error"):e.t("esign_code_error")))}finally{N(!1)}}},[y,n,r,f,g]),P=t.useCallback(async()=>{if(o){C(!0),S(null);try{await o()}catch{S(e.t("esign_resend_error"))}finally{C(!1)}}},[o]),D=e=>{e||(j(""),S(null)),r(e)},E=g?d.Lock:d.ShieldCheck,A=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return a.jsx(ys,{open:s,onOpenChange:D,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!y,children:[a.jsx(Ss,{children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(E,{className:"h-5 w-5 text-primary"}),u]})}),a.jsxs("div",{className:"py-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:b}),!g&&l&&a.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[a.jsx(d.Mail,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),a.jsx("span",{className:"font-medium",children:l})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"signature-input",children:A}),a.jsx(Zt,{id:"signature-input",type:g?"password":"text",value:y,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&(e.preventDefault(),T())},maxLength:g?void 0:c,placeholder:I,autoFocus:!0,className:Yt(k&&"border-destructive focus-visible:ring-destructive")}),k&&a.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:P,disabled:_,className:"text-primary",children:[a.jsx(d.RefreshCw,{className:Yt("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>D(!1),disabled:w,children:h}),a.jsx(Xt,{onClick:T,disabled:!y.trim()||w,children:w?"Validando...":p})]})]})})},exports.EllipsisText=Wn,exports.EmailService=Fp,exports.EmptyState=$n,exports.EntitySelect=Ur,exports.ErrorBoundary=yi,exports.ExportDialog=function({open:e,onOpenChange:s,onExport:r,mode:n="table",options:o,title:i,description:l,cancelLabel:d="Cancelar",exportLabel:c="Exportar"}){const{t:u}=y.useTranslation(),[m,p]=t.useState(""),h=o??("chart"===n?Bc:Vc),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),s(e)};return a.jsx(ys,{open:e,onOpenChange:g,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[a.jsx(Ss,{children:a.jsx(Ds,{children:x})}),a.jsxs("div",{className:"py-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),a.jsx(vd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(bd,{value:e.value,id:`export-${e.value}`}),a.jsxs(as,{htmlFor:`export-${e.value}`,className:Yt("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>g(!1),children:d}),a.jsx(Xt,{onClick:()=>{m&&(r(m),s(!1),p(""))},disabled:!m,children:c})]})]})})},exports.FORBIDDEN_FILE_TYPES=rx,exports.FilterBar=Wo,exports.Form=As,exports.FormControl=zs,exports.FormDateField=hx,exports.FormDescription=Us,exports.FormField=({...e})=>a.jsx(Is.Provider,{value:{name:e.name},children:a.jsx(h.Controller,{...e})}),exports.FormItem=Rs,exports.FormLabel=Ls,exports.FormMessage=Os,exports.FormMultiSelectionField=bx,exports.FormNumericField=gx,exports.FormQuestionsField=yx,exports.FormSingleSelectionField=vx,exports.FormSkeleton=function({fields:e=4}){return a.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-4 w-24"}),a.jsx(Rr,{className:"h-10 w-full"})]},t)),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Rr,{className:"h-10 w-20"}),a.jsx(Rr,{className:"h-10 w-20"})]})]})},exports.FormTextField=px,exports.FormTimeField=xx,exports.FormUrlField=fx,exports.Grid=function({children:e,cols:t="auto-fit",gap:s="md",className:r}){return a.jsx("div",{className:Yt("grid",El[t],Al[s],r),children:e})},exports.H1=ql,exports.H2=$l,exports.H3=Wl,exports.H4=Hl,exports.HeaderSkeleton=function(){return a.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Rr,{className:"h-8 w-8 rounded-full"}),a.jsx(Rr,{className:"h-6 w-32"})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Rr,{className:"h-8 w-8"}),a.jsx(Rr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Il,exports.HoverCardContent=Fl,exports.HoverCardTrigger=Ml,exports.IconPicker=Mo,exports.IframeDialog=tu,exports.ImageEditor=function({value:e,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:c}){const{t:u}=y.useTranslation(),[m,p]=t.useState(e||{alignment:"center",allowDownload:!1}),h=t.useRef(null),{upload:x,uploading:f}=nh({uploadFunction:o,deleteFunction:i,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:a.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:a.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"caption",children:"Legenda"}),a.jsx(Js,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"alt",children:u("alt_text")}),a.jsx(Zt,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Alinhamento"}),a.jsxs(Vs,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"left",children:"Esquerda"}),a.jsx(Ks,{value:"center",children:"Centro"}),a.jsx(Ks,{value:"right",children:"Direita"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"width",children:"Largura"}),a.jsx(Zt,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"height",children:"Altura"}),a.jsx(Zt,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),a.jsx(as,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:n,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{m.imageUrl?r(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:t="",style:s}){const{t:r}=y.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return a.jsx("div",{className:`flex ${n} my-4 ${t}`,style:s,children:a.jsxs("div",{className:"space-y-2 max-w-full",children:[a.jsx("img",{src:e.imageUrl,alt:e.alt||"",style:{width:e.width?`${e.width}px`:"auto",height:e.height?`${e.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),e.caption&&a.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&a.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[a.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=Jl,exports.Input=Zt,exports.InputGroup=Rl,exports.InputGroupAddon=zl,exports.InputGroupButton=Ol,exports.InputGroupInput=Vl,exports.InputGroupTextarea=Bl,exports.LINK_PROPERTIES=Vu,exports.LOGO_CONFIG=Be,exports.Label=as,exports.Large=Kl,exports.Lead=Yl,exports.LeadershipDialog=th,exports.LeadershipForm=ah,exports.LeadershipPage=function({unassociatedUsers:s=[],onAssociateUser:r,onMoveNode:n,onMoveNodes:o,columns:i,nameHeader:l=e.t("leader"),rootDropLabel:c=e.t("leadership_make_root")}={}){const{alias:u}=Pn(),{data:m,isLoading:p,error:h,refetch:x}=Bp(),f=Hp(),g=$p(),[v,b]=t.useState(()=>u?(e=>{try{const a=localStorage.getItem(`${sh}-${e}`);if(a)return new Set(JSON.parse(a))}catch{}return new Set})(u):new Set),[y,j]=t.useState([]),[w,N]=t.useState(new Set),[_,C]=t.useState(!0),[k,S]=t.useState(!1),[T,P]=t.useState(),[D,E]=t.useState(null),A=t.useMemo(()=>m?Vp(m):[],[m]),I=t.useMemo(()=>A.map(e=>e.id),[A]),M=I.length>0&&y.length===I.length,F=A.filter(e=>e.children.length>0).every(e=>v.has(e.id));t.useEffect(()=>{if(m&&m.length>0&&u){if(!localStorage.getItem(`${sh}-${u}`)){const e=m.map(e=>e.id),a=new Set(e);b(a),rh(u,a)}}},[m,u]);const R=t.useCallback(e=>{b(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),u&&rh(u,t),t})},[u]),L=t.useCallback(()=>{if(F){const e=new Set;b(e),u&&rh(u,e)}else{const e=new Set(A.filter(e=>e.children.length>0).map(e=>e.id));b(e),u&&rh(u,e)}},[F,A,u]),z=t.useCallback(e=>{j(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),U=t.useCallback(()=>{j(M?[]:I)},[M,I]),O=t.useCallback(e=>{N(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),V=t.useCallback(e=>A.find(a=>a.id===e),[A]),B=t.useCallback((e,a)=>{if(n)return void n(e,a);const t=s.find(a=>a.id===e);if(t){if(r){const e=a?V(a):null;r(t.id,e?.id_user||null)}else g.mutate({id_user:t.id,id_leader:a&&V(a)?.id_user||null});return}const o=V(e);if(!o)return;const i=a?V(a):null;f.mutate({id:o.id,id_leader:i?.id_user||null})},[n,s,r,V,f,g]),q=t.useCallback((e,a)=>{o?o(e,a):(e.forEach(e=>B(e,a)),j([]))},[o,B]),$=t.useCallback(e=>{P(e),E(null),S(!0)},[]),W=t.useCallback(()=>{P(void 0),E(null),S(!0)},[]),H=t.useCallback(()=>{S(!1),P(void 0),E(null)},[]),G=t.useCallback((e,a)=>{const t=w.has(e)&&w.size>1?Array.from(w):[e];a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t)),a.currentTarget.style.opacity="0.4"},[w]),Y=t.useMemo(()=>[{key:"subordinatesCount",header:"Subordinados",hoverContent:e=>e.subordinateNames&&e.subordinateNames.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subordinados diretos:"}),[...e.subordinateNames].sort((e,a)=>e.localeCompare(a)).map(e=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(d.User,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{children:e})]},e))]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem subordinados diretos"})},{key:"email",header:"Email",className:"text-left",width:180,render:e=>a.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground text-sm",children:[a.jsx(d.Mail,{className:"h-3.5 w-3.5"}),e.email||"—"]})}],[]),K=i??Y;if(p)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(h)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),a.jsx(Xt,{onClick:()=>x(),children:e.t("try_again")})]})});const Q=A.filter(a=>a.name!==e.t("inactive_user")).length;return a.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs(Xt,{size:"sm",onClick:W,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:L,children:F?a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 mr-1"}),"Colapsar"]}):a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronRight,{className:"h-4 w-4 mr-1"}),"Expandir"]})}),a.jsx("div",{className:"flex items-center gap-2 ml-4",children:a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("span",{className:"text-sm font-medium",children:[Q," usuário",1!==Q?"s":""," associado",1!==Q?"s":""]})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote"})]}),a.jsx(pp,{data:m||[],columns:K,nameKey:"name",nameHeader:l,expandedIds:v,onToggleExpand:R,iconComponent:a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:y,onSelectItem:z,onSelectAll:U,isAllSelected:M,onMoveNode:B,onMoveNodes:q,rootDropLabel:c,emptyMessage:e.t("leadership_no_hierarchy"),renderActions:e=>a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(e),children:a.jsx(d.Pencil,{className:"h-4 w-4"})})}),s.length>0&&a.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>C(e=>!e),className:"w-full px-4 py-2.5 bg-muted/50 border-b flex items-center gap-2 hover:bg-muted/70 transition-colors cursor-pointer",children:[_?a.jsx(d.ChevronDown,{className:"h-4 w-4 text-muted-foreground shrink-0"}):a.jsx(d.ChevronRight,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx(d.UserPlus,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:"Usuários não associados"}),a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(",s.length,")"]}),w.size>0&&a.jsxs("span",{className:"text-xs text-primary ml-1",children:["(",w.size," selecionado",w.size>1?"s":"",")"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Arraste para a hierarquia acima"})]}),_&&a.jsx("div",{className:"divide-y",children:s.map(e=>a.jsxs("div",{draggable:!0,onDragStart:a=>G(e.id,a),onDragEnd:e=>{e.currentTarget.style.opacity="1"},className:Yt("flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors",w.has(e.id)&&"bg-primary/5"),children:[a.jsx(Xs,{checked:w.has(e.id),onCheckedChange:()=>O(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),a.jsx("span",{className:"text-muted-foreground shrink-0 select-none",children:"⠿"}),a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"text-sm truncate",children:e.name}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})]}),a.jsxs("div",{className:"px-3 py-2 bg-muted/20 border rounded-lg text-xs text-muted-foreground flex justify-between",children:[a.jsxs("span",{children:["Usuários associados: ",Q]}),s.length>0&&a.jsxs("span",{children:["Usuários não associados: ",s.length]})]}),a.jsx(th,{open:k,onOpenChange:H,leader:T,prefilledLeaderId:D,title:T?e.t("edit_name"):D?e.t("leadership_add_subordinate"):e.t("leadership_add_root")},`leadership-dialog-${u}`)]})},exports.List=ed,exports.ListPanel=nm,exports.LoadingState=sr,exports.LocaleProvider=mi,exports.LoginPage=()=>{const{t:e}=y.useTranslation();return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a.jsxs(os,{className:"text-center space-y-4",children:[a.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),a.jsx(Xt,{onClick:async()=>{ze()?await _n.loginDev():_n.loginProd()},className:"w-full",size:"lg",children:ze()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=qe,exports.MODULES_DATA=Ui,exports.MONTHS_MAP=Uu,exports.ManageAccessModal=Lp,exports.MatrixRiskPanel=xm,exports.Menubar=mc,exports.MenubarCheckboxItem=vc,exports.MenubarContent=fc,exports.MenubarGroup=lc,exports.MenubarItem=gc,exports.MenubarLabel=yc,exports.MenubarMenu=ic,exports.MenubarPortal=dc,exports.MenubarRadioGroup=uc,exports.MenubarRadioItem=bc,exports.MenubarSeparator=jc,exports.MenubarShortcut=wc,exports.MenubarSub=cc,exports.MenubarSubContent=xc,exports.MenubarSubTrigger=hc,exports.MenubarTrigger=pc,exports.MindMap=({value:e,defaultValue:s,onChange:r,onNodeSelect:n,readOnly:o=!1,hideToolbar:i=!1,extraShortcuts:l,renderNodeContent:d,className:c,height:u=600})=>{const{t:m}=y.useTranslation(),p=Wm({value:e,defaultValue:s,onChange:r,readOnly:o}),h=Jm(p.root),x=function(){const[e,a]=t.useState({x:0,y:0,scale:1}),s=t.useRef(!1),r=t.useRef({x:0,y:0,tx:0,ty:0}),n=t.useCallback(a=>{0!==a.button&&1!==a.button||(s.current=!0,r.current={x:a.clientX,y:a.clientY,tx:e.x,ty:e.y},a.currentTarget.setPointerCapture(a.pointerId))},[e.x,e.y]),o=t.useCallback(e=>{s.current&&a(a=>({...a,x:r.current.tx+(e.clientX-r.current.x),y:r.current.ty+(e.clientY-r.current.y)}))},[]),i=t.useCallback(e=>{if(s.current){s.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),l=t.useCallback((e,t,s)=>{a(a=>{const r=Math.min(2.5,Math.max(.3,a.scale+e));if(r===a.scale)return a;if(void 0===t||void 0===s)return{...a,scale:r};const n=r/a.scale;return{scale:r,x:t-(t-a.x)*n,y:s-(s-a.y)*n}})},[]),d=t.useCallback(()=>l(.15),[l]),c=t.useCallback(()=>l(-.15),[l]),u=t.useCallback(()=>a({x:0,y:0,scale:1}),[]),m=t.useCallback((e,t,s,r)=>{const n=Math.min((s-64)/e,(r-64)/t,1.5),o=Math.max(.3,n);a({scale:o,x:(s-e*o)/2,y:(r-t*o)/2})},[]),p=t.useCallback(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const a=e.currentTarget.getBoundingClientRect(),t=e.clientX-a.left,s=e.clientY-a.top;l(e.deltaY>0?-.1:.1,t,s)},[l]);return t.useEffect(()=>{const e=()=>s.current=!1;return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]),{transform:e,setTransform:a,zoomIn:d,zoomOut:c,reset:u,fitTo:m,onBackgroundPointerDown:n,onPointerMove:o,onPointerUp:i,onWheel:p}}(),f=ae.useRef(null),g=ae.useRef(null),v=ae.useRef(null),[b,j]=ae.useState(null),[w,N]=ae.useState(null);ae.useEffect(()=>{n?.(p.selectedNode)},[p.selectedNode,n]),function({api:e,layout:a,containerRef:s,onStartEditing:r,readOnly:n,extraShortcuts:o}){t.useEffect(()=>{const t=t=>{const i=s.current;if(!i)return;if(!i.contains(document.activeElement))return;const l=t.target;if(l?.isContentEditable)return;if(l&&("INPUT"===l.tagName||"TEXTAREA"===l.tagName))return;const d={layout:a,selectedId:e.selectedId,setSelectedId:e.setSelectedId},c=e.selectedId;for(const a of o??[])if(a.key.toLowerCase()===t.key.toLowerCase()&&!!a.ctrl===(t.ctrlKey||t.metaKey)&&!!a.shift===t.shiftKey&&!!a.alt===t.altKey)return t.preventDefault(),void a.handler({selectedId:e.selectedId,root:e.root,setRoot:e.setRoot,select:e.setSelectedId});if((t.ctrlKey||t.metaKey)&&"z"===t.key.toLowerCase())return t.preventDefault(),void(t.shiftKey?e.redo():e.undo());if("ArrowUp"===t.key)return t.preventDefault(),void Zm("up",d);if("ArrowDown"===t.key)return t.preventDefault(),void Zm("down",d);if("ArrowLeft"===t.key)return t.preventDefault(),void Zm("left",d);if("ArrowRight"===t.key)return t.preventDefault(),void Zm("right",d);if(c){if(" "===t.key)return t.preventDefault(),void e.toggleNode(c);if("F2"===t.key){if(n)return;return t.preventDefault(),void r(c)}if(!n){if("Enter"===t.key&&!t.shiftKey)return t.preventDefault(),c===e.root.id?e.addChild(c,""):e.addSibling(c,""),void setTimeout(()=>{e.selectedId&&r(e.selectedId)},0);if("Insert"===t.key||"Tab"===t.key)return t.preventDefault(),e.addChild(c,""),void setTimeout(()=>{e.selectedId&&r(e.selectedId)},0);if("Delete"===t.key||"Backspace"===t.key){if(c===e.root.id)return;return t.preventDefault(),void e.removeNode(c)}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,a,s,r,n,o])}({api:p,layout:h,containerRef:f,onStartEditing:e=>{o||j(e)},readOnly:o,extraShortcuts:l});const _=ae.useRef(!1);ae.useEffect(()=>{if(_.current)return;const e=g.current;if(!e)return;const{clientWidth:a,clientHeight:t}=e;a>0&&t>0&&h.width>0&&(x.fitTo(h.width,h.height,a,t),_.current=!0)},[h.width,h.height,x]);const C=p.selectedId,k=p.selectedNode,S=C===p.root.id,T=ae.useRef(null),P=e=>a=>{if(o)return;const t=T.current;if(!t||t===e)return;const s=Fm(p.root,t);s&&Fm(s.node,e)||(a.preventDefault(),a.dataTransfer.dropEffect="move",N(e))},D=()=>N(null),E=e=>a=>{a.preventDefault();const t=T.current;N(null),T.current=null,t&&t!==e&&p.moveNode(t,e)};return a.jsx(yr,{children:a.jsxs("div",{ref:f,tabIndex:0,role:"tree","aria-label":m("mind_map_aria_label"),className:Yt("relative flex flex-col rounded-lg border bg-muted/20 overflow-hidden focus:outline-none",c),style:{height:u},onClick:()=>f.current?.focus(),children:[!i&&a.jsx(sp,{canAddChild:!!k&&!o,canAddSibling:!!k&&!o,canDelete:!!k&&!S&&!o,canUndo:p.canUndo&&!o,canRedo:p.canRedo&&!o,onAddChild:()=>{if(!C)return;const e=p.addChild(C,"");j(e)},onAddSibling:()=>{if(!C)return;if(S){const e=p.addChild(C,"");return void j(e)}const e=p.addSibling(C,"");j(e)},onDelete:()=>{C&&!S&&p.removeNode(C)},onExpandAll:p.expandAll,onCollapseAll:p.collapseAll,onFit:()=>{const e=g.current;e&&x.fitTo(h.width,h.height,e.clientWidth,e.clientHeight)},onZoomIn:x.zoomIn,onZoomOut:x.zoomOut,onUndo:p.undo,onRedo:p.redo,onExportJson:()=>{!function(e,a,t="application/json"){const s=new Blob([e],{type:t}),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=a,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}(rp(p.root),"mind-map.json")},onExportImage:async()=>{if(v.current)try{await async function(e,a="mind-map.png"){const t=e.cloneNode(!0),s=(new XMLSerializer).serializeToString(t),r=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(s)))}`,n=new Image;await new Promise((e,a)=>{n.onload=()=>e(),n.onerror=()=>a(new Error("Failed to load SVG snapshot")),n.src=r});const o=e.clientWidth||Number(e.getAttribute("width"))||1200,i=e.clientHeight||Number(e.getAttribute("height"))||800,l=document.createElement("canvas");l.width=2*o,l.height=2*i;const d=l.getContext("2d");if(!d)throw new Error("Canvas 2D context unavailable");d.fillStyle="#ffffff",d.fillRect(0,0,l.width,l.height),d.drawImage(n,0,0,l.width,l.height);const c=await new Promise(e=>l.toBlob(e,"image/png"));if(!c)throw new Error("Failed to create PNG blob");const u=URL.createObjectURL(c),m=document.createElement("a");m.href=u,m.download=a,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}(v.current,"mind-map.png")}catch(e){}}}),a.jsx("div",{ref:g,className:"relative flex-1 overflow-hidden cursor-grab active:cursor-grabbing",onPointerDown:e=>{e.target===e.currentTarget&&(x.onBackgroundPointerDown(e),p.setSelectedId(null))},onPointerMove:x.onPointerMove,onPointerUp:x.onPointerUp,onWheel:x.onWheel,children:a.jsxs("div",{className:"absolute origin-top-left",style:{transform:`translate(${x.transform.x}px, ${x.transform.y}px) scale(${x.transform.scale})`,width:h.width,height:h.height},children:[a.jsx("svg",{ref:v,width:h.width,height:h.height,className:"absolute inset-0 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:h.nodes.map(e=>e.visibleChildren.map(t=>a.jsx(ap,{parent:e,child:t},`${e.node.id}-${t.node.id}`)))}),h.nodes.map(e=>{return a.jsx(ep,{layout:e,selected:C===e.node.id,editing:b===e.node.id,readOnly:o,onSelect:()=>p.setSelectedId(e.node.id),onStartEditing:()=>j(e.node.id),onFinishEditing:a=>{null!==a&&p.renameNode(e.node.id,a),j(null)},onToggle:()=>p.toggleNode(e.node.id),onDragStart:(t=e.node.id,e=>{o||t===p.root.id||(T.current=t,e.dataTransfer.setData("text/plain",t),e.dataTransfer.effectAllowed="move")}),onDragOver:P(e.node.id),onDragLeave:D,onDrop:E(e.node.id),isDropTarget:w===e.node.id,renderNodeContent:d},e.node.id);var t})]})})]})})},exports.ModalStateProvider=function({children:e}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),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 a.jsx(Ep.Provider,{value:u,children:e})},exports.ModuleAccessGuard=Xi,exports.ModuleGrid=Bi,exports.ModuleOfferContent=function({title:e,description:t,image:s,icon:r,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=y.useTranslation(),c=n??l("want_to_know_more");return a.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&a.jsx("div",{className:"flex items-center justify-center",children:s?a.jsx("img",{src:s,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):r?a.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:a.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),a.jsxs("div",{className:"space-y-3 max-w-lg",children:[a.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),a.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t})]}),i?a.jsx("div",{className:"w-full",children:i}):o?a.jsxs(Xt,{onClick:o,size:"lg",className:"gap-2",children:[a.jsx(d.Sparkles,{className:"h-4 w-4"}),c]}):null]})},exports.ModuleProvider=xi,exports.ModulesContent=qi,exports.ModulesDialog=Yi,exports.ModulesFooterCards=zi,exports.MultiSelect=Ur,exports.MultiselectPermissions=function({items:s,categories:r,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:c=e.t("permissions"),addButtonLabel:u=e.t("allow"),chipsTitle:m=e.t("allowed_items"),chipsPlaceholder:p=e.t("no_item_selected"),searchPlaceholder:h=e.t("search_placeholder"),selectPlaceholder:x=e.t("select_items_to_add"),itemInfoTemplate:f=e=>`${e} ${1===e?"item":"itens"}`,disclaimer:g,disclaimerLink:v,onDisclaimerClick:b,className:j}){const[w,N]=t.useState(r[0]?.id??""),[_,C]=t.useState(""),[k,S]=t.useState([]),[T,P]=t.useState(!1),D=t.useMemo(()=>iu(n[w]),[n,w]),E=t.useMemo(()=>function(e){const{t:a}=y.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.inheritedIds?.forEach(e=>t.add(e));return t}(n[w]),[n,w]),A=t.useMemo(()=>s.filter(e=>D.has(e.id)),[s,D]),I=t.useMemo(()=>{const e=ou(_);return s.filter(a=>!D.has(a.id)&&!(e&&!ou(a.name).includes(e)))},[s,D,_]),M=t.useMemo(()=>{const e={};for(const a of r)e[a.id]=iu(n[a.id]).size;return e},[r,n]),F=t.useCallback(e=>{N(e),S([]),C("")},[]),R=t.useCallback(e=>{S(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=t.useCallback(()=>{if(0===k.length)return;const e=[...n[w]??[]];for(const a of k){const t=s.find(e=>e.id===a),r=t?.group??"default",n=e.find(e=>e.context===r);n?n.allowedIds.includes(a)||(n.allowedIds=[...n.allowedIds,a]):e.push({context:r,allowedIds:[a],inheritedIds:[]})}o({...n,[w]:e}),S([]),C(""),P(!1)},[k,n,w,s,o]),z=t.useCallback(e=>{if(E.has(e))return;const a=(n[w]??[]).map(a=>({...a,allowedIds:a.allowedIds.filter(a=>a!==e)}));o({...n,[w]:a})},[n,w,E,o]);return l?a.jsxs("div",{className:Yt("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",j),children:[a.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),a.jsx("div",{className:"h-9 w-full bg-muted rounded"}),a.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):a.jsx("div",{className:Yt("rounded-md border bg-muted/30",j),children:a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c}),a.jsxs(Vs,{value:w,onValueChange:F,children:[a.jsx($s,{className:"h-9 text-sm",children:a.jsx(qs,{})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Ks,{value:e.id,children:a.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&a.jsx(er,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Cr,{open:T,onOpenChange:P,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",role:"combobox",className:"flex-1 justify-between h-9 text-sm font-normal text-muted-foreground",children:[k.length>0?`${k.length} selecionado${k.length>1?"s":""}`:x,a.jsx(d.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[a.jsx("div",{className:"p-2 border-b",children:a.jsxs("div",{className:"relative",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),a.jsx(Do,{className:"max-h-[220px]",children:0===I.length?a.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):a.jsx("div",{className:"p-1",children:I.map(e=>{const t=k.includes(e.id);return a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",t&&"bg-accent/50"),onClick:()=>R(e.id),children:[a.jsx("div",{className:Yt("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",t&&"bg-primary text-primary-foreground"),children:t&&a.jsx(d.Check,{className:"h-3 w-3"})}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&a.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),a.jsxs(Xt,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:L,children:[a.jsx(d.Plus,{className:"h-4 w-4"}),u]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:m}),a.jsx("div",{className:Yt("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===A.length?a.jsx("span",{className:"text-sm text-muted-foreground",children:p}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(e=>{const t=E.has(e.id);return a.jsxs(er,{variant:t?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!t&&a.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:a.jsx(d.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",v&&b&&a.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:b,children:v})]})]})]})})},exports.Muted=Xl,exports.NavigationMenu=ad,exports.NavigationMenuContent=od,exports.NavigationMenuIndicator=dd,exports.NavigationMenuItem=sd,exports.NavigationMenuLink=id,exports.NavigationMenuList=td,exports.NavigationMenuTrigger=nd,exports.NavigationMenuViewport=ld,exports.NavigationProvider=yp,exports.NumericPanel=sm,exports.OnboardingDialog=zc,exports.OnlineEditorDialog=function({open:e,onOpenChange:s,identifier:r,fileName:n,mode:o="edit",type:i="document",onClose:l,className:c}){const[u,m]=t.useState(!0),p=function(e,a="edit",t="document"){return`https://docs.google.com/${t}/d/${e}/${a}?usp=drivesdk?embedded=true&rm=demo`}(r,o,i);t.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=t.useCallback(()=>{l?.(),s(!1)},[l,s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,h]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",c),children:[a.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),a.jsx("div",{className:"flex items-center ml-4 z-20",children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})})]}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=Gl,exports.PRIORITIES=Mh,exports.PROD_PROJECT_ID=Pe,exports.PROGRESS_ALLOWED_STATUSES=Rh,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:s}){const r=e.length>t?[e[0],...e.slice(-(t-1))]:e,n=e.length>t;return a.jsx(dl,{className:s,children:a.jsx(cl,{children:r.map((e,t)=>{const s=0===t,r=n&&1===t;return a.jsxs(ul,{children:[!s&&a.jsx(hl,{}),r&&a.jsxs(a.Fragment,{children:[a.jsx(xl,{}),a.jsx(hl,{})]}),e.isCurrentPage?a.jsx(pl,{children:e.label}):a.jsx(ml,{asChild:!0,children:a.jsx(N.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=ti,exports.Pagination=cd,exports.PaginationContent=ud,exports.PaginationEllipsis=fd,exports.PaginationItem=md,exports.PaginationLink=pd,exports.PaginationNext=xd,exports.PaginationPrevious=hd,exports.PanelError=Ju,exports.PanelHeader=Xu,exports.PanelLoader=Zu,exports.PanelNoData=em,exports.PanelUnavailable=am,exports.ParetoPanel=mm,exports.PerformancePanel=hm,exports.PiePanel=um,exports.PlaceCard=zp,exports.PlacesList=function({places:e,isLoading:t,manageAccessConfig:s}){return t?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):e&&0!==e.length?a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>a.jsx(zp,{place:e,manageAccessConfig:s},e.id))]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[a.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Cr,exports.PopoverContent=Sr,exports.PopoverTrigger=kr,exports.Progress=gd,exports.ProtectedRoute=({children:s})=>{const{isAuthenticated:r,isLoading:n}=Pn();if(t.useEffect(()=>{if(n)return;if(r)return;if(an.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const s=ze(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{s?await _n.loginDev():_n.loginProd()})()},[r,n]),n&&!r)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Carregando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!r){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Iniciando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:ze()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return a.jsx(a.Fragment,{children:s})},exports.QUALIEX_CONFIG=Ve,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=vn,exports.QualiexErrorInterceptor=un,exports.QualiexUserField=Lo,exports.RadioGroup=vd,exports.RadioGroupItem=bd,exports.ReadOnlyTextField=mx,exports.ReportRequestList=function({requests:e,isLoading:s=!1,onGetReportUrl:r,formatDate:n=uu,labels:o,className:i}){const{t:l}=y.useTranslation(),c={...du,...o},[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(""),[g,v]=t.useState(""),[b,j]=t.useState(null),w=t.useMemo(()=>{if(!u)return e;const a=cu(u);return e.filter(e=>cu(e.reportName).includes(a))},[e,u]),N=t.useCallback(async e=>{if(!b){j(e.id);try{const a=await r(e.id);a&&(f(a),v(e.reportName),h(!0))}finally{j(null)}}},[r,b]);return s?a.jsx("div",{className:Yt("space-y-3",i),children:Array.from({length:5}).map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:Yt("space-y-3",i),children:[a.jsxs("div",{className:"relative max-w-sm",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:c.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),a.jsx(Do,{className:"rounded-md border",children:a.jsxs(In,{children:[a.jsx(Mn,{children:a.jsxs(Ln,{children:[a.jsx(zn,{className:"min-w-[140px]",children:c.report}),a.jsx(zn,{className:"min-w-[150px]",children:c.status}),a.jsx(zn,{className:"min-w-[160px]",children:c.requestDate}),a.jsx(zn,{className:"min-w-[160px]",children:c.lastUpdate}),a.jsx(zn,{className:"min-w-[160px]",children:c.expirationDate}),a.jsx(zn,{className:"min-w-[140px]"})]})}),a.jsx(Fn,{children:0===w.length?a.jsx(Ln,{children:a.jsx(Un,{colSpan:6,className:"text-center text-muted-foreground py-8",children:c.noResults})}):w.map(e=>{const t=function(e){const{t:a}=y.useTranslation();return new Date>new Date(e.expirationDate)&&e.statusId===exports.ReportRequestStatus.Completed?exports.ReportRequestStatus.Expired:e.statusId}(e),s=function(e,t){const{t:s}=y.useTranslation();switch(e){case exports.ReportRequestStatus.WaitingProcessing:return{label:t.statusWaiting,icon:a.jsx(d.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case exports.ReportRequestStatus.Processing:return{label:t.statusProcessing,icon:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case exports.ReportRequestStatus.Completed:return{label:t.statusCompleted,icon:a.jsx(d.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case exports.ReportRequestStatus.Error:return{label:t.statusError,icon:a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case exports.ReportRequestStatus.Expired:return{label:t.statusExpired,icon:a.jsx(d.TriangleAlert,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-orange-600 border-orange-300 bg-orange-50"};default:return{label:"—",icon:null,variant:"secondary"}}}(t,c),r=t===exports.ReportRequestStatus.Completed,o=t===exports.ReportRequestStatus.Expired;return a.jsxs(Ln,{children:[a.jsx(Un,{className:"font-medium",children:e.reportName}),a.jsx(Un,{children:a.jsxs(er,{variant:s.variant,className:Yt("gap-1",s.className),children:[s.icon,s.label]})}),a.jsx(Un,{className:"text-sm",children:n(new Date(e.requestDate))}),a.jsx(Un,{className:"text-sm",children:n(new Date(e.lastUpdate))}),a.jsx(Un,{className:Yt("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),a.jsx(Un,{children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!r||b===e.id,onClick:()=>N(e),children:[b===e.id?a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}):a.jsx(d.Eye,{className:"h-4 w-4"}),c.viewReport]})})]},e.id)})})]})})]}),a.jsx(tu,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ResizableHandle=({withHandle:e,className:t,...s})=>a.jsx(Ce.PanelResizeHandle,{className:Yt("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...s,children:e&&a.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:a.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=yd,exports.ResizablePanelGroup=({className:e,...t})=>a.jsx(Ce.PanelGroup,{className:Yt("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),exports.RichTextEditor=({value:s,onChange:r,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:c=!0,className:u})=>{const{t:m}=y.useTranslation(),[p,h]=t.useState("visual"),x=q.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,Y.Color,K.configure({multicolor:!0})],content:s||"",editable:!n,onUpdate:({editor:e})=>{r(e.getHTML())}});ae.useEffect(()=>{x&&s!==x.getHTML()&&x.commands.setContent(s||"")},[s,x]);const f=t.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?x.chain().focus().extendMarkRange("link").setLink({href:a}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?a.jsxs("div",{className:Yt("space-y-2",u),children:[l&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(Xt,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[a.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[a.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[a.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",a.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&a.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[a.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[a.jsx(Ic,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:a.jsx(d.Heading1,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:a.jsx(d.Heading2,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:a.jsx(d.Heading3,{className:"h-4 w-4"})}),a.jsx(Mc,{}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:a.jsx(d.Bold,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:a.jsx(d.Italic,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:a.jsx(d.Underline,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:a.jsx(d.Strikethrough,{className:"h-4 w-4"})}),a.jsx(Mc,{}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:a.jsx(d.List,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:a.jsx(d.ListOrdered,{className:"h-4 w-4"})}),a.jsx(Mc,{}),a.jsx(Ic,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:a.jsx(d.Highlighter,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:a.jsx(d.Link,{className:"h-4 w-4"})}),a.jsx(Mc,{}),a.jsx(Ic,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:a.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),a.jsx(Mc,{}),a.jsx(Ic,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:a.jsx(d.Undo,{className:"h-4 w-4"})}),a.jsx(Ic,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:a.jsx(d.Redo,{className:"h-4 w-4"})})]}),a.jsx(q.EditorContent,{editor:x,className:Yt("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:i}})]}),"code"===p&&a.jsx("textarea",{value:s||"",onChange:e=>r(e.target.value),disabled:n,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===p&&a.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:a.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:a.jsx("div",{dangerouslySetInnerHTML:{__html:s||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Re,exports.STATUS_COLORS=Th,exports.STATUS_LABELS=Ah,exports.STATUS_MAP=Dh,exports.STATUS_TEXT_COLORS=Ph,exports.SUPPORTED_LOCALES=Pt,exports.ScrollArea=Do,exports.ScrollBar=Eo,exports.Select=Vs,exports.SelectApproverDialog=Lx,exports.SelectContent=Gs,exports.SelectGroup=Bs,exports.SelectItem=Ks,exports.SelectLabel=Ys,exports.SelectScrollDownButton=Hs,exports.SelectScrollUpButton=Ws,exports.SelectSearch=Ur,exports.SelectSeparator=Qs,exports.SelectTrigger=$s,exports.SelectValue=qs,exports.Separator=ls,exports.Sheet=jd,exports.SheetBody=Pd,exports.SheetClose=Nd,exports.SheetContent=Sd,exports.SheetDescription=Ad,exports.SheetFooter=Dd,exports.SheetHeader=Td,exports.SheetOverlay=Cd,exports.SheetPortal=_d,exports.SheetTitle=Ed,exports.SheetTrigger=wd,exports.Sidebar=Ld,exports.SidebarActionTrigger=Sp,exports.SidebarContent=Wd,exports.SidebarFooter=qd,exports.SidebarGroup=Hd,exports.SidebarGroupAction=Yd,exports.SidebarGroupContent=Kd,exports.SidebarGroupLabel=Gd,exports.SidebarHeader=function({open:e,appName:s}){const[r,n]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx(Bd,{className:"p-0 gap-0",children:e?a.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),s&&a.jsx("button",{className:"flex-1 min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground hover:text-primary-foreground/80 transition-colors leading-tight py-1",onClick:()=>n(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(s)})})]}):a.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:a.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),a.jsx(Yi,{open:r,onOpenChange:n})]})},exports.SidebarInput=Vd,exports.SidebarInset=Od,exports.SidebarLogo=_p,exports.SidebarMenu=Qd,exports.SidebarMenuAction=ec,exports.SidebarMenuBadge=ac,exports.SidebarMenuButton=Zd,exports.SidebarMenuItem=Xd,exports.SidebarMenuSkeleton=tc,exports.SidebarMenuSub=sc,exports.SidebarMenuSubButton=nc,exports.SidebarMenuSubItem=rc,exports.SidebarProvider=Rd,exports.SidebarRail=Ud,exports.SidebarSeparator=$d,exports.SidebarSkeleton=function(){return a.jsx("div",{className:"w-64 border-r bg-muted/10",children:a.jsxs("div",{className:"p-4",children:[a.jsx(Rr,{className:"h-8 w-32 mb-6"}),a.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>a.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[a.jsx(Rr,{className:"h-4 w-4"}),a.jsx(Rr,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=zd,exports.SignConfigForm=function({onSaved:e}){const{config:s,isLoading:r,saveConfig:n}=ph(),{t:o}=y.useTranslation(),[i,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?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a.jsxs("div",{className:"space-y-4",children:[s?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[a.jsx(d.CheckCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_configured",o("sign_configured_unit"))})]}):a.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_not_configured",o("sign_not_configured_unit"))})]}),a.jsxs(ts,{children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-base",children:o("sign_digital_config")})}),a.jsx(os,{children:a.jsxs("form",{onSubmit:async a=>{if(a.preventDefault(),i.trim()){h(!0);try{await n(i.trim(),u),l.toast.success(o("sign_config_saved",o("sign_config_saved_success"))),e?.()}catch(t){l.toast.error(o("sign_config_save_error",o("sign_config_save_err")))}finally{h(!1)}}else l.toast.error(o("sign_api_key_required",o("sign_api_key_info")))},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"sign-api-key",children:"API Key"}),a.jsx(Zt,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder",o("sign_api_key_input")),value:i,onChange:e=>c(e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:o("sign_environment","Ambiente")}),a.jsxs(Vs,{value:u,onValueChange:e=>m(e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"sandbox",children:"Sandbox (Testes)"}),a.jsx(Ks,{value:"production",children:"Produção"})]})]})]}),a.jsxs(Xt,{type:"submit",disabled:p,children:[p&&a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config",o("sign_update_config_btn")):o("sign_save_config",o("sign_save_config_btn"))]})]})})]})]})},exports.SignWidget=jh,exports.SingleFileUpload=function({storedFile:e,customFileName:s,allowedExtensions:r,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:c=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:v,onFileReplace:b,onDownload:j,onView:w,className:N}){const{t:_}=y.useTranslation(),C=t.useRef(null),[k,S]=t.useState(null),[T,P]=t.useState(null),[D,E]=t.useState(!1),A=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&ox(I);const F=s||I,R=l&&!k&&!!e,L=c&&!k&&!!e,z=!!T||!!f||p&&h&&!A,U=!!A,O=t.useCallback(e=>{if(rx.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(r?.length){const a=ox(e.name);if(!r.includes(a))return{type:"extension",message:n}}return null},[o,i,r,n]),V=t.useCallback(e=>{const a=e.target.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),S(null),void(C.current&&(C.current.value=""));P(null),S(a),g?.(a),C.current&&(C.current.value="")},[O,g]),B=t.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const a=e.dataTransfer.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),void S(null);P(null),S(a),g?.(a)},[x,O,g]),q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=t.useCallback(()=>{b?.(),C.current?.click()},[b]),W=t.useCallback(()=>{S(null),P(null),v?.(),C.current&&(C.current.value="")},[v]),H=t.useCallback(async()=>{if(!D&&e&&j){E(!0);try{await j(e)}finally{E(!1)}}},[D,e,j]),G=t.useCallback(()=>{e&&w&&w(e)},[e,w]),Y=t.useCallback(()=>{x||C.current?.click()},[x]),K=(()=>{if(f)return f;if(!T)return p&&h&&!A?_("required_field"):null;switch(T.type){case"extension":return T.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${nx(o)}`;case"max-size":return`Tamanho máximo: ${nx(i)}`;default:return _("file_error")}})();return a.jsxs("div",{className:Yt("space-y-1",N),children:[a.jsx("div",{className:Yt("rounded-md border border-dashed transition-colors",U&&"border-solid border-border",!U&&"border-muted-foreground/30 hover:border-primary/50 cursor-pointer",z&&"border-destructive border-solid",x&&"opacity-50 pointer-events-none"),children:U?a.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(d.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-xs truncate",children:F})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&a.jsx("span",{className:"text-xs text-muted-foreground",children:nx(M)}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[R&&j&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:D,onClick:H,children:a.jsx(d.Download,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Download"})]}),L&&w&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Visualizar"})]}),u&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Substituir"})]}),m&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground"})})}),a.jsx(Nr,{children:_("remove")})]})]})]})]}):a.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:Y,onKeyDown:e=>"Enter"===e.key&&Y(),onDrop:B,onDragOver:q,children:[a.jsx(d.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",a.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),K&&a.jsx("p",{className:"text-xs text-destructive",children:K}),a.jsx("input",{ref:C,type:"file",className:"hidden",accept:r?.map(e=>`.${e}`).join(","),onChange:V,disabled:x})]})},exports.Skeleton=Rr,exports.Slider=oc,exports.Small=Ql,exports.SonnerToaster=rr,exports.Spinner=tr,exports.SplitButton=Uc,exports.Stack=$o,exports.StatusBadge=pu,exports.StepSelector=$c,exports.Stepper=$c,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:s={},minHeight:r="80vh",...n}){const o=t.useMemo(()=>{const a=`${e}/api/reports/v1/Viewer/InitViewer`,t=new URLSearchParams(s).toString();return t?`${a}?${t}`:a},[e,s]);return a.jsx(tu,{...n,url:o,minHeight:r})},exports.Switch=Fo,exports.TIMEZONES=Et,exports.TabPageContent=function({children:e,className:t}){return a.jsx("div",{className:Yt("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:s,className:r}){return a.jsxs("div",{className:Yt("space-y-4",r),children:[a.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),a.jsx(ls,{})]})},exports.TabPageLayout=function({children:e,className:t}){return a.jsx("div",{className:Yt("flex flex-col h-full",t),children:a.jsx(Do,{className:"flex-1",children:a.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=In,exports.TableBody=Fn,exports.TableCaption=On,exports.TableCell=Un,exports.TableFooter=Rn,exports.TableHead=zn,exports.TableHeader=Mn,exports.TableResizeHandle=Hn,exports.TableRow=Ln,exports.TableRowActions=co,exports.TableSkeleton=Vn,exports.Tabs=ji,exports.TabsContent=_i,exports.TabsList=wi,exports.TabsTrigger=Ni,exports.TeamSelector=function({users:e,value:s,onChange:r,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:c="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=y.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=t.useState(""),[v,b]=t.useState(!1),[j,w]=t.useState(null),N=t.useMemo(()=>new Set(s),[s]),_=t.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=t.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=t.useCallback(e=>{e&&!N.has(e)&&(r([...s,e]),g(""))},[s,r,N]),S=t.useCallback(e=>{i?(w(e),b(!0)):r(s.filter(a=>a!==e))},[s,r,i]),T=t.useCallback(()=>{j&&r(s.filter(e=>e!==j)),b(!1),w(null)},[j,s,r]);return a.jsxs("div",{className:Yt("space-y-3",m),children:[a.jsx("div",{className:"flex items-start gap-3",children:a.jsx("div",{className:"flex-1",children:a.jsx(Ur,{options:C,value:f,onValueChange:e=>{const a="string"==typeof e?e:e?.[0]??"";g(a),a&&k(a)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),a.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?a.jsx("div",{className:"space-y-2",children:_.map(e=>a.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[a.jsxs(ol,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(il,{src:e.avatar,alt:e.name}),a.jsx(ll,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.Shield,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.MapPin,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),a.jsx("button",{type:"button",className:Yt("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:a.jsx(d.X,{className:"h-4 w-4"})})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[a.jsx(d.User,{className:"h-12 w-12 mb-2 opacity-30"}),a.jsx("p",{className:"text-sm",children:x})]}),a.jsx(ys,{open:v,onOpenChange:b,children:a.jsxs(ks,{className:"sm:max-w-[400px]",children:[a.jsx(Ss,{children:a.jsx(Ds,{children:h})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:c}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>b(!1),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:T,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:s,open:r,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:c=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=t.useState(!1),h=t.useCallback(()=>{o(s.id)},[o,s.id]);return a.jsxs(a.Fragment,{children:[a.jsx(ys,{open:r&&!m,onOpenChange:e=>!e&&n(),children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsxs(Ds,{className:"flex items-center gap-2",children:[a.jsx(d.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),a.jsxs("div",{className:"space-y-4",children:[s.description&&a.jsx(Do,{className:"max-h-48",children:a.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:s.description}})}),s.file&&a.jsxs(Xt,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[a.jsx(d.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),a.jsxs(Ps,{className:"gap-2 sm:gap-0",children:[a.jsx(Xt,{variant:"ghost",onClick:n,children:l}),a.jsx(Xt,{onClick:h,children:c})]})]})}),m&&a.jsx(su,{term:s,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=su,exports.TextPanel=rm,exports.Textarea=Js,exports.Timepicker=qc,exports.Toaster=rr,exports.Toggle=xo,exports.ToggleGroup=go,exports.ToggleGroupItem=vo,exports.TokenManager=an,exports.TokenService=Hr,exports.Tooltip=jr,exports.TooltipContent=Nr,exports.TooltipProvider=yr,exports.TooltipTrigger=wr,exports.TreeSelect=Wr,exports.TreeTable=pp,exports.TruncatedCell=Wn,exports.UpdatesNotification=Yc,exports.UsersGroupsSelector=function({users:s,groups:r=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:c=!1,searchPlaceholder:u="Buscar usuário...",selectLabel:m="Selecionar",doneLabel:p="Concluir",allLabel:h="Todos",emptyLabel:x=e.t("leadership_no_user_selected"),selectedLabel:f="selecionado",selectedPluralLabel:g="selecionados",className:v}){const[b,y]=t.useState(!1),[j,w]=t.useState(""),[N,_]=t.useState(void 0),C=t.useMemo(()=>new Set(n),[n]),k=t.useMemo(()=>{let e=s;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),j){const a=nu(j);e=e.filter(e=>nu(e.name).includes(a)||nu(e.email??"").includes(a))}return e},[s,N,j]),S=t.useMemo(()=>b?k:s.filter(e=>C.has(e.id)),[b,k,s,C]),T=n.length,P=t.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),D=t.useCallback(e=>{if(i)return;const a=C.has(e)?n.filter(a=>a!==e):[...n,e];o(a)},[n,C,o,i]),E=t.useCallback(e=>{if(i)return;const a=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...a]);o(Array.from(e))}else o(n.filter(e=>!a.has(e)))},[n,k,o,i]),A=t.useCallback(()=>{y(e=>!e),w(""),_(void 0)},[]);return a.jsxs("div",{className:Yt("rounded-md border bg-muted/30",v),children:[(!i||T>0)&&a.jsxs("div",{className:Yt("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:A,children:[a.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(b?p:m)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:T>0&&`${T} ${1===T?f:g}`})]}),a.jsxs("div",{className:"px-4 pb-3",children:[b&&a.jsxs("div",{className:"flex gap-3 mb-3",children:[!c&&r.length>0&&a.jsxs(Vs,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[a.jsx($s,{className:"w-[200px] h-9 text-sm",children:a.jsx(qs,{placeholder:e.t("approval_user_group")})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"__all__",children:e.t("team_all_groups")}),r.map(e=>a.jsx(Ks,{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:u,value:j,onChange:e=>w(e.target.value)})]})]}),!b&&0===T&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[a.jsx(d.Users,{className:"h-4 w-4 mr-2"}),x]}),b&&k.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Xs,{checked:P,onCheckedChange:e=>E(!!e)}),a.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&a.jsx(Do,{style:{maxHeight:l},className:"pr-2",children:a.jsx("div",{className:"space-y-0.5",children:S.map(e=>a.jsxs("div",{className:Yt("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",b&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:b?()=>D(e.id):void 0,children:[b&&a.jsx(Xs,{checked:C.has(e.id),onCheckedChange:()=>D(e.id),onClick:e=>e.stopPropagation()}),a.jsxs(ol,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(il,{src:e.avatar,alt:e.name}),a.jsx(ll,{className:"text-xs",children:ru(e.name)})]}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})}),b&&0===k.length&&a.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:s,onChange:r,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:c,uploadOptions:u}){const{t:m}=y.useTranslation(),[p,h]=t.useState(s||{inputType:"url",controls:!0}),x=t.useRef(null),f=t.useRef(null),{upload:g,uploading:v}=nh({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:b,uploading:j}=nh({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),w=t.useMemo(()=>uh(p.videoUrl||ch(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,a)=>{const t={...p,[e]:a};h(t),r(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("input_type")}),a.jsxs(Vs,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ks,{value:"url",children:"URL"}),a.jsx(Ks,{value:"upload",children:m("file_upload")}),a.jsx(Ks,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Arquivo"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};h(t),r(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:v,children:v?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&a.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",p.videoFile," (",Math.round((p.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===p.inputType&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("embed_code")}),a.jsx(Js,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Thumbnail"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),a.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await b(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(t),r(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:j,children:j?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"title",children:"Título"}),a.jsx(Zt,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),a.jsxs("div",{className:"flex gap-6",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),a.jsx(as,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),a.jsx(as,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||ch(p.embedCode)||"";if(!t)return a.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===w)return a.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[a.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const s="youtube"===w?ih(t,p.autoplay):dh(t,p.autoplay);return a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:p.title||e.t("video"),src:s,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{p.videoUrl||p.embedCode?n(p):l.toast.error("Erro",{description:m("no_video_selected")})},disabled:!(p.videoUrl||p.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:s="",style:r}){const n=t.videoUrl||ch(t.embedCode)||"";if(!n)return null;const o=uh(n);return a.jsx(ts,{className:`overflow-hidden my-4 ${s}`,style:r,children:a.jsxs(os,{className:"p-0",children:["file"===o?a.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[a.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:t.title||e.t("video"),src:"youtube"===o?ih(n,t.autoplay):dh(n,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&&a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:s,template:r,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:c=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:v=!1,readingConfirmationTimeRemaining:b,onIframeLoad:j,className:w}){const{t:N}=y.useTranslation(),_=t.useRef(null),C=n??Jc(r.extension),k=c||v||h,S=r.code?`${r.code} – ${r.name}`:r.name,T=t.useCallback(()=>{_.current&&j&&j(_.current)},[j]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&s(!1)};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,s]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Yt("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"w-[90vw]",w),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),a.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&a.jsxs(a.Fragment,{children:[(x||f)&&a.jsx(a.Fragment,{children:f?a.jsxs("div",{className:"flex flex-col mr-2.5",children:[a.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[a.jsx(d.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=b&&b>0?a.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[a.jsx("span",{children:N("terms_confirmation_available")}),a.jsx("span",{className:"font-medium min-w-[72px]",children:au(b)}),a.jsx("span",{children:"segundos"})]}):a.jsxs(Xt,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[a.jsx(d.ShieldCheck,{className:"h-4 w-4 mr-1"}),v?"Confirmando...":N("terms_confirm_reading")]})}),C!==exports.FileViewerType.none&&u&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:a.jsx(d.Star,{className:Yt("h-4 w-4",m&&"fill-accent text-accent")})})}),a.jsx(Nr,{children:m?"Desfavoritar":"Favoritar"})]}),C!==exports.FileViewerType.none&&i&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:a.jsx(d.Download,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Download"})]})]}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>s(!1),children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]})]}),a.jsx("div",{className:Yt("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",C===exports.FileViewerType.none&&"min-h-[124px]",C===exports.FileViewerType.image&&"max-h-[85vh]",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"min-w-[77vw] min-h-[80vh]"),children:o?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs(a.Fragment,{children:[(C===exports.FileViewerType.none||!r.url)&&a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),a.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),C===exports.FileViewerType.image&&a.jsx("img",{loading:"eager",src:r.url,alt:r.name,className:"max-w-full max-h-[85vh] object-contain"}),C===exports.FileViewerType.video&&a.jsx("video",{controls:!0,autoPlay:!0,src:r.url,className:"w-full h-full"}),C===exports.FileViewerType.audio&&a.jsx("audio",{controls:!0,autoPlay:!0,src:r.url}),(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{ref:_,src:r.url,onLoad:T,className:"border-none w-full h-full z-[1] relative",title:r.name})]})]})}),!o&&C===exports.FileViewerType.none&&a.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),i&&a.jsx(Xt,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.addAppTranslations=li,exports.addChild=Um,exports.addSibling=Om,exports.assets=We,exports.badgeVariants=Zs,exports.buildDetailRows=Sx,exports.buildHierarchy=Op,exports.buildModuleUrl=Gt,exports.buildPlacesTree=function(e){e.forEach(a=>{a.children=e.filter(e=>e.parentId===a.id)});const a=e.filter(e=>!e.parentId);return function e(a,t){a?.forEach(a=>{t(a),a.children&&e(a.children,t)})}(a,a=>{a.children=e.filter(e=>e.parentId===a.id)}),a},exports.buildWopiUrl=function(e){const{t:a}=y.useTranslation(),{viewerUrl:t,wopiUrl:s,fileId:r,token:n,extension:o,language:i="pt-br"}=e,l=eu(o);return l?`${t}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${s}${r}`)}`:null},exports.buttonGroupVariants=fl,exports.buttonVariants=Qt,exports.calculateAspectRatio=mh,exports.camelToDash=Ax,exports.cn=Yt,exports.createCrudPage=function(e){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=e,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit: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 a.jsx(Ho,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=hp({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createMindMapNode=Mm,exports.createRoutingHandlers=hp,exports.createService=jn,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=jn({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:a,useCrudHook:(t,s)=>Dn({queryKey:e.tableName,service:a,entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.createStatusConfig=function(e){return a=>e[a]},exports.createTranslatedMessages=a=>({success:{created:a=>e.t("msg_created_success",`${a} criado com sucesso`).replace("{{entity}}",a),updated:a=>e.t("msg_updated_success",`${a} atualizado com sucesso`).replace("{{entity}}",a),deleted:a=>e.t("msg_deleted_success",`${a} removido com sucesso`).replace("{{entity}}",a)},error:{create:a=>e.t("msg_create_error",`Erro ao criar ${a}`).replace("{{entity}}",a),update:a=>e.t("msg_update_error",`Erro ao atualizar ${a}`).replace("{{entity}}",a),delete:a=>e.t("msg_delete_error",`Erro ao remover ${a}`).replace("{{entity}}",a),load:a=>e.t("msg_load_error",`Erro ao carregar ${a}`).replace("{{entity}}",a)}}),exports.currencyFormatter=Gu,exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=hn,exports.deriveNameField=pn,exports.deriveUsernameField=xn,exports.detectBrowserLocale=Lt,exports.detectBrowserPreferences=()=>{const e=Lt();return{locale:e,timezone:zt(),datetimeFormat:Ut(e)}},exports.detectBrowserTimezone=zt,exports.detectVideoProvider=uh,exports.emailService=Rp,exports.errorService=tn,exports.exportMindMap=rp,exports.extractImageFileName=function(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}},exports.extractNumberFromCurrency=function(e){const a=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(a)},exports.extractVimeoId=lh,exports.extractYouTubeId=oh,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))},exports.findDatetimeFormat=e=>Dt.find(a=>a.value===e),exports.findLocale=e=>Pt.find(a=>a.value===e),exports.findNode=Fm,exports.findTimezone=e=>Et.find(a=>a.value===e),exports.flattenTree=Vp,exports.formatBytes=nx,exports.formatCurrency=(e,a="BRL",t="pt-BR")=>null==e?"":new Intl.NumberFormat(t,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Bt,exports.formatDatetime=Vt,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.formatTime=$h,exports.formatTimeProgress=qh,exports.generateCrudConfig=function(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:Yo(e),label:Yo(e),...Go(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.generateNodeId=Im,exports.generatePastelBg=$t,exports.getActionTypes=function(){return[{id:"immediate",label:e.t("ap_type_immediate")},{id:"corrective",label:e.t("ap_type_corrective")},{id:"preventive",label:e.t("ap_type_preventive")},{id:"improvement",label:e.t("ap_type_improvement")},{id:"standardization",label:e.t("ap_type_standardization")}]},exports.getContrastRatio=function(e,a){const t=Wt(e),s=Wt(a);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.List:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Text:case exports.DashboardPanelType.StackedColumn:return{x:4,y:2};case exports.DashboardPanelType.Pareto:case exports.DashboardPanelType.RiskMatrix:case exports.DashboardPanelType.Burndown:case exports.DashboardPanelType.PerformanceColumns:return{x:8,y:2};case exports.DashboardPanelType.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getEnvironmentConfig=Ae,exports.getFieldValue=cx,exports.getFileExtension=ox,exports.getFormFieldValues=function(e){return e.filter(e=>e.type!==exports.ECustomFormFieldType.readOnlyText).map(e=>({formFieldAssociationId:e.id,textValue:e.type===exports.ECustomFormFieldType.text?e.textValue:void 0,numberValue:e.type===exports.ECustomFormFieldType.number?e.numberValue:void 0,dateValue:e.type===exports.ECustomFormFieldType.date?e.dateValue:void 0,timeValue:e.type===exports.ECustomFormFieldType.time?e.timeValue:void 0,itemsValue:[exports.ECustomFormFieldType.url,exports.ECustomFormFieldType.singleSelection,exports.ECustomFormFieldType.multiSelection].includes(e.type)?e.itemsValue:void 0,questionsValue:e.type===exports.ECustomFormFieldType.questions?e.questionsValue:void 0}))},exports.getLinkFromRow=$u,exports.getLuminance=Wt,exports.getMinPanelSize=gm,exports.getOnlineViewerType=function(e){const{t:a}=y.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getPriorities=function(){return[{id:exports.ETaskPlanPriority.low,label:e.t("ap_priority_low"),color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:e.t("ap_priority_medium"),color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:e.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=Wh,exports.getQualiexApiUrl=Oe,exports.getStatusLabels=Eh,exports.getSupabaseClient=on,exports.getViewerType=Jc,exports.getWopiViewer=eu,exports.handleExternalLink=Ht,exports.importMindMap=function(e){return np(JSON.parse(e))},exports.inferDatetimeFormat=Ut,exports.inputGroupAddonVariants=Ll,exports.inputGroupButtonVariants=Ul,exports.isCurrency=function(e){return!!Hu.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnvironment=Ue,exports.isDevSupabaseProject=Ie,exports.isImageUrl=function(e){const a=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const t=new URL(e);return a.some(e=>t.pathname.toLowerCase().endsWith(e))}catch{const t=e.toLowerCase();return a.some(e=>t.endsWith(e))}},exports.isLovablePreview=Le,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isValidDatetimeFormat=e=>Dt.some(a=>a.value===e),exports.isValidLocale=Ft,exports.isValidTimezone=Rt,exports.loadClicksignScript=bh,exports.loadForlogicFonts=Zi,exports.logoSrc=He,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.moveNode=Bm,exports.navigationMenuTriggerStyle=rd,exports.normalizeVideoUrl=function(e,a,t){switch(a||uh(e)){case"youtube":return ih(e,t);case"vimeo":return dh(e,t);default:return e}},exports.normalizeVimeoUrl=dh,exports.normalizeYouTubeUrl=ih,exports.parseIframeSrc=ch,exports.placeService=Up,exports.processTrails=_x,exports.processUrl=qu,exports.qualiexApi=mn,exports.removeNode=Vm,exports.resizeKeepingAspect=function(e,a,t,s){const r=mh(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=fn,exports.resolvePageTitle=wp,exports.setCollapsedAll=$m,exports.setFormFieldValues=function(e,a){return a?.length?e.map(e=>{const t=a.find(a=>a.formFieldAssociationId===e.id);if(!t)return e;const s={...e};switch(e.type){case exports.ECustomFormFieldType.text:s.textValue=t.textValue;break;case exports.ECustomFormFieldType.number:s.numberValue=t.numberValue;break;case exports.ECustomFormFieldType.date:s.dateValue=t.dateValue;break;case exports.ECustomFormFieldType.time:s.timeValue=t.timeValue;break;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:s.itemsValue=t.itemsValue||[];break;case exports.ECustomFormFieldType.questions:s.questionsValue=t.questionsValue||[]}return s}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new w.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=ux,exports.shouldUseDevTokens=ze,exports.signService=gh,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=Ge,exports.sortByMonthYear=function(e){return e?.sort((e,a)=>{if(!e?.items?.length||!a?.items?.length)return 0;return Bu(e.items[0]?.keyDate)-Bu(a.items[0]?.keyDate)})},exports.toQueryString=function(e){return e?Wu(e).join("&"):null},exports.toggleCollapsed=qm,exports.toggleVariants=ho,exports.trackFooterClick=Li,exports.trackInterestClick=Ri,exports.trackModuleClick=Fi,exports.trimTextFields=Kt,exports.useActionPlan=Lh,exports.useActionPlanProgress=Bh,exports.useActiveModules=(e={})=>{const{enabled:a=!0}=e,{alias:t}=Pn();return w.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=on(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!cn.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},exports.useAliasFromUrl=Ko,exports.useAuth=Pn,exports.useBaseForm=So,exports.useClarity=el,exports.useColumnManager=wo,exports.useColumnResize=po,exports.useCreateMultipleLeadersMutation=Wp,exports.useCreateSingleLeaderMutation=$p,exports.useCrud=Dn,exports.useDebounce=Np,exports.useDerivedContractedModules=Gi,exports.useFormField=Ms,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Ap();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a}=pi(),t=It;return{formatDatetime:s=>Vt(s,t,a,e),formatDate:t=>Bt(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useIsMobile=An,exports.useLeadershipApi=Bp,exports.useLocale=pi,exports.useMediaQuery=En,exports.useMediaUpload=nh,exports.useModalState=Ap,exports.useModuleAccess=Hi,exports.useModuleConfig=fi,exports.useNavigation=jp,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=si(),r=t.useRef({});t.useEffect(()=>{const t=JSON.stringify(r.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(r.current.title!==e.title||r.current.subtitle!==e.subtitle||t)&&(r.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},a(e)),()=>s()},[e.title,e.subtitle,e.breadcrumbs,a,s])},exports.usePageMetadataContext=si,exports.usePageTitle=function(){const e=N.useLocation(),{navigation:a}=jp();return wp(a,e.pathname)},exports.usePermissionQuery=kp,exports.useQualiexUsers=Ro,exports.useRemoveLeaderMutation=Gp,exports.useRouteBreadcrumbs=function(){const e=N.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:o,href:n?void 0:s,isCurrentPage:n})}),t})()},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),x=t.useRef(0),f=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,x.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return o?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,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 v=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:v,getRowHeight:f}},exports.useSidebar=Fd,exports.useSidebarResize=Dp,exports.useSignConfig=ph,exports.useSyncSubordinatesMutation=Yp,exports.useUpdateLeaderMutation=Hp,exports.useUpdatesNotification=Gc,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),x=a.length,f=0===i,g=i===x-1,v=a[i],b=x>1?(i+1)/x*100:100,y=t.useCallback(()=>!v?.canProceed||v.canProceed(),[v]),j=t.useMemo(()=>y(),[y,d]),w=t.useMemo(()=>!f&&!v?.disableBack,[f,v]),N=t.useCallback(e=>{c(a=>({...a,...e}))},[]),_=t.useCallback((e,a)=>{c(t=>({...t,[e]:a}))},[]),C=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),k=t.useCallback(async()=>{if(y()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[y,p,d,n]),S=t.useCallback(async()=>{y()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[y,u,g,x,k]),T=t.useCallback(()=>{w&&!u&&l(e=>Math.max(e-1,0))},[w,u]),P=t.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),D=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:v,data:d,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:T,goTo:P,canProceed:j,canGoBack:w,setData:N,updateField:_,reset:C,complete:k,setLoading:D,progress:b,stepIndex:i,totalSteps:x}},exports.validateFields=function(e){const a=[];return e.forEach(e=>{if(!e.required||e.readOnly||e.type===exports.ECustomFormFieldType.readOnlyText)return;const t=cx(e);if((null==t||""===t||Array.isArray(t)&&0===t.length)&&a.push(e.id),e.type===exports.ECustomFormFieldType.number&&null!=t){const s=e.config;null!=s?.min&&t<s.min&&a.push(e.id),null!=s?.max&&t>s.max&&a.push(e.id)}}),{valid:0===a.length,invalidFields:[...new Set(a)]}};
|
|
1
|
+
"use strict";var e=require("i18next"),a=require("react/jsx-runtime"),t=require("react"),s=require("@radix-ui/react-slot"),r=require("class-variance-authority"),n=require("clsx"),o=require("tailwind-merge"),i=require("date-fns"),l=require("sonner"),d=require("lucide-react"),c=require("@radix-ui/react-label"),u=require("@radix-ui/react-dialog"),m=require("@radix-ui/react-separator"),p=require("@radix-ui/react-alert-dialog"),h=require("react-hook-form"),x=require("@radix-ui/react-select"),f=require("@radix-ui/react-checkbox"),g=require("@radix-ui/react-dropdown-menu"),v=require("@radix-ui/react-tooltip"),b=require("@radix-ui/react-popover"),y=require("react-i18next"),j=require("@supabase/supabase-js"),w=require("@tanstack/react-query"),N=require("react-router-dom"),_=require("@radix-ui/react-context-menu"),C=require("@radix-ui/react-toggle-group"),k=require("@radix-ui/react-toggle"),S=require("@radix-ui/react-scroll-area"),T=require("@radix-ui/react-switch"),P=require("@radix-ui/react-collapsible"),E=require("@radix-ui/react-tabs"),D=require("@radix-ui/react-accordion"),A=require("@radix-ui/react-avatar"),I=require("react-day-picker"),M=require("vaul"),F=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"),U=require("react-resizable-panels"),O=require("@radix-ui/react-slider"),V=require("@radix-ui/react-menubar"),B=require("recharts"),q=require("@tiptap/react"),$=require("@tiptap/starter-kit"),W=require("@tiptap/extension-underline"),H=require("@tiptap/extension-link"),G=require("@tiptap/extension-text-style"),K=require("@tiptap/extension-color"),Y=require("@tiptap/extension-highlight"),Q=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),J=require("zod"),Z=require("@hookform/resolvers");function ee(e){var a=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}}),a.default=e,Object.freeze(a)}var ae=ee(t),te=ee(d),se=ee(c),re=ee(u),ne=ee(m),oe=ee(p),ie=ee(x),le=ee(f),de=ee(g),ce=ee(v),ue=ee(b),me=ee(_),pe=ee(C),he=ee(k),xe=ee(S),fe=ee(T),ge=ee(P),ve=ee(E),be=ee(D),ye=ee(A),je=ee(F),we=ee(R),Ne=ee(L),_e=ee(z),Ce=ee(U),ke=ee(O),Se=ee(V),Te=ee(B);const Pe="ccjfvpnndclajkleyqkc",Ee={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api.qualiex.com"},De={storageProjectId:"ccjfvpnndclajkleyqkc",oauth:{authUrl:"https://login-dev.qualiex.com/oauth2/authorize",clientId:"ae6021a0-e874-4aab-9716-b478e59cec20"},qualiexApiUrl:"https://common-v4-api-dev.qualiex.com"};function Ae(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e===Pe?Ee:De}function Ie(){let e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)try{const a=(void 0).VITE_SUPABASE_URL;a&&(e=new URL(a).hostname.split(".")[0])}catch{}return e!==Pe}const Me={get oauth(){const e=Ae();return{authUrl:e.oauth.authUrl,clientId:e.oauth.clientId,responseType:"id_token token",scope:"openid profile email"}}},Fe={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Re={debounceDelay:500},Le=()=>{const e=window.location.origin,a=(()=>{try{return window.self!==window.top}catch{return!0}})();return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("lovable.dev")||e.includes("lovable.app")&&a||(void 0).DEV},ze=()=>Le(),Ue=Le,Oe=()=>Ae().qualiexApiUrl,Ve={userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"},Be={isQualiex:"true"===(void 0).VITE_IS_QUALIEX},qe={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}`}},$e=`https://${Ae().storageProjectId}.supabase.co/storage/v1/object/public/library-assets`,We={logo:Be.isQualiex?`${$e}/logo-qualiex-white.svg`:`${$e}/saber-gestao-white.png`,smallLogo:Be.isQualiex?`${$e}/logo-forlogic-white.svg`:`${$e}/small.svg`,favicon:`${$e}/favicon.png`},He=We.logo,Ge=We.smallLogo;if("undefined"!=typeof document){document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(e=>e.remove());const e=document.createElement("link");e.rel="icon",e.type="image/png",e.href=We.favicon,document.head.appendChild(e)}const Ke={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 Ye(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Qe={date:Ye({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Ye({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:Ye({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Xe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function Je(e){return(a,t)=>{let s;if("formatting"===(t?.context?String(t.context):"standalone")&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,r=t?.width?String(t.width):a;s=e.formattingValues[r]||e.formattingValues[a]}else{const a=e.defaultWidth,r=t?.width?String(t.width):e.defaultWidth;s=e.values[r]||e.values[a]}return s[e.argumentCallback?e.argumentCallback(a):a]}}function Ze(e){return(a,t={})=>{const s=t.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],n=a.match(r);if(!n)return null;const o=n[0],i=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?function(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t;return}(i,e=>e.test(o)):function(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t;return}(i,e=>e.test(o));let d;d=e.valueCallback?e.valueCallback(l):l,d=t.valueCallback?t.valueCallback(d):d;return{value:d,rest:a.slice(o.length)}}}function ea(e){return(a,t={})=>{const s=a.match(e.matchPattern);if(!s)return null;const r=s[0],n=a.match(e.parsePattern);if(!n)return null;let o=e.valueCallback?e.valueCallback(n[0]):n[0];o=t.valueCallback?t.valueCallback(o):o;return{value:o,rest:a.slice(r.length)}}}const aa={code:"en-US",formatDistance:(e,a,t)=>{let s;const r=Ke[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s},formatLong:Qe,formatRelative:(e,a,t,s)=>Xe[e],localize:{ordinalNumber:(e,a)=>{const t=Number(e),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:Je({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};let ta={};function sa(){return ta}const ra=6048e5;function na(e){const a=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===a?new e.constructor(+e):"number"==typeof e||"[object Number]"===a||"string"==typeof e||"[object String]"===a?new Date(e):new Date(NaN)}function oa(e){const a=na(e);return a.setHours(0,0,0,0),a}function ia(e){const a=na(e),t=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return t.setUTCFullYear(a.getFullYear()),+e-+t}function la(e,a){return e instanceof Date?new e.constructor(a):new Date(a)}function da(e){const a=na(e),t=function(e,a){const t=oa(e),s=oa(a),r=+t-ia(t),n=+s-ia(s);return Math.round((r-n)/864e5)}(a,function(e){const a=na(e),t=la(e,0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}(a));return t+1}function ca(e,a){const t=sa(),s=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=na(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 ua(e){return ca(e,{weekStartsOn:1})}function ma(e){const a=na(e),t=a.getFullYear(),s=la(e,0);s.setFullYear(t+1,0,4),s.setHours(0,0,0,0);const r=ua(s),n=la(e,0);n.setFullYear(t,0,4),n.setHours(0,0,0,0);const o=ua(n);return a.getTime()>=r.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function pa(e){const a=na(e),t=+ua(a)-+function(e){const a=ma(e),t=la(e,0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),ua(t)}(a);return Math.round(t/ra)+1}function ha(e,a){const t=na(e),s=t.getFullYear(),r=sa(),n=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=la(e,0);o.setFullYear(s+1,0,n),o.setHours(0,0,0,0);const i=ca(o,a),l=la(e,0);l.setFullYear(s,0,n),l.setHours(0,0,0,0);const d=ca(l,a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function xa(e,a){const t=na(e),s=+ca(t,a)-+function(e,a){const t=sa(),s=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=ha(e,a),n=la(e,0);return n.setFullYear(r,0,s),n.setHours(0,0,0,0),ca(n,a)}(t,a);return Math.round(s/ra)+1}function fa(e,a){return(e<0?"-":"")+Math.abs(e).toString().padStart(a,"0")}const ga={y(e,a){const t=e.getFullYear(),s=t>0?t:1-t;return fa("yy"===a?s%100:s,a.length)},M(e,a){const t=e.getMonth();return"M"===a?String(t+1):fa(t+1,2)},d:(e,a)=>fa(e.getDate(),a.length),a(e,a){const t=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return"am"===t?"a.m.":"p.m."}},h:(e,a)=>fa(e.getHours()%12||12,a.length),H:(e,a)=>fa(e.getHours(),a.length),m:(e,a)=>fa(e.getMinutes(),a.length),s:(e,a)=>fa(e.getSeconds(),a.length),S(e,a){const t=a.length,s=e.getMilliseconds();return fa(Math.trunc(s*Math.pow(10,t-3)),a.length)}},va="midnight",ba="noon",ya="morning",ja="afternoon",wa="evening",Na="night",_a={G:function(e,a,t){const s=e.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(s,{width:"abbreviated"});case"GGGGG":return t.era(s,{width:"narrow"});default:return t.era(s,{width:"wide"})}},y:function(e,a,t){if("yo"===a){const a=e.getFullYear(),s=a>0?a:1-a;return t.ordinalNumber(s,{unit:"year"})}return ga.y(e,a)},Y:function(e,a,t,s){const r=ha(e,s),n=r>0?r:1-r;if("YY"===a){return fa(n%100,2)}return"Yo"===a?t.ordinalNumber(n,{unit:"year"}):fa(n,a.length)},R:function(e,a){return fa(ma(e),a.length)},u:function(e,a){return fa(e.getFullYear(),a.length)},Q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"Q":return String(s);case"QQ":return fa(s,2);case"Qo":return t.ordinalNumber(s,{unit:"quarter"});case"QQQ":return t.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(s,{width:"narrow",context:"formatting"});default:return t.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,a,t){const s=Math.ceil((e.getMonth()+1)/3);switch(a){case"q":return String(s);case"qq":return fa(s,2);case"qo":return t.ordinalNumber(s,{unit:"quarter"});case"qqq":return t.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(s,{width:"narrow",context:"standalone"});default:return t.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,a,t){const s=e.getMonth();switch(a){case"M":case"MM":return ga.M(e,a);case"Mo":return t.ordinalNumber(s+1,{unit:"month"});case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}},L:function(e,a,t){const s=e.getMonth();switch(a){case"L":return String(s+1);case"LL":return fa(s+1,2);case"Lo":return t.ordinalNumber(s+1,{unit:"month"});case"LLL":return t.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(s,{width:"narrow",context:"standalone"});default:return t.month(s,{width:"wide",context:"standalone"})}},w:function(e,a,t,s){const r=xa(e,s);return"wo"===a?t.ordinalNumber(r,{unit:"week"}):fa(r,a.length)},I:function(e,a,t){const s=pa(e);return"Io"===a?t.ordinalNumber(s,{unit:"week"}):fa(s,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getDate(),{unit:"date"}):ga.d(e,a)},D:function(e,a,t){const s=da(e);return"Do"===a?t.ordinalNumber(s,{unit:"dayOfYear"}):fa(s,a.length)},E:function(e,a,t){const s=e.getDay();switch(a){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},e:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"e":return String(n);case"ee":return fa(n,2);case"eo":return t.ordinalNumber(n,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(e,a,t,s){const r=e.getDay(),n=(r-s.weekStartsOn+8)%7||7;switch(a){case"c":return String(n);case"cc":return fa(n,a.length);case"co":return t.ordinalNumber(n,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(e,a,t){const s=e.getDay(),r=0===s?7:s;switch(a){case"i":return String(r);case"ii":return fa(r,a.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},a:function(e,a,t){const s=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(s,{width:"narrow",context:"formatting"});default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,a,t){const s=e.getHours();let r;switch(r=12===s?ba:0===s?va:s/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,a,t){const s=e.getHours();let r;switch(r=s>=17?wa:s>=12?ja:s>=4?ya:Na,a){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,a,t){if("ho"===a){let a=e.getHours()%12;return 0===a&&(a=12),t.ordinalNumber(a,{unit:"hour"})}return ga.h(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getHours(),{unit:"hour"}):ga.H(e,a)},K:function(e,a,t){const s=e.getHours()%12;return"Ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},k:function(e,a,t){let s=e.getHours();return 0===s&&(s=24),"ko"===a?t.ordinalNumber(s,{unit:"hour"}):fa(s,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):ga.m(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getSeconds(),{unit:"second"}):ga.s(e,a)},S:function(e,a){return ga.S(e,a)},X:function(e,a,t){const s=e.getTimezoneOffset();if(0===s)return"Z";switch(a){case"X":return ka(s);case"XXXX":case"XX":return Sa(s);default:return Sa(s,":")}},x:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"x":return ka(s);case"xxxx":case"xx":return Sa(s);default:return Sa(s,":")}},O:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},z:function(e,a,t){const s=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ca(s,":");default:return"GMT"+Sa(s,":")}},t:function(e,a,t){return fa(Math.trunc(e.getTime()/1e3),a.length)},T:function(e,a,t){return fa(e.getTime(),a.length)}};function Ca(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),n=s%60;return 0===n?t+String(r):t+String(r)+a+fa(n,2)}function ka(e,a){if(e%60==0){return(e>0?"-":"+")+fa(Math.abs(e)/60,2)}return Sa(e,a)}function Sa(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+fa(Math.trunc(s/60),2)+a+fa(s%60,2)}const Ta=(e,a)=>{switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},Pa=(e,a)=>{switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},Ea={p:Pa,P:(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return Ta(e,a);let n;switch(s){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Ta(s,a)).replace("{{time}}",Pa(r,a))}},Da=/^D+$/,Aa=/^Y+$/,Ia=["D","DD","YY","YYYY"];function Ma(e){if(!(a=e,a instanceof Date||"object"==typeof a&&"[object Date]"===Object.prototype.toString.call(a)||"number"==typeof e))return!1;var a;const t=na(e);return!isNaN(Number(t))}const Fa=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ra=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,La=/^'([^]*?)'?$/,za=/''/g,Ua=/[a-zA-Z]/;function Oa(e,a,t){const s=sa(),r=t?.locale??s.locale??aa,n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,i=na(e);if(!Ma(i))throw new RangeError("Invalid time value");let l=a.match(Ra).map(e=>{const a=e[0];if("p"===a||"P"===a){return(0,Ea[a])(e,r.formatLong)}return e}).join("").match(Fa).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const a=e[0];if("'"===a)return{isToken:!1,value:Va(e)};if(_a[a])return{isToken:!0,value:e};if(a.match(Ua))throw new RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");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;(!t?.useAdditionalWeekYearTokens&&function(e){return Aa.test(e)}(n)||!t?.useAdditionalDayOfYearTokens&&function(e){return Da.test(e)}(n))&&function(e,a,t){const s=function(e,a,t){const s="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${a}\`) for formatting ${s} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,a,t);if(Ia.includes(e))throw new RangeError(s)}(n,a,String(e));return(0,_a[n[0]])(i,n,r.localize,d)}).join("")}function Va(e){const a=e.match(La);return a?a[1].replace(za,"'"):e}function Ba(e,a,t){const s=i.getDefaultOptions(),r=function(e,a,t){return new Intl.DateTimeFormat(t?[t.code,"en-US"]:void 0,{timeZone:a,timeZoneName:e})}(e,t.timeZone,t.locale??s.locale);return"formatToParts"in r?function(e,a){const t=e.formatToParts(a);for(let s=t.length-1;s>=0;--s)if("timeZoneName"===t[s].type)return t[s].value;return}(r,a):function(e,a){const t=e.format(a).replace(/\u200E/g,""),s=/ [\w-+ ]+$/.exec(t);return s?s[0].substr(1):""}(r,a)}function qa(e,a){const t=function(e){Wa[e]||(Wa[e]=Ga?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 Wa[e]}(a);return"formatToParts"in t?function(e,a){try{const t=e.formatToParts(a),s=[];for(let e=0;e<t.length;e++){const a=$a[t[e].type];void 0!==a&&(s[a]=parseInt(t[e].value,10))}return s}catch(t){if(t instanceof RangeError)return[NaN];throw t}}(t,e):function(e,a){const t=e.format(a),s=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(t);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)]}(t,e)}const $a={year:0,month:1,day:2,hour:3,minute:4,second:5};const Wa={},Ha=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")),Ga="06/25/2014, 00:00:00"===Ha||"06/25/2014 00:00:00"===Ha;function Ka(e,a,t,s,r,n,o){const i=new Date(0);return i.setUTCFullYear(e,a,t),i.setUTCHours(s,r,n,o),i}const Ya=36e5,Qa={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function Xa(e,a,t){if(!e)return 0;let s,r,n=Qa.timezoneZ.exec(e);if(n)return 0;if(n=Qa.timezoneHH.exec(e),n)return s=parseInt(n[1],10),Za(s)?-s*Ya:NaN;if(n=Qa.timezoneHHMM.exec(e),n){s=parseInt(n[2],10);const e=parseInt(n[3],10);return Za(s,e)?(r=Math.abs(s)*Ya+6e4*e,"+"===n[1]?-r:r):NaN}if(function(e){if(et[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),et[e]=!0,!0}catch(a){return!1}}(e)){a=new Date(a||Date.now());const s=t?a:function(e){return Ka(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(a),r=Ja(s,e),n=t?r:function(e,a,t){const s=e.getTime();let r=s-a;const n=Ja(new Date(r),t);if(a===n)return a;r-=n-a;const o=Ja(new Date(r),t);if(n===o)return n;return Math.max(n,o)}(a,r,e);return-n}return NaN}function Ja(e,a){const t=qa(e,a),s=Ka(t[0],t[1]-1,t[2],t[3]%24,t[4],t[5],0).getTime();let r=e.getTime();const n=r%1e3;return r-=n>=0?n:1e3+n,s-r}function Za(e,a){return-23<=e&&e<=23&&(null==a||0<=a&&a<=59)}const et={};const at={X:function(e,a,t){const s=tt(t.timeZone,e);if(0===s)return"Z";switch(a){case"X":return nt(s);case"XXXX":case"XX":return rt(s);default:return rt(s,":")}},x:function(e,a,t){const s=tt(t.timeZone,e);switch(a){case"x":return nt(s);case"xxxx":case"xx":return rt(s);default:return rt(s,":")}},O:function(e,a,t){const s=tt(t.timeZone,e);switch(a){case"O":case"OO":case"OOO":return"GMT"+function(e,a=""){const t=e>0?"-":"+",s=Math.abs(e),r=Math.floor(s/60),n=s%60;if(0===n)return t+String(r);return t+String(r)+a+st(n,2)}(s,":");default:return"GMT"+rt(s,":")}},z:function(e,a,t){switch(a){case"z":case"zz":case"zzz":return Ba("short",e,t);default:return Ba("long",e,t)}}};function tt(e,a){const t=e?Xa(e,a,!0)/6e4:a?.getTimezoneOffset()??0;if(Number.isNaN(t))throw new RangeError("Invalid time zone specified: "+e);return t}function st(e,a){const t=e<0?"-":"";let s=Math.abs(e).toString();for(;s.length<a;)s="0"+s;return t+s}function rt(e,a=""){const t=e>0?"-":"+",s=Math.abs(e);return t+st(Math.floor(s/60),2)+a+st(Math.floor(s%60),2)}function nt(e,a){if(e%60==0){return(e>0?"-":"+")+st(Math.abs(e)/60,2)}return rt(e,a)}function ot(e){const a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),+e-+a}const it=36e5,lt=6e4,dt={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 ct(e,a={}){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);const t=null==a.additionalDigits?2:Number(a.additionalDigits);if(2!==t&&1!==t&&0!==t)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 a={};let t,s=dt.dateTimePattern.exec(e);s?(a.date=s[1],t=s[3]):(s=dt.datePattern.exec(e),s?(a.date=s[1],t=s[2]):(a.date=null,t=e));if(t){const e=dt.timeZone.exec(t);e?(a.time=t.replace(e[1],""),a.timeZone=e[1].trim()):a.time=t}return a}(e),{year:r,restDateString:n}=function(e,a){if(e){const t=dt.YYY[a],s=dt.YYYYY[a];let r=dt.YYYY.exec(e)||s.exec(e);if(r){const a=r[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(r=dt.YY.exec(e)||t.exec(e),r){const a=r[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}}return{year:null}}(s.date,t),o=function(e,a){if(null===a)return null;let t,s,r;if(!e||!e.length)return t=new Date(0),t.setUTCFullYear(a),t;let n=dt.MM.exec(e);if(n)return t=new Date(0),s=parseInt(n[1],10)-1,xt(a,s)?(t.setUTCFullYear(a,s),t):new Date(NaN);if(n=dt.DDD.exec(e),n){t=new Date(0);const e=parseInt(n[1],10);return function(e,a){if(a<1)return!1;const t=ht(e);if(t&&a>366)return!1;if(!t&&a>365)return!1;return!0}(a,e)?(t.setUTCFullYear(a,0,e),t):new Date(NaN)}if(n=dt.MMDD.exec(e),n){t=new Date(0),s=parseInt(n[1],10)-1;const e=parseInt(n[2],10);return xt(a,s,e)?(t.setUTCFullYear(a,s,e),t):new Date(NaN)}if(n=dt.Www.exec(e),n)return r=parseInt(n[1],10)-1,ft(r)?ut(a,r):new Date(NaN);if(n=dt.WwwD.exec(e),n){r=parseInt(n[1],10)-1;const e=parseInt(n[2],10)-1;return ft(r,e)?ut(a,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 t,r=0;if(s.time&&(r=function(e){let a,t,s=dt.HH.exec(e);if(s)return a=parseFloat(s[1].replace(",",".")),gt(a)?a%24*it:NaN;if(s=dt.HHMM.exec(e),s)return a=parseInt(s[1],10),t=parseFloat(s[2].replace(",",".")),gt(a,t)?a%24*it+t*lt:NaN;if(s=dt.HHMMSS.exec(e),s){a=parseInt(s[1],10),t=parseInt(s[2],10);const e=parseFloat(s[3].replace(",","."));return gt(a,t,e)?a%24*it+t*lt+1e3*e:NaN}return null}(s.time),null===r||isNaN(r)))return new Date(NaN);if(s.timeZone||a.timeZone){if(t=Xa(s.timeZone||a.timeZone,new Date(e+r)),isNaN(t))return new Date(NaN)}else t=ot(new Date(e+r)),t=ot(new Date(e+r+t));return new Date(e+r+t)}return new Date(NaN)}function ut(e,a,t){a=a||0,t=t||0;const s=new Date(0);s.setUTCFullYear(e,0,4);const r=7*a+t+1-(s.getUTCDay()||7);return s.setUTCDate(s.getUTCDate()+r),s}const mt=[31,28,31,30,31,30,31,31,30,31,30,31],pt=[31,29,31,30,31,30,31,31,30,31,30,31];function ht(e){return e%400==0||e%4==0&&e%100!=0}function xt(e,a,t){if(a<0||a>11)return!1;if(null!=t){if(t<1)return!1;const s=ht(e);if(s&&t>pt[a])return!1;if(!s&&t>mt[a])return!1}return!0}function ft(e,a){return!(e<0||e>52)&&(null==a||!(a<0||a>6))}function gt(e,a,t){return!(e<0||e>=25)&&((null==a||!(a<0||a>=60))&&(null==t||!(t<0||t>=60)))}const vt=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function bt(e,a,t,s){return function(e,a,t={}){const s=(a=String(a)).match(vt);if(s){const r=ct(t.originalDate||e,t);a=s.reduce(function(e,a){if("'"===a[0])return e;const s=e.indexOf(a),n="'"===e[s-1],o=e.replace(a,"'"+at[a[0]](r,a,t)+"'");return n?o.substring(0,s-1)+o.substring(s+1):o},a)}return Oa(e,a,t)}(function(e,a,t){const s=Xa(a,e=ct(e,t),!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,a,{timeZone:(s={...s,timeZone:a,originalDate:e}).timeZone}),t,s)}const yt={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"}},jt={date:Ye({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:Ye({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ye({formats:{full:"{{date}} 'a las' {{time}}",long:"{{date}} 'a las' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},wt={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"},Nt={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"},_t={code:"es",formatDistance:(e,a,t)=>{let s;const r=yt[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",a.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"en "+s:"hace "+s:s},formatLong:jt,formatRelative:(e,a,t,s)=>1!==a.getHours()?Nt[e]:wt[e],localize:{ordinalNumber:(e,a)=>Number(e)+"º",era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","después de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)(º)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:1,firstWeekContainsDate:1}},Ct={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"}},kt={date:Ye({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:Ye({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Ye({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},St={lastWeek:e=>{const a=e.getDay();return"'"+(0===a||6===a?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},Tt={code:"pt-BR",formatDistance:(e,a,t)=>{let s;const r=Ct[e];return s="string"==typeof r?r:1===a?r.one:r.other.replace("{{count}}",String(a)),t?.addSuffix?t.comparison&&t.comparison>0?"em "+s:"há "+s:s},formatLong:kt,formatRelative:(e,a,t,s)=>{const r=St[e];return"function"==typeof r?r(a):r},localize:{ordinalNumber:(e,a)=>{const t=Number(e);return"week"===a?.unit?t+"ª":t+"º"},era:Je({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Je({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:Je({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:Je({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:Je({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"})},match:{ordinalNumber:ea({matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:Ze({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:Ze({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:Ze({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:Ze({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:Ze({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"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Pt=[{value:"pt-BR",label:"Português (BR)",flag:"🇧🇷"},{value:"en-US",label:"English (US)",flag:"🇺🇸"},{value:"es-ES",label:"Español",flag:"🇪🇸"}],Et=[{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"}],Dt=[{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"}],At="pt-BR",It="dd/MM/yyyy HH:mm",Mt="America/Sao_Paulo",Ft=e=>Pt.some(a=>a.value===e),Rt=e=>Dt.some(a=>a.value===e),Lt=()=>{if("undefined"==typeof navigator)return At;const e=navigator.language;if(Ft(e))return e;const a=e.split("-")[0],t=Pt.find(e=>e.value.startsWith(a));return t?.value||At},zt=()=>{if("undefined"==typeof Intl)return Mt;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Rt(e)?e:Mt}catch{return Mt}},Ut=e=>({"pt-BR":"dd/MM/yyyy HH:mm","en-US":"MM/dd/yyyy hh:mm a","es-ES":"dd/MM/yyyy HH:mm"}[e]||It),Ot={"pt-BR":Tt,"en-US":aa,"es-ES":_t},Vt=(e,a=It,t=Mt,s=At)=>{if(!e)return"";const r=i.parseISO(e);if(!i.isValid(r))return"Data inválida";const n=Ot[s]||Tt;try{return bt(r,t,a,{locale:n})}catch(o){return bt(r,Mt,a,{locale:n})}},Bt=(e,a=At,t=Mt)=>{if(!e)return"";const s=i.parseISO(e);if(!i.isValid(s))return"Data inválida";const r=Ot[a]||Tt;try{return bt(s,t,"PP",{locale:r})}catch(n){return bt(s,Mt,"PP",{locale:r})}};function qt(e){const a=e.replace("#",""),t=3===a.length?a.split("").map(e=>e+e).join(""):a;return{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16)}}function $t(e,a=.1){const{r:t,g:s,b:r}=qt(e);return`rgba(${t}, ${s}, ${r}, ${a})`}function Wt(e){const{r:a,g:t,b:s}=qt(e),[r,n,o]=[a,t,s].map(e=>{const a=e/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return.2126*r+.7152*n+.0722*o}function Ht(e,a){a?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{l.toast.info("Link copiado para a área de transferência")})}function Gt(e,a){return a?e.replace(/\{alias\}/g,a):e}function Kt(...e){return o.twMerge(n.clsx(e))}const Yt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Yt);if("object"==typeof e&&e.constructor===Object){const a={};for(const[t,s]of Object.entries(e))a[t]=Yt(s);return a}return e},Qt=r.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-lg",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"}}),Xt=ae.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},i)=>{const l=n?s.Slot:"button";return a.jsx(l,{className:Kt(Qt({variant:t,size:r,className:e})),ref:i,...o})});Xt.displayName="Button";const Jt=t.forwardRef(({className:e,children:t,variant:s="action",...r},n)=>a.jsx(Xt,{ref:n,variant:s,size:"icon",className:Kt("h-8 w-8",e),...r,children:t||a.jsx(d.EllipsisVertical,{size:16})}));Jt.displayName="ActionButton";const Zt=ae.forwardRef(({className:e,type:t,showCharCount:s,maxLength:r,onChange:n,...o},i)=>{const[l,d]=ae.useState(0);ae.useEffect(()=>{"string"==typeof o.value?d(o.value.length):"string"==typeof o.defaultValue&&d(o.defaultValue.length)},[o.value,o.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("input",{type:t,className:Kt("flex h-10 w-full rounded-lg 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 hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors md:text-sm",e),ref:i,maxLength:r,onChange:e=>{d(e.target.value.length),n?.(e)},...o}),s&&r&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[l," / ",r]})]})});Zt.displayName="Input";const es=r.cva("text-xs font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),as=ae.forwardRef(({className:e,...t},s)=>a.jsx(se.Root,{ref:s,className:Kt(es(),e),...t}));as.displayName=se.Root.displayName;const ts=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ts.displayName="Card";const ss=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("flex flex-col space-y-1.5 p-6",e),...t}));ss.displayName="CardHeader";const rs=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Kt("text-2xl font-semibold leading-none tracking-tight",e),...t}));rs.displayName="CardTitle";const ns=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));ns.displayName="CardDescription";const os=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("p-6 pt-0",e),...t}));os.displayName="CardContent";const is=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("flex items-center p-6 pt-0",e),...t}));is.displayName="CardFooter";const ls=ae.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...r},n)=>a.jsx(ne.Root,{ref:n,decorative:s,orientation:t,className:Kt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ls.displayName=ne.Root.displayName;const ds=oe.Root,cs=oe.Trigger,us=oe.Portal,ms=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Overlay,{className:Kt("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",e),...t,ref:s}));ms.displayName=oe.Overlay.displayName;const ps=ae.forwardRef(({className:e,...t},s)=>a.jsxs(us,{children:[a.jsx(ms,{}),a.jsx(oe.Content,{ref:s,className:Kt("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",e),...t})]}));ps.displayName=oe.Content.displayName;const hs=({className:e,...t})=>a.jsx("div",{className:Kt("flex flex-col space-y-2 text-center sm:text-left",e),...t});hs.displayName="AlertDialogHeader";const xs=({className:e,...t})=>a.jsx("div",{className:Kt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xs.displayName="AlertDialogFooter";const fs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Title,{ref:s,className:Kt("text-lg font-semibold",e),...t}));fs.displayName=oe.Title.displayName;const gs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Description,{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));gs.displayName=oe.Description.displayName;const vs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Action,{ref:s,className:Kt(Qt(),e),...t}));vs.displayName=oe.Action.displayName;const bs=ae.forwardRef(({className:e,...t},s)=>a.jsx(oe.Cancel,{ref:s,className:Kt(Qt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));bs.displayName=oe.Cancel.displayName;const ys=re.Root,js=re.Trigger,ws=re.Portal,Ns=re.Close,_s=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{ref:s,className:Kt("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",e),...t}));_s.displayName=re.Overlay.displayName;const Cs={sm:{width:"30vw",minWidth:"320px",maxWidth:"480px",maxHeight:"320px"},md:{width:"50vw",minWidth:"480px",maxWidth:"720px",maxHeight:"70vh"},lg:{width:"85vw",height:"85vh",maxWidth:"1440px",minHeight:"480px",maxHeight:"900px"}},ks=ae.forwardRef(({className:t,children:s,size:r,variant:n="informative",isDirty:o,customWidth:i,customMinWidth:l,customMaxWidth:c,customHeight:u,customMinHeight:m,customMaxHeight:p,unsavedChangesTitle:h=e.t("unsaved_changes"),unsavedChangesDescription:x=e.t("unsaved_changes_description"),cancelText:f=e.t("cancel"),leaveWithoutSavingText:g=e.t("leave_without_saving"),style:v,onInteractOutside:b,onEscapeKeyDown:y,...j},w)=>{const[N,_]=ae.useState(!1),C=ae.useRef(null),k=ae.useRef(!1),S=r??(i||l||c||u||m||p?void 0:"md"),T=S?Cs[S]:{},P={...i??T.width?{width:i??T.width}:{},...l??T.minWidth?{minWidth:l??T.minWidth}:{},...c??T.maxWidth?{maxWidth:c??T.maxWidth}:{},...u??T.height?{height:u??T.height}:{},...m??T.minHeight?{minHeight:m??T.minHeight}:{},...p??T.maxHeight?{maxHeight:p??T.maxHeight}:{},...v},E=ae.useCallback(e=>{"form"===n&&o?(C.current=e,_(!0)):e()},[n,o]),D=ae.useRef(null),A="destructive"!==n;if("development"===process.env.NODE_ENV&&s){const e=ae.Children.toArray(s);e.some(e=>ae.isValidElement(e)&&"DialogFooter"===e.type?.displayName),e.some(e=>ae.isValidElement(e)&&"DialogBody"===e.type?.displayName)}return a.jsxs(ws,{children:[a.jsx(_s,{}),a.jsxs(re.Content,{ref:w,className:Kt("fixed left-[50%] top-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] border-0 border-l-[10px] border-l-primary 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 max-sm:!w-[calc(100vw-2rem)] max-sm:!h-[calc(100dvh-2rem)] max-sm:!min-w-0 max-sm:!min-h-0 max-sm:!max-w-none max-sm:!max-h-none max-sm:p-4",t),style:P,onInteractOutside:e=>{"form"!==n&&"destructive"!==n?b?.(e):e.preventDefault()},onEscapeKeyDown:e=>{if("destructive"!==n)return"form"===n&&o?(e.preventDefault(),void E(()=>{k.current=!0,D.current?.click()})):void y?.(e);e.preventDefault()},...j,children:[s,A&&a.jsxs(re.Close,{ref:D,onClick:e=>{k.current?k.current=!1:"form"===n&&o&&(e.preventDefault(),E(()=>{k.current=!0,D.current?.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]}),a.jsx(ds,{open:N,onOpenChange:_,children:a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:h}),a.jsx(gs,{children:x})]}),a.jsxs(xs,{children:[a.jsx(bs,{onClick:()=>{_(!1),C.current=null},children:f}),a.jsx(vs,{onClick:()=>{_(!1),C.current?.(),C.current=null},children:g})]})]})})]})});ks.displayName=re.Content.displayName;const Ss=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Kt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Ss.displayName="DialogHeader";const Ts=({className:e,...t})=>a.jsx("div",{className:Kt("flex-1 min-h-0 overflow-auto py-4 px-2 -mx-2",e),...t});Ts.displayName="DialogBody";const Ps=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Kt("flex flex-row justify-end gap-2",e),...s,children:t})]});Ps.displayName="DialogFooter";const Es=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Kt("text-xl font-semibold leading-none tracking-tight",e),...t}));Es.displayName=re.Title.displayName;const Ds=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));Ds.displayName=re.Description.displayName;const As=h.FormProvider,Is=ae.createContext({}),Ms=()=>{const e=ae.useContext(Is),a=ae.useContext(Fs),{getFieldState:t,formState:s}=h.useFormContext(),r=t(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=a;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...r}},Fs=ae.createContext({}),Rs=ae.forwardRef(({className:e,...t},s)=>{const r=ae.useId();return a.jsx(Fs.Provider,{value:{id:r},children:a.jsx("div",{ref:s,className:Kt("space-y-1.5",e),...t})})});Rs.displayName="FormItem";const Ls=ae.forwardRef(({className:e,...t},s)=>{const{error:r,formItemId:n}=Ms();return a.jsx(as,{ref:s,className:Kt(r&&"text-destructive",e),htmlFor:n,...t})});Ls.displayName="FormLabel";const zs=ae.forwardRef(({...e},t)=>{const{error:r,formItemId:n,formDescriptionId:o,formMessageId:i}=Ms();return a.jsx(s.Slot,{ref:t,id:n,"aria-describedby":r?`${o} ${i}`:`${o}`,"aria-invalid":!!r,...e})});zs.displayName="FormControl";const Us=ae.forwardRef(({className:e,...t},s)=>{const{formDescriptionId:r}=Ms();return a.jsx("p",{ref:s,id:r,className:Kt("text-sm text-muted-foreground",e),...t})});Us.displayName="FormDescription";const Os=ae.forwardRef(({className:e,children:t,...s},r)=>{const{error:n,formMessageId:o}=Ms(),i=n?String(n?.message):t;return i?a.jsx("p",{ref:r,id:o,className:Kt("text-sm font-medium text-destructive",e),...s,children:i}):null});Os.displayName="FormMessage";const Vs=ie.Root,Bs=ie.Group,qs=ie.Value,$s=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Trigger,{ref:r,className:Kt("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors [&>span]:line-clamp-1",e),...s,children:[t,a.jsx(ie.Icon,{asChild:!0,children:a.jsx(d.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));$s.displayName=ie.Trigger.displayName;const Ws=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollUpButton,{ref:s,className:Kt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronUp,{className:"h-4 w-4"})}));Ws.displayName=ie.ScrollUpButton.displayName;const Hs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.ScrollDownButton,{ref:s,className:Kt("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(d.ChevronDown,{className:"h-4 w-4"})}));Hs.displayName=ie.ScrollDownButton.displayName;const Gs=ae.forwardRef(({className:e,children:t,position:s="popper",container:r,collisionBoundary:n,...o},i)=>a.jsx(ie.Portal,{container:r,children:a.jsxs(ie.Content,{ref:i,className:Kt("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",e),position:s,collisionBoundary:n,...o,children:[a.jsx(Ws,{}),a.jsx(ie.Viewport,{className:Kt("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(Hs,{})]})}));Gs.displayName=ie.Content.displayName;const Ks=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.Label,{ref:s,className:Kt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ks.displayName=ie.Label.displayName;const Ys=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(ie.Item,{ref:r,className:Kt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(ie.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),a.jsx(ie.ItemText,{children:t})]}));Ys.displayName=ie.Item.displayName;const Qs=ae.forwardRef(({className:e,...t},s)=>a.jsx(ie.Separator,{ref:s,className:Kt("-mx-1 my-1 h-px bg-muted",e),...t}));Qs.displayName=ie.Separator.displayName;const Xs=ae.forwardRef(({className:e,...t},s)=>a.jsx(le.Root,{ref:s,className:Kt("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",e),...t,children:a.jsx(le.Indicator,{className:Kt("flex items-center justify-center text-current"),children:a.jsx(d.Check,{className:"h-4 w-4"})})}));Xs.displayName=le.Root.displayName;const Js=ae.forwardRef(({className:e,showCharCount:t,maxLength:s,onChange:r,...n},o)=>{const[i,l]=ae.useState(0);ae.useEffect(()=>{"string"==typeof n.value?l(n.value.length):"string"==typeof n.defaultValue&&l(n.defaultValue.length)},[n.value,n.defaultValue]);return a.jsxs("div",{className:"w-full",children:[a.jsx("textarea",{className:Kt("flex min-h-[80px] w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",e),ref:o,maxLength:s,onChange:e=>{l(e.target.value.length),r?.(e)},...n}),t&&s&&a.jsxs("div",{className:"text-right text-xs text-muted-foreground mt-1",children:[i," / ",s]})]})});Js.displayName="Textarea";const Zs=r.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"}}),er=ae.forwardRef(({className:e,variant:t,...s},r)=>a.jsx("div",{ref:r,className:Kt(Zs({variant:t}),e),...s}));er.displayName="Badge";const ar={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function tr({size:e="md",className:t}){return a.jsx(d.Loader2,{className:Kt("animate-spin text-muted-foreground",ar[e],t)})}function sr({isLoading:e,children:t,className:s,type:r="spinner",size:n="md"}){return e?"overlay"===r?a.jsxs("div",{className:Kt("relative",s),children:[t,a.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:a.jsx(tr,{size:n})})]}):"skeleton"===r?a.jsx("div",{className:Kt("animate-pulse",s),children:a.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):a.jsx("div",{className:Kt("flex items-center justify-center py-8",s),children:a.jsx(tr,{size:n})}):a.jsx(a.Fragment,{children:t})}const rr=({...e})=>a.jsx(l.Toaster,{className:"group",position:"top-right",expand:!0,visibleToasts:5,closeButton:!0,icons:{success:a.jsx(d.CircleCheckIcon,{className:"h-4 w-4"}),info:a.jsx(d.InfoIcon,{className:"h-4 w-4"}),warning:a.jsx(d.TriangleAlertIcon,{className:"h-4 w-4"}),error:a.jsx(d.OctagonXIcon,{className:"h-4 w-4"}),loading:a.jsx(d.Loader2Icon,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:relative",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:absolute group-[.toast]:right-2 group-[.toast]:top-2 group-[.toast]:left-auto group-[.toast]:transform-none group-[.toast]:border-0 group-[.toast]:bg-transparent group-[.toast]:opacity-70 group-[.toast]:hover:opacity-100 group-[.toast]:hover:bg-transparent group-[.toast]:transition-opacity",success:"!bg-success-light !border-success-light",error:"!bg-destructive-light !border-destructive-light",warning:"!bg-warning-light !border-warning-light",info:"!bg-info-light !border-info-light"}},...e}),nr=de.Root,or=de.Trigger,ir=de.Group,lr=de.Portal,dr=de.Sub,cr=de.RadioGroup,ur=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(de.SubTrigger,{ref:n,className:Kt("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ur.displayName=de.SubTrigger.displayName;const mr=ae.forwardRef(({className:e,...t},s)=>a.jsx(de.SubContent,{ref:s,className:Kt("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",e),...t}));mr.displayName=de.SubContent.displayName;const pr=ae.forwardRef(({className:e,sideOffset:t=4,...s},r)=>a.jsx(de.Portal,{children:a.jsx(de.Content,{ref:r,sideOffset:t,className:Kt("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",e),...s})}));pr.displayName=de.Content.displayName;const hr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Item,{ref:r,className:Kt("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));hr.displayName=de.Item.displayName;const xr=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(de.CheckboxItem,{ref:n,className:Kt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));xr.displayName=de.CheckboxItem.displayName;const fr=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(de.RadioItem,{ref:r,className:Kt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(de.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fr.displayName=de.RadioItem.displayName;const gr=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(de.Label,{ref:r,className:Kt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));gr.displayName=de.Label.displayName;const vr=ae.forwardRef(({className:e,...t},s)=>a.jsx(de.Separator,{ref:s,className:Kt("-mx-1 my-1 h-px bg-muted",e),...t}));vr.displayName=de.Separator.displayName;const br=({className:e,...t})=>a.jsx("span",{className:Kt("ml-auto text-xs tracking-widest opacity-60",e),...t});br.displayName="DropdownMenuShortcut";const yr=({delayDuration:e=300,...t})=>a.jsx(ce.Provider,{delayDuration:e,...t}),jr=ce.Root,wr=ce.Trigger,Nr=ae.forwardRef(({className:e,sideOffset:t=4,container:s,...r},n)=>a.jsx(ce.Portal,{container:s,children:a.jsx(ce.Content,{ref:n,sideOffset:t,className:Kt("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",e),...r})}));Nr.displayName=ce.Content.displayName;const _r=ae.forwardRef(({children:e,disabledReason:t,className:s},r)=>{const n=a.jsx(hr,{ref:r,className:Kt("opacity-50 cursor-not-allowed pointer-events-auto",s),onSelect:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:e});return t?a.jsx(yr,{delayDuration:100,children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:"w-full",children:n})}),a.jsx(Nr,{side:"right",sideOffset:8,className:"max-w-[200px] z-[100]",children:t})]})}):n});_r.displayName="DisabledMenuItem";const Cr=ue.Root,kr=ue.Trigger,Sr=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,container:r,...n},o)=>a.jsx(ue.Portal,{container:r,children:a.jsx(ue.Content,{ref:o,align:t,sideOffset:s,className:Kt("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",e),...n})}));Sr.displayName=ue.Content.displayName;const Tr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Tr.displayName="Command";const Pr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:a.jsx("input",{ref:s,className:Kt("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",e),...t})}));Pr.displayName="CommandInput";const Er=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Er.displayName="CommandList";const Dr=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("py-6 text-center text-sm text-muted-foreground",e),...t}));Dr.displayName="CommandEmpty";const Ar=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("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",e),...t}));Ar.displayName="CommandGroup";const Ir=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("-mx-1 h-px bg-border",e),...t}));Ir.displayName="CommandSeparator";const Mr=ae.forwardRef(({className:e,disabled:t,onSelect:s,value:r,...n},o)=>a.jsx("div",{ref:o,className:Kt("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",e),"data-disabled":t,onClick:()=>!t&&s?.(r||""),...n}));Mr.displayName="CommandItem";const Fr=({className:e,...t})=>a.jsx("span",{className:Kt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function Rr({className:e,...t}){return a.jsx("div",{className:Kt("animate-pulse rounded-md bg-muted",e),...t})}Fr.displayName="CommandShortcut";const Lr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function zr({multiple:s,options:r,value:n,onChange:o,getOptionValue:i,getOptionLabel:l,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x,required:f,className:g,sortOptions:v,maxDisplayedBadges:b,popoverContainer:y,onOpen:j,onClose:w,clearable:N}){const[_,C]=t.useState(!1),[k,S]=t.useState(""),T=t.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),P=t.useMemo(()=>{if(!y)return;let e=y,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[y]),E=t.useMemo(()=>{const e=r.map(e=>({original:e,value:i(e),label:l(e)}));return v?e.sort((e,a)=>e.label.localeCompare(a.label,"pt-BR",{sensitivity:"base"})):e},[r,i,l,v]),D=t.useMemo(()=>{if(!k)return E;const e=Lr(k);return E.filter(a=>Lr(a.label).includes(e))},[E,k]),A=t.useMemo(()=>E.filter(e=>T.includes(e.value)),[E,T]),I=e=>{C(e),e?j?.():(S(""),w?.())},M=(e,a)=>{a.preventDefault(),a.stopPropagation(),o&&o(s?T.filter(a=>a!==e):"")},F=b?A.slice(0,b):A,R=b&&A.length>b?A.length-b:0;return a.jsxs("div",{className:Kt("space-y-2",g),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:_,onOpenChange:I,modal:!1,children:[s?a.jsx(kr,{asChild:!0,children:a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":x,tabIndex:x?-1:0,onKeyDown:e=>{x||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),I(!_))},className:Kt("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",x&&"pointer-events-none opacity-50 cursor-not-allowed",0===A.length&&"text-muted-foreground"),children:[0===A.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[F.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&M(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>M(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),R>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",R]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:x,className:Kt("flex-1 justify-between min-h-10 h-auto",0===A.length&&"text-muted-foreground"),children:[0===A.length?a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),c]}):a.jsxs("span",{className:"flex items-center gap-2",children:[m&&a.jsx(m,{className:"h-4 w-4"}),A[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),N&&A.length>0&&a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",disabled:x,className:"h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground",onClick:e=>M("",e),title:"Limpar seleção",children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:P,collisionBoundary:P,children:a.jsxs(Tr,{children:[a.jsxs("div",{className:"relative",children:[a.jsx(Pr,{placeholder:h,value:k,onChange:e=>S(e.target.value)}),k&&a.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:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx(Er,{children:0===r.length?a.jsx(Dr,{children:p}):0===D.length?a.jsx(Dr,{children:e.t("no_results")}):a.jsx(Ar,{children:D.map(e=>a.jsxs(Mr,{value:e.value,onSelect:()=>(e=>{if(o)if(s){const a=T.includes(e)?T.filter(a=>a!==e):[...T,e];o(a)}else o(e),C(!1)})(e.value),className:"cursor-pointer",children:[a.jsx(d.Check,{className:Kt("mr-2 h-4 w-4",T.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})]})]})}function Ur({multiple:e=!1,options:t,items:s,value:r,onChange:n,onValueChange:o,getOptionValue:i=e=>e.value,getOptionLabel:l=e=>e.label,placeholder:c,label:u,icon:m,emptyMessage:p,searchPlaceholder:h,disabled:x=!1,required:f=!1,isLoading:g=!1,error:v,className:b,sortOptions:j=!0,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C,clearable:k=!0}){const{t:S}=y.useTranslation(),T=t||s||[],P=o||n,E=c||S("select_placeholder","Selecione..."),D=p||S("no_results",S("no_results")),A=h||S("search_placeholder","Pesquisar...");if(g)return a.jsxs("div",{className:Kt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const I="string"==typeof v?v:v instanceof Error?v.message:v?S("error_loading",S("error_loading")):void 0;return I?a.jsxs("div",{className:Kt("space-y-2",b),children:[u&&a.jsxs(as,{children:[u,f&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:I})]})]}):a.jsx(zr,{multiple:e,options:T,value:r||(e?[]:""),onChange:P,getOptionValue:i,getOptionLabel:l,placeholder:E,label:u,icon:m,emptyMessage:D,searchPlaceholder:A,disabled:x,required:f,className:b,sortOptions:j,maxDisplayedBadges:w,popoverContainer:N,onOpen:_,onClose:C,clearable:k})}const Or=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function Vr(e,a){if(!a)return null;const t=Or(a),s=[];for(const r of e){const e=Or(r.label).includes(t),n=r.children?Vr(r.children,a):null,o=n&&n.length>0;(e||o)&&s.push({...r,children:e?r.children:o?n:r.children})}return s}function Br(e,a){for(const t of e){if(t.value===a)return t.label;if(t.children){const e=Br(t.children,a);if(e)return e}}}function qr({node:e,level:t,expanded:s,onToggleExpand:r,selectedValues:n,onSelect:o}){const i=e.children&&e.children.length>0,l=n.includes(e.value);return a.jsxs("div",{role:"treeitem","aria-expanded":i?s:void 0,"aria-selected":l,className:Kt("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*t+"px"},children:[a.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate",onClick:a=>{a.stopPropagation(),o(e.value)},children:[a.jsx(d.Check,{className:Kt("h-4 w-4 shrink-0",l?"opacity-100":"opacity-0")}),(()=>{const t=l?e.iconSelected??(s?e.iconOpen:null)??e.icon:s?e.iconOpen??e.icon:e.icon;return t?a.jsx(t,{className:Kt("h-4 w-4 shrink-0",e.iconClassName||"text-muted-foreground")}):null})(),a.jsx("span",{className:"truncate",children:e.label})]}),i&&a.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm hover:bg-muted ml-auto",onClick:a=>{a.stopPropagation(),r(e.value)},tabIndex:-1,"aria-label":s?"Recolher":"Expandir",children:s?a.jsx(d.ChevronDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})}function $r({nodes:e,level:s,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i}){return a.jsx(a.Fragment,{children:e.map(e=>{const l=r.has(e.value);return a.jsxs(t.Fragment,{children:[a.jsx(qr,{node:e,level:s,expanded:l,onToggleExpand:n,selectedValues:o,onSelect:i}),l&&e.children&&e.children.length>0&&a.jsx($r,{nodes:e.children,level:s+1,expandedIds:r,onToggleExpand:n,selectedValues:o,onSelect:i})]},e.value)})})}function Wr({multiple:e=!1,options:s,value:r,onChange:n,placeholder:o,label:i,icon:l,emptyMessage:c,searchPlaceholder:u,disabled:m=!1,required:p=!1,isLoading:h=!1,error:x,className:f,maxDisplayedBadges:g,popoverContainer:v,onOpen:b,onClose:j,defaultExpanded:w=!0}){const{t:N}=y.useTranslation(),[_,C]=t.useState(!1),[k,S]=t.useState(""),[T,P]=t.useState(()=>w?function(e){const a=new Set;return function e(t){for(const s of t)s.children&&s.children.length>0&&(a.add(s.value),e(s.children))}(e),a}(s):new Set),E=o||N("select_placeholder","Selecione..."),D=c||N("no_results",N("no_results")),A=u||N("search_placeholder","Pesquisar..."),I=t.useMemo(()=>r?Array.isArray(r)?r:[r]:[],[r]),M=t.useMemo(()=>{if(!v)return;let e=v,a=0;try{for(;e&&a<3;){const t=window.getComputedStyle(e),s=t.overflowY||t.overflow;if(!s||"visible"===s||"unset"===s)break;e=e.parentElement,a++}}catch{}return e??void 0},[v]),F=t.useMemo(()=>Vr(s,k),[s,k])??s,R=t.useMemo(()=>k?function(e,a){const t=new Set,s=Or(a);function r(e){if(!e.children||0===e.children.length)return Or(e.label).includes(s);let a=!1;for(const t of e.children)r(t)&&(a=!0);return a&&t.add(e.value),a||Or(e.label).includes(s)}for(const n of e)r(n);return t}(s,k):new Set,[s,k]),L=k?R:T,z=t.useCallback(e=>{k||P(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[k]),U=t.useMemo(()=>I.map(e=>({value:e,label:Br(s,e)||e})),[I,s]),O=e=>{C(e),e?b?.():(S(""),j?.())},V=t.useCallback(a=>{if(n)if(e){const e=I.includes(a)?I.filter(e=>e!==a):[...I,a];n(e)}else n(a),C(!1)},[n,e,I]),B=(a,t)=>{t.preventDefault(),t.stopPropagation(),n&&n(e?I.filter(e=>e!==a):"")},q=g?U.slice(0,g):U,$=g&&U.length>g?U.length-g:0;if(h)return a.jsxs("div",{className:Kt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Rr,{className:"h-10 w-full"})]});const W="string"==typeof x?x:x instanceof Error?x.message:x?N("error_loading",N("error_loading")):void 0;return W?a.jsxs("div",{className:Kt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:W})]})]}):a.jsxs("div",{className:Kt("space-y-2",f),children:[i&&a.jsxs(as,{children:[i,p&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Cr,{open:_,onOpenChange:O,modal:!1,children:[a.jsx(kr,{asChild:!0,children:e?a.jsxs("div",{role:"combobox","aria-expanded":_,"aria-disabled":m,tabIndex:m?-1:0,onKeyDown:e=>{m||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),O(!_))},className:Kt("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===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),E]}):a.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[q.map(e=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,a.jsx("button",{type:"button",className:"rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",onKeyDown:a=>{"Enter"===a.key&&B(e.value,a)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a=>B(e.value,a),children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),$>0&&a.jsxs(er,{variant:"outline",className:"gap-1",children:["+",$]})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]}):a.jsxs(Xt,{variant:"outline",role:"combobox","aria-expanded":_,disabled:m,className:Kt("w-full justify-between min-h-10 h-auto font-normal",0===U.length&&"text-muted-foreground"),children:[0===U.length?a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),E]}):a.jsxs("span",{className:"flex items-center gap-2",children:[l&&a.jsx(l,{className:"h-4 w-4"}),U[0]?.label]}),a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:M,collisionBoundary:M,children:[a.jsxs("div",{className:"flex items-center border-b px-3",children:[a.jsx(d.Search,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.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:A,value:k,onChange:e=>S(e.target.value)}),k&&a.jsx("button",{type:"button",className:"rounded-sm p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>S(""),children:a.jsx(d.X,{className:"h-3.5 w-3.5"})})]}),a.jsx("div",{className:"max-h-[300px] overflow-y-auto overflow-x-hidden",children:a.jsx("div",{role:"tree",className:"p-1",children:0===F.length?a.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:0===s.length?D:N("no_search_results",N("no_results"))}):a.jsx($r,{nodes:F,level:0,expandedIds:L,onToggleExpand:z,selectedValues:I,onSelect:V})})})]})]})]})}class Hr{static normalizeBase64Url(e){let a=e.replace(/-/g,"+").replace(/_/g,"/");const t=(4-a.length%4)%4;return a+="=".repeat(t),a}static parseJwtPayload(e){try{const r=e.split(".");if(3!==r.length)return null;const n=r[1];n.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(n),a=atob(e),t=new Uint8Array(a.length);for(let r=0;r<a.length;r++)t[r]=a.charCodeAt(r);const s=new TextDecoder("utf-8").decode(t);return JSON.parse(s)}catch(a){try{const e=this.normalizeBase64Url(n),a=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(a)}catch(t){try{const e=this.normalizeBase64Url(n),a=atob(e);return JSON.parse(a)}catch(s){throw s}}}}catch(r){return null}}static validateTokens(e,a){const t=[],s=[];try{a.split(".")[1],e.split(".")[1];const r=this.parseJwtPayload(a),n=this.parseJwtPayload(e);if(!r){const e="ID token decode falhou - possível problema com base64url encoding";return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}let o=!0;if(!n){const e="Access token decode falhou - será tentado novamente nas chamadas de API";t.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";t.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:t,errors:s}}return{isValid:!0,idTokenValid:!0,accessTokenValid:o,warnings:t,errors:s}}catch(r){const e=`Erro na validação de tokens: ${r}`;return s.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:t,errors:s}}}static isTokenExpired(e){const a=this.parseJwtPayload(e);return!a||!a.exp||1e3*a.exp<Date.now()}}Hr.LARGE_PAYLOAD_THRESHOLD=1e3;const Gr="qualiex_access_token",Kr="qualiex_id_token",Yr="supabase_token",Qr="oauth_state",Xr="oauth_nonce",Jr="selected_alias",Zr="manual_logout",en="supabase_project_id",an={setAccessToken:e=>localStorage.setItem(Gr,e),getAccessToken:()=>localStorage.getItem(Gr),setIdToken:e=>localStorage.setItem(Kr,e),getIdToken:()=>localStorage.getItem(Kr),getSupabaseToken:()=>localStorage.getItem(Yr),setOAuthState:e=>sessionStorage.setItem(Qr,e),getOAuthState:()=>sessionStorage.getItem(Qr),clearOAuthState:()=>sessionStorage.removeItem(Qr),setOAuthNonce:e=>sessionStorage.setItem(Xr,e),getOAuthNonce:()=>sessionStorage.getItem(Xr),clearOAuthNonce:()=>sessionStorage.removeItem(Xr),setSelectedAlias:e=>localStorage.setItem(Jr,e),getSelectedAlias:()=>localStorage.getItem(Jr),clearSelectedAlias:()=>localStorage.removeItem(Jr),generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!an.getAccessToken()||!an.getIdToken()),checkProjectMismatch:()=>{const e=(void 0).VITE_SUPABASE_PROJECT_ID;if(!e)return!1;const a=localStorage.getItem(en);return a&&a!==e?(an.clearAll(),localStorage.setItem(en,e),!0):(a||localStorage.setItem(en,e),!1)},setSupabaseToken:e=>{localStorage.setItem(Yr,e),an._clearValidationCache()},areAllTokensValid:()=>{const e=an.getAccessToken(),a=an.getIdToken();if(!e||!a)return!1;try{const t=Hr.validateTokens(e,a);return!!t.idTokenValid&&t.idTokenValid}catch(t){return!1}},clearExpiredTokens:()=>{let e=!1;const a=an.getAccessToken(),t=an.getIdToken(),s=an.getSupabaseToken();return a&&an.isTokenExpired(a)&&(localStorage.removeItem(Gr),e=!0),t&&an.isTokenExpired(t)&&(localStorage.removeItem(Kr),e=!0),s&&an.isTokenExpired(s)&&(localStorage.removeItem(Yr),e=!0),e},clearAll:()=>{localStorage.removeItem(Gr),localStorage.removeItem(Kr),localStorage.removeItem(Yr),localStorage.removeItem(Jr),localStorage.removeItem(Zr),sessionStorage.removeItem(Qr),sessionStorage.removeItem(Xr),an._clearValidationCache()},setManualLogout:()=>localStorage.setItem(Zr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Zr),clearManualLogout:()=>localStorage.removeItem(Zr),isTokenExpired:e=>{try{return Hr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{an._validationCache.isValid=!1,an._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=an.getSupabaseToken();if(!e)return!1;if(an.isTokenExpired(e))return an._clearValidationCache(),an._handleExpiredToken(),!1;const a=Date.now();return a-an._validationCache.timestamp<an._validationCache.cacheValidityMs?an._validationCache.isValid:(an._validationCache.isValid=!0,an._validationCache.timestamp=a,!0)},getValidSupabaseToken:()=>an.isSupabaseTokenValid()?an.getSupabaseToken():null,_handleExpiredToken:()=>{an.clearAll()},extractTokenData:()=>{if(!an.isSupabaseTokenValid())return null;const e=an.getSupabaseToken();if(!e)return null;try{const a=Hr.parseJwtPayload(e);if(!a)return null;const t=a.alias||a.default||a.user_alias,s=a.place_id||null,r=a.place_name||null;let n=a.company_id;if(!n&&t)for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");if(e.length>7&&e[0]===t){n=e[7];break}}}return{alias:t,companyId:n,placeId:s,placeName:r,payload:a}}catch(a){return an._handleExpiredToken(),null}},getCompanyId:e=>{const a=an.getAccessToken();if(a)try{const t=Hr.parseJwtPayload(a);if(t)for(const a in t)if(a.startsWith("co")&&/^co\d+$/.test(a)){const s=t[a];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}const t=an.extractTokenData();if(t?.companyId)return t.companyId;const s=an.getIdToken();if(s)try{const a=Hr.parseJwtPayload(s);if(a)for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>7&&a[0]===e)return a[7];if(!e&&a.length>7)return a[7]}}}catch(r){}return null},getCompanyIdInt:e=>{const a=[an.getAccessToken(),an.getIdToken()];for(const t of a)if(t)try{const a=Hr.parseJwtPayload(t);if(!a)continue;for(const t in a)if(t.startsWith("co")&&/^co\d+$/.test(t)){const s=a[t];if(s&&"string"==typeof s){const a=s.split(";");if(e&&a.length>1&&a[0]===e)return a[1];if(!e&&a.length>1)return a[1]}}}catch{}return null},getCurrentCompanyId:()=>{const e=an.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=an.getIdToken();if(!e)return[];try{const a=Hr.parseJwtPayload(e);if(!a)return[];const t=[];for(const e in a)if(e.startsWith("co")&&/^co\d+$/.test(e)){const s=a[e];if(s&&"string"==typeof s){const e=s.split(";");e.length>=4&&t.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:a})}}return t}catch{return[]}}};const tn=new class{constructor(){this.errors=[],this.toastCount=0,this.lastToastTime=0}handleError(e,a=!0){const t="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:t,timestamp:Date.now(),count:1}),this.errors.length>50&&(this.errors=this.errors.slice(-50)),a&&this.shouldShowToast()){const e=this.getErrorTitle(t);l.toast.error(e,{description:t})}}getErrorTitle(a){const t=a.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?e.t("error_session_expired"):t.includes("token")||t.includes("autenticação")?e.t("error_authentication"):t.includes("api")||t.includes("network")?e.t("error_connection"):"Erro"}success(e,a){l.toast.success(e,{description:a})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};["[forlogic-core] ⚠️ VITE_SUPABASE_PUBLISHABLE_KEY contém uma legacy anon key (JWT).","O Supabase desativou legacy API keys. Substitua pela nova publishable key (formato sb_publishable_*).","Todas as requests retornarão 401 Unauthorized.","Causa provável: a integração Supabase do Lovable sobrescreveu o .env com a anon key legada.","Solução: defina VITE_SUPABASE_PK_OVERRIDE no .env com a publishable key correta."].join(" ");function sn(e){return!!e&&e.startsWith("eyJ")}function rn(){const e=(void 0).VITE_SUPABASE_PK_OVERRIDE;return e||((void 0).VITE_SUPABASE_PUBLISHABLE_KEY??"")}let nn=!1;const on=(void 0).VITE_SUPABASE_URL,ln=rn();class dn{constructor(){this.currentToken=null,function(){const e=(void 0).VITE_SUPABASE_PK_OVERRIDE,a=(void 0).VITE_SUPABASE_PUBLISHABLE_KEY;nn?sn(a):e&&sn(a)?nn=!0:sn(a)?nn=!0:nn=!0}(),this.client=this.createClientWithToken(null)}createClientWithToken(e){const a={apikey:ln};e&&this.isTokenValid(e)&&(a.Authorization=`Bearer ${e}`);return j.createClient(on,ln,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:a,fetch:async(e,a)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,a)}})}static getInstance(){return dn.instance||(dn.instance=new dn),dn.instance}getClient(){const e=an.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{return!Hr.isTokenExpired(e)}catch(a){return tn.handleError(a instanceof Error?a:"Supabase - Error validating token",!1),!1}}}function cn(){return dn.getInstance().getClient()}class un{static async generateToken(e,a,t,s=!1){try{if(!s){const e=an.getSupabaseToken();if(e&&an.isSupabaseTokenValid())return e}const r=cn(),{data:n,error:o}=await r.functions.invoke("validate-token",{body:{access_token:e,alias:a}});return o&&(o.message?.includes("401")||o.message?.includes("Unauthorized"))?(t?.(),null):n?.access_token?(an.setSupabaseToken(n.access_token),n.access_token):null}catch(r){return r instanceof Error&&(r.message.includes("401")||r.message.includes("Unauthorized"))&&t?.(),null}}}class mn{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 a=an.getAccessToken(),t=an.getSelectedAlias();if(!a||!t)return null;const s=await un.generateToken(a,t,this.onLogoutCallback||void 0,e);return s||null}catch(a){return null}}}mn.regenerationPromise=null,mn.onLogoutCallback=null;class pn{static handleError(e){if(!e)return!1;const a=e.message||e.toString();return!!this.isAuthenticationError(e,a)&&(an.clearAll(),window.location.href="/login",!0)}static isAuthenticationError(e,a){if(401===e.status||401===e.statusCode)return!0;const t=a.toLowerCase();return["401","unauthorized","token expired","invalid token","session expired","jwt expired","authentication failed","not authenticated"].some(e=>t.includes(e))}static async wrapAsync(e){try{return await e}catch(a){if(!this.handleError(a))throw a;throw new Error("Sua sessão expirou. Você será redirecionado para fazer login novamente.")}}}class hn{static async handleApiError(e){if(!e||this.isRetrying)return!1;const a=e.status||e.statusCode,t=e.message||e.toString();if(401===a||t.includes("401")||t.includes("Unauthorized")){this.isRetrying=!0;try{return await mn.attemptRegeneration()?(this.isRetrying=!1,!0):(pn.handleError(e),this.isRetrying=!1,!1)}catch(s){return pn.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=an.getAccessToken();return e?an.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."}}}hn.isRetrying=!1;const xn=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=hn.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});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){let a;return a="boolean"==typeof e.isActive?e.isActive:"boolean"==typeof e.active?e.active:"string"!=typeof e.status||"active"===e.status.toLowerCase(),{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,isActive:a}}parseUsersResponse(e,a=""){let t=e;if(e.data)t=e.data;else{if(!Array.isArray(e))return tn.handleError(`[QualiexApi] Formato de resposta inesperado${a}`,!1),null;t=e}return Array.isArray(t)?t.map(e=>this.mapToQualiexUser(e)):(tn.handleError(`[QualiexApi] Resposta não é um array${a}`,!1),null)}async fetchUsers(e,a,t="active"){const s={companyId:a,search:"",filterStatus:t};try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a)??[]}catch(r){if(await hn.handleApiError(r))try{const a=await this.makeApiCall("/api/common/v1/companiesusers",s,e);return this.parseUsersResponse(a," após retry")??[]}catch(n){return tn.handleError(n instanceof Error?n:"Erro ao buscar usuários após renovação de token",!0),[]}return tn.handleError(r instanceof Error?r.message:"Erro ao buscar usuários da API Qualiex",!0),[]}}async fetchUserById(e,a,t){try{return(await this.fetchUsers(a,t)).find(a=>a.userId===e)||null}catch(s){return tn.handleError(s instanceof Error?s:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,a){const t=await this.fetchUsers(e,a,"active"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async fetchAllUsersMap(e,a){const t=await this.fetchUsers(e,a,"all"),s=new Map;return t.forEach(e=>s.set(e.userId,e)),s}async getUsers(e,a="active"){const t=an.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId,a):[]}async fetchSoftwares(e){try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):(tn.handleError("[QualiexApi] fetchSoftwares: formato de resposta inesperado",!1),[])}catch(a){if(await hn.handleApiError(a))try{const a=await this.makeApiCall("/api/common/v1/softwares",{},e),t=a?.data||a;return Array.isArray(t)?t.map(e=>({id:e.id,alias:e.alias||"",color:e.color||"",colorLight:e.colorLight||"",namePtBr:e.namePtBr||"",nameUs:e.nameUs||"",nameEs:e.nameEs||""})):[]}catch(t){return tn.handleError(t instanceof Error?t:"Erro ao buscar softwares após renovação de token",!0),[]}return tn.handleError(a instanceof Error?a.message:"Erro ao buscar softwares da API Qualiex",!0),[]}}async fetchUserAssociations(e,a){try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;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})):(tn.handleError("[QualiexApi] fetchUserAssociations: formato de resposta inesperado",!1),[])}catch(t){if(await hn.handleApiError(t))try{const t=await this.makeApiCall(`/api/common/v1/Users/${e}/associations`,{},a),s=t?.data||t;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 tn.handleError(s instanceof Error?s:"Erro ao buscar associações após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar associações do usuário",!0),[]}}};function fn(e,a){const t=a||Ve.userNameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function gn(e,a){const t=a||Ve.userEmailFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function vn(e,a){const t=a||Ve.userUsernameFieldSuffix;return e.endsWith("_id")?e.replace(/_id$/,t):`${e}${t}`}function bn(e,a){return a&&a.length>0?a.map(e=>({idField:e.idField,nameField:e.nameField||fn(e.idField),emailField:e.emailField||gn(e.idField),usernameField:e.usernameField||vn(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:fn(e),emailField:gn(e),usernameField:vn(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const yn=new Map;class jn{static async fetchQualiexUsers(e,a){const t=`${a}_${e}_all`,s=yn.get(t);if(s&&Date.now()-s.timestamp<3e5)return s.users;const r=await xn.fetchUsers(e,a,"all");return yn.set(t,{users:r,timestamp:Date.now()}),r}static extractUserIds(e,a){const t=new Set;for(const s of e)for(const e of a){const a=s[e.idField];a&&"string"==typeof a&&""!==a.trim()&&t.add(a)}return t}static indexUsers(e){const a=new Map;for(const t of e)t.id&&a.set(t.id,t),t.userId&&a.set(t.userId,t);return a}static enrichEntity(e,a,t){const s={...e};for(const r of a){const a=e[r.idField];if(!a)continue;const n=t.get(a);if(n){if(r.nameField){s[r.nameField]||(s[r.nameField]=n.userName||null)}if(r.emailField){s[r.emailField]||(s[r.emailField]=n.userEmail||null)}if(r.usernameField){s[r.usernameField]||(s[r.usernameField]=n.userName||null)}}}return s}static async enrichWithUserData(e,a){if(!Array.isArray(e)||0===e.length)return e;try{if(!an.areAllTokensValid())return e;const t=an.extractTokenData();if(!t)return e;const{alias:s,companyId:r}=t;if(!s||!r)return e;const n=bn(a.userIdFields,a.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(t){return tn.handleError(t instanceof Error?t:new Error(`[QualiexEnrichment.${a.entityName}] Erro crítico`),!1),e}}}const wn=["responsible_name"],Nn=e=>wn.includes(e);function _n(e,a,t){const s="string"==typeof e?{tableName:e,searchFields:a||[],schemaName:t||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:r,searchFields:n,selectFields:o,schemaName:i,entityName:l,enableQualiexEnrichment:d=!1}=s,c=()=>{if(!an.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return cn().schema(i).from(r)},u=(e,a,t,s)=>{let r=c().select(o||"*",{count:"exact"});r=r.eq("is_removed",!1),Object.entries(s).forEach(([e,a])=>{void 0!==a&&""!==a&&(Array.isArray(a)?r=r.in(e,a):"object"==typeof a&&a&&"operator"in a?"not_null"===a.operator?r=r.not(e,"is",null):"is_null"===a.operator&&(r=r.is(e,null)):null!==a&&(r=r.eq(e,a)))}),r=((e,a)=>{if(a&&n.length>0){const t=n.map(e=>`${e}.ilike.%${a}%`).join(",");return e.or(t)}return e})(r,e);const i=a.includes(".");return i||Nn(a)||(r=r.order(a,{ascending:"asc"===t})),{query:r,isForeignKey:i}},m=async(e,a,t,r,n)=>{const o=bn(s.userIdFields,s.userFieldsMapping).some(e=>e.nameField===a||e.emailField===a||e.usernameField===a),i=a.includes(".");if(Nn(a)||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 jn.enrichWithUserData(o.data,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping});let c;c=i?d.sort((e,s)=>{const r=a.split(".").reduce((e,a)=>e?.[a],e)||"",n=a.split(".").reduce((e,a)=>e?.[a],s)||"",o=String(r).localeCompare(String(n),"pt-BR");return"asc"===t?o:-o}):((e,a,t)=>[...e].sort((e,s)=>{const r=e[a]||"",n=s[a]||"",o=r.localeCompare(n,"pt-BR",{sensitivity:"base"});return"asc"===t?o:-o}))(d,a,t);const u=((e,a=1,t=25)=>{const s=(a-1)*t,r=s+t;return{data:e.slice(s,r),pagination:{currentPage:a,totalPages:Math.ceil(e.length/t),totalItems:e.length,itemsPerPage:t,hasNextPage:r<e.length,hasPreviousPage:a>1}}})(c,r,n);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalItems,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await jn.enrichWithUserData(e,{entityName:l,userIdFields:s.userIdFields,userFieldsMapping:s.userFieldsMapping})},p={async getAll(e={}){const{search:a,sortField:t,sortDirection:n,page:o,limit:i,additionalFilters:c}=(e=>{const{search:a="",sortField:t="updated_at",sortDirection:s="desc",page:r=1,limit:n=25,...o}=e;return{search:a,sortField:t,sortDirection:s,page:r,limit:n,additionalFilters:o}})(e),{query:p}=u(a,t,n,c),h=((e,a,t)=>{const s=(a-1)*t,r=s+t-1;return e.range(s,r)})(p,o,i),{data:x,error:f,count:g}=await h;if(f)throw new Error(`Error fetching ${r}: ${f.message}`);let v=((e,a,t,s)=>{const r=Math.ceil((a||0)/s);return{data:e,currentPage:t,totalPages:r,totalItems:a||0,itemsPerPage:s,hasNextPage:t<r,hasPreviousPage:t>1}})(x||[],g,o,i);if((e=>{if(!d||!l||0===e.length)return!1;const a=bn(s.userIdFields,s.userFieldsMapping);return e.some(e=>a.some(a=>e[a.idField]))})(v.data)){const e=await m(v.data,t,n,o,i);if(!Array.isArray(e))return e;v={...v,data:e}}return v},async getById(e){const{data:a,error:t}=await c().select(o||"*").eq("id",e).maybeSingle();if(t)throw new Error(`Error fetching ${r}: ${t.message}`);return a},async create(e){const a=Yt(e),t=Object.entries(a).reduce((e,[a,t])=>(void 0!==t&&(e[a]=t),e),{}),{data:s,error:n}=await c().insert(t).select().single();if(n)throw new Error(`Error creating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from create ${r} operation`);return s},async update(e,a){const t={...Yt(a),updated_at:(new Date).toISOString()},{data:s,error:n}=await c().update(t).eq("id",e).select().single();if(n)throw new Error(`Error updating ${r}: ${n.message}`);if(!s)throw new Error(`No data returned from update ${r} operation`);return s},async delete(e){const a={is_removed:!0,updated_at:(new Date).toISOString()},{error:t}=await c().update(a).eq("id",e);if(t)throw new Error(`Error soft deleting ${r}: ${t.message}`)}};return p}var Cn;const kn={isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};class Sn{static async initialize(){try{if(an.checkProjectMismatch())return{...kn};if(!an.hasAllTokens()||!an.areAllTokensValid())return an.clearExpiredTokens(),{...kn};const e=an.getAccessToken(),a=an.getIdToken();an.clearManualLogout();const t=this.extractUserFromIdToken(a,e),s=this.extractCompaniesFromIdToken(a),r=this.extractAliasFromAccessToken(e),n=an.extractTokenData(),o=n?.alias;let i=null;if(o&&s.some(e=>e.alias===o))i=o;else{const e=an.getSelectedAlias(),a=e&&s.some(a=>a.alias===e);i=a?e:r||s[0]?.alias||null}if(!an.isSupabaseTokenValid()&&i&&await mn.attemptRegeneration(),!an.isSupabaseTokenValid())return{...kn};let l=null;if(i){const e=an.getCompanyId(i),a=s.find(e=>e.alias===i);a&&(l={id:e||a.id,name:a.name,alias:a.alias})}const d=n?.placeId??null,c=n?.placeName??null;return{isAuthenticated:!0,isLoading:!1,user:t,alias:i,companies:s,selectedUnit:l,userId:t?.id||null,userAlias:t?.id||null,placeId:d,placeName:c,activePlaceId:d,activePlaceName:c}}catch(e){return{...kn}}}static async loginDev(){try{const e=cn(),{data:a,error:t}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(t)return!1;if(!a?.access_token||!a?.id_token)return!1;const s=new URL("/callback",window.location.origin);return s.hash=`access_token=${a.access_token}&id_token=${a.id_token}&token_type=bearer`,window.location.href=s.toString(),!0}catch(e){return!1}}static loginProd(){const e="Lw==";an.setOAuthState(e);const a=an.generateOAuthNonce();an.setOAuthNonce(a);const t=`${window.location.origin}/callback`,s=new URL(Me.oauth.authUrl);s.searchParams.set("client_id",Me.oauth.clientId),s.searchParams.set("response_type",Me.oauth.responseType),s.searchParams.set("scope",Me.oauth.scope),s.searchParams.set("redirect_uri",t),s.searchParams.set("state",e),s.searchParams.set("nonce",a),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),a=new URLSearchParams(window.location.search),t=t=>e.get(t)||a.get(t),s=t("access_token"),r=t("id_token"),n=t("error");if(n)throw new Error(`Erro OAuth: ${n}`);if(s&&r){const e=an.getAccessToken();e!==s&&an.clearAll()}if(an.hasAllTokens()){return an.getValidSupabaseToken()||await mn.attemptRegeneration(!0),!0}const o=s,i=r;if(!o||!i)throw new Error("Tokens não encontrados na URL de callback");an.setAccessToken(o),an.setIdToken(i),an.clearManualLogout();const l=this.extractAliasFromAccessToken(o);if(l)an.setSelectedAlias(l);else{const e=this.extractCompaniesFromIdToken(i);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");an.setSelectedAlias(e[0].alias)}if(!await mn.attemptRegeneration(!0))throw new Error("Falha ao gerar token Supabase");return an.clearOAuthState(),an.clearOAuthNonce(),!0}catch(e){throw e}}static async logout(){an.setManualLogout(),an.clearAll(),localStorage.removeItem("auth_return_url"),sessionStorage.clear();try{if("caches"in window){const e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}catch{}window.location.href="/login"}static decodeToken(e){return Hr.parseJwtPayload(e)}static extractUserFromIdToken(e,a){const t=this.decodeToken(e);if(!t)return null;const s=a?this.decodeToken(a):null;return{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier,isSysAdmin:"1"===s?.admin}}static extractCompaniesFromIdToken(e){const a=this.decodeToken(e);if(!a)return[];const t=[];return Object.keys(a).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof a[e]){const s=a[e].split(";");if(s.length>=4)t.push({id:s.length>7?s[7].trim():"",alias:s[0].trim(),name:s[3].trim()});else{const[s,r]=a[e].split("|");s&&r&&t.push({id:"",alias:s.trim(),name:r.trim()})}}}),t}static extractAliasFromAccessToken(e){const a=this.decodeToken(e);return a?.default||null}}Cn=Sn,mn.setLogoutCallback(()=>{Cn.logout()});const Tn=e=>e?.placeId||null,Pn=e=>e?.placeName||null,En=t.createContext(void 0),Dn=({children:e})=>{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=w.useQueryClient()}catch{}const[o,i]=t.useState(!1),l=t.useRef(0),d=t.useCallback(e=>{r(a=>({...a,...e}))},[]),c=t.useCallback(e=>{r(a=>({...a,isLoading:e}))},[]),u=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})},[]),m=t.useCallback(async e=>{if(e.alias===s.alias)return;const a=++l.current;try{const r=an.getAccessToken();if(!r)return;const o=await un.generateToken(r,e.alias,void 0,!0);if(l.current!==a)return;if(!o)return;an.setSupabaseToken(o),an.setSelectedAlias(e.alias);const i=an.extractTokenData(),c=i?.alias||e.alias,u=i?.companyId||an.getCompanyId(e.alias),m={id:u||e.id,name:e.name,alias:c};let p=null,h=null;if(s.user?.id&&c&&u)try{const e=await xn.fetchActiveUsersMap(c,u);if(l.current!==a)return;const t=e.get(s.user.id);if(t){const e=(e=>({placeId:Tn(e),placeName:Pn(e)}))(t);p=e.placeId,h=e.placeName}}catch(t){}if(l.current!==a)return;d({alias:c,selectedUnit:m,placeId:p,placeName:h,activePlaceId:p,activePlaceName:h}),n&&await n.clear()}catch(t){}},[d,n,s.user,s.alias]),p=t.useCallback(async()=>{const e=await Sn.processCallback();if(e){const e=await Sn.initialize();e&&e.isAuthenticated&&(d({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},[d,n]),h=t.useCallback(async()=>{await Sn.logout(),u(),n&&await n.clear()},[u,n]),x=t.useCallback(e=>{i(e)},[]),f=t.useCallback(()=>{},[]),g=t.useCallback(()=>{n&&n.invalidateQueries()},[n]);t.useEffect(()=>{if(!s.isAuthenticated)return;let e=!0;const a=setInterval(async()=>{if(e)if(an.areAllTokensValid()){if(!an.isSupabaseTokenValid())try{await mn.attemptRegeneration()||e&&h()}catch(a){e&&h()}}else e&&h()},6e5);return()=>{e=!1,clearInterval(a)}},[s.isAuthenticated,h]),t.useEffect(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const a=await Sn.initialize();if(!e)return;a&&a.isAuthenticated?d({user:a.user,companies:a.companies,alias:a.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:a.selectedUnit,userId:a.userId,userAlias:a.userAlias,placeId:a.placeId,placeName:a.placeName,activePlaceId:a.activePlaceId,activePlaceName:a.activePlaceName}):e&&c(!1)}catch(a){e&&(pn.handleError(a),c(!1))}})(),()=>{e=!1}},[d,c,h]);const v=t.useMemo(()=>({...s,logout:h,processCallback:p,switchUnit:m,availableUnits:s.companies,isSearchVisible:o,setSearchVisible:x,clearSearch:f,refreshData:g}),[s.user,s.companies,s.alias,s.isAuthenticated,s.isLoading,s.selectedUnit,s.userId,s.userAlias,s.placeId,s.placeName,s.activePlaceId,s.activePlaceName,h,p,m,o,x,f,g]);return a.jsx(En.Provider,{value:v,children:e})},An=()=>{const e=t.useContext(En);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function In({queryKey:e,service:a,entityName:s,searchFields:r,additionalFilters:n={},onSuccess:o}){const[i,d]=N.useSearchParams(),c=w.useQueryClient(),{alias:u,userId:m,isAuthenticated:p}=An(),{t:h}=y.useTranslation(),x=t.useCallback(a=>{const t=`${e}_${a}`,s=i.get(t);return s||(i.get(a)||"")},[i,e]),f=x("search"),g=x("sortField")||Fe.sorting.defaultField,v=x("sortDirection")||Fe.sorting.defaultDirection,b=parseInt(x("page")||"1"),j=parseInt(x("limit")||String(Fe.pagination.defaultPageSize)),_=f,C=t.useMemo(()=>({search:_,sortField:g,sortDirection:v,page:b,limit:j,...n}),[_,g,v,b,j,n]),k=t.useCallback(()=>a.getAll(C),[a,C]),S=w.useQuery({queryKey:[e,u,m,C],queryFn:k,enabled:!!u&&p});if(!S)throw new Error(`useCrud: Query initialization failed for "${s}". Ensure QueryClientProvider is configured in your app root.`);const T=w.useMutation({mutationFn:a.create,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.created(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.create(s)}: ${e.message}`)}}),P=w.useMutation({mutationFn:({id:e,data:t})=>a.update(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.updated(s)),o?.()},onError:e=>{l.toast.error(`${qe.error.update(s)}: ${e.message}`)}}),E=w.useMutation({mutationFn:a.delete,onSuccess:()=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(qe.success.deleted(s))},onError:e=>{l.toast.error(`${qe.error.delete(s)}: ${e.message}`)}}),D=t.useCallback(a=>{const t={...Object.fromEntries(i)};Object.entries(a).forEach(([a,s])=>{const r=`${e}_${a}`;""===s||0===s?delete t[r]:t[r]=String(s)}),delete t.sortField,delete t.sortDirection,d(t)},[i,d,e]),A=t.useCallback(e=>{D({search:e,page:1})},[D]),I=t.useCallback(e=>{D({sortField:e,sortDirection:g===e&&"asc"===v?"desc":"asc",page:1})},[g,v,D]),M=t.useCallback(e=>{D({page:e})},[D]),F=t.useCallback(e=>{D({limit:e,page:1})},[D]),R=t.useCallback(()=>{const a=Object.fromEntries(i),t=`${e}_`,s=Object.fromEntries(Object.entries(a).filter(([e])=>!e.startsWith(t)));d(s)},[d,i,e]),[L,z]=t.useState([]),U=t.useCallback(e=>{z(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),O=t.useCallback(()=>{const e=S?.data?.data.map(e=>e.id)||[];z(a=>a.length===e.length?[]:e)},[S?.data?.data]),V=t.useCallback(()=>{z([])},[]),B=t.useMemo(()=>{const e=S?.data?.data.map(e=>e.id)||[];return e.length>0&&L.length===e.length},[L,S?.data?.data]),q=w.useMutation({mutationFn:async e=>{await Promise.all(e.map(e=>a.delete(e)))},onSuccess:(a,t)=>{c.invalidateQueries({queryKey:[e]}),l.toast.success(h("bulk_delete_success",`${t.length} ${s}(s) deletado(s) com sucesso`)),V()},onError:e=>{l.toast.error(h("bulk_delete_error",`Erro ao deletar itens: ${e.message}`))}}),$=t.useCallback((e,a)=>{const t=a?a(e):e;e.id?P.mutate({id:e.id,data:t}):T.mutate({...t,alias:u})},[u,T,P]);return{entities:S?.data?.data||[],pagination:{data:S?.data?.data||[],currentPage:S?.data?.currentPage||1,totalPages:S?.data?.totalPages||1,totalItems:S?.data?.totalItems||0,itemsPerPage:S?.data?.itemsPerPage||Fe.pagination.defaultPageSize,hasNextPage:S?.data?.hasNextPage||!1,hasPreviousPage:S?.data?.hasPreviousPage||!1},isLoading:S?.isLoading??!0,isCreating:T?.isPending??!1,isUpdating:P?.isPending??!1,isDeleting:E?.isPending??!1,error:S?.error||null,searchTerm:f,sortField:g,sortDirection:v,currentPage:b,itemsPerPage:j,queryKey:e,createEntity:T.mutate,updateEntity:(e,a)=>P.mutate({id:e,data:a}),deleteEntity:E.mutate,save:$,handleSearch:A,handleSort:I,handlePageChange:M,handleItemsPerPageChange:F,clearFilters:R,refetch:S.refetch,selectedIds:L,selectItem:U,selectAll:O,clearSelection:V,isAllSelected:B,bulkDelete:e=>q.mutateAsync(e),isBulkDeleting:q.isPending}}function Mn(e){const[a,s]=t.useState(()=>"undefined"!=typeof window&&window.matchMedia(e).matches);return t.useEffect(()=>{const a=window.matchMedia(e);s(a.matches);const t=e=>{s(e.matches)};return a.addEventListener("change",t),()=>a.removeEventListener("change",t)},[e]),a}function Fn(e=768){return Mn(`(max-width: ${e-1}px)`)}const Rn=ae.forwardRef(({className:e,...t},s)=>a.jsx("table",{ref:s,className:Kt("w-full caption-bottom text-[13px] table-fixed",e),...t}));Rn.displayName="Table";const Ln=ae.forwardRef(({className:e,...t},s)=>a.jsx("thead",{ref:s,className:Kt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));Ln.displayName="TableHeader";const zn=ae.forwardRef(({className:e,...t},s)=>a.jsx("tbody",{ref:s,className:Kt("[&_tr:last-child]:border-0",e),...t}));zn.displayName="TableBody";const Un=ae.forwardRef(({className:e,...t},s)=>a.jsx("tfoot",{ref:s,className:Kt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Un.displayName="TableFooter";const On=ae.forwardRef(({className:e,...t},s)=>a.jsx("tr",{ref:s,className:Kt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted even:bg-table-stripe",e),...t}));On.displayName="TableRow";const Vn=ae.forwardRef(({className:e,...t},s)=>a.jsx("th",{ref:s,className:Kt("h-9 px-4 py-2 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));Vn.displayName="TableHead";const Bn=ae.forwardRef(({className:e,...t},s)=>a.jsx("td",{ref:s,className:Kt("px-4 py-2 align-middle overflow-hidden [&:has([role=checkbox])]:pr-0",e),...t}));Bn.displayName="TableCell";const qn=ae.forwardRef(({className:e,...t},s)=>a.jsx("caption",{ref:s,className:Kt("mt-4 text-sm text-muted-foreground",e),...t}));function $n({rows:e=5,columns:t=4}){return a.jsx("div",{className:"w-full",children:a.jsxs("div",{className:"rounded-md border",children:[a.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-24"},t))})}),a.jsx("div",{children:Array.from({length:e}).map((e,s)=>a.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:a.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>a.jsx(Rr,{className:"h-4 w-20"},t))})},s))})]})})}function Wn({count:e=3}){return a.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>a.jsxs(ts,{children:[a.jsxs(ss,{children:[a.jsx(Rr,{className:"h-4 w-3/4"}),a.jsx(Rr,{className:"h-3 w-1/2"})]}),a.jsx(os,{children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-3 w-full"}),a.jsx(Rr,{className:"h-3 w-2/3"})]})})]},t))})}qn.displayName="TableCaption";const Hn={default:d.FileX,search:d.Search,error:d.AlertCircle};function Gn({icon:e,title:t,description:s,action:r,className:n,variant:o="default"}){const{t:i}=y.useTranslation(),l=!!e,d=Hn[o];return a.jsxs("div",{className:Kt("flex flex-col items-center justify-center py-12 px-4 text-center",n),children:[a.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:l?e:a.jsx(d,{className:"h-8 w-8 text-muted-foreground"})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),s&&a.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:s}),r&&a.jsx(Xt,{onClick:r.onClick,variant:"outline",children:r.label})]})}function Kn({children:e,className:t}){const s=ae.useRef(null),[r,n]=ae.useState(!1);ae.useEffect(()=>{const e=()=>{const e=s.current;e&&n(e.scrollWidth>e.clientWidth)};e();const a=new ResizeObserver(e);return s.current&&a.observe(s.current),()=>a.disconnect()},[e]);const o=a.jsx("div",{ref:s,className:`truncate w-full max-w-full ${t||""}`,children:e});return r?a.jsx(yr,{delayDuration:300,children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:o}),a.jsx(Nr,{side:"top",className:"max-w-[400px] break-words",children:e})]})}):o}const Yn=ae.forwardRef(({direction:e,onMouseDown:t,isDragging:s,className:r},n)=>{const o="horizontal"===e;return a.jsx("div",{ref:n,onMouseDown:t,className:Kt("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:a.jsx("div",{className:Kt("rounded-full bg-border transition-colors group-hover:bg-primary",s&&"bg-primary",o?"h-6 w-0.5":"w-6 h-0.5")})})});Yn.displayName="TableResizeHandle";const Qn=me.Root,Xn=me.Trigger,Jn=me.Group,Zn=me.Portal,eo=me.Sub,ao=me.RadioGroup,to=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(me.SubTrigger,{ref:n,className:Kt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));to.displayName=me.SubTrigger.displayName;const so=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.SubContent,{ref:s,className:Kt("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",e),...t}));so.displayName=me.SubContent.displayName;const ro=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Portal,{children:a.jsx(me.Content,{ref:s,className:Kt("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",e),...t})}));ro.displayName=me.Content.displayName;const no=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Item,{ref:r,className:Kt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));no.displayName=me.Item.displayName;const oo=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(me.CheckboxItem,{ref:n,className:Kt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));oo.displayName=me.CheckboxItem.displayName;const io=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(me.RadioItem,{ref:r,className:Kt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(me.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));io.displayName=me.RadioItem.displayName;const lo=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(me.Label,{ref:r,className:Kt("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...s}));lo.displayName=me.Label.displayName;const co=ae.forwardRef(({className:e,...t},s)=>a.jsx(me.Separator,{ref:s,className:Kt("-mx-1 my-1 h-px bg-border",e),...t}));co.displayName=me.Separator.displayName;const uo=({className:e,...t})=>a.jsx("span",{className:Kt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});uo.displayName="ContextMenuShortcut";const mo=({onEdit:e,onDelete:t,onToggleStatus:s,isActive:r=!0,canDelete:n=!0,customActions:o=[],renderAs:i})=>{const{t:l}=y.useTranslation(),c=[];if(e){const a={icon:d.Edit,label:l("edit"),onClick:e};c.push(a)}if(o.forEach(e=>{c.push(e)}),s){const e={icon:r?d.PowerOff:d.Power,label:r?"Inativar":"Ativar",onClick:s};c.push(e)}if(n&&t){const e={icon:d.Trash2,label:l("ap_delete"),onClick:t,destructive:!0};c.push(e)}const u="dropdown"===i?hr:no;return a.jsx(a.Fragment,{children:c.map((e,t)=>a.jsxs(u,{onClick:e.onClick,className:Kt("whitespace-normal cursor-pointer",e.destructive&&"text-destructive focus:text-destructive"),children:[a.jsx(e.icon,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.label]},t))})},po=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:a.jsx(d.EllipsisVertical,{size:12})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[160px]",children:a.jsx(mo,{onEdit:e?a=>{a?.stopPropagation(),e?.()}:void 0,onDelete:t?e=>{e?.stopPropagation(),t?.()}:void 0,onToggleStatus:r?e=>{e?.stopPropagation(),r?.()}:void 0,isActive:n,canDelete:s&&!!t,customActions:o,renderAs:"dropdown"})})]}),ho=({onEdit:e,onDelete:t,canDelete:s=!0,onToggleStatus:r,isActive:n=!0,customActions:o=[]})=>{const{t:i}=y.useTranslation();return a.jsx(yr,{delayDuration:200,children:a.jsxs("div",{className:"flex items-center justify-end gap-0.5",children:[e&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e()},children:a.jsx(d.Pencil,{size:14})})}),a.jsx(Nr,{children:i("edit")})]}),o.map((e,t)=>{const s=e.icon;return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),e.onClick()},children:a.jsx(s,{size:14})})}),a.jsx(Nr,{children:e.label})]},t)}),r&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:e=>{e.stopPropagation(),r()},children:n?a.jsx(d.ToggleRight,{size:14}):a.jsx(d.ToggleLeft,{size:14})})}),a.jsx(Nr,{children:n?"Inativar":"Ativar"})]}),t&&s&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Kt("h-7 w-7 hover:text-destructive"),onClick:e=>{e.stopPropagation(),t()},children:a.jsx(d.Trash2,{size:14})})}),a.jsx(Nr,{children:i("ap_delete")})]})]})})},xo=150;function fo({columns:e,storageKey:a,onResize:s,enabled:r=!0}){const[n,o]=t.useState(()=>{if(!r||"undefined"==typeof window)return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??xo,e),{});if(a){const e=localStorage.getItem(a);if(e)try{return JSON.parse(e)}catch{}}return e.reduce((e,a)=>(e[a.key]=a.defaultWidth??xo,e),{})}),[i,l]=t.useState(!1),[d,c]=t.useState(null),u=t.useRef(0),m=t.useRef(0),p=t.useCallback((e,a)=>{r&&(a.preventDefault(),a.stopPropagation(),l(!0),c(e),u.current=a.clientX,m.current=n[e]??xo)},[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 a=e.clientX-u.current,t=Math.max(r,Math.min(n,m.current+a));o(e=>{const a={...e,[d]:t};return s?.(a),a})},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,a)=>(e[a.key]=a.defaultWidth??xo,e),{});o(t),a&&localStorage.removeItem(a),s?.(t)},[e,a,s]);return{columnWidths:n,isDragging:i,activeColumn:d,handleMouseDown:p,resetWidths:h}}const go=r.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"}}),vo=ae.forwardRef(({className:e,variant:t,size:s,...r},n)=>a.jsx(he.Root,{ref:n,className:Kt(go({variant:t,size:s,className:e})),...r}));vo.displayName=he.Root.displayName;const bo=ae.createContext({size:"default",variant:"default"}),yo=ae.forwardRef(({className:e,variant:t,size:s,children:r,...n},o)=>a.jsx(pe.Root,{ref:o,className:Kt("flex items-center justify-center gap-1",e),...n,children:a.jsx(bo.Provider,{value:{variant:t,size:s},children:r})}));yo.displayName=pe.Root.displayName;const jo=ae.forwardRef(({className:e,children:t,variant:s,size:r,...n},o)=>{const i=ae.useContext(bo);return a.jsx(pe.Item,{ref:o,className:Kt(go({variant:i.variant||s,size:i.size||r}),e),...n,children:t})});jo.displayName=pe.Item.displayName;const wo=t.memo(function({onNew:e,newButtonLabel:t,showNewButton:s=!0,showSearch:r=!1,searchValue:n="",onSearchChange:o,searchPlaceholder:i,showBulkActions:l=!1,selectedCount:c=0,bulkActions:u=[],onBulkDelete:m,onClearSelection:p,customActions:h=[],filters:x,viewMode:f,onViewModeChange:g,showViewToggle:v=!1,availableViewModes:b=["table","list","grid"],rightSlot:j,className:w}){const{t:N}=y.useTranslation(),_=c>0,C=e&&s||h.length>0,k=x||v||j,S=r&&o;return C||S||k||l&&_?a.jsxs("div",{className:Kt("flex-shrink-0 flex items-center px-4 py-1.5 bg-muted/50 border-b gap-4",w),children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e&&s&&a.jsxs(Xt,{onClick:e,children:[a.jsx(d.Plus,{size:16,className:"mr-2"}),t||"Novo"]}),h.map((e,t)=>{const s=e.icon;return a.jsxs(Xt,{onClick:e.action,variant:e.variant||"outline",disabled:e.disabled,title:e.disabled?e.disabledReason:void 0,children:[s&&a.jsx(s,{size:16,className:"mr-2"}),e.label]},t)})]}),l&&_&&a.jsxs("div",{className:"flex items-center gap-1 shrink-0 border-l pl-4",children:[a.jsx(er,{variant:"secondary",className:"mr-1 tabular-nums",children:c}),a.jsxs(yr,{delayDuration:200,children:[u.length>0?u.map((e,t)=>{const s=e.icon,r=e.disabled;return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Kt("h-8 w-8","destructive"===e.variant&&"text-destructive hover:text-destructive hover:bg-destructive/10"),disabled:r,onClick:()=>e.action([]),children:s?a.jsx(s,{size:16}):a.jsx("span",{className:"text-xs",children:e.label[0]})})}),a.jsx(Nr,{children:e.label})]},t)}):a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:m,children:a.jsx(d.Trash2,{size:16})})}),a.jsx(Nr,{children:N("ap_delete")})]}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:p,children:a.jsx(d.X,{size:16})})}),a.jsx(Nr,{children:N("clear_selection")})]})]})]}),S&&a.jsx("div",{className:"flex-1 flex justify-center max-w-md mx-auto",children:a.jsxs("div",{className:"relative w-full",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i||"Pesquisar",value:n,onChange:e=>o?.(e.target.value),className:"pl-9 w-full"})]})}),k&&a.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-auto",children:[x,v&&f&&g&&a.jsx(yo,{type:"single",value:f,onValueChange:e=>e&&g(e),size:"sm",children:b.map(e=>{const t=(e=>{switch(e){case"table":return d.Table2;case"list":return d.List;case"grid":return d.LayoutGrid}})(e);return a.jsx(jo,{value:e,"aria-label":"Visualizar como "+("table"===e?"tabela":"list"===e?"lista":"grade"),children:a.jsx(t,{className:"h-4 w-4"})},e)})}),j]})]}):null}),No=t.memo(({checked:e,onCheckedChange:t})=>a.jsx(Xs,{checked:e,onCheckedChange:t}),(e,a)=>e.checked===a.checked);function _o(e){try{const a=localStorage.getItem(e);if(!a)return null;const t=JSON.parse(a);let s=t.groupByColumns||[];return 0===s.length&&t.groupByColumn&&(s=[t.groupByColumn]),{hiddenColumns:new Set(t.hiddenColumns||[]),columnOrder:t.columnOrder||[],groupByColumns:s}}catch{return null}}function Co({columns:e,storageKey:a,enabled:s=!0,defaultHiddenColumns:r}){const n=t.useMemo(()=>e.map(e=>String(e.key)),[e]),o=t.useMemo(()=>new Set(r??[]),[r]),[i,l]=t.useState(()=>{if(!s)return o;if(!a)return o;const e=_o(a);return e?.hiddenColumns??o}),[d,c]=t.useState(()=>{if(!s||!a)return n;const e=_o(a)?.columnOrder;return e&&e.length>0?e:n}),[u,m]=t.useState(()=>s&&a?_o(a)?.groupByColumns??[]:[]),[p,h]=t.useState(new Set);t.useEffect(()=>{s&&a&&function(e,a){try{localStorage.setItem(e,JSON.stringify({hiddenColumns:Array.from(a.hiddenColumns),columnOrder:a.columnOrder,groupByColumns:a.groupByColumns}))}catch{}}(a,{hiddenColumns:i,columnOrder:d,groupByColumns:u})},[i,d,u,a,s]),t.useEffect(()=>{const a=new Set(e.map(e=>String(e.key))),t=new Set(d),s=[...a].filter(e=>!t.has(e));s.length>0&&c(e=>[...e.filter(e=>a.has(e)),...s])},[e]);const x=t.useCallback(e=>i.has(e),[i]),f=t.useCallback(e=>{l(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),g=t.useCallback(()=>{l(new Set)},[]),v=t.useCallback(()=>{if(l(o),c(n),m([]),h(new Set),a)try{localStorage.removeItem(a)}catch{}},[n,o,a]),b=t.useCallback((e,a)=>{c(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s})},[]),y=t.useCallback(e=>{h(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),j=t.useCallback(e=>{m(e),h(new Set)},[]),w=t.useCallback(e=>{m(a=>a.includes(e)?a:[...a,e])},[]),N=t.useCallback(e=>{m(a=>a.filter(a=>a!==e)),h(a=>{const t=new Set;for(const s of a)s.includes(`${e}:`)||t.add(s);return t})},[]),_=t.useCallback((e,a)=>{m(t=>{const s=[...t],[r]=s.splice(e,1);return s.splice(a,0,r),s}),h(new Set)},[]),C=u[0]??null,k=t.useCallback(e=>{m(e?[e]:[]),h(new Set)},[]),S=t.useMemo(()=>{if(!s)return e;const a=new Map(e.map(e=>[String(e.key),e]));return d.filter(e=>!i.has(e)&&a.has(e)).map(e=>a.get(e))},[e,d,i,s]),T=t.useCallback(e=>{if(0===u.length)return[{groupKey:"__all__",groupValue:"",items:e,count:e.length,level:0}];return function e(a,t,s,r){if(0===t.length)return[{groupKey:r||"__leaf__",groupValue:"",items:a,count:a.length,level:s}];const[n,...o]=t,i=new Map;for(const l of a){const e=String(l[n]??"(vazio)");i.has(e)||i.set(e,[]),i.get(e).push(l)}return Array.from(i.entries()).map(([a,t])=>{const i=r?`${r}|${n}:${a}`:`${n}:${a}`,l=o.length>0?e(t,o,s+1,i):void 0;return{groupKey:i,groupValue:a,items:t,count:t.length,level:s,children:l}})}(e,u,0,"")},[u]);return{visibleColumns:S,allColumns:e,isColumnHidden:x,toggleColumn:f,showAllColumns:g,resetColumns:v,columnOrder:d,reorderColumns:b,groupByColumn:C,setGroupByColumn:k,groupByColumns:u,setGroupByColumns:j,addGroupByColumn:w,removeGroupByColumn:N,reorderGroupByColumns:_,getGroupedData:T,collapsedGroups:p,toggleGroupCollapse:y}}function ko({enabled:e=!1,onReorder:a}){const[s,r]=t.useState(null),[n,o]=t.useState(null),i=t.useCallback(()=>{r(null),o(null)},[]),l=t.useCallback((t,n)=>({draggable:e,onDragStart:a=>{e&&(r(t),a.dataTransfer.effectAllowed="copyMove",a.dataTransfer.setData("text/plain",String(t)),n&&a.dataTransfer.setData("application/column-key",n))},onDragOver:a=>{e&&null!==s&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDragEnter:a=>{e&&null!==s&&(a.preventDefault(),o(t))},onDrop:r=>{r.preventDefault(),e&&null!==s&&s!==t?(a(s,t),i()):i()},onDragEnd:()=>{i()}}),[e,s,a,i]);return t.useMemo(()=>({dragFromIndex:s,dragOverIndex:n,isDragging:null!==s,getDragProps:l}),[s,n,l])}function So({columns:e,columnOrder:s,isColumnHidden:r,toggleColumn:n,showAllColumns:o,reorderColumns:i,groupByColumn:l,setGroupByColumn:c,groupByColumns:u=[],addGroupByColumn:m,removeGroupByColumn:p,resetColumns:h}){const{t:x}=y.useTranslation(),[f,g]=t.useState(null),[v,b]=t.useState(null),j=t.useRef(null),w=new Map(e.map(e=>[String(e.key),e])),N=s.filter(e=>w.has(e)).map(e=>w.get(e)),_=()=>{j.current=null,g(null),b(null)};N.some(e=>r(String(e.key)));const C=N.every(e=>!r(String(e.key)));return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"icon",className:"h-8 w-8",children:a.jsx(d.Columns3,{size:16})})}),a.jsxs(Sr,{className:"w-[260px] p-0",align:"end",children:[a.jsx("div",{className:"px-3 py-2 border-b",children:a.jsx("span",{className:"text-sm font-medium",children:"Colunas"})}),a.jsx("div",{className:"max-h-[300px] overflow-auto py-1",children:a.jsx(yr,{delayDuration:300,children:N.map((e,t)=>{const s=String(e.key),o=r(s),h=!1!==e.hideable,y=!0===e.groupable,w=u.includes(s)||l===s;return a.jsxs("div",{draggable:!0,onDragStart:()=>(e=>{j.current=e,g(e)})(t),onDragOver:e=>((e,a)=>{e.preventDefault(),b(a)})(e,t),onDrop:()=>(e=>{null!==j.current&&j.current!==e&&i(j.current,e),j.current=null,g(null),b(null)})(t),onDragEnd:_,className:Kt("flex items-center gap-2 px-3 py-1.5 text-sm cursor-grab active:cursor-grabbing","hover:bg-muted/50 transition-colors",f===t&&"opacity-50",v===t&&"border-t-2 border-primary"),children:[a.jsx(d.GripVertical,{size:14,className:"text-muted-foreground shrink-0"}),a.jsx(Xs,{checked:!o,onCheckedChange:()=>h&&n(s),disabled:!h,className:"shrink-0"}),a.jsx("span",{className:Kt("flex-1 truncate",o&&"text-muted-foreground"),children:e.header}),y&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:Kt("h-6 w-6 shrink-0",w&&"text-primary bg-primary/10"),onClick:e=>{e.stopPropagation(),w?p?p(s):c?.(null):m?m(s):c?.(s)},children:a.jsx(d.Group,{size:14})})}),a.jsx(Nr,{children:x(w?"remove_grouping":"group_by_column")})]})]},s)})})}),a.jsxs("div",{className:"border-t px-3 py-2 space-y-1",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:C?()=>N.filter(e=>!1!==e.hideable).forEach(e=>n(String(e.key))):o,children:x(C?"deselect_all":"select_all_columns")}),h&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"w-full text-xs font-normal justify-start",onClick:h,children:"Redefinir padrão"})]})]})]})}function To({columns:e,groupByColumns:s,addGroupByColumn:r,removeGroupByColumn:n,reorderGroupByColumns:o}){const[i,l]=t.useState(!1),[c,u]=t.useState(null),[m,p]=t.useState(null),h=new Map(e.map(e=>[String(e.key),e])),x=()=>{u(null),p(null)},f=s.length>0;return a.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",l(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{e.preventDefault(),l(!1);if(Array.from(e.dataTransfer.types).includes("application/group-chip-index"))return;const a=e.dataTransfer.getData("application/column-key");if(a&&!s.includes(a)){const e=h.get(a);e&&e.groupable&&r(a)}},className:Kt("flex items-center gap-2 px-4 py-2 min-h-[40px] border-b transition-colors",i&&"bg-primary/5 border-primary/30",!f&&"text-muted-foreground"),children:[a.jsx(d.Group,{size:14,className:"shrink-0 text-muted-foreground"}),a.jsx("div",{className:"flex-1 flex items-center gap-1.5 flex-wrap",children:f?s.map((e,s)=>{const r=h.get(e);if(!r)return null;const i=c===s,l=m===s&&c!==s;return a.jsxs(t.Fragment,{children:[s>0&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"›"}),a.jsxs(er,{variant:"secondary",className:Kt("cursor-grab active:cursor-grabbing gap-1 pr-1 select-none",i&&"opacity-50",l&&"ring-2 ring-primary"),draggable:!0,onDragStart:e=>((e,a)=>{e.stopPropagation(),e.dataTransfer.setData("application/group-chip-index",String(a)),e.dataTransfer.effectAllowed="move",u(a)})(e,s),onDragOver:e=>((e,a)=>{e.preventDefault(),e.stopPropagation(),p(a)})(e,s),onDrop:e=>((e,a)=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer.getData("application/group-chip-index");if(""!==t){const e=parseInt(t,10);isNaN(e)||e===a||o(e,a)}u(null),p(null)})(e,s),onDragEnd:x,children:[r.header,a.jsx("button",{onClick:a=>{a.stopPropagation(),n(e)},className:"ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20 transition-colors",children:a.jsx(d.X,{size:12})})]})]},e)}):a.jsx("span",{className:"text-xs",children:"Arraste um cabeçalho de coluna aqui para agrupar"})})]})}const Po=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:u,enableBulkActions:m=!1,rowActionsVariant:p="dropdown",onNew:h,newButtonLabel:x,showNewButton:f=!0,customActions:g=[],hideActionBar:v,showActionBar:b=!0,showSearch:j=!1,searchValue:w,onSearchChange:N,searchPlaceholder:_,bulkActions:C=[],onBulkDelete:k,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:E=!1,enableColumnResize:D=!0,resizeStorageKey:A,enableColumnManager:I=!0,columnManagerStorageKey:M,defaultHiddenColumns:F,enableGrouping:R=!1,enableExpandableRows:L=!1,renderExpandedContent:z,expandedRowIds:U,onToggleExpand:O,defaultExpandAll:V=!1,hideActionsColumn:B=!1})=>{const{t:q}=y.useTranslation(),{setSearchVisible:$}=An(),W=Fn(),[H,G]=t.useState(()=>V&&L?new Set(s.entities.map(e=>e.id)):new Set),K=void 0!==U,Y=K?new Set(U):H,Q=t.useCallback(e=>{K&&O?O(e):G(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[K,O]),X=void 0!==v?!v:b;t.useEffect(()=>{if(!j)return $(!0),()=>$(!1)},[$,j]);const J=Co({columns:r,storageKey:M,enabled:I,defaultHiddenColumns:F}),Z=ko({enabled:I,onReorder:J.reorderColumns}),ee=I?J.visibleColumns:r,{columnWidths:ae,isDragging:te,activeColumn:se,handleMouseDown:re}=fo({columns:ee.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:D}),ne=t.useMemo(()=>(()=>{if(D){const e=ee.map(e=>ae[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return ee.map((t,s)=>({...t,calculatedWidth:e[s],style:{width:e[s]/a*100+"%"}}))}let e=0;const a=ee.map(a=>{if(a.width)return e+=a.width,{...a,calculatedWidth:a.width,isFixed:!0};{const t=a.minWidth||120,s=a.weight||1;return e+=t,{...a,calculatedWidth:t,weight:s,isFixed:!1}}});return e+=50,a.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[ee,D,ae]),oe=h||g.length>0||j||m||S||E||I,ie=X&&oe,le=k||(()=>{s.bulkDelete?.(s.selectedIds)}),de=e=>a.jsx(Bn,{className:"text-center",children:c?c(e):"inline"===p?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:a.jsx(ho,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}):a.jsx(po,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})}),ce=e=>a.jsx(ro,{className:"w-[160px]",children:a.jsx(mo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:u?u(e):[],renderAs:"context"})}),ue=I?a.jsx(So,{columns:r,columnOrder:J.columnOrder,isColumnHidden:J.isColumnHidden,toggleColumn:J.toggleColumn,showAllColumns:J.showAllColumns,resetColumns:J.resetColumns,reorderColumns:J.reorderColumns,groupByColumn:R?J.groupByColumn:void 0,setGroupByColumn:R?J.setGroupByColumn:void 0,groupByColumns:R?J.groupByColumns:void 0,addGroupByColumn:R?J.addGroupByColumn:void 0,removeGroupByColumn:R?J.removeGroupByColumn:void 0}):void 0;if(W)return s.isLoading?a.jsx(Wn,{count:3}):0===s.entities.length?a.jsx(Gn,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"}):a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(wo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:j,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:E}),a.jsx("div",{className:"flex-1 overflow-auto space-y-4 p-4",children:s.entities.map(e=>a.jsxs(Qn,{children:[a.jsx(Xn,{asChild:!0,children:a.jsx(ts,{className:Kt("overflow-hidden cursor-pointer hover:bg-muted/50",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:a.jsx(os,{className:"p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[m&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(No,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1",children:[ee.map(t=>a.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||c)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(e):a.jsx(po,{onEdit:n?()=>{n(e)}:void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:u?u(e):[]})})]})]})})})}),ce(e)]},e.id))})]});const me=R&&J.groupByColumns.length>0?J.getGroupedData(s.entities):null,pe=null!==me,he=(L?1:0)+(m?1:0)+ee.length+(B?0:1),xe=e=>{const r=L&&Y.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(Qn,{children:[a.jsx(Xn,{asChild:!0,children:a.jsxs(On,{className:Kt("cursor-pointer hover:bg-muted/50 relative",("inline"===p||B)&&"group",m&&s.selectedIds.includes(e.id)&&"bg-muted"),onClick:a=>{a.stopPropagation(),m?s.selectItem(e.id):n?.(e)},children:[L&&a.jsx(Bn,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),Q(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":q(r?"collapse_row":"expand_row"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),m&&a.jsx(Bn,{onClick:e=>e.stopPropagation(),children:a.jsx(No,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),ee.map(t=>a.jsx(Bn,{className:t.className,children:a.jsx(Kn,{children:t.render?t.render(e):String(e[t.key]??"")})},String(t.key))),!B&&de(e)]})}),ce(e)]}),r&&z&&a.jsx(On,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Bn,{colSpan:he,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:z(e)})})})]},e.id)},fe=(e,s)=>{const{t:r}=y.useTranslation();return e.map(e=>{const r=J.collapsedGroups.has(e.groupKey),n=16*e.level,o=Math.max(30,70-15*e.level);return a.jsxs(t.Fragment,{children:[a.jsx(On,{className:Kt("hover:bg-muted cursor-pointer"),style:{backgroundColor:`hsl(var(--muted) / ${o}%)`},onClick:()=>J.toggleGroupCollapse(e.groupKey),children:a.jsx(Bn,{colSpan:s,className:"py-2 px-4",children:a.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm",style:{paddingLeft:`${n}px`},children:[r?a.jsx(d.ChevronRight,{size:16}):a.jsx(d.ChevronDown,{size:16}),a.jsx("span",{children:e.groupValue}),a.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",e.count,")"]})]})})}),!r&&(e.children?fe(e.children,s):e.items.map(xe))]},e.groupKey)})};return a.jsxs("div",{className:"flex flex-col h-full",children:[ie&&a.jsx(wo,{onNew:h,newButtonLabel:x,showNewButton:f,showSearch:j,searchValue:w,onSearchChange:N,searchPlaceholder:_,showBulkActions:m,selectedCount:s.selectedIds.length,bulkActions:C,onBulkDelete:le,onClearSelection:s.clearSelection,customActions:g,filters:S,viewMode:T,onViewModeChange:P,showViewToggle:E}),s.isLoading?a.jsx($n,{rows:5,columns:ee.length}):a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[R&&a.jsx(To,{columns:r,groupByColumns:J.groupByColumns,addGroupByColumn:J.addGroupByColumn,removeGroupByColumn:J.removeGroupByColumn,reorderGroupByColumns:J.reorderGroupByColumns}),a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs(Rn,{className:"table-fixed w-full",children:[a.jsxs("colgroup",{children:[L&&a.jsx("col",{style:{width:"40px"}}),m&&a.jsx("col",{style:{width:"50px"}}),ne.map((e,t)=>a.jsx("col",{style:e.style},t)),!B&&a.jsx("col",{style:{width:"inline"===p?"auto":"50px",minWidth:"50px"}})]}),a.jsx(Ln,{children:a.jsxs(On,{children:[L&&a.jsx(Vn,{className:"w-[40px]"}),m&&a.jsx(Vn,{className:"w-[50px]",children:a.jsx(No,{checked:s.isAllSelected,onCheckedChange:s.selectAll})}),ee.map((e,t)=>{const r=D&&!1!==e.resizable,n=se===String(e.key),o=I?Z.getDragProps(t,String(e.key)):{},i=Z.dragFromIndex===t,l=Z.dragOverIndex===t&&Z.dragFromIndex!==t;return a.jsxs(Vn,{className:Kt(e.className,!1!==e.sortable&&"hover:bg-muted/50 cursor-pointer","relative transition-opacity",I&&Z.isDragging&&"cursor-grabbing",i&&"opacity-50",l&&"border-l-2 border-primary"),onClick:!1!==e.sortable?()=>s.handleSort(String(e.key)):void 0,...o,children:[a.jsxs("div",{className:"flex items-center "+(e.className?.includes("text-center")?"justify-center":""),children:[e.header,!1!==e.sortable&&(c=String(e.key),s.sortField!==c?null:"asc"===s.sortDirection?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}),r&&a.jsx(Yn,{direction:"horizontal",onMouseDown:a=>re(String(e.key),a),isDragging:n})]},String(e.key));var c}),!B&&a.jsx(Vn,{className:"w-[50px] text-center",children:ue||e.t("actions")})]})}),a.jsx(zn,{children:0===s.entities.length?a.jsx(On,{children:a.jsx(Bn,{colSpan:he,className:"h-32",children:a.jsx(Gn,{title:e.t("no_items_found_empty"),description:"Não há dados para exibir no momento.",variant:"search"})})}):pe?fe(me,he):s.entities.map(xe)})]})})]})]})};function Eo(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,a)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(a)}catch(t){return u(e)}},p=(e,a,t)=>{if(e.required&&(""===a||null==a||Array.isArray(a)&&0===a.length))return`${e.label} é obrigatório`;if(e.validation){let r;if("function"==typeof e.validation?r=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(r=e.validation.custom),r)try{const e=r(a,t);if(e)return e}catch(s){}}};t.useEffect(()=>{if(!r)return;const e=a=>{const t=[];return a.forEach(a=>{t.push(a),a.fields&&t.push(...e(a.fields))}),t},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 a=m(e,n);void 0!==a&&(n[e.name]=a)}),a&&Object.keys(a).forEach(e=>{t.find(a=>a.name===e)||void 0===a[e]||(n[e]=a[e])}),o(n),l({}),s&&s(n)},[d,a,s,r]);const h=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...h(e.fields))}),a},x=()=>{const e=h(d),a={};return e.forEach(e=>{const t=p(e,n[e.name],n);t&&(a[e.name]=t)}),l(a),0===Object.keys(a).length};return{formData:n,errors:i,updateField:(e,a)=>{o(t=>{const r={...t,[e]:a},n=((e,a)=>{let t={...a};const s=e=>{const a=[];return e.forEach(e=>{a.push(e),e.fields&&a.push(...s(e.fields))}),a};return s(d).filter(a=>a.dependsOn===e).forEach(e=>{const a=m(e,t);void 0!==a&&(t={...t,[e.name]:a})}),t})(e,r);return s&&s(n),n}),i[e]&&l(a=>{const t={...a};return delete t[e],t});const t=h(d).find(a=>a.name===e);if(t){const s=p(t,a,n);s&&l(a=>({...a,[e]:s}))}},validateForm:x,handleSubmit:e=>a=>{a&&(a.preventDefault(),a.stopPropagation()),x()&&e(n)}}}const Do=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ao=({value:e="#3b82f6",onChange:t,label:s,customColorLabel:r,presetColorsLabel:n})=>{const{t:o}=y.useTranslation(),i=r??o("custom_color"),l=n??o("preset_colors");return a.jsxs("div",{className:"space-y-2",children:[s&&a.jsx(as,{children:s}),a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[a.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),a.jsx(Sr,{className:"w-64",children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx(as,{htmlFor:"color-input",children:i}),a.jsx(Zt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),a.jsxs("div",{children:[a.jsx(as,{children:l}),a.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Do.map(e=>a.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]})},Io=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(xe.Root,{ref:r,className:Kt("relative overflow-hidden",e),...s,children:[a.jsx(xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(Mo,{}),a.jsx(xe.Corner,{})]}));Io.displayName=xe.Root.displayName;const Mo=ae.forwardRef(({className:e,orientation:t="vertical",...s},r)=>a.jsx(xe.ScrollAreaScrollbar,{ref:r,orientation:t,className:Kt("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...s,children:a.jsx(xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Mo.displayName=xe.ScrollAreaScrollbar.displayName;const Fo=[{name:"alarm",filled:!1},{name:"account_box",filled:!0},{name:"announcement",filled:!0},{name:"assessment",filled:!0},{name:"assignment",filled:!0},{name:"bookmark",filled:!0},{name:"build",filled:!0},{name:"change_history",filled:!1},{name:"credit_card",filled:!1},{name:"date_range",filled:!0},{name:"extension",filled:!0},{name:"face",filled:!0},{name:"favorite",filled:!0},{name:"store",filled:!0},{name:"group_work",filled:!0},{name:"home",filled:!0},{name:"label",filled:!0},{name:"lightbulb_2",filled:!1},{name:"list",filled:!0},{name:"line_weight",filled:!0},{name:"question_answer",filled:!0},{name:"mode_heat",filled:!0},{name:"reorder",filled:!0},{name:"warning",filled:!0},{name:"room",filled:!0},{name:"settings",filled:!0},{name:"shopping_cart",filled:!0},{name:"work",filled:!0},{name:"star_rate",filled:!0},{name:"monetization_on",filled:!0},{name:"view_list",filled:!0},{name:"visibility",filled:!0},{name:"error",filled:!0},{name:"equalizer",filled:!0},{name:"release_alert",filled:!0},{name:"mic",filled:!0},{name:"videocam",filled:!0},{name:"call",filled:!0},{name:"chat",filled:!0},{name:"chat_bubble",filled:!0},{name:"email",filled:!0},{name:"link",filled:!0},{name:"report",filled:!0},{name:"flag",filled:!0},{name:"attach_file",filled:!0},{name:"attachment",filled:!0},{name:"attach_money",filled:!0},{name:"bubble_chart",filled:!0},{name:"folder",filled:!0},{name:"business",filled:!0},{name:"device_hub",filled:!0},{name:"flash_on",filled:!0},{name:"image",filled:!0},{name:"lens",filled:!0},{name:"photo_camera",filled:!0},{name:"style",filled:!0},{name:"view_compact",filled:!0},{name:"wb_incandescent",filled:!0},{name:"directions_bus",filled:!0},{name:"directions_car",filled:!0},{name:"flight",filled:!0},{name:"hotel",filled:!0},{name:"local_offer",filled:!0},{name:"restaurant",filled:!0},{name:"restaurant_menu",filled:!0},{name:"local_shipping",filled:!0},{name:"all_inclusive",filled:!0},{name:"business_center",filled:!0},{name:"notifications",filled:!0},{name:"share",filled:!0}];function Ro({name:e,filled:t,className:s}){return a.jsx("span",{className:`material-symbols-outlined ${s??""}`,style:t?{fontVariationSettings:"'FILL' 1"}:void 0,children:e})}const Lo=({value:e=null,onChange:s,label:r,noIconLabel:n="SEM ÍCONE"})=>{const[o,i]=t.useState(!1),l=e?(c=e,Fo.find(e=>e.name===c)):null;var c;const u=e=>{s?.(e),i(!1)};return a.jsxs("div",{className:"space-y-2",children:[r&&a.jsx(as,{children:r}),a.jsxs(Cr,{open:o,onOpenChange:i,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"justify-start text-left font-normal gap-2",children:[l?a.jsx(Ro,{name:l.name,filled:l.filled,className:"text-xl text-muted-foreground"}):a.jsx("span",{className:"text-muted-foreground text-sm",children:n}),a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 opacity-50"})]})}),a.jsx(Sr,{className:"w-72 p-3",align:"start",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Io,{className:"h-64",children:a.jsx("div",{className:"grid grid-cols-7 gap-1",children:Fo.map(t=>a.jsx("button",{type:"button",className:"flex items-center justify-center p-1.5 rounded hover:bg-accent transition-colors "+(e===t.name?"bg-primary/10 text-primary":"text-muted-foreground"),onClick:()=>u(t.name),title:t.name,children:a.jsx(Ro,{name:t.name,filled:t.filled,className:"text-2xl"})},t.name))})}),a.jsx("button",{type:"button",className:"w-full py-2 text-sm font-semibold text-foreground hover:bg-accent rounded transition-colors border-t pt-3",onClick:()=>u(null),children:n})]})})]})]})},zo=ae.forwardRef(({className:e,...t},s)=>a.jsx(fe.Root,{className:Kt("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",e),...t,ref:s,children:a.jsx(fe.Thumb,{className:Kt("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")})}));zo.displayName=fe.Root.displayName;const Uo=(e={})=>{const{user:a,alias:t}=An(),{enabled:s=!0,status:r="active"}=e;return w.useQuery({queryKey:["qualiex-users",t,r],queryFn:()=>xn.getUsers(t,r),enabled:s&&!!t&&!!a,staleTime:3e5,retry:2,retryDelay:1e3})},Oo=({value:s,onChange:r,multiple:n=!1,label:o,required:i,placeholder:l,icon:d,maxDisplayedBadges:c,className:u,disabled:m,enabled:p,displayFormat:h="name",customDisplayFn:x,filterFn:f,sortOptions:g=!0,popoverContainer:v,onOpen:b,onClose:j})=>{const{t:w}=y.useTranslation(),{data:N=[],isLoading:_,error:C}=Uo({enabled:p}),[k,S]=t.useState(new Map),T=t.useMemo(()=>s?Array.isArray(s)?s.filter(Boolean):[s].filter(Boolean):[],[s]),P=t.useMemo(()=>{if(0===T.length||0===N.length)return"";const e=new Set(N.map(e=>e.userId||e.id||""));return T.filter(a=>a&&!e.has(a)&&!k.has(a)).sort().join(",")},[T,N,k]);t.useEffect(()=>{if(!P)return;const e=P.split(",");let a=!1;const t=an.extractTokenData();return t?.alias&&t?.companyId?(xn.fetchUsers(t.alias,t.companyId,"all").then(t=>{a||S(a=>{const s=new Map(a);for(const r of e){const e=t.find(e=>e.userId===r||e.id===r);e&&s.set(r,{...e,isActive:e.isActive??!1})}return s})}).catch(()=>{}),()=>{a=!0}):void 0},[P]);const E=t.useMemo(()=>f?N.filter(f):N,[N,f]),D=t.useMemo(()=>{if(0===T.length)return E;const a=new Set(E.map(e=>e.userId||e.id||"")),t=T.filter(e=>e&&!a.has(e));if(0===t.length)return E;const s=t.map(a=>{const t=k.get(a);return t||{userId:a,id:a,userName:e.t("inactive_user"),userEmail:"",isActive:!1}});return[...E,...s]},[E,T,k]),A=t.useCallback(a=>{let t;if("custom"===h&&x)t=x(a);else{const e=a.userName||"";switch(h){case"name-email":t=a.userEmail?`${e} (${a.userEmail})`:e;break;case"name-role":t=a.roleName?`${e} - ${a.roleName}`:e;break;default:t=e}}return!1===a.isActive?`${t} (${e.t("inactive")})`:t},[h,x]);return a.jsx(Ur,{multiple:n,value:s??(n?[]:""),onChange:r,options:D,isLoading:_,error:C,getOptionValue:e=>e.userId||e.id||"",getOptionLabel:A,placeholder:l||"Pesquisar...",searchPlaceholder:"Pesquisar...",emptyMessage:w("no_results"),label:o,required:i,icon:d,maxDisplayedBadges:c,disabled:m,className:u,sortOptions:g,popoverContainer:v,onOpen:b,onClose:j})};function Vo({title:e,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,x]=t.useState(null),f=t.useCallback(e=>{p.current=e,x(e)},[]),g=t.useMemo(()=>s&&Array.isArray(s)?s.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[s]),{formData:v,errors:b,updateField:y,handleSubmit:j}=Eo(g,r,void 0,i),w=t.useMemo(()=>s&&Array.isArray(s)?s.map(e=>({...e,disabled:e.condition?!e.condition(v):e.disabled||!1})):[],[s,v]),N=t.useMemo(()=>{const e=w.find(e=>e.id===u);if(e&&!e.disabled)return u;const a=w.find(e=>!e.disabled);return a?.id||u},[w,u]);t.useEffect(()=>{N!==u&&m(N)},[N,u]);const _=w.find(e=>e.id===N),C=e=>{const t=(e.computedValue,v[e.name]),s=void 0!==t?t:"",r=b[e.name];switch(e.type){case"group":const t="horizontal"===e.layout,n=t?`flex gap-3 w-full ${e.className||""}`:"space-y-3",o=t?Kt("space-y-2 w-full",e.wrapperClassName):Kt("space-y-2",e.className,e.wrapperClassName);return a.jsxs("div",{className:o,children:[e.label,a.jsx("div",{className:n,children:e.fields?.map(e=>C(e))})]},e.name);case"user-select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Oo,{value:s||"",onChange:a=>y(e.name,a),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-destructive":""}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"textarea":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Js,{id:e.name,value:s||"",onChange:a=>{y(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,rows:e.rows,maxLength:e.maxLength,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"select":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsxs(Vs,{value:String(s),onValueChange:a=>{y(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,children:[a.jsx($s,{className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options?.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"multiselect":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Ur,{options:e.options||[],value:Array.isArray(s)?s:[],onChange:a=>y(e.name,a),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:h,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"date":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"date",value:String(s),onChange:a=>y(e.name,a.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Kt("w-full",r?"border-destructive":"",e.disabled?"bg-muted cursor-not-allowed":"")}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"color":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"color",value:s||e.defaultValue||"#000000",onChange:a=>y(e.name,a.target.value),className:"h-10"}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Ao,{value:s||e.defaultValue||"#3b82f6",onChange:a=>y(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return a.jsxs("div",{children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Lo,{value:s||e.defaultValue||null,onChange:a=>y(e.name,a)}),r&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const i=e.component,l="function"==typeof e.componentProps?e.componentProps(v):e.componentProps||{};return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(i,{value:s,onChange:a=>{y(e.name,a),e.onValueChange&&e.onValueChange(a)},disabled:e.disabled,error:r,popoverContainer:h,...l}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"number":return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"number",value:null!=s?String(s):"",onChange:a=>{const t=a.target.value,s=""===t?null:Number(t);y(e.name,s)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"checkbox":return a.jsxs("div",{className:`flex items-center space-x-2 ${e.className||""}`,children:[a.jsx(Xs,{id:e.name,checked:!!s,onCheckedChange:a=>y(e.name,a),disabled:e.disabled}),a.jsxs(as,{htmlFor:e.name,className:"cursor-pointer",children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name);case"switch":return a.jsxs("div",{className:`flex items-center justify-between space-x-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(zo,{id:e.name,checked:!!s,onCheckedChange:a=>y(e.name,a),disabled:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive mt-2",children:r})]},e.name);default:return a.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[a.jsxs(as,{htmlFor:e.name,children:[e.label,e.required&&a.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.jsx(Zt,{id:e.name,type:"text",value:s||"",onChange:a=>{y(e.name,a.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-destructive":""} ${e.disabled?"bg-muted cursor-not-allowed":""}`,readOnly:e.disabled}),r&&a.jsx("p",{className:"text-sm text-destructive",children:r})]},e.name)}},k=t.useCallback(()=>{if(!_)return null;if(_.disabled)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:a.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),a.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Complete as informações obrigatórias na seção i18n.t('ap_general_info') para acessar esta seção."})]});if(_.component){const e=_.component;return a.jsx(e,{formData:v,updateField:y,errors:b,users:c,disabled:_.disabled})}return a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.fields.map(C)})},[_,v,y,b,c,C]),S=a.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[w.length>1&&a.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:a.jsx("div",{className:"flex space-x-2",children:w.map(e=>a.jsx(Xt,{variant:N===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const a=w.find(a=>a.id===e);a&&!a.disabled&&m(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 py-4",children:d?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Carregando..."})}):a.jsxs("form",{onSubmit:j(n),className:"space-y-3 md:space-y-4",children:[k(),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Xt,{type:"button",variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{type:"submit",disabled:d,children:l||"Salvar"})]})]})})]});return a.jsx(ys,{open:i,onOpenChange:e=>{!1===e&&!0===i&&o()},children:a.jsxs(ks,{ref:f,variant:"form",className:"max-w-4xl max-h-[90vh] overflow-visible",children:[a.jsxs(Ss,{showSeparator:!0,children:[a.jsx(Es,{children:e}),a.jsx(Ds,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function Bo({currentPage:e,totalPages:t,totalItems:s,itemsPerPage:r,onPageChange:n,onItemsPerPageChange:o,variant:i="full"}){const{t:l}=y.useTranslation();if(0===s)return null;const c=(e-1)*r+1,u=Math.min(e*r,s);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:l("rows_per_page","Linhas por página")}),a.jsxs(Vs,{value:String(r),onValueChange:e=>o(Number(e)),children:[a.jsx($s,{className:"h-8 w-[70px]",children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"10",children:"10"}),a.jsx(Ys,{value:"25",children:"25"}),a.jsx(Ys,{value:"50",children:"50"}),a.jsx(Ys,{value:"100",children:"100"})]})]})]})}),a.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[c,"-",u," ",l("of","de")," ",s," ",l("items","itens")]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsLeft,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronLeft,{size:16})}),a.jsxs("div",{className:"flex items-center gap-1 px-2",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-sm text-muted-foreground",children:l("of","de")}),a.jsx("span",{className:"text-sm font-medium",children:t})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronRight,{size:16})}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>n(t),disabled:e===t,className:"h-8 w-8 p-0",children:a.jsx(d.ChevronsRight,{size:16})})]})]})}function qo({manager:e}){return a.jsx(Bo,{currentPage:e.pagination.currentPage,totalPages:e.pagination.totalPages,totalItems:e.pagination.totalItems,itemsPerPage:e.pagination.itemsPerPage,onPageChange:e.handlePageChange,onItemsPerPageChange:e.handleItemsPerPageChange,variant:"full"})}const $o={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Wo={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Ho={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function Go({children:e,direction:t="column",gap:s="md",align:r="stretch",justify:n="start",wrap:o=!1,className:i}){return a.jsx("div",{className:Kt("flex","column"===t?"flex-col":"flex-row",$o[s],Wo[r],Ho[n],o&&"flex-wrap",i),children:e})}function Ko({manager:e,filters:t,inline:s=!1}){const{t:r}=y.useTranslation(),{isSearchVisible:n}=An(),o=e.searchTerm,i=a.jsxs(a.Fragment,{children:[t.some(e=>"search"===e.type)&&!n&&a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:e.searchTerm,onChange:a=>e.handleSearch(a.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>a.jsxs(Vs,{value:e.value||"",onValueChange:a=>e.onChange?.(a),children:[a.jsx($s,{className:"w-[180px]",children:a.jsx(qs,{placeholder:e.placeholder})}),a.jsx(Gs,{children:e.options.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return a.jsx("div",{className:s?"":"w-full sm:w-auto",children:a.jsx(r,{...e.props})},`custom-${t}`)}),o&&a.jsxs(Xt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[a.jsx(d.X,{className:"h-4 w-4 mr-2"}),"Limpar"]})]});return s?a.jsx("div",{className:"flex items-center gap-2",children:i}):a.jsx(Go,{direction:"column",gap:"md",className:"mb-6",children:a.jsx(Go,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:i})})}function Yo({manager:e,config:s,formSections:r,onSave:n,onToggleStatus:o,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=An(),[d,c]=N.useSearchParams(),[u,m]=t.useState(!1),[p,h]=t.useState(null),[x,f]=t.useState({isOpen:!1,entityId:null,entityName:""}),[g,v]=t.useState({isOpen:!1,count:0});t.useEffect(()=>(l(!0),()=>{l(!1)}),[l]),t.useEffect(()=>{if(i&&e){const a=`${e.queryKey}_sortField`,t=`${e.queryKey}_sortDirection`;if(!d.has(a)&&!d.has(t)){const e=Object.fromEntries(d);e[a]=i.column,e[t]=i.direction,c(e)}}},[]);const b=r.length>0?e=>{s.onEdit?s.onEdit(e):(h(e),m(!0))}:void 0,y="function"==typeof e?.deleteEntity?e=>{f({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})}:void 0,j=()=>{f({isOpen:!1,entityId:null,entityName:""})},w=void 0!==s.hideNewButton?!s.hideNewButton:s.showNewButton??!0,_=(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 a.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[(s.showActionBar??!0)&&a.jsx(wo,{onNew:()=>{s.onNew?s.onNew():(h(null),m(!0))},newButtonLabel:s.newButtonLabel,showNewButton:w,showSearch:s.showSearch,searchValue:e.searchTerm,onSearchChange:e.handleSearch,searchPlaceholder:s.searchPlaceholder,showBulkActions:s.enableBulkActions,selectedCount:e.selectedIds.length,bulkActions:s.bulkActions,onBulkDelete:()=>{v({isOpen:!0,count:e.selectedIds.length})},onClearSelection:e.clearSelection,customActions:_,filters:s.filters&&s.filters.length>0?a.jsx(Ko,{manager:e,filters:s.filters,inline:!0}):void 0}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:s.customListView?a.jsx("div",{className:"flex-1 overflow-auto p-4",children:s.customListView(e.entities,e)}):a.jsx(Po,{manager:e,columns:s.columns,onEdit:b,onDelete:y,onToggleStatus:o,enableBulkActions:s.enableBulkActions,customRowActions:s.customRowActions,enableColumnManager:!0,columnManagerStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-columns`,resizeStorageKey:`crud-${s.entityName.toLowerCase().replace(/\s+/g,"-")}-resize`,defaultHiddenColumns:s.defaultHiddenColumns})}),a.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:a.jsx(qo,{manager:e})}),!s.useCustomRouting&&!s.onNew&&r.length>0&&a.jsx(Vo,{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:e.isLoading,submitButtonText:p?"Atualizar":"Criar"}),a.jsx(ys,{open:x.isOpen,onOpenChange:j,children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Es,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:x.entityName}),". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:j,children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{x.entityId&&"function"==typeof e?.deleteEntity&&(e.deleteEntity(x.entityId),f({isOpen:!1,entityId:null,entityName:""}))},disabled:e.isDeleting,children:e.isDeleting?"Excluindo...":"Sim, excluir"})]})]})}),a.jsx(ys,{open:g.isOpen,onOpenChange:()=>v({isOpen:!1,count:0}),children:a.jsxs(ks,{size:"sm",variant:"destructive",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Es,{children:"Você tem certeza absoluta?"})}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Você está prestes a excluir ",a.jsx("strong",{children:g.count})," ",1===g.count?s.entityName:s.entityNamePlural,". Esta ação não pode ser desfeita."]})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>v({isOpen:!1,count:0}),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:()=>{e.bulkDelete?.(e.selectedIds),v({isOpen:!1,count:0})},disabled:e.isBulkDeleting,children:e.isBulkDeleting?"Excluindo...":"Sim, excluir"})]})]})})]})}function Qo(e,a){const t=e.toLowerCase();return t.includes("email")?{type:"email",required:!0}:t.includes("phone")||t.includes("tel")?{type:"tel"}:t.includes("description")||t.includes("content")||t.includes("notes")?{type:"textarea"}:t.includes("status")||t.includes("type")||t.includes("category")?{type:"select",options:[]}:"boolean"==typeof a?{type:"boolean"}:"number"==typeof a?{type:"number"}:a instanceof Date?{type:"date"}:{type:"text"}}function Xo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Jo(e={}){const{paramName:a="alias"}=e,s=N.useParams(),{alias:r,companies:n}=An(),o=s[a]||null;return t.useMemo(()=>{if(!o)return{urlAlias:null,isAliasMismatch:!1,isValidAlias:!1,isMissing:!0,matchedCompany:null};const e=n?.find(e=>e.alias===o)||null,a=!!e;return{urlAlias:o,isAliasMismatch:a&&o!==r,isValidAlias:a,isMissing:!1,matchedCompany:e}},[o,r,n])}const Zo=r.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"}}),ei={info:d.Info,warning:d.Info,danger:d.AlertTriangle,success:d.CheckCircle},ai=ae.forwardRef(({className:e,variant:t="info",showIcon:s=!0,children:r,...n},o)=>{const i=ei[t||"info"];return a.jsxs("div",{ref:o,role:"alert",className:Kt(Zo({variant:t}),e),...n,children:[s&&a.jsx(i,{className:"h-4 w-4"}),r]})});ai.displayName="Alert";const ti=ae.forwardRef(({className:e,...t},s)=>a.jsx("h5",{ref:s,className:Kt("mb-1 font-medium leading-none tracking-tight",e),...t}));ti.displayName="AlertTitle";const si=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("text-sm [&_p]:leading-relaxed",e),...t}));si.displayName="AlertDescription";const ri=t.createContext(void 0);function ni({children:e,actions:s}){const{t:r}=y.useTranslation(),[n,o]=t.useState({}),[i,l]=t.useState(s);t.useEffect(()=>{l(s)},[s]);const d=t.useCallback(()=>o({}),[]),c=t.useMemo(()=>({metadata:n,setMetadata:o,clearMetadata:d,headerActions:i,setHeaderActions:l}),[n,d,i]);return a.jsx(ri.Provider,{value:c,children:e})}function oi(){const e=t.useContext(ri);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}var ii={actions:"Ações",activate:"Ativar",add_first_item:"Adicione seu primeiro item para começar",add_item:"Adicionar Item",advanced_filter:"Filtro avançado",all:"Todos",allow:"Permitir",allowed_items:"Itens permitidos",also_discover:"Conheça também",alt_text:"Texto Alternativo",anonymous:"Anônimo",ap_action_plan:"Plano de Ação",ap_action_type:"Tipo de Ação",ap_add:"Adicionar",ap_add_comment_placeholder:"Adicionar comentário...",ap_add_cost:"Adicionar custo",ap_add_predecessor:"Adicionar predecessor",ap_attachments:"Anexos",ap_belongs_to:"Pertence a",ap_cause:"Causa",ap_change_status:"Alterar Status",ap_checker:"Verificador",ap_clear:"Limpar",ap_comments:"Comentários",ap_cost_description:"Descrição do custo",ap_costs:"Custos",ap_delete:"Excluir",ap_description:"Descrição",ap_description_placeholder:"Descreva o plano de ação",ap_duration_days:"Duração (dias)",ap_edit_progress:"Editar Progresso",ap_end_date:"Data de Término",ap_estimated_cost:"Custo Estimado",ap_file_duplicate:"Arquivo duplicado",ap_file_upload_error:"Erro ao enviar arquivo",ap_general:"Geral",ap_general_info:"Informações Gerais",ap_history:"Histórico",ap_justification:"Justificativa",ap_justification_placeholder:"Justificativa do plano de ação",ap_name:"Nome",ap_new_action:"Nova Ação",ap_no_attachments:"Nenhum anexo",ap_no_comments:"Nenhum comentário",ap_no_costs:"Nenhum custo registrado",ap_no_history:"Nenhum registro no histórico",ap_no_predecessors:"Nenhum predecessor adicionado",ap_no_progress:"Sem dados de progresso disponíveis",ap_overall_progress:"Progresso geral",ap_place:"Local",ap_plan_name_placeholder:"Nome do plano de ação",ap_predecessors:"Predecessores",ap_priority:"Prioridade",ap_priority_high:"Alta",ap_priority_low:"Baixa",ap_priority_medium:"Média",ap_progress:"Progresso",ap_progress_comment_placeholder:"Adicione um comentário sobre o progresso",ap_progress_percent:"Progresso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progresso",ap_reporting:"Reportando...",ap_reports_history:"Histórico de reportes",ap_responsible:"Responsável",ap_select_action:"Selecione uma ação",ap_select_cause:"Selecione a causa",ap_select_checker:"Selecione o verificador",ap_select_date:"Selecione a data",ap_select_parent:"Selecione a ação pai",ap_select_place:"Selecione o local",ap_select_priority:"Selecione a prioridade",ap_select_responsible:"Selecione o responsável",ap_select_type:"Selecione o tipo",ap_start_date:"Data de Início",ap_status_canceled:"Cancelada",ap_status_done:"Concluída",ap_status_effectiveness_check:"Verificação de eficácia",ap_status_running:"Em andamento",ap_status_suspended:"Suspensa",ap_status_waiting_start:"Aguardando início",ap_time_label:"Tempo",ap_time_spent:"Tempo gasto (HH:MM)",ap_total_cost:"Custo total realizado",ap_total_time:"Tempo total",ap_type_corrective:"Corretiva",ap_type_immediate:"Imediata",ap_type_improvement:"Oportunidade de Melhoria",ap_type_preventive:"Preventiva",ap_type_standardization:"Padronização",ap_value:"Valor (R$)",ap_via_app:"Via app",approval_approve:"Aprovar",approval_execute_action:"Executar ação",approval_opinion:"Parecer *",approval_read_less:"Ler menos",approval_read_more:"Ler mais",approval_reprove_radio:"Reprovar e retornar para etapa",approval_search_approver:"Buscar aprovador...",approval_select_approver:"Selecionar aprovador",approval_select_approver_placeholder:"Selecione um aprovador...",approval_select_step:"Selecione a etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuários",audit_description:"Descrição",audit_esign:"Assinatura eletrônica",audit_not_informed:"Não informado",audit_references:"Referências",audit_security:"Segurança",audit_trail:"Trilha de Auditoria",auth_error:"Erro durante a autenticação. Tente novamente.",auth_failed:"Falha na autenticação. Tente novamente.",auto_login:"Fazendo login automático...",back:"Voltar",bulk_delete_error:"Erro ao excluir itens em lote",bulk_delete_success:"Itens excluídos com sucesso",cancel:"Cancelar",change_photo:"Trocar foto",cannot_be_own_leader:"Um líder não pode ser seu próprio superior",clear_filters:"Limpar filtros",clear_formatting:"Limpar Formatação",clear_search:"Limpar busca",clear_selection:"Limpar seleção",close:"Fechar",collapse_row:"Recolher linha",columns:"Colunas",conclude:"Concluir",confirm_removal:"Confirmar remoção",could_not_load_info:"Não foi possível carregar as informações",current:"Atual",custom_color:"Cor personalizada",dashboard_advanced_filter:"Filtro avançado",dashboard_all_access:"Todos os colaboradores terão acesso",dashboard_average:"Média",dashboard_code:"Código",dashboard_distinct_count:"Contagem distinta",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Sair do fullscreen",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabela",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Meus dashboards",dashboard_new:"Novo Dashboard",dashboard_no_data:"A consulta não retornou itens para o seu perfil.",dashboard_no_refresh:"Não atualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"Não compartilhado",dashboard_only_mine:"Somente meus",dashboard_only_overdue:"Somente atrasados",dashboard_only_responsible:"Somente o responsável terá acesso",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remover favorito",dashboard_responsible:"Responsável",dashboard_select_groups:"Selecione grupos, locais e colaboradores específicos",dashboard_shared_unit:"Compartilhado com todos os colaboradores da unidade",dashboard_status:"Situação",dashboard_title:"Título",dashboard_wait_refresh:"Aguarde para atualizar novamente",dashboard_work_done:"Trabalho executado",dashboard_work_planned:"Trabalho planejado",deactivate:"Inativar",deselect_all:"Deselecionar todas",dev_login:"Login Desenvolvimento",download:"Download",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nome",electronic_signature:"Assinatura Eletrônica",embed_code:"Código embed",embedded_content:"Embedded content",enter_code:"Digite o código",enter_password:"Digite sua senha",error_authentication:"Erro de Autenticação",error_connection:"Erro de Conexão",error_copied_clipboard:"Os detalhes do erro foram copiados para a área de transferência.",error_loading:"Erro ao carregar",error_loading_data:"Erro ao carregar dados",error_session_expired:"Sessão Expirada",error_token_expired:"Token de autenticação expirado. Faça login novamente.",esign_code_description:"Um código de verificação foi enviado para o seu e-mail. Insira o código abaixo para confirmar a operação.",esign_code_error:"Erro ao validar o código. Tente novamente.",esign_invalid_code:"Código inválido. Tente novamente.",esign_invalid_password:"Senha incorreta. Tente novamente.",esign_password_description:"Digite sua senha para confirmar a operação.",esign_password_error:"Erro ao validar a senha. Tente novamente.",esign_resend_error:"Erro ao reenviar o código.",expand_row:"Expandir linha",expiration_date:"Data de expiração",file_error:"Erro no arquivo",file_upload:"Upload de arquivo",go_to_next_page:"Ir para próxima página",go_to_previous_page:"Ir para página anterior",group_by_column:"Agrupar por esta coluna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descrição da imagem",import_flows:"Fluxos de Importação",import_manage:"Gerencie seus fluxos de importação",inactive:"inativo",inactive_user:"[Usuário inativo]",input_type:"Tipo de entrada",invalid_form:"Formulário inválido. Preencha todos os campos obrigatórios.",italic:"Itálico",item_details:"Detalhes do item",items:"itens",items_per_page:"Itens por página",know_saber_gestao:"Conheça o Saber Gestão",know_staff:"Conheça Staff",language:"Idioma",last_update:"Última atualização",leader:"Líder",leader_create_error:"Erro ao criar líder",leader_not_found:"Líder não encontrado",leader_promoted_success:"Líder promovido com sucesso",leader_remove_error:"Erro ao remover líder",leader_removed_success:"Líder removido com sucesso",leader_update_error:"Erro ao atualizar líder",leader_updated_success:"Líder atualizado com sucesso",leadership_add_root:"Adicionar Líder Raiz",leadership_add_subordinate:"Adicionar Liderado",leadership_cycle_error:"Esta associação criaria um ciclo na hierarquia",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Imediato",leadership_make_root:"Tornar Líder Raiz",leadership_make_root_short:"Tornar Raiz",leadership_no_hierarchy:"Nenhuma hierarquia de liderança encontrada.",leadership_no_members:"Nenhum membro na equipe",leadership_no_user_selected:"Nenhum usuário selecionado",leadership_no_users_available:"Nenhum usuário disponível",leadership_no_users_found:"Nenhum usuário encontrado",leadership_remove_team:"Remover da equipe",leadership_select_subordinates:"Selecione pelo menos um liderado",learn_qualiex:"Aprenda a usar o Qualiex",leave_without_saving:"Sair sem salvar",lines_per_page:"Linhas por página",link:"Link",login_with_qualiex:"Entrar com Qualiex",manage_access:"Gerenciar Acessos",mind_map_add_child:"Adicionar filho",mind_map_add_sibling:"Adicionar irmão",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar tudo",mind_map_delete_node:"Excluir nó",mind_map_expand_all:"Expandir tudo",mind_map_export_image:"Exportar como imagem",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar à tela",mind_map_redo:"Refazer",mind_map_undo:"Desfazer",mind_map_zoom_in:"Aproximar",mind_map_zoom_out:"Afastar",modules:"Módulos",more_options:"Mais opções",msg_create_error:"Erro ao criar registro",msg_created_success:"Registro criado com sucesso",msg_delete_error:"Erro ao excluir registro",msg_deleted_success:"Registro excluído com sucesso",msg_load_error:"Erro ao carregar dados",msg_update_error:"Erro ao atualizar registro",msg_updated_success:"Registro atualizado com sucesso",new_document:"Novo Documento",new_folder:"Nova Pasta",new_item:"Novo Item",next:"Próximo",no_access_page:"Parece que você não tem acesso a essa página",no_data_to_display:"Não há dados para exibir no momento.",no_errors_recorded:"Nenhum erro registrado",no_image_selected:"Nenhuma imagem selecionada",no_item_selected:"Nenhum item selecionado",no_items_found:"Nenhum item encontrado",no_items_found_empty:"Nenhum item encontrado",no_place_found:"Nenhum local encontrado",no_place_selected:"Sem local",no_products:"Sem produtos",no_reports_found:"Nenhum relatório encontrado",no_results:"Nenhum resultado encontrado",no_search_results:"Nenhum resultado para a busca",no_video_selected:"Nenhum vídeo selecionado",not_authenticated:"Não autenticado",not_available:"Não disponível",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Cole o código embed aqui",permissions:"Permissões",preset_colors:"Cores predefinidas",preview:"Visualizar",redirecting_auth:"Redirecionando para autenticação...",refresh_data:"Atualizar dados",remove:"Remover",remove_grouping:"Remover agrupamento",replace:"Substituir",report:"Relatório",request_date:"Data da solicitação",required_field:"Campo obrigatório",resend_code:"Reenviar código",restricted_access:"Acesso restrito",rows_per_page:"Registros por página",save:"Salvar",save_as_draft:"Salvar como Rascunho",save_as_template:"Salvar como Modelo",saving:"Salvando...",search:"Pesquisar",search_placeholder:"Pesquisar...",search_report_placeholder:"Buscar relatório...",search_user_placeholder:"Buscar usuário...",select_all:"Selecionar todos",select_all_columns:"Selecionar todas",select_all_items:"Selecionar todos",select_at_least_one:"Selecione pelo menos um item",select_at_least_one_item:"Selecione ao menos um item",select_date:"Selecione uma data",select_file_format:"Selecione o formato do arquivo",select_items_to_add:"Selecione itens para adicionar...",select_placeholder:"Selecione...",selected:"Selecionados",session_expired:"Sua sessão expirou. Você será redirecionado para fazer login novamente.",sign_access_error:"Erro ao acessar serviço de assinatura",sign_api_key_info:"Informe a API Key do provedor de assinatura",sign_api_key_input:"Insira a API Key do provedor de assinatura",sign_api_key_placeholder:"Insira a chave de API",sign_api_key_required:"Chave de API obrigatória",sign_attempt:"Tentativa de assinatura",sign_auth_required:"Autenticação necessária para assinar",sign_click_to_select:"Clique para selecionar documento",sign_config_save_err:"Erro ao salvar configuração de assinatura",sign_config_save_error:"Erro ao salvar configuração de assinatura",sign_config_saved:"Configuração de assinatura salva",sign_config_saved_success:"Configuração de assinatura salva com sucesso",sign_configured:"Assinatura configurada",sign_configured_unit:"Assinatura digital configurada para esta unidade",sign_digital_config:"Configuração de Assinatura Digital",sign_doc_available:"Documento assinado disponível para download",sign_doc_load_error:"Erro ao carregar documento",sign_doc_process_error:"Erro ao processar documento",sign_doc_sent:"Documento enviado para assinatura",sign_download_signed:"Baixar documento assinado",sign_email_fallback:"E-mail de fallback para assinatura",sign_environment:"Ambiente de assinatura",sign_fetch_failed:"Falha ao buscar documento assinado",sign_file_not_allowed:"Extensão de arquivo não permitida",sign_file_type_not_allowed:"Tipo de arquivo não permitido",sign_incorrect_data:"O signatário reportou dados incorretos.",sign_login_required:"Login necessário para assinar",sign_login_to_sign:"Faça login para utilizar a assinatura digital.",sign_monthly_limit:"Limite mensal de assinaturas atingido",sign_no_access:"Não foi possível obter o acesso para assinatura. Tente novamente.",sign_not_configured:"Assinatura não configurada",sign_not_configured_unit:"Assinatura digital ainda não configurada para esta unidade",sign_preparing_doc:"Preparando documento para assinatura",sign_process_error:"Erro ao processar assinatura",sign_save_config:"Salvar configuração",sign_save_config_btn:"Salvar Configuração",sign_select_pdf:"Selecione um arquivo PDF",sign_sending_doc:"Enviando documento para assinatura",sign_signed_success:"Documento assinado com sucesso",sign_signer_unavailable:"Signer ID não disponível",sign_try_again:"Tentar novamente",sign_update_config:"Atualizar configuração",sign_update_config_btn:"Atualizar Configuração",sign_waiting_provider:"Aguardando provedor de assinatura",sign_widget_error:"Erro no widget de assinatura",something_went_wrong:"Algo deu errado",state:"Estado",status:"Status",status_completed:"Concluído",status_error:"Erro",status_expired:"Expirado",status_processing:"Processando",status_waiting:"Aguardando",steps:"Etapas",subordinates_add_error:"Erro ao adicionar subordinados",subordinates_added_success:"Subordinados adicionados com sucesso",subordinates_sync_error:"Erro ao sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados com sucesso",team_all_groups:"Todos os grupos",terms_confirm_reading:"Confirmar leitura",terms_confirmation_available:"Confirmação disponível em",terms_of_use:"Termos de Uso",terms_read_agree:"Li e concordo",terms_see_later:"Ver depois",terms_updated:"Termos de Uso Atualizados",terms_view:"Visualizar termo de uso",terms_view_short:"View term",try_adjust_search:"Tente ajustar sua busca",try_again:"Tentar Novamente",unit_not_selected:"Nenhuma unidade selecionada",unknown_error:"Erro desconhecido",unsaved_changes:"Alterações não salvas",unsaved_changes_description:"Existem alterações não salvas. Deseja sair sem salvar?",updates:"Atualizações",user:"Usuário",user_info:"Informações do Usuário",user_photo:"Foto do usuário",users_already_leaders:"Usuários já são líderes",verification_code:"Código de verificação",video:"Vídeo",video_title:"Título do vídeo",view_report:"Visualizar relatório",want_to_know_more:"Quero conhecer mais",write_content_here:"Escreva o conteúdo aqui..."},li={actions:"Actions",activate:"Activate",add_first_item:"Add your first item to get started",add_item:"Add Item",advanced_filter:"Advanced filter",all:"All",allow:"Allow",allowed_items:"Allowed items",also_discover:"Also discover",alt_text:"Alternative Text",anonymous:"Anonymous",ap_action_plan:"Action Plan",ap_action_type:"Action type",ap_add:"Add",ap_add_comment_placeholder:"Add a comment...",ap_add_cost:"Add cost",ap_add_predecessor:"Add predecessor",ap_attachments:"Attachments",ap_belongs_to:"Belongs to",ap_cause:"Cause",ap_change_status:"Change Status",ap_checker:"Checker",ap_clear:"Clear",ap_comments:"Comments",ap_cost_description:"Cost description",ap_costs:"Costs",ap_delete:"Delete",ap_description:"Description",ap_description_placeholder:"Describe the action plan",ap_duration_days:"Duration (days)",ap_edit_progress:"Edit Progress",ap_end_date:"End date",ap_estimated_cost:"Estimated cost",ap_file_duplicate:"Duplicate file",ap_file_upload_error:"Error uploading file",ap_general:"General",ap_general_info:"General Information",ap_history:"History",ap_justification:"Justification",ap_justification_placeholder:"Action plan justification",ap_name:"Name",ap_new_action:"New Action",ap_no_attachments:"No attachments",ap_no_comments:"No comments",ap_no_costs:"No costs recorded",ap_no_history:"No history records",ap_no_predecessors:"No predecessors added",ap_no_progress:"No progress data available",ap_overall_progress:"Overall progress",ap_place:"Place",ap_plan_name_placeholder:"Action plan name",ap_predecessors:"Predecessors",ap_priority:"Priority",ap_priority_high:"High",ap_priority_low:"Low",ap_priority_medium:"Medium",ap_progress:"Progress",ap_progress_comment_placeholder:"Add a comment about the progress",ap_progress_percent:"Progress (%)",ap_report:"Report",ap_report_progress:"Report progress",ap_reporting:"Reporting...",ap_reports_history:"Reports history",ap_responsible:"Responsible",ap_select_action:"Select an action",ap_select_cause:"Select cause",ap_select_checker:"Select checker",ap_select_date:"Select date",ap_select_parent:"Select parent action",ap_select_place:"Select place",ap_select_priority:"Select priority",ap_select_responsible:"Select responsible",ap_select_type:"Select type",ap_start_date:"Start date",ap_status_canceled:"Canceled",ap_status_done:"Completed",ap_status_effectiveness_check:"Effectiveness check",ap_status_running:"In progress",ap_status_suspended:"Suspended",ap_status_waiting_start:"Waiting to start",ap_time_label:"Time",ap_time_spent:"Time spent (HH:MM)",ap_total_cost:"Total realized cost",ap_total_time:"Total time",ap_type_corrective:"Corrective",ap_type_immediate:"Immediate",ap_type_improvement:"Improvement Opportunity",ap_type_preventive:"Preventive",ap_type_standardization:"Standardization",ap_value:"Value",ap_via_app:"Via app",approval_approve:"Approve",approval_execute_action:"Execute action",approval_opinion:"Opinion *",approval_read_less:"Read less",approval_read_more:"Read more",approval_reprove_radio:"Reject and return to step",approval_search_approver:"Search approver...",approval_select_approver:"Select approver",approval_select_approver_placeholder:"Select an approver...",approval_select_step:"Select the step",approval_step_label:"Step",approval_user_group:"User group",audit_description:"Description",audit_esign:"Electronic signature",audit_not_informed:"Not informed",audit_references:"References",audit_security:"Security",audit_trail:"Audit Trail",auth_error:"Error during authentication. Try again.",auth_failed:"Authentication failed. Try again.",auto_login:"Logging in automatically...",back:"Back",bulk_delete_error:"Error deleting items in bulk",bulk_delete_success:"Items deleted successfully",cancel:"Cancel",change_photo:"Change photo",cannot_be_own_leader:"A leader cannot be their own superior",clear_filters:"Clear filters",clear_formatting:"Clear Formatting",clear_search:"Clear search",clear_selection:"Clear selection",close:"Close",collapse_row:"Collapse row",columns:"Columns",conclude:"Finish",confirm_removal:"Confirm removal",could_not_load_info:"Could not load the information",current:"Current",custom_color:"Custom color",dashboard_advanced_filter:"Advanced filter",dashboard_all_access:"All collaborators will have access",dashboard_average:"Average",dashboard_code:"Code",dashboard_distinct_count:"Distinct count",dashboard_edit:"Edit Dashboard",dashboard_exit_fullscreen:"Exit fullscreen",dashboard_export_chart:"Export chart",dashboard_export_table:"Export table",dashboard_max_value:"Maximum value",dashboard_min_value:"Minimum value",dashboard_my:"My dashboards",dashboard_new:"New Dashboard",dashboard_no_data:"The query returned no items for your profile.",dashboard_no_refresh:"Do not refresh",dashboard_normal_page:"Normal page",dashboard_not_shared:"Not shared",dashboard_only_mine:"Only mine",dashboard_only_overdue:"Only overdue",dashboard_only_responsible:"Only the responsible will have access",dashboard_open_query:"Open query",dashboard_remove_favorite:"Remove favorite",dashboard_responsible:"Responsible",dashboard_select_groups:"Select groups, places and specific collaborators",dashboard_shared_unit:"Shared with all unit collaborators",dashboard_status:"Status",dashboard_title:"Title",dashboard_wait_refresh:"Wait to refresh again",dashboard_work_done:"Work done",dashboard_work_planned:"Work planned",deactivate:"Deactivate",deselect_all:"Deselect all",dev_login:"Development Login",download:"Download",edit:"Edit",edit_profile:"Edit Profile",edit_name:"Edit Name",electronic_signature:"Electronic Signature",embed_code:"Embed code",embedded_content:"Embedded content",enter_code:"Enter the code",enter_password:"Enter your password",error_authentication:"Authentication Error",error_connection:"Connection Error",error_copied_clipboard:"Error details were copied to the clipboard.",error_loading:"Error loading",error_loading_data:"Error loading data",error_session_expired:"Session Expired",error_token_expired:"Authentication token expired. Please log in again.",esign_code_description:"A verification code was sent to your email. Enter the code below to confirm the operation.",esign_code_error:"Error validating code. Try again.",esign_invalid_code:"Invalid code. Try again.",esign_invalid_password:"Incorrect password. Try again.",esign_password_description:"Enter your password to confirm the operation.",esign_password_error:"Error validating password. Try again.",esign_resend_error:"Error resending code.",expand_row:"Expand row",expiration_date:"Expiration date",file_error:"File error",file_upload:"File upload",go_to_next_page:"Go to next page",go_to_previous_page:"Go to previous page",group_by_column:"Group by this column",heading_1:"Heading 1",heading_2:"Heading 2",heading_3:"Heading 3",image_description:"Image description",import_flows:"Import Flows",import_manage:"Manage your import flows",inactive:"inactive",inactive_user:"[Inactive user]",input_type:"Input type",invalid_form:"Invalid form. Fill in all required fields.",italic:"Italic",item_details:"Item details",items:"items",items_per_page:"Items per page",know_saber_gestao:"Discover Saber Gestão",know_staff:"Discover Staff",language:"Language",last_update:"Last update",leader:"Leader",leader_create_error:"Error creating leader",leader_not_found:"Leader not found",leader_promoted_success:"Leader promoted successfully",leader_remove_error:"Error removing leader",leader_removed_success:"Leader removed successfully",leader_update_error:"Error updating leader",leader_updated_success:"Leader updated successfully",leadership_add_root:"Add Root Leader",leadership_add_subordinate:"Add Subordinate",leadership_cycle_error:"This association would create a cycle in the hierarchy",leadership_define_leader:"Define Leader",leadership_immediate_superior:"Immediate Superior",leadership_make_root:"Make Root Leader",leadership_make_root_short:"Make Root",leadership_no_hierarchy:"No leadership hierarchy found.",leadership_no_members:"No team members",leadership_no_user_selected:"No user selected",leadership_no_users_available:"No users available",leadership_no_users_found:"No users found",leadership_remove_team:"Remove from team",leadership_select_subordinates:"Select at least one subordinate",learn_qualiex:"Learn how to use Qualiex",leave_without_saving:"Leave without saving",lines_per_page:"Lines per page",link:"Link",login_with_qualiex:"Login with Qualiex",manage_access:"Manage Access",mind_map_add_child:"Add child",mind_map_add_sibling:"Add sibling",mind_map_aria_label:"Mind map",mind_map_collapse_all:"Collapse all",mind_map_delete_node:"Delete node",mind_map_expand_all:"Expand all",mind_map_export_image:"Export as image",mind_map_export_json:"Export as JSON",mind_map_fit_to_screen:"Fit to screen",mind_map_redo:"Redo",mind_map_undo:"Undo",mind_map_zoom_in:"Zoom in",mind_map_zoom_out:"Zoom out",modules:"Modules",more_options:"More options",msg_create_error:"Error creating record",msg_created_success:"Record created successfully",msg_delete_error:"Error deleting record",msg_deleted_success:"Record deleted successfully",msg_load_error:"Error loading data",msg_update_error:"Error updating record",msg_updated_success:"Record updated successfully",new_document:"New Document",new_folder:"New Folder",new_item:"New Item",next:"Next",no_access_page:"It seems you don't have access to this page",no_data_to_display:"No data to display at this time.",no_errors_recorded:"No errors recorded",no_image_selected:"No image selected",no_item_selected:"No item selected",no_items_found:"No items found",no_items_found_empty:"No items found",no_place_found:"No place found",no_place_selected:"No place",no_products:"No products",no_reports_found:"No reports found",no_results:"No results found",no_search_results:"No results for the search",no_video_selected:"No video selected",not_authenticated:"Not authenticated",not_available:"Not available",of:"of",open_popover:"Open Popover",open_wiki:"Open Wiki",ordered_list:"Ordered List",page:"Page",paste_embed_code:"Paste the embed code here",permissions:"Permissions",preset_colors:"Preset colors",preview:"Preview",redirecting_auth:"Redirecting to authentication...",refresh_data:"Refresh data",remove:"Remove",remove_grouping:"Remove grouping",replace:"Replace",report:"Report",request_date:"Request date",required_field:"Required field",resend_code:"Resend code",restricted_access:"Restricted access",rows_per_page:"Rows per page",save:"Save",save_as_draft:"Save as Draft",save_as_template:"Save as Template",saving:"Saving...",search:"Search",search_placeholder:"Search...",search_report_placeholder:"Search report...",search_user_placeholder:"Search user...",select_all:"Select all",select_all_columns:"Select all",select_all_items:"Select all",select_at_least_one:"Select at least one item",select_at_least_one_item:"Select at least one item",select_date:"Select a date",select_file_format:"Select the file format",select_items_to_add:"Select items to add...",select_placeholder:"Select...",selected:"Selected",session_expired:"Your session has expired. You will be redirected to log in again.",sign_access_error:"Error accessing signature service",sign_api_key_info:"Enter the signature provider API Key",sign_api_key_input:"Enter the signature provider API Key",sign_api_key_placeholder:"Enter API key",sign_api_key_required:"API key is required",sign_attempt:"Signature attempt",sign_auth_required:"Authentication required to sign",sign_click_to_select:"Click to select document",sign_config_save_err:"Error saving signature configuration",sign_config_save_error:"Error saving signature configuration",sign_config_saved:"Signature configuration saved",sign_config_saved_success:"Signature configuration saved successfully",sign_configured:"Signature configured",sign_configured_unit:"Digital signature configured for this unit",sign_digital_config:"Digital Signature Configuration",sign_doc_available:"Signed document available for download",sign_doc_load_error:"Error loading document",sign_doc_process_error:"Error processing document",sign_doc_sent:"Document sent for signature",sign_download_signed:"Download signed document",sign_email_fallback:"Signature fallback email",sign_environment:"Signature environment",sign_fetch_failed:"Failed to fetch signed document",sign_file_not_allowed:"File extension not allowed",sign_file_type_not_allowed:"File type not allowed",sign_incorrect_data:"The signer reported incorrect data.",sign_login_required:"Login required to sign",sign_login_to_sign:"Log in to use the digital signature.",sign_monthly_limit:"Monthly signature limit reached",sign_no_access:"Could not obtain access for signing. Try again.",sign_not_configured:"Signature not configured",sign_not_configured_unit:"Digital signature not yet configured for this unit",sign_preparing_doc:"Preparing document for signature",sign_process_error:"Error processing signature",sign_save_config:"Save configuration",sign_save_config_btn:"Save Configuration",sign_select_pdf:"Select a PDF file",sign_sending_doc:"Sending document for signature",sign_signed_success:"Document signed successfully",sign_signer_unavailable:"Signer ID not available",sign_try_again:"Try again",sign_update_config:"Update configuration",sign_update_config_btn:"Update Configuration",sign_waiting_provider:"Waiting for signature provider",sign_widget_error:"Signature widget error",something_went_wrong:"Something went wrong",state:"State",status:"Status",status_completed:"Completed",status_error:"Error",status_expired:"Expired",status_processing:"Processing",status_waiting:"Waiting",steps:"Steps",subordinates_add_error:"Error adding subordinates",subordinates_added_success:"Subordinates added successfully",subordinates_sync_error:"Error syncing subordinates",subordinates_synced_success:"Subordinates synced successfully",team_all_groups:"All groups",terms_confirm_reading:"Confirm reading",terms_confirmation_available:"Confirmation available at",terms_of_use:"Terms of Use",terms_read_agree:"I have read and agree",terms_see_later:"See later",terms_updated:"Terms of Use Updated",terms_view:"View terms of use",terms_view_short:"View term",try_adjust_search:"Try adjusting your search",try_again:"Try Again",unit_not_selected:"No unit selected",unknown_error:"Unknown error",unsaved_changes:"Unsaved changes",unsaved_changes_description:"There are unsaved changes. Do you want to leave without saving?",updates:"Updates",user:"User",user_info:"User Information",user_photo:"User photo",users_already_leaders:"Users are already leaders",verification_code:"Verification code",video:"Video",video_title:"Video title",view_report:"View report",want_to_know_more:"I want to know more",write_content_here:"Write content here..."},di={actions:"Acciones",activate:"Activar",add_first_item:"Agregue su primer elemento para comenzar",add_item:"Agregar Elemento",advanced_filter:"Filtro avanzado",all:"Todos",allow:"Permitir",allowed_items:"Elementos permitidos",also_discover:"Conozca también",alt_text:"Texto Alternativo",anonymous:"Anónimo",ap_action_plan:"Plan de Acción",ap_action_type:"Tipo de acción",ap_add:"Agregar",ap_add_comment_placeholder:"Agregar comentario...",ap_add_cost:"Agregar costo",ap_add_predecessor:"Agregar predecesor",ap_attachments:"Anexos",ap_belongs_to:"Pertenece a",ap_cause:"Causa",ap_change_status:"Cambiar Estado",ap_checker:"Verificador",ap_clear:"Limpiar",ap_comments:"Comentarios",ap_cost_description:"Descripción del costo",ap_costs:"Costos",ap_delete:"Eliminar",ap_description:"Descripción",ap_description_placeholder:"Describa el plan de acción",ap_duration_days:"Duración (días)",ap_edit_progress:"Editar Progreso",ap_end_date:"Fecha de finalización",ap_estimated_cost:"Costo estimado",ap_file_duplicate:"Archivo duplicado",ap_file_upload_error:"Error al subir archivo",ap_general:"General",ap_general_info:"Información General",ap_history:"Historial",ap_justification:"Justificación",ap_justification_placeholder:"Justificación del plan de acción",ap_name:"Nombre",ap_new_action:"Nueva Acción",ap_no_attachments:"Sin anexos",ap_no_comments:"Sin comentarios",ap_no_costs:"Ningún costo registrado",ap_no_history:"Sin registros en el historial",ap_no_predecessors:"Sin predecesores agregados",ap_no_progress:"Sin datos de progreso disponibles",ap_overall_progress:"Progreso general",ap_place:"Lugar",ap_plan_name_placeholder:"Nombre del plan de acción",ap_predecessors:"Predecesores",ap_priority:"Prioridad",ap_priority_high:"Alta",ap_priority_low:"Baja",ap_priority_medium:"Media",ap_progress:"Progreso",ap_progress_comment_placeholder:"Agregue un comentario sobre el progreso",ap_progress_percent:"Progreso (%)",ap_report:"Reportar",ap_report_progress:"Reportar progreso",ap_reporting:"Reportando...",ap_reports_history:"Historial de reportes",ap_responsible:"Responsable",ap_select_action:"Seleccione una acción",ap_select_cause:"Seleccione la causa",ap_select_checker:"Seleccione el verificador",ap_select_date:"Seleccione la fecha",ap_select_parent:"Seleccione la acción padre",ap_select_place:"Seleccione el lugar",ap_select_priority:"Seleccione la prioridad",ap_select_responsible:"Seleccione el responsable",ap_select_type:"Seleccione el tipo",ap_start_date:"Fecha de inicio",ap_status_canceled:"Cancelada",ap_status_done:"Completada",ap_status_effectiveness_check:"Verificación de eficacia",ap_status_running:"En progreso",ap_status_suspended:"Suspendida",ap_status_waiting_start:"Esperando inicio",ap_time_label:"Tiempo",ap_time_spent:"Tiempo dedicado (HH:MM)",ap_total_cost:"Costo total realizado",ap_total_time:"Tiempo total",ap_type_corrective:"Correctiva",ap_type_immediate:"Inmediata",ap_type_improvement:"Oportunidad de Mejora",ap_type_preventive:"Preventiva",ap_type_standardization:"Estandarización",ap_value:"Valor",ap_via_app:"Vía app",approval_approve:"Aprobar",approval_execute_action:"Ejecutar acción",approval_opinion:"Opinión *",approval_read_less:"Leer menos",approval_read_more:"Leer más",approval_reprove_radio:"Rechazar y retornar a etapa",approval_search_approver:"Buscar aprobador...",approval_select_approver:"Seleccionar aprobador",approval_select_approver_placeholder:"Seleccione un aprobador...",approval_select_step:"Seleccione la etapa",approval_step_label:"Etapa",approval_user_group:"Grupo de usuarios",audit_description:"Descripción",audit_esign:"Firma electrónica",audit_not_informed:"No informado",audit_references:"Referencias",audit_security:"Seguridad",audit_trail:"Pista de Auditoría",auth_error:"Error durante la autenticación. Intente de nuevo.",auth_failed:"Fallo en la autenticación. Intente de nuevo.",auto_login:"Iniciando sesión automáticamente...",back:"Volver",bulk_delete_error:"Error al eliminar elementos en lote",bulk_delete_success:"Elementos eliminados exitosamente",cancel:"Cancelar",change_photo:"Cambiar foto",cannot_be_own_leader:"Un líder no puede ser su propio superior",clear_filters:"Limpiar filtros",clear_formatting:"Limpiar Formato",clear_search:"Limpiar búsqueda",clear_selection:"Limpiar selección",close:"Cerrar",collapse_row:"Contraer fila",columns:"Columnas",conclude:"Concluir",confirm_removal:"Confirmar eliminación",could_not_load_info:"No se pudo cargar la información",current:"Actual",custom_color:"Color personalizado",dashboard_advanced_filter:"Filtro avanzado",dashboard_all_access:"Todos los colaboradores tendrán acceso",dashboard_average:"Promedio",dashboard_code:"Código",dashboard_distinct_count:"Conteo distinto",dashboard_edit:"Editar Dashboard",dashboard_exit_fullscreen:"Salir de pantalla completa",dashboard_export_chart:"Exportar gráfico",dashboard_export_table:"Exportar tabla",dashboard_max_value:"Valor máximo",dashboard_min_value:"Valor mínimo",dashboard_my:"Mis dashboards",dashboard_new:"Nuevo Dashboard",dashboard_no_data:"La consulta no devolvió elementos para su perfil.",dashboard_no_refresh:"No actualizar",dashboard_normal_page:"Página normal",dashboard_not_shared:"No compartido",dashboard_only_mine:"Solo míos",dashboard_only_overdue:"Solo atrasados",dashboard_only_responsible:"Solo el responsable tendrá acceso",dashboard_open_query:"Abrir consulta",dashboard_remove_favorite:"Quitar favorito",dashboard_responsible:"Responsable",dashboard_select_groups:"Seleccione grupos, lugares y colaboradores específicos",dashboard_shared_unit:"Compartido con todos los colaboradores de la unidad",dashboard_status:"Situación",dashboard_title:"Título",dashboard_wait_refresh:"Espere para actualizar nuevamente",dashboard_work_done:"Trabajo ejecutado",dashboard_work_planned:"Trabajo planificado",deactivate:"Desactivar",deselect_all:"Deseleccionar todas",dev_login:"Login Desarrollo",download:"Descargar",edit:"Editar",edit_profile:"Editar Perfil",edit_name:"Editar Nombre",electronic_signature:"Firma Electrónica",embed_code:"Código embed",embedded_content:"Contenido embebido",enter_code:"Ingrese el código",enter_password:"Ingrese su contraseña",error_authentication:"Error de Autenticación",error_connection:"Error de Conexión",error_copied_clipboard:"Los detalles del error se copiaron al portapapeles.",error_loading:"Error al cargar",error_loading_data:"Error al cargar datos",error_session_expired:"Sesión Expirada",error_token_expired:"Token de autenticación expirado. Inicie sesión nuevamente.",esign_code_description:"Un código de verificación fue enviado a su correo. Ingrese el código a continuación para confirmar la operación.",esign_code_error:"Error al validar el código. Intente de nuevo.",esign_invalid_code:"Código inválido. Intente de nuevo.",esign_invalid_password:"Contraseña incorrecta. Intente de nuevo.",esign_password_description:"Ingrese su contraseña para confirmar la operación.",esign_password_error:"Error al validar la contraseña. Intente de nuevo.",esign_resend_error:"Error al reenviar el código.",expand_row:"Expandir fila",expiration_date:"Fecha de expiración",file_error:"Error en el archivo",file_upload:"Subir archivo",go_to_next_page:"Ir a la página siguiente",go_to_previous_page:"Ir a la página anterior",group_by_column:"Agrupar por esta columna",heading_1:"Título 1",heading_2:"Título 2",heading_3:"Título 3",image_description:"Descripción de la imagen",import_flows:"Flujos de Importación",import_manage:"Gestione sus flujos de importación",inactive:"inactivo",inactive_user:"[Usuario inactivo]",input_type:"Tipo de entrada",invalid_form:"Formulario inválido. Complete todos los campos obligatorios.",italic:"Itálica",item_details:"Detalles del elemento",items:"elementos",items_per_page:"Elementos por página",know_saber_gestao:"Conozca Saber Gestión",know_staff:"Conozca Staff",language:"Idioma",last_update:"Última actualización",leader:"Líder",leader_create_error:"Error al crear líder",leader_not_found:"Líder no encontrado",leader_promoted_success:"Líder promovido exitosamente",leader_remove_error:"Error al eliminar líder",leader_removed_success:"Líder eliminado exitosamente",leader_update_error:"Error al actualizar líder",leader_updated_success:"Líder actualizado exitosamente",leadership_add_root:"Agregar Líder Raíz",leadership_add_subordinate:"Agregar Subordinado",leadership_cycle_error:"Esta asociación crearía un ciclo en la jerarquía",leadership_define_leader:"Definir Líder",leadership_immediate_superior:"Superior Inmediato",leadership_make_root:"Hacer Líder Raíz",leadership_make_root_short:"Hacer Raíz",leadership_no_hierarchy:"No se encontró jerarquía de liderazgo.",leadership_no_members:"Ningún miembro en el equipo",leadership_no_user_selected:"Ningún usuario seleccionado",leadership_no_users_available:"Ningún usuario disponible",leadership_no_users_found:"Ningún usuario encontrado",leadership_remove_team:"Quitar del equipo",leadership_select_subordinates:"Seleccione al menos un subordinado",learn_qualiex:"Aprenda a usar Qualiex",leave_without_saving:"Salir sin guardar",lines_per_page:"Líneas por página",link:"Enlace",login_with_qualiex:"Iniciar sesión con Qualiex",manage_access:"Gestionar Accesos",mind_map_add_child:"Agregar hijo",mind_map_add_sibling:"Agregar hermano",mind_map_aria_label:"Mapa mental",mind_map_collapse_all:"Colapsar todo",mind_map_delete_node:"Eliminar nodo",mind_map_expand_all:"Expandir todo",mind_map_export_image:"Exportar como imagen",mind_map_export_json:"Exportar como JSON",mind_map_fit_to_screen:"Ajustar a la pantalla",mind_map_redo:"Rehacer",mind_map_undo:"Deshacer",mind_map_zoom_in:"Acercar",mind_map_zoom_out:"Alejar",modules:"Módulos",more_options:"Más opciones",msg_create_error:"Error al crear registro",msg_created_success:"Registro creado exitosamente",msg_delete_error:"Error al eliminar registro",msg_deleted_success:"Registro eliminado exitosamente",msg_load_error:"Error al cargar datos",msg_update_error:"Error al actualizar registro",msg_updated_success:"Registro actualizado exitosamente",new_document:"Nuevo Documento",new_folder:"Nueva Carpeta",new_item:"Nuevo Elemento",next:"Siguiente",no_access_page:"Parece que no tienes acceso a esta página",no_data_to_display:"No hay datos para mostrar en este momento.",no_errors_recorded:"Sin errores registrados",no_image_selected:"Ninguna imagen seleccionada",no_item_selected:"Ningún elemento seleccionado",no_items_found:"No se encontraron elementos",no_items_found_empty:"Ningún elemento encontrado",no_place_found:"Ningún lugar encontrado",no_place_selected:"Sin lugar",no_products:"Sin productos",no_reports_found:"Ningún informe encontrado",no_results:"No se encontraron resultados",no_search_results:"Sin resultados para la búsqueda",no_video_selected:"Ningún vídeo seleccionado",not_authenticated:"No autenticado",not_available:"No disponible",of:"de",open_popover:"Abrir Popover",open_wiki:"Abrir Wiki",ordered_list:"Lista Ordenada",page:"Página",paste_embed_code:"Pegue el código embed aquí",permissions:"Permisos",preset_colors:"Colores predefinidos",preview:"Vista previa",redirecting_auth:"Redirigiendo a autenticación...",refresh_data:"Actualizar datos",remove:"Eliminar",remove_grouping:"Quitar agrupación",replace:"Reemplazar",report:"Informe",request_date:"Fecha de solicitud",required_field:"Campo obligatorio",resend_code:"Reenviar código",restricted_access:"Acceso restringido",rows_per_page:"Registros por página",save:"Guardar",save_as_draft:"Guardar como Borrador",save_as_template:"Guardar como Plantilla",saving:"Guardando...",search:"Buscar",search_placeholder:"Buscar...",search_report_placeholder:"Buscar informe...",search_user_placeholder:"Buscar usuario...",select_all:"Seleccionar todo",select_all_columns:"Seleccionar todas",select_all_items:"Seleccionar todos",select_at_least_one:"Seleccione al menos un elemento",select_at_least_one_item:"Seleccione al menos un elemento",select_date:"Seleccione una fecha",select_file_format:"Seleccione el formato del archivo",select_items_to_add:"Seleccione elementos para agregar...",select_placeholder:"Seleccionar...",selected:"Seleccionados",session_expired:"Su sesión ha expirado. Será redirigido para iniciar sesión nuevamente.",sign_access_error:"Error al acceder al servicio de firma",sign_api_key_info:"Ingrese la API Key del proveedor de firma",sign_api_key_input:"Ingrese la API Key del proveedor de firma",sign_api_key_placeholder:"Ingrese la clave de API",sign_api_key_required:"Clave de API obligatoria",sign_attempt:"Intento de firma",sign_auth_required:"Autenticación requerida para firmar",sign_click_to_select:"Haga clic para seleccionar documento",sign_config_save_err:"Error al guardar configuración de firma",sign_config_save_error:"Error al guardar configuración de firma",sign_config_saved:"Configuración de firma guardada",sign_config_saved_success:"Configuración de firma guardada exitosamente",sign_configured:"Firma configurada",sign_configured_unit:"Firma digital configurada para esta unidad",sign_digital_config:"Configuración de Firma Digital",sign_doc_available:"Documento firmado disponible para descarga",sign_doc_load_error:"Error al cargar documento",sign_doc_process_error:"Error al procesar documento",sign_doc_sent:"Documento enviado para firma",sign_download_signed:"Descargar documento firmado",sign_email_fallback:"Correo de respaldo para firma",sign_environment:"Ambiente de firma",sign_fetch_failed:"Error al obtener documento firmado",sign_file_not_allowed:"Extensión de archivo no permitida",sign_file_type_not_allowed:"Tipo de archivo no permitido",sign_incorrect_data:"El firmante reportó datos incorrectos.",sign_login_required:"Inicio de sesión requerido para firmar",sign_login_to_sign:"Inicie sesión para usar la firma digital.",sign_monthly_limit:"Límite mensual de firmas alcanzado",sign_no_access:"No se pudo obtener acceso para firma. Intente de nuevo.",sign_not_configured:"Firma no configurada",sign_not_configured_unit:"Firma digital aún no configurada para esta unidad",sign_preparing_doc:"Preparando documento para firma",sign_process_error:"Error al procesar firma",sign_save_config:"Guardar configuración",sign_save_config_btn:"Guardar Configuración",sign_select_pdf:"Seleccione un archivo PDF",sign_sending_doc:"Enviando documento para firma",sign_signed_success:"Documento firmado exitosamente",sign_signer_unavailable:"ID del firmante no disponible",sign_try_again:"Intentar de nuevo",sign_update_config:"Actualizar configuración",sign_update_config_btn:"Actualizar Configuración",sign_waiting_provider:"Esperando proveedor de firma",sign_widget_error:"Error en el widget de firma",something_went_wrong:"Algo salió mal",state:"Estado",status:"Estado",status_completed:"Completado",status_error:"Error",status_expired:"Expirado",status_processing:"Procesando",status_waiting:"Esperando",steps:"Etapas",subordinates_add_error:"Error al agregar subordinados",subordinates_added_success:"Subordinados agregados exitosamente",subordinates_sync_error:"Error al sincronizar subordinados",subordinates_synced_success:"Subordinados sincronizados exitosamente",team_all_groups:"Todos los grupos",terms_confirm_reading:"Confirmar lectura",terms_confirmation_available:"Confirmación disponible en",terms_of_use:"Términos de Uso",terms_read_agree:"He leído y acepto",terms_see_later:"Ver después",terms_updated:"Términos de Uso Actualizados",terms_view:"Ver términos de uso",terms_view_short:"Ver término",try_adjust_search:"Intente ajustar su búsqueda",try_again:"Intentar de Nuevo",unit_not_selected:"Ninguna unidad seleccionada",unknown_error:"Error desconocido",unsaved_changes:"Cambios sin guardar",unsaved_changes_description:"Hay cambios sin guardar. ¿Desea salir sin guardar?",updates:"Actualizaciones",user:"Usuario",user_info:"Información del Usuario",user_photo:"Foto del usuario",users_already_leaders:"Los usuarios ya son líderes",verification_code:"Código de verificación",video:"Video",video_title:"Título del vídeo",view_report:"Ver informe",want_to_know_more:"Quiero conocer más",write_content_here:"Escriba el contenido aquí..."};const ci="true"===(void 0).VITE_I18N_DEBUG_MODE;function ui(a,t){e.addResourceBundle(a,"app",t,!0,!0)}ci&&e.use({type:"postProcessor",name:"debugKeys",process:(e,a)=>`🔑 ${Array.isArray(a)?a[0]:a}`}),e.use(y.initReactI18next).init({resources:{"pt-BR":{core:ii},"en-US":{core:li},"es-ES":{core:di}},fallbackLng:"pt-BR",lng:"pt-BR",defaultNS:"app",fallbackNS:"core",ns:["core"],interpolation:{escapeValue:!1},react:{useSuspense:!1},saveMissing:!1,returnEmptyString:!1,parseMissingKeyHandler:e=>e,postProcess:ci?["debugKeys"]:[]});const mi=t.createContext(void 0),pi={locale:At,timezone:Mt,datetimeFormat:It},hi=async()=>{},xi=({children:e})=>a.jsx(mi.Provider,{value:{...pi,setLocale:hi,setTimezone:hi,setDatetimeFormat:hi,isLoading:!1},children:e}),fi=()=>{const e=t.useContext(mi);if(!e)throw new Error("useLocale deve ser usado dentro de LocaleProvider");return e},gi=t.createContext({moduleAlias:null});function vi({moduleAlias:e=null,children:t}){return a.jsx(gi.Provider,{value:{moduleAlias:e},children:t})}function bi(){return t.useContext(gi)}const yi=ge.Root,ji=ge.CollapsibleTrigger,wi=ge.CollapsibleContent;class Ni extends t.Component{constructor(a){super(a),this.copyErrorDetails=()=>{const a=tn.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||e.t("unknown_error")}\n\nStack Trace:\n${this.state.error?.stack||e.t("not_available")}\n\n=== ÚLTIMOS ERROS ===\n${a.map((e,a)=>`${a+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||e.t("no_errors_recorded")}\n `.trim();navigator.clipboard.writeText(t),l.toast.success("Detalhes copiados!",{description:e.t("error_copied_clipboard")})},this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if((void 0).DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,a){if((void 0).DEV)throw e;tn.handleError(e,!1),this.setState({errorInfo:a})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const t=tn.getErrors().slice(0,2);return a.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:a.jsxs(ts,{className:"w-full max-w-2xl",children:[a.jsxs(ss,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-destructive"})}),a.jsx(rs,{children:e.t("something_went_wrong")})]}),a.jsxs(os,{className:"space-y-4",children:[a.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),a.jsxs(yi,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[a.jsx(ji,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),a.jsxs(wi,{className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),a.jsxs("div",{className:"text-sm space-y-2",children:[a.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||e.t("unknown_error")}),this.state.error?.stack&&a.jsx(Io,{className:"h-32 w-full rounded border bg-muted p-2",children:a.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),t.length>0&&a.jsxs("div",{className:"pt-3 border-t",children:[a.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),a.jsx("div",{className:"space-y-2",children:t.map((e,t)=>a.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),a.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),a.jsxs(Xt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[a.jsx(d.Copy,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),a.jsx(Xt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}const _i=ve.Root,Ci=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.List,{ref:s,className:Kt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Ci.displayName=ve.List.displayName;const ki=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.Trigger,{ref:s,className:Kt("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",e),...t}));ki.displayName=ve.Trigger.displayName;const Si=ae.forwardRef(({className:e,...t},s)=>a.jsx(ve.Content,{ref:s,className:Kt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function Ti({className:e}){return a.jsxs("svg",{className:e,width:"32",height:"34",viewBox:"0 0 32 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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 Pi({className:e}){return a.jsxs("svg",{className:e,width:"18",height:"33",viewBox:"0 0 18 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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"}),a.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"})]})}Si.displayName=ve.Content.displayName;const Ei={init(e){!function(e){try{return void function(e,a,t,s,r,n,o){a.getElementById("clarity-script")||(e[t]=e[t]||function(){(e[t].q=e[t].q||[]).push(arguments)},(n=a.createElement(s)).async=1,n.src="https://www.clarity.ms/tag/"+r+"?ref=npm",n.id="clarity-script",(o=a.getElementsByTagName(s)[0]).parentNode.insertBefore(n,o))}(window,document,"clarity","script",e)}catch(a){return}}(e)},setTag(e,a){window.clarity("set",e,a)},identify(e,a,t,s){window.clarity("identify",e,a,t,s)},consent(e=!0){window.clarity("consent",e)},consentV2(e={ad_Storage:"granted",analytics_Storage:"granted"}){window.clarity("consentv2",e)},upgrade(e){window.clarity("upgrade",e)},event(e){window.clarity("event",e)}},Di="forlogic_";function Ai(){return"undefined"!=typeof window&&"function"==typeof window.clarity}function Ii(){return"undefined"!=typeof window&&"piggyback"===window.__forlogicClarityMode}function Mi(e){return Ii()?`${Di}${e}`:e}function Fi(e){return Ii()?`${Di}${e}`:e}function Ri(e){try{e()}catch(a){(void 0).DEV}}function Li(e){for(const[a,t]of Object.entries(e))null!=t&&""!==t&&Ei.setTag(Fi(a),t)}function zi({module:e,isContracted:a,sourceModule:t,alias:s}){Ai()&&Ri(()=>{Li({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:String(a),source_module:t,alias:s}),Ei.event(Mi("module_menu_click"))})}function Ui({module:e,sourceModule:a,alias:t}){Ai()&&Ri(()=>{Li({clicked_module:e.name,clicked_module_id:e.softwareAlias,is_contracted:"false",source_module:a,alias:t}),Ei.event(Mi("module_interest_click"))})}function Oi({resource:e,sourceModule:a,alias:t}){Ai()&&Ri(()=>{Li({footer_resource:e,source_module:a,alias:t}),Ei.event(Mi("module_footer_click"))})}function Vi({educaUrl:e="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:t="https://sabergestao.com.br/",wikiUrl:s,alias:r,sourceModule:n}){const{t:o}=y.useTranslation(),i=Gt(e||s||"https://educacao.sabergestao.com.br/{alias}/fe",r),l=e=>{Oi({resource:e,sourceModule:n,alias:r})};return a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsxs("div",{className:"grid grid-cols-1 min-[480px]:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-3",children:[a.jsxs("div",{className:"bg-primary text-primary-foreground rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-white",children:o("learn_qualiex")}),a.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("educa"),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",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(Ti,{className:"absolute right-2 bottom-2 w-16 h-16 text-[#043481] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:o("know_saber_gestao")}),a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:()=>l("saber-gestao"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Saiba mais",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(Pi,{className:"absolute right-2 bottom-2 w-12 h-16 text-[#E0E0E0] pointer-events-none"})]}),a.jsxs("div",{className:"bg-muted rounded-lg p-4 relative overflow-hidden",children:[a.jsxs("div",{className:"relative z-10",children:[a.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Dúvidas sobre os módulos?"}),a.jsxs("a",{href:s||"https://wiki.qualiex.com/",target:"_blank",rel:"noopener noreferrer",onClick:()=>l("wiki"),className:"inline-flex items-center gap-1 text-sm text-primary underline underline-offset-2 hover:opacity-80 mt-2",children:["Consulte nossa Wiki",a.jsx(d.ExternalLink,{className:"h-3.5 w-3.5"})]})]}),a.jsx(d.NotebookText,{className:"absolute right-2 top-2 bottom-2 h-[calc(100%-1rem)] w-auto text-[#E0E0E0] pointer-events-none",strokeWidth:1})]})]})]})}const Bi=[{id:"qualiex",label:"Qualiex",modules:[{name:"Análises",description:"Análise de dados",color:"bg-[#002338]",softwareAlias:"analysis",url:"https://apps4.qualiex.com/analysis/{alias}"},{name:"Atas e Decisões",description:"Gestão de atas e decisões",color:"bg-[#7DB3B2]",softwareAlias:"decisions",url:"https://apps4.qualiex.com/decisions/{alias}"},{name:"Auditorias",description:"Gestão de auditorias",color:"bg-[#912F71]",softwareAlias:"audit",url:"https://apps4.qualiex.com/audit/{alias}"},{name:"Configurações",description:"Configurações gerais",color:"bg-[#5C6BC0]",softwareAlias:"common",url:"https://apps4.qualiex.com/common/{alias}"},{name:"Documentos",description:"Gestão de documentos",color:"bg-[#1D43A6]",softwareAlias:"docs",url:"https://apps4.qualiex.com/docs/{alias}"},{name:"Fluxos",description:"Gestão de fluxos",color:"bg-[#8BFFE0]",softwareAlias:"flow",url:"https://apps4.qualiex.com/flow/{alias}"},{name:"Fornecedores",description:"Gestão de fornecedores",color:"bg-[#5C5094]",softwareAlias:"suppliers",url:"https://apps4.qualiex.com/suppliers/{alias}"},{name:"Mapeamentos",description:"Mapeamento de dados pessoais",color:"bg-[#62416B]",softwareAlias:"mapping",url:"https://apps4.qualiex.com/mapping/{alias}"},{name:"Metrologia",description:"Gestão de metrologia",color:"bg-[#8CC74F]",softwareAlias:"metrology",url:"https://apps4.qualiex.com/metrology/{alias}"},{name:"Ocorrências",description:"Gestão de ocorrências",color:"bg-[#EE7121]",softwareAlias:"occurrences",url:"https://apps4.qualiex.com/occurrences/{alias}"},{name:"OKR",description:"Objetivos e resultados-chave",color:"bg-[#4A90D9]",softwareAlias:"okr",url:"https://okr.qualiex.com/{alias}"},{name:"Planos",description:"Planos de ação",color:"bg-[#FBC02D]",softwareAlias:"plans",url:"https://apps4.qualiex.com/plans/{alias}"},{name:"Portal do Fornecedor",description:"Portal do Fornecedor",color:"bg-[#26A69A]",softwareAlias:"suppliers-portal",url:"https://portaldofornecedor.qualiex.com/{alias}"},{name:"Riscos",description:"Gestão de riscos",color:"bg-[#ED7096]",softwareAlias:"risks",url:"https://apps4.qualiex.com/risks/{alias}"},{name:"Competências",description:"Gestão de competências",color:"bg-[#9B4F96]",softwareAlias:"competencies",url:"https://competencias.sabergestao.com.br/{alias}"},{name:"Desempenho",description:"Gestão de desempenho",color:"bg-[#4A90D9]",softwareAlias:"performance",url:"https://desempenho.sabergestao.com.br/{alias}"},{name:"Educação",description:"Plataforma de ensino",color:"bg-[#00BCD4]",softwareAlias:"education",url:"https://educacao.sabergestao.com.br/{alias}"},{name:"PDI",description:"Plano de desenvolvimento individual",color:"bg-[#7CB342]",softwareAlias:"pdi",url:"https://pdi.sabergestao.com.br/{alias}"},{name:"Pulso",description:"Pesquisas de clima",color:"bg-[#F5A623]",softwareAlias:"pulse",url:"https://nr1pulso.sabergestao.com.br/{alias}"},{name:"Treinamentos",description:"Gestão de treinamentos",color:"bg-[#26A69A]",softwareAlias:"staff",url:"https://treinamentos.sabergestao.com.br/{alias}"}]},{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={alias}"},{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={alias}"},{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 qi({module:e,onClick:t}){return a.jsxs("button",{type:"button",onClick:t,className:"flex items-start gap-3 p-2 rounded-lg transition-colors text-left w-full group hover:bg-muted/50",children:[a.jsx("div",{className:Kt("w-4 h-4 rounded-sm shrink-0 mt-0.5",e.color)}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"font-medium transition-colors text-foreground group-hover:text-primary",children:e.name}),e.description&&a.jsx("div",{className:"text-sm text-muted-foreground truncate",children:e.description})]})]})}function $i(e,a){if(0===e.length)return e;const t=Math.ceil(e.length/a),s=[];for(let r=0;r<t;r++)for(let n=0;n<a;n++){const a=n*t+r;a<e.length&&s.push(e[a])}return s}function Wi({modules:e,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):window.matchMedia("(min-width: 640px)").matches?a(2):a(1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),i=[...e].sort((e,a)=>e.name.localeCompare(a.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=$i(d,o),m=$i(c,o),p=(e,a)=>{a?s?.(e):n?.(e)};return a.jsxs("div",{className:"space-y-6",children:[u.length>0&&a.jsx("section",{children:a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:u.map(e=>a.jsx(qi,{module:e,onClick:()=>p(e,!0)},e.name))})}),m.length>0&&a.jsxs("section",{className:"bg-neutral-100 dark:bg-neutral-800 rounded-lg p-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Conheça também"}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-1",children:m.map(e=>a.jsx(qi,{module:e,onClick:()=>p(e,!1)},e.name))})]})]})}function Hi({onModuleClick:e,contractedModules:s,onModuleInterest:r,nonContractedUrl:n="https://qualiex.com/",educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,alias:d,sourceModule:c}){const[u,m]=t.useState("qualiex"),p=e=>{Ui({module:e,sourceModule:c,alias:d}),window.open(n,"_blank","noopener,noreferrer"),r?.(e)};return a.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[a.jsxs(_i,{value:u,onValueChange:m,className:"flex-1 flex flex-col min-h-0",children:[a.jsx(Ci,{className:"w-fit shrink-0",children:Bi.map(e=>a.jsxs(ki,{value:e.id,children:[e.label,a.jsxs("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",e.modules.length,")"]})]},e.id))}),Bi.map(t=>a.jsx(Si,{value:t.id,className:"flex-1 mt-4 overflow-auto pr-2",children:a.jsx(Wi,{modules:t.modules,onModuleClick:a=>{return r=a,n=t.id,zi({module:r,isContracted:"qualiex"!==n||!s||s.includes(r.name),sourceModule:c,alias:d}),void e?.(r);var r,n},contractedModules:"qualiex"===t.id?s:void 0,onModuleInterest:p})},t.id))]}),a.jsx(Vi,{educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:d,sourceModule:c})]})}const Gi={analysis:12,decisions:13,audit:1,common:0,competencies:23,performance:24,docs:17,education:25,flow:7,suppliers:15,"suppliers-portal":16,mapping:11,metrology:8,control:18,msa:21,occurrences:3,okr:26,pdi:27,plans:6,"strategy-extension":14,pulse:28,boards:10,risks:4,fmea:20,staff:19,"control-plan":22},Ki=6e5;function Yi(e){const{moduleAlias:a}=bi(),{alias:s,user:r,isAuthenticated:n}=An(),o=e??a,i=r?.id??null,l=n&&!!s&&!!i,{data:d=[],isLoading:c}=w.useQuery({queryKey:["qualiex-associations",i,s],queryFn:()=>xn.fetchUserAssociations(i,s),enabled:l,staleTime:Ki,gcTime:12e5}),u=t.useMemo(()=>s&&0!==d.length?d.find(e=>e.companyAlias===s)??null:null,[d,s]),m=t.useCallback(e=>{if(!u)return!1;return(Array.isArray(e)?e:[e]).every(e=>{const a=Gi[e];return void 0!==a&&u.softwares.includes(a)})},[u]);return{hasAccess:t.useMemo(()=>!o||m(o),[o,m]),isLoading:l&&c,role:t.useMemo(()=>u?{id:u.roleId,name:u.roleName}:null,[u]),association:u,hasAccessTo:m}}function Qi(e){const{association:a}=Yi();return t.useMemo(()=>{if(e)return e;if(!a?.softwares)return;const t=a.softwares,s=Bi.find(e=>"qualiex"===e.id);return s?s.modules.filter(e=>{if(!e.softwareAlias)return!1;const a=Gi[e.softwareAlias];return void 0!==a&&t.includes(a)}).map(e=>e.name):void 0},[e,a])}function Xi({open:e,onOpenChange:t,onModuleClick:s,contractedModules:r,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:d}){const{alias:c}=An(),u=Qi(r);return a.jsx(ys,{open:e,onOpenChange:t,children:a.jsxs(ks,{size:"lg",className:"overflow-hidden flex flex-col",children:[a.jsx(Ss,{className:"sr-only",children:a.jsx(Es,{children:"Módulos"})}),a.jsx(Hi,{onModuleClick:e=>{s?s(e):e.url&&Ht(Gt(e.url,c||void 0))},contractedModules:u,onModuleInterest:n,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,alias:c||void 0,sourceModule:d})]})})}function Ji({open:s,onOpenChange:r,onModuleClick:n,contractedModules:o,onModuleInterest:i,userName:l,unitName:c,units:u=[],currentAlias:m,onUnitChange:p,onLogout:h,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,blocking:v=!0,size:b="lg",children:j,sourceModule:w}){const{t:N}=y.useTranslation(),_=t.useMemo(()=>{if(!u.length)return[];const e=new Map;u.forEach(a=>e.set(a.alias,a));const a=Array.from(e.values()),t=a.find(e=>e.alias===m),s=a.filter(e=>e.alias!==m).sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"}));return t?[t,...s]:s},[u,m]);return a.jsx(ys,{open:s,onOpenChange:v?void 0:r,children:a.jsxs(ks,{size:b,variant:"destructive",className:"overflow-hidden flex flex-col max-h-[85vh]",onPointerDownOutside:v?e=>e.preventDefault():void 0,onEscapeKeyDown:v?e=>e.preventDefault():void 0,children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 flex-shrink-0",children:[a.jsxs("div",{className:"flex flex-col gap-1.5 text-left",children:[a.jsx(Es,{children:N("no_access_page")}),a.jsx(Ds,{children:"Selecione um módulo para continuar navegando!"})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.length>1&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",size:"sm",className:"gap-2 max-w-[200px]",children:[a.jsx(d.Building2,{className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate text-xs",children:c||"Unidade"}),a.jsx(d.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),a.jsx(pr,{align:"end",className:"max-h-[300px] overflow-auto",children:_.map(e=>a.jsxs(hr,{onClick:()=>p?.(e),className:e.alias===m?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4 shrink-0"}),a.jsx("span",{className:"truncate",children:e.name}),e.alias===m&&a.jsx(er,{variant:"outline",className:"ml-auto text-xs shrink-0",children:"Atual"})]},e.alias))})]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-2",children:[a.jsx("div",{className:"w-7 h-7 bg-primary rounded-full flex items-center justify-center",children:a.jsx(d.User,{className:"h-3.5 w-3.5 text-primary-foreground"})}),a.jsx(d.ChevronDown,{className:"h-3 w-3"})]})}),a.jsxs(pr,{align:"end",children:[a.jsxs("div",{className:"px-2 py-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:l||e.t("user")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:c})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:h,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})]})]}),j?a.jsxs("div",{className:"flex-1 min-h-0 overflow-auto flex flex-col",children:[a.jsx("div",{className:"flex-1",children:j}),a.jsx(Vi,{educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]}):a.jsx(Hi,{onModuleClick:n,contractedModules:o,onModuleInterest:i,educaUrl:x,saberGestaoUrl:f,wikiUrl:g,alias:m,sourceModule:w})]})})}function Zi(e,a){const{t:t}=y.useTranslation();return a.some(a=>a.endsWith("*")?e.startsWith(a.slice(0,-1)):e===a)}function el({children:e,contractedModules:s,onModuleClick:r,onModuleInterest:n,educaUrl:o="https://educacao.sabergestao.com.br/{alias}/fe",saberGestaoUrl:i="https://sabergestao.com.br/",wikiUrl:l,bypassPaths:d,accessDeniedRoutes:c,sourceModule:u}){const{t:m}=y.useTranslation(),{hasAccess:p,isLoading:h,association:x}=Yi(),{user:f,alias:g,companies:v,isAuthenticated:b,isLoading:j,logout:w,switchUnit:N}=An(),_=Qi(s),C=t.useMemo(()=>v?.length?g&&v.find(e=>e.alias===g)||v[0]:null,[v,g]),k=t.useMemo(()=>v?.length?v.map(e=>({alias:e.alias,name:e.name||e.alias})):[],[v]),S=t.useCallback(e=>{const a=v?.find(a=>a.alias===e.alias);if(!a)return;const{pathname:t,search:s,hash:r}=window.location;if(g){const e=t.split("/"),n=e.indexOf(g);if(n>=0)return e[n]=a.alias,void(window.location.href=e.join("/")+s+r)}N(a)},[g,N,v]),T=t.useCallback(e=>{r?r(e):e.url&&Ht(Gt(e.url,g||void 0))},[r,g]),P=t.useMemo(()=>{if(!c)return;const e=window.location.pathname,a=Object.keys(c).find(a=>Zi(e,[a]));return a?c[a]:void 0},[c]);return j||!b||d?.length&&Zi(window.location.pathname,d)?a.jsx(a.Fragment,{children:e}):h?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsx(tr,{size:"lg"})}):p?a.jsx(a.Fragment,{children:e}):a.jsx(Ji,{open:!0,onModuleClick:T,contractedModules:_,onModuleInterest:n,userName:f?.name,unitName:C?.name,units:k,currentAlias:g||void 0,onUnitChange:S,onLogout:w,educaUrl:o,saberGestaoUrl:i,wikiUrl:l,sourceModule:u,blocking:!0,children:P})}let al=!1;function tl(){if(al||"undefined"==typeof document)return;al=!0;for(const a of["https://fonts.googleapis.com","https://fonts.gstatic.com"])if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=a,a.includes("gstatic")&&(e.crossOrigin="anonymous"),document.head.appendChild(e)}const e=["https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap","https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap"];for(const a of e)if(!document.querySelector(`link[href="${a}"]`)){const e=document.createElement("link");e.rel="stylesheet",e.href=a,document.head.appendChild(e)}}function sl({projectId:e,mode:a="auto"}){const{user:s,alias:r,isAuthenticated:n}=An();t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&e&&!ze()&&!window.__forlogicClarityOwned)if("function"!=typeof window.clarity)try{Ei.init(e),window.__forlogicClarityOwned=!0,window.__forlogicClarityMode="owned"}catch(t){(void 0).DEV,window.__forlogicClarityMode="inactive"}else window.__forlogicClarityMode="piggyback"},[e,a]),t.useEffect(()=>{if("undefined"!=typeof window&&"disabled"!==a&&n&&s&&"function"==typeof window.clarity)try{const e=s.email||s.identifier||"anonymous";Ei.identify(e,void 0,"modules-menu",s.name||void 0),r&&Ei.setTag("alias",r),"boolean"==typeof s.isSysAdmin&&Ei.setTag("isSysAdmin",String(s.isSysAdmin))}catch(e){(void 0).DEV}},[s,r,n,a])}function rl({projectId:e,mode:a}){return sl({projectId:e,mode:a}),null}function nl(){const e=sn((void 0).VITE_SUPABASE_PUBLISHABLE_KEY),t=!!(void 0).VITE_SUPABASE_PK_OVERRIDE;if(!e||t||!(void 0).DEV)return null;const s={background:"rgba(0,0,0,.2)",padding:"1px 4px",borderRadius:4};return a.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,zIndex:99999,background:"#dc2626",color:"#fff",padding:"8px 16px",fontSize:"13px",fontFamily:"Inter, system-ui, sans-serif",textAlign:"center",lineHeight:1.4},children:[a.jsx("strong",{children:"⚠️ Legacy Supabase Key Detectada"})," — O ",a.jsx("code",{style:s,children:"VITE_SUPABASE_PUBLISHABLE_KEY"})," contém uma anon key JWT legada. Adicione ",a.jsx("code",{style:s,children:'VITE_SUPABASE_PK_OVERRIDE="sb_publishable_..."'})," no .env para corrigir."]})}const ol=be.Root,il=ae.forwardRef(({className:e,...t},s)=>a.jsx(be.Item,{ref:s,className:Kt("border-b",e),...t}));il.displayName="AccordionItem";const ll=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Header,{className:"flex",children:a.jsxs(be.Trigger,{ref:r,className:Kt("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,a.jsx(d.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ll.displayName=be.Trigger.displayName;const dl=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsx(be.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:a.jsx("div",{className:Kt("pb-4 pt-0",e),children:t})}));dl.displayName=be.Content.displayName;const cl=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Root,{ref:s,className:Kt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));cl.displayName=ye.Root.displayName;const ul=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Image,{ref:s,className:Kt("aspect-square h-full w-full",e),...t}));ul.displayName=ye.Image.displayName;const ml=ae.forwardRef(({className:e,...t},s)=>a.jsx(ye.Fallback,{ref:s,className:Kt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));ml.displayName=ye.Fallback.displayName;const pl=ae.forwardRef(({...e},t)=>a.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));pl.displayName="Breadcrumb";const hl=ae.forwardRef(({className:e,...t},s)=>a.jsx("ol",{ref:s,className:Kt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));hl.displayName="BreadcrumbList";const xl=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Kt("inline-flex items-center gap-1.5",e),...t}));xl.displayName="BreadcrumbItem";const fl=ae.forwardRef(({asChild:e,className:t,...r},n)=>{const o=e?s.Slot:"a";return a.jsx(o,{ref:n,className:Kt("transition-colors hover:text-foreground",t),...r})});fl.displayName="BreadcrumbLink";const gl=ae.forwardRef(({className:e,...t},s)=>a.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Kt("font-normal text-foreground",e),...t}));gl.displayName="BreadcrumbPage";const vl=({children:e,className:t,...s})=>a.jsx("li",{role:"presentation","aria-hidden":"true",className:Kt("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...s,children:e??a.jsx(d.ChevronRight,{})});vl.displayName="BreadcrumbSeparator";const bl=({className:e,...t})=>a.jsxs("span",{role:"presentation","aria-hidden":"true",className:Kt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Mais"})]});bl.displayName="BreadcrumbEllipsis";const yl=r.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"}}),jl=ae.forwardRef(({className:e,orientation:t,...s},r)=>a.jsx("div",{ref:r,className:Kt(yl({orientation:t}),e),...s}));function wl({className:e,classNames:t,showOutsideDays:s=!0,...r}){return a.jsx(I.DayPicker,{showOutsideDays:s,className:Kt("p-3 pointer-events-auto",e),locale:Tt,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:Kt(Qt({variant:"outline"}),"z-10 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),button_next:Kt(Qt({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:Kt(Qt({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",...t},components:{Chevron:({orientation:e})=>"left"===e?a.jsx(d.ChevronLeft,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})},...r})}jl.displayName="ButtonGroup",wl.displayName="Calendar";const Nl={Root:function({children:e,className:t}){return a.jsx("div",{className:Kt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:s}){return a.jsx(ts,{className:Kt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",s),onClick:t,children:a.jsx(os,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:s}){return a.jsxs("div",{className:Kt("flex justify-between items-center text-sm",s),children:[a.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),a.jsx("span",{className:"text-foreground",children:t})]})}};function _l({date:e,onDateChange:t,placeholder:s,disabled:r=!1,className:n,disabledDates:o}){const{t:l}=y.useTranslation(),c=s??l("select_date");return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",disabled:r,className:Kt("w-full justify-start text-left font-normal",!e&&"text-muted-foreground",n),children:[a.jsx(d.Calendar,{className:"mr-2 h-4 w-4"}),e?i.format(e,"d 'de' MMMM 'de' yyyy",{locale:Tt}):a.jsx("span",{children:c})]})}),a.jsx(Sr,{className:"w-auto p-0",align:"start",children:a.jsx(wl,{mode:"single",selected:e,onSelect:t,disabled:o,initialFocus:!0,className:"pointer-events-auto"})})]})}const Cl=({shouldScaleBackground:e=!0,...t})=>a.jsx(M.Drawer.Root,{shouldScaleBackground:e,...t});Cl.displayName="Drawer";const kl=M.Drawer.Trigger,Sl=M.Drawer.Portal,Tl=M.Drawer.Close,Pl=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Overlay,{ref:s,className:Kt("fixed inset-0 z-50 bg-black/80",e),...t}));Pl.displayName=M.Drawer.Overlay.displayName;const El=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(Sl,{children:[a.jsx(Pl,{}),a.jsxs(M.Drawer.Content,{ref:r,className:Kt("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",e),...s,children:[a.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),t]})]}));El.displayName="DrawerContent";const Dl=({className:e,...t})=>a.jsx("div",{className:Kt("grid gap-1.5 p-4 text-center sm:text-left",e),...t});Dl.displayName="DrawerHeader";const Al=({className:e,...t})=>a.jsx("div",{className:Kt("mt-auto flex flex-col gap-2 p-4",e),...t});Al.displayName="DrawerFooter";const Il=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Title,{ref:s,className:Kt("text-lg font-semibold leading-none tracking-tight",e),...t}));Il.displayName=M.Drawer.Title.displayName;const Ml=ae.forwardRef(({className:e,...t},s)=>a.jsx(M.Drawer.Description,{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));Ml.displayName=M.Drawer.Description.displayName;const Fl={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))]"},Rl={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};const Ll=je.Root,zl=je.Trigger,Ul=ae.forwardRef(({className:e,align:t="center",sideOffset:s=4,...r},n)=>a.jsx(je.Content,{ref:n,align:t,sideOffset:s,className:Kt("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",e),...r}));Ul.displayName=je.Content.displayName;const Ol=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-slot":"input-group",className:Kt("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",e),...t}));Ol.displayName="InputGroup";const Vl=r.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"}}),Bl=ae.forwardRef(({className:e,align:t,...s},r)=>a.jsx("div",{ref:r,"data-slot":"input-group-addon",className:Kt(Vl({align:t}),e),...s}));Bl.displayName="InputGroupAddon";const ql=r.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"}}),$l=ae.forwardRef(({className:e,size:t,variant:s="ghost",...r},n)=>a.jsx(Xt,{ref:n,"data-slot":"input-group-button",variant:s,className:Kt(ql({size:t}),"rounded-none first:rounded-l-md last:rounded-r-md",e),...r}));$l.displayName="InputGroupButton";const Wl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-slot":"input-group-control",className:Kt("flex-1 border-0 bg-transparent shadow-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Wl.displayName="InputGroupInput";const Hl=ae.forwardRef(({className:e,...t},s)=>a.jsx(Js,{ref:s,"data-slot":"input-group-control",className:Kt("flex-1 border-0 bg-transparent shadow-none resize-none","focus-visible:ring-0 focus-visible:ring-offset-0",e),...t}));Hl.displayName="InputGroupTextarea";const Gl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h1",{ref:s,className:Kt("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",e),...t}));Gl.displayName="H1";const Kl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h2",{ref:s,className:Kt("scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",e),...t}));Kl.displayName="H2";const Yl=ae.forwardRef(({className:e,...t},s)=>a.jsx("h3",{ref:s,className:Kt("scroll-m-20 text-2xl font-semibold tracking-tight",e),...t}));Yl.displayName="H3";const Ql=ae.forwardRef(({className:e,...t},s)=>a.jsx("h4",{ref:s,className:Kt("scroll-m-20 text-xl font-semibold tracking-tight",e),...t}));Ql.displayName="H4";const Xl=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Kt("leading-7 [&:not(:first-child)]:mt-6",e),...t}));Xl.displayName="P";const Jl=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Kt("text-xl text-muted-foreground",e),...t}));Jl.displayName="Lead";const Zl=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:Kt("text-lg font-semibold",e),...t}));Zl.displayName="Large";const ed=ae.forwardRef(({className:e,...t},s)=>a.jsx("small",{ref:s,className:Kt("text-sm font-medium leading-none",e),...t}));ed.displayName="Small";const ad=ae.forwardRef(({className:e,...t},s)=>a.jsx("p",{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));ad.displayName="Muted";const td=ae.forwardRef(({className:e,...t},s)=>a.jsx("code",{ref:s,className:Kt("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",e),...t}));td.displayName="InlineCode";const sd=ae.forwardRef(({className:e,...t},s)=>a.jsx("blockquote",{ref:s,className:Kt("mt-6 border-l-2 pl-6 italic",e),...t}));sd.displayName="Blockquote";const rd=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Kt("my-6 ml-6 list-disc [&>li]:mt-2",e),...t}));rd.displayName="List";const nd=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Root,{ref:r,className:Kt("relative z-10 flex max-w-max flex-1 items-center justify-center",e),...s,children:[t,a.jsx(md,{})]}));nd.displayName=we.Root.displayName;const od=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.List,{ref:s,className:Kt("group flex flex-1 list-none items-center justify-center space-x-1",e),...t}));od.displayName=we.List.displayName;const id=we.Item,ld=r.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"),dd=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(we.Trigger,{ref:r,className:Kt(ld(),"group",e),...s,children:[t," ",a.jsx(d.ChevronDown,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));dd.displayName=we.Trigger.displayName;const cd=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.Content,{ref:s,className:Kt("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 ",e),...t}));cd.displayName=we.Content.displayName;const ud=we.Link,md=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{className:Kt("absolute left-0 top-full flex justify-center"),children:a.jsx(we.Viewport,{className:Kt("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)]",e),ref:s,...t})}));md.displayName=we.Viewport.displayName;const pd=ae.forwardRef(({className:e,...t},s)=>a.jsx(we.Indicator,{ref:s,className:Kt("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",e),...t,children:a.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));pd.displayName=we.Indicator.displayName;const hd=({className:e,...t})=>a.jsx("nav",{role:"navigation","aria-label":"pagination",className:Kt("mx-auto flex w-full justify-center",e),...t});hd.displayName="Pagination";const xd=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,className:Kt("flex flex-row items-center gap-1",e),...t}));xd.displayName="PaginationContent";const fd=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,className:Kt("",e),...t}));fd.displayName="PaginationItem";const gd=({className:e,isActive:t,size:s="icon",...r})=>a.jsx("a",{"aria-current":t?"page":void 0,className:Kt(Qt({variant:t?"outline":"ghost",size:s}),e),...r});gd.displayName="PaginationLink";const vd=({className:t,...s})=>a.jsxs(gd,{"aria-label":e.t("go_to_previous_page"),size:"default",className:Kt("gap-1 pl-2.5",t),...s,children:[a.jsx(d.ChevronLeft,{className:"h-4 w-4"}),a.jsx("span",{children:"Previous"})]});vd.displayName="PaginationPrevious";const bd=({className:t,...s})=>a.jsxs(gd,{"aria-label":e.t("go_to_next_page"),size:"default",className:Kt("gap-1 pr-2.5",t),...s,children:[a.jsx("span",{children:"Next"}),a.jsx(d.ChevronRight,{className:"h-4 w-4"})]});bd.displayName="PaginationNext";const yd=({className:e,...t})=>a.jsxs("span",{"aria-hidden":!0,className:Kt("flex h-9 w-9 items-center justify-center",e),...t,children:[a.jsx(d.MoreHorizontal,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"More pages"})]});yd.displayName="PaginationEllipsis";const jd=ae.forwardRef(({className:e,value:t,...s},r)=>a.jsx(Ne.Root,{ref:r,className:Kt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:a.jsx(Ne.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));jd.displayName=Ne.Root.displayName;const wd=ae.forwardRef(({className:e,...t},s)=>a.jsx(_e.Root,{className:Kt("grid gap-2",e),...t,ref:s}));wd.displayName=_e.Root.displayName;const Nd=ae.forwardRef(({className:e,...t},s)=>a.jsx(_e.Item,{ref:s,className:Kt("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",e),...t,children:a.jsx(_e.Indicator,{className:"flex items-center justify-center",children:a.jsx(d.Circle,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Nd.displayName=_e.Item.displayName;const _d=Ce.Panel,Cd=re.Root,kd=re.Trigger,Sd=re.Close,Td=re.Portal,Pd=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Overlay,{className:Kt("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",e),...t,ref:s}));Pd.displayName=re.Overlay.displayName;const Ed=r.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"}}),Dd=ae.forwardRef(({side:e="right",className:t,children:s,...r},n)=>a.jsxs(Td,{children:[a.jsx(Pd,{}),a.jsxs(re.Content,{ref:n,className:Kt(Ed({side:e}),t),...r,children:[s,a.jsxs(re.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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dd.displayName=re.Content.displayName;const Ad=({className:e,showSeparator:t=!1,children:s,...r})=>a.jsxs("div",{className:Kt("flex flex-col flex-shrink-0",e),...r,children:[a.jsx("div",{className:"flex flex-col text-left",children:s}),t&&a.jsx(ls,{className:"mt-2"})]});Ad.displayName="SheetHeader";const Id=({className:e,...t})=>a.jsx("div",{className:Kt("flex-1 min-h-0 overflow-auto py-4 px-1 -mx-1",e),...t});Id.displayName="SheetBody";const Md=({className:e,children:t,...s})=>a.jsxs("div",{className:"flex-shrink-0 pt-4",children:[a.jsx(ls,{className:"mb-4"}),a.jsx("div",{className:Kt("flex flex-row justify-end gap-2",e),...s,children:t})]});Md.displayName="SheetFooter";const Fd=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Title,{ref:s,className:Kt("text-lg font-semibold text-foreground",e),...t}));Fd.displayName=re.Title.displayName;const Rd=ae.forwardRef(({className:e,...t},s)=>a.jsx(re.Description,{ref:s,className:Kt("text-sm text-muted-foreground",e),...t}));Rd.displayName=re.Description.displayName;const Ld="sidebar:state",zd=ae.createContext(null);function Ud(){const e=ae.useContext(zd);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Od=ae.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:s,className:r,style:n,children:o,...i},l)=>{const d=Fn(),[c,u]=ae.useState(!1),[m,p]=ae.useState(()=>{if("undefined"!=typeof window){const a=localStorage.getItem(Ld);return null!==a?"true"===a:e}return e}),h=t??m,x=ae.useCallback(e=>{const a="function"==typeof e?e(h):e;s?s(a):p(a),"undefined"!=typeof window&&localStorage.setItem(Ld,String(a))},[s,h]),f=ae.useCallback(()=>d?u(e=>!e):x(e=>!e),[d,x,u]);ae.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f]);const g=h?"expanded":"collapsed",v=ae.useMemo(()=>({state:g,open:h,setOpen:x,isMobile:d,openMobile:c,setOpenMobile:u,toggleSidebar:f}),[g,h,x,d,c,u,f]);return a.jsx(zd.Provider,{value:v,children:a.jsx(yr,{delayDuration:0,children:a.jsx("div",{className:Kt("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})})})});Od.displayName="SidebarProvider";const Vd=ae.forwardRef(({side:e="left",variant:t="sidebar",collapsible:s="offcanvas",className:r,children:n,...o},i)=>{const{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=Ud();return"none"===s?a.jsx("div",{className:Kt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...o,children:n}):l?a.jsx(Cd,{open:c,onOpenChange:u,...o,children:a.jsxs(Dd,{"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:e,children:[a.jsx(Fd,{className:"sr-only",children:"Menu de Navegação"}),a.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):a.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":"collapsed"===d?s:"","data-variant":t,"data-side":e,children:[a.jsx("div",{className:Kt("duration-200 relative h-[calc(100svh-var(--header-height,0px))] w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),a.jsx("div",{className:Kt("duration-200 fixed z-30 hidden w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex overflow-visible","top-[var(--header-height,0px)] h-[calc(100svh-var(--header-height,0px))]","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...o,children:a.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})})]})});Vd.displayName="Sidebar";const Bd=ae.forwardRef(({className:e,onClick:t,...s},r)=>{const{toggleSidebar:n}=Ud();return a.jsxs(Xt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Kt("h-7 w-7",e),onClick:e=>{t?.(e),n()},...s,children:[a.jsx(d.PanelLeft,{}),a.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Bd.displayName="SidebarTrigger";const qd=ae.forwardRef(({className:e,...t},s)=>{const{toggleSidebar:r}=Ud();return a.jsx("button",{ref:s,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Kt("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",e),...t})});qd.displayName="SidebarRail";const $d=ae.forwardRef(({className:e,...t},s)=>a.jsx("main",{ref:s,className:Kt("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",e),...t}));$d.displayName="SidebarInset";const Wd=ae.forwardRef(({className:e,...t},s)=>a.jsx(Zt,{ref:s,"data-sidebar":"input",className:Kt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Wd.displayName="SidebarInput";const Hd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"header",className:Kt("flex flex-col gap-2 p-2",e),...t}));Hd.displayName="SidebarHeader";const Gd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"footer",className:Kt("flex flex-col gap-2 p-2",e),...t}));Gd.displayName="SidebarFooter";const Kd=ae.forwardRef(({className:e,...t},s)=>a.jsx(ls,{ref:s,"data-sidebar":"separator",className:Kt("mx-2 w-auto bg-sidebar-border",e),...t}));Kd.displayName="SidebarSeparator";const Yd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"content",className:Kt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Yd.displayName="SidebarContent";const Qd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group",className:Kt("relative flex w-full min-w-0 flex-col p-2",e),...t}));Qd.displayName="SidebarGroup";const Xd=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"div";return a.jsx(o,{ref:n,"data-sidebar":"group-label",className:Kt("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",e),...r})});Xd.displayName="SidebarGroupLabel";const Jd=ae.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?s.Slot:"button";return a.jsx(o,{ref:n,"data-sidebar":"group-action",className:Kt("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",e),...r})});Jd.displayName="SidebarGroupAction";const Zd=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"group-content",className:Kt("w-full text-sm",e),...t}));Zd.displayName="SidebarGroupContent";const ec=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu",className:Kt("flex w-full min-w-0 flex-col gap-1",e),...t}));ec.displayName="SidebarMenu";const ac=ae.forwardRef(({className:e,...t},s)=>a.jsx("li",{ref:s,"data-sidebar":"menu-item",className:Kt("group/menu-item relative",e),...t}));ac.displayName="SidebarMenuItem";const tc=r.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"}}),sc=ae.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:n="default",tooltip:o,className:i,...l},d)=>{const c=e?s.Slot:"button",{isMobile:u,state:m}=Ud(),p=a.jsx(c,{ref:d,"data-sidebar":"menu-button","data-size":n,"data-active":t,className:Kt(tc({variant:r,size:n}),i),...l});return o?("string"==typeof o&&(o={children:o}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:p}),a.jsx(Nr,{side:"right",align:"center",hidden:"collapsed"!==m||u,...o})]})):p});sc.displayName="SidebarMenuButton";const rc=ae.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...n},o)=>{const i=t?s.Slot:"button";return a.jsx(i,{ref:o,"data-sidebar":"menu-action",className:Kt("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",e),...n})});rc.displayName="SidebarMenuAction";const nc=ae.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,"data-sidebar":"menu-badge",className:Kt("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",e),...t}));nc.displayName="SidebarMenuBadge";const oc=ae.forwardRef(({className:e,showIcon:t=!1,...s},r)=>{const n=ae.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return a.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:Kt("rounded-md h-8 flex gap-2 px-2 items-center",e),...s,children:[t&&a.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),a.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});oc.displayName="SidebarMenuSkeleton";const ic=ae.forwardRef(({className:e,...t},s)=>a.jsx("ul",{ref:s,"data-sidebar":"menu-sub",className:Kt("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",e),...t}));ic.displayName="SidebarMenuSub";const lc=ae.forwardRef(({...e},t)=>a.jsx("li",{ref:t,...e}));lc.displayName="SidebarMenuSubItem";const dc=ae.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:n,...o},i)=>{const l=e?s.Slot:"a";return a.jsx(l,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:Kt("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"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});dc.displayName="SidebarMenuSubButton";const cc=ae.forwardRef(({className:e,value:t,defaultValue:s,...r},n)=>{const o=t||s||[0];return a.jsxs(ke.Root,{ref:n,value:t,defaultValue:s,className:Kt("relative flex w-full touch-none select-none items-center",e),...r,children:[a.jsx(ke.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:a.jsx(ke.Range,{className:"absolute h-full bg-primary"})}),o.map((e,t)=>a.jsx(ke.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},t))]})});cc.displayName=ke.Root.displayName;const uc=Se.Menu,mc=Se.Group,pc=Se.Portal,hc=Se.Sub,xc=Se.RadioGroup,fc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Root,{ref:s,className:Kt("flex h-10 items-center space-x-1 rounded-md border bg-background p-1",e),...t}));fc.displayName=Se.Root.displayName;const gc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Trigger,{ref:s,className:Kt("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",e),...t}));gc.displayName=Se.Trigger.displayName;const vc=ae.forwardRef(({className:e,inset:t,children:s,...r},n)=>a.jsxs(Se.SubTrigger,{ref:n,className:Kt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...r,children:[s,a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4"})]}));vc.displayName=Se.SubTrigger.displayName;const bc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.SubContent,{ref:s,className:Kt("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",e),...t}));bc.displayName=Se.SubContent.displayName;const yc=ae.forwardRef(({className:e,align:t="start",alignOffset:s=-4,sideOffset:r=8,...n},o)=>a.jsx(Se.Portal,{children:a.jsx(Se.Content,{ref:o,align:t,alignOffset:s,sideOffset:r,className:Kt("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",e),...n})}));yc.displayName=Se.Content.displayName;const jc=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Item,{ref:r,className:Kt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));jc.displayName=Se.Item.displayName;const wc=ae.forwardRef(({className:e,children:t,checked:s,...r},n)=>a.jsxs(Se.CheckboxItem,{ref:n,className:Kt("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",e),checked:s,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Check,{className:"h-4 w-4"})})}),t]}));wc.displayName=Se.CheckboxItem.displayName;const Nc=ae.forwardRef(({className:e,children:t,...s},r)=>a.jsxs(Se.RadioItem,{ref:r,className:Kt("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",e),...s,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Se.ItemIndicator,{children:a.jsx(d.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Nc.displayName=Se.RadioItem.displayName;const _c=ae.forwardRef(({className:e,inset:t,...s},r)=>a.jsx(Se.Label,{ref:r,className:Kt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));_c.displayName=Se.Label.displayName;const Cc=ae.forwardRef(({className:e,...t},s)=>a.jsx(Se.Separator,{ref:s,className:Kt("-mx-1 my-1 h-px bg-muted",e),...t}));Cc.displayName=Se.Separator.displayName;const kc=({className:e,...t})=>a.jsx("span",{className:Kt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});kc.displayname="MenubarShortcut";const Sc={light:"",dark:".dark"},Tc=ae.createContext(null);function Pc(){const e=ae.useContext(Tc);if(!e)throw new Error("useChart must be used within a <ChartContainer />");return e}const Ec=ae.forwardRef(({id:e,className:t,children:s,config:r,...n},o)=>{const i=ae.useId(),l=`chart-${e||i.replace(/:/g,"")}`;return a.jsx(Tc.Provider,{value:{config:r},children:a.jsxs("div",{"data-chart":l,ref:o,className:Kt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",t),...n,children:[a.jsx(Dc,{id:l,config:r}),a.jsx(Te.ResponsiveContainer,{children:s})]})})});Ec.displayName="Chart";const Dc=({id:e,config:t})=>{const s=Object.entries(t).filter(([,e])=>e.theme||e.color);return s.length?a.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Sc).map(([a,t])=>`\n${t} [data-chart=${e}] {\n${s.map(([e,t])=>{const s=t.theme?.[a]||t.color;return s?` --color-${e}: ${s};`:null}).join("\n")}\n}\n`).join("\n")}}):null},Ac=Te.Tooltip,Ic=ae.forwardRef(({active:e,payload:t,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:x}=Pc(),f=ae.useMemo(()=>{if(n||!t?.length)return null;const[e]=t,s=Rc(x,e,`${p||e?.dataKey||e?.name||"value"}`),r=p||"string"!=typeof i?s?.label:x[i]?.label||i;return l?a.jsx("div",{className:Kt("font-medium",d),children:l(r,t)}):r?a.jsx("div",{className:Kt("font-medium",d),children:r}):null},[i,l,t,n,d,x,p]);if(!e||!t?.length)return null;const g=1===t.length&&"dot"!==r;return a.jsxs("div",{ref:h,className:Kt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",s),children:[g?null:f,a.jsx("div",{className:"grid gap-1.5",children:t.map((e,t)=>{const s=`${m||e.name||e.dataKey||"value"}`,n=Rc(x,e,s),i=u||e.payload?.fill||e.color;return a.jsx("div",{className:Kt("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!==e?.value&&e.name?c(e.value,e.name,e,t,e.payload):a.jsxs(a.Fragment,{children:[n?.icon?a.jsx(n.icon,{}):!o&&a.jsx("div",{className:Kt("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}}),a.jsxs("div",{className:Kt("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[a.jsxs("div",{className:"grid gap-1.5",children:[g?f:null,a.jsx("span",{className:"text-muted-foreground",children:n?.label||e.name})]}),void 0!==e.value&&a.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString():e.value})]})]})},e.dataKey||t)})})]})});Ic.displayName="ChartTooltip";const Mc=Te.Legend,Fc=ae.forwardRef(({className:e,hideIcon:t=!1,payload:s,verticalAlign:r="bottom",nameKey:n},o)=>{const{config:i}=Pc();return s?.length?a.jsx("div",{ref:o,className:Kt("flex items-center justify-center gap-4","top"===r?"pb-3":"pt-3",e),children:s.map(e=>{const s=`${n||e.dataKey||"value"}`,r=Rc(i,e,s);return a.jsxs("div",{className:Kt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[r?.icon&&!t?a.jsx(r.icon,{}):a.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:e.color}}),r?.label]},e.value)})}):null});function Rc(e,a,t){if("object"!=typeof a||null===a)return;const s="payload"in a&&"object"==typeof a.payload&&null!==a.payload?a.payload:void 0;let r=t;return t in a&&"string"==typeof a[t]?r=a[t]:s&&t in s&&"string"==typeof s[t]&&(r=s[t]),r in e?e[r]:e[t]}Fc.displayName="ChartLegend";const Lc=({onClick:e,isActive:t,disabled:s,children:r,title:n})=>a.jsx("button",{type:"button",onClick:e,disabled:s,title:n,className:Kt("p-1.5 rounded hover:bg-muted transition-colors",t?"bg-muted text-primary":"text-muted-foreground",s&&"opacity-50 cursor-not-allowed"),children:r}),zc=()=>a.jsx("div",{className:"w-px h-5 bg-border mx-1"});function Uc({image:e,title:t,className:s}){return a.jsx("div",{className:Kt("relative w-full aspect-video bg-muted rounded-lg overflow-hidden","max-h-[25vh] sm:max-h-[35vh]",s),children:e?a.jsx("img",{src:e,alt:t,className:"w-full h-full object-cover"}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(d.ImageIcon,{className:"w-16 h-16 text-muted-foreground"})})})}function Oc({steps:e,currentStepIndex:t,onStepSelect:s,stepLabel:r,className:n}){const{t:o}=y.useTranslation(),i=e.length,l=(t+1)/i*100;return a.jsxs("div",{className:Kt("flex items-center gap-3",n),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-8 px-2 text-sm",children:[r," ",t+1,"/",i,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:e.map((e,r)=>a.jsxs(hr,{onClick:()=>s(r),className:Kt(r===t&&"bg-accent"),children:[r+1,". ",e.title]},e.id))})]}),a.jsx(jd,{value:l,className:"w-32 h-2"})]})}function Vc({currentStepIndex:e,totalSteps:t,onBack:s,onNext:r,onComplete:n,backButtonText:o,continueButtonText:i,finishButtonText:l,className:c}){const{t:u}=y.useTranslation(),m=0===e,p=e===t-1;return a.jsxs("div",{className:Kt("flex items-center gap-2",c),children:[!m&&a.jsxs(Xt,{variant:"outline",onClick:s,size:"sm",children:[a.jsx(d.ArrowLeft,{className:"h-4 w-4 mr-2"}),o]}),a.jsxs(Xt,{onClick:p?n:r,size:"sm",children:[p?l:i,!p&&a.jsx(d.ArrowRight,{className:"h-4 w-4 ml-2"})]})]})}const Bc=ae.forwardRef(({open:t,onOpenChange:s,steps:r,onComplete:n,onStepChange:o,continueButtonText:i="Continuar",backButtonText:l="Voltar",finishButtonText:c="Concluir",stepLabel:u=e.t("approval_step_label"),size:m="md",showProgressIndicator:p=!0,currentStepIndex:h,onCurrentStepChange:x,className:f},g)=>{const[v,b]=ae.useState(0),y=void 0!==h,j=y?h:v,w=ae.useCallback(e=>{y?x?.(e):b(e),o?.(e)},[y,x,o]);ae.useEffect(()=>{t||y||b(0)},[t,y]);const N=r[j],_=r.length;return N?a.jsx(ys,{open:t,onOpenChange:s,children:a.jsxs(ks,{ref:g,size:m,variant:"informative",className:Kt("p-0 gap-0 overflow-hidden",f),children:[a.jsxs(Ns,{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:[a.jsx(d.X,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Fechar"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx(Uc,{image:N.image,title:N.title}),a.jsx(Es,{className:"text-xl font-semibold",children:N.title}),a.jsx(Ds,{className:"text-muted-foreground",children:N.description})]})}),a.jsxs("div",{className:"flex-shrink-0",children:[a.jsx(ls,{}),a.jsxs("div",{className:"p-4 flex flex-wrap items-center justify-between gap-2",children:[p&&_>1?a.jsx(Oc,{steps:r,currentStepIndex:j,onStepSelect:e=>{w(e)},stepLabel:u}):a.jsx("div",{}),a.jsx(Vc,{currentStepIndex:j,totalSteps:_,onBack:()=>{j>0&&w(j-1)},onNext:()=>{j<_-1&&w(j+1)},onComplete:()=>{n?.(),s(!1)},backButtonText:l,continueButtonText:i,finishButtonText:c})]})]})]})}):null});function qc({label:e,onClick:t,icon:s,actions:r=[],variant:n="default",size:o="default",disabled:i=!1,loading:l=!1,menuAlign:c="end",className:u}){const{t:m}=y.useTranslation(),p=i||l;if(!(r.length>0))return a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:u,children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]});return a.jsxs("div",{className:Kt("inline-flex rounded-md shadow-sm",u),children:[a.jsxs(Xt,{variant:n,size:o,disabled:p,onClick:t,className:"rounded-r-none border-r-0 focus:z-10",children:[l?a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):s?a.jsx(s,{className:"mr-2 h-4 w-4"}):null,e]}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:n,size:o,disabled:p,className:Kt("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":m("more_options"),children:a.jsx(d.ChevronDown,{className:{sm:"h-3 w-3",default:"h-4 w-4",lg:"h-4 w-4"}[o]})})}),a.jsx(pr,{align:c,className:"min-w-[160px]",children:r.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:Kt("destructive"===e.variant&&"text-destructive focus:text-destructive"),children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})]})}var $c;Bc.displayName="OnboardingDialog",exports.ExportFormat=void 0,($c=exports.ExportFormat||(exports.ExportFormat={})).CSV="csv",$c.PDF="pdf",$c.XLSX="xlsx",$c.PNG="png",$c.JPEG="jpeg",$c.SVG="svg";const Wc=[{value:exports.ExportFormat.CSV,label:"CSV",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})},{value:exports.ExportFormat.XLSX,label:"XLSX",icon:a.jsx(d.FileSpreadsheet,{className:"h-5 w-5"})}],Hc=[{value:exports.ExportFormat.PNG,label:"PNG",icon:a.jsx(d.Image,{className:"h-5 w-5"})},{value:exports.ExportFormat.JPEG,label:"JPEG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.SVG,label:"SVG",icon:a.jsx(d.FileImage,{className:"h-5 w-5"})},{value:exports.ExportFormat.PDF,label:"PDF",icon:a.jsx(d.FileText,{className:"h-5 w-5"})}];const Gc=t.forwardRef(({value:e,onChange:s,onTimeChange:r,label:n,error:o,format:i="24h",className:l,id:c,...u},m)=>{const p=c??ae.useId(),h=t.useCallback(e=>{const a=e.target.value;s?.(a),r?.(a)},[s,r]),x=t.useCallback(e=>{["0","1","2","3","4","5","6","7","8","9","Backspace","Tab",":","ArrowLeft","ArrowRight","Delete"].includes(e.key)||e.preventDefault()},[]);return a.jsxs("div",{className:Kt("grid gap-1.5",l),children:[n&&a.jsx(as,{htmlFor:p,children:n}),a.jsxs("div",{className:"relative",children:[a.jsx(Zt,{ref:m,id:p,type:"time",value:e??"",onChange:h,onKeyDown:x,min:"00:00",max:"23:59",step:60,className:Kt("pr-9",o&&"border-destructive focus-visible:ring-destructive"),...u}),a.jsx(d.Clock,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})});function Kc({currentStep:e,totalSteps:t,onStepChange:s,stepLabels:r,canGoToStep:n,className:o,progressWidth:i="w-32"}){ae.useEffect(()=>{process.env.NODE_ENV},[]);const l=Array.from({length:t},(e,a)=>a+1),c=a=>!(a<=e)&&(!!n&&!n(a));return a.jsxs("div",{className:Kt("flex items-center gap-3",o),children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 text-sm text-muted-foreground hover:text-foreground",children:["Etapa ",e,"/",t,a.jsx(d.ChevronDown,{className:"h-3 w-3 ml-1"})]})}),a.jsx(pr,{align:"start",children:l.map(t=>a.jsxs(hr,{onClick:()=>{var a;(a=t)<e?s(a):n&&!n(a)||s(a)},disabled:c(t),className:Kt("cursor-pointer",t===e&&"bg-muted font-medium",c(t)&&"opacity-50 cursor-not-allowed"),children:[a.jsxs("span",{className:"mr-2 text-muted-foreground",children:[t,"."]}),r?.[t-1]||`Etapa ${t}`,t===e&&a.jsx(d.Check,{className:"h-4 w-4 ml-auto"})]},t))})]}),a.jsx(jd,{value:e/t*100,className:Kt("h-2",i)})]})}function Yc(e){const a=an.getAccessToken(),t={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},"un-alias":e};if(a)try{const e=JSON.parse(atob(a.split(".")[1]));e.sub&&(t["x-waf-rate"]=btoa(e.sub))}catch{}return t}async function Qc(e,a,t){let s=await fetch(e,a);if(401===s.status){if(await hn.handleApiError({status:401})){const r={...a,headers:Yc(t)};s=await fetch(e,r)}}return s}function Xc(e){const[a,s]=t.useState([]),[r,n]=t.useState(0),[o,i]=t.useState(!1);t.useEffect(()=>{if(!e)return;let a=!1;const t=`${Oe().replace(/\/?$/,"/")}api/common/v1/updates/listUpdatesNotification`;return async function(){i(!0);try{const r=Yc(e),o=await Qc(t,{method:"GET",headers:r},e);if(!o.ok)return;const i=await o.json();!a&&i.data?.[0]&&(s(i.data[0].updates??[]),n(i.data[0].valueBadge??0))}catch(r){}finally{a||i(!1)}}(),()=>{a=!0}},[e]);const l=t.useCallback(async()=>{if(!e||r<=0||0===a.length)return;const t=a[0].id,s=`${Oe().replace(/\/?$/,"/")}api/common/v1/Updates/userVisualized/3/undefined`;n(0);try{const a=Yc(e),r=JSON.stringify({id:t,idUpdateType:3});await Qc(s,{method:"POST",headers:a,body:r},e)}catch(o){}},[e,r,a]);return{updates:a,badgeCount:r,loading:o,markAsVisualized:l}}Gc.displayName="Timepicker";const Jc=t.forwardRef(({updates:t,badgeCount:s,onOpen:r,onViewAll:n},o)=>{const i=void 0===t,l=An(),c=l?.alias??null,u=Xc(i?c:null),m=i?u.updates??[]:t,p=i?u.badgeCount??0:s??0,h=r??(i?u.markAsVisualized:void 0),x=n??(i&&c?()=>{const e=`https://apps4.qualiex.com/common/${c}/up/view`;window.open(e,"_blank","noopener,noreferrer")}:void 0);return a.jsxs(Cr,{children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{ref:o,variant:"ghost",size:"sm",className:"relative h-9 w-9 p-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:h,title:e.t("updates"),children:[a.jsx(d.Coffee,{className:"h-7 w-7"}),p>0&&a.jsx("span",{className:"absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:p>99?"99+":p})]})}),a.jsxs(Sr,{align:"end",className:"w-80 p-0",children:[a.jsx("div",{className:"border-b border-border px-4 py-3",children:a.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Atualizações"})}),a.jsx("div",{className:"max-h-72 overflow-y-auto",children:m.length>0?a.jsx("ul",{className:"divide-y divide-border",children:m.map(e=>a.jsxs("li",{className:"px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer",onClick:x,children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.text})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[a.jsx(d.Coffee,{className:"h-8 w-8 text-muted-foreground mb-2"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum café quentinho, ou melhor, atualização quentinha no momento!"})]})}),a.jsx("div",{className:"border-t border-border px-4 py-2",children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"w-full justify-between text-primary hover:text-primary",onClick:x,children:["Ver todas as atualizações",a.jsx(d.ArrowRight,{className:"h-[18px] w-[18px]"})]})})]})]})});var Zc,eu;Jc.displayName="UpdatesNotification",exports.FileViewerType=void 0,(Zc=exports.FileViewerType||(exports.FileViewerType={}))[Zc.none=0]="none",Zc[Zc.image=1]="image",Zc[Zc.video=2]="video",Zc[Zc.audio=3]="audio",Zc[Zc.wopi=4]="wopi",Zc[Zc.onlineEditor=5]="onlineEditor",Zc[Zc.report=6]="report",exports.FilePrintType=void 0,(eu=exports.FilePrintType||(exports.FilePrintType={}))[eu.SimplePrint=0]="SimplePrint",eu[eu.ManagedCopy=1]="ManagedCopy",eu[eu.NonManagedCopy=2]="NonManagedCopy";const au={".jpg":exports.FileViewerType.image,".jpeg":exports.FileViewerType.image,".png":exports.FileViewerType.image,".bmp":exports.FileViewerType.image,".gif":exports.FileViewerType.image,".svg":exports.FileViewerType.image,".webp":exports.FileViewerType.image,".wav":exports.FileViewerType.audio,".mp3":exports.FileViewerType.audio,".mp4":exports.FileViewerType.video,".webm":exports.FileViewerType.video,".ogg":exports.FileViewerType.video,".pdf":exports.FileViewerType.wopi,".ods":exports.FileViewerType.wopi,".xls":exports.FileViewerType.wopi,".xlsb":exports.FileViewerType.wopi,".xlsm":exports.FileViewerType.wopi,".xlsx":exports.FileViewerType.wopi,".doc":exports.FileViewerType.wopi,".docm":exports.FileViewerType.wopi,".docx":exports.FileViewerType.wopi,".dot":exports.FileViewerType.wopi,".dotm":exports.FileViewerType.wopi,".dotx":exports.FileViewerType.wopi,".odt":exports.FileViewerType.wopi,".odp":exports.FileViewerType.wopi,".pot":exports.FileViewerType.wopi,".potm":exports.FileViewerType.wopi,".potx":exports.FileViewerType.wopi,".pps":exports.FileViewerType.wopi,".ppsm":exports.FileViewerType.wopi,".ppsx":exports.FileViewerType.wopi,".ppt":exports.FileViewerType.wopi,".pptm":exports.FileViewerType.wopi,".pptx":exports.FileViewerType.wopi,".gdocs":exports.FileViewerType.onlineEditor,".gsheets":exports.FileViewerType.onlineEditor};function tu(e){const{t:a}=y.useTranslation();return e?au[e.toLowerCase()]??exports.FileViewerType.none:exports.FileViewerType.none}const su={".pdf":"wv/wordviewerframe.aspx?PdfMode=1&",".xls":"x/_layouts/xlviewerinternal.aspx?",".xlsb":"x/_layouts/xlviewerinternal.aspx?",".xlsm":"x/_layouts/xlviewerinternal.aspx?",".xlsx":"x/_layouts/xlviewerinternal.aspx?",".ods":"x/_layouts/xlviewerinternal.aspx?",".doc":"wv/wordviewerframe.aspx?",".docm":"wv/wordviewerframe.aspx?",".docx":"wv/wordviewerframe.aspx?",".dot":"wv/wordviewerframe.aspx?",".dotm":"wv/wordviewerframe.aspx?",".dotx":"wv/wordviewerframe.aspx?",".odt":"wv/wordviewerframe.aspx?",".ppt":"p/PowerPointFrame.aspx?",".pptm":"p/PowerPointFrame.aspx?",".pptx":"p/PowerPointFrame.aspx?",".pot":"p/PowerPointFrame.aspx?",".potm":"p/PowerPointFrame.aspx?",".potx":"p/PowerPointFrame.aspx?",".pps":"p/PowerPointFrame.aspx?",".ppsm":"p/PowerPointFrame.aspx?",".ppsx":"p/PowerPointFrame.aspx?",".odp":"p/PowerPointFrame.aspx?"};function ru(e){const{t:a}=y.useTranslation();return su[e?.toLowerCase()]||""}function nu(e){const{t:a}=y.useTranslation(),t=e%60;return`${Math.floor(e/60)}min ${t<10?"0":""}${t}`}function ou({open:e,onOpenChange:s,url:r,title:n,className:o,minHeight:i="250px"}){const{t:l}=y.useTranslation(),c=t.useCallback(()=>{s(!1)},[s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&c()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,c]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Kt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",o),children:[a.jsxs("div",{className:"flex items-center justify-end mb-2.5",children:[n&&a.jsx("h2",{className:"text-lg font-medium text-foreground truncate mr-auto",children:n}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]}),a.jsx("iframe",{src:r,className:"border-none w-full",style:{minHeight:i},title:n||l("embedded_content")})]})})}function iu({term:s,open:r,onClose:n,onSign:o,viewOnly:i=!1,title:l=e.t("terms_of_use"),signLabel:c=e.t("terms_read_agree")}){const u=t.useMemo(()=>s.file?function(e,a=""){const{t:t}=y.useTranslation(),s=atob(e),r=[];for(let o=0;o<s.length;o+=512){const e=s.slice(o,o+512),a=new Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t);r.push(new Uint8Array(a))}const n=new Blob(r,{type:a});return URL.createObjectURL(n)}(s.file,s.type):null,[s.file,s.type]),m=t.useCallback(()=>{u&&URL.revokeObjectURL(u),n()},[u,n]),p=t.useCallback(()=>{s.hasUserSignature?m():o?.(s.id)},[s,o,m]),h=!i&&!s.hasUserSignature&&o;return a.jsx(ys,{open:r,onOpenChange:e=>!e&&m(),children:a.jsxs(ks,{className:Kt("flex flex-col p-0 sm:max-w-[80vw] h-[95vh]","[&>button.absolute]:hidden"),children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[a.jsx(d.FileText,{className:"h-5 w-5 text-primary"}),l]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsx(Xt,{size:"sm",onClick:p,children:c}),a.jsx(Xt,{variant:"ghost",size:"icon",onClick:m,children:a.jsx(d.X,{className:"h-4 w-4"})})]})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s.file&&u?a.jsx("iframe",{className:"h-full w-full border-0",src:u,title:l}):a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a.jsx("p",{children:"Nenhum termo de uso ativo encontrado."})})})]})})}function lu(e){return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function du(e){const{t:a}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function cu(e){const{t:a}=y.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.allowedIds?.forEach(e=>t.add(e)),s.inheritedIds?.forEach(e=>t.add(e));return t}var uu;exports.ReportRequestStatus=void 0,(uu=exports.ReportRequestStatus||(exports.ReportRequestStatus={}))[uu.WaitingProcessing=1]="WaitingProcessing",uu[uu.Processing=2]="Processing",uu[uu.Completed=3]="Completed",uu[uu.Error=4]="Error",uu[uu.Expired=5]="Expired";const mu={report:e.t("report"),status:e.t("status"),requestDate:e.t("request_date"),lastUpdate:e.t("last_update"),expirationDate:e.t("expiration_date"),viewReport:e.t("view_report"),searchPlaceholder:e.t("search_report_placeholder"),noResults:e.t("no_reports_found"),statusWaiting:e.t("status_waiting"),statusProcessing:e.t("status_processing"),statusCompleted:e.t("status_completed"),statusError:e.t("status_error"),statusExpired:e.t("status_expired")};function pu(e){const{t:a}=y.useTranslation();return(e??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function hu(e){const{t:a}=y.useTranslation();return e.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const xu={sm:{badge:"px-1.5 py-0.5 text-[11px] gap-1",icon:14},md:{badge:"px-2.5 py-1 text-xs gap-1.5",icon:16},lg:{badge:"px-3 py-1.5 text-sm gap-2",icon:18}};function fu({label:e,color:t,icon:s,showIcon:r,size:n="md",variant:o="filled",backgroundColor:i,className:l}){const d=xu[n],c=r??!!s;return a.jsxs("span",{className:Kt("inline-flex items-center rounded-md font-medium whitespace-nowrap","outline"===o&&"border",d.badge,l),style:(()=>{switch(o){case"outline":return{color:t,borderColor:$t(t,.3),backgroundColor:"transparent"};case"ghost":return{color:t,backgroundColor:"transparent"};default:return{color:t,backgroundColor:i||$t(t,.1)}}})(),children:[c&&s&&a.jsx(s,{size:d.icon,strokeWidth:2}),e]})}var gu,vu,bu,yu,ju,wu,Nu,_u,Cu,ku,Su,Tu,Pu,Eu,Du,Au,Iu,Mu,Fu,Ru,Lu,zu,Uu,Ou,Vu;exports.AggregationType=void 0,(gu=exports.AggregationType||(exports.AggregationType={})).Count="valuecount",gu.Sum="sum",gu.Average="average",gu.DistinctCount="valuecount_distict",gu.Max="max",gu.Min="min",exports.AnalysisFunctionality=void 0,(exports.AnalysisFunctionality||(exports.AnalysisFunctionality={})).ViewAllAnalysis="nes3j6wn",exports.DashboardFunctionality=void 0,(vu=exports.DashboardFunctionality||(exports.DashboardFunctionality={})).RegisterDashboards="EeKs7CYA",vu.RemoveDashboards="3GKZYOQ9",vu.ViewAllDashboards="wYBdQNvZ",vu.EditDashboards="bMFcbwv4",exports.DashboardListType=void 0,(bu=exports.DashboardListType||(exports.DashboardListType={}))[bu.Default=1]="Default",bu[bu.Compact=2]="Compact",exports.DashboardPageTime=void 0,(yu=exports.DashboardPageTime||(exports.DashboardPageTime={}))[yu.FiveSeconds=1]="FiveSeconds",yu[yu.TenSeconds=2]="TenSeconds",yu[yu.FifteenSeconds=3]="FifteenSeconds",yu[yu.ThirtySeconds=4]="ThirtySeconds",yu[yu.OneMinute=5]="OneMinute",yu[yu.ThreeMinutes=6]="ThreeMinutes",yu[yu.FiveMinutes=7]="FiveMinutes",yu[yu.TenMinutes=8]="TenMinutes",exports.DashboardPanelDimension=void 0,(ju=exports.DashboardPanelDimension||(exports.DashboardPanelDimension={}))[ju.Day=1]="Day",ju[ju.Month=2]="Month",ju[ju.Year=3]="Year",exports.DashboardPanelOrderByType=void 0,(wu=exports.DashboardPanelOrderByType||(exports.DashboardPanelOrderByType={}))[wu.Ascending=1]="Ascending",wu[wu.Descending=2]="Descending",exports.DashboardPanelOrderBy=void 0,(Nu=exports.DashboardPanelOrderBy||(exports.DashboardPanelOrderBy={}))[Nu.Label=1]="Label",Nu[Nu.Value=2]="Value",exports.DashboardPanelPeriod=void 0,(_u=exports.DashboardPanelPeriod||(exports.DashboardPanelPeriod={}))[_u.LastSevenDays=1]="LastSevenDays",_u[_u.LastWeek=2]="LastWeek",_u[_u.LastMonth=3]="LastMonth",_u[_u.PreviousQuarter=4]="PreviousQuarter",_u[_u.PreviousSemester=5]="PreviousSemester",_u[_u.LastYear=6]="LastYear",_u[_u.SpecificPeriod=7]="SpecificPeriod",_u[_u.CurrentMonth=8]="CurrentMonth",_u[_u.CurrentSemester=9]="CurrentSemester",_u[_u.CurrentWeek=10]="CurrentWeek",_u[_u.CurrentYear=11]="CurrentYear",exports.DashboardPanelType=void 0,(Cu=exports.DashboardPanelType||(exports.DashboardPanelType={}))[Cu.Text=1]="Text",Cu[Cu.Area=2]="Area",Cu[Cu.Bar=3]="Bar",Cu[Cu.Column=4]="Column",Cu[Cu.StackedColumn=5]="StackedColumn",Cu[Cu.Line=6]="Line",Cu[Cu.List=7]="List",Cu[Cu.Numeric=8]="Numeric",Cu[Cu.Pareto=9]="Pareto",Cu[Cu.Pie=10]="Pie",Cu[Cu.RiskMatrix=11]="RiskMatrix",Cu[Cu.Burndown=12]="Burndown",Cu[Cu.PerformanceColumns=13]="PerformanceColumns",Cu[Cu.EvolutionLine=14]="EvolutionLine",exports.DashboardUpdateTime=void 0,(ku=exports.DashboardUpdateTime||(exports.DashboardUpdateTime={}))[ku.NotUpdate=1]="NotUpdate",ku[ku.FiveMinutes=2]="FiveMinutes",ku[ku.TenMinutes=3]="TenMinutes",ku[ku.FifteenMinutes=4]="FifteenMinutes",ku[ku.ThirtyMinutes=5]="ThirtyMinutes",ku[ku.OneHour=6]="OneHour",exports.DashboardViewType=void 0,(Su=exports.DashboardViewType||(exports.DashboardViewType={}))[Su.NormalPage=1]="NormalPage",Su[Su.Carousel=2]="Carousel",exports.DashboardFormTab=void 0,(Tu=exports.DashboardFormTab||(exports.DashboardFormTab={}))[Tu.General=0]="General",Tu[Tu.Share=1]="Share",exports.DashboardShareType=void 0,(Pu=exports.DashboardShareType||(exports.DashboardShareType={}))[Pu.NotShared=1]="NotShared",Pu[Pu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",Pu[Pu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.DashboardLanguage=void 0,(Eu=exports.DashboardLanguage||(exports.DashboardLanguage={})).PtBr="pt-br",Eu.EnUs="en",Eu.EsEs="es",exports.MatrixViewType=void 0,(Du=exports.MatrixViewType||(exports.MatrixViewType={}))[Du.Quantity=0]="Quantity",Du[Du.AllRisksList=1]="AllRisksList",exports.PanelItemsPerPanel=void 0,(Au=exports.PanelItemsPerPanel||(exports.PanelItemsPerPanel={}))[Au.Five=5]="Five",Au[Au.Ten=10]="Ten",Au[Au.Fifteen=15]="Fifteen",Au[Au.Twenty=20]="Twenty",Au[Au.All=0]="All",Au[Au.Custom=-1]="Custom",exports.PanelSortType=void 0,(Iu=exports.PanelSortType||(exports.PanelSortType={}))[Iu.AlphabeticalAsc=1]="AlphabeticalAsc",Iu[Iu.AlphabeticalDesc=2]="AlphabeticalDesc",Iu[Iu.CountAsc=3]="CountAsc",Iu[Iu.CountDesc=4]="CountDesc",Iu[Iu.DateAsc=5]="DateAsc",Iu[Iu.DateDesc=6]="DateDesc",exports.PanelState=void 0,(Mu=exports.PanelState||(exports.PanelState={}))[Mu.Loading=0]="Loading",Mu[Mu.Loaded=1]="Loaded",Mu[Mu.Error=3]="Error",Mu[Mu.NoData=4]="NoData",Mu[Mu.Unavailable=5]="Unavailable",exports.VisualizationType=void 0,(Fu=exports.VisualizationType||(exports.VisualizationType={}))[Fu.Quantity=1]="Quantity",Fu[Fu.Percentage=2]="Percentage",Fu[Fu.QuantityPercentage=3]="QuantityPercentage",exports.PlanType=void 0,(Ru=exports.PlanType||(exports.PlanType={}))[Ru.Program=1]="Program",Ru[Ru.Project=2]="Project",Ru[Ru.Action=3]="Action",Ru[Ru.PerformanceProject=4]="PerformanceProject",Ru[Ru.PerformanceAction=5]="PerformanceAction",exports.QueriesContextType=void 0,(Lu=exports.QueriesContextType||(exports.QueriesContextType={})).OccurrenceActionPlans="xebGnSSq",Lu.OccurrenceGeneral="UFws4AvH",Lu.PlansActionPlans="Kux6CcVC",Lu.PlansProgramProjects="UWjrp6Dw",Lu.PlansIdeas="3g7vNm2w",Lu.RisksGeneral="PZ4b6FhP",Lu.RisksActionPlans="xZErDg57",Lu.RisksAnalysis="UxsioMbH",Lu.RisksIncidences="gNt5IJ2F",Lu.MetrologyGeneral="4MfEPbRY",Lu.MetrologyActivities="hdFM9XQW",Lu.MetrologyServiceOrders="cIrVPdMv",Lu.DecisionsGeneral="CopsnHDB",Lu.DecisionsItems="qLFAayjx",Lu.DecisionsActionPlans="RiQFpxdb",Lu.FlowGeneral="AFV98JoG",Lu.AuditGeneral="gON8LJPi",Lu.AuditPlans="SsCNVOvr",Lu.AuditPlansItems="OpPkCCFm",Lu.AuditActionPlans="P1oGePhh",Lu.CommonGeneral="VVfEzgMQ",Lu.ActionPlans="C6Z4MgGa",Lu.SuppliersEvaluations="fSCeS4mH",Lu.SuppliersGeneral="8qPThkrD",Lu.SuppliersEvaluationsCriteria="RiSIStdY",Lu.SuppliersDocuments="Riua4jMa",Lu.SuppliersMaterialsServices="UpEkatXH",Lu.DocumentsGeneral="FRhhEX2J",Lu.DocumentsPhysicalCopies="PZLtJ23h",Lu.DocumentsObsolete="XDjbga14",Lu.FmeaGeneral="aPwf4uPr",Lu.FmeaActionPlans="vQ8PMrVX",exports.QueriesShareType=void 0,(zu=exports.QueriesShareType||(exports.QueriesShareType={}))[zu.NotShared=1]="NotShared",zu[zu.SharedWithAllCollaborators=2]="SharedWithAllCollaborators",zu[zu.SharedWithUsersGroupsPlacesCollaborators=3]="SharedWithUsersGroupsPlacesCollaborators",exports.QuickFilterDashboard=void 0,(Uu=exports.QuickFilterDashboard||(exports.QuickFilterDashboard={}))[Uu.All=1]="All",Uu[Uu.OnlyMine=2]="OnlyMine",Uu[Uu.Favorites=3]="Favorites",exports.RiskCriticality=void 0,(Ou=exports.RiskCriticality||(exports.RiskCriticality={}))[Ou.Current=1]="Current",Ou[Ou.Inherent=2]="Inherent",exports.PaletteType=void 0,(Vu=exports.PaletteType||(exports.PaletteType={}))[Vu.Default=1]="Default",Vu[Vu.Pastel=2]="Pastel",Vu[Vu.Vibrant=3]="Vibrant",Vu[Vu.Earth=4]="Earth",Vu[Vu.Ocean=5]="Ocean",Vu[Vu.Floral=6]="Floral",Vu[Vu.Night=7]="Night",Vu[Vu.Winter=8]="Winter",Vu[Vu.Spring=9]="Spring",Vu[Vu.Summer=10]="Summer",Vu[Vu.Fall=11]="Fall",Vu[Vu.Gray=12]="Gray",Vu[Vu.Brown=13]="Brown",Vu[Vu.Blue=14]="Blue",Vu[Vu.Yellow=15]="Yellow",Vu[Vu.Green=16]="Green",Vu[Vu.Purple=17]="Purple",Vu[Vu.Orange=18]="Orange",Vu[Vu.Pink=19]="Pink",Vu[Vu.Red=20]="Red";const Bu={jan:1,fev:2,mar:3,abr:4,mai:5,jun:6,jul:7,ago:8,set:9,out:10,nov:11,dez:12},qu=["total_calibration_cost","total_verification_cost","total_maintenance_cost","last_calibration_cost","last_verification_cost","last_maintenance_cost","total_cost","total_reported_cost","estimated_cost","last_report_cost_reported_cost","occurrence_reported_cost","task_estimated_cost"],$u=["link","link_risk","risk_link","link_group","group_link","link_occurrence","occurrence_link","link_audit","link_project","link_program","link_ideia","flow_link","decision_link","link_supplier","auditing_link","fmea_link"];function Wu(e){if(!e)return 0;const[a,t]=e.split("/"),s=Bu[a?.toLowerCase()]??0;return 12*(parseInt(t)||0)+s}function Hu(e){const a=e.split("/"),t=a[a.length-1];return`${a.slice(0,-1).join("/")}/${encodeURIComponent(t.replace(/[!@#$%^&*()_+={}[\]|\\;:'",.<>?/`~]/g,""))}`}function Gu(e){for(const a of $u)if(e[a])return e[a];return null}function Ku(e){const a=[];for(const t of Object.keys(e)){const s=e[t];null!=s&&(s instanceof Date?a.push(`${t}=${s.toISOString()}`):Array.isArray(s)?s.forEach(e=>{a.push(...Ku({[t]:e}))}):"string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s||a.push(`${t}=${s}`))}return a}const Yu=/^-?\d+(,\d{3})*(\.\d+)?$/;const Qu=new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"});const Xu=new Set([exports.DashboardPanelType.Text]),Ju=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.Numeric,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]),Zu=new Set([exports.DashboardPanelType.Text,exports.DashboardPanelType.RiskMatrix,exports.DashboardPanelType.Burndown,exports.DashboardPanelType.PerformanceColumns]);function em({config:e,viewOnly:s=!1,complement:r,complementPosition:n="before-options",queryUrlBuilder:o,onRefresh:i,onExport:l,onToggleOnlyMine:c,className:u}){const{t:m}=y.useTranslation(),[p,h]=t.useState(e.onlyMine??!1),x=Xu.has(e.typeId),f=!Ju.has(e.typeId),g=!Zu.has(e.typeId),v=t.useMemo(()=>{if(!e.jsonRules||e.typeId===exports.DashboardPanelType.PerformanceColumns)return!1;try{const a=JSON.parse(e.jsonRules);return a?.rules?.rules?.length>0}catch{return!1}},[e.jsonRules,e.typeId]),b=t.useMemo(()=>o?.(e)??"#",[o,e]),j=t.useCallback(()=>{const e=!p;h(e),c?.(e)},[p,c]),w=[];return p&&w.push(m("dashboard_only_mine")),e.onlyLate&&w.push(m("dashboard_only_overdue")),v&&w.push(m("dashboard_advanced_filter")),a.jsxs("div",{className:Kt("flex items-center justify-between gap-2 border-b bg-muted/30 px-2.5 py-1 text-sm font-medium",u),children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:["before-title"===n&&r,a.jsxs("div",{className:"flex min-w-0 flex-col",children:[a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:e.title})}),a.jsx(Nr,{children:e.title})]}),w.length>0&&a.jsx("span",{className:"text-[9px] font-normal text-muted-foreground truncate",children:w.join(" | ")})]}),"after-title"===n&&r]}),!s&&a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:["before-options"===n&&r,a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",children:a.jsx(d.MoreVertical,{className:"h-3.5 w-3.5"})})}),a.jsxs(pr,{align:"end",className:"w-48",children:[e.canUpdate&&a.jsxs(hr,{onClick:()=>e.onEdit?.(e.id),children:[a.jsx(d.Pencil,{className:"mr-2 h-3.5 w-3.5"}),"Editar"]}),!x&&a.jsxs(hr,{onClick:i,children:[a.jsx(d.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),"Atualizar"]}),f&&a.jsxs(hr,{disabled:e.noData,onClick:l,children:[a.jsx(d.Download,{className:"mr-2 h-3.5 w-3.5"}),"Exportar"]}),!x&&a.jsxs(hr,{disabled:!e.openQueryEnabled,onClick:()=>window.open(b,"_blank"),children:[a.jsx(d.ExternalLink,{className:"mr-2 h-3.5 w-3.5"}),"Abrir consulta"]}),g&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:j,children:[p&&a.jsx(d.Check,{className:"mr-2 h-3.5 w-3.5"}),!p&&a.jsx("span",{className:"mr-2 w-3.5"}),"Somente meus"]})]}),e.canUpdate&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>e.onDuplicate?.(e.id),children:[a.jsx(d.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Duplicar"]}),a.jsxs(hr,{className:"text-destructive",onClick:()=>e.onRemove?.(e.id),children:[a.jsx(d.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Remover"]})]})]})]}),"after-options"===n&&r]})]})}function am({config:e,queryUrl:t,className:s}){return a.jsxs("div",{className:Kt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"Erro ao exibir os dados."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"A consulta não pôde ser realizada."}),a.jsxs("p",{className:"mt-2 text-xs",children:[t&&a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:"Verificar a consulta"}),t&&e.canUpdate&&a.jsx("span",{className:"text-muted-foreground",children:" ou "}),e.canUpdate&&a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>e.onEdit?.(e.id),children:"revisar o painel"})]})]})}function tm({panelType:e,className:t}){const s=e===exports.DashboardPanelType.Burndown;return a.jsxs("div",{className:Kt("flex flex-1 flex-col items-center justify-center gap-2 p-4",t),children:[a.jsx(tr,{className:"h-10 w-10 text-muted-foreground/40"}),s&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Aguarde, processando dados..."})]})}function sm({hasRemovedColumn:t=!1,className:s}){return a.jsxs("div",{className:Kt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",s),children:[a.jsx("h2",{className:"text-lg font-normal text-foreground/80 lg:text-base",children:e.t("no_data_to_display")}),a.jsx("p",{className:"text-sm text-muted-foreground lg:text-xs",children:e.t("dashboard_no_data")})]})}function rm({onRemove:e,className:t}){return a.jsxs("div",{className:Kt("flex flex-1 flex-col items-center justify-center gap-1 p-4 text-center",t),children:[a.jsx(d.AlertTriangle,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsx("h2",{className:"mt-1 text-lg font-normal text-foreground/80",children:"A consulta não pôde ser realizada."}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Este recurso não está disponível."}),e&&a.jsx("p",{className:"mt-2 text-xs",children:a.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:e,children:"Remover painel"})})]})}const nm={[exports.AggregationType.Count]:e.t("dashboard_distinct_count").replace("distinta","").trim()||"Count",[exports.AggregationType.Sum]:"Sum",[exports.AggregationType.Average]:e.t("dashboard_average"),[exports.AggregationType.DistinctCount]:e.t("dashboard_distinct_count"),[exports.AggregationType.Max]:e.t("dashboard_max_value"),[exports.AggregationType.Min]:e.t("dashboard_min_value")};function om({config:e,state:t,value:s,label:r,viewOnly:n=!1,onClick:o,onRefresh:i,queryUrl:l,queryUrlBuilder:d,className:c}){const{t:u}=y.useTranslation(),m=r??nm[e.aggregationType??""]??"",p=function(e,a){if(null==e)return"—";const t=qu.includes(a.field),s=a.aggregationType===exports.AggregationType.Count||a.aggregationType===exports.AggregationType.DistinctCount;return t&&!s?Qu.format("string"==typeof e?parseFloat(e):e):"number"==typeof e?s?String(e):e.toLocaleString("pt-BR",{maximumFractionDigits:2}):String(e)}(s,e);return a.jsxs("div",{className:Kt("flex h-full flex-col",c),children:[a.jsx(em,{config:e,viewOnly:n,onRefresh:i,queryUrlBuilder:d}),t===exports.PanelState.Loading&&a.jsx(tm,{}),t===exports.PanelState.Loaded&&a.jsxs("div",{className:Kt("flex flex-1 flex-col items-center justify-center",o&&"cursor-pointer hover:bg-muted/20 transition-colors"),onClick:o,children:[a.jsx("span",{className:"text-[clamp(1.5rem,7vh,5rem)] font-bold text-foreground leading-tight",children:p}),m&&a.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:m})]}),t===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:l}),t===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function im({config:e,state:t,htmlContent:s,viewOnly:r=!1,onRefresh:n,queryUrl:o,queryUrlBuilder:i,className:l}){const d=s??e.textTypeString??"";return a.jsxs("div",{className:Kt("flex h-full flex-col",l),children:[a.jsx(em,{config:e,viewOnly:r,onRefresh:n,queryUrlBuilder:i}),t===exports.PanelState.Loading&&a.jsx(tm,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 prose prose-sm max-w-none text-foreground",dangerouslySetInnerHTML:{__html:d}}),t===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:o})]})}function lm({config:e,state:s,data:r=[],columns:n=[],viewOnly:o=!1,onRowClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,enableRowLinks:m=!0,className:p}){const h=t.useMemo(()=>n.filter(e=>!1!==e.visible),[n]),x=t.useCallback(e=>{if(i)i(e);else if(m){const a=Gu(e);a&&window.open(Hu(a),"_blank")}},[i,m]);return a.jsxs("div",{className:Kt("flex h-full flex-col",p),children:[a.jsx(em,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(tm,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 bg-muted/60 backdrop-blur-sm",children:a.jsx("tr",{children:h.map(e=>a.jsx("th",{className:"px-2 py-1.5 text-left text-xs font-medium text-muted-foreground whitespace-nowrap border-b",children:e.header||e.columnLabel||e.columnName},e.columnName))})}),a.jsx("tbody",{children:r.map((e,t)=>{const s=m&&!!Gu(e);return a.jsx("tr",{className:Kt("border-b border-border/50 transition-colors hover:bg-muted/30",(s||i)&&"cursor-pointer"),onClick:()=>x(e),children:h.map(t=>a.jsx("td",{className:"px-2 py-1.5 text-foreground whitespace-nowrap truncate max-w-[200px]",children:t.render?t.render(e[t.columnName],e):dm(e[t.columnName],t)},t.columnName))},t)})})]})}),s===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function dm(e,a){return null==e?"":e instanceof Date?"datetime"===a.columnType?e.toLocaleString("pt-BR"):e.toLocaleDateString("pt-BR"):"number"==typeof e?e.toLocaleString("pt-BR"):String(e)}const cm=["hsl(var(--primary))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))","#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3"];function um({config:e,variant:s,state:r,data:n=[],series:o,colors:i,categoryKey:l="key",yAxisFormat:d,viewOnly:c=!1,onPointClick:u,onRefresh:m,onExport:p,queryUrl:h,queryUrlBuilder:x,className:f}){const g=i?.length?i:e.hexColors?.length?e.hexColors:cm,v=t.useMemo(()=>o?.length?o:[{dataKey:"value",name:e.title}],[o,e.title]),b="bar"===s,y="stacked-column"===s,j=t.useMemo(()=>{if(d)return e=>d.replace("{value}",e.toLocaleString("pt-BR"))},[d]);return a.jsxs("div",{className:Kt("flex h-full flex-col",f),children:[a.jsx(em,{config:e,viewOnly:c,onRefresh:m,onExport:p,queryUrlBuilder:x}),r===exports.PanelState.Loading&&a.jsx(tm,{}),r===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:mm({variant:s,data:n,series:v,colors:g,categoryKey:l,isHorizontalBar:b,isStacked:y,yAxisTickFormatter:j,tooltipFormatter:e=>"number"==typeof e?e.toLocaleString("pt-BR"):String(e??""),onPointClick:u})})}),r===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),r===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:h}),r===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function mm({variant:e,data:t,series:s,colors:r,categoryKey:n,isHorizontalBar:o,isStacked:i,yAxisTickFormatter:l,tooltipFormatter:d,onPointClick:c}){const u={tick:{fontSize:11},tickLine:!1,axisLine:!1},m=a.jsx(B.XAxis,{dataKey:o?void 0:n,type:o?"number":"category",...u,angle:o?0:-45,textAnchor:o?"middle":"end",height:o?void 0:60,tickFormatter:o?l:void 0}),p=a.jsx(B.YAxis,{dataKey:o?n:void 0,type:o?"category":"number",...u,width:o?100:60,tickFormatter:o?void 0:l}),h=a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),x=a.jsx(B.Tooltip,{formatter:d,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),f=s.length>1?a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}):null,g=c?(e,a)=>c(t[a],a):void 0;return"bar"===e||"column"===e||"stacked-column"===e?a.jsxs(B.BarChart,{data:t,layout:o?"vertical":"horizontal",margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Bar,{dataKey:e.dataKey,name:e.name||e.dataKey,fill:e.color||r[t%r.length],stackId:i?e.stackId||"stack":void 0,radius:i?void 0:[2,2,0,0],onClick:g,cursor:c?"pointer":void 0},e.dataKey))]}):"area"===e?a.jsxs(B.AreaChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>{const s=e.color||r[t%r.length];return a.jsx(B.Area,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:s,fill:s,fillOpacity:.15,strokeWidth:2,dot:!1,activeDot:{r:4,cursor:c?"pointer":void 0}},e.dataKey)})]}):a.jsxs(B.LineChart,{data:t,margin:{top:5,right:10,left:0,bottom:5},children:[h,m,p,x,f,s.map((e,t)=>a.jsx(B.Line,{type:"monotone",dataKey:e.dataKey,name:e.name||e.dataKey,stroke:e.color||r[t%r.length],strokeWidth:2,dot:{r:3},activeDot:{r:5,cursor:c?"pointer":void 0}},e.dataKey))]})}const pm=["#1f78b4","#33a02c","#e31a1c","#ff7f00","#6a3d9a","#b15928","#a6cee3","#b2df8a","#fb9a99","#fdbf6f","#cab2d6","#ffff99"];function hm({config:e,state:s,data:r=[],colors:n,viewOnly:o=!1,onSliceClick:i,onRefresh:l,onExport:d,queryUrl:c,queryUrlBuilder:u,className:m}){const p=n?.length?n:e.hexColors?.length?e.hexColors:pm,h=t.useMemo(()=>r.map(e=>({...e,name:String(e.key??""),value:e.value??0})),[r]),x=t.useMemo(()=>h.reduce((e,a)=>e+(a.value??0),0),[h]);return a.jsxs("div",{className:Kt("flex h-full flex-col",m),children:[a.jsx(em,{config:e,viewOnly:o,onRefresh:l,onExport:d,queryUrlBuilder:u}),s===exports.PanelState.Loading&&a.jsx(tm,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.PieChart,{children:[a.jsx(B.Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:"80%",label:({name:e,percent:a})=>`${e??""}: ${(100*(a??0)).toFixed(0)}%`,labelLine:!0,onClick:i?(e,a)=>i(r[a],a):void 0,cursor:i?"pointer":void 0,children:h.map((e,t)=>a.jsx(B.Cell,{fill:p[t%p.length]},t))}),a.jsx(B.Tooltip,{formatter:e=>{const a="number"==typeof e?e:0,t=x>0?(a/x*100).toFixed(1):"0";return`${a.toLocaleString("pt-BR")} (${t}%)`}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}})]})})}),s===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:c}),s===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function xm({config:e,state:s,data:r=[],barColor:n,lineColor:o="#e31a1c",viewOnly:i=!1,onPointClick:l,onRefresh:d,onExport:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=e.hexColors?.length?e.hexColors:["#1f78b4"],x=n??h[0],f=t.useMemo(()=>{const e=[...r].sort((e,a)=>(a.value??0)-(e.value??0)),a=e.reduce((e,a)=>e+(a.value??0),0);let t=0;return e.map(e=>(t+=e.value??0,{key:String(e.key??""),value:e.value??0,cumulativePercent:a>0?Math.round(t/a*100):0}))},[r]);return a.jsxs("div",{className:Kt("flex h-full flex-col",p),children:[a.jsx(em,{config:e,viewOnly:i,onRefresh:d,onExport:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(tm,{}),s===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.ComposedChart,{data:f,margin:{top:5,right:30,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"key",tick:{fontSize:11},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{yAxisId:"left",tick:{fontSize:11},tickLine:!1,axisLine:!1}),a.jsx(B.YAxis,{yAxisId:"right",orientation:"right",tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:(e,a)=>"% Acumulado"===a?`${e}%`:"number"==typeof e?e.toLocaleString("pt-BR"):e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{yAxisId:"left",dataKey:"value",name:"Quantidade",fill:x,radius:[2,2,0,0],onClick:l?(e,a)=>l(r[a],a):void 0,cursor:l?"pointer":void 0}),a.jsx(B.Line,{yAxisId:"right",type:"monotone",dataKey:"cumulativePercent",name:"% Acumulado",stroke:o,strokeWidth:2,dot:{r:3,fill:o}})]})})}),s===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function fm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onRefresh:d,queryUrl:c,queryUrlBuilder:u,className:m}){const{t:p}=y.useTranslation(),h=r??p("dashboard_work_done"),x=n??p("dashboard_work_planned");return a.jsxs("div",{className:Kt("flex h-full flex-col",m),children:[a.jsx(em,{config:e,viewOnly:l,onRefresh:d,queryUrlBuilder:u}),t===exports.PanelState.Loading&&a.jsx(tm,{panelType:exports.DashboardPanelType.Burndown}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.AreaChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"date",tick:{fontSize:10},angle:-45,textAnchor:"end",height:50}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`,domain:[0,100]}),a.jsx(B.Tooltip,{formatter:e=>`${e}%`,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Area,{type:"monotone",dataKey:"executedPercentage",name:h,stroke:o,fill:o,fillOpacity:.2,strokeWidth:2,dot:{r:3}}),a.jsx(B.Area,{type:"monotone",dataKey:"plannedPercentage",name:x,stroke:i,fill:i,fillOpacity:.1,strokeWidth:2,dot:{r:3}})]})})}),t===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:c}),t===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function gm({config:e,state:t,data:s=[],executedLabel:r,plannedLabel:n,executedColor:o="hsl(var(--primary))",plannedColor:i="hsl(var(--chart-2))",viewOnly:l=!1,onPointClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const{t:h}=y.useTranslation(),x=r??h("dashboard_work_done"),f=n??h("dashboard_work_planned");return a.jsxs("div",{className:Kt("flex h-full flex-col",p),children:[a.jsx(em,{config:e,viewOnly:l,onRefresh:c,queryUrlBuilder:m}),t===exports.PanelState.Loading&&a.jsx(tm,{}),t===exports.PanelState.Loaded&&a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(B.ResponsiveContainer,{width:"100%",height:"100%",children:a.jsxs(B.BarChart,{data:s,margin:{top:5,right:10,left:0,bottom:5},children:[a.jsx(B.CartesianGrid,{strokeDasharray:"3 3",className:"stroke-border/50"}),a.jsx(B.XAxis,{dataKey:"name",tick:{fontSize:10},angle:-45,textAnchor:"end",height:60}),a.jsx(B.YAxis,{tick:{fontSize:11},tickFormatter:e=>`${e}%`}),a.jsx(B.Tooltip,{formatter:e=>"number"==typeof e?`${e}%`:e,contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"}}),a.jsx(B.Legend,{wrapperStyle:{fontSize:"11px"}}),a.jsx(B.Bar,{dataKey:"executedWork",name:x,fill:o,radius:[2,2,0,0],onClick:d?(e,a)=>d(s[a],a):void 0,cursor:d?"pointer":void 0}),a.jsx(B.Bar,{dataKey:"plannedWork",name:f,fill:i,radius:[2,2,0,0]})]})})}),t===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),t===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:u}),t===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}function vm({config:e,state:s,rule:r,risks:n=[],matrixViewType:o=exports.MatrixViewType.Quantity,viewOnly:i=!1,onCellClick:l,onRiskClick:d,onRefresh:c,queryUrl:u,queryUrlBuilder:m,className:p}){const h=t.useMemo(()=>[...r?.parametersY??[]].sort((e,a)=>a.position-e.position),[r?.parametersY]),x=r?.parametersX??[],f=t.useMemo(()=>{const e={};return n.forEach(a=>{const t=`${a.parameterYPosition}-${a.parameterXPosition}`;e[t]||(e[t]=[]),e[t].push(a)}),e},[n]);return a.jsxs("div",{className:Kt("flex h-full flex-col",p),children:[a.jsx(em,{config:e,viewOnly:i,onRefresh:c,queryUrlBuilder:m}),s===exports.PanelState.Loading&&a.jsx(tm,{}),s===exports.PanelState.Loaded&&r&&a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsxs("div",{className:"flex gap-4 items-stretch min-w-fit",children:[a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"text-xs font-medium text-muted-foreground [writing-mode:vertical-lr] rotate-180",children:r.name_y})}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex mb-1",children:[a.jsx("div",{className:"w-16 shrink-0"}),a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.threat_strategy_type_name}),!r.disable_opportunities&&a.jsx("div",{className:"flex-1 text-center text-xs font-medium text-muted-foreground truncate",children:r.opportunity_strategy_type_name})]}),h.map((e,t)=>a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0 flex items-center justify-center border border-border/50 text-xs font-medium p-1 text-center",children:e.name}),x.map((s,n)=>{const i=((e,a)=>f[`${a.position}-${e.position}`]??[])(s,e),c=((e,a)=>r?.colorMatrix?.[a]?.[e]??"hsl(var(--muted))")(n,t);return a.jsxs("div",{className:Kt("flex-1 min-w-[60px] min-h-[40px] border border-border/50 flex flex-col items-center justify-center gap-0.5 p-1",(l||d)&&i.length>0&&"cursor-pointer hover:opacity-80"),style:{backgroundColor:c},onClick:()=>i.length>0&&l?.(s,e,i),children:[o===exports.MatrixViewType.Quantity&&i.length>0&&a.jsxs("span",{className:"text-xs font-semibold",children:[i.length," risco",1!==i.length?"s":""]}),o===exports.MatrixViewType.AllRisksList&&i.map(e=>a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{type:"button",className:"text-[10px] text-primary underline hover:text-primary/80",onClick:a=>{a.stopPropagation(),d?.(e)},children:e.code})}),a.jsxs(Nr,{className:"max-w-[250px]",children:[a.jsxs("p",{className:"font-medium",children:[e.code," - ",e.name]}),e.analysisDate&&a.jsxs("p",{className:"text-xs mt-1",children:["Última análise: ",a.jsx("strong",{children:e.analysisDate})]}),e.strategy&&a.jsxs("p",{className:"text-xs",children:["Estratégia: ",a.jsx("strong",{children:e.strategy})]}),e.resultName&&a.jsxs("p",{className:"text-xs",children:["Criticidade: ",a.jsx("strong",{style:{backgroundColor:c},className:"px-1 rounded",children:e.resultName})]})]})]},e.code))]},s.position)})]},e.position)),a.jsxs("div",{className:"flex",children:[a.jsx("div",{className:"w-16 shrink-0"}),x.map(e=>a.jsx("div",{className:"flex-1 min-w-[60px] border border-border/50 text-xs font-medium p-1 text-center",children:e.name},e.position))]}),a.jsx("div",{className:"text-center text-xs font-medium text-muted-foreground mt-2",children:r.name_x})]})]})}),s===exports.PanelState.NoData&&a.jsx(sm,{hasRemovedColumn:e.hasRemovedColumn}),s===exports.PanelState.Error&&a.jsx(am,{config:e,queryUrl:u}),s===exports.PanelState.Unavailable&&a.jsx(rm,{onRemove:()=>e.onRemove?.(e.id)})]})}const bm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:a,y:t}=e;return"translate3d("+(a?Math.round(a):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:a,scaleY:t}=e;return"scaleX("+a+") scaleY("+t+")"}},Transform:{toString(e){if(e)return[bm.Translate.toString(e),bm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:a,duration:t,easing:s}=e;return a+" "+t+"ms "+s}}});function ym(e){switch(Number(e)){case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Numeric:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.Text:return{x:1,y:1};default:return{x:2,y:2}}}function jm({panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:i}){const{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:m,isDragging:p}=X.useSortable({id:e.id,disabled:!o}),h=t.useMemo(()=>({gridColumn:`${e.col+1} / span ${e.sizeX}`,gridRow:`${e.row+1} / span ${e.sizeY}`,minHeight:e.sizeY*r+(e.sizeY-1)*n+"px",transform:bm.Transform.toString(u),transition:m,zIndex:p?50:void 0,opacity:p?.85:1}),[e,s,r,n,u,m,p]);return a.jsxs("div",{ref:c,style:h,className:Kt("rounded-lg border border-border bg-card shadow-sm overflow-hidden","transition-shadow duration-200",p&&"shadow-lg ring-2 ring-primary/20"),...l,children:[a.jsx("div",{className:Kt("dashboard-panel-drag-handle",o&&"cursor-grab active:cursor-grabbing"),...o?d:{}}),a.jsx("div",{className:"h-full",children:i})]})}function wm({panels:e,columns:s=8,cellHeight:r=160,cellGap:n=10,allowDragging:o=!1,showGridLines:i=!1,renderPanel:l,onLayoutChange:d,className:c}){const[u,m]=t.useState(e);t.useMemo(()=>{m(e)},[e]);const p=Q.useSensors(Q.useSensor(Q.PointerSensor,{activationConstraint:{distance:8}})),h=t.useMemo(()=>0===u.length?1:Math.max(...u.map(e=>e.row+e.sizeY)),[u]),x=t.useMemo(()=>u.map(e=>e.id),[u]),f=t.useCallback(e=>{const{active:a,over:t}=e;if(!t||a.id===t.id)return;const s=u.findIndex(e=>e.id===a.id),r=u.findIndex(e=>e.id===t.id);if(-1===s||-1===r)return;const n=[...u],o={...n[s]},i={...n[r]},l=o.col,c=o.row;o.col=i.col,o.row=i.row,i.col=l,i.row=c,n[s]=o,n[r]=i,m(n),d?.(n)},[u,d]),g=t.useMemo(()=>({display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gridTemplateRows:`repeat(${h}, ${r}px)`,gap:`${n}px`}),[s,h,r,n]);return 0===u.length?a.jsxs("div",{className:Kt("flex flex-col items-center justify-center py-16 text-center",c),children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Nenhum painel adicionado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione painéis para visualizar seus dados aqui."})]}):a.jsx(Q.DndContext,{sensors:p,collisionDetection:Q.closestCenter,onDragEnd:f,children:a.jsx(X.SortableContext,{items:x,strategy:X.rectSortingStrategy,children:a.jsx("div",{style:g,className:Kt("relative w-full",i&&"bg-muted/30",c),children:u.map(e=>a.jsx(jm,{panel:e,columns:s,cellHeight:r,cellGap:n,allowDragging:o,children:l(e.id)},e.id))})})})}const Nm={[exports.DashboardPanelType.Bar]:"bar",[exports.DashboardPanelType.Column]:"column",[exports.DashboardPanelType.StackedColumn]:"stacked-column",[exports.DashboardPanelType.Area]:"area",[exports.DashboardPanelType.Line]:"line",[exports.DashboardPanelType.EvolutionLine]:"evolution-line"};function _m({config:e,state:t,data:s,numericValue:r,listColumns:n,cartesianData:o,cartesianSeries:i,burndownData:l,performanceData:d,matrixRule:c,matrixRisks:u,onPanelClick:m}){const p=Nm[e.typeId];if(p)return a.jsx(um,{config:e,variant:p,state:t,data:o,series:i});switch(e.typeId){case exports.DashboardPanelType.Numeric:return a.jsx(om,{config:e,state:t,value:r});case exports.DashboardPanelType.Text:return a.jsx(im,{config:e,state:t});case exports.DashboardPanelType.List:return a.jsx(lm,{config:e,state:t,data:s,columns:n??[]});case exports.DashboardPanelType.Pie:return a.jsx(hm,{config:e,state:t,data:s});case exports.DashboardPanelType.Pareto:return a.jsx(xm,{config:e,state:t,data:s});case exports.DashboardPanelType.Burndown:return a.jsx(fm,{config:e,state:t,data:l});case exports.DashboardPanelType.PerformanceColumns:return a.jsx(gm,{config:e,state:t,data:d});case exports.DashboardPanelType.RiskMatrix:return a.jsx(vm,{config:e,state:t,rule:c,risks:u??[]});default:return a.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:["Tipo de painel não suportado (",e.typeId,")"]})}}function Cm({dashboard:e,panels:s,pages:r,activePageId:n,canEdit:o=!1,isFullscreen:i=!1,isLoading:l=!1,getPanelData:d,onRefresh:c,onToggleFullscreen:u,onToggleFavorite:m,onEdit:p,onShare:h,onAddPanel:x,onEditPanel:f,onRemovePanel:g,onDuplicatePanel:v,onLayoutChange:b,onPageChange:j,toolbarActions:w,className:N}){const{t:_}=y.useTranslation(),[C,k]=t.useState(!1),S=e.idViewType===exports.DashboardViewType.Carousel,T=t.useMemo(()=>s,[s,S,n]),P=t.useMemo(()=>T.map(e=>{const a=ym(e.typeId);return{id:e.id,col:e.col,row:e.row,sizeX:e.sizeX,sizeY:e.sizeY,minSizeX:a.x,minSizeY:a.y}}),[T]),E=t.useCallback(e=>({id:e.id,title:e.titlePtBr||e.titleEnUs||e.titleEsEs,typeId:e.typeId,queryId:e.queryId,queryContextId:e.queryContextId,queryTitle:e.queryTitle,querySelectedColumns:e.querySelectedColumns,field:e.field??"",fieldType:e.fieldType??"",fieldAuxAxis:e.fieldAuxAxis,fieldAuxAxisType:e.fieldAuxAxisType,aggregationType:e.aggregationType,textTypeString:e.textTypeString,referenceDate:e.referenceDate,period:e.period,initialDate:e.initialDate,finalDate:e.finalDate,dimension:e.dimension,yAxis:e.yAxis,yAxisType:e.yAxisType,orderBy:e.orderBy,orderByType:e.orderByType,secondaryGrouping:e.secondaryGrouping,secondaryGroupingType:e.secondaryGroupingType,onlyLate:e.onlyLate,jsonRules:e.jsonRules,ignoreRules:e.ignoreRules,visualizationType:e.visualizationType,sortType:e.sortType,itemsPerPanel:e.itemsPerPanel,secondaryItemsPerPanel:e.secondaryItemsPerPanel,matrixViewRule:e.matrixViewRule,listPanelColumns:e.listPanelColumns,listPanelListType:e.listPanelListType,paletteId:e.paletteId,hexColors:e.hexColors,showNotInformedData:e.showNotInformedData,fieldAnalysisRule:e.fieldAnalysisRule,fieldCriticality:e.fieldCriticality,fieldPlansType:e.fieldPlansType,fieldPlansSelected:e.fieldPlansSelected,fieldPlansBurndown:e.fieldPlansBurndown,fieldPlansBurndownGroup:e.fieldPlansBurndownGroup,analysisCriteriaId:e.analysisCriteriaId,analysisCriteriaParameter:e.analysisCriteriaParameter,evolutionSecondaryGrouping:e.evolutionSecondaryGrouping,canUpdate:o,hasRemovedColumn:e.hasRemovedColumn,panelSize:{x:e.sizeX,y:e.sizeY},onEdit:f,onRemove:g,onDuplicate:v}),[o,f,g,v]),D=t.useCallback(()=>{C||l||(k(!0),c?.(),setTimeout(()=>k(!1),3e4))},[C,l,c]),A=t.useCallback(e=>{const t=T.find(a=>a.id===e);if(!t)return null;const s=E(t),r=d?.(e)??{state:exports.PanelState.Loaded};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(em,{config:s,onRefresh:()=>{}}),a.jsx("div",{className:"flex-1 min-h-0 p-2",children:a.jsx(_m,{config:s,...r})})]})},[T,E,d,o,f,g,v]);return a.jsxs("div",{className:Kt("flex flex-col h-full",i&&"fixed inset-0 z-50 bg-background",N),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:e.title}),e.responsibleName&&!i&&a.jsx("span",{className:"text-xs text-muted-foreground truncate hidden sm:inline",children:e.responsibleName})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[w,c&&a.jsx("button",{onClick:D,disabled:C||l,className:Kt("inline-flex items-center justify-center rounded-md p-2 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors","disabled:opacity-50 disabled:pointer-events-none"),title:C?_("dashboard_wait_refresh"):"Atualizar",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m0 0a9 9 0 0 1 9-9m-9 9a9 9 0 0 0 9 9"})})}),u&&a.jsx("button",{onClick:u,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:i?_("dashboard_exit_fullscreen"):"Fullscreen",children:a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i?a.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"}):a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),o&&!i&&h&&a.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:"Compartilhar",children:a.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),m&&!i&&a.jsx("button",{onClick:m,className:"inline-flex items-center justify-center rounded-md p-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",title:e.isFavorite?_("dashboard_remove_favorite"):"Favoritar",children:a.jsx("svg",{className:Kt("h-4 w-4",e.isFavorite&&"fill-yellow-400 text-yellow-400"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})]})]}),S&&r&&r.length>1&&a.jsx("div",{className:"flex items-center gap-1 px-4 py-1 border-b border-border bg-card overflow-x-auto",children:r.map(e=>a.jsx("button",{onClick:()=>j?.(e.id),className:Kt("px-3 py-1.5 text-sm rounded-md whitespace-nowrap transition-colors",n===e.id?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:e.name||`Dashboard ${e.position}`},e.id))}),o&&!i&&x&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsxs("button",{onClick:x,className:Kt("inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Adicionar painel"]})}),l&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!l&&a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-muted/30",children:a.jsx(wm,{panels:P,allowDragging:o,showGridLines:o,renderPanel:A,onLayoutChange:b})})]})}function km(e,a=exports.DashboardLanguage.PtBr){const{t:t}=y.useTranslation();switch(a){case exports.DashboardLanguage.EnUs:return e.titleEnUs||e.titlePtBr||e.titleEsEs;case exports.DashboardLanguage.EsEs:return e.titleEsEs||e.titleEnUs||e.titlePtBr;default:return e.titlePtBr||e.titleEnUs||e.titleEsEs}}function Sm(e){const{t:a}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}const Tm=[{value:exports.QuickFilterDashboard.All,label:"Todos"},{value:exports.QuickFilterDashboard.OnlyMine,label:e.t("dashboard_my")},{value:exports.QuickFilterDashboard.Favorites,label:"Favoritos"}];function Pm({dashboards:e,limit:s,isLoading:r=!1,language:n=exports.DashboardLanguage.PtBr,canAdd:o=!1,canEdit:i=!1,canRemove:l=!1,onOpen:d,onEdit:c,onShare:u,onDuplicate:m,onRemove:p,onAdd:h,onToggleFavorite:x,onRefresh:f,onSearch:g,onQuickFilterChange:v,toolbarExtra:b,className:j}){const{t:w}=y.useTranslation(),[N,_]=t.useState(""),[C,k]=t.useState(exports.QuickFilterDashboard.All),[S,T]=t.useState(null),P=t.useCallback(e=>{_(e),g?.(e)},[g]),E=t.useCallback(e=>{k(e),v?.(e)},[v]),D=t.useMemo(()=>{let a=e;if(N){const e=N.toLowerCase();a=a.filter(a=>a.code?.toLowerCase().includes(e)||km(a,n).toLowerCase().includes(e)||a.responsibleName?.toLowerCase().includes(e))}switch(C){case exports.QuickFilterDashboard.OnlyMine:break;case exports.QuickFilterDashboard.Favorites:a=a.filter(e=>e.isFavorite)}return a},[e,N,C,n]);return a.jsxs("div",{className:Kt("flex flex-col h-full",j),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboards"}),s&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.countDashboards,"/",s.maxDashboards,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative",children:[a.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.3-4.3"})]}),a.jsx("input",{type:"text",placeholder:"Buscar...",value:N,onChange:e=>P(e.target.value),className:Kt("h-9 w-48 rounded-md border border-input bg-background pl-9 pr-3 text-sm","placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")})]}),b,o&&h&&a.jsxs("button",{onClick:h,className:Kt("inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"),children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M12 5v14M5 12h14"})}),"Novo"]})]})]}),a.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-border bg-card",children:Tm.map(e=>a.jsx("button",{onClick:()=>E(e.value),disabled:r,className:Kt("px-3 py-1.5 text-sm rounded-md transition-colors",C===e.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground","disabled:opacity-50"),children:e.label},e.value))}),r&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),!r&&a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-muted/80 backdrop-blur-sm border-b border-border",children:a.jsxs("tr",{children:[a.jsx("th",{className:"w-12 px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Código"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Título"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Responsável"}),a.jsx("th",{className:"w-12 px-3 py-2 text-center font-medium text-muted-foreground",children:a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Última modificação"}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Situação"}),a.jsx("th",{className:"w-12 px-3 py-2"})]})}),a.jsxs("tbody",{children:[0===D.length&&a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"px-3 py-12 text-center text-muted-foreground",children:"Nenhum dashboard encontrado."})}),D.map(e=>a.jsxs("tr",{onClick:()=>d?.(e),className:Kt("border-b border-border cursor-pointer transition-colors","hover:bg-accent/50"),children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),x?.(e)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsx("svg",{className:Kt("h-4 w-4",e.isFavorite?"fill-yellow-400 text-yellow-400":"text-muted-foreground"),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-foreground",children:e.code}),a.jsx("td",{className:"px-3 py-2 text-foreground font-medium",children:km(e,n)}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:e.responsibleName}),a.jsx("td",{className:"px-3 py-2 text-center",children:e.hasSharedIcon&&a.jsxs("svg",{className:"h-4 w-4 mx-auto text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),a.jsx("circle",{cx:"9",cy:"7",r:"4"}),a.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),a.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:Sm(e.lastModified)}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("span",{className:Kt("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",e.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),children:e.isActive?"Ativo":"Inativo"})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(S===e.id?null:e.id)},className:"p-1 hover:bg-accent rounded transition-colors",children:a.jsxs("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"5",r:"1"}),a.jsx("circle",{cx:"12",cy:"12",r:"1"}),a.jsx("circle",{cx:"12",cy:"19",r:"1"})]})}),S===e.id&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>T(null)}),a.jsxs("div",{className:"absolute right-0 top-8 z-50 min-w-[160px] rounded-md border border-border bg-popover shadow-md py-1",children:[a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),d?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Abrir"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),c?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Editar"}),i&&a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),u?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Compartilhar"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),m?.(e)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-accent transition-colors",children:"Duplicar"}),l&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"my-1 border-t border-border"}),a.jsx("button",{onClick:a=>{a.stopPropagation(),T(null),p?.(e)},className:"w-full px-3 py-1.5 text-left text-sm text-destructive hover:bg-destructive/10 transition-colors",children:"Remover"})]})]})]})]})})]},e.id))]})]})})]})}const Em=[{value:exports.DashboardUpdateTime.NotUpdate,label:e.t("dashboard_no_refresh")},{value:exports.DashboardUpdateTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardUpdateTime.TenMinutes,label:"10 minutos"},{value:exports.DashboardUpdateTime.FifteenMinutes,label:"15 minutos"},{value:exports.DashboardUpdateTime.ThirtyMinutes,label:"30 minutos"},{value:exports.DashboardUpdateTime.OneHour,label:"1 hora"}],Dm=[{value:exports.DashboardViewType.NormalPage,label:e.t("dashboard_normal_page")},{value:exports.DashboardViewType.Carousel,label:"Carrossel"}],Am=[{value:exports.DashboardPageTime.FiveSeconds,label:"5 segundos"},{value:exports.DashboardPageTime.TenSeconds,label:"10 segundos"},{value:exports.DashboardPageTime.FifteenSeconds,label:"15 segundos"},{value:exports.DashboardPageTime.ThirtySeconds,label:"30 segundos"},{value:exports.DashboardPageTime.OneMinute,label:"1 minuto"},{value:exports.DashboardPageTime.ThreeMinutes,label:"3 minutos"},{value:exports.DashboardPageTime.FiveMinutes,label:"5 minutos"},{value:exports.DashboardPageTime.TenMinutes,label:"10 minutos"}],Im=[{value:exports.DashboardShareType.NotShared,label:e.t("dashboard_not_shared"),description:e.t("dashboard_only_responsible")},{value:exports.DashboardShareType.SharedWithAllCollaborators,label:e.t("dashboard_shared_unit"),description:e.t("dashboard_all_access")},{value:exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators,label:e.t("dashboard_select_groups"),description:e.t("dashboard_select_groups")}],Mm=[{key:"pt-br",label:"PT-BR"},{key:"en",label:"EN-US"},{key:"es",label:"ES-ES"}];function Fm({dashboard:e,initialTab:s=exports.DashboardFormTab.General,isSaving:r=!1,isQualitfy:n=!1,users:o=[],groups:i=[],places:l=[],collaborators:d=[],onSave:c,onCancel:u,className:m}){const{t:p}=y.useTranslation(),h=!!e,[x,f]=t.useState(s),[g,v]=t.useState({"pt-br":!!e?.titlePtBr||!h,en:!!e?.titleEnUs,es:!!e?.titleEsEs}),[b,j]=t.useState(e?.titlePtBr??""),[w,N]=t.useState(e?.titleEnUs??""),[_,C]=t.useState(e?.titleEsEs??""),[k,S]=t.useState(e?.responsibleId??""),[T,P]=t.useState(e?.isActive??!0),[E,D]=t.useState(e?.idUpdateTime??exports.DashboardUpdateTime.NotUpdate),[A,I]=t.useState(e?.idViewType??exports.DashboardViewType.NormalPage),[M,F]=t.useState(e?.idPageTime??exports.DashboardPageTime.FifteenSeconds),[R,L]=t.useState(e?.idShare??exports.DashboardShareType.NotShared),[z,U]=t.useState(e?.groups??[]),[O,V]=t.useState(e?.places??[]),[B,q]=t.useState(e?.collaborators??[]),$=A===exports.DashboardViewType.Carousel,W=g["pt-br"]||g.en||g.es,H=t.useMemo(()=>!!W&&(!(g["pt-br"]&&!b.trim())&&(!(g.en&&!w.trim())&&!(g.es&&!_.trim()))),[W,g,b,w,_]),G=t.useCallback(e=>{v(a=>({...a,[e]:!a[e]}))},[]),K=t.useCallback(()=>{H&&!r&&c?.({titlePtBr:g["pt-br"]?b:"",titleEnUs:g.en?w:"",titleEsEs:g.es?_:"",responsibleId:k||void 0,isActive:T,idUpdateTime:E,idViewType:A,idPageTime:$?M:null,idShare:R,groups:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?z:[],places:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?O:[],collaborators:R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators?B:[]})},[H,r,c,g,b,w,_,k,T,E,A,M,$,R,z,O,B]);return a.jsxs("div",{className:Kt("flex flex-col h-full bg-background",m),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-lg font-semibold text-foreground",children:p(h?"dashboard_edit":"dashboard_new")}),h&&e&&a.jsx("span",{className:"text-sm text-muted-foreground",children:e.code})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:u,className:"px-3 py-2 text-sm rounded-md border border-input hover:bg-accent transition-colors",children:"Cancelar"}),a.jsxs("button",{onClick:K,disabled:!H||r,className:Kt("inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-sm font-medium","bg-primary text-primary-foreground hover:bg-primary/90 transition-colors","disabled:opacity-50 disabled:pointer-events-none"),children:[r?a.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground border-t-transparent"}):a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Salvar"]})]})]}),a.jsxs("div",{className:"flex border-b border-border bg-card",children:[a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.General),className:Kt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.General?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Geral"}),a.jsx("button",{onClick:()=>f(exports.DashboardFormTab.Share),className:Kt("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",x===exports.DashboardFormTab.Share?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:"Compartilhamento"})]}),a.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x===exports.DashboardFormTab.General&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium text-foreground",children:"Título *"}),a.jsx("div",{className:"flex gap-2",children:Mm.map(e=>a.jsx("button",{onClick:()=>G(e.key),className:Kt("px-3 py-1 text-xs rounded-md border transition-colors",g[e.key]?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:bg-accent"),children:e.label},e.key))}),!W&&a.jsx("p",{className:"text-xs text-destructive",children:"Selecione pelo menos um idioma"})]}),g["pt-br"]&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Português (BR)"}),a.jsx("input",{value:b,onChange:e=>j(e.target.value),maxLength:200,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[b.length,"/200"]})]}),g.en&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Inglês (US)"}),a.jsx("input",{value:w,onChange:e=>N(e.target.value),maxLength:200,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[w.length,"/200"]})]}),g.es&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Título em Espanhol (ES)"}),a.jsx("input",{value:_,onChange:e=>C(e.target.value),maxLength:200,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring")}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[_.length,"/200"]})]}),!e?.isStandard&&o.length>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Responsável"}),a.jsxs("select",{value:k,onChange:e=>S(e.target.value),disabled:!h,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:[a.jsx("option",{value:"",children:"Selecione..."}),o.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Intervalo de atualização"}),a.jsx("select",{value:E,onChange:e=>D(Number(e.target.value)),disabled:n,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:Em.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Situação"}),a.jsxs("div",{className:"flex items-center gap-3 h-10",children:[a.jsx("button",{onClick:()=>P(!T),disabled:e?.isGeneralViewUse,className:Kt("relative inline-flex h-6 w-11 items-center rounded-full transition-colors",T?"bg-primary":"bg-muted","disabled:opacity-50"),children:a.jsx("span",{className:Kt("inline-block h-4 w-4 rounded-full bg-white transition-transform",T?"translate-x-6":"translate-x-1")})}),a.jsx("span",{className:"text-sm text-foreground",children:T?"Ativo":"Inativo"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Tipo de visualização"}),a.jsx("select",{value:A,onChange:e=>I(Number(e.target.value)),disabled:n||$,className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50"),children:Dm.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]}),$&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm text-muted-foreground",children:"Trocar página a cada"}),a.jsx("select",{value:M??"",onChange:e=>F(Number(e.target.value)),className:Kt("w-full h-10 rounded-md border border-input bg-background px-3 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:Am.map(e=>a.jsx("option",{value:e.value,children:e.label},e.value))})]})]})]}),x===exports.DashboardFormTab.Share&&a.jsxs("div",{className:"max-w-2xl space-y-6",children:[a.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 border border-border",children:[a.jsxs("svg",{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("path",{d:"M12 8h.01"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure quem pode visualizar este dashboard. O responsável sempre terá acesso."})]}),a.jsx("div",{className:"space-y-3",children:Im.map(t=>a.jsxs("label",{className:Kt("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",R===t.value?"border-primary bg-primary/5":"border-border hover:bg-accent/50",e?.isGeneralViewUse&&"opacity-50 pointer-events-none"),children:[a.jsx("input",{type:"radio",name:"shareType",value:t.value,checked:R===t.value,onChange:()=>L(t.value),disabled:e?.isGeneralViewUse,className:"mt-1 accent-primary"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:t.label}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]})]},t.value))}),R===exports.DashboardShareType.SharedWithUsersGroupsPlacesCollaborators&&a.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Grupos de usuários (",z.length,")"]}),a.jsx("select",{multiple:!0,value:z,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);U(a)},className:Kt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:i.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Locais (",O.length,")"]}),a.jsx("select",{multiple:!0,value:O,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);V(a)},className:Kt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:l.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Colaboradores (",B.length,")"]}),a.jsx("select",{multiple:!0,value:B,onChange:e=>{const a=Array.from(e.target.selectedOptions,e=>e.value);q(a)},className:Kt("w-full h-24 rounded-md border border-input bg-background px-3 py-2 text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:d.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))})]})]})]})]})]})}function Rm(){return`n_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Lm(e,a){return{id:a?.id??Rm(),text:e,children:a?.children,collapsed:a?.collapsed,color:a?.color,icon:a?.icon,note:a?.note,side:a?.side}}function zm(e,a){if(e.id===a)return{node:e,parent:null};const t=[];for(const s of e.children??[])t.push({node:s,parent:e});for(;t.length;){const e=t.pop();if(e.node.id===a)return{node:e.node,parent:e.parent};for(const a of e.node.children??[])t.push({node:a,parent:e.node})}return null}function Um(e,a){const t=a(e);return t.children?.length?{...t,children:t.children.map(e=>Um(e,a))}:t}function Om(e,a,t){return Um(e,e=>e.id===a?t(e):e)}function Vm(e){return{left:(e.children??[]).filter(e=>"left"===e.side).length,right:(e.children??[]).filter(e=>"left"!==e.side).length}}function Bm(e,a,t){const s=Lm(t||"");let r=s.id;const n=Um(e,t=>{if(t.id!==a)return t;let n=s;if(t.id===e.id){const a=Vm(e);n={...n,side:a.left<=a.right?"left":"right"}}else n={...n,side:t.side};return r=n.id,{...t,collapsed:!1,children:[...t.children??[],n]}});return{root:n,newId:r}}function qm(e,a,t){if(e.id===a)return Bm(e,a,t);const s=zm(e,a);if(!s||!s.parent)return{root:e,newId:a};const r=s.parent,n=Lm(t||"",{side:s.node.side}),o=n.id,i=Um(e,e=>{if(e.id!==r.id)return e;const t=(e.children??[]).findIndex(e=>e.id===a),s=[...e.children??[]];return s.splice(t+1,0,n),{...e,children:s}});return{root:i,newId:o}}function $m(e,a){if(e.id===a)return{root:e,nextSelectedId:a};const t=zm(e,a);if(!t||!t.parent)return{root:e,nextSelectedId:null};const s=t.parent,r=s.children??[],n=r.findIndex(e=>e.id===a),o=r[n+1]?.id??r[n-1]?.id??s.id,i=Um(e,e=>e.id!==s.id?e:{...e,children:(e.children??[]).filter(e=>e.id!==a)});return{root:i,nextSelectedId:o}}function Wm(e,a,t){if(a===t)return e;if(a===e.id)return e;if(function(e,a,t){const s=zm(e,a);return!!s&&!!zm(s.node,t)}(e,a,t))return e;const s=zm(e,a);if(!s)return e;const r=(()=>{if(t===e.id){const a=Vm(e);return{...s.node,side:a.left<=a.right?"left":"right"}}const a=zm(e,t)?.node;return{...s.node,side:a?.side}})(),n=Um(e,e=>e.children?.length&&e.children.some(e=>e.id===a)?{...e,children:e.children.filter(e=>e.id!==a)}:e);return Um(n,e=>e.id!==t?e:{...e,collapsed:!1,children:[...e.children??[],r]})}function Hm(e,a){return Om(e,a,e=>({...e,collapsed:!e.collapsed}))}function Gm(e,a){return Um(e,t=>t.children?.length?t.id===e.id&&a?t:{...t,collapsed:a}:t)}function Km(e){const{value:a,defaultValue:s,onChange:r,readOnly:n}=e,o=void 0!==a,[i,l]=t.useState(()=>s??a??Lm("Mapa Mental",{id:"root"})),d=o?a:i,[c,u]=t.useState(d.id),m=t.useRef([]),p=t.useRef([]),h=t.useCallback((e,a)=>{n||(m.current.push(a),m.current.length>50&&m.current.shift(),p.current=[],o||l(e),r?.(e))},[o,r,n]),x=t.useCallback((e,a)=>{const t=Om(d,e,e=>({...e,text:a}));h(t,d)},[d,h]),f=t.useCallback((e,a)=>{const t=Om(d,e,e=>({...e,...a}));h(t,d)},[d,h]),g=t.useCallback((e,a="")=>{const{root:t,newId:s}=Bm(d,e,a);return h(t,d),u(s),s},[d,h]),v=t.useCallback((e,a="")=>{const{root:t,newId:s}=qm(d,e,a);return h(t,d),u(s),s},[d,h]),b=t.useCallback(e=>{const{root:a,nextSelectedId:t}=$m(d,e);a!==d&&(h(a,d),u(t))},[d,h]),y=t.useCallback((e,a)=>{const t=Wm(d,e,a);t!==d&&h(t,d)},[d,h]),j=t.useCallback(e=>{const a=zm(d,e);if(!a||!a.node.children?.length)return;const t=Hm(d,e);h(t,d)},[d,h]),w=t.useCallback(()=>{h(Gm(d,!1),d)},[d,h]),N=t.useCallback(()=>{h(Gm(d,!0),d)},[d,h]),_=t.useCallback(()=>{const e=m.current.pop();e&&(p.current.push(d),o||l(e),r?.(e))},[d,o,r]),C=t.useCallback(()=>{const e=p.current.pop();e&&(m.current.push(d),o||l(e),r?.(e))},[d,o,r]),k=m.current.length>0,S=p.current.length>0,T=t.useMemo(()=>c?zm(d,c)?.node??null:null,[d,c]),P=t.useCallback(e=>{h(e,d)},[d,h]);return{root:d,setRoot:P,selectedId:c,selectedNode:T,setSelectedId:u,renameNode:x,updateNodeProps:f,addChild:g,addSibling:v,removeNode:b,moveNode:y,toggleNode:j,expandAll:w,collapseAll:N,undo:_,redo:C,canUndo:k,canRedo:S}}const Ym=180,Qm=80,Xm=16,Jm=60;function Zm(e){const a=(e.collapsed?[]:e.children??[]).map(Zm);if(!a.length)return{node:e,visibleChildren:a,height:44};const t=a.reduce((e,a)=>e+a.height,0)+Xm*(a.length-1);return{node:e,visibleChildren:a,height:Math.max(44,t)}}function ep(e,a,t,s,r,n,o){const i=[],l={node:e.node,parent:a,x:t,y:s,width:180,height:44,side:r,depth:n,visibleChildren:i};if(o.push(l),!e.visibleChildren.length)return l;let d=s+22-(e.visibleChildren.reduce((e,a)=>e+a.height,0)+Xm*(e.visibleChildren.length-1))/2;for(const c of e.visibleChildren){const a="right"===r?t+180+Qm:t-Qm-Ym,s=d+c.height/2-22,l=ep(c,e.node,a,s,r,n+1,o);i.push(l),d+=c.height+Xm}return l}function ap(e){return t.useMemo(()=>function(e){const a=e.collapsed?[]:e.children??[],t=a.filter(e=>"left"!==e.side).map(Zm),s=a.filter(e=>"left"===e.side).map(Zm),r=t.reduce((e,a)=>e+a.height,0)+Xm*Math.max(0,t.length-1),n=s.reduce((e,a)=>e+a.height,0)+Xm*Math.max(0,s.length-1),o=Math.max(r,n,56),i=e=>e.visibleChildren.length?1+Math.max(...e.visibleChildren.map(i)):0,l=t.length?Math.max(...t.map(i))+1:0,d=260*(s.length?Math.max(...s.map(i))+1:0),c=220+260*l+d+120,u=o+120,m=Jm+d,p=[],h={node:e,parent:null,x:m,y:Jm+o/2-28,width:220,height:56,side:"root",depth:0,visibleChildren:[]};p.push(h);let x=Jm+o/2-r/2;for(const v of t){const a=x+v.height/2-22,t=ep(v,e,m+220+Qm,a,"right",1,p);h.visibleChildren.push(t),x+=v.height+Xm}let f=Jm+o/2-n/2;for(const v of s){const a=f+v.height/2-22,t=ep(v,e,m-Qm-Ym,a,"left",1,p);h.visibleChildren.push(t),f+=v.height+Xm}const g=new Map(p.map(e=>[e.node.id,e]));return{nodes:p,byId:g,width:c,height:u}}(e),[e])}function tp(e,a){const{layout:t,selectedId:s,setSelectedId:r}=a;if(!s)return void r(t.nodes[0]?.node.id??null);const n=t.byId.get(s);if(!n)return;if("left"===e||"right"===e){if("root"===n.side){const a=n.visibleChildren.find(a=>a.side===e);return void(a&&r(a.node.id))}if(e===n.side){const e=n.visibleChildren[Math.floor(n.visibleChildren.length/2)];e&&r(e.node.id)}else n.parent&&r(n.parent.id);return}if(!n.parent)return;const o=t.byId.get(n.parent.id);if(!o)return;const i=o.visibleChildren.filter(e=>e.side===n.side),l=i.findIndex(e=>e.node.id===s),d="up"===e?i[l-1]:i[l+1];d&&r(d.node.id)}const sp=({layout:e,selected:t,editing:s,readOnly:r,onSelect:n,onStartEditing:o,onFinishEditing:i,onToggle:l,onDragStart:c,onDragOver:u,onDragLeave:m,onDrop:p,isDropTarget:h,renderNodeContent:x})=>{const f=e.node,g="root"===e.side,v=(b=f.icon)?te[b]??null:null;var b;const y=!!f.children?.length,j=ae.useRef(null),[w,N]=ae.useState(f.text);ae.useEffect(()=>{if(s){N(f.text);const e=window.setTimeout(()=>{j.current?.focus(),j.current?.select()},0);return()=>window.clearTimeout(e)}},[s,f.text]);const _=()=>{i(w.trim()||f.text)},C=f.color;return a.jsxs("div",{role:"treeitem","aria-selected":t,"aria-expanded":y?!f.collapsed:void 0,tabIndex:t?0:-1,"data-node-id":f.id,draggable:!r&&!g&&!s,onDragStart:c,onDragOver:u,onDragLeave:m,onDrop:p,onClick:e=>{e.stopPropagation(),n()},onDoubleClick:e=>{e.stopPropagation(),r||o()},className:Kt("absolute flex items-center gap-2 rounded-lg border bg-card text-card-foreground px-3 select-none transition-shadow","shadow-sm hover:shadow-md cursor-pointer",g&&"font-semibold border-primary/40 bg-primary text-primary-foreground",t&&!g&&"ring-2 ring-primary ring-offset-1",t&&g&&"ring-2 ring-primary-foreground/60 ring-offset-1",h&&"ring-2 ring-accent border-accent"),style:{left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:C},children:[v&&a.jsx(v,{className:Kt("h-4 w-4 shrink-0",g&&"text-primary-foreground")}),a.jsx("div",{className:"flex-1 min-w-0",children:s?a.jsx("input",{ref:j,value:w,onChange:e=>N(e.target.value),onBlur:_,onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),_()):"Escape"===e.key?(e.preventDefault(),i(null)):e.stopPropagation()},className:Kt("w-full bg-transparent outline-none text-sm",g&&"text-primary-foreground placeholder:text-primary-foreground/60")}):x?a.jsx("div",{className:"text-sm truncate",children:x(f)}):a.jsx("div",{className:"text-sm truncate",children:f.text||a.jsx("span",{className:"opacity-50",children:"—"})})}),f.note&&!s&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{type:"button",onClick:e=>e.stopPropagation(),className:Kt("shrink-0 rounded p-0.5 hover:bg-muted/40",g&&"hover:bg-primary-foreground/10"),"aria-label":f.note,children:a.jsx(d.FileText,{className:"h-3.5 w-3.5 opacity-70"})})}),a.jsx(Nr,{className:"max-w-xs whitespace-pre-line",children:f.note})]}),y&&a.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},className:Kt("shrink-0 rounded-full border bg-background text-foreground h-5 w-5 flex items-center justify-center -mr-1","shadow-sm hover:bg-muted transition-colors",g&&"border-primary-foreground/30"),"aria-label":f.collapsed?"Expandir":"Colapsar",children:f.collapsed?a.jsx(d.Plus,{className:"h-3 w-3"}):"left"===e.side?a.jsx(d.ChevronRight,{className:"h-3 w-3 rotate-180"}):"right"===e.side?a.jsx(d.ChevronRight,{className:"h-3 w-3"}):a.jsx(d.Minus,{className:"h-3 w-3"})})]})},rp=({parent:e,child:t})=>{const s=t.x+t.width/2<e.x+e.width/2,r=s?e.x:e.x+e.width,n=e.y+e.height/2,o=s?t.x+t.width:t.x,i=t.y+t.height/2,l=(r+o)/2,d=`M ${r} ${n} C ${l} ${n}, ${l} ${i}, ${o} ${i}`;return a.jsx("path",{d:d,fill:"none",stroke:"hsl(var(--border))",strokeWidth:2,strokeLinecap:"round"})},np=({label:e,icon:t,onClick:s,disabled:r})=>a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",onClick:s,disabled:r,"aria-label":e,className:"h-8 w-8",children:t})}),a.jsx(Nr,{children:e})]}),op=e=>{const{t:t}=y.useTranslation();return a.jsxs("div",{className:"flex items-center gap-1 border-b bg-card px-2 py-1.5",children:[a.jsx(np,{label:t("mind_map_add_child"),icon:a.jsx(d.CornerDownRight,{className:"h-4 w-4"}),onClick:e.onAddChild,disabled:!e.canAddChild}),a.jsx(np,{label:t("mind_map_add_sibling"),icon:a.jsx(d.Plus,{className:"h-4 w-4"}),onClick:e.onAddSibling,disabled:!e.canAddSibling}),a.jsx(np,{label:t("mind_map_delete_node"),icon:a.jsx(d.Trash2,{className:"h-4 w-4"}),onClick:e.onDelete,disabled:!e.canDelete}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(np,{label:t("mind_map_expand_all"),icon:a.jsx(d.ChevronsUpDown,{className:"h-4 w-4"}),onClick:e.onExpandAll}),a.jsx(np,{label:t("mind_map_collapse_all"),icon:a.jsx(d.ChevronsDownUp,{className:"h-4 w-4"}),onClick:e.onCollapseAll}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(np,{label:t("mind_map_zoom_out"),icon:a.jsx(d.ZoomOut,{className:"h-4 w-4"}),onClick:e.onZoomOut}),a.jsx(np,{label:t("mind_map_zoom_in"),icon:a.jsx(d.ZoomIn,{className:"h-4 w-4"}),onClick:e.onZoomIn}),a.jsx(np,{label:t("mind_map_fit_to_screen"),icon:a.jsx(d.Maximize2,{className:"h-4 w-4"}),onClick:e.onFit}),a.jsx(ls,{orientation:"vertical",className:"mx-1 h-5"}),a.jsx(np,{label:t("mind_map_undo"),icon:a.jsx(d.Undo2,{className:"h-4 w-4"}),onClick:e.onUndo,disabled:!e.canUndo}),a.jsx(np,{label:t("mind_map_redo"),icon:a.jsx(d.Redo2,{className:"h-4 w-4"}),onClick:e.onRedo,disabled:!e.canRedo}),a.jsx("div",{className:"flex-1"}),a.jsx(np,{label:t("mind_map_export_json"),icon:a.jsx(d.Download,{className:"h-4 w-4"}),onClick:e.onExportJson}),a.jsx(np,{label:t("mind_map_export_image"),icon:a.jsx(d.Image,{className:"h-4 w-4"}),onClick:e.onExportImage})]})};function ip(e){return JSON.stringify(e,null,2)}function lp(e){if(!e||"object"!=typeof e)throw new Error("Invalid mind map node: not an object");const a=e;if("string"!=typeof a.text)throw new Error('Invalid mind map node: missing "text"');const t=Array.isArray(a.children)?a.children.map(e=>lp(e)):void 0;return Lm(a.text,{id:"string"==typeof a.id?a.id:void 0,collapsed:"boolean"==typeof a.collapsed?a.collapsed:void 0,color:"string"==typeof a.color?a.color:void 0,icon:"string"==typeof a.icon?a.icon:void 0,note:"string"==typeof a.note?a.note:void 0,side:"left"===a.side||"right"===a.side?a.side:void 0,children:t})}function dp({data:e,columns:s,sortField:r,sortDirection:n,onSort:o,onRowClick:i,renderActions:l,isLoading:c=!1,emptyMessage:u,className:m,enableSelection:p=!1,selectedIds:h=[],onSelectItem:x,onSelectAll:f,isAllSelected:g=!1,enableColumnResize:v=!0,onColumnResize:b,enableColumnReorder:j=!1,onReorderColumns:w,storageKey:N,enableExpandableRows:_=!1,renderExpandedContent:C,expandedRowIds:k,onToggleExpand:S,defaultExpandAll:T=!1,rowActionsVariant:P="default",hideActionsColumn:E=!1,actionsHeaderContent:D}){const{t:A}=y.useTranslation(),I=u||A("no_items_found",A("no_items_found_empty")),[M,F]=t.useState(()=>T?new Set(e.map(e=>e.id)):new Set),R=void 0!==k,L=R?new Set(k):M,z=t.useCallback(e=>{R&&S?S(e):F(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[R,S]),{columnWidths:U,isDragging:O,activeColumn:V,handleMouseDown:B}=fo({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:b,enabled:v}),q=ko({enabled:j&&!!w,onReorder:w??(()=>{})}),$=t.useMemo(()=>{if(v){const e=s.map(e=>U[String(e.key)]??e.width??e.minWidth??150),a=e.reduce((e,a)=>e+a,0);return e.map(e=>e/a*100+"%")}const e=s.reduce((e,a)=>a.width?e:e+(a.weight??1),0);return s.map(a=>{if(a.width)return`${a.width}px`;if(a.minWidth&&!a.weight)return`${a.minWidth}px`;const t=(a.weight??1)/e*100;return a.minWidth?`minmax(${a.minWidth}px, ${t}%)`:`${t}%`})},[s,v,U]);if(c)return a.jsx("div",{className:"flex-1 overflow-auto",children:a.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))})});if(0===e.length)return a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"text-center text-muted-foreground",children:a.jsx("p",{children:I})})});const W=l&&!E,H=(p?1:0)+(_?1:0)+s.length+(W?1:0);return a.jsx("div",{className:"flex-1 overflow-auto "+(O?"select-none":""),children:a.jsxs(Rn,{className:Kt("table-fixed w-full",m),children:[a.jsx(Ln,{className:"sticky top-0 bg-background z-10",children:a.jsxs(On,{children:[_&&a.jsx(Vn,{className:"w-[40px]"}),p&&a.jsx(Vn,{className:"w-[40px]",children:a.jsx(Xs,{checked:g,onCheckedChange:f,"aria-label":A("select_all","Selecionar todos")})}),s.map((e,t)=>{const s=v&&!1!==e.resizable,i=V===String(e.key),l=j&&!!w,c=l?q.getDragProps(t):{},u=q.dragFromIndex===t,m=q.dragOverIndex===t&&q.dragFromIndex!==t;return a.jsxs(Vn,{className:Kt(e.className,"relative transition-opacity",e.sortable&&"cursor-pointer",l&&q.isDragging&&"cursor-grabbing",u&&"opacity-50",m&&"border-l-2 border-primary"),style:{width:$[t]},...c,children:[!1!==e.sortable&&o?a.jsxs("button",{onClick:()=>o(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(p=String(e.key),r!==p?null:"asc"===n?a.jsx(d.ArrowUp,{size:14,className:"ml-1"}):a.jsx(d.ArrowDown,{size:14,className:"ml-1"}))]}):a.jsx("span",{className:"font-medium",children:e.header}),s&&a.jsx(Yn,{direction:"horizontal",onMouseDown:a=>B(String(e.key),a),isDragging:i})]},String(e.key));var p}),W&&a.jsx(Vn,{className:"w-[80px] text-right",children:D??A("actions","Ações")})]})}),a.jsx(zn,{children:e.map(e=>{const r=_&&L.has(e.id);return a.jsxs(t.Fragment,{children:[a.jsxs(On,{onClick:()=>i?.(e),className:Kt(i?"cursor-pointer":"","relative","inline"===P&&"group"),children:[_&&a.jsx(Bn,{className:"w-[40px] px-2",children:a.jsx("button",{onClick:a=>{a.stopPropagation(),z(e.id)},className:"p-1 rounded-sm hover:bg-muted transition-colors","aria-label":r?A("collapse_row","Recolher linha"):A("expand_row","Expandir linha"),children:r?a.jsx(d.ChevronDown,{size:16,className:"text-muted-foreground"}):a.jsx(d.ChevronRight,{size:16,className:"text-muted-foreground"})})}),p&&a.jsx(Bn,{children:a.jsx(Xs,{checked:h.includes(e.id),onCheckedChange:()=>x?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`${A("select_all","Selecionar todos")} ${e.id}`})}),s.map(t=>a.jsx(Bn,{className:t.className,children:a.jsx(Kn,{children:t.render?t.render(e):String(e[t.key]??"-")})},String(t.key))),W&&a.jsx(Bn,{className:"text-right",onClick:e=>e.stopPropagation(),children:"inline"===P?a.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:l(e)}):l(e)})]}),r&&C&&a.jsx(On,{className:"bg-muted/30 hover:bg-muted/30",children:a.jsx(Bn,{colSpan:H,className:"p-0",children:a.jsx("div",{className:"animate-accordion-down overflow-hidden",children:C(e)})})})]},e.id)})})]})})}function cp({onEdit:e,onDelete:s,onToggleStatus:r,isActive:n=!0,canEdit:o=!0,canDelete:i=!0,customActions:l=[],renderAs:c="dropdown",variant:u="default"}){const{t:m}=y.useTranslation(),p=t.useMemo(()=>{const a=[];return e&&o&&a.push({key:"edit",icon:d.Edit,label:m("edit","Editar"),onClick:e,variant:"default"}),r&&a.push({key:"toggle-status",icon:n?d.PowerOff:d.Power,label:n?m("deactivate","Inativar"):m("activate","Ativar"),onClick:r,variant:"default"}),l.forEach(e=>{!1!==e.show&&a.push({key:`custom-${e.label}`,icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default",disabled:e.disabled,disabledReason:e.disabledReason})}),s&&i&&a.push({key:"delete",icon:d.Trash2,label:m("remove","Remover"),onClick:s,variant:"destructive"}),a},[e,s,r,n,o,i,l,m]);return 0===p.length?null:"dropdown"===c?a.jsx(yr,{delayDuration:200,children:a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"compact"===u?"sm":"default",className:"compact"===u?"h-7 px-2":"",children:a.jsx(d.EllipsisVertical,{size:"compact"===u?14:16})})}),a.jsx(pr,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:p.map(e=>e.disabled?a.jsxs(_r,{disabledReason:e.disabledReason,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key):a.jsxs(hr,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&a.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},e.key))})]})}):a.jsx("div",{className:"flex items-center gap-1",children:p.map(e=>a.jsxs(Xt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===u?"sm":"default",onClick:e.onClick,className:"compact"===u?"h-7 px-2":"",children:[e.icon&&a.jsx(e.icon,{size:"compact"===u?14:16}),"compact"!==u&&a.jsx("span",{className:"ml-1",children:e.label})]},e.key))})}function up({searchValue:e="",onSearchChange:t,customFilters:s=[],onClearFilters:r,showClearButton:n=!0,layout:o="horizontal"}){const{t:i}=y.useTranslation(),l=e||s.length>0;return a.jsxs("div",{className:`flex ${"vertical"===o?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{type:"text",placeholder:i("search","Pesquisar"),value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),s.map((e,t)=>a.jsx("div",{className:"vertical"===o?"w-full":"",children:e},t)),n&&l&&r&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[a.jsx(d.X,{size:14,className:"mr-1"}),i("clear_filters","Limpar filtros")]})]})}function mp(e,a){const{t:t}=y.useTranslation(),s=new Set;function r(e){if(e)for(const a of e)s.add(a.id),r(a.children)}return function e(t){for(const s of t){if(s.id===a)return r(s.children),!0;if(s.children&&e(s.children))return!0}return!1}(e),s}function pp({children:e,itemId:t,enableDrag:s,onDragStartCell:r,onDragEndCell:n,onDragOverCell:o,onDropCell:i,className:l}){return a.jsx(Bn,{draggable:s,onDragStart:s?e=>r(t,e):void 0,onDragEnd:s?n:void 0,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o(t,e)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(t,e)},className:l,children:e})}function hp({item:e,level:t,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u="default",enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j,dragCount:w}){const N=o.has(e.id),_=(e.children?.length??0)>0,C=24*t,k="inline"===u,S=f===e.id||p?.has(e.id)&&f&&p?.has(f),T=g===e.id&&f!==e.id,P=p?.has(e.id)??!1,E={itemId:e.id,enableDrag:x,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j};return a.jsxs(a.Fragment,{children:[a.jsxs(On,{className:Kt(l&&"cursor-pointer",k&&"group",S&&"opacity-40",T&&"ring-2 ring-primary ring-inset bg-primary/5"),onClick:l?()=>l(e):void 0,children:[a.jsx(pp,{...E,children:a.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${C}px`},children:[m&&a.jsx(Xs,{checked:P,onCheckedChange:()=>h?.(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),x&&a.jsx("span",{className:"cursor-grab text-muted-foreground shrink-0 select-none",title:"Arrastar",children:"⠿"}),_?a.jsx("button",{onClick:a=>{a.stopPropagation(),i(e.id)},className:"p-1 hover:bg-accent rounded shrink-0",children:N?a.jsx(d.ChevronDown,{className:"h-4 w-4"}):a.jsx(d.ChevronRight,{className:"h-4 w-4"})}):a.jsx("div",{className:"w-6 shrink-0"}),n??a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"truncate",children:String(e[r]??e.id)}),f===e.id&&w&&w>1&&a.jsx("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary px-1.5 py-0 text-xs font-semibold text-primary-foreground",children:w})]})}),s.map(s=>{const r=e[s.key],n=s.render?s.render(e,t):null!=r?String(r):"—";return a.jsx(pp,{...E,className:Kt("text-center",s.className),children:s.hoverContent?a.jsxs(Ll,{openDelay:200,children:[a.jsx(zl,{asChild:!0,children:a.jsx("span",{className:"cursor-default underline decoration-dotted underline-offset-4 text-foreground",children:n})}),a.jsx(Ul,{side:"bottom",align:"center",className:"w-auto max-w-xs",children:s.hoverContent(e)})]}):n},String(s.key))}),c&&a.jsx(pp,{...E,className:"text-right",children:a.jsx("div",{onClick:e=>e.stopPropagation(),className:Kt("flex items-center justify-end gap-1",k&&"opacity-0 group-hover:opacity-100 transition-opacity"),children:c(e)})})]}),_&&N&&e.children.map(e=>a.jsx(hp,{item:e,level:t+1,columns:s,nameKey:r,iconComponent:n,expandedIds:o,onToggleExpand:i,onRowClick:l,renderActions:c,rowActionsVariant:u,enableSelection:m,selectedIds:p,onSelectItem:h,enableRowDrag:x,draggedId:f,dragOverId:g,onDragStartCell:v,onDragEndCell:b,onDragOverCell:y,onDropCell:j,dragCount:w},e.id))]})}function xp({onDrop:t,isDragOver:s,onDragOver:r,onDragLeave:n,label:o}){return a.jsxs("div",{className:Kt("absolute top-0 left-0 right-0 z-10 flex items-center justify-center gap-2 py-2 px-4 border-2 border-dashed rounded-md text-sm transition-colors mx-2 mt-2",s?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground bg-background/95"),onDragOver:r,onDragEnter:r,onDragLeave:n,onDrop:t,children:[a.jsx(d.ArrowUpToLine,{className:"h-4 w-4"}),o??e.t("leadership_make_root_short")]})}function fp({data:s,columns:r,nameKey:n,nameHeader:o=e.t("ap_name"),iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,actionsHeader:p="",rowActionsVariant:h="default",isLoading:x,emptyMessage:f="Nenhum registro encontrado.",className:g,enableSelection:v,selectedIds:b,onSelectItem:j,onSelectAll:w,isAllSelected:N,enableRowDrag:_,onMoveNode:C,onMoveNodes:k,rootDropLabel:S,actionsWidth:T=20,nameMinWidth:P=200}){const[E,D]=t.useState(null),[A,I]=t.useState(null),[M,F]=t.useState(!1),[R,L]=t.useState(1),z=t.useRef(null),U=t.useRef([]),O=t.useRef(null),V=t.useMemo(()=>new Set(b??[]),[b]),B=t.useMemo(()=>{if(!E||!s)return new Set;const e=U.current.length>0?U.current:[E],a=function(e,a){const{t:t}=y.useTranslation(),s=new Set;for(const r of a)mp(e,r).forEach(e=>s.add(e));return s}(s,e);return e.forEach(e=>a.add(e)),a},[E,s]),q=t.useRef(B);q.current=B;const $=t.useCallback(()=>{z.current=null,U.current=[],O.current=null,D(null),I(null),F(!1),L(1)},[]),W=t.useCallback((e,a)=>{e.length>1&&k?k(e,a):1===e.length&&C?.(e[0],a)},[C,k]),H=t.useCallback((e,a)=>{const t=V.has(e)&&V.size>1?Array.from(V):[e];z.current=e,U.current=t,O.current=null,D(e),L(t.length),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t))},[V]),G=t.useCallback((e,a)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",q.current.has(e)?I(null):(O.current=e,I(e))},[]),K=t.useCallback((e,a)=>{a.preventDefault(),a.stopPropagation();const t=q.current.has(e)?O.current:e;if(!t)return void $();let s=U.current;if(0===s.length){try{const e=a.dataTransfer.getData("application/x-tree-ids");if(e){const a=JSON.parse(e);Array.isArray(a)&&a.length>0&&(s=a)}}catch{}if(0===s.length){const e=a.dataTransfer.getData("text/plain");e&&(s=[e])}}0===s.length||s.includes(t)||W(s,t),$()},[W,$]),Y=t.useCallback(e=>{e.preventDefault(),e.stopPropagation();let a=U.current;if(0===a.length){try{const t=e.dataTransfer.getData("application/x-tree-ids");if(t){const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(a=e)}}catch{}if(0===a.length){const t=e.dataTransfer.getData("text/plain");t&&(a=[t])}}0!==a.length?(W(a,null),$()):$()},[W,$]),Q=t.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",F(!0)},[]),X=t.useCallback(e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[_]),J=t.useCallback(e=>{if(!_)return;const a=document.elementFromPoint(e.clientX,e.clientY)?.closest?.("[data-tree-row-id]"),t=a?.dataset?.treeRowId??O.current;t&&K(t,e)},[_,K]);if(x)return a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(!s||0===s.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-2",children:[a.jsx(d.User,{className:"h-10 w-10 text-muted-foreground/50"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:f})]});const Z=null!==E;return a.jsxs("div",{className:Kt("border rounded-lg overflow-hidden relative",g),onDragOver:X,onDrop:J,onDragLeave:_?e=>{const a=e.relatedTarget;a&&e.currentTarget.contains(a)||(I(null),F(!1))}:void 0,children:[_&&Z&&a.jsx(xp,{onDrop:Y,isDragOver:M,onDragOver:Q,onDragLeave:()=>F(!1),label:S}),a.jsxs(Rn,{children:[a.jsx(Ln,{children:a.jsxs(On,{children:[a.jsx(Vn,{className:"text-left",style:{minWidth:P},children:a.jsxs("div",{className:"flex items-center gap-2",children:[v&&a.jsx(Xs,{checked:N??!1,onCheckedChange:()=>w?.()}),o]})}),r.map(e=>a.jsx(Vn,{className:Kt("text-center",e.className),style:e.width?{width:e.width}:void 0,children:e.header},String(e.key))),m&&a.jsx(Vn,{className:"text-right",style:{width:T},children:p})]})}),a.jsx(zn,{children:s.map(e=>a.jsx(hp,{item:e,level:0,columns:r,nameKey:n,iconComponent:i,expandedIds:l,onToggleExpand:c,onRowClick:u,renderActions:m,rowActionsVariant:h,enableSelection:v,selectedIds:V,onSelectItem:j,enableRowDrag:_,draggedId:E,dragOverId:A,onDragStartCell:H,onDragEndCell:$,onDragOverCell:G,onDropCell:K,dragCount:R},e.id))})]})]})}function gp(e){const a=N.useNavigate();return{onNew:()=>{const t=e.newPath||`${e.basePath}/new`;a(t)},onEdit:t=>{const s=e.editPath?e.editPath.replace(":id",t.id):`${e.basePath}/${t.id}/edit`;a(s)}}}const vp=[{value:"pt-BR",label:"Português (Brasil)"},{value:"en-US",label:"English (US)"},{value:"es-ES",label:"Español"}],bp=({open:e,onOpenChange:s,user:r,userPhotoUrl:n,userInitials:o})=>{const{t:i,i18n:l}=y.useTranslation(),c=t.useRef(null),[u,m]=t.useState(null),[p,h]=t.useState(l.language||"pt-BR"),x=u||n,f=e=>{e||(m(null),h(l.language||"pt-BR")),s(e)};return a.jsx(ys,{open:e,onOpenChange:f,children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsx(Es,{children:i("edit_profile","Editar Perfil")})}),a.jsxs("div",{className:"space-y-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"relative flex-shrink-0",children:a.jsxs(cl,{className:"w-24 h-24",children:[x&&a.jsx(ul,{src:x,alt:r.name||""}),a.jsx(ml,{className:"bg-primary text-primary-foreground font-semibold text-2xl",children:o})]})}),a.jsxs("div",{className:"space-y-1",children:[r.name&&a.jsx("p",{className:"text-base font-semibold",children:r.name}),r.email&&a.jsx("p",{className:"text-sm text-muted-foreground",children:r.email}),a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>c.current?.click(),children:[a.jsx(d.Camera,{className:"mr-2 h-4 w-4"}),i("change_photo","Trocar foto")]}),a.jsx("input",{ref:c,type:"file",accept:"image/*",className:"hidden",onChange:e=>{const a=e.target.files?.[0];if(!a)return;const t=URL.createObjectURL(a);m(t)}})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("language","Idioma")}),a.jsxs(Vs,{value:p,onValueChange:h,children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsx(Gs,{children:vp.map(e=>a.jsx(Ys,{value:e.value,children:e.label},e.value))})]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>f(!1),children:i("cancel","Cancelar")}),a.jsx(Xt,{onClick:()=>{p!==l.language&&l.changeLanguage(p),s(!1)},children:i("save","Salvar")})]})]})})},yp="true"===(void 0).VITE_SHOW_EDIT_PROFILE,jp=t.memo(({variant:e="card",className:s="",selectedUnit:r,onUnitChange:n})=>{const{t:o}=y.useTranslation(),{user:i,companies:l,alias:c,isAuthenticated:u,logout:m,switchUnit:p}=An(),{role:h}=Yi(),x=h?.name||null,f=l?.[0]||null,g=c?l?.find(e=>e.alias===c):f,v=l||[],b=r||g||f||f,j=t.useMemo(()=>{if(!i?.id)return null;const e=(new Date).toISOString().slice(0,10);return`https://login-api.qualiex.com/api/Users/Photo/${i.id}/${e}/1?size=48`},[i?.id]),w=t.useMemo(()=>{if(!i?.name)return"";const e=i.name.trim().split(/\s+/);return 1===e.length?e[0].charAt(0).toUpperCase():(e[0].charAt(0)+e[e.length-1].charAt(0)).toUpperCase()},[i?.name]),N=t.useCallback(e=>{n?n(e):p(e)},[n,p]),_=t.useMemo(()=>{if(!v?.length)return[];const e=new Map;v.forEach(a=>{e.set(a.alias,a)});const a=Array.from(e.values()),t=a.find(e=>e.alias===b?.alias),s=a.filter(e=>e.alias!==b?.alias);return s.sort((e,a)=>(e.name||"").localeCompare(a.name||"","pt-BR",{sensitivity:"base"})),t?[t,...s]:s},[v,b?.alias]),[C,k]=t.useState(!1);if(!u||!i)return null;return"dropdown"===e?a.jsxs(a.Fragment,{children:[a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",className:`h-auto p-2 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10 ${s}`,children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs("div",{className:"hidden md:block text-right",children:[a.jsxs("p",{className:"text-sm font-medium",children:[i.name?.split(" ")[0],x?` [${x}]`:""]}),a.jsx("p",{className:"text-xs text-primary-foreground/70",children:b?.name||"N/A"})]}),a.jsxs(cl,{className:"w-8 h-8 border border-primary-foreground/30",children:[j&&a.jsx(ul,{src:j,alt:i.name||o("user_photo")}),a.jsx(ml,{className:"bg-primary-foreground/20 text-primary-foreground font-semibold text-xs",children:w||a.jsx(d.User,{className:"h-4 w-4"})})]}),a.jsx(d.ChevronDown,{className:"h-4 w-4"})]})})}),a.jsxs(pr,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[a.jsxs(dr,{children:[a.jsxs(ur,{children:[a.jsx(d.RefreshCw,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),a.jsx(mr,{children:_.map(e=>a.jsxs(hr,{onClick:()=>N(e),className:e.alias===b?.alias?"bg-muted":"",children:[a.jsx(d.Building2,{className:"mr-2 h-4 w-4"}),e.name,e.alias===b?.alias&&a.jsx(er,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),yp&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsxs(hr,{onClick:()=>k(!0),children:[a.jsx(d.UserPen,{className:"mr-2 h-4 w-4"}),o("edit_profile","Editar Perfil")]})]}),a.jsx(vr,{}),a.jsxs(hr,{onClick:m,children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}),yp&&a.jsx(bp,{open:C,onOpenChange:k,user:i,userPhotoUrl:j,userInitials:w})]}):a.jsxs(ts,{className:s,children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-lg",children:o("user_info")})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx("div",{className:"flex-shrink-0",children:a.jsxs(cl,{className:"w-10 h-10",children:[j&&a.jsx(ul,{src:j,alt:i.name||o("user_photo")}),a.jsx(ml,{className:"bg-primary text-primary-foreground text-white font-semibold text-sm",children:w||a.jsx(d.User,{className:"h-5 w-5"})})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:i.name}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",b?.name||"N/A"]})]})]}),b&&a.jsx("div",{className:"mt-3",children:a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:b.name})]})}),_.length>1&&a.jsxs("div",{className:"mt-2",children:[a.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",_.length]}),a.jsxs("div",{className:"flex flex-wrap gap-1",children:[_.slice(0,3).map(e=>a.jsx(er,{variant:e.alias===b?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>N(e),children:e.name},e.alias)),_.length>3&&a.jsxs(er,{variant:"outline",className:"text-xs",children:["+",_.length-3]})]})]})]}),{}),a.jsx(ls,{}),a.jsxs(Xt,{variant:"outline",onClick:m,size:"sm",className:"w-full",children:[a.jsx(d.LogOut,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),wp=t.createContext({});function Np({children:e,config:s}){const r=t.useMemo(()=>{const e=Ie(),a=s?.appName?e?`${s.appName} (Dev)`:s.appName:void 0;return{navigation:s?.navigation,appName:a}},[s?.navigation,s?.appName]);return a.jsx(wp.Provider,{value:r,children:e})}function _p(){return t.useContext(wp)}function Cp(e,a){if(!e)return"";const t=e.find(e=>e.path===a);if(t)return t.label;const s=e.find(e=>a.startsWith(e.path+"/"));return s?.label||""}function kp(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]}function Sp({appName:e}){const[s,r]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between w-[258px]",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>r(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),e&&a.jsx("button",{className:"min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground/80 hover:text-primary-foreground/60 transition-colors leading-tight py-1",onClick:()=>r(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(e)})})]}),a.jsx(Xi,{open:s,onOpenChange:r})]})}const Tp=t.memo(function({actions:s}){const r=N.useLocation(),n=N.useNavigate(),{navigation:o,appName:i}=_p(),l=Cp(o,r.pathname),{metadata:c,headerActions:u}=oi(),{setOpenMobile:m}=Ud(),{companies:p,alias:h,isSearchVisible:x,clearSearch:f,refreshData:g,switchUnit:v}=An(),b=h?p?.find(e=>e.alias===h)||p?.[0]||null:p?.[0]||null,[y,j]=N.useSearchParams(),w=t.useCallback(e=>{const{pathname:a,search:t,hash:s}=r;if(h){const r=a.split("/"),o=r.indexOf(h);if(o>=0)return r[o]=e.alias,void n(r.join("/")+t+s)}v(e)},[h,r,n,v]),[_,C]=t.useState(()=>y.get("search")||""),[k,S]=kp(_,Re.debounceDelay);t.useEffect(()=>{if(!x)return;const e=new URLSearchParams(y);k?(e.set("search",k),e.set("page","1")):e.delete("search"),j(e)},[k,j,x]);const T=o?.find(e=>e.path===r.pathname)||o?.find(e=>r.pathname.startsWith(e.path+"/")),P=c.title||l,E=c.subtitle||T?.complementaryText||"";return a.jsx("header",{className:"bg-primary border-b border-primary px-2 md:px-4 py-2",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Xt,{variant:"ghost",size:"sm",className:"md:hidden h-8 w-8 p-0 flex-shrink-0 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:()=>m(!0),children:a.jsx(d.Menu,{size:20})}),a.jsx("div",{className:"hidden md:flex items-center flex-shrink-0",children:a.jsx(Sp,{appName:i})}),a.jsx("div",{className:"hidden md:block w-px h-8 bg-primary-foreground/20 flex-shrink-0"}),a.jsxs("div",{className:"flex-shrink-0",children:[c.breadcrumbs&&c.breadcrumbs.length>0&&a.jsx("nav",{className:"flex items-center gap-1 text-xs text-primary-foreground/70 mb-0.5",children:c.breadcrumbs.map((e,t)=>a.jsxs("span",{className:"flex items-center gap-1",children:[t>0&&a.jsx(d.ChevronRight,{className:"h-3 w-3"}),e.href?a.jsx(N.Link,{to:e.href,className:"hover:text-primary-foreground transition-colors",children:e.label}):a.jsx("span",{children:e.label})]},t))}),a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("h1",{className:"text-lg font-semibold text-primary-foreground truncate",children:P})}),E&&a.jsx("div",{className:"text-sm text-primary-foreground/70 truncate",children:E})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),a.jsx(Zt,{placeholder:"Pesquisar",value:_,onChange:e=>{return a=e.target.value,void C(a);var a},className:"w-full pl-10 pr-8"}),_&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-primary-foreground/10 text-primary-foreground/60",onClick:()=>{S(),C("");const e=new URLSearchParams(y);e.delete("search"),e.delete("page"),j(e)},title:e.t("clear_search"),children:a.jsx(d.X,{size:14})})]}),a.jsx(Xt,{variant:"outline",size:"sm",onClick:g,className:"flex-shrink-0 h-10 w-10 p-0 bg-primary-foreground/20 border-primary-foreground/30 text-primary-foreground hover:bg-primary-foreground/30 hover:text-primary-foreground",title:e.t("refresh_data"),children:a.jsx(d.RefreshCw,{size:14})})]}),a.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[(u||s)&&a.jsx("div",{className:"flex items-center gap-2",children:u||s}),(void 0).VITE_WIKI_URL&&a.jsx(Xt,{variant:"ghost",size:"sm",className:"h-8 px-3 text-primary-foreground hover:text-primary-foreground hover:bg-primary-foreground/10",onClick:e=>Ht((void 0).VITE_WIKI_URL,e),title:e.t("open_wiki"),children:"Wiki"}),a.jsx(Jc,{}),a.jsx("div",{className:"text-sm",children:a.jsx(jp,{variant:"dropdown",selectedUnit:b,onUnitChange:w})})]})]})})}),Pp=({key:e,enabled:a,checkFn:t,staleTime:s=3e5,gcTime:r=6e5})=>w.useQuery({queryKey:["permission",e],queryFn:t,enabled:a,staleTime:s,gcTime:r,retry:0,refetchOnWindowFocus:!1});function Ep({config:e,isCollapsed:t=!1,isDisabled:s=!1,className:r}){const{t:n}=y.useTranslation(),{actions:o,triggerLabel:i="Criar",triggerIcon:l=d.Plus,variant:c="button"}=e;if(!o||0===o.length)return null;if("split-button"===c){const e=o[0],n=e.icon||l,i=o.slice(1).map(e=>({id:e.id,label:e.label,icon:e.icon,onClick:e.onClick,disabled:e.disabled}));if(t){const t=a.jsx(Xt,{onClick:e.onClick,disabled:s||e.disabled,className:Kt("justify-center px-2 w-full",r),variant:"outline",size:"default",children:a.jsx(n,{className:"h-4 w-4 shrink-0"})});return a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:t}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})}return a.jsx(qc,{label:e.label,onClick:e.onClick,icon:n,actions:i,variant:"outline",disabled:s||e.disabled,className:Kt("w-full",r),menuAlign:"start"})}const u=(e,s,r=!1)=>a.jsxs(a.Fragment,{children:[e,!t&&s&&a.jsx("span",{className:"truncate",children:s}),!t&&r&&a.jsx(d.ChevronDown,{className:"ml-auto h-4 w-4 shrink-0"})]});if(!(o.length>1)){const e=o[0],n=e.icon||l,i=s||e.disabled,d=a.jsx(Xt,{onClick:e.onClick,disabled:i,className:Kt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(n,{className:"h-4 w-4 shrink-0"}),e.label)});return t?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:d}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]}):d}const m=a.jsx(Xt,{disabled:s,className:Kt("w-full gap-2 justify-start",t&&"justify-center px-2",r),variant:"outline",size:"default",children:u(a.jsx(l,{className:"h-4 w-4 shrink-0"}),i,!0)});return a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:t?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:m}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:i})})]}):m}),a.jsx(pr,{align:"start",side:t?"right":"bottom",className:"w-56 bg-popover",children:o.map(e=>{const t=e.icon;return a.jsxs(hr,{onClick:e.onClick,disabled:e.disabled,className:"cursor-pointer",children:[t&&a.jsx(t,{className:"mr-2 h-4 w-4"}),e.label]},e.id)})})]})}const Dp="forlogic-sidebar-pinned",Ap=()=>{try{const e=localStorage.getItem(Dp);return!!e&&JSON.parse(e)}catch{return!1}};function Ip({direction:e="right",minWidth:a=224,maxWidth:s=384,defaultWidth:r=290,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","290px"))},[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 Mp=t.createContext(void 0);function Fp(){const e=t.useContext(Mp);return e||{openModals:new Set,hasOpenModal:!1,registerModal:()=>{},unregisterModal:()=>{},setHasOpenModal:()=>{}}}function Rp({config:e,customContent:s,resizable:r=!1,minWidth:n=224,maxWidth:o=384}={}){const{t:i}=y.useTranslation(),{open:l,setOpen:c,setOpenMobile:u}=Ud(),m=N.useLocation(),{alias:p,user:h}=An(),{appName:x}=_p(),{hasOpenModal:f}=Fp(),[g,v]=t.useState(Ap),b=Fn(),j=!!b||l,w=t.useCallback(()=>{b&&u(!1)},[b,u]),_=r?Ip({minWidth:n,maxWidth:o,storageKey:"app-sidebar-width",isOpen:l}):null;t.useEffect(()=>{c(!!g)},[g,c]);const C=e=>m.pathname===e||m.pathname.startsWith(e+"/");return a.jsxs(Vd,{collapsible:"icon",className:Kt("app-sidebar bg-background border-r border-border flex flex-col",j?"px-3":"px-1.5"),style:_&&j?{width:`${_.width}px`,transition:"none"}:{transition:"width 300ms ease-in-out"},children:[e?.moduleActions&&e.moduleActions.actions.length>0&&a.jsx("div",{className:"py-3",children:a.jsx(yr,{children:a.jsx(Ep,{config:e.moduleActions,isCollapsed:!j,isDisabled:f})})}),a.jsx(Yd,{className:Kt(e?.moduleActions&&e.moduleActions.actions.length>0?"pt-0":"pt-3"),children:s||a.jsx(Qd,{className:"p-0",children:a.jsx(Zd,{children:a.jsx(ec,{className:"gap-1",children:a.jsx(yr,{children:e?.navigation?.map((e,t)=>{if("separator"===e.type)return a.jsx(Kd,{className:"my-2"},`sep-${t}`);const s=({item:e,index:t})=>{const r=`${e.path}-${t}-${p??"noalias"}-${h?.id??"nouser"}`,{data:n=!0,isLoading:o}=Pp({key:r,enabled:Boolean(e.permissionCheck&&p&&h?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),l=e.permissionCheck&&!n,c=o?d.Loader2:l?d.Lock:e.icon;l?i("restricted_access"):e.complementaryText;return e.children&&e.children.length>0?j?a.jsx(yi,{defaultOpen:!0,className:"group/collapsible",children:a.jsxs(ac,{children:[a.jsx(ji,{asChild:!0,children:a.jsx(sc,{size:"default",children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label}),a.jsx(d.ChevronRight,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90"})]})})}),a.jsx(wi,{children:a.jsx(ic,{children:e.children.map((e,t)=>a.jsx(s,{item:e,index:t},e.path))})})]})},e.path):a.jsx(ac,{children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("div",{className:Kt("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:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path):a.jsx(ac,{children:l||o?a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:j?a.jsx(sc,{size:"default",className:"opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:a.jsxs("div",{className:"flex w-full items-center gap-3",children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.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:a.jsx(c,{className:"h-4 w-4 "+(o?"animate-spin":"")})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:o?"Verificando acesso...":i("restricted_access")})})]}):j?a.jsx(sc,{asChild:!0,isActive:C(e.path),size:"default",children:a.jsxs(N.Link,{to:e.path,className:"flex w-full items-center gap-3",onClick:w,children:[a.jsx("span",{className:"flex items-center justify-center h-8 w-8",children:a.jsx(c,{className:"h-4 w-4"})}),a.jsx("span",{className:"font-medium sidebar-text",children:e.label})]})}):a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(N.Link,{to:e.path,onClick:w,className:Kt("flex items-center justify-center h-8 w-8 mx-auto rounded-md transition-colors",C(e.path)?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:a.jsx(c,{className:"h-4 w-4"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:e.label})})]})},e.path)};return a.jsx(s,{item:e,index:t},e.path)})})})})})}),!b&&a.jsx("div",{className:Kt("mt-auto pb-4 pt-2 flex",l?"justify-end":"justify-center"),children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx("button",{id:"btn-expand-side-nav",onClick:()=>{const e=!g;v(e),(e=>{try{localStorage.setItem(Dp,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:l?a.jsx(d.ChevronLeft,{className:"h-3.5 w-3.5 text-primary-foreground"}):a.jsx(d.ChevronRight,{className:"h-3.5 w-3.5 text-primary-foreground"})})}),a.jsx(Nr,{side:"right",children:a.jsx("p",{children:l?"Recolher":"Expandir"})})]})}),r&&_&&j&&a.jsx("div",{ref:_.dragRef,onMouseDown:_.handleMouseDown,className:Kt("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-['']",_.isDragging&&"bg-primary/40")})]})}const Lp=t.memo(function({children:e,sidebar:s,sidebarConfig:r,showHeader:n=!0}){const o=t.useMemo(()=>s||a.jsx(Rp,{config:r}),[s,r]),i=t.useMemo(()=>({"--sidebar-width":"290px","--sidebar-width-icon":"58px"}),[]),l=t.useRef(null),d=t.useRef(null),c=t.useCallback(()=>{if(l.current&&d.current){const e=l.current.offsetHeight;d.current.style.setProperty("--header-height",`${e}px`)}},[]);return t.useEffect(()=>{c();const e=new ResizeObserver(c);return l.current&&e.observe(l.current),()=>e.disconnect()},[c]),a.jsx(Np,{config:r,children:a.jsx(ni,{children:a.jsx(Od,{defaultOpen:!1,style:i,children:a.jsxs("div",{ref:d,className:"flex flex-col h-screen w-full overflow-hidden",children:[n&&a.jsx("div",{ref:l,className:"flex-shrink-0 sticky top-0 z-40 bg-primary",children:a.jsx(Tp,{})}),a.jsxs("div",{className:"sidebar-container flex flex-1 overflow-hidden",children:[o,a.jsx("main",{className:"relative z-0 flex-1 flex flex-col overflow-hidden",children:a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30",children:e})})]})]})})})})});class zp{static async sendEmail(e){const a=cn(),{data:t,error:s}=await a.functions.invoke("send-email",{body:{template_code:e.templateCode,to:e.to,variables:e.variables,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo}});if(s)throw s;return t}}const Up=zp;function Op({open:e,onOpenChange:s,placeId:r,placeName:n,onMakeManager:o,onMakeMembers:i,currentManagerId:l,currentMemberIds:c=[]}){const{t:u}=y.useTranslation(),[m,p]=t.useState([]),[h,x]=t.useState(!1),[f,g]=t.useState(""),{data:v=[],isLoading:b}=Uo({enabled:e}),j=t.useMemo(()=>{let e=[...v];if(e.sort((e,a)=>{const t=e.userName?.toLowerCase()||"",s=a.userName?.toLowerCase()||"";return t.localeCompare(s)}),f){const a=f.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(a)||e.userEmail?.toLowerCase().includes(a))}return e},[v,f]),w=e=>{p(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},N=1===m.length,_=m.length>0;return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"max-w-2xl",variant:"form",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsxs(Es,{className:"flex items-center gap-2",children:[a.jsx(d.Users,{className:"h-5 w-5"}),"Gerenciar Acessos - ",n]})}),a.jsxs(Ts,{children:[a.jsxs("div",{className:"relative mb-4",children:[a.jsx(d.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{placeholder:"Pesquisar...",value:f,onChange:e=>g(e.target.value),className:"pl-9"})]}),a.jsx(Io,{className:"h-[400px] pr-4",children:b?a.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>a.jsx(Rr,{className:"h-16 w-full"},t))}):0===j.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(d.Users,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:u(f?"leadership_no_users_found":"leadership_no_users_available")})]}):a.jsx("div",{className:"space-y-2",children:j.map(e=>{const t=e.userId===l,s=c.includes(e.userId||""),r=m.includes(e.userId||"");return a.jsxs("div",{className:Kt("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(e.userId||""),children:[a.jsx(Xs,{checked:r,onCheckedChange:()=>w(e.userId||""),onClick:e=>e.stopPropagation()}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium",children:e.userName}),t&&a.jsx(d.Crown,{className:"h-4 w-4 text-yellow-500"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||s)&&a.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})})]}),a.jsxs(Ps,{className:"flex gap-2 sm:gap-2",children:[a.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:m.length>0&&a.jsxs("span",{children:[m.length," selecionado(s)"]})}),N&&o&&a.jsxs(Xt,{onClick:async()=>{if(o&&1===m.length){x(!0);try{await o(m[0],r),p([])}finally{x(!1)}}},disabled:h,variant:"outline",children:[a.jsx(d.Crown,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),_&&i&&a.jsxs(Xt,{onClick:async()=>{if(i&&0!==m.length){x(!0);try{await i(m,r),p([])}finally{x(!1)}}},disabled:h,children:[a.jsx(d.UserPlus,{className:"h-4 w-4 mr-2"}),"Tornar ",m.length>1?"Membros":"Membro"]})]})]})})}function Vp({place:e,level:s=0,manageAccessConfig:r}){const{t:n}=y.useTranslation(),[o,i]=t.useState(!1),[l,c]=t.useState(!1),u=e.subPlaces&&e.subPlaces.length>0,m=e.isActive??!0,p=e.usersCount??0;return a.jsxs("div",{children:[a.jsxs(yi,{open:o,onOpenChange:i,children:[a.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:[u?a.jsxs(ji,{className:"flex items-center gap-2 flex-1",children:[a.jsx(d.ChevronRight,{className:Kt("h-4 w-4 transition-transform shrink-0",o&&"rotate-90")}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):a.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a.jsx("div",{className:"w-4 shrink-0"}),a.jsx(d.Building2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Users,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:p})]}),a.jsx(er,{variant:m?"default":"secondary",className:"text-xs",children:m?"Ativo":"Inativo"}),r&&a.jsx(cp,{customActions:[{label:n("manage_access"),icon:d.Settings,onClick:()=>c(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),u&&a.jsx(wi,{children:e.subPlaces.map(e=>a.jsx(Vp,{place:e,level:s+1,manageAccessConfig:r},e.id))})]}),0===s&&a.jsx(ls,{}),r&&a.jsx(Op,{open:l,onOpenChange:c,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}const Bp=new class{get baseUrl(){return Oe()}async makeApiCall(e,a,t){const s=hn.validateToken();if(!s.valid)throw new Error(s.message||"Token inválido");const r=an.getAccessToken();if(!r)throw new Error("Token Qualiex não encontrado");if(!t||""===t.trim())throw new Error("Alias da unidade é obrigatório");const n=new URL(e,this.baseUrl);Object.entries(a).forEach(([e,a])=>{n.searchParams.append(e,a)});const o=await fetch(n.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!o.ok){const e=new Error(`API call failed: ${o.status}`);throw e.status=o.status,e}return o.json()}buildHierarchy(e){const a=new Map,t=[];return e.forEach(e=>{a.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const s=a.get(e.id);if(e.parentId){const r=a.get(e.parentId);r?(r.subPlaces=r.subPlaces||[],r.subPlaces.push(s)):t.push(s)}else t.push(s)}),t}async getPlaces(e,a){try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(t){if(await hn.handleApiError(t))try{const t=await this.makeApiCall("/api/common/v1/places",{companyId:a},e),s=t.data||t||[];return this.buildHierarchy(s)}catch(s){return tn.handleError(s instanceof Error?s:"Erro ao buscar locais após renovação de token",!0),[]}return tn.handleError(t instanceof Error?t.message:"Erro ao buscar locais",!0),[]}}};function qp(e){const a=new Map,t=new Map,s=[];e.forEach(e=>{const s={...e,children:[],level:0};a.set(e.id,s),t.set(e.id_user,s)}),e.forEach(e=>{const r=a.get(e.id);if(e.id_leader){const a=t.get(e.id_leader);if(a)return void a.children.push(r)}s.push(r)});const r=(e,a)=>{e.level=a,e.children.forEach(e=>r(e,a+1))};s.forEach(e=>r(e,0));const n=e=>{e.sort((e,a)=>{const t=e.name||e.id_user||e.email||"",s=a.name||a.id_user||a.email||"";return t.localeCompare(s)}),e.forEach(e=>e.children.length>0&&n(e.children))};return n(s),s}function $p(e){const a=[],t=e=>{a.push(e),e.children.forEach(t)};return e.forEach(t),a}function Wp(){const{alias:a,isAuthenticated:t}=An(),s=an.getAccessToken(),{data:r=[]}=Uo({enabled:!0,status:"all"});return w.useQuery({queryKey:["leadership",a],queryFn:async()=>{if(!s||!a)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=cn(),{data:n,error:o}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",a);if(o)throw new Error("Erro ao buscar hierarquia de liderança");if(!n||0===n.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const l=n.map(a=>{const t=n.filter(e=>e.id_leader===a.id_user);return{...a,name:i[a.id_user]?.name||e.t("inactive_user"),email:i[a.id_user]?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))}}),d=new Set(n.map(e=>e.id_user));return new Set(n.filter(e=>e.id_leader&&!d.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const a=i[e],t=n.filter(a=>a.id_leader===e);l.push({id:`virtual-${e}`,alias:n[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:a?.name||"[Usuário inativo]",email:a?.email||"",subordinatesCount:t.length,subordinateNames:t.map(e=>i[e.id_user]?.name||"[Usuário inativo]").sort((e,a)=>e.localeCompare(a))})}),qp(l)},enabled:!!s&&!!a&&t})}(void 0).VITE_SUPABASE_URL,rn();const Hp="common";function Gp(){const{alias:e}=An(),a=w.useQueryClient(),t=cn(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(a.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Jp(t,e,a.id_user,a.id_leader);const{data:r,error:n}=await t.schema(Hp).from("leaders").insert({alias:e,id_user:a.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1}).select().single();if(n)throw n;return r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_promoted_success","Líder virtual promovido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_create_error","Erro ao criar líder"))}})}function Kp(){const{alias:e}=An(),a=w.useQueryClient(),t=cn(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));if(!a.users.length)throw new Error(s("select_at_least_one",s("leadership_select_subordinates")));const r=a.users.map(e=>e.id_user),{data:n}=await t.schema(Hp).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 a.users){if(a.id_leader&&d.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Jp(t,e,d.id_user,a.id_leader)}const o=a.users.map(t=>({alias:e,id_user:t.id_user,id_leader:a.id_leader,is_active:!0,is_removed:!1})),{data:i,error:l}=await t.schema(Hp).from("leaders").insert(o).select();if(l)throw l;return i},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_added_success",`${t?.length||0} liderado(s) adicionado(s) com sucesso`))},onError:e=>{l.toast.error(e.message||s("subordinates_add_error","Erro ao adicionar liderados"))}})}function Yp(){const{alias:e}=An(),a=w.useQueryClient(),t=cn(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{data:r}=await t.schema(Hp).from("leaders").select("id_user").eq("id",a.id).eq("alias",e).single();if(!r)throw new Error(s("leader_not_found","Líder não encontrado"));if(r.id_user===a.id_leader)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));a.id_leader&&await Jp(t,e,r.id_user,a.id_leader,a.id);const{data:n,error:o}=await t.schema(Hp).from("leaders").update({id_leader:a.id_leader}).eq("id",a.id).eq("alias",e).select().single();if(o)throw o;return n},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_updated_success","Líder atualizado com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_update_error","Erro ao atualizar líder"))}})}function Qp(){const{alias:e}=An(),a=w.useQueryClient(),t=cn(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async a=>{if(!e)throw new Error(s("unit_not_selected","Unidade não selecionada"));const{error:r}=await t.schema(Hp).from("leaders").update({is_removed:!0}).eq("id",a).eq("alias",e);if(r)throw r},onSuccess:()=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("leader_removed_success","Líder removido com sucesso"))},onError:e=>{l.toast.error(e.message||s("leader_remove_error","Erro ao remover líder"))}})}function Xp(){const{alias:e}=An(),a=w.useQueryClient(),t=cn(),{t:s}=y.useTranslation();return w.useMutation({mutationFn:async({leaderUserId:a,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([t.schema(Hp).from("leaders").select("id, id_user, id_leader").eq("alias",e).eq("is_removed",!1).eq("id_leader",a),t.schema(Hp).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)),x=m.filter(e=>e.id_leader!==a),f=new Set(m.map(e=>e.id_user)),g=r.filter(e=>!f.has(e.id_user));for(const s of x)await Jp(t,e,s.id_user,a,s.id);for(const y of g){if(y.id_user===a)throw new Error(s("cannot_be_own_leader","Usuário não pode ser seu próprio líder"));await Jp(t,e,y.id_user,a)}const v=[];if(h.length){const a=h.map(e=>e.id);v.push(t.schema(Hp).from("leaders").update({is_removed:!0}).in("id",a).eq("alias",e))}if(x.length){const s=x.map(e=>e.id);v.push(t.schema(Hp).from("leaders").update({id_leader:a}).in("id",s).eq("alias",e))}if(g.length){const s=g.map(t=>({alias:e,id_user:t.id_user,id_leader:a,is_active:!0,is_removed:!1}));v.push(t.schema(Hp).from("leaders").insert(s))}const b=(await Promise.all(v)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:h.length,updated:x.length,created:g.length}},onSuccess:t=>{a.invalidateQueries({queryKey:["leadership",e]}),l.toast.success(s("subordinates_synced_success",`Subordinados sincronizados (${t.created} adicionados, ${t.updated} atualizados, ${t.unlinked} removidos)`))},onError:e=>{l.toast.error(e.message||s("subordinates_sync_error","Erro ao sincronizar subordinados"))}})}async function Jp(a,t,s,r,n){const{data:o,error:i}=await a.schema(Hp).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(i)throw i;const l=n?o.filter(e=>e.id!==n):o,d=new Set;let c=r;for(;c;){if(d.has(c))throw new Error(e.t("leadership_cycle_error"));if(c===s)throw new Error("Esta associação criaria um ciclo na hierarquia");d.add(c);const a=l.find(e=>e.id_user===c);c=a?.id_leader||null}}var Zp=function(e,a){for(var t={};e.length;){var s=e[0],r=s.code,n=s.message,o=s.path.join(".");if(!t[o])if("unionErrors"in s){var i=s.unionErrors[0].errors[0];t[o]={message:i.message,type:i.code}}else t[o]={message:n,type:r};if("unionErrors"in s&&s.unionErrors.forEach(function(a){return a.errors.forEach(function(a){return e.push(a)})}),a){var l=t[o].types,d=l&&l[s.code];t[o]=h.appendErrors(o,a,t,r,d?[].concat(d,s.message):s.message)}e.shift()}return t},eh=function(e,a,t){return void 0===t&&(t={}),function(s,r,n){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(e["sync"===t.mode?"parse":"parseAsync"](s,a)).then(function(e){return n.shouldUseNativeValidation&&Z.validateFieldsNatively({},n),{errors:{},values:t.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:Z.toNestErrors(Zp(e.errors,!n.shouldUseNativeValidation&&"all"===n.criteriaMode),n)};throw e}))}catch(o){return Promise.reject(o)}}};const ah=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string()).min(1,e.t("leadership_select_subordinates"))}),th=J.z.object({id_leader:J.z.string().nullable(),id_users:J.z.array(J.z.string())});function sh({value:s,onChange:r,excludeUserIds:n=[],error:o}){const{data:i=[],isLoading:l}=Uo(),[c,u]=t.useState(""),m=t.useRef(null),p=t.useRef(0),h=i.filter(e=>!n.includes(e.userId||"")).filter(e=>{const a=c.toLowerCase(),t=e.userName?.toLowerCase().includes(a);return t}).sort((e,a)=>{const t=s.includes(e.userId),r=s.includes(a.userId);if(t&&!r)return-1;if(!t&&r)return 1;const n=e.userName||e.userEmail||"",o=a.userName||a.userEmail||"";return n.localeCompare(o)});return t.useEffect(()=>{m.current&&p.current>0&&(m.current.scrollTop=p.current)},[h]),l?a.jsxs("div",{className:"flex items-center justify-center p-4",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin"}),a.jsx("span",{className:"ml-2",children:"Carregando dados..."})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Zt,{placeholder:e.t("search_user_placeholder"),value:c,onChange:e=>u(e.target.value)}),a.jsx("div",{ref:m,className:"border rounded-md p-4 max-h-[300px] overflow-y-auto",children:0===h.length?a.jsx("p",{className:"text-sm text-muted-foreground",children:e.t("search_user_placeholder")}):a.jsx("div",{className:"space-y-2",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Xs,{id:e.userId,checked:s.includes(e.userId),onCheckedChange:()=>{return a=e.userId,m.current&&(p.current=m.current.scrollTop),void(s.includes(a)?r(s.filter(e=>e!==a)):r([...s,a]));var a}}),a.jsx(as,{htmlFor:e.userId,className:"flex-1 cursor-pointer",children:e.userName||e.userEmail})]},e.userId))})}),s.length>0&&a.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," selecionado(s)"]}),o&&a.jsx("p",{className:"text-sm text-destructive",children:o})]})}function rh({leader:s,prefilledLeaderId:r,onSuccess:n}){const{t:o}=y.useTranslation(),{alias:i}=An(),l=!!s,c=s?.id.startsWith("virtual-"),u=Kp(),m=Gp(),p=Yp(),x=Xp(),f=Qp(),{data:g=[]}=Wp(),{data:v=[]}=Uo(),[b,j]=t.useState(""),w=$p(g).map(e=>e.id_user),N=l?$p(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user):[],_=h.useForm({resolver:eh(l?th:ah),defaultValues:{id_leader:r||(l?s?.id_leader:null)||null,id_users:l?N:[]}});t.useEffect(()=>{if(s){const e=$p(g).filter(e=>e.id_leader===s.id_user).map(e=>e.id_user);_.reset({id_leader:s.id_leader||null,id_users:e})}else r?_.reset({id_leader:r,id_users:[]}):_.reset({id_leader:null,id_users:[]})},[i,s?.id,s?.id_user,s?.id_leader,r,g]);const C=u.isPending||m.isPending||p.isPending||x.isPending||f.isPending,k=_.watch("id_leader"),S=_.watch("id_users"),T=l?[s.id_user,...w.filter(e=>e!==s.id_user&&!S.includes(e)&&!N.includes(e))]:[k,...w.filter(e=>!S.includes(e))].filter(Boolean);return a.jsxs("form",{onSubmit:_.handleSubmit(async e=>{try{if(l)if(c){await m.mutateAsync({id_user:s.id_user,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{await p.mutateAsync({id:s.id,id_leader:e.id_leader});const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await x.mutateAsync({leaderUserId:s.id_user,selectedUsers:a})}else{const a=v.filter(a=>e.id_users.includes(a.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({id_leader:e.id_leader,users:a})}n?.()}catch(a){}}),className:"space-y-4",children:[l&&a.jsxs("div",{children:[a.jsx(as,{children:e.t("leader")}),a.jsx(Zt,{value:v.find(e=>e.userId===s.id_user)?.userName||s.name||e.t("inactive_user"),disabled:!0,className:"bg-muted"})]}),a.jsxs("div",{children:[a.jsx(as,{children:o("leadership_immediate_superior")}),a.jsxs(Vs,{value:k||"none",onValueChange:e=>_.setValue("id_leader","none"===e?null:e),children:[a.jsx($s,{children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:a.jsx(Zt,{placeholder:"Buscar superior...",value:b,onChange:e=>j(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),a.jsxs(Io,{className:"h-[200px]",children:[a.jsx(Ys,{value:"none",children:"[Nenhum]"}),v.filter(e=>{const a=l?e.userId!==s.id_user:!S.includes(e.userId),t=!b||e.userName?.toLowerCase().includes(b.toLowerCase());return a&&t}).sort((e,a)=>{const t=e.userName||e.userEmail||"",s=a.userName||a.userEmail||"";return t.localeCompare(s)}).map(e=>a.jsx(Ys,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${i}`),_.formState.errors.id_leader&&a.jsx("p",{className:"text-sm text-destructive mt-1",children:_.formState.errors.id_leader.message})]}),a.jsxs("div",{children:[a.jsx(as,{children:"Subordinados *"}),a.jsx(sh,{value:S,onChange:e=>_.setValue("id_users",e),excludeUserIds:T,error:_.formState.errors.id_users?.message},`users-multiselect-${i}`)]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx(Xt,{type:"submit",disabled:C||!l&&0===S.length,children:C&&!f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Atualizando...":"Salvando..."]}):l?"Atualizar":"Criar"}),l&&!k&&0===S.length&&a.jsxs(ds,{children:[a.jsx(cs,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"destructive",disabled:C,className:"ml-auto",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Trash2,{className:"mr-2 h-4 w-4"}),"Remover"]})})}),a.jsxs(ps,{children:[a.jsxs(hs,{children:[a.jsx(fs,{children:o("confirm_removal")}),a.jsx(gs,{children:"Tem certeza que deseja remover este líder? Esta ação não pode ser desfeita."})]}),a.jsxs(xs,{children:[a.jsx(bs,{children:o("cancel")}),a.jsx(vs,{onClick:async()=>{if(s)try{await f.mutateAsync(s.id),n?.()}catch(e){}},children:o("remove")})]})]})]})]})]})}function nh({open:e,onOpenChange:t,leader:s,prefilledLeaderId:r,title:n}){return a.jsx(ys,{open:e,onOpenChange:t,children:a.jsxs(ks,{variant:"form",className:"sm:max-w-[500px]",children:[a.jsx(Ss,{showSeparator:!0,children:a.jsx(Es,{children:n})}),a.jsx(Ts,{children:a.jsx(rh,{leader:s,prefilledLeaderId:r,onSuccess:()=>t(!1)})})]})})}const oh="leadership-expanded-nodes",ih=(e,a)=>{try{localStorage.setItem(`${oh}-${e}`,JSON.stringify(Array.from(a)))}catch{}};function lh(e){const[a,s]=t.useState(!1),{uploadFunction:r,deleteFunction:n,defaultOptions:o,onSuccess:i,onError:d}=e||{};return{upload:async(e,a)=>{if(!r){const e=new Error("uploadFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de upload não configurada. Verifique a documentação."}),e}s(!0);try{const t={...o,...a};if(t.maxSize&&e.size>t.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(t.maxSize/1024/1024)}MB`);if(t.allowedTypes){if(!t.allowedTypes.some(a=>a.endsWith("/*")?e.type.startsWith(a.replace("/*","")):e.type===a))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${t.allowedTypes.join(", ")}`)}const s=await r(e,t);return l.toast.success("Sucesso",{description:"Arquivo enviado com sucesso"}),i?.(s),s}catch(t){const e=t instanceof Error?t:new Error("Erro ao fazer upload");throw l.toast.error("Erro",{description:e.message}),d?.(e),e}finally{s(!1)}},deleteMedia:async(e,a)=>{if(!n){const e=new Error("deleteFunction não fornecida");throw l.toast.error("Erro de configuração",{description:"Função de delete não configurada."}),e}try{await n(e,a),l.toast.success("Sucesso",{description:"Arquivo removido com sucesso"})}catch(t){throw l.toast.error("Erro",{description:"Erro ao remover o arquivo"}),t}},uploading:a}}function dh(e){const a=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const t of a){const a=e.match(t);if(a)return a[1]}return null}function ch(e,a){const t=dh(e);if(!t)return e;return`https://www.youtube.com/embed/${t}${a?"?autoplay=1&mute=1":""}`}function uh(e){const a=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return a?a[1]:null}function mh(e,a){const t=uh(e);if(!t)return e;return`https://player.vimeo.com/video/${t}${a?"?autoplay=1&muted=1":""}`}function ph(e){if(!e)return;const a=e.match(/src="([^"]+)"/);return a?a[1]:void 0}function hh(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function xh(e,a){return e/a}function fh(){const{alias:e}=An(),[a,s]=t.useState(null),[r,n]=t.useState(!0);t.useEffect(()=>{if(!e)return void n(!1);let a=!1;return(async()=>{n(!0);try{const t=cn(),{data:r,error:n}=await t.schema("common").from("sign_configs").select("*").eq("alias",e).is("deleted_at",null).maybeSingle();a||s(r)}catch(t){a||s(null)}finally{a||n(!1)}})(),()=>{a=!0}},[e]);return{config:a,isLoading:r,saveConfig:t.useCallback(async(a,t)=>{if(!e)throw new Error("Alias not available");const r=cn(),{data:n,error:o}=await r.schema("common").from("sign_configs").upsert({alias:e,api_key:a,environment:t,updated_at:(new Date).toISOString()},{onConflict:"alias"}).select().maybeSingle();if(o)throw o;return s(n),n},[e])}}const gh=(void 0).VITE_SUPABASE_URL,vh=rn();async function bh(e,a,t){const s=an.getSupabaseToken(),r={"Content-Type":"application/json",apikey:vh};s&&(r.Authorization=`Bearer ${s}`);const n=await fetch(`${gh}/functions/v1/${e}`,{method:"POST",headers:r,body:JSON.stringify({action:a,data:t})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.error||`Erro na requisição: ${n.status}`)}return n}const yh={async createEnvelopeWithSigner(e){const a="d4sign"===e.provider?"d4sign":"clicksign",t="d4sign"===e.provider?"create_and_send":"create_envelope_with_signer";return(await bh(a,t,{content_base64:e.contentBase64,filename:e.filename,signer_email:e.signerEmail,signer_name:e.signerName})).json()},async getSignedDocument(e){const a="d4sign"===e.provider?"d4sign":"clicksign";return(await bh(a,"get_signed_document",{envelope_id:e.envelopeId,document_id:e.documentId})).json()}};let jh=null;function wh(){return window.Clicksign?Promise.resolve():jh||(jh=new Promise((e,a)=>{const t=document.createElement("script");t.src="https://cdn-public-library.clicksign.com/embedded/embedded.min-2.1.0.js",t.onload=()=>e(),t.onerror=()=>a(new Error("Falha ao carregar script do Clicksign")),document.head.appendChild(t)}),jh)}const Nh="clicksign-container";function _h({signerId:e,environment:s="sandbox",onSign:r,onError:n,onClose:o}){const{t:i}=y.useTranslation(),l=t.useRef(null),[c,u]=t.useState(!0),[m,p]=t.useState(null);return t.useEffect(()=>{let a=!1;return l.current&&(l.current.unmount(),l.current=null),p(null),u(!0),wh().then(()=>{if(a)return;const t=new window.Clicksign(e);t.endpoint="production"===s?"https://app.clicksign.com":"https://sandbox.clicksign.com",t.origin=window.origin,t.mount(Nh),t.on("loaded",function(){u(!1)}),t.on("signed",function(){r?.()}),t.on("resized",function(e){const a=e,t=document.getElementById(Nh);t&&a?.data?.height&&(t.style.height=a.data.height+"px")}),t.on("error",function(e){u(!1),n?.(e instanceof Error?e:new Error(i("sign_widget_error")))}),t.on("closed",function(){o?.()}),l.current=t}).catch(e=>{a||(p("Falha ao carregar o script de assinatura."),u(!1),n?.(e))}),()=>{a=!0,l.current&&(l.current.unmount(),l.current=null)}},[e,s]),a.jsxs("div",{className:"relative h-full",children:[c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx("p",{className:"text-sm text-destructive",children:m})}),a.jsx("div",{id:Nh,style:{height:"600px"}})]})}function Ch({documentKey:s,signerEmail:r,signerName:n,keySigner:o,environment:i,onSign:l,onError:c}){const u=t.useRef(null),[m,p]=t.useState("loading"),[h,x]=t.useState(null),f="production"===i?"https://secure.d4sign.com.br/embed/viewblob":"https://sandbox.d4sign.com.br/embed/viewblob",g=(()=>{const e=new URLSearchParams({email:r,display_name:n||"",disable_preview:"0"});return o&&e.set("key_signer",o),`${f}/${s}?${e.toString()}`})(),v=t.useCallback(a=>"signed"===a.data?(p("ready"),void l?.()):"wrong-data"===a.data?(p("error"),x(e.t("sign_incorrect_data")),void c?.(new Error(e.t("sign_incorrect_data")))):void 0,[l,c]);t.useEffect(()=>(window.addEventListener("message",v,!1),()=>{window.removeEventListener("message",v,!1)}),[v]);const b=t.useCallback(()=>{"loading"===m&&p("ready")},[m]);return"error"===m?a.jsxs(ai,{variant:"danger",className:"my-4",children:[a.jsx(ti,{children:e.t("sign_doc_load_error")}),a.jsx(si,{children:h||"Ocorreu um erro inesperado ao carregar o documento para assinatura. Tente novamente."})]}):a.jsxs("div",{className:"relative h-full",children:["loading"===m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(d.Loader2,{className:"h-5 w-5 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Carregando documento..."})]})}),a.jsx("iframe",{ref:u,id:"d4sign-container",src:g,width:"100%",style:{height:"600px",border:0},allow:"geolocation",onLoad:b})]})}var kh,Sh,Th,Ph,Eh;exports.ETaskPlanStatus=void 0,(kh=exports.ETaskPlanStatus||(exports.ETaskPlanStatus={}))[kh.waitingStart=1]="waitingStart",kh[kh.running=2]="running",kh[kh.effectivenessCheck=3]="effectivenessCheck",kh[kh.done=4]="done",kh[kh.suspended=5]="suspended",kh[kh.canceled=6]="canceled",exports.ETaskPlanPriority=void 0,(Sh=exports.ETaskPlanPriority||(exports.ETaskPlanPriority={}))[Sh.low=0]="low",Sh[Sh.medium=1]="medium",Sh[Sh.high=2]="high",exports.ETaskPlanAssociationType=void 0,(Th=exports.ETaskPlanAssociationType||(exports.ETaskPlanAssociationType={}))[Th.plan=2]="plan",Th[Th.occurrence=3]="occurrence",Th[Th.risk=4]="risk",Th[Th.decisions=5]="decisions",Th[Th.audit=6]="audit",Th[Th.strategyExtension=7]="strategyExtension",Th[Th.standardization=8]="standardization",Th[Th.supplier=9]="supplier",Th[Th.auditItems=10]="auditItems",exports.ETaskPlanTypeProgress=void 0,(Ph=exports.ETaskPlanTypeProgress||(exports.ETaskPlanTypeProgress={}))[Ph.currentProgress=1]="currentProgress",Ph[Ph.cumulativeProgress=2]="cumulativeProgress",exports.EAttachmentItemStatus=void 0,(Eh=exports.EAttachmentItemStatus||(exports.EAttachmentItemStatus={})).uploading="uploading",Eh.waiting="waiting",Eh.done="done",Eh.error="error",Eh.canceled="canceled",Eh.duplicateItem="duplicateItem";const Dh={[exports.ETaskPlanStatus.waitingStart]:"#D6D6D6",[exports.ETaskPlanStatus.running]:"#DAE9F4",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB29",[exports.ETaskPlanStatus.done]:"#DDEECA",[exports.ETaskPlanStatus.suspended]:"#FFF2D6",[exports.ETaskPlanStatus.canceled]:"#F4433629"},Ah={[exports.ETaskPlanStatus.waitingStart]:"#666666",[exports.ETaskPlanStatus.running]:"#1B75BB",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB",[exports.ETaskPlanStatus.done]:"#4CAF50",[exports.ETaskPlanStatus.suspended]:"#FF9800",[exports.ETaskPlanStatus.canceled]:"#F44336"},Ih={[exports.ETaskPlanStatus.waitingStart]:"waiting-start",[exports.ETaskPlanStatus.running]:"running",[exports.ETaskPlanStatus.effectivenessCheck]:"effectiveness-check",[exports.ETaskPlanStatus.done]:"done",[exports.ETaskPlanStatus.suspended]:"suspended",[exports.ETaskPlanStatus.canceled]:"canceled"};function Mh(){return{[exports.ETaskPlanStatus.waitingStart]:e.t("ap_status_waiting_start"),[exports.ETaskPlanStatus.running]:e.t("ap_status_running"),[exports.ETaskPlanStatus.effectivenessCheck]:e.t("ap_status_effectiveness_check"),[exports.ETaskPlanStatus.done]:e.t("ap_status_done"),[exports.ETaskPlanStatus.suspended]:e.t("ap_status_suspended"),[exports.ETaskPlanStatus.canceled]:e.t("ap_status_canceled")}}const Fh=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return Mh()[a]}});const Rh=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const Lh=[{id:exports.ETaskPlanPriority.low,label:"Baixa",color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:"Média",color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:"Alta",color:"#F44336"}],zh=[exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.canceled],Uh=[exports.ETaskPlanStatus.waitingStart,exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.suspended];function Oh(e){const{actionPlan:a,isNew:s=!1,config:r,onSave:n,onCancel:o,onDelete:i,onChangeStatus:l}=e,[d,c]=t.useState({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});t.useEffect(()=>{a&&c(e=>({...e,formData:a,isFormDisabled:r?.disableFields||zh.includes(a.statusId)}))},[a,r?.disableFields]),t.useEffect(()=>{c(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const u=t.useCallback((e,a)=>{c(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=t.useCallback(e=>{c(a=>({...a,activeTab:e}))},[]),p=t.useCallback(async()=>{if(n){c(e=>({...e,isSaving:!0}));try{await n(d.formData)}finally{c(e=>({...e,isSaving:!1}))}}},[n,d.formData]),h=t.useCallback(async e=>{if(l&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await l(d.formData.id,e)}finally{c(e=>({...e,isLoading:!1}))}}},[l,d.formData.id]),x=t.useCallback(async()=>{if(i&&d.formData.id){c(e=>({...e,isLoading:!0}));try{await i(d.formData.id)}finally{c(e=>({...e,isLoading:!1}))}}},[i,d.formData.id]);return{formData:d.formData,isLoading:d.isLoading,isSaving:d.isSaving,activeTab:d.activeTab,isFormDisabled:d.isFormDisabled,updateField:u,setActiveTab:m,save:p,changeStatus:h,remove:x,cancel:o}}const Vh={[exports.ETaskPlanStatus.waitingStart]:{label:"",color:"#8B7355",icon:d.Clock},[exports.ETaskPlanStatus.running]:{label:"",color:"#2E7D5B",icon:d.Play},[exports.ETaskPlanStatus.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:d.ShieldCheck},[exports.ETaskPlanStatus.done]:{label:"",color:"#3D7A40",icon:d.CheckCircle2},[exports.ETaskPlanStatus.suspended]:{label:"",color:"#6B7280",icon:d.Pause},[exports.ETaskPlanStatus.canceled]:{label:"",color:"#B44A4A",icon:d.X}};function Bh({status:e,labels:t,className:s,size:r,showIcon:n,variant:o}){const i=Mh(),l=Vh[e];if(!l)return null;const d=t?.[e]||i[e]||"";return a.jsx(fu,{label:d,color:l.color,icon:l.icon,size:r,showIcon:n,variant:o,className:s})}function qh({formData:e,updateField:s,disabled:r=!1,users:n=[],places:o=[],actionTypes:i,causes:l=[],parentActions:d=[],config:c}){const{t:u}=y.useTranslation(),m=c?.requiredFields,p=i||Rh,h=e=>{if(c?.hiddenFields?.includes(e))return!1;if(c?.visibleFields&&c.visibleFields.length>0)return c.visibleFields.includes(e);const a=`${e}Visible`;return!m||!(a in m)||!1!==m[a]},x=e=>m?!!m[e]:"name"===e,f=t.useMemo(()=>{if(e.startDate&&e.endDate){const a=new Date(e.startDate),t=new Date(e.endDate).getTime()-a.getTime();return Math.max(0,Math.ceil(t/864e5))}return e.duration||0},[e.startDate,e.endDate,e.duration]);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),a.jsx(Zt,{value:e.name||"",onChange:e=>s("name",e.target.value),maxLength:500,disabled:r,placeholder:u("ap_plan_name_placeholder")})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("responsibleWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a.jsxs(Vs,{value:e.responsibleId||"",onValueChange:e=>s("responsibleId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_responsible")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),h("checkerWho")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a.jsxs(Vs,{value:e.checkerId||"",onValueChange:e=>s("checkerId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_checker")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("place")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a.jsxs(Vs,{value:e.placeId||"",onValueChange:e=>s("placeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_place")})}),a.jsx(Gs,{children:$h(o).map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),h("planType")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a.jsxs(Vs,{value:e.typeId||"",onValueChange:e=>s("typeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_type")})}),a.jsx(Gs,{children:p.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h("priority")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a.jsxs(Vs,{value:e.priorityType?.toString()||"",onValueChange:e=>s("priorityType",Number(e)),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_priority")})}),a.jsx(Gs,{children:Lh.map(e=>a.jsx(Ys,{value:e.id.toString(),children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})},e.id))})]})]}),d.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_belongs_to")}),a.jsxs(Vs,{value:e.parentId||"",onValueChange:e=>s("parentId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_parent")})}),a.jsx(Gs,{children:d.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[h("startDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),a.jsx(_l,{date:e.startDate?new Date(e.startDate):void 0,onDateChange:e=>s("startDate",e||null),disabled:r,placeholder:u("ap_select_date")})]}),h("endDate")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),a.jsx(_l,{date:e.endDate?new Date(e.endDate):void 0,onDateChange:e=>s("endDate",e||null),disabled:r,placeholder:u("ap_select_date"),disabledDates:e.startDate?a=>a<new Date(e.startDate):void 0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:u("ap_duration_days")}),a.jsx(Zt,{type:"number",value:f,disabled:!0,className:"bg-muted"})]})]}),h("estimatedCost")&&a.jsxs("div",{className:"space-y-2 max-w-xs",children:[a.jsx(as,{className:Kt(x("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:e.estimatedCost||"",onChange:e=>s("estimatedCost",Number(e.target.value)),disabled:r,className:"pl-9",placeholder:"0,00"})]})]}),h("cause")&&l.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Causa"}),a.jsxs(Vs,{value:e.causeId||"",onValueChange:e=>s("causeId",e),disabled:r,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:u("ap_select_cause")})}),a.jsx(Gs,{children:l.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]}),h("description")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),a.jsx(Js,{value:e.description||"",onChange:e=>s("description",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_description_placeholder")})]}),h("justification")&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{className:Kt(x("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),a.jsx(Js,{value:e.justification||"",onChange:e=>s("justification",e.target.value),maxLength:4e3,disabled:r,rows:4,placeholder:u("ap_justification_placeholder")})]})]})}function $h(e,a=0){const t=[];for(const s of e)t.push({...s,depth:a}),s.children?.length&&t.push(...$h(s.children,a+1));return t}function Wh(e){const{progress:a,onReportProgress:s,onEditProgress:r,onDeleteProgress:n}=e,[o,i]=t.useState(!1),[l,d]=t.useState(null),c=!!a&&Uh.includes(a.status),u=t.useCallback(async e=>{if(s&&a){i(!0);try{const t=100===e.percentProgress;await s({id:a.id,...e,conclude:t})}finally{i(!1)}}},[s,a]),m=t.useCallback(async e=>{if(r){i(!0);try{await r(e)}finally{i(!1),d(null)}}},[r]),p=t.useCallback(async e=>{if(n){i(!0);try{await n(e)}finally{i(!1)}}},[n]);return{progress:a,canReportProgress:c,isSubmitting:o,editingReport:l,setEditingReport:d,reportProgress:u,editProgress:m,deleteProgress:p}}function Hh(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let s=parseInt(a)||0,r=parseInt(t)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,s=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,s=parseInt(a.substring(2,4))||0,t+=Math.floor(s/60),s%=60):(t=parseInt(a)||0,s=0),`${t.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}function Gh(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let s=parseInt(t)||0,r=parseInt(e)||0;return s+=Math.floor(r/60),r%=60,`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}}function Kh(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function Yh({open:e,onOpenChange:s,report:r,onSave:n,isSubmitting:o=!1}){const{t:i}=y.useTranslation(),[l,d]=t.useState(r?.percentProgress||0),[c,u]=t.useState(r?.timeProgress||""),[m,p]=t.useState(r?.comments||""),h=l!==(r?.percentProgress??0)||c!==(r?.timeProgress??"")||m!==(r?.comments??"");t.useEffect(()=>{r&&(d(r.percentProgress),u(r.timeProgress||""),p(r.comments||""))},[r]);return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:h,children:[a.jsx(Ss,{children:a.jsx(Es,{children:i("ap_edit_progress")})}),a.jsxs("div",{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:l,onChange:e=>d(Number(e.target.value))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_time_spent")}),a.jsx(Zt,{value:c,onChange:e=>u(e.target.value),onBlur:()=>u(Hh(c)||""),placeholder:"00:00"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:i("ap_comments")}),a.jsx(Js,{value:m,onChange:e=>p(e.target.value),rows:3,maxLength:4e3})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>s(!1),disabled:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{r&&n({...r,percentProgress:l,timeProgress:Hh(c)||"00:00",comments:m})},disabled:o,children:o?"Salvando...":"Salvar"})]})]})})}function Qh(e){const{t:s}=y.useTranslation(),{progress:r,canReportProgress:n,isSubmitting:o,editingReport:i,setEditingReport:l,reportProgress:d,editProgress:c,deleteProgress:u}=Wh(e),[m,p]=t.useState(""),[h,x]=t.useState(""),[f,g]=t.useState("");if(!r)return a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const v=Kh(r.percentProgress),b=!m,j=!m&&!h&&!f;return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium",children:s("ap_overall_progress")}),a.jsxs("span",{className:"font-semibold",style:{color:v||void 0},children:[r.percentProgress,"%"]})]}),a.jsx(jd,{value:r.percentProgress,className:"h-3"}),r.timeProgress&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",Gh(r.timeProgress)]})]}),n&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_report_progress")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_progress_percent")}),a.jsx(Zt,{type:"number",min:0,max:100,value:m,onChange:e=>p(e.target.value),placeholder:"0"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_time_spent")}),a.jsx(Zt,{value:h,onChange:e=>x(e.target.value),onBlur:()=>x(Hh(h)||""),placeholder:"00:00"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:s("ap_comments")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),rows:3,maxLength:4e3,placeholder:s("ap_progress_comment_placeholder")})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>{p(""),x(""),g("")},disabled:j||o,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{const e=Number(m);(e||0===e)&&(await d({percentProgress:e,timeProgress:Hh(h)||"00:00",comments:f}),p(""),x(""),g(""))},disabled:b||o,children:o?"Reportando...":"Reportar"})]})]}),r.reports.length>0&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:s("ap_reports_history")}),a.jsx("div",{className:"space-y-2",children:r.reports.map(e=>a.jsx(Xh,{report:e,onEdit:()=>l(e),onDelete:()=>u(e.id),disabled:!n},e.id))})]}),a.jsx(Yh,{open:!!i,onOpenChange:e=>!e&&l(null),report:i,onSave:c,isSubmitting:o})]})}function Xh({report:t,onEdit:s,onDelete:r,disabled:n}){const o=t.date?new Date(t.date):null,i=Kh(t.percentProgress);return a.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:t.userName}),o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:o.toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("span",{style:{color:i||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a.jsxs("span",{children:["Tempo: ",Gh(t.timeProgress)]})]}),t.comments&&a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[a.jsx(hr,{onClick:s,children:e.t("edit")}),a.jsx(hr,{className:"text-destructive",onClick:r,children:e.t("ap_delete")})]})]})]})}function Jh({predecessors:e=[],availablePredecessors:s=[],onAdd:r,onRemove:n,disabled:o=!1}){const{t:i}=y.useTranslation(),[l,c]=t.useState(""),u=s.filter(a=>!e.some(e=>e.predecessorId===a.id));return a.jsxs("div",{className:"space-y-6 p-1",children:[!o&&u.length>0&&a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx(as,{children:i("ap_add_predecessor")}),a.jsxs(Vs,{value:l,onValueChange:c,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:i("ap_select_action")})}),a.jsx(Gs,{children:u.map(e=>a.jsx(Ys,{value:e.id,children:e.label},e.id))})]})]}),a.jsxs(Xt,{size:"sm",onClick:()=>{l&&r&&(r(l),c(""))},disabled:!l,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[e.predecessorCode&&a.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.predecessorCode}),a.jsx("span",{className:"text-sm font-medium",children:e.predecessorName}),null!=e.predecessorStatus&&a.jsx(Bh,{status:e.predecessorStatus})]}),!o&&n&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.predecessorId),children:"Remover"})})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function Zh({costs:e=[],onAdd:s,onEdit:r,onDelete:n,disabled:o=!1}){const{t:i}=y.useTranslation(),[l,c]=t.useState(""),[u,m]=t.useState(""),p=e.reduce((e,a)=>e+(a.value||0),0);return a.jsxs("div",{className:"space-y-6 p-1",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium",children:i("ap_total_cost")}),a.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",p.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!o&&s&&a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:i("ap_add_cost")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Descrição"}),a.jsx(Zt,{value:l,onChange:e=>c(e.target.value),placeholder:i("ap_cost_description")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Valor (R$)"}),a.jsx(Zt,{type:"number",min:0,step:.01,value:u,onChange:e=>m(e.target.value),placeholder:"0,00"})]})]}),a.jsx("div",{className:"flex justify-end",children:a.jsxs(Xt,{size:"sm",onClick:()=>{l&&u&&s&&(s({description:l,value:Number(u),date:(new Date).toISOString()}),c(""),m(""))},disabled:!l||!u,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:e.description}),e.date&&a.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString("pt-BR")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",e.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!o&&(r||n)&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[r&&a.jsx(hr,{onClick:()=>r(e),children:i("edit")}),n&&a.jsx(hr,{className:"text-destructive",onClick:()=>n(e.id),children:i("ap_delete")})]})]})]})]},e.id))}):a.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function ex({comments:e=[],currentUserId:s,onAdd:r,onEdit:n,onDelete:o,disabled:i=!1,maxLength:l=4e3}){const{t:c}=y.useTranslation(),[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(null),[g,v]=t.useState(""),b=()=>{f(null),v("")};return a.jsxs("div",{className:"space-y-6 p-1",children:[!i&&r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(Js,{value:u,onChange:e=>m(e.target.value),placeholder:c("ap_add_comment_placeholder"),maxLength:l,rows:3}),a.jsxs("div",{className:"flex items-center justify-between",children:[l&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length,"/",l]}),a.jsxs("div",{className:"flex gap-2 ml-auto",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!u||p,children:"Limpar"}),a.jsx(Xt,{size:"sm",onClick:async()=>{if(u.trim()&&r){h(!0);try{await r(u),m("")}finally{h(!1)}}},disabled:!u.trim()||p,children:p?"Enviando...":"Comentar"})]})]})]}),a.jsxs("div",{className:"space-y-1",children:[e.length>0?a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"text-sm font-medium",children:c("ap_comments")}),a.jsx(er,{variant:"info",className:"text-[10px] px-1.5 py-0",children:e.length})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),e.map(e=>a.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[a.jsx("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"font-medium truncate",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.userEmail}),a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:ax(e.dateEdited||e.dateCreation)}),e.dateEdited&&a.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),x===e.id?a.jsxs("div",{className:"space-y-2",children:[a.jsx(Js,{value:g,onChange:e=>v(e.target.value),maxLength:l,rows:3}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Xt,{variant:"outline",size:"sm",onClick:b,disabled:p,children:"Cancelar"}),a.jsx(Xt,{size:"sm",onClick:()=>(async e=>{if(g.trim()&&n){h(!0);try{await n({...e,text:g,stringText:g}),f(null),v("")}finally{h(!1)}}})(e),disabled:!g.trim()||p,children:p?"Salvando...":"Salvar"})]})]}):a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.stringText||e.text})]}),!i&&s===e.userId&&x!==e.id&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&a.jsx(hr,{onClick:()=>(e=>{f(e.id),v(e.stringText||e.text)})(e),children:c("edit")}),o&&a.jsx(hr,{className:"text-destructive",onClick:()=>(async e=>{if(o){h(!0);try{await o(e)}finally{h(!1)}}})(e.id),children:"Excluir"})]})]})]},e.id))]})]})}function ax(e){const{t:a}=y.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function tx({history:e=[],isLoading:t=!1}){const{t:s}=y.useTranslation();return t?a.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===e.length?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:s("ap_no_history")})]}):a.jsx("div",{className:"p-1",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),a.jsx("div",{className:"space-y-0",children:e.map((e,t)=>a.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[a.jsx("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:e.icon?a.jsx("span",{className:"text-xs text-primary",children:e.icon}):a.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium",children:e.translateEvent||e.eventName}),e.eventDescription&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.eventDescription})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:e.userPhotoUrl?a.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-xs font-medium truncate block",children:e.userName}),e.userEmail&&a.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:e.userEmail})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Calendar,{className:"h-3 w-3"}),a.jsx("span",{children:sx(e.date)})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),a.jsx("span",{children:rx(e.date)})]}),e.isMobileRequest&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(d.Smartphone,{className:"h-3 w-3"}),a.jsx("span",{children:s("ap_via_app")})]})]})]})]},e.id))})]})})}function sx(e){const{t:a}=y.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function rx(e){const{t:a}=y.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function nx({attachments:e=[],onUpload:s,onDelete:r,onRename:n,onDownload:o,onView:i,disabled:l=!1}){const{t:c}=y.useTranslation(),u=t.useRef(null),[m,p]=t.useState(null),[h,x]=t.useState(""),f=async e=>{h.trim()&&n&&(await n(e.id,h),p(null),x(""))},g=()=>{p(null),x("")};return a.jsxs("div",{className:"space-y-4 p-1",children:[!l&&s&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&s){for(let e=0;e<a.length;e++){const t=a.item(e);t&&s(t)}u.current&&(u.current.value="")}}}),a.jsxs(Xt,{size:"sm",onClick:()=>u.current?.click(),children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),e.length>0?a.jsx("div",{className:"space-y-2",children:e.map(e=>a.jsxs("div",{className:Kt("flex items-center gap-3 rounded-lg border bg-card p-3",e.status===exports.EAttachmentItemStatus.error&&"border-destructive/50 bg-destructive/5",e.status===exports.EAttachmentItemStatus.canceled&&"opacity-50"),children:[a.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:a.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:e.extension.replace(".","").substring(0,4)})}),a.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[m===e.id?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:h,onChange:e=>x(e.target.value),onKeyDown:a=>{"Enter"===a.key&&f(e),"Escape"===a.key&&g()},autoFocus:!0}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:g,children:c("cancel")}),a.jsx(Xt,{size:"sm",onClick:()=>f(e),children:c("save")})]}):a.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>i?.(e.id),children:e.name}),(e.status===exports.EAttachmentItemStatus.uploading||e.status===exports.EAttachmentItemStatus.waiting)&&a.jsx(jd,{value:e.progress||0,className:"h-1.5"}),e.status===exports.EAttachmentItemStatus.error&&a.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),e.status===exports.EAttachmentItemStatus.duplicateItem&&a.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),e.status===exports.EAttachmentItemStatus.canceled&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[e.status===exports.EAttachmentItemStatus.done&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:ox(e.size)}),a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Jt,{})}),a.jsxs(pr,{align:"end",children:[n&&!l&&a.jsx(hr,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");p(e.id),x(a)})(e),children:"Renomear"}),i&&a.jsx(hr,{onClick:()=>i(e.id),children:"Visualizar"}),o&&a.jsx(hr,{onClick:()=>o(e.id),children:"Download"}),r&&!l&&a.jsxs(a.Fragment,{children:[a.jsx(vr,{}),a.jsx(hr,{className:"text-destructive",onClick:()=>r(e.id),children:"Excluir"})]})]})]})]}),e.status===exports.EAttachmentItemStatus.uploading&&a.jsx(Xt,{variant:"outline",size:"sm",onClick:()=>r?.(e.id),children:"Cancelar"})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[a.jsx(d.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function ox(e){const{t:a}=y.useTranslation();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}const ix=["application/x-msdownload","application/x-msdos-program","application/x-executable","application/x-javascript","application/javascript","text/javascript","text/vbscript","application/sql","application/x-sh","application/x-shellscript","application/hta","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12"];function lx(e){if(!e)return"";if(e<1024)return`${e} Bytes`;const a=e/1024;if(a<1024)return`${Math.round(a)} KB`;const t=a/1024;if(t<1024)return`${Math.round(t)} MB`;const s=t/1024;return Math.round(100*s)/100+" GB"}function dx(e){const a=e.lastIndexOf(".");return-1===a?"":e.substring(a+1).toLowerCase()}var cx,ux,mx;function px(e){switch(e.type){case exports.ECustomFormFieldType.text:return e.textValue;case exports.ECustomFormFieldType.number:return e.numberValue;case exports.ECustomFormFieldType.date:return e.dateValue;case exports.ECustomFormFieldType.time:return e.timeValue;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:return e.itemsValue;case exports.ECustomFormFieldType.questions:return e.questionsValue;case exports.ECustomFormFieldType.readOnlyText:return e.textValue;default:return null}}function hx(e,a){if(!a)return!0;const t=null!=px(e)&&""!==px(e)&&!(Array.isArray(px(e))&&0===px(e).length);return!1!==e.isActive||t}function xx({field:e}){return a.jsxs("div",{className:"space-y-1",children:[e.name&&a.jsx("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description&&a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description}),e.textValue&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:e.textValue})]})}function fx({field:e,readOnly:t,onChange:s}){const r=e.config,n=r?.multiline??!1,o=t||e.readOnly,i=a=>{s?.({...e,textValue:a})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),n?a.jsx(Js,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o,rows:4}):a.jsx(Zt,{value:e.textValue||"",onChange:e=>i(e.target.value),placeholder:e.placeholder,disabled:o})]})}function gx({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e.dateValue?"string"==typeof e.dateValue?e.dateValue.substring(0,10):new Date(e.dateValue).toISOString().substring(0,10):"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"date",value:n,onChange:a=>{return t=a.target.value,void s?.({...e,dateValue:t||void 0});var t},placeholder:e.placeholder,disabled:r})]})}function vx({field:e,readOnly:t,onChange:s}){const r=t||e.readOnly,n=e=>{if(!e)return;const[a,t]=e.split(":").map(Number);return 60*a+t};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"time",value:(e=>{if(null==e)return"";const a=e%60;return`${Math.floor(e/60).toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`})(e.timeValue),onChange:a=>s?.({...e,timeValue:n(a.target.value)}),placeholder:e.placeholder,disabled:r})]})}function bx({field:e,readOnly:s,onChange:r}){const n=e.config,o=n?.multiple??!1,i=s||e.readOnly,[l,c]=t.useState(""),u=e.itemsValue||[],m=()=>{if(!l.trim())return;const a={value:crypto.randomUUID(),text:l.trim()};r?.({...e,itemsValue:[...u,a]}),c("")};if(!o){const t=u[0]?.text||"";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:t,onChange:a=>(a=>{const t={value:a,text:a};r?.({...e,itemsValue:a?[t]:[]})})(a.target.value),placeholder:e.placeholder||"https://",disabled:i}),t&&a.jsx(Xt,{variant:"outline",size:"icon",asChild:!0,className:"flex-shrink-0",children:a.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:a.jsx(d.ExternalLink,{className:"h-4 w-4"})})})]})]})}return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),!i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zt,{type:"url",value:l,onChange:e=>c(e.target.value),placeholder:e.placeholder||"https://",onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),m())}),a.jsx(Xt,{variant:"outline",size:"icon",onClick:m,disabled:!l.trim(),className:"flex-shrink-0",children:a.jsx(d.Plus,{className:"h-4 w-4"})})]}),u.length>0&&a.jsx("div",{className:"space-y-1",children:u.map((t,s)=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("a",{href:t.text,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate flex-1",children:t.text}),!i&&a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>(a=>{const t=u.filter((e,t)=>t!==a);r?.({...e,itemsValue:t})})(s),children:a.jsx(d.Trash2,{className:"h-3 w-3"})})]},t.value))})]})}function yx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=null!=r?.decimals&&r.decimals>0?(1/Math.pow(10,r.decimals)).toString():"1";return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx(Zt,{type:"number",value:e.numberValue??"",onChange:a=>(a=>{if(""===a)return void s?.({...e,numberValue:void 0});const t=parseFloat(a);isNaN(t)||s?.({...e,numberValue:t})})(a.target.value),placeholder:e.placeholder,disabled:n,min:r?.min,max:r?.max,step:o}),null!=r?.min&&null!=r?.max&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Min: ",r.min," | Max: ",r.max]})]})}function jx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=e.itemsValue?.[0]?.value||"",d=a=>{const t=i.find(e=>e.value===a);if(!t)return;const r={value:t.value,text:t.text,isActive:t.isActive};s?.({...e,itemsValue:[r]})};return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),o===exports.EFieldViewMode.dropdown&&a.jsxs(Vs,{value:l,onValueChange:d,disabled:n,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.placeholder||"Selecione..."})}),a.jsx(Gs,{children:i.map(e=>a.jsxs(Ys,{value:e.value,children:[e.text,!1===e.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]},e.value))})]}),(o===exports.EFieldViewMode.radio||o===exports.EFieldViewMode.buttons)&&a.jsx(wd,{value:l,onValueChange:d,disabled:n,className:Kt(o===exports.EFieldViewMode.buttons?"flex flex-wrap gap-2":"space-y-2"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nd,{value:t.value,id:`${e.id}-${t.value}`}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))}),!n&&l&&!e.required&&a.jsx("button",{type:"button",onClick:()=>{s?.({...e,itemsValue:[]})},className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Limpar seleção"})]})}function wx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.viewMode??exports.EFieldViewMode.dropdown,i=r?.data?.filter(a=>!1!==a.isActive||e.itemsValue?.some(e=>e.value===a.value))||[],l=new Set(e.itemsValue?.map(e=>e.value)||[]);return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),(e.itemsValue?.length??0)>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.itemsValue.map(t=>a.jsxs(er,{variant:"secondary",className:"gap-1 pr-1",children:[a.jsx("span",{className:"text-xs",children:t.text}),!n&&a.jsx("button",{type:"button",onClick:()=>(a=>{const t=(e.itemsValue||[]).filter(e=>e.value!==a);s?.({...e,itemsValue:t})})(t.value),className:"rounded-full p-0.5 hover:bg-muted-foreground/20",children:a.jsx(d.X,{className:"h-3 w-3"})})]},t.value))}),!n&&a.jsx("div",{className:Kt(o===exports.EFieldViewMode.checkbox?"space-y-2":"grid grid-cols-2 gap-2 border rounded-md p-3 max-h-48 overflow-y-auto"),children:i.map(t=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:`${e.id}-${t.value}`,checked:l.has(t.value),onCheckedChange:()=>(a=>{const t=e.itemsValue||[],r=t.some(e=>e.value===a.value)?t.filter(e=>e.value!==a.value):[...t,{value:a.value,text:a.text,isActive:a.isActive}];s?.({...e,itemsValue:r})})(t),disabled:n}),a.jsxs(as,{htmlFor:`${e.id}-${t.value}`,className:"text-sm font-normal cursor-pointer",children:[t.text,!1===t.isActive&&a.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(inativo)"})]})]},t.value))})]})}function Nx({field:e,readOnly:t,onChange:s}){const r=e.config,n=t||e.readOnly,o=r?.questions||[],i=r?.options||[],l=e.questionsValue||[];return 0===o.length||0===i.length?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.name}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhuma questão configurada"})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{className:Kt(e.required&&"after:content-['*'] after:text-destructive after:ml-0.5"),children:e.name}),e.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}),a.jsx("div",{className:"border rounded-md overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-muted/50",children:[a.jsx("th",{className:"text-left p-2 font-medium min-w-[150px]",children:"Pergunta"}),i.map(e=>a.jsx("th",{className:"text-center p-2 font-medium min-w-[80px]",children:e.text},e.value))]})}),a.jsx("tbody",{children:o.map((t,r)=>a.jsxs("tr",{className:Kt(r<o.length-1&&"border-b"),children:[a.jsx("td",{className:"p-2 text-muted-foreground",children:t.text}),i.map(r=>{return a.jsx("td",{className:"text-center p-2",children:a.jsx(wd,{value:(o=t.value,l.find(e=>e.questionValue===o)?.optionValue||""),onValueChange:a=>((a,t,r,n)=>{const o={questionValue:a,questionText:t,optionValue:r,optionText:n},i=l.filter(e=>e.questionValue!==a);i.push(o),s?.({...e,questionsValue:i})})(t.value,t.text,a,r.text),disabled:n,className:"flex justify-center",children:a.jsx(Nd,{value:r.value,id:`${e.id}-${t.value}-${r.value}`})})},r.value);var o})]},t.value))})]})})]})}function _x({field:e,readOnly:t,onChange:s}){const r={field:e,readOnly:t,onChange:s};switch(e.type){case exports.ECustomFormFieldType.readOnlyText:return a.jsx(xx,{...r});case exports.ECustomFormFieldType.text:return a.jsx(fx,{...r});case exports.ECustomFormFieldType.date:return a.jsx(gx,{...r});case exports.ECustomFormFieldType.time:return a.jsx(vx,{...r});case exports.ECustomFormFieldType.url:return a.jsx(bx,{...r});case exports.ECustomFormFieldType.number:return a.jsx(yx,{...r});case exports.ECustomFormFieldType.singleSelection:return a.jsx(jx,{...r});case exports.ECustomFormFieldType.multiSelection:return a.jsx(wx,{...r});case exports.ECustomFormFieldType.questions:return a.jsx(Nx,{...r});default:return null}}function Cx({queryParams:e,events:s,softwares:r,users:n=[],permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},isLoading:i=!1,onFilter:l,onReset:c,onExport:u,onSoftwareChange:m}){const[p,h]=t.useState(e.softwareId),[x,f]=t.useState(e.eventId),[g,v]=t.useState(e.userId||"all"),[b,y]=t.useState(kx(e.startDate)),[j,w]=t.useState(kx(e.endDate)),N=t.useCallback(e=>{const a=parseInt(e);h(a),m?.(a)},[m]),_=t.useCallback(()=>{l({...e,softwareId:p,eventId:x,userId:"all"===g?void 0:g,startDate:new Date(b),endDate:new Date(j),software:r.find(e=>e.id===p)?.software||e.software,event:s.find(e=>e.id===x)?.name||e.event})},[e,p,x,g,b,j,r,s,l]),C=t.useCallback(()=>{const a=new Date;a.setHours(0,0,0,0),y(kx(a)),w(kx(a)),f(e.eventId),o.viewAllEvents&&v("all"),c?.()},[e.eventId,o.viewAllEvents,c]),k=o.viewOnlyMyEvents&&!o.viewAllEvents,S=p&&x&&b&&j;return a.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsxs("div",{className:"flex flex-col gap-1 min-w-[180px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Módulo *"}),a.jsxs(Vs,{value:String(p),onValueChange:N,disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Ys,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Evento *"}),a.jsxs(Vs,{value:String(x),onValueChange:e=>f(parseInt(e)),disabled:i,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsx(Gs,{children:s.map(e=>a.jsx(Ys,{value:String(e.id),className:"text-xs",children:e.translation},e.id))})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[200px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Usuário *"}),a.jsxs(Vs,{value:g,onValueChange:v,disabled:i||k,children:[a.jsx($s,{className:"h-8 text-xs",children:a.jsx(qs,{placeholder:"Selecione..."})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"all",className:"text-xs",children:"Todos"}),n.map(e=>a.jsx(Ys,{value:e.id,className:"text-xs",children:e.name},e.id))]})]})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"De *"}),a.jsx(Zt,{type:"date",value:b,onChange:e=>y(e.target.value),className:"h-8 text-xs",max:j,disabled:i})]}),a.jsxs("div",{className:"flex flex-col gap-1 min-w-[150px]",children:[a.jsx(as,{className:"text-xs text-muted-foreground",children:"Até *"}),a.jsx(Zt,{type:"date",value:j,onChange:e=>w(e.target.value),className:"h-8 text-xs",min:b,disabled:i})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsxs(Xt,{variant:"outline",size:"sm",onClick:C,disabled:i,children:[a.jsx(d.RotateCcw,{className:"h-3.5 w-3.5 mr-1"}),"Limpar"]}),o.download&&u&&a.jsxs(Xt,{variant:"outline",size:"sm",onClick:()=>u("xlsx"),disabled:i,children:[a.jsx(d.Download,{className:"h-3.5 w-3.5 mr-1"}),"Exportar"]}),a.jsxs(Xt,{size:"sm",onClick:_,disabled:i||!S,children:[a.jsx(d.Filter,{className:"h-3.5 w-3.5 mr-1"}),"Filtrar"]})]})]})}function kx(e){return(e instanceof Date?e:new Date(e)).toISOString().split("T")[0]}function Sx(e,a,t,s="Anônimo"){return e.map(e=>({...e,translatedSoftware:Px(e.software,t),user:e.userEmail||e.userName||s,translatedEvent:Tx(e.eventName,a),date:new Date(e.dateTime)})).sort((e,a)=>(a.date?.getTime()??0)-(e.date?.getTime()??0))}function Tx(e,a){const t=a.find(a=>a.name===e);return t?.translation||e}function Px(e,a){const t=e.includes(".")?e.split(".").pop():e,s=a.find(e=>e.software===t);return s?.translation||t}function Ex(e,a){const t=[],s={...Lx,...a?.labels},r=e.eventName;t.push({name:s.event,value:r});const n=e.entities?.[0];if(n&&(t.push({name:s.entityName,value:Dx(n)}),n.description&&t.push({name:s.description,value:n.description}),n.justification&&t.push({name:s.justification,value:n.justification}),n.statusName&&t.push({name:s.status,value:n.statusName}),n.equipmentType&&t.push({name:s.type,value:n.equipmentType}),n.extra?.length)){[...new Set(n.extra.map(e=>e.property))].forEach(e=>{const a=n.extra.filter(a=>a.property===e).map(e=>e.value||"").join(", ");t.push({name:Fx(e),value:a})})}e.entities?.forEach(e=>{e.data?.forEach(e=>{if("Removed"===e.property)return;if(""===e.newValue&&!e.tagTranslate)return;const n=Ax(e,r,a?.translateProperty),o=Ix(e,null,r,s,a);o&&t.push({name:n,value:o})})}),e.entities?.forEach(e=>{if(e.association?.length){const a=e.association.filter(e=>""!==e.id).map(e=>{const a=Dx(e);return`(${e.softwareName||e.type}) ${a}`});a.length&&t.push({name:s.references,value:a.join(", ")})}}),n?.isElectronicSigned&&t.push({name:s.security,value:"🛡️ "+s.electronicSigned}),t.push({name:s.accomplishedBy,value:e.userName?`${e.userName} (${e.userEmail})`:e.userEmail});const o=a?.formatDate?a.formatDate(e.dateTime):Rx(e.dateTime);return t.push({name:s.accomplishedIn,value:o}),t}function Dx(e){return e.code&&e.name&&e.code!==e.name?`${e.code} ${e.name}`:e.name||e.code||""}function Ax(e,a,t){if(e.propertyCustomName)return e.propertyCustomName;const s=Fx(e.property);return t?t(a,s):s}function Ix(e,a,t,s,r){if(e.propertyResource||(e.propertyResource=a?`${a.propertyResource}.${e.property}`:e.property),e.children?.length){if(e.newValue){const a=Ax(e,t,r?.translateProperty),n=function(e,a){switch(e.state){case"Added":return a.stateAdded;case"Modified":return e.children?.some(e=>"Removed"===e.property)?a.stateRemoved:a.stateModified;default:return""}}(e,s);let o=`${a}: "${Mx(e,"newValue",s,r)}" ${n}`;const i=e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,Ix(a,e,t,s,r)));return i.some(Boolean)&&(o+="\n"+i.filter(Boolean).join("\n")),o}return e.children.map(a=>(a.propertyResource=`${e.propertyResource}.${a.property}`,Ix(a,e,t,s,r))).filter(Boolean).join("\n")}if("Removed"===e.property)return"";if("Modified"===e.state){const n=Mx(e,"oldValue",s,r),o=Mx(e,"newValue",s,r);return`${a?Ax(e,t,r?.translateProperty)+": ":""}${s.changedFrom} "${n}" ${s.changedTo} "${o}"`}const n=Mx(e,"newValue",s,r);return a?`${Ax(e,t,r?.translateProperty)}: ${n}`:n}function Mx(e,a,t,s){const r=e[a];return null==r||""===r?"Modified"===e.state||"Added"===e.state||"Unchanged"===e.state?t.uninformed:"":"string"==typeof r&&function(e){if("string"!=typeof e)return!1;if(!/^\d{4}[-/]\d{2}[-/]\d{2}/.test(e))return!1;const a=new Date(e);return!isNaN(a.getTime())}(r)?s?.formatDate?s.formatDate(r):Rx(r):String(r)}function Fx(e){return e.replace(/([A-Z])/g,(e,a,t)=>`${t>0?"-":""}${a.toLowerCase()}`)}function Rx(e){try{return new Date(e).toLocaleString()}catch{return e}}exports.ECustomFormFieldType=void 0,(cx=exports.ECustomFormFieldType||(exports.ECustomFormFieldType={}))[cx.readOnlyText=1]="readOnlyText",cx[cx.text=2]="text",cx[cx.date=3]="date",cx[cx.time=4]="time",cx[cx.url=5]="url",cx[cx.number=6]="number",cx[cx.singleSelection=7]="singleSelection",cx[cx.multiSelection=8]="multiSelection",cx[cx.questions=9]="questions",exports.EFieldViewMode=void 0,(ux=exports.EFieldViewMode||(exports.EFieldViewMode={}))[ux.dropdown=1]="dropdown",ux[ux.buttons=2]="buttons",ux[ux.radio=3]="radio",ux[ux.checkbox=4]="checkbox",exports.ESelectionFieldDataSource=void 0,(mx=exports.ESelectionFieldDataSource||(exports.ESelectionFieldDataSource={}))[mx.custom=1]="custom",mx[mx.users=2]="users",mx[mx.usersLists=3]="usersLists";const Lx={event:"Evento",entityName:"Item",description:e.t("audit_description"),justification:"Justificativa",status:"Status",type:"Tipo",references:e.t("audit_references"),security:e.t("audit_security"),electronicSigned:e.t("audit_esign"),accomplishedBy:"Realizado por",accomplishedIn:"Realizado em",changedFrom:"de",changedTo:"para",uninformed:e.t("audit_not_informed"),stateAdded:"(adicionado)",stateModified:"(modificado)",stateRemoved:"(removido)"};function zx({documentId:e,onFetchDetails:s,onClose:r,labels:n,translateProperty:o,translatePropertyValue:i,formatDate:l}){const[c,u]=t.useState(!1),[m,p]=t.useState([]),[h,x]=t.useState(null),f=t.useCallback(async e=>{u(!0),x(null);try{const a=Ex(await s(e),{translateProperty:o,translatePropertyValue:i,formatDate:l,labels:n});p(a)}catch(a){x("Erro ao carregar detalhes da trilha de auditoria."),p([])}finally{u(!1)}},[s,o,i,l,n]);return t.useEffect(()=>{e&&f(e)},[e,f]),e?a.jsxs("div",{className:"flex flex-col h-full bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Detalhes da Auditoria"}),a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(d.X,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:c?a.jsxs("div",{className:"flex items-center justify-center p-6",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando detalhes..."})]}):h?a.jsx("div",{className:"p-6 text-sm text-destructive",children:h}):a.jsx("table",{className:"w-full text-xs",children:a.jsx("tbody",{children:m.map((e,t)=>a.jsxs("tr",{className:t%2==0?"bg-background":"bg-muted/20",children:[a.jsx("td",{className:"px-4 py-2.5 font-semibold text-foreground whitespace-nowrap align-top w-[180px] border-b border-border/50",children:e.name}),a.jsx("td",{className:"px-4 py-2.5 text-muted-foreground break-words border-b border-border/50",children:a.jsx("span",{dangerouslySetInnerHTML:{__html:e.value.replace(/\n/g,"<br />")}})})]},t))})})})]}):null}function Ux({open:s,onOpenChange:r,returnSteps:n,initialObservation:o="",title:i=e.t("approval_execute_action"),descriptions:d=[],setDefaultApproverOnInit:c=!0,onSubmit:u}){const[m,p]=t.useState(!0),[h,x]=t.useState(c&&n.length>0?n[0].id:null),[f,g]=t.useState(o),v=e=>{p(e),e&&!c?x(null):!e&&!c&&n.length>0&&x(n[0].id)},b=f!==o||!m;return a.jsx(ys,{open:s,onOpenChange:r,children:a.jsxs(ks,{className:"sm:max-w-[480px]",variant:"form",isDirty:b,children:[a.jsx(Ss,{children:a.jsx(Es,{children:i})}),a.jsxs("div",{className:"space-y-4",children:[d.length>0&&a.jsx("div",{className:"space-y-1 text-sm text-muted-foreground",children:d.map((e,t)=>a.jsx("p",{dangerouslySetInnerHTML:{__html:e}},t))}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:m,onChange:()=>v(!0),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_approve")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"approved",checked:!m,onChange:()=>v(!1),className:"accent-primary"}),a.jsx("span",{className:"text-sm",children:e.t("approval_reprove_radio")})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:"Etapa"}),a.jsxs(Vs,{value:h??void 0,onValueChange:x,disabled:m,children:[a.jsx($s,{children:a.jsx(qs,{placeholder:e.t("approval_select_step")})}),a.jsx(Gs,{children:n.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(as,{children:e.t("approval_opinion")}),a.jsx(Js,{value:f,onChange:e=>g(e.target.value),maxLength:4e3,rows:4,autoFocus:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/",4e3]})]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>r(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!f.trim())return void l.toast.error("Formulário inválido. Preencha todos os campos obrigatórios.");const e=m?null:n.find(e=>e.id===h);u({approved:m,returnStepId:m?null:h,returnType:e?.type??null,observation:f})},disabled:!b,children:"Concluir"})]})]})})}function Ox({open:e,onOpenChange:s,approvers:r,isLoading:n=!1,ignoreUserIds:o=[],onSubmit:i}){const{t:l}=y.useTranslation(),[d,c]=t.useState(null),u=t.useMemo(()=>{const e=new Set(o);return r.filter(a=>!e.has(a.id))},[r,o]),m=t.useMemo(()=>u.map(e=>({value:e.id,label:e.name})),[u]);return a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:"sm:max-w-[450px]",variant:"form",isDirty:!!d,children:[a.jsx(Ss,{children:a.jsx(Es,{children:l("approval_select_approver")})}),a.jsx(sr,{isLoading:n,type:"spinner",children:a.jsx("div",{className:"space-y-4",children:a.jsx(Ur,{options:m,value:d??void 0,onValueChange:e=>c("string"==typeof e?e:e?.[0]??null),placeholder:l("approval_select_approver_placeholder"),searchPlaceholder:l("approval_search_approver")})})}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{if(!d)return;const e=u.find(e=>e.id===d);e&&i(e)},disabled:!d||n,children:"Concluir"})]})]})})}function Vx(e){const{t:a}=y.useTranslation();if(!e)return"";return("string"==typeof e?new Date(e):e).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})}function Bx({text:e,maxLength:s=130}){const{t:r}=y.useTranslation(),[n,o]=t.useState(!1);return e.length<=s?a.jsx("span",{children:e}):a.jsxs("span",{children:[n?e:`${e.substring(0,s)}... `,a.jsx("button",{className:"text-primary hover:underline text-sm cursor-pointer",onClick:()=>o(!n),children:r(n?"approval_read_less":"approval_read_more")})]})}function qx({approver:e}){if(1===e.type&&e.approverId)return a.jsxs(cl,{className:"h-9 w-9 shrink-0",children:[a.jsx(ul,{src:e.photoUrl,alt:e.name}),a.jsx(ml,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]});const t=2===e.type?d.Users:3===e.type?d.MapPin:d.User;return a.jsx("div",{className:"h-9 w-9 rounded-full bg-muted-foreground/30 flex items-center justify-center shrink-0",children:a.jsx(t,{className:"h-4 w-4 text-background"})})}function $x({approver:e}){return e.date?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-green-500/10 text-foreground",children:[a.jsx(d.CheckCircle,{className:"h-3.5 w-3.5 text-green-600"}),"Aprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:Vx(e.date)}),1!==e.type&&e.approvedUsername&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["por ",e.approvedUsername]})]}):e.returnDate?a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-red-500/10 text-foreground",children:[a.jsx(d.XCircle,{className:"h-3.5 w-3.5 text-red-600"}),"Reprovado"]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:Vx(e.returnDate)})]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs rounded px-2 py-0.5 bg-muted text-muted-foreground",children:[a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),"Aguardando"]})}function Wx({approver:e}){const{t:t}=y.useTranslation(),s=1!==e.type||e.approverId?e.name:"A definir";return a.jsxs("div",{children:[2===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:t("approval_user_group")}),3===e.type&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Local"}),a.jsx("p",{className:"text-sm font-medium break-words",children:s}),a.jsx($x,{approver:e})]})}var Hx;exports.ApprovalFlowReturnStep=void 0,(Hx=exports.ApprovalFlowReturnStep||(exports.ApprovalFlowReturnStep={}))[Hx.ApprovalFlow=1]="ApprovalFlow",Hx[Hx.Association=2]="Association",exports.i18n=e,Object.defineProperty(exports,"sonnerToast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"toast",{enumerable:!0,get:function(){return l.toast}}),Object.defineProperty(exports,"I18nextProvider",{enumerable:!0,get:function(){return y.I18nextProvider}}),Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:function(){return y.useTranslation}}),exports.AUTH_CONFIG=Me,exports.AccessDeniedDialog=Ji,exports.Accordion=ol,exports.AccordionContent=dl,exports.AccordionItem=il,exports.AccordionTrigger=ll,exports.ActionButton=Jt,exports.ActionMenu=Jt,exports.ActionMenuItems=mo,exports.ActionPlanAttachmentsTab=nx,exports.ActionPlanCommentsTab=ex,exports.ActionPlanCostTab=Zh,exports.ActionPlanGeneralTab=qh,exports.ActionPlanHistoryTab=tx,exports.ActionPlanPage=function(e){const{formData:t,isLoading:s,isSaving:r,activeTab:n,isFormDisabled:o,updateField:i,setActiveTab:l,save:c,changeStatus:u,remove:m,cancel:p}=Oh(e),{t:h}=y.useTranslation(),{isNew:x=!1,config:f,users:g,places:v,actionTypes:b,causes:j,parentActions:w,progress:N,predecessors:_,availablePredecessors:C,costs:k,comments:S,history:T,attachments:P,attachmentsSlot:E,commentsSlot:D,historySlot:A,onAddPredecessor:I,onRemovePredecessor:M,onAddCost:F,onEditCost:R,onDeleteCost:L,onAddComment:z,onEditComment:U,onDeleteComment:O,onUploadAttachment:V,onDeleteAttachment:B,onRenameAttachment:q,onDownloadAttachment:$,onViewAttachment:W}=e;if(s&&!t.id)return a.jsx(sr,{isLoading:!0,children:a.jsx("div",{})});const H=function(e){const{t:a}=y.useTranslation();if(!e)return[];return{[exports.ETaskPlanStatus.waitingStart]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.running]:[exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.effectivenessCheck]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.done]:[exports.ETaskPlanStatus.running],[exports.ETaskPlanStatus.suspended]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.canceled]:[exports.ETaskPlanStatus.waitingStart]}[e]||[]}(t.statusId);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[p&&a.jsx(Xt,{variant:"ghost",size:"icon",onClick:p,children:a.jsx(d.ArrowLeft,{className:"h-4 w-4"})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:x?h("ap_new_action"):t.name||h("ap_action_plan")}),!x&&t.statusId&&a.jsx(Bh,{status:t.statusId})]}),t.code&&a.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:t.code})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!x&&H.length>0&&!o&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"outline",size:"sm",children:"Alterar Status"})}),a.jsx(pr,{align:"end",children:H.map(e=>a.jsx(hr,{onClick:()=>u(e),children:Fh[e]},e))})]}),!x&&e.onDelete&&a.jsxs(nr,{children:[a.jsx(or,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",children:a.jsx(d.MoreVertical,{className:"h-4 w-4"})})}),a.jsx(pr,{align:"end",children:a.jsx(hr,{className:"text-destructive",onClick:m,children:"Excluir"})})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a.jsxs(_i,{value:n,onValueChange:l,children:[a.jsxs(Ci,{className:"mb-6",children:[a.jsx(ki,{value:"general",children:"Geral"}),!x&&a.jsx(ki,{value:"progress",children:"Progresso"}),!x&&f?.enablePredecessors&&a.jsx(ki,{value:"predecessors",children:h("ap_predecessors")}),!x&&f?.enableCosts&&a.jsx(ki,{value:"costs",children:"Custos"}),!x&&f?.enableAttachments&&a.jsx(ki,{value:"attachments",children:h("ap_attachments")}),!x&&f?.enableComments&&a.jsx(ki,{value:"comments",children:h("ap_comments")}),!x&&f?.enableHistory&&a.jsx(ki,{value:"history",children:"Histórico"})]}),a.jsx(Si,{value:"general",children:a.jsx(qh,{formData:t,updateField:i,disabled:o,users:g,places:v,actionTypes:b,causes:j,parentActions:w,config:f})}),!x&&a.jsx(Si,{value:"progress",children:a.jsx(Qh,{...e})}),!x&&f?.enablePredecessors&&a.jsx(Si,{value:"predecessors",children:a.jsx(Jh,{predecessors:_,availablePredecessors:C,onAdd:I,onRemove:M,disabled:o})}),!x&&f?.enableCosts&&a.jsx(Si,{value:"costs",children:a.jsx(Zh,{costs:k,onAdd:F,onEdit:R,onDelete:L,disabled:o})}),!x&&f?.enableAttachments&&a.jsx(Si,{value:"attachments",children:E||a.jsx(nx,{attachments:P,onUpload:V,onDelete:B,onRename:q,onDownload:$,onView:W,disabled:o})}),!x&&f?.enableComments&&a.jsx(Si,{value:"comments",children:D||a.jsx(ex,{comments:S,onAdd:z,onEdit:U,onDelete:O,disabled:o})}),!x&&f?.enableHistory&&a.jsx(Si,{value:"history",children:A||a.jsx(tx,{history:T})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&a.jsx(Xt,{variant:"outline",onClick:p,disabled:r,children:"Cancelar"}),a.jsx(Xt,{onClick:c,disabled:r||o,children:r?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=Jh,exports.ActionPlanProgressDialog=Yh,exports.ActionPlanProgressTab=Qh,exports.ActionPlanStatusBadge=Bh,exports.Alert=ai,exports.AlertDescription=si,exports.AlertDialog=ds,exports.AlertDialogAction=vs,exports.AlertDialogCancel=bs,exports.AlertDialogContent=ps,exports.AlertDialogDescription=gs,exports.AlertDialogFooter=xs,exports.AlertDialogHeader=hs,exports.AlertDialogOverlay=ms,exports.AlertDialogPortal=us,exports.AlertDialogTitle=fs,exports.AlertDialogTrigger=cs,exports.AlertTitle=ti,exports.AliasRedirect=function(){const{alias:e}=An(),{pathname:t,search:s,hash:r}=N.useLocation();return e?a.jsx(N.Navigate,{to:`/${e}${t}${s}${r}`,replace:!0}):null},exports.AliasRouteGuard=function({children:e,paramName:s="alias"}){const r=N.useNavigate(),n=N.useLocation(),o=N.useParams(),{alias:i,isAuthenticated:l,isLoading:d,switchUnit:c}=An(),{urlAlias:u,isAliasMismatch:m,isValidAlias:p,isMissing:h,matchedCompany:x}=Jo({paramName:s}),[f,g]=t.useState(!1),v=t.useRef(!1),b=s in o,y=t.useCallback(e=>{const a=o[s],{pathname:t,search:r,hash:i}=n;if(a){const s=t.split("/"),n=s.findIndex(e=>e===a);if(n>=0)return s[n]=e,s.join("/")+r+i}return`/${e}${"/"===t?"":t}${r}${i}`},[o,s,n]);return t.useEffect(()=>{if(b&&!d&&l&&i&&!v.current)if(h)r(y(i),{replace:!0});else if(!u||p){if(m&&x&&!v.current){(async()=>{v.current=!0,g(!0);try{await c(x)}catch(e){i&&r(y(i),{replace:!0})}finally{v.current=!1,g(!1)}})()}}else r(y(i),{replace:!0})},[b,d,l,i,h,u,p,m,x,c,y,r]),d||!l?a.jsx(a.Fragment,{children:e}):f?a.jsx("div",{className:"flex items-center justify-center min-h-screen",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(tr,{size:"lg"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Trocando unidade..."})]})}):a.jsx(a.Fragment,{children:e})},exports.AppHeader=Tp,exports.AppLayout=Lp,exports.AppSidebar=Rp,exports.ApprovalSidenav=function({config:e,isLoading:s=!1,onClose:r,onApprove:n,onDefineApprover:o,onRefreshSteps:i,availableApprovers:l=[],isLoadingApprovers:c=!1}){const{t:u}=y.useTranslation(),[m,p]=t.useState(!1),[h,x]=t.useState(!1),[f,g]=t.useState(""),[v,b]=t.useState(""),[j,w]=t.useState(!1),[N,_]=t.useState(""),C=s||m,k=t.useCallback((e,a)=>{g(e),b(a??""),x(!0)},[]),S=t.useCallback(async a=>{x(!1),p(!0);if(!await n(e.associationId,{stepApproverId:f,...a}))return k(f,a.observation),void p(!1);r(),p(!1)},[e.associationId,f,n,r,k]),T=t.useCallback(e=>{_(e),w(!0)},[]),P=t.useCallback(async a=>{w(!1),p(!0),await o(e.associationId,N,a),await(i?.(e.associationId)),p(!1)},[e.associationId,N,o,i]),E=e.approvalFlowSteps.find(e=>e.isCurrentStep)?.approvers.filter(e=>1===e.type&&e.approverId).map(e=>e.approverId)??[],D=(a,t)=>e.canApprove&&a.isCurrentStep&&t.approverId&&!t.date&&t.canApprove,A=(a,t)=>!e.flowReproved&&a.isCurrentStep&&1===t.type&&t.canApprove&&(!t.approverId||t.isToBeDefined);return a.jsxs("div",{className:"w-[550px] max-w-[900px] min-w-[400px] h-full flex flex-col bg-background",children:[a.jsxs("div",{className:"shrink-0 shadow-sm px-1 py-2 flex items-center gap-1 border-l-4",style:{borderLeftColor:e.color},children:[a.jsx(Xt,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0",children:a.jsx(d.X,{className:"h-5 w-5"})}),a.jsx("span",{className:"text-lg font-medium",children:e.title})]}),C?a.jsx(sr,{isLoading:!0,type:"spinner",className:"flex-1",children:a.jsx("div",{})}):a.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.approvalFlowInfo.length>0&&a.jsx("div",{className:"space-y-1",children:e.approvalFlowInfo.map((e,t)=>a.jsx("div",{className:Kt("flex items-center gap-1.5 text-sm",e.color&&"rounded-lg px-2 py-1"),style:e.color?{color:e.color,backgroundColor:e.backgroundColor}:void 0,children:e.title?`${e.title}: ${e.value}`:e.value},t))}),a.jsx("hr",{className:"border-border"}),e.approvalFlowSteps.map(t=>a.jsxs("div",{className:Kt("space-y-2",(!t.isCurrentStep||e.flowReproved)&&"opacity-50"),children:[a.jsxs("p",{className:"font-semibold text-sm",children:[t.index,". Etapa: ",t.name]}),t.description&&a.jsx("p",{className:"text-sm text-muted-foreground break-words",children:a.jsx(Bx,{text:t.description})}),t.returnDate&&a.jsxs("div",{className:"border-y border-border py-3 mt-3 space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs rounded px-1.5 py-0.5 bg-red-500/10 text-red-600",children:"Retorno de etapa"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.returnUserName," em ",Vx(t.returnDate)]})]}),t.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground bg-muted rounded p-2 break-words",children:a.jsx(Bx,{text:t.returnObservation})})]}),t.approvers.map(e=>a.jsxs("div",{className:"p-2 space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx(qx,{approver:e}),a.jsx(Wx,{approver:e})]}),D(t,e)&&a.jsx(Xt,{size:"sm",onClick:()=>k(e.id),children:"Aprovar"}),A(t,e)&&a.jsx(Xt,{size:"sm",variant:"outline",onClick:()=>T(e.id),children:"Selecionar"})]}),e.observation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Bx,{text:e.observation})}),e.returnObservation&&a.jsx("p",{className:"text-sm text-muted-foreground break-words ml-11",children:a.jsx(Bx,{text:e.returnObservation})})]},e.id))]},t.id))]}),a.jsx(Ux,{open:h,onOpenChange:x,returnSteps:e.returnSteps,initialObservation:v,title:e.approveDialogTitle,descriptions:e.approveDialogDescriptions,setDefaultApproverOnInit:e.approveDialogSetDefaultApproverOnInit,onSubmit:S}),a.jsx(Ox,{open:j,onOpenChange:w,approvers:l,isLoading:c,ignoreUserIds:E,onSubmit:P})]})},exports.ApproveDialog=Ux,exports.AuditTrailDetails=zx,exports.AuditTrailFilter=Cx,exports.AuditTrailPage=function({title:s,softwares:r,softwareId:n,permissions:o={viewAllEvents:!0,viewOnlyMyEvents:!1,download:!1},callbacks:i,limit:l=2e3,currentUserId:c,labels:u,formatDate:m,anonymousLabel:p=e.t("anonymous")}){const{t:h}=y.useTranslation();s??h("audit_trail");const[x,f]=t.useState(!0),[g,v]=t.useState([]),[b,j]=t.useState([]),[w,N]=t.useState([]),[_,C]=t.useState(null),[k,S]=t.useState(!1),T=t.useRef(null),P=new Date;P.setHours(0,0,0,0);const[E,D]=t.useState({software:r.find(e=>e.id===n)?.software||"",softwareId:n,event:"All",eventId:1,startDate:P,endDate:P,limit:l,softwares:r,userId:o.viewOnlyMyEvents&&!o.viewAllEvents?c:void 0});t.useEffect(()=>{(async()=>{f(!0);try{const[e,a]=await Promise.all([i.onFetchEvents(E.softwareId),i.onFetchUsers?.()??Promise.resolve([])]);j(e),N(a),await A(E,e)}catch(e){}finally{f(!1)}})()},[]);const A=t.useCallback(async(e,a)=>{try{const t=Sx((await i.onFetchTrails(e)).data,a||b,r,p);v(t)}catch(t){}},[i,b,r,p]),I=t.useCallback(async e=>{f(!0),D(e);try{await A(e)}finally{f(!1)}},[A]),M=t.useCallback(async e=>{try{const a=await i.onFetchEvents(e);j(a)}catch(a){}},[i]),F=t.useCallback(e=>{C(e.documentId),S(!0)},[]),R=t.useCallback(()=>{S(!1),C(null)},[]),L=t.useCallback(async()=>{const e={...E,startDate:P,endDate:P,eventId:1,userId:o.viewAllEvents?void 0:c};D(e),f(!0);try{await A(e)}finally{f(!1)}},[E,A]),z=t.useCallback(e=>{i.onExport?.(e,g)},[i,g]),U=t.useCallback(e=>{try{return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}},[]);return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"p-3",children:a.jsx(Cx,{queryParams:E,events:b,softwares:r,users:w,permissions:o,isLoading:x,onFilter:I,onReset:L,onExport:o.download?z:void 0,onSoftwareChange:M})}),a.jsxs("div",{className:"flex flex-1 min-h-0 relative",children:[a.jsxs("div",{className:Kt("flex-1 overflow-auto transition-all duration-300",k?"mr-[400px]":""),children:[x?a.jsxs("div",{className:"flex items-center justify-center h-64",children:[a.jsx(tr,{size:"md"}),a.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Carregando trilha de auditoria..."})]}):0===g.length?a.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground",children:[a.jsx(d.FileText,{className:"h-12 w-12 mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"Nenhum registro encontrado"}),a.jsx("p",{className:"text-xs mt-1",children:"Ajuste os filtros e tente novamente"})]}):a.jsxs("table",{className:"w-full text-xs border-collapse",children:[a.jsx("thead",{className:"sticky top-0 z-10",children:a.jsxs("tr",{className:"bg-muted/60 border-b border-border",children:[a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Layers,{className:"h-3 w-3"}),"Módulo"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.Clock,{className:"h-3 w-3"}),"Data"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.User,{className:"h-3 w-3"}),"Usuário"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(d.FileText,{className:"h-3 w-3"}),"Evento"]})}),a.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"px-3 py-2 w-10"})]})}),a.jsx("tbody",{children:g.map((e,t)=>a.jsxs("tr",{onClick:()=>F(e),className:Kt("cursor-pointer border-b border-border/50 transition-colors","hover:bg-accent/50",_===e.documentId&&"bg-accent",t%2==0?"bg-background":"bg-muted/10"),children:[a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedSoftware}),a.jsx("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",children:e.date?U(e.date.toISOString()):"—"}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.user}),a.jsx("td",{className:"px-3 py-2 text-foreground",children:e.translatedEvent}),a.jsx("td",{className:"px-3 py-2 text-foreground truncate max-w-[200px]",title:e.entityName,children:e.entityName}),a.jsx("td",{className:"px-3 py-2",children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.documentId||t))})]}),!x&&g.length>0&&a.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border bg-muted/20",children:[g.length," registro",1!==g.length?"s":""]})]}),a.jsx("div",{ref:T,className:Kt("fixed right-0 top-0 h-full w-[400px] border-l border-border bg-background shadow-lg z-30","transition-transform duration-300 ease-in-out",k?"translate-x-0":"translate-x-full"),children:k&&a.jsx(zx,{documentId:_,onFetchDetails:i.onFetchDetails,onClose:R,labels:u,translateProperty:i.translateProperty,translatePropertyValue:i.translatePropertyValue,formatDate:m||U})})]})]})},exports.AuthErrorInterceptor=pn,exports.AuthProvider=Dn,exports.AuthService=Sn,exports.AutoComplete=Ur,exports.Avatar=cl,exports.AvatarFallback=ml,exports.AvatarImage=ul,exports.Badge=er,exports.BaseForm=Vo,exports.Blockquote=sd,exports.BodyContent=function({breadcrumbs:e,children:t,className:s}){return a.jsxs("div",{className:Kt("bg-neutral-100 dark:bg-neutral-900","h-full overflow-y-auto","p-6",s),children:[e&&e.length>0&&a.jsx(pl,{className:"mb-4",children:a.jsx(hl,{children:e.map((t,s)=>{const r=s===e.length-1;return a.jsxs(ae.Fragment,{children:[s>0&&a.jsx(vl,{}),a.jsx(xl,{children:r||!t.href?a.jsx(gl,{children:t.label}):t.asChild&&t.children?a.jsx(fl,{asChild:!0,children:t.children}):a.jsx(fl,{asChild:!0,children:a.jsx(N.Link,{to:t.href||"/",children:t.label})})})]},`${t.label}-${s}`)})})}),a.jsx("div",{className:"space-y-6",children:t})]})},exports.Breadcrumb=pl,exports.BreadcrumbEllipsis=bl,exports.BreadcrumbItem=xl,exports.BreadcrumbLink=fl,exports.BreadcrumbList=hl,exports.BreadcrumbPage=gl,exports.BreadcrumbSeparator=vl,exports.BurndownPanel=fm,exports.Button=Xt,exports.ButtonGroup=jl,exports.CLOSED_STATUSES=zh,exports.CRUD_CONFIG=Fe,exports.CURRENCY_FIELDS=qu,exports.Calendar=wl,exports.CallbackPage=()=>{const{processCallback:e}=An(),s=N.useNavigate(),[r,n]=t.useState(null),[o,i]=t.useState(!1);t.useEffect(()=>{(async()=>{try{if(await e()){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(a){localStorage.removeItem("auth_return_url"),n(a?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e,s]);const l=async()=>{i(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(a){n(a?.message||"Erro ao tentar novamente.")}finally{i(!1)}},c=()=>{window.location.href="/"};return r?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsxs(rs,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[a.jsx(d.AlertCircle,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),a.jsxs(os,{className:"space-y-4",children:[a.jsx(ai,{variant:"danger",children:a.jsx(si,{children:r})}),a.jsx("div",{className:"text-sm text-muted-foreground",children:a.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Xt,{onClick:l,disabled:o,className:"flex-1",children:o?a.jsxs(a.Fragment,{children:[a.jsx(tr,{size:"sm",className:"mr-2"}),"Tentando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),a.jsx(Xt,{onClick:c,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsx(tr,{size:"lg"})}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},exports.Card=ts,exports.CardContent=os,exports.CardDescription=ns,exports.CardFooter=is,exports.CardHeader=ss,exports.CardSkeleton=Wn,exports.CardTitle=rs,exports.CartesianPanel=um,exports.ChartContainer=Ec,exports.ChartLegend=Mc,exports.ChartLegendContent=Fc,exports.ChartStyle=Dc,exports.ChartTooltip=Ac,exports.ChartTooltipContent=Ic,exports.Checkbox=Xs,exports.Collapsible=yi,exports.CollapsibleContent=wi,exports.CollapsibleTrigger=ji,exports.ColorPicker=Ao,exports.ColumnSettingsPopover=So,exports.ComboTree=Wr,exports.Combobox=Ur,exports.Command=Tr,exports.CommandDialog=({children:e,...t})=>a.jsx("div",{...t,children:a.jsx(Tr,{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:e})}),exports.CommandEmpty=Dr,exports.CommandGroup=Ar,exports.CommandInput=Pr,exports.CommandItem=Mr,exports.CommandList=Er,exports.CommandSeparator=Ir,exports.CommandShortcut=Fr,exports.ContentContainer=function({title:e,subtitle:t,children:s,className:r,hasHeader:n=!0}){const o=e||t;return a.jsxs("div",{className:Kt("bg-white dark:bg-card","rounded-lg","shadow-sm","border border-border/40","overflow-visible",r),children:[n&&o&&a.jsxs("div",{className:"px-6 py-4 border-b border-border/50",children:[e&&a.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),t&&a.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]}),s&&a.jsx("div",{className:Kt("p-6",!n&&o&&"pt-4"),children:s})]})},exports.ContextMenu=Qn,exports.ContextMenuCheckboxItem=oo,exports.ContextMenuContent=ro,exports.ContextMenuGroup=Jn,exports.ContextMenuItem=no,exports.ContextMenuLabel=lo,exports.ContextMenuPortal=Zn,exports.ContextMenuRadioGroup=ao,exports.ContextMenuRadioItem=io,exports.ContextMenuSeparator=co,exports.ContextMenuShortcut=uo,exports.ContextMenuSub=eo,exports.ContextMenuSubContent=so,exports.ContextMenuSubTrigger=to,exports.ContextMenuTrigger=Xn,exports.CoreProviders=function({children:s,queryClient:r,moduleAlias:n,moduleAccessGuardProps:o,appTranslations:i,clarityProjectId:l,clarityMode:d="auto"}){tl();const[c]=t.useState(()=>new w.QueryClient({defaultOptions:{queries:{staleTime:3e5,retry:1}}})),u=r??c;t.useEffect(()=>{if(i)for(const[e,a]of Object.entries(i))ui(e,a)},[i]);const m={sourceModule:n,...o};return a.jsxs(Ni,{children:[a.jsx(nl,{}),a.jsx(y.I18nextProvider,{i18n:e,children:a.jsx(w.QueryClientProvider,{client:u,children:a.jsxs(Dn,{children:[a.jsx(rl,{projectId:l,mode:d}),a.jsx(xi,{children:a.jsx(vi,{moduleAlias:n,children:a.jsx(el,{...m,children:s})})})]})})})]})},exports.CrudActionBar=wo,exports.CrudActionMenu=cp,exports.CrudGrid=({manager:s,columns:r,onEdit:n,onView:o,onToggleStatus:i,onDelete:l,renderActions:d,customRowActions:c,enableBulkActions:u=!1,onNew:m,newButtonLabel:p,showNewButton:h=!0,customActions:x=[],hideActionBar:f,showActionBar:g=!0,showSearch:v=!1,searchValue:b,onSearchChange:j,searchPlaceholder:w,bulkActions:N=[],onBulkDelete:_,filters:C,gridColumns:k=3,renderCard:S,viewMode:T,onViewModeChange:P,listCardRenderer:E,gridCardRenderer:D,showViewToggle:A=!1})=>{const{setSearchVisible:I}=An(),M=void 0!==f?!f:g;t.useEffect(()=>{if(!v)return I(!0),()=>I(!1)},[I,v]);const F=m||x.length>0||v||u||C||A,R=_||(()=>{s.bulkDelete?.(s.selectedIds)}),L=T||"grid",z="list"===L,U={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"}[z?1:k],O=M&&F?a.jsx(wo,{onNew:m,newButtonLabel:p,showNewButton:h,showSearch:v,searchValue:b,onSearchChange:j,searchPlaceholder:w,showBulkActions:u,selectedCount:s.selectedIds.length,bulkActions:N,onBulkDelete:R,onClearSelection:s.clearSelection,customActions:x,filters:C,viewMode:L,onViewModeChange:P,showViewToggle:A,availableViewModes:["list","grid"]}):null;return s.isLoading?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx(Wn,{count:6})})]}):0===s.entities.length?a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx(Gn,{title:e.t("no_items_found_empty"),description:e.t("no_data_to_display"),variant:"search"})})]}):a.jsxs("div",{className:"flex flex-col h-full",children:[O,a.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.jsx("div",{className:Kt("grid gap-4",U),children:s.entities.map(e=>{const t=(e=>{const{t:a}=y.useTranslation();return z&&E?E(e):!z&&D?D(e):S?S(e):null})(e);return a.jsxs(Qn,{children:[a.jsx(Xn,{asChild:!0,children:t?a.jsx("div",{className:"cursor-pointer",onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:t}):a.jsx(ts,{className:Kt("overflow-hidden cursor-pointer hover:bg-muted/50 transition-colors",u&&s.selectedIds.includes(e.id)&&"bg-muted ring-2 ring-primary",z&&"flex-row"),onClick:a=>{a.stopPropagation(),u?s.selectItem(e.id):n?.(e)},children:a.jsxs(os,{className:Kt("p-4",z&&"flex items-center gap-4 w-full"),children:[u&&a.jsx("div",{className:Kt(z?"":"pt-0.5"),onClick:e=>e.stopPropagation(),children:a.jsx(No,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),z?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1 flex items-center gap-6 min-w-0",children:r.map(t=>a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key)))}),(n||o||d)&&a.jsx("div",{onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(po,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[u&&a.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:a.jsx(No,{checked:s.selectedIds.includes(e.id),onCheckedChange:()=>s.selectItem(e.id)})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[r.map((t,s)=>a.jsxs("div",{className:Kt("flex justify-between items-start gap-2",s!==r.length-1&&"mb-2"),children:[a.jsxs("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:[t.header,":"]}),a.jsx("div",{className:"text-sm text-foreground text-right truncate",children:t.render?t.render(e):String(e[t.key]??"")})]},String(t.key))),(n||o||d)&&a.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:d?d(e):a.jsx(po,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,customActions:c?c(e):[]})})]})]})]})})}),a.jsx(ro,{className:"w-[160px]",children:a.jsx(mo,{onEdit:n?()=>n(e):void 0,onDelete:l?()=>l(e):void 0,onToggleStatus:i?()=>i(e):void 0,isActive:e.is_actived,canDelete:!!l,customActions:c?c(e):[],renderAs:"context"})})]},e.id)})})})]})},exports.CrudPageInternal=Yo,exports.CrudPagination=qo,exports.CrudPrimitiveFilterBar=up,exports.CrudPrimitivePagination=Bo,exports.CrudPrimitiveTable=dp,exports.CrudTable=Po,exports.CustomFormFields=function({fields:e,readOnly:s=!1,hideInactiveWithoutValue:r=!1,onChange:n,onFieldChange:o}){const i=t.useCallback(a=>{if(o?.(a),n){const t=e.map(e=>e.id===a.id?a:e);n(t)}},[e,n,o]),l=e.filter(e=>hx(e,r));return 0===l.length?null:a.jsx("div",{className:"space-y-4",children:l.map(e=>a.jsx(_x,{field:e,readOnly:s,onChange:i},e.id))})},exports.D4SignWidget=Ch,exports.DASHBOARD_STORAGE_KEYS={advancedFilter:"analysisDashboardsListFilter"},exports.DATETIME_FORMATS=Et,exports.DEFAULT_ACTION_TYPES=Rh,exports.DEFAULT_DATETIME_FORMAT=It,exports.DEFAULT_LOCALE=At,exports.DEFAULT_TIMEZONE=Mt,exports.DashboardForm=Fm,exports.DashboardGeneralView=function({dashboards:e,limit:s,generalView:r,language:n=exports.DashboardLanguage.PtBr,isLoading:o=!1,canAdd:i=!1,canEdit:l=!1,canRemove:d=!1,canEditStandard:c=!1,activePanels:u=[],activePages:m=[],getPanelData:p,users:h=[],groups:x=[],places:f=[],collaborators:g=[],isSaving:v=!1,onOpen:b,onBackToList:y,onRefresh:j,onRefreshList:w,onToggleFavorite:N,onSave:_,onUpdate:C,onRemove:k,onDuplicate:S,onShare:T,onAddPanel:P,onEditPanel:E,onRemovePanel:D,onDuplicatePanel:A,onLayoutChange:I,onSearch:M,onQuickFilterChange:F,onSetGeneralView:R,viewState:L,onViewStateChange:z,listToolbarExtra:U,viewToolbarActions:O,className:V}){const[B,q]=t.useState({mode:"list"}),$=L??B,W=t.useCallback(e=>{z?z(e):q(e)},[z]),H=t.useMemo(()=>"view"===$.mode||"edit"===$.mode||"share"===$.mode?e.find(e=>e.id===$.dashboardId)??null:null,[e,$]),[G,K]=t.useState(!1),[Y,Q]=t.useState(m[0]?.id);t.useEffect(()=>{m.length>0&&!Y&&Q(m[0]?.id)},[m,Y]),t.useEffect(()=>{if("view"!==$.mode||!H||H.idViewType!==exports.DashboardViewType.Carousel||m.length<=1)return;const e=function(e){switch(e){case exports.DashboardPageTime.FiveSeconds:return 5e3;case exports.DashboardPageTime.TenSeconds:return 1e4;case exports.DashboardPageTime.FifteenSeconds:return 15e3;case exports.DashboardPageTime.ThirtySeconds:return 3e4;case exports.DashboardPageTime.OneMinute:return 6e4;case exports.DashboardPageTime.ThreeMinutes:return 18e4;case exports.DashboardPageTime.FiveMinutes:return 3e5;case exports.DashboardPageTime.TenMinutes:return 6e5;default:return 15e3}}(H.idPageTime),a=setInterval(()=>{Q(e=>{const a=(m.findIndex(a=>a.id===e)+1)%m.length;return m[a]?.id})},e);return()=>clearInterval(a)},[$,H,m]);const X=t.useCallback(e=>{W({mode:"view",dashboardId:e.id}),Q(void 0),b?.(e)},[W,b]),J=t.useCallback(()=>{W({mode:"list"}),K(!1),y?.()},[W,y]),Z=t.useCallback(()=>{W({mode:"create"})},[W]),ee=t.useCallback(e=>{W({mode:"edit",dashboardId:e.id})},[W]),ae=t.useCallback(e=>{W({mode:"share",dashboardId:e.id})},[W]),te=t.useCallback(e=>{"edit"===$.mode||"share"===$.mode?C?.($.dashboardId,e):_?.(e)},[$,_,C]),se=t.useCallback(()=>{"edit"===$.mode||"share"===$.mode?W({mode:"view",dashboardId:$.dashboardId}):W({mode:"list"})},[$,W]),re=t.useCallback(()=>{H&&N?.(H)},[H,N]),ne=t.useCallback(()=>{H&&ee(H)},[H,ee]),oe=t.useCallback(()=>{H&&ae(H)},[H,ae]);return a.jsxs("div",{className:Kt("flex flex-col h-full",V),children:["list"===$.mode&&a.jsx(Pm,{dashboards:e,limit:s,isLoading:o,language:n,canAdd:i,canEdit:l,canRemove:d,onOpen:X,onEdit:ee,onShare:ae,onDuplicate:S,onRemove:k,onAdd:Z,onToggleFavorite:N,onRefresh:w,onSearch:M,onQuickFilterChange:F,toolbarExtra:U,className:"flex-1"}),"view"===$.mode&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[!G&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:[a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]}),r?.dashboardId===H.id&&a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary",children:[a.jsxs("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),a.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),"Visão geral"]}),l&&R&&r?.dashboardId!==H.id&&a.jsx("button",{onClick:()=>R(H.id),className:"ml-auto text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Definir como visão geral"})]}),a.jsx(Cm,{dashboard:H,panels:u,pages:m,activePageId:Y,canEdit:l||c&&!!H.isStandard,isFullscreen:G,isLoading:o,getPanelData:p,onRefresh:j,onToggleFullscreen:()=>K(e=>!e),onToggleFavorite:re,onEdit:ne,onShare:oe,onAddPanel:P,onEditPanel:E,onRemovePanel:D,onDuplicatePanel:A,onLayoutChange:I,onPageChange:Q,toolbarActions:O,className:"flex-1"})]}),"create"===$.mode&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:J,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar para lista"]})}),a.jsx(Fm,{users:h,groups:x,places:f,collaborators:g,isSaving:v,onSave:te,onCancel:se,className:"flex-1"})]}),("edit"===$.mode||"share"===$.mode)&&H&&a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-card",children:a.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"m15 18-6-6 6-6"})}),"Voltar"]})}),a.jsx(Fm,{dashboard:H,initialTab:"share"===$.mode?exports.DashboardFormTab.Share:exports.DashboardFormTab.General,users:h,groups:x,places:f,collaborators:g,isSaving:v,isQualitfy:!!H.isStandard&&!c,onSave:te,onCancel:se,className:"flex-1"})]})]})},exports.DashboardGrid=wm,exports.DashboardList=Pm,exports.DashboardPanelRenderer=_m,exports.DashboardView=Cm,exports.DataFilterBar=up,exports.DataList=Nl,exports.DataPagination=Bo,exports.DataTable=dp,exports.DatePicker=_l,exports.Dialog=ys,exports.DialogBody=Ts,exports.DialogClose=Ns,exports.DialogContent=ks,exports.DialogDescription=Ds,exports.DialogFooter=Ps,exports.DialogHeader=Ss,exports.DialogOverlay=_s,exports.DialogPortal=ws,exports.DialogTitle=Es,exports.DialogTrigger=js,exports.DialogWizard=function({open:t,onOpenChange:s,currentStep:r,onStepChange:n,steps:o,canGoToStep:i,children:l,title:c,description:u,onSave:m,saveLabel:p=e.t("save"),nextLabel:h=e.t("next"),backLabel:x=e.t("back"),variant:f="form",isDirty:g,size:v="lg",unsavedChangesTitle:b,unsavedChangesDescription:j,cancelText:w,leaveWithoutSavingText:N,className:_,disableNext:C,hideNavigation:k,footerLeft:S}){const{t:T}=y.useTranslation(),P=o.length,E=r>=P,D=r<=1;return a.jsx(ys,{open:t,onOpenChange:s,children:a.jsxs(ks,{size:v,variant:f,isDirty:g,unsavedChangesTitle:b,unsavedChangesDescription:j,cancelText:w,leaveWithoutSavingText:N,className:Kt("!p-0 !border-l-0 flex-row overflow-hidden",_),children:[a.jsxs("div",{className:"hidden sm:flex w-56 flex-shrink-0 flex-col bg-primary text-primary-foreground p-6 rounded-l-lg",children:[a.jsx("h3",{className:"text-sm font-medium opacity-80 mb-6",children:"Etapas"}),a.jsx("nav",{className:"flex flex-col gap-1 flex-1",children:o.map((e,t)=>{const s=t+1,o=s===r,l=(e=>e<r)(s),c=(u=s)<=r||!i||i(u);var u;return a.jsxs("button",{type:"button",onClick:()=>(e=>{e!==r&&(e<r?n(e):i&&!i(e)||n(e))})(s),disabled:!c,className:Kt("flex items-center gap-2 py-3 px-2 rounded-md text-left transition-colors text-xs",o&&"bg-primary-foreground/20 font-semibold",!o&&c&&"hover:bg-primary-foreground/10 cursor-pointer",!c&&"opacity-40 cursor-not-allowed"),children:[a.jsx("span",{className:Kt("flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold flex-shrink-0 transition-colors",o&&"bg-primary-foreground text-primary",l&&!o&&"bg-primary-foreground/30 text-primary-foreground",!o&&!l&&"border-2 border-primary-foreground/40 text-primary-foreground/60"),children:l&&!o?a.jsx(d.Check,{className:"h-3.5 w-3.5"}):s}),a.jsx("span",{className:Kt("line-clamp-2",o&&"text-primary-foreground",!o&&"text-primary-foreground/70"),children:e})]},s)})})]}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[a.jsxs(Ss,{className:"p-6 pb-0",children:[a.jsxs("p",{className:"text-xs text-muted-foreground sm:hidden mb-1",children:["Etapa ",r," de ",P]}),a.jsx(Es,{children:c}),u&&a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]}),a.jsx(Ts,{className:"px-6",children:l}),!k&&a.jsx(Ps,{className:"px-6 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsx("div",{className:"flex items-center gap-2",children:S}),a.jsxs("div",{className:"flex items-center gap-2",children:[!D&&a.jsx(Xt,{variant:"outline",onClick:()=>n(r-1),children:x}),E?a.jsx(Xt,{onClick:m,disabled:C,children:p}):a.jsx(Xt,{onClick:()=>n(r+1),disabled:C,children:h})]})]})})]})]})})},exports.DisabledMenuItem=_r,exports.DocumentSigner=function({file:s,onDocumentSigned:r,onError:n,showEventLog:o=!1}){const{user:i,alias:c}=An(),{config:u,isLoading:m}=fh(),{t:p}=y.useTranslation(),[h,x]=t.useState(null),[f,g]=t.useState(!1),[v,b]=t.useState(null),[j,w]=t.useState("sandbox"),[N,_]=t.useState("clicksign"),[C,k]=t.useState(null),[S,T]=t.useState(null),[P,E]=t.useState(!1),[D,A]=t.useState(0),[I,M]=t.useState(!1),[F,R]=t.useState([]),L=t.useRef(null),z=t.useRef(null),U=t.useCallback(e=>{o&&R(a=>[...a,`[${(new Date).toLocaleTimeString()}] ${e}`])},[o]),O=t.useCallback(async a=>{if(x(a),b(null),k(null),T(null),U(`Arquivo selecionado: ${a.name}`),c&&i){g(!0);try{const t=u?.provider??"clicksign";_(t),U(`Provedor resolvido: ${t}`);const s=new FileReader,r=await new Promise((e,t)=>{s.onload=()=>{const a=s.result;e(a)},s.onerror=t,s.readAsDataURL(a)});U(`Criando envelope para assinatura via ${t}...`);const o=await yh.createEnvelopeWithSigner({alias:c,contentBase64:r,filename:a.name,signerEmail:i.email||"",signerName:i.name||"",provider:t});U(`Envelope criado: ${o.envelope_id}`),k({envelope_id:o.envelope_id,document_id:o.document_id,signer_email:o.signer_email,key_signer:o.signer_id}),w(o.environment),_(o.provider||t),"d4sign"===t?(U("Documento enviado para D4Sign. Abrindo widget de assinatura..."),await new Promise(e=>setTimeout(e,2e3)),b(o.document_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):o.signer_id?(U(`Signer ID obtido: ${o.signer_id}. Aguardando processamento (3s)...`),await new Promise(e=>setTimeout(e,3e3)),b(o.signer_id),l.toast.success(p("sign_doc_sent","Documento enviado! Assine abaixo."))):(U(e.t("sign_signer_unavailable")),l.toast.error(p("sign_access_error","Não foi possível obter o acesso para assinatura. Tente novamente.")),n?.(new Error(p("sign_signer_unavailable"))))}catch(t){const a=t instanceof Error?t:new Error(p("sign_process_error",p("sign_doc_process_error"))),s=a.message||"";s.includes("MONTHLY_LIMIT_REACHED")?(U(e.t("sign_monthly_limit")),l.toast.error(p("sign_monthly_limit","Limite mensal de assinaturas atingido. Entre em contato com o administrador para ampliar seu plano."))):(U(`Erro: ${s}`),l.toast.error(s)),n?.(a)}finally{g(!1)}}},[c,i,U,n,u]);t.useEffect(()=>{s&&c&&i&&!m&&s!==z.current&&(z.current=s,O(s))},[s,c,i,m,O]);const V=t.useCallback(async()=>{if(!C||!c)return;E(!0),A(0),M(!1),U("Buscando documento assinado...");for(let t=1;t<=6;t++){A(t),U(`Tentativa ${t}/6...`);try{const a=await yh.getSignedDocument({alias:c,envelopeId:C.envelope_id,documentId:C.document_id,provider:N});if(a.download_url)return U(e.t("sign_doc_available")),T(a.download_url),void E(!1)}catch(a){U(`Erro na tentativa ${t}: ${a instanceof Error?a.message:p("unknown_error")}`)}t<6&&(U("Aguardando 10 segundos para próxima tentativa..."),await new Promise(e=>setTimeout(e,1e4)))}U(e.t("sign_fetch_failed")),E(!1),M(!0)},[C,c,U,N]),B=t.useCallback(async()=>{U("Documento assinado com sucesso!"),l.toast.success(p("sign_signed_success","Documento assinado com sucesso!")),b(null),C&&c&&(r?.({success:!0,provider:N,envelope_id:C.envelope_id,document_id:C.document_id,signer_id:v||"",environment:j}),await V())},[U,r,C,v,c,j,N,V]);if(!c)return a.jsx(ts,{className:"border-amber-200 bg-amber-50",children:a.jsx(os,{className:"flex items-start gap-3 py-6",children:a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-amber-800",children:p("sign_auth_required","Autenticação necessária")}),a.jsx("p",{className:"text-sm text-amber-700 mt-1",children:p("sign_login_required","Faça login para utilizar a assinatura digital.")})]})})});const q="d4sign"===N?"D4Sign":"Clicksign",$=()=>o&&F.length>0?a.jsx("div",{className:"bg-muted p-3 rounded-md text-xs font-mono space-y-1 max-h-40 overflow-auto",children:F.map((e,t)=>a.jsx("div",{children:e},t))}):null;return C&&!v&&(S||P||I)?a.jsxs("div",{className:"space-y-4",children:[a.jsx(ts,{className:"border-green-200 bg-green-50",children:a.jsxs(os,{className:"flex flex-col items-center gap-4 py-8",children:[a.jsx(d.CheckCircle2,{className:"h-12 w-12 text-green-600"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-lg font-semibold text-green-800",children:p("sign_signed_success","Documento assinado com sucesso!")}),a.jsx("p",{className:"text-sm text-green-700 mt-1",children:h?.name})]}),P?a.jsxs("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}),p("sign_preparing_doc","Preparando documento assinado...")," (",p("sign_attempt","tentativa")," ",D,"/6)"]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_waiting_provider",`Aguardando processamento pelo ${q}...`)})]}):S?a.jsx(Xt,{asChild:!0,variant:"default",className:"gap-2",children:a.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(d.Download,{className:"h-4 w-4"}),p("sign_download_signed","Baixar documento assinado")]})}):I?a.jsxs("div",{className:"text-center space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_fetch_failed","Não foi possível obter o documento assinado após 1 minuto.")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:p("sign_email_fallback","O documento será enviado para o seu e-mail assim que estiver disponível.")})]}),a.jsxs(Xt,{variant:"secondary",className:"gap-2",onClick:V,children:[a.jsx(d.RefreshCw,{className:"h-4 w-4"}),p("sign_try_again","Tentar novamente")]})]}):null]})}),a.jsx($,{})]}):v?a.jsxs("div",{className:"space-y-4",children:["d4sign"===N?a.jsx(Ch,{documentKey:v,signerEmail:C?.signer_email||i?.email||"",signerName:i?.name,keySigner:C?.key_signer,environment:j,onSign:B,onError:n}):a.jsx(_h,{signerId:v,environment:j,onSign:B,onError:n}),a.jsx($,{})]}):s&&(f||m)?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("input",{ref:L,type:"file",accept:"application/pdf",className:"hidden",onChange:e=>{const a=e.target.files?.[0];a&&"application/pdf"===a.type?O(a):l.toast.error(p("sign_select_pdf","Selecione um arquivo PDF"))}}),f?a.jsx(ts,{children:a.jsxs(os,{className:"flex items-center justify-center gap-3 py-10",children:[a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-primary"}),a.jsx("p",{className:"font-medium",children:p("sign_sending_doc","Enviando documento para assinatura...")})]})}):a.jsx(ts,{className:"border-dashed border-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>L.current?.click(),children:a.jsxs(os,{className:"flex flex-col items-center justify-center py-10 gap-3",children:[a.jsx(d.Upload,{className:"h-8 w-8 text-muted-foreground"}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"font-medium",children:p("sign_select_pdf","Selecione um arquivo PDF")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:p("sign_click_to_select","Clique para escolher o documento para assinatura")})]})]})}),a.jsx($,{})]})},exports.Drawer=Cl,exports.DrawerClose=Tl,exports.DrawerContent=El,exports.DrawerDescription=Ml,exports.DrawerFooter=Al,exports.DrawerHeader=Dl,exports.DrawerOverlay=Pl,exports.DrawerPortal=Sl,exports.DrawerTitle=Il,exports.DrawerTrigger=kl,exports.DropdownMenu=nr,exports.DropdownMenuCheckboxItem=xr,exports.DropdownMenuContent=pr,exports.DropdownMenuGroup=ir,exports.DropdownMenuItem=hr,exports.DropdownMenuLabel=gr,exports.DropdownMenuPortal=lr,exports.DropdownMenuRadioGroup=cr,exports.DropdownMenuRadioItem=fr,exports.DropdownMenuSeparator=vr,exports.DropdownMenuShortcut=br,exports.DropdownMenuSub=dr,exports.DropdownMenuSubContent=mr,exports.DropdownMenuSubTrigger=ur,exports.DropdownMenuTrigger=or,exports.ElectronicSignatureDialog=function({open:s,onOpenChange:r,onConfirm:n,onGenerateCode:o,mode:i="code",email:l,maxLength:c=8,title:u=e.t("electronic_signature"),description:m,confirmLabel:p=e.t("conclude"),cancelLabel:h=e.t("cancel"),resendLabel:x=e.t("resend_code"),errorMessage:f}){const g="password"===i,v=g?e.t("esign_password_description"):e.t("esign_code_description"),b=m??v,[y,j]=t.useState(""),[w,N]=t.useState(!1),[_,C]=t.useState(!1),[k,S]=t.useState(null),T=t.useCallback(async()=>{if(y.trim()){N(!0),S(null);try{await n(y)?(j(""),r(!1)):S(f??(g?e.t("esign_invalid_password"):e.t("esign_invalid_code")))}catch{S(f??(g?e.t("esign_password_error"):e.t("esign_code_error")))}finally{N(!1)}}},[y,n,r,f,g]),P=t.useCallback(async()=>{if(o){C(!0),S(null);try{await o()}catch{S(e.t("esign_resend_error"))}finally{C(!1)}}},[o]),E=e=>{e||(j(""),S(null)),r(e)},D=g?d.Lock:d.ShieldCheck,A=g?"Senha":e.t("verification_code"),I=g?e.t("enter_password"):e.t("enter_code");return a.jsx(ys,{open:s,onOpenChange:E,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!y,children:[a.jsx(Ss,{children:a.jsxs(Es,{className:"flex items-center gap-2",children:[a.jsx(D,{className:"h-5 w-5 text-primary"}),u]})}),a.jsxs("div",{className:"py-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:b}),!g&&l&&a.jsxs("div",{className:"flex items-center gap-2 text-sm bg-muted/50 rounded-md px-3 py-2",children:[a.jsx(d.Mail,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground",children:"Enviado para:"}),a.jsx("span",{className:"font-medium",children:l})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"signature-input",children:A}),a.jsx(Zt,{id:"signature-input",type:g?"password":"text",value:y,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&(e.preventDefault(),T())},maxLength:g?void 0:c,placeholder:I,autoFocus:!0,className:Kt(k&&"border-destructive focus-visible:ring-destructive")}),k&&a.jsx("p",{className:"text-sm text-destructive",children:k})]}),!g&&a.jsxs(Xt,{variant:"ghost",size:"sm",onClick:P,disabled:_,className:"text-primary",children:[a.jsx(d.RefreshCw,{className:Kt("h-4 w-4 mr-1",_&&"animate-spin")}),x]})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>E(!1),disabled:w,children:h}),a.jsx(Xt,{onClick:T,disabled:!y.trim()||w,children:w?"Validando...":p})]})]})})},exports.EllipsisText=Kn,exports.EmailService=zp,exports.EmptyState=Gn,exports.EntitySelect=Ur,exports.ErrorBoundary=Ni,exports.ExportDialog=function({open:e,onOpenChange:s,onExport:r,mode:n="table",options:o,title:i,description:l,cancelLabel:d="Cancelar",exportLabel:c="Exportar"}){const{t:u}=y.useTranslation(),[m,p]=t.useState(""),h=o??("chart"===n?Hc:Wc),x=i??u("chart"===n?"dashboard_export_chart":"dashboard_export_table"),f=l??u("select_file_format"),g=e=>{e||p(""),s(e)};return a.jsx(ys,{open:e,onOpenChange:g,children:a.jsxs(ks,{className:"sm:max-w-md",variant:"form",isDirty:!!m,children:[a.jsx(Ss,{children:a.jsx(Es,{children:x})}),a.jsxs("div",{className:"py-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),a.jsx(wd,{value:m,onValueChange:p,className:"gap-3",children:h.map(e=>a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Nd,{value:e.value,id:`export-${e.value}`}),a.jsxs(as,{htmlFor:`export-${e.value}`,className:Kt("flex items-center gap-2 cursor-pointer font-normal",m===e.value&&"font-medium"),children:[e.icon,e.label]})]},e.value))})]}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"outline",onClick:()=>g(!1),children:d}),a.jsx(Xt,{onClick:()=>{m&&(r(m),s(!1),p(""))},disabled:!m,children:c})]})]})})},exports.FORBIDDEN_FILE_TYPES=ix,exports.FilterBar=Ko,exports.Form=As,exports.FormControl=zs,exports.FormDateField=gx,exports.FormDescription=Us,exports.FormField=({...e})=>a.jsx(Is.Provider,{value:{name:e.name},children:a.jsx(h.Controller,{...e})}),exports.FormItem=Rs,exports.FormLabel=Ls,exports.FormMessage=Os,exports.FormMultiSelectionField=wx,exports.FormNumericField=yx,exports.FormQuestionsField=Nx,exports.FormSingleSelectionField=jx,exports.FormSkeleton=function({fields:e=4}){return a.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Rr,{className:"h-4 w-24"}),a.jsx(Rr,{className:"h-10 w-full"})]},t)),a.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[a.jsx(Rr,{className:"h-10 w-20"}),a.jsx(Rr,{className:"h-10 w-20"})]})]})},exports.FormTextField=fx,exports.FormTimeField=vx,exports.FormUrlField=bx,exports.Grid=function({children:e,cols:t="auto-fit",gap:s="md",className:r}){return a.jsx("div",{className:Kt("grid",Fl[t],Rl[s],r),children:e})},exports.H1=Gl,exports.H2=Kl,exports.H3=Yl,exports.H4=Ql,exports.HeaderSkeleton=function(){return a.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[a.jsxs("div",{className:"flex items-center space-x-3",children:[a.jsx(Rr,{className:"h-8 w-8 rounded-full"}),a.jsx(Rr,{className:"h-6 w-32"})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(Rr,{className:"h-8 w-8"}),a.jsx(Rr,{className:"h-8 w-24"})]})]})},exports.HoverCard=Ll,exports.HoverCardContent=Ul,exports.HoverCardTrigger=zl,exports.IconPicker=Lo,exports.IframeDialog=ou,exports.ImageEditor=function({value:e,onChange:s,onSubmit:r,onCancel:n,uploadFunction:o,deleteFunction:i,uploadOptions:c}){const{t:u}=y.useTranslation(),[m,p]=t.useState(e||{alignment:"center",allowDownload:!1}),h=t.useRef(null),{upload:x,uploading:f}=lh({uploadFunction:o,deleteFunction:i,defaultOptions:{...c,allowedTypes:["image/*"],maxSize:5242880}}),g=(e,a)=>{const t={...m,[e]:a};p(t),s(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:m.imageUrl||"",onChange:e=>g("imageUrl",e.target.value),className:"flex-1"}),o&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await x(a),t={...m,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};p(t),s(t)}catch(t){}finally{h.current&&(h.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>h.current?.click(),disabled:f,children:f?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),m.imageFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",m.imageFile," (",Math.round((m.imageSize||0)/1024)," KB)"]})]}),m.imageUrl&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:a.jsx("div",{className:"flex "+("left"===m.alignment?"justify-start":"right"===m.alignment?"justify-end":"justify-center"),children:a.jsx("img",{src:m.imageUrl,alt:m.alt||"Preview",style:{width:m.width?`${m.width}px`:"auto",height:m.height?`${m.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"caption",children:"Legenda"}),a.jsx(Js,{id:"caption",placeholder:"Legenda",value:m.caption||"",onChange:e=>g("caption",e.target.value),rows:2})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"alt",children:u("alt_text")}),a.jsx(Zt,{id:"alt",placeholder:u("alt_text"),value:m.alt||"",onChange:e=>g("alt",e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Alinhamento"}),a.jsxs(Vs,{value:m.alignment||"center",onValueChange:e=>g("alignment",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"left",children:"Esquerda"}),a.jsx(Ys,{value:"center",children:"Centro"}),a.jsx(Ys,{value:"right",children:"Direita"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"width",children:"Largura"}),a.jsx(Zt,{id:"width",type:"number",placeholder:"px",value:m.width||"",onChange:e=>g("width",e.target.value?Number(e.target.value):void 0)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"height",children:"Altura"}),a.jsx(Zt,{id:"height",type:"number",placeholder:"px",value:m.height||"",onChange:e=>g("height",e.target.value?Number(e.target.value):void 0)})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"allowDownload",checked:m.allowDownload||!1,onCheckedChange:e=>g("allowDownload",!0===e)}),a.jsx(as,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:n,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{m.imageUrl?r(m):l.toast.error("Erro",{description:u("no_image_selected")})},disabled:!m.imageUrl,children:"Salvar"})]})]})},exports.ImageRenderer=function({content:e,className:t="",style:s}){const{t:r}=y.useTranslation();if(!e.imageUrl)return null;const n={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return a.jsx("div",{className:`flex ${n} my-4 ${t}`,style:s,children:a.jsxs("div",{className:"space-y-2 max-w-full",children:[a.jsx("img",{src:e.imageUrl,alt:e.alt||"",style:{width:e.width?`${e.width}px`:"auto",height:e.height?`${e.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"}),e.caption&&a.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&a.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[a.jsx(d.Download,{className:"h-4 w-4"}),"Baixar imagem"]})]})})},exports.InlineCode=td,exports.Input=Zt,exports.InputGroup=Ol,exports.InputGroupAddon=Bl,exports.InputGroupButton=$l,exports.InputGroupInput=Wl,exports.InputGroupTextarea=Hl,exports.LINK_PROPERTIES=$u,exports.LOGO_CONFIG=Be,exports.Label=as,exports.Large=Zl,exports.Lead=Jl,exports.LeadershipDialog=nh,exports.LeadershipForm=rh,exports.LeadershipPage=function({unassociatedUsers:s=[],onAssociateUser:r,onMoveNode:n,onMoveNodes:o,columns:i,nameHeader:l=e.t("leader"),rootDropLabel:c=e.t("leadership_make_root")}={}){const{alias:u}=An(),{data:m,isLoading:p,error:h,refetch:x}=Wp(),f=Yp(),g=Gp(),[v,b]=t.useState(()=>u?(e=>{try{const a=localStorage.getItem(`${oh}-${e}`);if(a)return new Set(JSON.parse(a))}catch{}return new Set})(u):new Set),[y,j]=t.useState([]),[w,N]=t.useState(new Set),[_,C]=t.useState(!0),[k,S]=t.useState(!1),[T,P]=t.useState(),[E,D]=t.useState(null),A=t.useMemo(()=>m?$p(m):[],[m]),I=t.useMemo(()=>A.map(e=>e.id),[A]),M=I.length>0&&y.length===I.length,F=A.filter(e=>e.children.length>0).every(e=>v.has(e.id));t.useEffect(()=>{if(m&&m.length>0&&u){if(!localStorage.getItem(`${oh}-${u}`)){const e=m.map(e=>e.id),a=new Set(e);b(a),ih(u,a)}}},[m,u]);const R=t.useCallback(e=>{b(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),u&&ih(u,t),t})},[u]),L=t.useCallback(()=>{if(F){const e=new Set;b(e),u&&ih(u,e)}else{const e=new Set(A.filter(e=>e.children.length>0).map(e=>e.id));b(e),u&&ih(u,e)}},[F,A,u]),z=t.useCallback(e=>{j(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),U=t.useCallback(()=>{j(M?[]:I)},[M,I]),O=t.useCallback(e=>{N(a=>{const t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),V=t.useCallback(e=>A.find(a=>a.id===e),[A]),B=t.useCallback((e,a)=>{if(n)return void n(e,a);const t=s.find(a=>a.id===e);if(t){if(r){const e=a?V(a):null;r(t.id,e?.id_user||null)}else g.mutate({id_user:t.id,id_leader:a&&V(a)?.id_user||null});return}const o=V(e);if(!o)return;const i=a?V(a):null;f.mutate({id:o.id,id_leader:i?.id_user||null})},[n,s,r,V,f,g]),q=t.useCallback((e,a)=>{o?o(e,a):(e.forEach(e=>B(e,a)),j([]))},[o,B]),$=t.useCallback(e=>{P(e),D(null),S(!0)},[]),W=t.useCallback(()=>{P(void 0),D(null),S(!0)},[]),H=t.useCallback(()=>{S(!1),P(void 0),D(null)},[]),G=t.useCallback((e,a)=>{const t=w.has(e)&&w.size>1?Array.from(w):[e];a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",e),a.dataTransfer.setData("application/x-tree-ids",JSON.stringify(t)),a.currentTarget.style.opacity="0.4"},[w]),K=t.useMemo(()=>[{key:"subordinatesCount",header:"Subordinados",hoverContent:e=>e.subordinateNames&&e.subordinateNames.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subordinados diretos:"}),[...e.subordinateNames].sort((e,a)=>e.localeCompare(a)).map(e=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(d.User,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{children:e})]},e))]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem subordinados diretos"})},{key:"email",header:"Email",className:"text-left",width:180,render:e=>a.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground text-sm",children:[a.jsx(d.Mail,{className:"h-3.5 w-3.5"}),e.email||"—"]})}],[]),Y=i??K;if(p)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."})]})});if(h)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),a.jsx(Xt,{onClick:()=>x(),children:e.t("try_again")})]})});const Q=A.filter(a=>a.name!==e.t("inactive_user")).length;return a.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs(Xt,{size:"sm",onClick:W,children:[a.jsx(d.Plus,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),a.jsx(Xt,{size:"sm",variant:"outline",onClick:L,children:F?a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronDown,{className:"h-4 w-4 mr-1"}),"Colapsar"]}):a.jsxs(a.Fragment,{children:[a.jsx(d.ChevronRight,{className:"h-4 w-4 mr-1"}),"Expandir"]})}),a.jsx("div",{className:"flex items-center gap-2 ml-4",children:a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("span",{className:"text-sm font-medium",children:[Q," usuário",1!==Q?"s":""," associado",1!==Q?"s":""]})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Arraste as linhas para reorganizar • Selecione múltiplos para mover em lote"})]}),a.jsx(fp,{data:m||[],columns:Y,nameKey:"name",nameHeader:l,expandedIds:v,onToggleExpand:R,iconComponent:a.jsx(d.Users,{className:"h-4 w-4 text-muted-foreground shrink-0"}),rowActionsVariant:"inline",enableRowDrag:!0,enableSelection:!0,selectedIds:y,onSelectItem:z,onSelectAll:U,isAllSelected:M,onMoveNode:B,onMoveNodes:q,rootDropLabel:c,emptyMessage:e.t("leadership_no_hierarchy"),renderActions:e=>a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(e),children:a.jsx(d.Pencil,{className:"h-4 w-4"})})}),s.length>0&&a.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>C(e=>!e),className:"w-full px-4 py-2.5 bg-muted/50 border-b flex items-center gap-2 hover:bg-muted/70 transition-colors cursor-pointer",children:[_?a.jsx(d.ChevronDown,{className:"h-4 w-4 text-muted-foreground shrink-0"}):a.jsx(d.ChevronRight,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx(d.UserPlus,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium",children:"Usuários não associados"}),a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(",s.length,")"]}),w.size>0&&a.jsxs("span",{className:"text-xs text-primary ml-1",children:["(",w.size," selecionado",w.size>1?"s":"",")"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Arraste para a hierarquia acima"})]}),_&&a.jsx("div",{className:"divide-y",children:s.map(e=>a.jsxs("div",{draggable:!0,onDragStart:a=>G(e.id,a),onDragEnd:e=>{e.currentTarget.style.opacity="1"},className:Kt("flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors",w.has(e.id)&&"bg-primary/5"),children:[a.jsx(Xs,{checked:w.has(e.id),onCheckedChange:()=>O(e.id),onClick:e=>e.stopPropagation(),className:"shrink-0"}),a.jsx("span",{className:"text-muted-foreground shrink-0 select-none",children:"⠿"}),a.jsx(d.User,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"text-sm truncate",children:e.name}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id))})]}),a.jsxs("div",{className:"px-3 py-2 bg-muted/20 border rounded-lg text-xs text-muted-foreground flex justify-between",children:[a.jsxs("span",{children:["Usuários associados: ",Q]}),s.length>0&&a.jsxs("span",{children:["Usuários não associados: ",s.length]})]}),a.jsx(nh,{open:k,onOpenChange:H,leader:T,prefilledLeaderId:E,title:T?e.t("edit_name"):E?e.t("leadership_add_subordinate"):e.t("leadership_add_root")},`leadership-dialog-${u}`)]})},exports.List=rd,exports.ListPanel=lm,exports.LoadingState=sr,exports.LocaleProvider=xi,exports.LoginPage=()=>{const{t:e}=y.useTranslation();return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),a.jsxs(os,{className:"text-center space-y-4",children:[a.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),a.jsx(Xt,{onClick:async()=>{ze()?await Sn.loginDev():Sn.loginProd()},className:"w-full",size:"lg",children:ze()?e("dev_login"):e("login_with_qualiex")})]})]})})},exports.MESSAGES=qe,exports.MODULES_DATA=Bi,exports.MONTHS_MAP=Bu,exports.ManageAccessModal=Op,exports.MatrixRiskPanel=vm,exports.Menubar=fc,exports.MenubarCheckboxItem=wc,exports.MenubarContent=yc,exports.MenubarGroup=mc,exports.MenubarItem=jc,exports.MenubarLabel=_c,exports.MenubarMenu=uc,exports.MenubarPortal=pc,exports.MenubarRadioGroup=xc,exports.MenubarRadioItem=Nc,exports.MenubarSeparator=Cc,exports.MenubarShortcut=kc,exports.MenubarSub=hc,exports.MenubarSubContent=bc,exports.MenubarSubTrigger=vc,exports.MenubarTrigger=gc,exports.MindMap=({value:e,defaultValue:s,onChange:r,onNodeSelect:n,readOnly:o=!1,hideToolbar:i=!1,extraShortcuts:l,renderNodeContent:d,className:c,height:u=600})=>{const{t:m}=y.useTranslation(),p=Km({value:e,defaultValue:s,onChange:r,readOnly:o}),h=ap(p.root),x=function(){const[e,a]=t.useState({x:0,y:0,scale:1}),s=t.useRef(!1),r=t.useRef({x:0,y:0,tx:0,ty:0}),n=t.useCallback(a=>{0!==a.button&&1!==a.button||(s.current=!0,r.current={x:a.clientX,y:a.clientY,tx:e.x,ty:e.y},a.currentTarget.setPointerCapture(a.pointerId))},[e.x,e.y]),o=t.useCallback(e=>{s.current&&a(a=>({...a,x:r.current.tx+(e.clientX-r.current.x),y:r.current.ty+(e.clientY-r.current.y)}))},[]),i=t.useCallback(e=>{if(s.current){s.current=!1;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}},[]),l=t.useCallback((e,t,s)=>{a(a=>{const r=Math.min(2.5,Math.max(.3,a.scale+e));if(r===a.scale)return a;if(void 0===t||void 0===s)return{...a,scale:r};const n=r/a.scale;return{scale:r,x:t-(t-a.x)*n,y:s-(s-a.y)*n}})},[]),d=t.useCallback(()=>l(.15),[l]),c=t.useCallback(()=>l(-.15),[l]),u=t.useCallback(()=>a({x:0,y:0,scale:1}),[]),m=t.useCallback((e,t,s,r)=>{const n=Math.min((s-64)/e,(r-64)/t,1.5),o=Math.max(.3,n);a({scale:o,x:(s-e*o)/2,y:(r-t*o)/2})},[]),p=t.useCallback(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const a=e.currentTarget.getBoundingClientRect(),t=e.clientX-a.left,s=e.clientY-a.top;l(e.deltaY>0?-.1:.1,t,s)},[l]);return t.useEffect(()=>{const e=()=>s.current=!1;return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]),{transform:e,setTransform:a,zoomIn:d,zoomOut:c,reset:u,fitTo:m,onBackgroundPointerDown:n,onPointerMove:o,onPointerUp:i,onWheel:p}}(),f=ae.useRef(null),g=ae.useRef(null),v=ae.useRef(null),[b,j]=ae.useState(null),[w,N]=ae.useState(null);ae.useEffect(()=>{n?.(p.selectedNode)},[p.selectedNode,n]),function({api:e,layout:a,containerRef:s,onStartEditing:r,readOnly:n,extraShortcuts:o}){t.useEffect(()=>{const t=t=>{const i=s.current;if(!i)return;if(!i.contains(document.activeElement))return;const l=t.target;if(l?.isContentEditable)return;if(l&&("INPUT"===l.tagName||"TEXTAREA"===l.tagName))return;const d={layout:a,selectedId:e.selectedId,setSelectedId:e.setSelectedId},c=e.selectedId;for(const a of o??[])if(a.key.toLowerCase()===t.key.toLowerCase()&&!!a.ctrl===(t.ctrlKey||t.metaKey)&&!!a.shift===t.shiftKey&&!!a.alt===t.altKey)return t.preventDefault(),void a.handler({selectedId:e.selectedId,root:e.root,setRoot:e.setRoot,select:e.setSelectedId});if((t.ctrlKey||t.metaKey)&&"z"===t.key.toLowerCase())return t.preventDefault(),void(t.shiftKey?e.redo():e.undo());if("ArrowUp"===t.key)return t.preventDefault(),void tp("up",d);if("ArrowDown"===t.key)return t.preventDefault(),void tp("down",d);if("ArrowLeft"===t.key)return t.preventDefault(),void tp("left",d);if("ArrowRight"===t.key)return t.preventDefault(),void tp("right",d);if(c){if(" "===t.key)return t.preventDefault(),void e.toggleNode(c);if("F2"===t.key){if(n)return;return t.preventDefault(),void r(c)}if(!n){if("Enter"===t.key&&!t.shiftKey)return t.preventDefault(),c===e.root.id?e.addChild(c,""):e.addSibling(c,""),void setTimeout(()=>{e.selectedId&&r(e.selectedId)},0);if("Insert"===t.key||"Tab"===t.key)return t.preventDefault(),e.addChild(c,""),void setTimeout(()=>{e.selectedId&&r(e.selectedId)},0);if("Delete"===t.key||"Backspace"===t.key){if(c===e.root.id)return;return t.preventDefault(),void e.removeNode(c)}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,a,s,r,n,o])}({api:p,layout:h,containerRef:f,onStartEditing:e=>{o||j(e)},readOnly:o,extraShortcuts:l});const _=ae.useRef(!1);ae.useEffect(()=>{if(_.current)return;const e=g.current;if(!e)return;const{clientWidth:a,clientHeight:t}=e;a>0&&t>0&&h.width>0&&(x.fitTo(h.width,h.height,a,t),_.current=!0)},[h.width,h.height,x]);const C=p.selectedId,k=p.selectedNode,S=C===p.root.id,T=ae.useRef(null),P=e=>a=>{if(o)return;const t=T.current;if(!t||t===e)return;const s=zm(p.root,t);s&&zm(s.node,e)||(a.preventDefault(),a.dataTransfer.dropEffect="move",N(e))},E=()=>N(null),D=e=>a=>{a.preventDefault();const t=T.current;N(null),T.current=null,t&&t!==e&&p.moveNode(t,e)};return a.jsx(yr,{children:a.jsxs("div",{ref:f,tabIndex:0,role:"tree","aria-label":m("mind_map_aria_label"),className:Kt("relative flex flex-col rounded-lg border bg-muted/20 overflow-hidden focus:outline-none",c),style:{height:u},onClick:()=>f.current?.focus(),children:[!i&&a.jsx(op,{canAddChild:!!k&&!o,canAddSibling:!!k&&!o,canDelete:!!k&&!S&&!o,canUndo:p.canUndo&&!o,canRedo:p.canRedo&&!o,onAddChild:()=>{if(!C)return;const e=p.addChild(C,"");j(e)},onAddSibling:()=>{if(!C)return;if(S){const e=p.addChild(C,"");return void j(e)}const e=p.addSibling(C,"");j(e)},onDelete:()=>{C&&!S&&p.removeNode(C)},onExpandAll:p.expandAll,onCollapseAll:p.collapseAll,onFit:()=>{const e=g.current;e&&x.fitTo(h.width,h.height,e.clientWidth,e.clientHeight)},onZoomIn:x.zoomIn,onZoomOut:x.zoomOut,onUndo:p.undo,onRedo:p.redo,onExportJson:()=>{!function(e,a,t="application/json"){const s=new Blob([e],{type:t}),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=a,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}(ip(p.root),"mind-map.json")},onExportImage:async()=>{if(v.current)try{await async function(e,a="mind-map.png"){const t=e.cloneNode(!0),s=(new XMLSerializer).serializeToString(t),r=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(s)))}`,n=new Image;await new Promise((e,a)=>{n.onload=()=>e(),n.onerror=()=>a(new Error("Failed to load SVG snapshot")),n.src=r});const o=e.clientWidth||Number(e.getAttribute("width"))||1200,i=e.clientHeight||Number(e.getAttribute("height"))||800,l=document.createElement("canvas");l.width=2*o,l.height=2*i;const d=l.getContext("2d");if(!d)throw new Error("Canvas 2D context unavailable");d.fillStyle="#ffffff",d.fillRect(0,0,l.width,l.height),d.drawImage(n,0,0,l.width,l.height);const c=await new Promise(e=>l.toBlob(e,"image/png"));if(!c)throw new Error("Failed to create PNG blob");const u=URL.createObjectURL(c),m=document.createElement("a");m.href=u,m.download=a,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}(v.current,"mind-map.png")}catch(e){}}}),a.jsx("div",{ref:g,className:"relative flex-1 overflow-hidden cursor-grab active:cursor-grabbing",onPointerDown:e=>{e.target===e.currentTarget&&(x.onBackgroundPointerDown(e),p.setSelectedId(null))},onPointerMove:x.onPointerMove,onPointerUp:x.onPointerUp,onWheel:x.onWheel,children:a.jsxs("div",{className:"absolute origin-top-left",style:{transform:`translate(${x.transform.x}px, ${x.transform.y}px) scale(${x.transform.scale})`,width:h.width,height:h.height},children:[a.jsx("svg",{ref:v,width:h.width,height:h.height,className:"absolute inset-0 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:h.nodes.map(e=>e.visibleChildren.map(t=>a.jsx(rp,{parent:e,child:t},`${e.node.id}-${t.node.id}`)))}),h.nodes.map(e=>{return a.jsx(sp,{layout:e,selected:C===e.node.id,editing:b===e.node.id,readOnly:o,onSelect:()=>p.setSelectedId(e.node.id),onStartEditing:()=>j(e.node.id),onFinishEditing:a=>{null!==a&&p.renameNode(e.node.id,a),j(null)},onToggle:()=>p.toggleNode(e.node.id),onDragStart:(t=e.node.id,e=>{o||t===p.root.id||(T.current=t,e.dataTransfer.setData("text/plain",t),e.dataTransfer.effectAllowed="move")}),onDragOver:P(e.node.id),onDragLeave:E,onDrop:D(e.node.id),isDropTarget:w===e.node.id,renderNodeContent:d},e.node.id);var t})]})})]})})},exports.ModalStateProvider=function({children:e}){const[s,r]=t.useState(new Set),[n,o]=t.useState(!1),i=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.add(e),t})},[]),l=t.useCallback(e=>{r(a=>{const t=new Set(a);return t.delete(e),t})},[]),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 a.jsx(Mp.Provider,{value:u,children:e})},exports.ModuleAccessGuard=el,exports.ModuleGrid=Wi,exports.ModuleOfferContent=function({title:e,description:t,image:s,icon:r,ctaLabel:n,onCtaClick:o,children:i}){const{t:l}=y.useTranslation(),c=n??l("want_to_know_more");return a.jsxs("div",{className:"flex flex-col items-center text-center gap-6 py-8 px-4",children:[!i&&(s||r)&&a.jsx("div",{className:"flex items-center justify-center",children:s?a.jsx("img",{src:s,alt:e,className:"max-h-48 w-auto object-contain rounded-lg"}):r?a.jsx("div",{className:"w-24 h-24 rounded-2xl bg-primary/10 flex items-center justify-center",children:a.jsx(r,{className:"h-12 w-12 text-primary"})}):null}),a.jsxs("div",{className:"space-y-3 max-w-lg",children:[a.jsx("h3",{className:"text-xl font-semibold text-foreground",children:e}),a.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t})]}),i?a.jsx("div",{className:"w-full",children:i}):o?a.jsxs(Xt,{onClick:o,size:"lg",className:"gap-2",children:[a.jsx(d.Sparkles,{className:"h-4 w-4"}),c]}):null]})},exports.ModuleProvider=vi,exports.ModulesContent=Hi,exports.ModulesDialog=Xi,exports.ModulesFooterCards=Vi,exports.MultiSelect=Ur,exports.MultiselectPermissions=function({items:s,categories:r,value:n,onChange:o,readonly:i=!1,isLoading:l=!1,title:c=e.t("permissions"),addButtonLabel:u=e.t("allow"),chipsTitle:m=e.t("allowed_items"),chipsPlaceholder:p=e.t("no_item_selected"),searchPlaceholder:h=e.t("search_placeholder"),selectPlaceholder:x=e.t("select_items_to_add"),itemInfoTemplate:f=e=>`${e} ${1===e?"item":"itens"}`,disclaimer:g,disclaimerLink:v,onDisclaimerClick:b,className:j}){const[w,N]=t.useState(r[0]?.id??""),[_,C]=t.useState(""),[k,S]=t.useState([]),[T,P]=t.useState(!1),E=t.useMemo(()=>cu(n[w]),[n,w]),D=t.useMemo(()=>function(e){const{t:a}=y.useTranslation(),t=new Set;if(!e)return t;for(const s of e)s.inheritedIds?.forEach(e=>t.add(e));return t}(n[w]),[n,w]),A=t.useMemo(()=>s.filter(e=>E.has(e.id)),[s,E]),I=t.useMemo(()=>{const e=du(_);return s.filter(a=>!E.has(a.id)&&!(e&&!du(a.name).includes(e)))},[s,E,_]),M=t.useMemo(()=>{const e={};for(const a of r)e[a.id]=cu(n[a.id]).size;return e},[r,n]),F=t.useCallback(e=>{N(e),S([]),C("")},[]),R=t.useCallback(e=>{S(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},[]),L=t.useCallback(()=>{if(0===k.length)return;const e=[...n[w]??[]];for(const a of k){const t=s.find(e=>e.id===a),r=t?.group??"default",n=e.find(e=>e.context===r);n?n.allowedIds.includes(a)||(n.allowedIds=[...n.allowedIds,a]):e.push({context:r,allowedIds:[a],inheritedIds:[]})}o({...n,[w]:e}),S([]),C(""),P(!1)},[k,n,w,s,o]),z=t.useCallback(e=>{if(D.has(e))return;const a=(n[w]??[]).map(a=>({...a,allowedIds:a.allowedIds.filter(a=>a!==e)}));o({...n,[w]:a})},[n,w,D,o]);return l?a.jsxs("div",{className:Kt("rounded-md border bg-muted/30 p-4 animate-pulse space-y-3",j),children:[a.jsx("div",{className:"h-4 w-32 bg-muted rounded"}),a.jsx("div",{className:"h-9 w-full bg-muted rounded"}),a.jsx("div",{className:"h-20 w-full bg-muted rounded"})]}):a.jsx("div",{className:Kt("rounded-md border bg-muted/30",j),children:a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c}),a.jsxs(Vs,{value:w,onValueChange:F,children:[a.jsx($s,{className:"h-9 text-sm",children:a.jsx(qs,{})}),a.jsx(Gs,{children:r.map(e=>a.jsx(Ys,{value:e.id,children:a.jsxs("span",{className:"flex items-center gap-2",children:[e.icon,e.name,M[e.id]>0&&a.jsx(er,{variant:"secondary",className:"ml-1 text-xs px-1.5 py-0",children:M[e.id]})]})},e.id))})]})]}),!i&&a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Cr,{open:T,onOpenChange:P,children:[a.jsx(kr,{asChild:!0,children:a.jsxs(Xt,{variant:"outline",role:"combobox",className:"flex-1 justify-between h-9 text-sm font-normal text-muted-foreground",children:[k.length>0?`${k.length} selecionado${k.length>1?"s":""}`:x,a.jsx(d.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsxs(Sr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:[a.jsx("div",{className:"p-2 border-b",children:a.jsxs("div",{className:"relative",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-8 text-sm",placeholder:h,value:_,onChange:e=>C(e.target.value)})]})}),a.jsx(Io,{className:"max-h-[220px]",children:0===I.length?a.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nenhum item encontrado"}):a.jsx("div",{className:"p-1",children:I.map(e=>{const t=k.includes(e.id);return a.jsxs("div",{className:Kt("flex items-center gap-3 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent",t&&"bg-accent/50"),onClick:()=>R(e.id),children:[a.jsx("div",{className:Kt("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",t&&"bg-primary text-primary-foreground"),children:t&&a.jsx(d.Check,{className:"h-3 w-3"})}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"truncate",children:e.name}),null!=e.count&&a.jsx("span",{className:"text-xs text-muted-foreground",children:f(e.count)})]})]},e.id)})})})]})]}),a.jsxs(Xt,{size:"sm",className:"h-9 gap-1",disabled:0===k.length,onClick:L,children:[a.jsx(d.Plus,{className:"h-4 w-4"}),u]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:m}),a.jsx("div",{className:Kt("rounded-md border bg-background p-3 min-h-[60px]",i&&"bg-muted/50"),children:0===A.length?a.jsx("span",{className:"text-sm text-muted-foreground",children:p}):a.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(e=>{const t=D.has(e.id);return a.jsxs(er,{variant:t?"secondary":"default",className:"gap-1 pl-2 pr-1 py-1 text-xs",children:[e.name,!i&&!t&&a.jsx("button",{type:"button",className:"ml-0.5 rounded-full hover:bg-primary-foreground/20 p-0.5",onClick:()=>z(e.id),children:a.jsx(d.X,{className:"h-3 w-3"})})]},e.id)})})}),i&&g&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.jsx("span",{dangerouslySetInnerHTML:{__html:g}})," ",v&&b&&a.jsx("button",{type:"button",className:"text-primary underline hover:no-underline",onClick:b,children:v})]})]})]})})},exports.Muted=ad,exports.NavigationMenu=nd,exports.NavigationMenuContent=cd,exports.NavigationMenuIndicator=pd,exports.NavigationMenuItem=id,exports.NavigationMenuLink=ud,exports.NavigationMenuList=od,exports.NavigationMenuTrigger=dd,exports.NavigationMenuViewport=md,exports.NavigationProvider=Np,exports.NumericPanel=om,exports.OnboardingDialog=Bc,exports.OnlineEditorDialog=function({open:e,onOpenChange:s,identifier:r,fileName:n,mode:o="edit",type:i="document",onClose:l,className:c}){const[u,m]=t.useState(!0),p=function(e,a="edit",t="document"){return`https://docs.google.com/${t}/d/${e}/${a}?usp=drivesdk?embedded=true&rm=demo`}(r,o,i);t.useEffect(()=>{if(e){m(!0);const e=setTimeout(()=>m(!1),300);return()=>clearTimeout(e)}},[e]);const h=t.useCallback(()=>{l?.(),s(!1)},[l,s]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&h()};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,h]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Kt("max-w-[95vw] max-h-[95vh] w-[90vw] p-6 gap-0 [&>button.absolute]:hidden",c),children:[a.jsxs("div",{className:"flex items-center justify-between mb-6 min-h-[30px]",children:[u?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-80px)]",children:n}),a.jsx("div",{className:"flex items-center ml-4 z-20",children:a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})})]}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[160px] w-full min-w-[77vw] min-h-[80vh]",children:u?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{src:p,className:"border-none w-full h-full z-[1] relative",title:n})]})})]})})},exports.P=Xl,exports.PRIORITIES=Lh,exports.PROD_PROJECT_ID=Pe,exports.PROGRESS_ALLOWED_STATUSES=Uh,exports.PageBreadcrumb=function({items:e,maxItems:t=3,className:s}){const r=e.length>t?[e[0],...e.slice(-(t-1))]:e,n=e.length>t;return a.jsx(pl,{className:s,children:a.jsx(hl,{children:r.map((e,t)=>{const s=0===t,r=n&&1===t;return a.jsxs(xl,{children:[!s&&a.jsx(vl,{}),r&&a.jsxs(a.Fragment,{children:[a.jsx(bl,{}),a.jsx(vl,{})]}),e.isCurrentPage?a.jsx(gl,{children:e.label}):a.jsx(fl,{asChild:!0,children:a.jsx(N.Link,{to:e.href||"/",children:e.label})})]},e.label)})})})},exports.PageMetadataProvider=ni,exports.Pagination=hd,exports.PaginationContent=xd,exports.PaginationEllipsis=yd,exports.PaginationItem=fd,exports.PaginationLink=gd,exports.PaginationNext=bd,exports.PaginationPrevious=vd,exports.PanelError=am,exports.PanelHeader=em,exports.PanelLoader=tm,exports.PanelNoData=sm,exports.PanelUnavailable=rm,exports.ParetoPanel=xm,exports.PerformancePanel=gm,exports.PiePanel=hm,exports.PlaceCard=Vp,exports.PlacesList=function({places:e,isLoading:t,manageAccessConfig:s}){return t?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsxs("div",{className:"text-center space-y-2",children:[a.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando dados..."})]})}):e&&0!==e.length?a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>a.jsx(Vp,{place:e,manageAccessConfig:s},e.id))]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[a.jsx(d.Building2,{className:"h-12 w-12 text-muted-foreground/50"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})},exports.Popover=Cr,exports.PopoverContent=Sr,exports.PopoverTrigger=kr,exports.Progress=jd,exports.ProtectedRoute=({children:s})=>{const{isAuthenticated:r,isLoading:n}=An();if(t.useEffect(()=>{if(n)return;if(r)return;if(an.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),a=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,t=new URLSearchParams(a);if(e.has("access_token")||t.has("access_token"))return;const s=ze(),o=window.location.pathname+window.location.search+window.location.hash;["/","/login","/callback"].includes(window.location.pathname)||localStorage.setItem("auth_return_url",o);(async()=>{s?await Sn.loginDev():Sn.loginProd()})()},[r,n]),n&&!r)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Carregando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!r){return new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token")?a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Processando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})}):a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:a.jsxs(ts,{className:"w-full max-w-md",children:[a.jsx(ss,{className:"text-center",children:a.jsx(rs,{className:"text-xl font-semibold",children:"Iniciando..."})}),a.jsxs(os,{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:ze()?e.t("auto_login"):e.t("redirecting_auth")})]})]})})}return a.jsx(a.Fragment,{children:s})},exports.QUALIEX_CONFIG=Ve,exports.QUERY_KEYS={crud:e=>[e],list:(e,a)=>[e,"list",a],detail:(e,a)=>[e,"detail",a]},exports.QualiexEnrichmentService=jn,exports.QualiexErrorInterceptor=hn,exports.QualiexUserField=Oo,exports.RadioGroup=wd,exports.RadioGroupItem=Nd,exports.ReadOnlyTextField=xx,exports.ReportRequestList=function({requests:e,isLoading:s=!1,onGetReportUrl:r,formatDate:n=hu,labels:o,className:i}){const{t:l}=y.useTranslation(),c={...mu,...o},[u,m]=t.useState(""),[p,h]=t.useState(!1),[x,f]=t.useState(""),[g,v]=t.useState(""),[b,j]=t.useState(null),w=t.useMemo(()=>{if(!u)return e;const a=pu(u);return e.filter(e=>pu(e.reportName).includes(a))},[e,u]),N=t.useCallback(async e=>{if(!b){j(e.id);try{const a=await r(e.id);a&&(f(a),v(e.reportName),h(!0))}finally{j(null)}}},[r,b]);return s?a.jsx("div",{className:Kt("space-y-3",i),children:Array.from({length:5}).map((e,t)=>a.jsx(Rr,{className:"h-12 w-full"},t))}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:Kt("space-y-3",i),children:[a.jsxs("div",{className:"relative max-w-sm",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:c.searchPlaceholder,value:u,onChange:e=>m(e.target.value)})]}),a.jsx(Io,{className:"rounded-md border",children:a.jsxs(Rn,{children:[a.jsx(Ln,{children:a.jsxs(On,{children:[a.jsx(Vn,{className:"min-w-[140px]",children:c.report}),a.jsx(Vn,{className:"min-w-[150px]",children:c.status}),a.jsx(Vn,{className:"min-w-[160px]",children:c.requestDate}),a.jsx(Vn,{className:"min-w-[160px]",children:c.lastUpdate}),a.jsx(Vn,{className:"min-w-[160px]",children:c.expirationDate}),a.jsx(Vn,{className:"min-w-[140px]"})]})}),a.jsx(zn,{children:0===w.length?a.jsx(On,{children:a.jsx(Bn,{colSpan:6,className:"text-center text-muted-foreground py-8",children:c.noResults})}):w.map(e=>{const t=function(e){const{t:a}=y.useTranslation();return new Date>new Date(e.expirationDate)&&e.statusId===exports.ReportRequestStatus.Completed?exports.ReportRequestStatus.Expired:e.statusId}(e),s=function(e,t){const{t:s}=y.useTranslation();switch(e){case exports.ReportRequestStatus.WaitingProcessing:return{label:t.statusWaiting,icon:a.jsx(d.Hourglass,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50"};case exports.ReportRequestStatus.Processing:return{label:t.statusProcessing,icon:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 animate-spin"}),variant:"outline",className:"text-blue-600 border-blue-300 bg-blue-50"};case exports.ReportRequestStatus.Completed:return{label:t.statusCompleted,icon:a.jsx(d.CheckCircle2,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50"};case exports.ReportRequestStatus.Error:return{label:t.statusError,icon:a.jsx(d.AlertCircle,{className:"h-3.5 w-3.5"}),variant:"danger"};case exports.ReportRequestStatus.Expired:return{label:t.statusExpired,icon:a.jsx(d.TriangleAlert,{className:"h-3.5 w-3.5"}),variant:"outline",className:"text-orange-600 border-orange-300 bg-orange-50"};default:return{label:"—",icon:null,variant:"secondary"}}}(t,c),r=t===exports.ReportRequestStatus.Completed,o=t===exports.ReportRequestStatus.Expired;return a.jsxs(On,{children:[a.jsx(Bn,{className:"font-medium",children:e.reportName}),a.jsx(Bn,{children:a.jsxs(er,{variant:s.variant,className:Kt("gap-1",s.className),children:[s.icon,s.label]})}),a.jsx(Bn,{className:"text-sm",children:n(new Date(e.requestDate))}),a.jsx(Bn,{className:"text-sm",children:n(new Date(e.lastUpdate))}),a.jsx(Bn,{className:Kt("text-sm",o&&"text-destructive"),children:n(new Date(e.expirationDate))}),a.jsx(Bn,{children:a.jsxs(Xt,{variant:"ghost",size:"sm",className:"gap-1.5",disabled:!r||b===e.id,onClick:()=>N(e),children:[b===e.id?a.jsx(d.Loader2,{className:"h-4 w-4 animate-spin"}):a.jsx(d.Eye,{className:"h-4 w-4"}),c.viewReport]})})]},e.id)})})]})})]}),a.jsx(ou,{open:p,onOpenChange:h,url:x,title:g})]})},exports.ResizableHandle=({withHandle:e,className:t,...s})=>a.jsx(Ce.PanelResizeHandle,{className:Kt("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...s,children:e&&a.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:a.jsx(d.GripVertical,{className:"h-2.5 w-2.5"})})}),exports.ResizablePanel=_d,exports.ResizablePanelGroup=({className:e,...t})=>a.jsx(Ce.PanelGroup,{className:Kt("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),exports.RichTextEditor=({value:s,onChange:r,disabled:n,placeholder:o=e.t("write_content_here"),minHeight:i="300px",showModeToggle:l=!0,showVariableHint:c=!0,className:u})=>{const{t:m}=y.useTranslation(),[p,h]=t.useState("visual"),x=q.useEditor({extensions:[$.configure({heading:{levels:[1,2,3]}}),W,H.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),G.TextStyle,K.Color,Y.configure({multicolor:!0})],content:s||"",editable:!n,onUpdate:({editor:e})=>{r(e.getHTML())}});ae.useEffect(()=>{x&&s!==x.getHTML()&&x.commands.setContent(s||"")},[s,x]);const f=t.useCallback(()=>{if(!x)return;const e=x.getAttributes("link").href,a=window.prompt("URL",e);null!==a&&(""!==a?x.chain().focus().extendMarkRange("link").setLink({href:a}).run():x.chain().focus().extendMarkRange("link").unsetLink().run())},[x]);return x?a.jsxs("div",{className:Kt("space-y-2",u),children:[l&&a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(Xt,{type:"button",size:"sm",variant:"visual"===p?"default":"outline",onClick:()=>h("visual"),disabled:n,children:[a.jsx(d.Edit3,{className:"h-3.5 w-3.5 mr-1"}),"Editor Visual"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"code"===p?"default":"outline",onClick:()=>h("code"),disabled:n,children:[a.jsx(d.Code,{className:"h-3.5 w-3.5 mr-1"}),"Código HTML"]}),a.jsxs(Xt,{type:"button",size:"sm",variant:"preview"===p?"default":"outline",onClick:()=>h("preview"),disabled:n,children:[a.jsx(d.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]}),c&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ",a.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"{{variavel}}"})]})]}),"visual"===p&&a.jsxs("div",{className:"border rounded-md overflow-hidden bg-background cursor-text",onClick:e=>{e.target.closest(".editor-toolbar")||x?.commands.focus()},children:[a.jsxs("div",{className:"editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[a.jsx(Lc,{onClick:()=>x.chain().focus().toggleHeading({level:1}).run(),isActive:x.isActive("heading",{level:1}),disabled:n,title:e.t("heading_1"),children:a.jsx(d.Heading1,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),isActive:x.isActive("heading",{level:2}),disabled:n,title:e.t("heading_2"),children:a.jsx(d.Heading2,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleHeading({level:3}).run(),isActive:x.isActive("heading",{level:3}),disabled:n,title:e.t("heading_3"),children:a.jsx(d.Heading3,{className:"h-4 w-4"})}),a.jsx(zc,{}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleBold().run(),isActive:x.isActive("bold"),disabled:n,title:e.t("bold"),children:a.jsx(d.Bold,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleItalic().run(),isActive:x.isActive("italic"),disabled:n,title:e.t("italic"),children:a.jsx(d.Italic,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleUnderline().run(),isActive:x.isActive("underline"),disabled:n,title:"Sublinhado",children:a.jsx(d.Underline,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleStrike().run(),isActive:x.isActive("strike"),disabled:n,title:"Riscado",children:a.jsx(d.Strikethrough,{className:"h-4 w-4"})}),a.jsx(zc,{}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleBulletList().run(),isActive:x.isActive("bulletList"),disabled:n,title:"Lista",children:a.jsx(d.List,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleOrderedList().run(),isActive:x.isActive("orderedList"),disabled:n,title:m("ordered_list"),children:a.jsx(d.ListOrdered,{className:"h-4 w-4"})}),a.jsx(zc,{}),a.jsx(Lc,{onClick:()=>x.chain().focus().toggleHighlight().run(),isActive:x.isActive("highlight"),disabled:n,title:"Destacar",children:a.jsx(d.Highlighter,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:f,isActive:x.isActive("link"),disabled:n,title:"Link",children:a.jsx(d.Link,{className:"h-4 w-4"})}),a.jsx(zc,{}),a.jsx(Lc,{onClick:()=>x.chain().focus().unsetAllMarks().clearNodes().run(),disabled:n,title:m("clear_formatting"),children:a.jsx(d.RemoveFormatting,{className:"h-4 w-4"})}),a.jsx(zc,{}),a.jsx(Lc,{onClick:()=>x.chain().focus().undo().run(),disabled:n||!x.can().undo(),title:"Desfazer",children:a.jsx(d.Undo,{className:"h-4 w-4"})}),a.jsx(Lc,{onClick:()=>x.chain().focus().redo().run(),disabled:n||!x.can().redo(),title:"Refazer",children:a.jsx(d.Redo,{className:"h-4 w-4"})})]}),a.jsx(q.EditorContent,{editor:x,className:Kt("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:i}})]}),"code"===p&&a.jsx("textarea",{value:s||"",onChange:e=>r(e.target.value),disabled:n,className:"w-full p-3 border rounded-md font-mono text-sm resize-none focus:ring-2 focus:ring-primary bg-background",style:{height:i},placeholder:"Cole ou edite o HTML aqui..."}),"preview"===p&&a.jsx("div",{className:"border rounded-lg p-4 bg-muted overflow-auto",style:{height:i},children:a.jsx("div",{className:"bg-background shadow-sm rounded border p-4",children:a.jsx("div",{dangerouslySetInnerHTML:{__html:s||`<p class="text-muted-foreground">${o}</p>`}})})})]}):null},exports.SEARCH_CONFIG=Re,exports.STATUS_COLORS=Dh,exports.STATUS_LABELS=Fh,exports.STATUS_MAP=Ih,exports.STATUS_TEXT_COLORS=Ah,exports.SUPPORTED_LOCALES=Pt,exports.ScrollArea=Io,exports.ScrollBar=Mo,exports.Select=Vs,exports.SelectApproverDialog=Ox,exports.SelectContent=Gs,exports.SelectGroup=Bs,exports.SelectItem=Ys,exports.SelectLabel=Ks,exports.SelectScrollDownButton=Hs,exports.SelectScrollUpButton=Ws,exports.SelectSearch=Ur,exports.SelectSeparator=Qs,exports.SelectTrigger=$s,exports.SelectValue=qs,exports.Separator=ls,exports.Sheet=Cd,exports.SheetBody=Id,exports.SheetClose=Sd,exports.SheetContent=Dd,exports.SheetDescription=Rd,exports.SheetFooter=Md,exports.SheetHeader=Ad,exports.SheetOverlay=Pd,exports.SheetPortal=Td,exports.SheetTitle=Fd,exports.SheetTrigger=kd,exports.Sidebar=Vd,exports.SidebarActionTrigger=Ep,exports.SidebarContent=Yd,exports.SidebarFooter=Gd,exports.SidebarGroup=Qd,exports.SidebarGroupAction=Jd,exports.SidebarGroupContent=Zd,exports.SidebarGroupLabel=Xd,exports.SidebarHeader=function({open:e,appName:s}){const[r,n]=t.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx(Hd,{className:"p-0 gap-0",children:e?a.jsxs("div",{className:"flex items-center gap-2 pl-2 min-h-10",children:[a.jsx("button",{className:"flex-shrink-0 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.logo,alt:"Logo",className:"h-8 max-w-[140px] object-contain"})}),s&&a.jsx("button",{className:"flex-1 min-w-0 text-sm font-medium text-right cursor-pointer text-primary-foreground hover:text-primary-foreground/80 transition-colors leading-tight py-1",onClick:()=>n(!0),children:a.jsx("span",{className:"line-clamp-2",children:(e=>{const t=e.split(" ");if(t.length<=1)return a.jsxs("span",{className:"whitespace-nowrap",children:[e," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]});const s=t[t.length-1],r=t.slice(0,-1).join(" ");return a.jsxs(a.Fragment,{children:[r," ",a.jsxs("span",{className:"whitespace-nowrap",children:[s," ",a.jsx(d.ChevronDown,{size:12,className:"inline-block align-middle ml-1 opacity-60 text-primary-foreground"})]})]})})(s)})})]}):a.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:a.jsx("button",{className:"flex items-center justify-center h-10 w-8 cursor-pointer",onClick:()=>n(!0),children:a.jsx("img",{src:We.smallLogo,alt:"Logo",className:"h-6 w-auto object-contain"})})})}),a.jsx(Xi,{open:r,onOpenChange:n})]})},exports.SidebarInput=Wd,exports.SidebarInset=$d,exports.SidebarLogo=Sp,exports.SidebarMenu=ec,exports.SidebarMenuAction=rc,exports.SidebarMenuBadge=nc,exports.SidebarMenuButton=sc,exports.SidebarMenuItem=ac,exports.SidebarMenuSkeleton=oc,exports.SidebarMenuSub=ic,exports.SidebarMenuSubButton=dc,exports.SidebarMenuSubItem=lc,exports.SidebarProvider=Od,exports.SidebarRail=qd,exports.SidebarSeparator=Kd,exports.SidebarSkeleton=function(){return a.jsx("div",{className:"w-64 border-r bg-muted/10",children:a.jsxs("div",{className:"p-4",children:[a.jsx(Rr,{className:"h-8 w-32 mb-6"}),a.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>a.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[a.jsx(Rr,{className:"h-4 w-4"}),a.jsx(Rr,{className:"h-4 w-20"})]},t))})]})})},exports.SidebarTrigger=Bd,exports.SignConfigForm=function({onSaved:e}){const{config:s,isLoading:r,saveConfig:n}=fh(),{t:o}=y.useTranslation(),[i,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?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(d.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a.jsxs("div",{className:"space-y-4",children:[s?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600",children:[a.jsx(d.CheckCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_configured",o("sign_configured_unit"))})]}):a.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600",children:[a.jsx(d.AlertCircle,{className:"h-4 w-4"}),a.jsx("span",{children:o("sign_not_configured",o("sign_not_configured_unit"))})]}),a.jsxs(ts,{children:[a.jsx(ss,{children:a.jsx(rs,{className:"text-base",children:o("sign_digital_config")})}),a.jsx(os,{children:a.jsxs("form",{onSubmit:async a=>{if(a.preventDefault(),i.trim()){h(!0);try{await n(i.trim(),u),l.toast.success(o("sign_config_saved",o("sign_config_saved_success"))),e?.()}catch(t){l.toast.error(o("sign_config_save_error",o("sign_config_save_err")))}finally{h(!1)}}else l.toast.error(o("sign_api_key_required",o("sign_api_key_info")))},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"sign-api-key",children:"API Key"}),a.jsx(Zt,{id:"sign-api-key",type:"password",placeholder:o("sign_api_key_placeholder",o("sign_api_key_input")),value:i,onChange:e=>c(e.target.value)})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:o("sign_environment","Ambiente")}),a.jsxs(Vs,{value:u,onValueChange:e=>m(e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"sandbox",children:"Sandbox (Testes)"}),a.jsx(Ys,{value:"production",children:"Produção"})]})]})]}),a.jsxs(Xt,{type:"submit",disabled:p,children:[p&&a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),s?o("sign_update_config",o("sign_update_config_btn")):o("sign_save_config",o("sign_save_config_btn"))]})]})})]})]})},exports.SignWidget=_h,exports.SingleFileUpload=function({storedFile:e,customFileName:s,allowedExtensions:r,customExtensionErrorMessage:n,minSizeInBytes:o=1,maxSizeInBytes:i=314572800,showDownloadButton:l=!0,showViewButton:c=!0,showReplaceButton:u=!0,showCloseButton:m=!0,required:p=!1,touched:h=!1,disabled:x=!1,error:f,onFileSelect:g,onFileRemove:v,onFileReplace:b,onDownload:j,onView:w,className:N}){const{t:_}=y.useTranslation(),C=t.useRef(null),[k,S]=t.useState(null),[T,P]=t.useState(null),[E,D]=t.useState(!1),A=k||e,I=k?.name||e?.name||"",M=k?.size||e?.size;I&&dx(I);const F=s||I,R=l&&!k&&!!e,L=c&&!k&&!!e,z=!!T||!!f||p&&h&&!A,U=!!A,O=t.useCallback(e=>{if(ix.includes(e.type))return{type:"forbidden-type"};if(e.size<=o)return{type:"min-size"};if(e.size>=i)return{type:"max-size"};if(r?.length){const a=dx(e.name);if(!r.includes(a))return{type:"extension",message:n}}return null},[o,i,r,n]),V=t.useCallback(e=>{const a=e.target.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),S(null),void(C.current&&(C.current.value=""));P(null),S(a),g?.(a),C.current&&(C.current.value="")},[O,g]),B=t.useCallback(e=>{if(e.preventDefault(),e.stopPropagation(),x)return;const a=e.dataTransfer.files?.[0];if(!a)return;const t=O(a);if(t)return P(t),void S(null);P(null),S(a),g?.(a)},[x,O,g]),q=t.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),$=t.useCallback(()=>{b?.(),C.current?.click()},[b]),W=t.useCallback(()=>{S(null),P(null),v?.(),C.current&&(C.current.value="")},[v]),H=t.useCallback(async()=>{if(!E&&e&&j){D(!0);try{await j(e)}finally{D(!1)}}},[E,e,j]),G=t.useCallback(()=>{e&&w&&w(e)},[e,w]),K=t.useCallback(()=>{x||C.current?.click()},[x]),Y=(()=>{if(f)return f;if(!T)return p&&h&&!A?_("required_field"):null;switch(T.type){case"extension":return T.message||_("sign_file_not_allowed");case"forbidden-type":return _("sign_file_type_not_allowed");case"min-size":return`Tamanho mínimo: ${lx(o)}`;case"max-size":return`Tamanho máximo: ${lx(i)}`;default:return _("file_error")}})();return a.jsxs("div",{className:Kt("space-y-1",N),children:[a.jsx("div",{className:Kt("rounded-md border border-dashed transition-colors",U&&"border-solid border-border",!U&&"border-muted-foreground/30 hover:border-primary/50 cursor-pointer",z&&"border-destructive border-solid",x&&"opacity-50 pointer-events-none"),children:U?a.jsxs("div",{className:"flex items-center justify-between px-3 min-h-[36px]",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(d.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-xs truncate",children:F})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[null!=M&&a.jsx("span",{className:"text-xs text-muted-foreground",children:lx(M)}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[R&&j&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",disabled:E,onClick:H,children:a.jsx(d.Download,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Download"})]}),L&&w&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,children:a.jsx(d.Eye,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Visualizar"})]}),u&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:$,children:a.jsx(d.RefreshCw,{className:"h-3.5 w-3.5 text-primary"})})}),a.jsx(Nr,{children:"Substituir"})]}),m&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 bg-muted rounded",onClick:W,children:a.jsx(d.X,{className:"h-3 w-3 text-muted-foreground"})})}),a.jsx(Nr,{children:_("remove")})]})]})]})]}):a.jsxs("div",{className:"flex items-center justify-center gap-2 min-h-[36px] px-3",tabIndex:0,onClick:K,onKeyDown:e=>"Enter"===e.key&&K(),onDrop:B,onDragOver:q,children:[a.jsx(d.CloudUpload,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:["Arraste ou ",a.jsx("span",{className:"text-primary",children:"selecione um arquivo"})]})]})}),Y&&a.jsx("p",{className:"text-xs text-destructive",children:Y}),a.jsx("input",{ref:C,type:"file",className:"hidden",accept:r?.map(e=>`.${e}`).join(","),onChange:V,disabled:x})]})},exports.Skeleton=Rr,exports.Slider=cc,exports.Small=ed,exports.SonnerToaster=rr,exports.Spinner=tr,exports.SplitButton=qc,exports.Stack=Go,exports.StatusBadge=fu,exports.StepSelector=Kc,exports.Stepper=Kc,exports.StimulsoftViewer=function({reportApiUrl:e,parameters:s={},minHeight:r="80vh",...n}){const o=t.useMemo(()=>{const a=`${e}/api/reports/v1/Viewer/InitViewer`,t=new URLSearchParams(s).toString();return t?`${a}?${t}`:a},[e,s]);return a.jsx(ou,{...n,url:o,minHeight:r})},exports.Switch=zo,exports.TIMEZONES=Dt,exports.TabPageContent=function({children:e,className:t}){return a.jsx("div",{className:Kt("space-y-6",t),children:e})},exports.TabPageHeader=function({title:e,description:t,actions:s,className:r}){return a.jsxs("div",{className:Kt("space-y-4",r),children:[a.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&a.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),s&&a.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s})]}),a.jsx(ls,{})]})},exports.TabPageLayout=function({children:e,className:t}){return a.jsx("div",{className:Kt("flex flex-col h-full",t),children:a.jsx(Io,{className:"flex-1",children:a.jsx("div",{className:"space-y-6 p-6",children:e})})})},exports.Table=Rn,exports.TableBody=zn,exports.TableCaption=qn,exports.TableCell=Bn,exports.TableFooter=Un,exports.TableHead=Vn,exports.TableHeader=Ln,exports.TableResizeHandle=Yn,exports.TableRow=On,exports.TableRowActions=po,exports.TableSkeleton=$n,exports.Tabs=_i,exports.TabsContent=Si,exports.TabsList=Ci,exports.TabsTrigger=ki,exports.TeamSelector=function({users:e,value:s,onChange:r,disabled:n=!1,placeholder:o="Buscar membro da equipe...",confirmRemoval:i=!0,confirmTitle:l,confirmMessage:c="Tem certeza que deseja remover este membro da equipe?",emptyMessage:u,className:m}){const{t:p}=y.useTranslation(),h=l??p("leadership_remove_team"),x=u??p("leadership_no_members"),[f,g]=t.useState(""),[v,b]=t.useState(!1),[j,w]=t.useState(null),N=t.useMemo(()=>new Set(s),[s]),_=t.useMemo(()=>e.filter(e=>N.has(e.id)),[e,N]),C=t.useMemo(()=>e.filter(e=>!N.has(e.id)).map(e=>({value:e.id,label:e.name})),[e,N]),k=t.useCallback(e=>{e&&!N.has(e)&&(r([...s,e]),g(""))},[s,r,N]),S=t.useCallback(e=>{i?(w(e),b(!0)):r(s.filter(a=>a!==e))},[s,r,i]),T=t.useCallback(()=>{j&&r(s.filter(e=>e!==j)),b(!1),w(null)},[j,s,r]);return a.jsxs("div",{className:Kt("space-y-3",m),children:[a.jsx("div",{className:"flex items-start gap-3",children:a.jsx("div",{className:"flex-1",children:a.jsx(Ur,{options:C,value:f,onValueChange:e=>{const a="string"==typeof e?e:e?.[0]??"";g(a),a&&k(a)},placeholder:o,searchPlaceholder:"Buscar...",disabled:n})})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-muted-foreground",children:"Selecionados"}),a.jsx("span",{className:"text-xs bg-muted text-muted-foreground rounded-full px-2 py-0.5 font-medium",children:_.length})]}),_.length>0?a.jsx("div",{className:"space-y-2",children:_.map(e=>a.jsxs("div",{className:"flex items-center border border-border rounded-lg p-2 gap-3",children:[a.jsxs(cl,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(ul,{src:e.avatar,alt:e.name}),a.jsx(ml,{className:"text-xs",children:e.name?.substring(0,2).toUpperCase()})]}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("p",{className:"text-sm font-medium truncate",title:e.name,dangerouslySetInnerHTML:{__html:e.title||e.name}})}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 text-xs text-muted-foreground",children:[e.roleName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.Shield,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.roleName})]}),e.placeName&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(d.MapPin,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"truncate max-w-[120px]",children:e.placeName})]}),a.jsx("button",{type:"button",className:Kt("text-muted-foreground hover:text-destructive transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>!n&&S(e.id),title:p("remove"),children:a.jsx(d.X,{className:"h-4 w-4"})})]})]},e.id))}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[a.jsx(d.User,{className:"h-12 w-12 mb-2 opacity-30"}),a.jsx("p",{className:"text-sm",children:x})]}),a.jsx(ys,{open:v,onOpenChange:b,children:a.jsxs(ks,{className:"sm:max-w-[400px]",children:[a.jsx(Ss,{children:a.jsx(Es,{children:h})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:c}),a.jsxs(Ps,{children:[a.jsx(Xt,{variant:"ghost",onClick:()=>b(!1),children:"Cancelar"}),a.jsx(Xt,{variant:"destructive",onClick:T,children:"Remover"})]})]})})]})},exports.TermsOfUseDialog=function({term:s,open:r,onClose:n,onAgree:o,title:i=e.t("terms_updated"),seeLaterLabel:l=e.t("terms_see_later"),agreeLabel:c=e.t("terms_read_agree"),viewTermLabel:u=e.t("terms_view")}){const[m,p]=t.useState(!1),h=t.useCallback(()=>{o(s.id)},[o,s.id]);return a.jsxs(a.Fragment,{children:[a.jsx(ys,{open:r&&!m,onOpenChange:e=>!e&&n(),children:a.jsxs(ks,{className:"sm:max-w-md",children:[a.jsx(Ss,{children:a.jsxs(Es,{className:"flex items-center gap-2",children:[a.jsx(d.ShieldCheck,{className:"h-5 w-5 text-primary"}),i]})}),a.jsxs("div",{className:"space-y-4",children:[s.description&&a.jsx(Io,{className:"max-h-48",children:a.jsx("div",{className:"text-sm text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:s.description}})}),s.file&&a.jsxs(Xt,{variant:"link",className:"px-0 text-primary",onClick:()=>p(!0),children:[a.jsx(d.ExternalLink,{className:"mr-1 h-4 w-4"}),u]})]}),a.jsxs(Ps,{className:"gap-2 sm:gap-0",children:[a.jsx(Xt,{variant:"ghost",onClick:n,children:l}),a.jsx(Xt,{onClick:h,children:c})]})]})}),m&&a.jsx(iu,{term:s,open:m,onClose:()=>p(!1),viewOnly:!0})]})},exports.TermsOfUseViewer=iu,exports.TextPanel=im,exports.Textarea=Js,exports.Timepicker=Gc,exports.Toaster=rr,exports.Toggle=vo,exports.ToggleGroup=yo,exports.ToggleGroupItem=jo,exports.TokenManager=an,exports.TokenService=Hr,exports.Tooltip=jr,exports.TooltipContent=Nr,exports.TooltipProvider=yr,exports.TooltipTrigger=wr,exports.TreeSelect=Wr,exports.TreeTable=fp,exports.TruncatedCell=Kn,exports.UpdatesNotification=Jc,exports.UsersGroupsSelector=function({users:s,groups:r=[],value:n,onChange:o,disabled:i=!1,maxHeight:l=350,hideGroupFilter:c=!1,searchPlaceholder:u="Buscar usuário...",selectLabel:m="Selecionar",doneLabel:p="Concluir",allLabel:h="Todos",emptyLabel:x=e.t("leadership_no_user_selected"),selectedLabel:f="selecionado",selectedPluralLabel:g="selecionados",className:v}){const[b,y]=t.useState(!1),[j,w]=t.useState(""),[N,_]=t.useState(void 0),C=t.useMemo(()=>new Set(n),[n]),k=t.useMemo(()=>{let e=s;if(N&&(e=e.filter(e=>e.groupIds?.includes(N))),j){const a=lu(j);e=e.filter(e=>lu(e.name).includes(a)||lu(e.email??"").includes(a))}return e},[s,N,j]),S=t.useMemo(()=>b?k:s.filter(e=>C.has(e.id)),[b,k,s,C]),T=n.length,P=t.useMemo(()=>k.length>0&&k.every(e=>C.has(e.id)),[k,C]),E=t.useCallback(e=>{if(i)return;const a=C.has(e)?n.filter(a=>a!==e):[...n,e];o(a)},[n,C,o,i]),D=t.useCallback(e=>{if(i)return;const a=new Set(k.map(e=>e.id));if(e){const e=new Set([...n,...a]);o(Array.from(e))}else o(n.filter(e=>!a.has(e)))},[n,k,o,i]),A=t.useCallback(()=>{y(e=>!e),w(""),_(void 0)},[]);return a.jsxs("div",{className:Kt("rounded-md border bg-muted/30",v),children:[(!i||T>0)&&a.jsxs("div",{className:Kt("flex items-center justify-between px-4 py-2",!i&&"cursor-pointer hover:bg-muted/50"),onClick:i?void 0:A,children:[a.jsx("span",{className:"text-sm font-medium text-primary uppercase",children:!i&&(b?p:m)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:T>0&&`${T} ${1===T?f:g}`})]}),a.jsxs("div",{className:"px-4 pb-3",children:[b&&a.jsxs("div",{className:"flex gap-3 mb-3",children:[!c&&r.length>0&&a.jsxs(Vs,{value:N??"__all__",onValueChange:e=>_("__all__"===e?void 0:e),children:[a.jsx($s,{className:"w-[200px] h-9 text-sm",children:a.jsx(qs,{placeholder:e.t("approval_user_group")})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"__all__",children:e.t("team_all_groups")}),r.map(e=>a.jsx(Ys,{value:e.id,children:e.name},e.id))]})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx(d.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),a.jsx(Zt,{className:"pl-8 h-9 text-sm",placeholder:u,value:j,onChange:e=>w(e.target.value)})]})]}),!b&&0===T&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:[a.jsx(d.Users,{className:"h-4 w-4 mr-2"}),x]}),b&&k.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Xs,{checked:P,onCheckedChange:e=>D(!!e)}),a.jsx("span",{className:"text-sm",children:h})]}),S.length>0&&a.jsx(Io,{style:{maxHeight:l},className:"pr-2",children:a.jsx("div",{className:"space-y-0.5",children:S.map(e=>{return a.jsxs("div",{className:Kt("flex items-center gap-3 rounded-md bg-background px-3 py-2 text-sm",b&&!i&&"cursor-pointer hover:bg-accent/50"),onClick:b?()=>E(e.id):void 0,children:[b&&a.jsx(Xs,{checked:C.has(e.id),onCheckedChange:()=>E(e.id),onClick:e=>e.stopPropagation()}),a.jsxs(cl,{className:"h-8 w-8 shrink-0",children:[e.avatar&&a.jsx(ul,{src:e.avatar,alt:e.name}),a.jsx(ml,{className:"text-xs",children:(t=e.name,t.split(" ").slice(0,2).map(e=>e[0]?.toUpperCase()??"").join(""))})]}),a.jsxs("div",{className:"flex flex-col min-w-0",children:[a.jsx("span",{className:"font-normal truncate",children:e.name}),e.email&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]},e.id);var t})})}),b&&0===k.length&&a.jsx("div",{className:"flex items-center justify-center py-4 text-sm text-muted-foreground",children:"Nenhum usuário encontrado"})]})]})},exports.VideoEditor=function({value:s,onChange:r,onSubmit:n,onCancel:o,uploadFunction:i,deleteFunction:c,uploadOptions:u}){const{t:m}=y.useTranslation(),[p,h]=t.useState(s||{inputType:"url",controls:!0}),x=t.useRef(null),f=t.useRef(null),{upload:g,uploading:v}=lh({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["video/*"],maxSize:104857600}}),{upload:b,uploading:j}=lh({uploadFunction:i,deleteFunction:c,defaultOptions:{...u,allowedTypes:["image/*"],maxSize:5242880}}),w=t.useMemo(()=>hh(p.videoUrl||ph(p.embedCode)||""),[p.videoUrl,p.embedCode]),N=(e,a)=>{const t={...p,[e]:a};h(t),r(t)};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("input_type")}),a.jsxs(Vs,{value:p.inputType||"url",onValueChange:e=>N("inputType",e),children:[a.jsx($s,{children:a.jsx(qs,{})}),a.jsxs(Gs,{children:[a.jsx(Ys,{value:"url",children:"URL"}),a.jsx(Ys,{value:"upload",children:m("file_upload")}),a.jsx(Ys,{value:"embed",children:m("embed_code")})]})]})]}),"upload"===p.inputType&&i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Arquivo"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{ref:x,type:"file",accept:"video/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await g(a),t={...p,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:p.title||a.name.replace(/\.[^/.]+$/,"")};h(t),r(t)}catch(t){}finally{x.current&&(x.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>x.current?.click(),disabled:v,children:v?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),p.videoFile&&a.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:["Arquivo: ",p.videoFile," (",Math.round((p.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===p.inputType&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:m("embed_code")}),a.jsx(Js,{placeholder:m("paste_embed_code"),value:p.embedCode||"",onChange:e=>N("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Thumbnail"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Zt,{type:"url",placeholder:"URL da thumbnail",value:p.thumbnail||"",onChange:e=>N("thumbnail",e.target.value),className:"flex-1"}),a.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const a=e.target.files?.[0];if(a)try{const e=await b(a),t={...p,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};h(t),r(t)}catch(t){}finally{f.current&&(f.current.value="")}},className:"hidden"}),a.jsx(Xt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:j,children:j?a.jsxs(a.Fragment,{children:[a.jsx(d.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):a.jsxs(a.Fragment,{children:[a.jsx(d.Upload,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),p.thumbnailFile&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Thumbnail: ",p.thumbnailFile]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{htmlFor:"title",children:"Título"}),a.jsx(Zt,{id:"title",placeholder:m("video_title"),value:p.title||"",onChange:e=>N("title",e.target.value)})]}),a.jsxs("div",{className:"flex gap-6",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"autoplay",checked:p.autoplay||!1,onCheckedChange:e=>N("autoplay",!0===e)}),a.jsx(as,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xs,{id:"controls",checked:!1!==p.controls,onCheckedChange:e=>N("controls",!0===e)}),a.jsx(as,{htmlFor:"controls",className:"cursor-pointer",children:"Controles"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(as,{children:"Preview"}),a.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const t=p.videoUrl||ph(p.embedCode)||"";if(!t)return a.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum conteúdo para visualizar"});if("file"===w)return a.jsxs("video",{controls:!1!==p.controls,autoPlay:p.autoplay,poster:p.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[a.jsx("source",{src:t}),"Seu navegador não suporta este vídeo."]});const s="youtube"===w?ch(t,p.autoplay):mh(t,p.autoplay);return a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:p.title||e.t("video"),src:s,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[a.jsx(Xt,{variant:"outline",onClick:o,children:"Cancelar"}),a.jsx(Xt,{onClick:()=>{p.videoUrl||p.embedCode?n(p):l.toast.error("Erro",{description:m("no_video_selected")})},disabled:!(p.videoUrl||p.embedCode),children:"Salvar"})]})]})},exports.VideoRenderer=function({content:t,className:s="",style:r}){const n=t.videoUrl||ph(t.embedCode)||"";if(!n)return null;const o=hh(n);return a.jsx(ts,{className:`overflow-hidden my-4 ${s}`,style:r,children:a.jsxs(os,{className:"p-0",children:["file"===o?a.jsxs("video",{controls:!1!==t.controls,autoPlay:t.autoplay,poster:t.thumbnail,className:"w-full h-auto",playsInline:!0,muted:t.autoplay,children:[a.jsx("source",{src:n}),"Seu navegador não suporta vídeos HTML5."]}):a.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:a.jsx("iframe",{title:t.title||e.t("video"),src:"youtube"===o?ch(n,t.autoplay):mh(n,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&&a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-sm font-medium",children:t.title})})]})})},exports.ViewerDialog=function({open:e,onOpenChange:s,template:r,viewerType:n,isLoading:o=!1,enableDownload:i=!0,onDownload:l,isDownloading:c=!1,enableFavorite:u=!1,isFavorite:m=!1,onFavorite:p,isFavoriting:h=!1,enableConfirmReading:x=!1,readingConfirmationDate:f,onConfirmReading:g,isConfirmingReading:v=!1,readingConfirmationTimeRemaining:b,onIframeLoad:j,className:w}){const{t:N}=y.useTranslation(),_=t.useRef(null),C=n??tu(r.extension),k=c||v||h,S=r.code?`${r.code} – ${r.name}`:r.name,T=t.useCallback(()=>{_.current&&j&&j(_.current)},[j]);return t.useEffect(()=>{if(!e)return;const a=e=>{"Escape"===e.key&&s(!1)};return window.addEventListener("keyup",a),()=>window.removeEventListener("keyup",a)},[e,s]),a.jsx(ys,{open:e,onOpenChange:s,children:a.jsxs(ks,{className:Kt("max-w-[95vw] max-h-[95vh] p-6 gap-0 [&>button.absolute]:hidden",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"w-[90vw]",w),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4 min-h-[35px]",children:[o?a.jsx("h2",{className:"text-lg font-medium text-foreground truncate",children:"Carregando..."}):a.jsx("h2",{className:"text-lg font-medium text-foreground truncate max-w-[calc(100%-200px)]",children:S}),a.jsxs("div",{className:"flex items-center gap-1 ml-4 z-20",children:[!o&&a.jsxs(a.Fragment,{children:[(x||f)&&a.jsx(a.Fragment,{children:f?a.jsxs("div",{className:"flex flex-col mr-2.5",children:[a.jsxs("span",{className:"text-sm font-medium flex items-center gap-1 text-foreground",children:[a.jsx(d.CheckCheck,{className:"h-4 w-4"}),"Leitura confirmada"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-5",children:f.toLocaleDateString()})]}):null!=b&&b>0?a.jsxs("div",{className:"flex items-center gap-1 mr-2.5 text-sm text-muted-foreground",children:[a.jsx("span",{children:N("terms_confirmation_available")}),a.jsx("span",{className:"font-medium min-w-[72px]",children:nu(b)}),a.jsx("span",{children:"segundos"})]}):a.jsxs(Xt,{variant:"default",size:"sm",disabled:k,onClick:()=>g?.(),className:"mr-2.5",children:[a.jsx(d.ShieldCheck,{className:"h-4 w-4 mr-1"}),v?"Confirmando...":N("terms_confirm_reading")]})}),C!==exports.FileViewerType.none&&u&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>p?.(m),children:a.jsx(d.Star,{className:Kt("h-4 w-4",m&&"fill-accent text-accent")})})}),a.jsx(Nr,{children:m?"Desfavoritar":"Favoritar"})]}),C!==exports.FileViewerType.none&&i&&a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>l?.(),children:a.jsx(d.Download,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Download"})]})]}),a.jsxs(jr,{children:[a.jsx(wr,{asChild:!0,children:a.jsx(Xt,{variant:"ghost",size:"icon",className:"h-7 w-7",disabled:k,onClick:()=>s(!1),children:a.jsx(d.X,{className:"h-4 w-4"})})}),a.jsx(Nr,{children:"Fechar"})]})]})]}),a.jsx("div",{className:Kt("flex flex-col items-center justify-center min-h-[160px] w-full",o&&"relative -top-5",C===exports.FileViewerType.none&&"min-h-[124px]",C===exports.FileViewerType.image&&"max-h-[85vh]",(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&"min-w-[77vw] min-h-[80vh]"),children:o?a.jsx(tr,{className:"h-14 w-14"}):a.jsxs(a.Fragment,{children:[(C===exports.FileViewerType.none||!r.url)&&a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-base text-foreground mb-1",children:"Extensão não suportada para visualização."}),a.jsx("b",{className:"text-base text-foreground",children:"Deseja fazer o download do arquivo?"})]}),C===exports.FileViewerType.image&&a.jsx("img",{loading:"eager",src:r.url,alt:r.name,className:"max-w-full max-h-[85vh] object-contain"}),C===exports.FileViewerType.video&&a.jsx("video",{controls:!0,autoPlay:!0,src:r.url,className:"w-full h-full"}),C===exports.FileViewerType.audio&&a.jsx("audio",{controls:!0,autoPlay:!0,src:r.url}),(C===exports.FileViewerType.wopi||C===exports.FileViewerType.report)&&a.jsxs("div",{className:"relative w-full h-[79.5vh]",children:[a.jsx(tr,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-16 w-16"}),a.jsx("iframe",{ref:_,src:r.url,onLoad:T,className:"border-none w-full h-full z-[1] relative",title:r.name})]})]})}),!o&&C===exports.FileViewerType.none&&a.jsxs("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-border",children:[a.jsx(Xt,{variant:"ghost",onClick:()=>s(!1),children:"Cancelar"}),i&&a.jsx(Xt,{variant:"default",onClick:()=>l?.(),children:"Download"})]})]})})},exports.addAppTranslations=ui,exports.addChild=Bm,exports.addSibling=qm,exports.assets=We,exports.badgeVariants=Zs,exports.buildDetailRows=Ex,exports.buildHierarchy=qp,exports.buildModuleUrl=Gt,exports.buildPlacesTree=function(e){e.forEach(a=>{a.children=e.filter(e=>e.parentId===a.id)});const a=e.filter(e=>!e.parentId);return function e(a,t){a?.forEach(a=>{t(a),a.children&&e(a.children,t)})}(a,a=>{a.children=e.filter(e=>e.parentId===a.id)}),a},exports.buildWopiUrl=function(e){const{t:a}=y.useTranslation(),{viewerUrl:t,wopiUrl:s,fileId:r,token:n,extension:o,language:i="pt-br"}=e,l=ru(o);return l?`${t}${l}ui=${i}&rs=${i}&access_token=${n}&WOPISrc=${encodeURIComponent(`${s}${r}`)}`:null},exports.buttonGroupVariants=yl,exports.buttonVariants=Qt,exports.calculateAspectRatio=xh,exports.camelToDash=Fx,exports.cn=Kt,exports.createCrudPage=function(e){return({manager:t})=>{const{manager:s,config:r,onSave:n,onEdit:o,onToggleStatus:i}=e,l=t??s,d={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit: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 a.jsx(Yo,{manager:l,config:d,formSections:r.formSections,onSave:n,onToggleStatus:i,defaultSort:r.defaultSort})}},exports.createCrudRoutingConfig=function(e,a){const t=gp({basePath:e,newPath:a.newPath,editPath:a.editPath});return{useCustomRouting:!0,onNew:t.onNew,onEdit:t.onEdit}},exports.createMindMapNode=Lm,exports.createRoutingHandlers=gp,exports.createService=_n,exports.createSimpleSaveHandler=function(e,a,t){return s=>{if(s.id){const a=t(s);e.updateEntity(s.id,a)}else{const t=a(s);e.createEntity(t)}}},exports.createSimpleService=function(e){const a=_n({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment??!0,userIdFields:e.userIdFields,userFieldsMapping:e.userFieldsMapping});return{service:a,useCrudHook:(t,s)=>In({queryKey:e.tableName,service:a,entityName:e.entityName,additionalFilters:t,onSuccess:s})}},exports.createStatusConfig=function(e){return a=>e[a]},exports.createTranslatedMessages=a=>({success:{created:a=>e.t("msg_created_success",`${a} criado com sucesso`).replace("{{entity}}",a),updated:a=>e.t("msg_updated_success",`${a} atualizado com sucesso`).replace("{{entity}}",a),deleted:a=>e.t("msg_deleted_success",`${a} removido com sucesso`).replace("{{entity}}",a)},error:{create:a=>e.t("msg_create_error",`Erro ao criar ${a}`).replace("{{entity}}",a),update:a=>e.t("msg_update_error",`Erro ao atualizar ${a}`).replace("{{entity}}",a),delete:a=>e.t("msg_delete_error",`Erro ao remover ${a}`).replace("{{entity}}",a),load:a=>e.t("msg_load_error",`Erro ao carregar ${a}`).replace("{{entity}}",a)}}),exports.currencyFormatter=Qu,exports.debounce=(e,a)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>e(...s),a)}},exports.deriveEmailField=gn,exports.deriveNameField=fn,exports.deriveUsernameField=vn,exports.detectBrowserLocale=Lt,exports.detectBrowserPreferences=()=>{const e=Lt();return{locale:e,timezone:zt(),datetimeFormat:Ut(e)}},exports.detectBrowserTimezone=zt,exports.detectVideoProvider=hh,exports.emailService=Up,exports.errorService=tn,exports.exportMindMap=ip,exports.extractImageFileName=function(e){try{const a=new URL(e),t=a.pathname.split("/");return t[t.length-1]||"image"}catch{const a=e.split("/");return a[a.length-1]||"image"}},exports.extractNumberFromCurrency=function(e){const a=e.replace(/[^\d,.-]/g,"").replace(/\./g,"").replace(",",".");return parseFloat(a)},exports.extractVimeoId=uh,exports.extractYouTubeId=dh,exports.filterAndPromoteOrphans=function(e,a){const t=e.map(e=>({...e})),s=new Set(t.filter(e=>!a.has(e.id_user)).map(e=>e.id_user));return t.forEach(e=>{if(e.id_leader&&s.has(e.id_leader)){let a=e.id_leader;for(;a&&s.has(a);){const e=t.find(e=>e.id_user===a);a=e?.id_leader||null}e.id_leader=a}}),t.filter(e=>a.has(e.id_user))},exports.findDatetimeFormat=e=>Et.find(a=>a.value===e),exports.findLocale=e=>Pt.find(a=>a.value===e),exports.findNode=zm,exports.findTimezone=e=>Dt.find(a=>a.value===e),exports.flattenTree=$p,exports.formatBytes=lx,exports.formatCurrency=(e,a="BRL",t="pt-BR")=>null==e?"":new Intl.NumberFormat(t,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(e),exports.formatDate=Bt,exports.formatDatetime=Vt,exports.formatFileSize=function(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`},exports.formatTime=Gh,exports.formatTimeProgress=Hh,exports.generateCrudConfig=function(e,a,t={}){const s=[];return Object.keys(a).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const t=a[e],r={key:e,header:Xo(e),label:Xo(e),...Qo(e,t),sortable:!0,searchable:"string"==typeof t};s.push(r)}}),{title:e,columns:s,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...t}},exports.generateNodeId=Rm,exports.generatePastelBg=$t,exports.getActionTypes=function(){return[{id:"immediate",label:e.t("ap_type_immediate")},{id:"corrective",label:e.t("ap_type_corrective")},{id:"preventive",label:e.t("ap_type_preventive")},{id:"improvement",label:e.t("ap_type_improvement")},{id:"standardization",label:e.t("ap_type_standardization")}]},exports.getContrastRatio=function(e,a){const t=Wt(e),s=Wt(a);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)},exports.getDefaultPanelSize=function(e){switch(e){case exports.DashboardPanelType.Bar:case exports.DashboardPanelType.Column:case exports.DashboardPanelType.Pie:case exports.DashboardPanelType.List:case exports.DashboardPanelType.Line:case exports.DashboardPanelType.Area:case exports.DashboardPanelType.Text:case exports.DashboardPanelType.StackedColumn:return{x:4,y:2};case exports.DashboardPanelType.Pareto:case exports.DashboardPanelType.RiskMatrix:case exports.DashboardPanelType.Burndown:case exports.DashboardPanelType.PerformanceColumns:return{x:8,y:2};case exports.DashboardPanelType.Numeric:return{x:1,y:1};default:return{x:2,y:2}}},exports.getEnvironmentConfig=Ae,exports.getFieldValue=px,exports.getFileExtension=dx,exports.getFormFieldValues=function(e){return e.filter(e=>e.type!==exports.ECustomFormFieldType.readOnlyText).map(e=>({formFieldAssociationId:e.id,textValue:e.type===exports.ECustomFormFieldType.text?e.textValue:void 0,numberValue:e.type===exports.ECustomFormFieldType.number?e.numberValue:void 0,dateValue:e.type===exports.ECustomFormFieldType.date?e.dateValue:void 0,timeValue:e.type===exports.ECustomFormFieldType.time?e.timeValue:void 0,itemsValue:[exports.ECustomFormFieldType.url,exports.ECustomFormFieldType.singleSelection,exports.ECustomFormFieldType.multiSelection].includes(e.type)?e.itemsValue:void 0,questionsValue:e.type===exports.ECustomFormFieldType.questions?e.questionsValue:void 0}))},exports.getLinkFromRow=Gu,exports.getLuminance=Wt,exports.getMinPanelSize=ym,exports.getOnlineViewerType=function(e){const{t:a}=y.useTranslation();return{".gdocs":"document",".gsheets":"spreadsheets"}[e.toLowerCase()]||"document"},exports.getPriorities=function(){return[{id:exports.ETaskPlanPriority.low,label:e.t("ap_priority_low"),color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:e.t("ap_priority_medium"),color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:e.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=Kh,exports.getQualiexApiUrl=Oe,exports.getStatusLabels=Mh,exports.getSupabaseClient=cn,exports.getViewerType=tu,exports.getWopiViewer=ru,exports.handleExternalLink=Ht,exports.importMindMap=function(e){return lp(JSON.parse(e))},exports.inferDatetimeFormat=Ut,exports.inputGroupAddonVariants=Vl,exports.inputGroupButtonVariants=ql,exports.isCurrency=function(e){return!!Yu.test(e)&&!isNaN(parseFloat(e.replace(/,/g,"")))},exports.isDevEnvironment=Ue,exports.isDevSupabaseProject=Ie,exports.isImageUrl=function(e){const a=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"];try{const t=new URL(e);return a.some(e=>t.pathname.toLowerCase().endsWith(e))}catch{const t=e.toLowerCase();return a.some(e=>t.endsWith(e))}},exports.isLovablePreview=Le,exports.isNullOrEmptyField=function(e){return null==e?.value||""===e.value.trim()},exports.isValidDatetimeFormat=e=>Et.some(a=>a.value===e),exports.isValidLocale=Ft,exports.isValidTimezone=Rt,exports.loadClicksignScript=wh,exports.loadForlogicFonts=tl,exports.logoSrc=He,exports.mergeTranslationFiles=function(...e){return Object.assign({},...e)},exports.moveNode=Wm,exports.navigationMenuTriggerStyle=ld,exports.normalizeVideoUrl=function(e,a,t){switch(a||hh(e)){case"youtube":return ch(e,t);case"vimeo":return mh(e,t);default:return e}},exports.normalizeVimeoUrl=mh,exports.normalizeYouTubeUrl=ch,exports.parseIframeSrc=ph,exports.placeService=Bp,exports.processTrails=Sx,exports.processUrl=Hu,exports.qualiexApi=xn,exports.removeNode=$m,exports.resizeKeepingAspect=function(e,a,t,s){const r=xh(e,a);return t&&!s?{width:t,height:Math.round(t/r)}:s&&!t?{width:Math.round(s*r),height:s}:{width:e,height:a}},exports.resolveFieldMappings=bn,exports.resolvePageTitle=Cp,exports.setCollapsedAll=Gm,exports.setFormFieldValues=function(e,a){return a?.length?e.map(e=>{const t=a.find(a=>a.formFieldAssociationId===e.id);if(!t)return e;const s={...e};switch(e.type){case exports.ECustomFormFieldType.text:s.textValue=t.textValue;break;case exports.ECustomFormFieldType.number:s.numberValue=t.numberValue;break;case exports.ECustomFormFieldType.date:s.dateValue=t.dateValue;break;case exports.ECustomFormFieldType.time:s.timeValue=t.timeValue;break;case exports.ECustomFormFieldType.url:case exports.ECustomFormFieldType.singleSelection:case exports.ECustomFormFieldType.multiSelection:s.itemsValue=t.itemsValue||[];break;case exports.ECustomFormFieldType.questions:s.questionsValue=t.questionsValue||[]}return s}):e},exports.setupQualiexCore=function(e){return{queryClient:e.queryClient||new w.QueryClient({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}},exports.shouldShowField=hx,exports.shouldUseDevTokens=ze,exports.signService=yh,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=Ge,exports.sortByMonthYear=function(e){return e?.sort((e,a)=>{if(!e?.items?.length||!a?.items?.length)return 0;return Wu(e.items[0]?.keyDate)-Wu(a.items[0]?.keyDate)})},exports.toQueryString=function(e){return e?Ku(e).join("&"):null},exports.toggleCollapsed=Hm,exports.toggleVariants=go,exports.trackFooterClick=Oi,exports.trackInterestClick=Ui,exports.trackModuleClick=zi,exports.trimTextFields=Yt,exports.useActionPlan=Oh,exports.useActionPlanProgress=Wh,exports.useActiveModules=(e={})=>{const{enabled:a=!0}=e,{alias:t}=An();return w.useQuery({queryKey:["active-modules",t],queryFn:async()=>{if(!t)return[];const e=cn(),{data:a,error:s}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",t).eq("status","active").order("name");if(s){if(!pn.handleError(s))throw s;return[]}return a||[]},enabled:a&&!!t})},exports.useAliasFromUrl=Jo,exports.useAuth=An,exports.useBaseForm=Eo,exports.useClarity=sl,exports.useColumnManager=Co,exports.useColumnResize=fo,exports.useCreateMultipleLeadersMutation=Kp,exports.useCreateSingleLeaderMutation=Gp,exports.useCrud=In,exports.useDebounce=kp,exports.useDerivedContractedModules=Qi,exports.useFormField=Ms,exports.useHasOpenModal=function(){const{hasOpenModal:e}=Fp();return e},exports.useI18nFormatters=()=>{const{locale:e,timezone:a}=fi(),t=It;return{formatDatetime:s=>Vt(s,t,a,e),formatDate:t=>Bt(t,e,a),locale:e,timezone:a,datetimeFormat:t}},exports.useIsMobile=Fn,exports.useLeadershipApi=Wp,exports.useLocale=fi,exports.useMediaQuery=Mn,exports.useMediaUpload=lh,exports.useModalState=Fp,exports.useModuleAccess=Yi,exports.useModuleConfig=bi,exports.useNavigation=_p,exports.usePageMetadata=function(e){const{setMetadata:a,clearMetadata:s}=oi(),r=t.useRef({});t.useEffect(()=>{const t=JSON.stringify(r.current.breadcrumbs)!==JSON.stringify(e.breadcrumbs);return(r.current.title!==e.title||r.current.subtitle!==e.subtitle||t)&&(r.current={title:e.title,subtitle:e.subtitle,breadcrumbs:e.breadcrumbs},a(e)),()=>s()},[e.title,e.subtitle,e.breadcrumbs,a,s])},exports.usePageMetadataContext=oi,exports.usePageTitle=function(){const e=N.useLocation(),{navigation:a}=_p();return Cp(a,e.pathname)},exports.usePermissionQuery=Pp,exports.useQualiexUsers=Uo,exports.useRemoveLeaderMutation=Qp,exports.useRouteBreadcrumbs=function(){const e=N.useLocation();return(()=>{const a=e.pathname.split("/").filter(Boolean),t=[{label:"Exemplos",href:"/"}];let s="";return a.forEach((e,r)=>{s+=`/${e}`;const n=r===a.length-1,o=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:o,href:n?void 0:s,isCurrentPage:n})}),t})()},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),x=t.useRef(0),f=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,x.current=l[e]??a)},[i,l,a]);t.useEffect(()=>{if(!c||!m)return;const e=e=>{const a=e.clientY-h.current,t=Math.max(s,Math.min(r,x.current+a));d(e=>{const a={...e,[m]:t};return o?.(a),a})},a=()=>{u(!1),p(null),n&&d(e=>(localStorage.setItem(n,JSON.stringify(e)),e))};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,s,r,n,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 v=t.useCallback(()=>{d({}),n&&localStorage.removeItem(n),o?.({})},[n,o]);return{rowHeights:l,isDragging:c,activeRow:m,handleMouseDown:g,resetHeights:v,getRowHeight:f}},exports.useSidebar=Ud,exports.useSidebarResize=Ip,exports.useSignConfig=fh,exports.useSyncSubordinatesMutation=Xp,exports.useUpdateLeaderMutation=Yp,exports.useUpdatesNotification=Xc,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),x=a.length,f=0===i,g=i===x-1,v=a[i],b=x>1?(i+1)/x*100:100,y=t.useCallback(()=>!v?.canProceed||v.canProceed(),[v]),j=t.useMemo(()=>y(),[y,d]),w=t.useMemo(()=>!f&&!v?.disableBack,[f,v]),N=t.useCallback(e=>{c(a=>({...a,...e}))},[]),_=t.useCallback((e,a)=>{c(t=>({...t,[e]:a}))},[]),C=t.useCallback(()=>{l(s),c(r),m(!1),h(!1),o?.()},[s,r,o]),k=t.useCallback(async()=>{if(y()&&!p){h(!0);try{await(n?.(d))}finally{h(!1)}}},[y,p,d,n]),S=t.useCallback(async()=>{y()&&!u&&(g?await k():l(e=>Math.min(e+1,x-1)))},[y,u,g,x,k]),T=t.useCallback(()=>{w&&!u&&l(e=>Math.max(e-1,0))},[w,u]),P=t.useCallback(e=>{e<0||e>=x||u||(e<=i||e===i+1)&&l(e)},[i,x,u]),E=t.useCallback(e=>{m(e)},[]);return{currentStep:i,currentStepConfig:v,data:d,isFirstStep:f,isLastStep:g,isLoading:u,isCompleting:p,next:S,back:T,goTo:P,canProceed:j,canGoBack:w,setData:N,updateField:_,reset:C,complete:k,setLoading:E,progress:b,stepIndex:i,totalSteps:x}},exports.validateFields=function(e){const a=[];return e.forEach(e=>{if(!e.required||e.readOnly||e.type===exports.ECustomFormFieldType.readOnlyText)return;const t=px(e);if((null==t||""===t||Array.isArray(t)&&0===t.length)&&a.push(e.id),e.type===exports.ECustomFormFieldType.number&&null!=t){const s=e.config;null!=s?.min&&t<s.min&&a.push(e.id),null!=s?.max&&t>s.max&&a.push(e.id)}}),{valid:0===a.length,invalidFields:[...new Set(a)]}};
|