PageSourceSearch

https://appcasacor.com.br/_next/static/chunks/pages/admin-3c830e1ad3564ebf.js

js appcasacor.com.br collected 2026-09-24 18:06:43 UTC 898,035 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6964,3852,5364],{64830:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin",function(){return a(97047)}])},77872:function(e,t,a){"use strict";a.d(t,{Z:function(){return m}});var n=a(85893);a(67294);var s=a(54109),i=a(23599),r=a(94054),l=a(18360),o=a(98456),d=a(93946),c=a(56815),u=a(95537);function m(e){let{label:t,options:a,value:m="",onChange:h,className:v,error:x,errorMessage:p,multiple:g,renderValue:j,selectProps:f={},disabled:b,name:y,cleanable:N,isLoading:k}=e,w=(e,t)=>{let a=e.target.value;"string"==typeof a||"number"==typeof a?h(g?a.split(","):a):h(a)};return(0,n.jsxs)(r.Z,{fullWidth:!0,className:"basic-select "+v,disabled:b,children:[(0,n.jsx)(s.Z,{id:"basic-select",children:t}),(0,n.jsx)(l.Z,{labelId:"basic-select",id:"select",value:g?m||[]:null==m?void 0:m.toString(),label:t,name:y,onChange:w,error:x,multiple:g,renderValue:j||void 0,...f,children:k?(0,n.jsxs)(i.Z,{children:[(0,n.jsx)(o.Z,{size:20,sx:{marginRight:1}}),(0,n.jsx)("span",{children:"Carregando..."})]}):a.map(e=>"string"==typeof e||"number"==typeof e?(0,n.jsx)(i.Z,{value:e,children:e},e):(0,n.jsx)(i.Z,{value:e.value,disabled:!!e.disabled,children:e.label},e.value))}),N&&!!m&&(0,n.jsx)(d.Z,{className:"clean-btn",onClick:function(){h()},children:(0,n.jsx)(u.Z,{})}),!!p&&(0,n.jsx)(c.Z,{error:!0,children:p})]})}},45507:function(e,t,a){"use strict";var n=a(86455),s=a.n(n),i=a(58467),r=a(60845),l=a(67294),o=a(97762);function d(e){if(null==e)return"";if("string"==typeof e){try{let t=JSON.parse(e);if("string"==typeof(null==t?void 0:t.message))return t.message}catch(e){}return e}return"object"==typeof e?"string"==typeof e.message?e.message:JSON.stringify(e):String(e)}let c=e=>{let{title:t,text:a,icon:n,confirmButtonText:c,endpoint:u,endpointConfig:m,onSuccess:h,onConfirm:v,onError:x,onCancel:p,successMessage:g,skipConfirm:j,onConfirmOnSuccess:f,showCancelButton:b=!0,cancelButtonText:y,messageError:N,doneMassage:k,confirmWord:w}=e;return j?(async()=>{let{t:e}=(0,r.$G)("common");try{let t=await (0,i.ZP)(u,m);t.error?(s().fire({title:"".concat(e("ops_error")),text:"".concat(e("reason"))+d(t.error),icon:"error"}),x&&x()):(g&&s().fire({title:"".concat(e("Done")),text:g,icon:"success"}),h&&h(t))}catch(e){return{error:e.message}}})():u?s().fire({title:t,html:"string"==typeof a?a:a?(0,o.Dq)(l.createElement("div",null,a)):void 0,icon:n||"question",showCancelButton:b,reverseButtons:!0,confirmButtonText:c||"Sim, tenho certeza",cancelButtonText:y||"Cancelar",showLoaderOnConfirm:!0,allowOutsideClick:!1,preConfirm:async()=>{try{let e=await (0,i.ZP)(u,m);if(e.data.error)return{error:e.data.error};return e}catch(e){return{error:e.message}}}}).then(e=>{if(e.dismiss===s().DismissReason.cancel)return p&&p();e.error||e.value.error?(s().fire({title:N||"Oops, ocorreu um erro!",text:"Motivo: "+d(e.error||e.value.error),icon:"error"}),x&&x()):(g&&s().fire({title:k||"Pronto!",text:g,icon:"success"}).then(e=>{e.isConfirmed&&f&&f()}),h&&h(e.value))}):void s().fire({title:t,html:"string"==typeof a?a||"Tem certeza que deseja sair e descatar as altera\xe7\xf5es?":a?(0,o.Dq)(l.createElement("div",null,a)):"Tem certeza que deseja sair e descatar as altera\xe7\xf5es?",icon:n||"question",showCancelButton:b,reverseButtons:!0,confirmButtonText:c||"Descartar e sair",cancelButtonText:y||"Cancelar",allowOutsideClick:!1,didOpen:()=>{let e=s().getContainer(),t=e=>e.stopPropagation();if(null==e||e.addEventListener("keydown",t,!0),null==e||e.addEventListener("keyup",t,!0),!w)return;let a=s().getConfirmButton(),n=s().getInput();a&&(a.disabled=!0);let i=()=>null==n?void 0:n.focus();i(),requestAnimationFrame(i),null==n||n.addEventListener("input",()=>{a&&(a.disabled=n.value!==w)})}
1,...w?{input:"text",inputPlaceholder:"Digite ".concat(w),inputValidator:e=>{if(e!==w)return"Digite ".concat(w," para confirmar")}}:{}}).then(e=>{if(e.isConfirmed)return v&&v();p&&p()})};t.Z=c},57257:function(e,t,a){"use strict";a.d(t,{Z:function(){return y}});var n=a(85893),s=a(38679),i=a(72428),r=a(99964),l=a(6336),o=a(83321),d=a(89755),c=a.n(d),u=a(67294),m=a(96120),h=a.n(m);a(96167);var v=a(40221),x=a(21313),p=a(9669),g=a.n(p),j=a(89723);let f=Math.PI/180;async function b(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=t.getContext("2d");if(!i)throw Error("No 2d context");let r=e.naturalWidth/e.width,l=e.naturalHeight/e.height,o=window.devicePixelRatio;t.width=Math.floor(a.width*r*o),t.height=Math.floor(a.height*l*o),i.scale(o,o),i.imageSmoothingQuality="high";let d=a.x*r,c=a.y*l,u=e.naturalWidth/2,m=e.naturalHeight/2;i.save(),i.translate(-d,-c),i.translate(u,m),i.rotate(s*f),i.scale(n,n),i.translate(-u,-m),i.drawImage(e,0,0,e.naturalWidth,e.naturalHeight,0,0,e.naturalWidth,e.naturalHeight),i.restore()}function y(e){var t,a;let{refId:d="imgcrop",renderBtn:p=(0,n.jsx)("label",{children:(0,n.jsx)("div",{className:"placeholder-btn",children:(0,n.jsx)(c(),{className:"placeholder",src:"/placeholder.png",layout:"fill",objectFit:"contain",unoptimized:!0,alt:"",width:"100%",height:"100%"})})}),onChange:f,round:y,aspectRatio:N,changeable:k=!0,className:w="",maxWidthOrHeight:Z=1920,defaultImage:C}=e,[S,_]=(0,u.useState)(""),D=(0,u.useRef)(null),E=(0,u.useRef)(null),P=u.useRef(),I=u.useRef(),[A,T]=(0,u.useState)(),[R,L]=(0,u.useState)(),[q,M]=(0,u.useState)(1),[O,F]=u.useState(500),[B,U]=(0,u.useState)(0),[z,V]=(0,u.useState)(y?1:void 0),G=u.useRef(z),[W,$]=u.useState(!1);function H(){P.current&&(P.current.value=""),_(""),V(void 0)}return u.useEffect(()=>{V(y?1:void 0)},[y]),u.useEffect(()=>{(null==C?void 0:C.includes("http"))?g().get(C,{responseType:"blob",headers:{"Access-Control-Allow-Origin":"*"}}).then(e=>{setTimeout(()=>{_(URL.createObjectURL(e.data))},500)}):_(C)},[C]),t=async()=>{(null==R?void 0:R.width)&&(null==R?void 0:R.height)&&E.current&&D.current&&b(E.current,D.current,R,q,B)},a=[R,q,B],(0,u.useEffect)(()=>{let e=setTimeout(()=>{t.apply(void 0,a)},100);return()=>{clearTimeout(e)}},a),(0,n.jsxs)("div",{className:"image-cropper "+(w||d),children:[(0,n.jsx)("input",{type:"file",accept:"image/*",onChange:function(e){if(e.target.files&&e.target.files.length>0){T(void 0);let t=new FileReader;t.addEventListener("load",()=>{var e;return _((null===(e=t.result)||void 0===e?void 0:e.toString())||"")}),t.readAsDataURL(e.target.files[0]),I.current=e.target.files[0]}},className:"d-none",ref:P,id:d,name:"file",disabled:!k}),(0,n.jsx)("input",{id:"scale-input",type:"number",step:"0.1",value:q,disabled:!S,onChange:e=>M(Number(e.target.value))}),(0,n.jsxs)("div",{className:"processing",children:[u.cloneElement(p||(0,n.jsx)("label",{children:"Open File"}),{htmlFor:d}),W&&(0,n.jsx)(x.aN,{message:"Processando imagem"})]}),(0,n.jsx)(r.Z,{open:Boolean(S),disablePortal:!0,children:(0,n.jsxs)("div",{className:"modal",children:[(0,n.jsxs)("div",{className:"content",children:[(0,n.jsx)("div",{className:"title",children:"Edi\xe7\xe3o imagem"}),(0,n.jsx)(h(),{crop:A,onDragStart:()=>V(N),onChange:(e,t)=>
1{let{height:a,width:n}=e;G.current=n/a,T(t)},onComplete:e=>L(e),aspect:z,circularCrop:y,ruleOfThirds:!0,children:(0,n.jsx)("img",{ref:E,alt:"Crop me",src:S,style:{transform:"scale(".concat(q,") rotate(").concat(B,"deg)")},onLoad:function(e){let{width:t,height:a}=e.currentTarget;z?T((0,m.centerCrop)((0,m.makeAspectCrop)({unit:"%",width:90},z,t,a),t,a)):G.current=t/a},draggable:!1})}),(0,n.jsxs)("div",{className:"modal-actions",children:[(0,n.jsxs)("div",{className:"sliders",children:[(0,n.jsxs)("div",{className:"slider",children:[(0,n.jsx)("span",{children:"Zoom:"}),(0,n.jsx)(s.Z,{}),(0,n.jsx)(l.ZP,{value:q,min:1,max:5,step:.1,onChange:(e,t)=>M(Number(t))}),(0,n.jsx)(i.Z,{})]}),(0,n.jsxs)("div",{className:"slider slider2",children:[(0,n.jsx)("span",{className:"item",children:"Tamanho imagem (kb):"}),(0,n.jsx)(l.ZP,{value:O,min:300,max:800,step:100,onChange:(e,t)=>F(Number(t)),marks:[{value:300,label:"300"},{value:400,label:"400"},{value:500,label:"500"},{value:600,label:"600"},{value:700,label:"700"},{value:800,label:"800"}]})]})]}),(0,n.jsx)(o.Z,{variant:"outlined",onClick:H,size:"large",children:"Cancelar"}),(0,n.jsx)(o.Z,{variant:"contained",onClick:function(){function e(e){(0,v.Z)(e,{maxSizeMB:O/1e3,maxWidthOrHeight:Z}).then(e=>{f(e,G.current),$(!1)}).catch(function(e){$(!1),(0,j.C)(e.message)})}if($(!0),A){var t;null===(t=D.current)||void 0===t||t.toBlob(e)}else e(I.current);H()},size:"large",className:"submit",children:"Salvar imagem"})]})]}),(0,n.jsx)("canvas",{ref:D,style:{display:"none",objectFit:"contain",width:null==R?void 0:R.width,height:null==R?void 0:R.height}})]})})]})}},96013:function(e,t,a){"use strict";var n=a(85893),s=a(67294),i=a(89755),r=a.n(i),l=a(45332);let o=e=>{let{src:t,...a}=e,[i,o]=(0,s.useState)((0,l.e6)(t));return s.useEffect(()=>{o((0,l.e6)(t))},[t]),(0,n.jsx)(r(),{src:i,alt:"",placeholder:"blur",className:"placeholder image-with-fallback",draggable:!1,objectFit:"contain",blurDataURL:l.LG,unoptimized:"/placeholder.png"===i,onError:()=>{o("/placeholder.png")},...a})};t.Z=o},37276:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});var n=a(85893),s=a(67294);let i=["heading","fontfamily","fontsize","|","alignment","|","fontColor","fontBackgroun
1dColor","|","italic","strikethrough","underline","subscript","superscript","|","link","|","bulletedList","numberedList","todoList","|","blockQuote","|","undo","redo"],r=["bold","italic","underline","|","link","|","bulletedList","numberedList","|","undo","redo"];function l(e){let{onChange:t,initValue:l,disabled:o=!1,compact:d=!1}=e,c=(0,s.useRef)(),[u,m]=(0,s.useState)(!1),{CKEditor:h,ClassicEditor:v}=c.current||{};return(0,s.useEffect)(()=>{u||(c.current={CKEditor:a(72757).CKEditor,ClassicEditor:a(5234)},m(!0))},[u]),u?(0,n.jsx)("div",{className:d?"text-editor-compact":void 0,children:(0,n.jsx)(h,{editor:v,disabled:o,config:{removePlugins:["Table","Media"],toolbar:d?r:i,...d?{link:{defaultProtocol:"https://"}}:{}},data:l||"",onChange:(e,a)=>{t(a.getData().replace("<br>",""))}})}):(0,n.jsx)("div",{children:"Editor loading"})}},32101:function(e,t,a){"use strict";var n=a(85893),s=a(50135),i=a(67294);let r=e=>{var t;let{...a}=e,r=(0,i.useRef)((null===(t=a.value)||void 0===t?void 0:t.toString())||""),l={};return a.onValueChange&&(l.onChange=e=>{e.stopPropagation(),a.onValueChange&&a.onValueChange(e.target.value)}),a.onBlur&&(l.onBlur=()=>{let e=r.current.value;e="string"==typeof e?null==e?void 0:e.trim():e,a.onValueChange&&a.onValueChange(e),a.onBlur&&a.onBlur(e)}),i.useEffect(()=>{a.defaultValue&&(r.current.value=a.defaultValue)},[a.defaultValue]),(0,n.jsx)(s.Z,{inputRef:r,className:"textfield",autoComplete:"off",...a,...l})};t.Z=r},39673:function(e,t,a){"use strict";var n=a(67294),s=a(77982),i=a(313),r=a(99490),l=a(46870),o=a(89723);let d=()=>{let e=(e,t)=>{let a=r.ou.fromJSDate(new Date(e),{zone:l.YR}).startOf("day");if(!a.isValid)return null;for(let e=0;e<7;e+=1){let n=0===e?a:a.minus({days:e}),s=String(n.weekday%7),i=null==t?void 0:t[s];if((0,o.C)("\uD83D\uDD0D Debug - checking SP day:",n.toISODate(),"dayOfWeek:",s,"has hours:",!!(null==i?void 0:i.length)),i&&i.length>0){let e=i[i.length-1],t="00:00"===e.endTime?"23:59":e.endTime;if(!t)continue;let a=(0,l.mr)(n.toJSDate(),t);return(0,o.C)("\uD83D\uDD0D Debug - sellEndDatetime (SP wall clock):",a.toISOString()),a}}let n=(0,l.O)(e);return Number.isNaN(n.year)?null:new Date(e)},t=(0,n.useCallback)((t,a)=>{(0,o.C)("\uD83D\uDD0D Debug - verifyIsExpiredTicket called with sellEndDate:",t);let n=(0,s.Z)(new Date(t),1);if((0,i.Z)(new Date,n))return!1;let r=e(t,a);return!r||(0,l.oJ)(r)},[]);return{verifyIsExpiredTicket:t}};t.Z=d},97047:function(e,t,a){"use strict";let n;a.r(t),a.d(t,{__N_SSG:function(){return dA},default:function(){return dT}});var s,i,r=a(85893),l=a(67294),o=a(87168),d=a(20483),c=a(801),u=a(6571),m=a(67358),h=a(38895),v=a(83321),x=a(22797),p=a(77058),g=a(84433),j=a(76722),f=a(38043),b=a(74347),y=a(83784),N=a(11113),k=a(25068),w=a(27489),Z=a(34511),C=a(26155),S=a(54118),_=a(31688),D=a(54566),E=a(98233),P=a(11399),I=a(21943),A=a(58805),T=a(73479),R=a(50185),L=a(67108),q=a(19933),M=a(25683),O=a(39243),F=a(35886),B=a(60928),U=a(80878),z=a(44702),V=a(98395),G=a(45059),W=a(37150),$=a(31760),H=a(9828),J=a(58467),Q=a(89723),Y={allowedEventsIds:[],accessRules:[],userRole:void 0},K=a(55765),X=a(93946),ee=a(21313),et=a(72132),ea=a(50480),en=a(69368),es=a(50135),ei=a(54007),er=a(19717);let el=e=>{let{onChange:t,onRemove:a}=e,{toggleLoader:n}=(0,ee.U2)(),{t:s}=(0,p.$)("admin"),{storedState:i}=(0,o.oR)(),{currentSelectedEvent:d}=i||{},[c,u]=l.useState(!1),[m,h]=l.useState(e.rule||{eventId:null==d?void 0:d._id}),{id:x,label:g,screens:j=[]}=m;function f(e){h(t=>({...t,...e}))}async function b(){try{var e,a;let i={...m};if(!i.label)return et.Am.error("Nome da regra obrigat\xf3rio!");if(i.screens=null===(e=i.screens)||void 0===e?void 0:e.filter(e=>!!e.view||!!e.edit||!!e.delete),!(null===(a=i.screens)||void 0===a?void 0:a.length))return et.Am.error("Selecione as permiss\xf5es dos usu\xe1rios para as rotas do sistema!");c&&(i.eventId="all"),n(!0,s("processing"));let r=await J.ZP.post("/access-rule",i);if(n(),r.data.error)throw Error(s("error_on_processing")+" \n\n"+r.data.error.message);et.Am.success(s("success_on_processing")),t(),(0,K.Mr)()}catch(e){n(),et.Am.error(e.message)}}async function y(){a&&a(x)}let N=e=>{var t,a,n,i,l,o,d;let{route:c}=e,u=!!c.subRoutes;return(0,r.jsxs)("div",{className:"route",children:[(0,r.jsxs)("div",{className:"title",children:[s(c.label),":"]}),!u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ea.Z,{label:"Visualizar",control:(0,r.jsx)(en.Z,{}),checked:!!(null===(t=j.find(e=>e.screenId===c.id))||void 0===t?void 0:t.view),onChange:e=>{let{checked:t}=e.target,a=[...j],n=a.findIndex(e=>e.screenId===c.id);t?n>=0?a[n].view=t:a.push({screenId:c.id,view:t}):n>=0?(a[n].view=t,a[n].edit=t,a[n].delete=t):a.push({screenId:c.id,view:t,edit:t,delete:t}),f({screens:a})}}),(0,r.jsx)(ea.Z,{label:"Editar",control:(0,r.jsx)(en.Z,{}),checked:!!(null===(a=j.find(e=>e.screenId===c.id))||void 0===a?void 0:a.edit),onChange:e=>{let{checked:t}=e.target,a=[...j],n=a.findIndex(e=>e.screenId===c.id);n>=0?a[n].edit=t:a.push({screenId:c.id,edit:t}),f({screens:a})}}),(0,r.jsx)(ea.Z,{label:"Deletar",control:(0,r.jsx)(en.Z,{}),checked:!!(null===(n=j.find(e=>e.screenId===c.id))||void 0===n?void 0:n.delete),onChange:e=>{let{checked:t}=e.target,a=[...j],n=a.findIndex(e=>e.screenId===c.id);n>=0?a[n].delete=t:a.push({screenId:c.id,delete:t}),f({screens:a})}}),(0,r.jsx)(ea.Z,{label:"Acesso total",control:(0,r.jsx)(en.Z,{}),checked:!!(null===(i=j.find(e=>e.screenId===c.id))||void 0===i?void 0:i.view)&&!!(null===(l=j.find(e=>e.screenId===c.id))||void 0===l?void 0:l.edit)&&!!(null===(o=j.find(e=>e.screenId===c.id))||void 0===o?void 0:o.delete),onChange:e=>{let{checked:t}=e.target,a=[...j],n=a.findIndex(e=>e.screenId===c.id);n>=0?(a[n].view=t,a[n].edit=t,a[n].delete=t):a.push({screenId:c.id,view:t,edit:t,delete:t}),f({screens:a})}})]}),null===(d=c.subRoutes)||void 0===d?void 0:d.map(e=>(0,r.jsx)(N,{route:e},e.id))]})};return(0,r.jsx)("div",{className:"access-rules-form",children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:x?"Editar regra de acesso":"Nova regra de acesso",onGoBack:()=>(0,K.Mr)(),data:{id:null==m?void 0:m.id,updatedAt:null==m?void 0:m.updatedAt,lastUpdatedBy:null==m?void 0:m.lastUpdatedBy}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("h3",{children:"Nome da regra:"}),(0,r.jsx)(es.Z,{className:"textfield",value:g||"",onChange:e=>{e.stopPropagation(),f({label:e.target.value})}}),(0,r.jsx)("h3",{children:"Selecione as permiss\xf5es dos usu\xe1rios para as rotas do sistema:"}),dk.map(e=>(0,r.jsx)(N,{route:e},e.id)),(0,r.jsx)(ea.Z,{style:{display:"flex",marginLeft:"auto"},label:"Criar como regra global",control:(0,r.jsx)(en.Z,{}),checked:c,onChange:e=>{u(e.target.checked)}}),(0,r.jsxs)("div",{className:"actions",children:[!!x&&(0,r.jsx)(X.Z,{size:"large",className:"remove-btn",onClick:y,children:(0,r.jsx)(er.Z,{})}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:s("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,children:s("save")})]})]})]})})})};var eo=a(87109),ed=a(96506),ec=a(95537);let eu=e=>{var t;return(0,r.jsx)(es.Z,{...e,InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==e?void 0:null===(t=e.value)||void 0===t?void 0:t.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>
1null==e?void 0:e.onChange(),children:(0,r.jsx)(ec.Z,{})})})}})};var em=a(45507),eh=a(62126),ev=a(62672);let ex=()=>{var e,t;let{toggleLoader:a}=(0,ee.U2)(),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(null==n?void 0:n.accessRulesFilters)||{},{currentSelectedEvent:r}=n||{},{itemsLimit:d=20,itemsPage:c=0}=i,u=new URLSearchParams({...i,eventId:null==r?void 0:r._id}),m=(0,eh.Z)("/access-rule/list?"+u),h=(null===(e=m.data)||void 0===e?void 0:e.items)||[],v=(null===(t=m.data)||void 0===t?void 0:t.numberOfItems)||0,[x,p]=l.useState(""),g=(0,ev.Nr)(x,300);l.useEffect(()=>{s({accessRulesFilters:{...i,search:g}})},[g]);let j=l.useCallback(e=>{s({accessRulesFilters:{...i,...e}})},[i]),f=l.useCallback(e=>{(0,em.Z)({text:"Deseja realmente remover esta regra?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{a(!0,"Removendo regra");let t=await J.ZP.delete("/access-rule/".concat(e));if(t.data.error)return et.Am.error(t.data.error.message);m.refresh(),a(),(0,K.Mr)(),et.Am.success("Regra removida com sucesso!")},onError:()=>{a()}})},[null==h?void 0:h.length]);return{numberOfItems:v,itemsLimit:d,itemsPage:c,loadingRules:m.isLoading,rules:h,removeRule:f,refreshRules:m.refresh,setFilters:j,search:x,setSearch:p}};var ep=a(51797),eg=a(46761),ej=a(46870),ef=a(8896),eb=a(68623),ey=a(13973),eN=a(26602),ek=a(95533);function ew(e){let{count:t,page:a,rowsPerPage:n,onPageChange:s}=e,i=e=>{s(e,0)},l=e=>{s(e,a-1)},o=e=>{s(e,a+1)},d=e=>{s(e,Math.max(0,Math.ceil(t/n)-1))};return(0,r.jsxs)("div",{style:{flexShrink:0,marginLeft:20},children:[(0,r.jsx)(X.Z,{onClick:i,disabled:0===a,"aria-label":"first page",children:(0,r.jsx)(eb.Z,{})}),(0,r.jsx)(X.Z,{onClick:l,disabled:0===a,"aria-label":"previous page",children:(0,r.jsx)(ey.Z,{})}),(0,r.jsx)(X.Z,{onClick:o,disabled:a>=Math.ceil(t/n)-1,"aria-label":"next page",children:(0,r.jsx)(eN.Z,{})}),(0,r.jsx)(X.Z,{onClick:d,disabled:a>=Math.ceil(t/n)-1,"aria-label":"last page",children:(0,r.jsx)(ek.Z,{})})]})}let eZ=e=>{let{numberOfItems:t=0,rowsPerPage:a,page:n,onPageChange:s,onRowsPerPageChange:i,resetPageOnFirstLoad:o}=e;return l.useEffect(()=>{o&&s(0)},[]),(0,r.jsx)(ef.Z,{component:"div",className:"table-pagination",rowsPerPageOptions:[5,10,15,20,25],style:{borderWidth:0,display:"flex",justifyContent:"flex-end",marginTop:20},count:t,rowsPerPage:a,page:n,labelRowsPerPage:"Items por p\xe1gina",labelDisplayedRows:e=>{let{from:t,to:a,count:n,page:s}=e;return(0,r.jsxs)("span",{children:[t,"-",a," de ",n]})},onPageChange:(e,t)=>
1s(t),onRowsPerPageChange:e=>i(Number(e.target.value)),ActionsComponent:ew})},eC=()=>{let{t:e}=(0,p.$)("admin"),{storedState:t}=(0,o.oR)(),{currentSelectedEvent:a}=t||{},{loadingRules:n,rules:s,removeRule:i,refreshRules:l,numberOfItems:d,itemsLimit:c,itemsPage:u,setFilters:m,search:h,setSearch:x}=ex();return(0,r.jsxs)("div",{className:"access-rules",children:[(0,r.jsx)("h3",{children:"Regras de acesso"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(eu,{value:h,onChange:e=>{var t;return x((null===(t=null==e?void 0:e.target.value)||void 0===t?void 0:t.trim())||"")},className:"search",placeholder:"Pesquisar regra, permiss\xf5es"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>{if(!a)return et.Am.error("Selecione um evento primeiro!");(0,K.K4)((0,r.jsx)(el,{onChange:l}))},className:"add-rule",children:"Adicionar regra de acesso"})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Regra"}),(0,r.jsx)("th",{children:"Permiss\xf5es"}),(0,r.jsx)("th",{children:"Data cria\xe7\xe3o"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),!n||(null==s?void 0:s.length)?(0,r.jsx)("tbody",{children:null==s?void 0:s.map((t,a)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:t.label}),(0,r.jsx)("td",{children:t.screens.map(e=>e.screenId).map(t=>(function(e){var t,a,n;let s=e.split("-").length>1;if(s){let t=e.split("-")[0],{subRoutes:s,label:i}=(null==dk?void 0:null===(a=dk.find)||void 0===a?void 0:a.call(dk,e=>e.id===t))||{};return i+" - "+(null===(n=null==s?void 0:s.find(t=>t.id===e))||void 0===n?void 0:n.label)||""}return(null===(t=dk.find(t=>t.id===e))||void 0===t?void 0:t.label)||""})(t).split(" - ").map(e).join(" - ")).join("; ")}),(0,r.jsx)("td",{children:(0,ej.p6)(t.createdAt,"Pp")}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:()=>(0,K.K4)((0,r.jsx)(el,{rule:t,onChange:l,onRemove:i})),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>i(t.id),children:(0,r.jsx)(eg.Z,{})})]})]},a))}):(0,r.jsx)(ee.aN,{inline:!0})]}),(0,r.jsx)(eZ,{numberOfItems:d,rowsPerPage:c,page:u,onPageChange:e=>m({itemsPage:e}),onRowsPerPageChange:e=>m({itemsPage:0,itemsLimit:e})})]})};var eS=a(34386),e_=a(11588),eD=a(45332),eE=a(57257),eP=a(96013);function eI(e){return String((null==e?void 0:e.id)||(null==e?void 0:e._id)||"")}let eA=e=>{let{onCreated:t}=e,{toggleLoader:a}=(0,ee.U2)(),{t:n}=(0,p.$)("admin"),[s,i]=l.useState({}),[o,d]=l.useState(!1),[c,u]=l.useState(!1),[m,h]=l.useState(null),[x,g]=l.useState(""),j=(0,ev.Nr)(x,300),[f,b]=l.useState([]),[y,N]=l.useState(!1),{name:k,email:w}=s;function Z(e){i(t=>({...t,...e}))}function C(){d(!1),i({}),u(!1),h(null),g(""),b([])}async function S(){try{if(!k||!w)throw Error("Preencha nome e email.");if(c&&!eI(m||{}))throw Error("Selecione o usu\xe1rio de quem herdar as permiss\xf5es.");a(!0,"Salvando novo usu\xe1rio");let e={name:k,email:w,avatar:s.avatar,...c?{inheritFromUserId:eI(m||{})}:{}},n=await J.ZP.post("/user/create-admin",(0,eD.GZ)(e),{headers:{"Content-Type":"multipart/form-data"}});if(a(),n.data.error)throw Error("Erro ao adicionar usu\xe1rio! \n\n"+n.data.error.message);let i=n.data.user;if(i&&(null==t||t(i)),C(),c&&m){let e=Number(n.data.inheritedPermissions)||0;et.Am.success(e?"Usu\xe1rio criado. Permiss\xf5es copiadas de ".concat(m.name||m.email,". A senha foi enviada por email."):"Usu\xe1rio criado. A senha foi enviada por email.")}else et.Am.success("Usu\xe1rio criado. A senha foi enviada por email.")}catch(e){a(),et.Am.error(e.message)}}return l.useEffect(()=>{async function e(){N(!0);try{var e;let t=new URLSearchParams;j&&t.set("search",j),t.set("page","0"),t.set("limit","20");let a=await J.ZP.get("/admin-permission/users?".concat(t.toString()));if(null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.error)return;b(a.data.users||[])}finally{N(!1)}}o&&c&&e()},[j,c,o]),(0,r.jsxs)("div",{className:"user-form",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>d(!0),children:"Novo usu\xe1rio"}),(0,r.jsx)(K.ZP,{showAt:o,onClose:C,children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Novo usu\xe1rio",onGoBack:C}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"avatar",children:(0,r.jsx)(eE.Z,{refId:"prof-avatar",round:!0,maxWidthOrHeight:500,onChange:e=>{Z({avatar:e})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)(eP.Z,{src:s.avatar,layout:"fill"})})})}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Nome",value:k||"",onChange:e=>{e.stopPropagation(),Z({name:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Email",value:w||"",helperText:"Mesmo email usado para login. A senha chega neste endere\xe7o.",type:"email",onChange:e=>{e.stopPropagation(),Z({email:e.target.value})}}),(0,r.jsxs)("div",{className:"inherit-permissions",children:[(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:c,onChange:e=>{let t=e.target.checked;u(t),t||(h(null),g(""))}}),label:"Herdar permiss\xf5es de outro usu\xe1rio"}),(0,r.jsx)("span",{className:"inherit-hint",children:"A pessoa entra nos mesmos eventos e regras de acesso."}),c&&(0,r.jsx)(e_.Z,{className:"inherit-user-select",options:m&&!f.some(e=>eI(e)===eI(m))?[m,...f]:f,getOptionLabel:e=>e.email||e.name||"",isOptionEqualToValue:(e,t)=>
1eI(e)===eI(t),loading:y,loadingText:"Carregando...",noOptionsText:"Nenhum usu\xe1rio com acesso encontrado",value:m,onChange:(e,t)=>h(t),onInputChange:(e,t)=>g(t),renderInput:e=>{var t;return(0,r.jsx)(es.Z,{...e,className:"textfield",label:"Usu\xe1rio de origem",helperText:(null==m?void 0:null===(t=m.events)||void 0===t?void 0:t.length)?"Copia o acesso de ".concat(m.events.length," evento(s)"):"Digite nome ou email de quem j\xe1 tem acesso"})},renderOption:(e,t)=>{let a=eI(t);return(0,l.createElement)("li",{...e,key:a,className:"user-select-list-opt",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:t.avatar,width:40,height:40})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{children:t.name}),(0,r.jsx)("span",{children:t.email})]})]})}})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:C,children:n("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:S,children:n("create")})]})]})]})})})]})};function eT(e){return String((null==e?void 0:e.id)||(null==e?void 0:e._id)||"")}let eR=e=>{let{item:t,onChange:a,onRemove:n}=e,s=!!(null==t?void 0:t.id),{toggleLoader:i}=(0,ee.U2)(),{t:d}=(0,p.$)("admin"),{storedState:c}=(0,o.oR)(),{currentSelectedEvent:u={}}=c||{},{_id:m,title:h}=u,[x,g]=l.useState(""),j=(0,ev.Nr)(x,300),[f,b]=l.useState(!1),[y,N]=l.useState([]),[k,w]=l.useState([]),Z=null==k?void 0:k.map(e=>eT(e)).filter(Boolean),[C,S]=l.useState(""),[_,D]=l.useState(!1),[E,P]=l.useState([]),[I,A]=l.useState([]),T=null==I?void 0:I.map(e=>e.id);async function R(){try{if(!Z.length)return et.Am.error("Selecione os usu\xe1rios!");if(!T.length)return et.Am.error("Selecione as regras de acesso!");i(!0,d("processing"));let e=await J.ZP.post("/admin-permission",{id:null==t?void 0:t.id,usersIds:Z,accessRulesIds:T,eventId:m});if(i(),e.data.error)throw Error(d("error_on_processing")+" \n\n"+e.data.error.message);et.Am.success(d("success_on_processing")),a(),(0,K.Mr)()}catch(e){i(),et.Am.error(e.message)}}async function L(){(null==t?void 0:t.id)&&n&&n(t.id)}return l.useEffect(()=>{async function e(){var e;b(!0);let t=await J.ZP.get("/user/list?search=".concat(j));if(null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.error){b(!1);return}N(t.data.users||[]),b(!1)}(null==j?void 0:j.length)>2&&e()},[j]),l.useEffect(()=>{(async function(){D(!0);let e=await J.ZP.get("/access-rule/list?eventId=".concat(m));P(e.data.items||[]),D(!1)})()},[m]),l.useEffect(()=>{t&&(w((t.users||[]).map(e=>({...e,id:eT(e)}))),A((t.accessRules||[]).map(e=>({...e,id:e.id||e._id}))))},[t]),(0,r.jsx)("div",{className:"access-rules-form user-access-form",children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:(s?"Editar acesso":"Novo acesso")+(h?" \xb7 ".concat(h):""),onGoBack:()=>(0,K.Mr)(),data:{id:null==t?void 0:t.id,updatedAt:null==t?void 0:t.updatedAt,lastUpdatedBy:null==t?void 0:t.lastUpdatedBy}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"user-access-section",children:[(0,r.jsxs)("div",{className:"user-access-section-head",children:[(0,r.jsx)("h3",{children:"Pessoas"}),(0,r.jsx)("span",{children:"Busque um cadastro existente ou crie um novo."})]}),(0,r.jsxs)("div",{className:"user-select-container",children:[(0,r.jsx)(e_.Z,{id:"users",className:"user-select",options:y,getOptionLabel:e=>e.email||e.name||"",isOptionEqualToValue:(e,t)=>eT(e)===eT(t),multiple:!0,loading:f,loadingText:"Carregando...",value:k,onChange:(e,t)=>
1{w(t)},onInputChange:(e,t)=>{g(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"Nome ou email",inputProps:e.inputProps,helperText:"Digite ao menos 3 caracteres para buscar"}),renderTags:e=>e.map(e=>{let t=eT(e);return(0,r.jsxs)("li",{className:"user-select-selected",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:e.avatar,width:36,height:36})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{children:e.name}),(0,r.jsx)("span",{children:e.email})]}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>w(e=>e.filter(e=>eT(e)!==t)),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},t)}),renderOption:(e,t)=>{let{name:a,email:n,avatar:s}=t,i=eT(t);return(0,l.createElement)("li",{...e,key:i,className:"user-select-list-opt",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:s,width:40,height:40})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("span",{children:n})]})]})}}),(0,r.jsx)(eA,{onCreated:function(e){let t=eT(e);t&&w(a=>a.some(e=>eT(e)===t)?a:[...a,{...e,id:t}])}})]})]}),(0,r.jsxs)("div",{className:"user-access-section",children:[(0,r.jsxs)("div",{className:"user-access-section-head",children:[(0,r.jsx)("h3",{children:"Regras de acesso"}),(0,r.jsx)("span",{children:"O que essas pessoas podem ver e editar neste evento."})]}),(0,r.jsx)("div",{className:"access-rules-select-container",children:(0,r.jsx)(e_.Z,{id:"access-rules",className:"access-rules-select",options:E.filter(e=>!T.includes(e.id)),getOptionLabel:e=>"string"==typeof e?e:e.label,multiple:!0,filterSelectedOptions:!0,loading:_,loadingText:"Carregando...",value:I,onChange:(e,t)=>
1{A(t)},onInputChange:(e,t)=>{S(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"Selecione as regras",inputProps:e.inputProps}),renderTags:e=>e.map(e=>(0,r.jsxs)("li",{className:"access-rules-select-selected",children:[(0,r.jsx)("span",{children:e.label}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>A(t=>t.filter(t=>t.id!==e.id)),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e.id)),renderOption:(e,t)=>{let{label:a,id:n}=t;return(0,l.createElement)("li",{...e,key:n,className:"access-rules-select-list-opt"},(0,r.jsx)("span",{children:a}))}})})]}),(0,r.jsxs)("div",{className:"actions",children:[!!(null==t?void 0:t.id)&&(0,r.jsx)(X.Z,{size:"large",className:"remove-btn",onClick:L,style:{minWidth:"unset",height:"unset"},children:(0,r.jsx)(er.Z,{})}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:d("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:R,children:d("save")})]})]})]})})})};function eL(e){return String((null==e?void 0:e.id)||(null==e?void 0:e._id)||"")}let eq=()=>{let{toggleLoader:e}=(0,ee.U2)(),{storedState:t,setStoredState:a}=(0,o.oR)(),n=(null==t?void 0:t.userAccessFilters)||{},{currentSelectedEvent:s}=t||{},[i,r]=l.useState(n.search||""),d=(0,ev.Nr)(i,300),{itemsLimit:c=20,itemsPage:u=0}=n,m=new URLSearchParams;(null==s?void 0:s._id)&&m.set("eventId",s._id),d&&m.set("search",d),m.set("limit",String(c)),m.set("page",String(u));let{data:h,isLoading:v,refresh:x}=(0,eh.Z)("/admin-permission/list?"+m,{enabled:!!(null==s?void 0:s._id)}),p=(null==h?void 0:h.items)||[],g=function(e){let t=new Map;for(let s of e||[]){var a,n;let e=function(e){let t=(e.accessRules||[]).map(e=>String(e.id||e._id||"")).filter(Boolean).sort();return t.join("|")||e.id}(s),i=t.get(e);if(!i){t.set(e,{...s,users:[...s.users||[]]});continue}((null===(a=s.users)||void 0===a?void 0:a.length)||0)>((null===(n=i.users)||void 0===n?void 0:n.length)||0)&&(i.id=s.id,i.lastUpdatedBy=s.lastUpdatedBy);let r=new Set((i.users||[]).map(e=>eL(e)).filter(Boolean));for(let e of s.users||[]){let t=eL(e);!t||r.has(t)||(r.add(t),i.users.push(e))}s.createdAt&&(!i.createdAt||new Date(s.createdAt)<new Date(i.createdAt))&&(i.createdAt=s.createdAt)}return Array.from(t.values())}(p),j=Math.max(0,(Number(null==h?void 0:h.numberOfItems)||g.length)-(p.length-g.length));l.useEffect(()=>{a({userAccessFilters:{...n,search:d,...d!==(n.search||"")?{itemsPage:0}:{}}})},[d]);let f=l.useCallback(e=>{a({userAccessFilters:{...n,...e}})},[n]),b=l.useCallback(t=>{(0,em.Z)({title:"Excluir grupo de acesso",icon:"warning",text:"Deseja realmente remover este grupo de acesso? Os usu\xe1rios deixam de ter essas permiss\xf5es neste evento.",confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{e(!0,"Removendo acesso");let a=await J.ZP.delete("/admin-permission/".concat(t));if(e(),a.data.error)return et.Am.error(a.data.error.message);x(),(0,K.Mr)(),et.Am.success("Acesso removido com sucesso!")}catch(t){e(),et.Am.error((null==t?void 0:t.message)||"Erro ao remover acesso")}}})},[x]),y=l.useCallback((t,a)=>{let n=eL(a);return t?n?void(0,em.Z)({title:"Excluir acesso",icon:"warning",text:"Remover <b>".concat(a.name||a.email||"este usu\xe1rio","</b>").concat(a.email?" (".concat(a.email,")"):""," deste grupo?<br/><br/>A pessoa deixa de ter essas permiss\xf5es neste evento."),confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{e(!0,"Excluindo acesso");let a=await J.ZP.delete("/admin-permission/".concat(t,"/user/").concat(n));if(e(),a.data.error)return et.Am.error(a.data.error.message);x(),et.Am.success("Acesso exclu\xeddo com sucesso!")}catch(t){e(),et.Am.error((null==t?void 0:t.message)||"Erro ao excluir acesso")}}}):et.Am.error("Usu\xe1rio inv\xe1lido"):et.Am.error("Grupo de acesso inv\xe1lido")},[x]),N=l.useCallback(t=>{let a=eL(t);return a?t.email?void(0,em.Z)({title:"Reenviar email de acesso",text:"Uma nova senha ser\xe1 gerada para <b>".concat(t.name||t.email,"</b> (").concat(t.email,") e enviada por email.<br/><br/>A senha atual deixa de funcionar imediatamente."),confirmButtonText:"Sim, gerar senha e reenviar",onConfirm:async()=>{try{e(!0,"Gerando senha e enviando email");let n=await J.ZP.post("/user/resend-admin-credentials/".concat(a));if(e(),n.data.error)return et.Am.error(n.data.error.message);et.Am.success("Email reenviado para ".concat(t.email))}catch(t){e(),et.Am.error((null==t?void 0:t.message)||"Erro ao reenviar email")}}}):et.Am.error("Este usu\xe1rio n\xe3o tem email cadastrado"):et.Am.error("Usu\xe1rio inv\xe1lido")},[]),k=l.useMemo(()=>{let e=new Set;for(let t of g||[])for(let a of t.users||[]){let t=eL(a);t&&e.add(t)}return e.size},[g]);return{loadingData:v,items:g,removeItem:b,removeUserFromGroup:y,resendCredentials:N,refreshData:x,numberOfItems:j,itemsLimit:c,itemsPage:u,setFilters:f,search:i,setSearch:r,userCount:k}};var eM=a(67462),eO=a(23132);let eF=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},{loadingData:a,items:n,removeItem:s,removeUserFromGroup:i,resendCredentials:d,refreshData:c,numberOfItems:m,itemsLimit:h,itemsPage:x,setFilters:p,search:g,setSearch:j,userCount:f}=eq(),[b,y]=l.useState({});function N(e){if(!(null==t?void 0:t._id))return et.Am.error("Selecione um evento primeiro!");
1(0,K.K4)((0,r.jsx)(eR,{item:e,onChange:c,onRemove:s}))}return(0,r.jsxs)("div",{className:"user-access",children:[(0,r.jsxs)("div",{className:"user-access-head",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{children:"Acesso a usu\xe1rios"}),(0,r.jsx)("p",{children:(null==t?void 0:t.title)?"Quem pode entrar no admin de ".concat(t.title):"Pessoas com permiss\xe3o neste evento"})]}),(0,r.jsx)(v.Z,{variant:"contained",startIcon:(0,r.jsx)(eM.Z,{}),onClick:()=>N(),children:"Adicionar acesso"})]}),(0,r.jsxs)("div",{className:"user-access-toolbar",children:[(0,r.jsx)(eu,{value:g,onChange:e=>j((null==e?void 0:e.target.value)||""),className:"search",placeholder:"Buscar por nome ou email"}),!a&&(0,r.jsxs)("div",{className:"user-access-stats",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("b",{children:f})," ",1===f?"pessoa":"pessoas"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("b",{children:m||0})," ",1===(m||0)?"grupo":"grupos"]})]})]}),!a||(null==n?void 0:n.length)?(null==n?void 0:n.length)?(0,r.jsx)("div",{className:"user-access-groups",children:n.map(e=>{var t,a,n,l,o;let c=!!b[e.id],m=(null===(t=e.accessRules)||void 0===t?void 0:t.length)||0,h=(null===(a=e.users)||void 0===a?void 0:a.length)||0,x=(null===(n=e.accessRules)||void 0===n?void 0:n.length)?e.accessRules.map(e=>e.label).filter(Boolean).join(" \xb7 "):"Sem regras";return(0,r.jsxs)("section",{className:"user-access-group ".concat(c?"is-open":"is-collapsed"),children:[(0,r.jsxs)("header",{className:"user-access-group-head",children:[(0,r.jsxs)("button",{type:"button",className:"user-access-group-toggle","aria-expanded":c,onClick:()=>{var t;return t=e.id,void y(e=>({...e,[t]:!e[t]}))},children:[(0,r.jsx)(u.Z,{className:"user-access-chevron"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"user-access-group-title",title:x,children:x}),(0,r.jsxs)("span",{className:"user-access-group-summary",children:[m," ",1===m?"regra":"regras"," \xb7 ",h," ",1===h?"pessoa":"pessoas"]}),c&&(0,r.jsx)("div",{className:"user-access-chips",children:(null===(l=e.accessRules)||void 0===l?void 0:l.length)?e.accessRules.map(e=>(0,r.jsx)("span",{className:"user-access-chip",children:e.label},e._id||e.label)):(0,r.jsx)("span",{className:"user-access-chip muted",children:"Sem regras"})})]})]}),(0,r.jsxs)("div",{className:"user-access-group-meta",children:[e.createdAt&&(0,r.jsx)("span",{children:(0,ej.p6)(e.createdAt,"P")}),(0,r.jsx)(eS.Z,{title:"Editar grupo",children:(0,r.jsx)(X.Z,{onClick:()=>N(e),children:(0,r.jsx)(ep.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Remover grupo",children:(0,r.jsx)(X.Z,{onClick:()=>s(e.id),children:(0,r.jsx)(eg.Z,{})})})]})]}),c&&(0,r.jsx)("ul",{className:"user-access-users",children:(null===(o=e.users)||void 0===o?void 0:o.length)?e.users.map((t,a)=>(0,r.jsxs)("li",{className:"user-access-user",children:[(0,r.jsx)("span",{className:"user-access-avatar",children:(0,r.jsx)(eP.Z,{src:t.avatar,width:44,height:44})}),(0,r.jsxs)("div",{className:"user-access-identity",children:[(0,r.jsx)("strong",{children:t.name||"Sem nome"}),(0,r.jsx)("span",{children:t.email||"Sem email"})]}),(0,r.jsxs)("div",{className:"user-access-user-actions",children:[(0,r.jsx)(v.Z,{className:"resend-btn",variant:"outlined",startIcon:(0,r.jsx)(eO.Z,{}),onClick:()=>d(t),disabled:!t.email,children:"Reenviar email"}),(0,r.jsx)(v.Z,{className:"remove-user-btn",variant:"outlined",color:"error",startIcon:(0,r.jsx)(eg.Z,{}),onClick:()=>i(e.id,t),children:"Excluir"})]})]},function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return String((null==e?void 0:e.id)||(null==e?void 0:e._id)||t)}(t,String(a)))):(0,r.jsx)("li",{className:"user-access-user empty",children:"Nenhuma pessoa neste grupo"})})]},e.id)})}):(0,r.jsxs)("div",{className:"user-access-empty",children:[(0,r.jsx)("strong",{children:"Ningu\xe9m com acesso neste evento"}),(0,r.jsx)("span",{children:"Adicione pessoas e escolha as regras que cada uma pode usar."})]}):(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsx)(eZ,{numberOfItems:m,rowsPerPage:h,page:x,onPageChange:e=>p({itemsPage:e}),onRowsPerPageChange:e=>p({itemsPage:0,itemsLimit:e})})]})};var eB=a(52186),eU=a(72428);let ez="permissionUsersFilters",eV=()=>{let{toggleLoader:e}=(0,ee.U2)(),{storedState:t,setStoredState:a}=(0,o.oR)(),n=(null==t?void 0:t[ez])||{},[s,i]=l.useState(n.search||""),r=(0,ev.Nr)(s,300),d=n.itemsPage||0,c=new URLSearchParams;r&&c.set("search",r),c.set("page",String(d)),c.set("limit","20");let{data:u,isLoading:m,error:h,refresh:v}=(0,eh.Z)("/admin-permission/users?".concat(c.toString())),x=Array.isArray(null==u?void 0:u.users)?u.users:[],p=Number(null==u?void 0:u.total)||0;l.useEffect(()=>{a({[ez]:{...n,search:r,...r!==(n.search||"")?{itemsPage:0}:{}}})},[r]);let g=l.useCallback(e=>{a({[ez]:{...n,...e}})},[n]),j=l.useCallback(async(t,a,n)=>{var s;e(!0,"Adicionando eventos");let i=await J.ZP.post("/admin-permission/users/".concat(t,"/events"),{eventIds:a,accessRulesIds:n});if(e(),null===(s=i.data)||void 0===s?void 0:s.error)throw Error(i.data.error.message);et.Am.success("Evento adicionado"),v()},[v,e]),f=l.useCallback(async(t,a,n)=>{var s;e(!0,"Salvando regras");let i=await J.ZP.put("/admin-permission/users/".concat(t,"/events/").concat(a,"/rules"),{accessRulesIds:n});if(e(),null===(s=i.data)||void 0===s?void 0:s.error)throw Error(i.data.error.message);et.Am.success("Regras atualizadas"),v()},[v,e]),b=l.useCallback((e,t)=>{let a=t.map(e=>
1e.title).filter(Boolean),n=a.slice(0,8).map(e=>"• ".concat(e)).join("<br/>"),s=a.length>8?"<br/>• e mais ".concat(a.length-8):"";return new Promise(a=>{(0,em.Z)({title:1===t.length?"Remover evento":"Remover eventos",icon:"warning",text:1===t.length?"Tirar <b>".concat(e.name||e.email,"</b> de <b>").concat(t[0].title,"</b>?<br/><br/>A pessoa deixa de ter acesso a esse evento."):"Tirar <b>".concat(e.name||e.email,"</b> de <b>").concat(t.length," eventos</b>?<br/><br/>").concat(n).concat(s,"<br/><br/>A pessoa deixa de ter acesso a esses eventos."),confirmButtonText:1===t.length?"Sim, remover":"Sim, remover ".concat(t.length),onConfirm:()=>a(!0),onCancel:()=>a(!1)})})},[]),y=l.useCallback(async(e,t)=>{var a,n,s;if(t.length>1)try{let n=await J.ZP.post("/admin-permission/users/".concat(e,"/events/remove"),{eventIds:t});if(!(null===(a=n.data)||void 0===a?void 0:a.error))return t;throw Error(n.data.error.message)}catch(t){let e=null==t?void 0:null===(n=t.response)||void 0===n?void 0:n.status;if(e&&404!==e||!e&&(null==t?void 0:t.message)&&!/404|not found/i.test(String(t.message)))throw t}let i=[];for(let a of t){let t=await J.ZP.delete("/admin-permission/users/".concat(e,"/events/").concat(a));if(null===(s=t.data)||void 0===s?void 0:s.error)throw Error(t.data.error.message);i.push(a)}return i},[]),N=l.useCallback(async(t,a)=>{let n=a.filter((e,t,a)=>(null==e?void 0:e.id)&&a.findIndex(t=>t.id===e.id)===t);if(!n.length)return[];let s=await b(t,n);if(!s)return[];try{e(!0,1===n.length?"Removendo evento":"Removendo eventos");let a=await y(t.id,n.map(e=>e.id));return e(),v(),et.Am.success(1===a.length?"Evento removido":"".concat(a.length," eventos removidos")),a}catch(t){var i,r,l;return e(),v(),et.Am.error((null==t?void 0:null===(i=t.response)||void 0===i?void 0:null===(r=i.data)||void 0===r?void 0:null===(l=r.error)||void 0===l?void 0:l.message)||(null==t?void 0:t.message)||"Erro ao remover evento"),[]}},[b,v,y,e]),k=l.useCallback((e,t)=>N(e,[t]),[N]),w=l.useCallback(t=>{if(!t.email)return et.Am.error("Este usu\xe1rio n\xe3o tem email cadastrado");(0,em.Z)({title:"Reenviar email de acesso",text:"Uma nova senha ser\xe1 gerada para <b>".concat(t.name||t.email,"</b> (").concat(t.email,") e enviada por email.<br/><br/>A senha atual deixa de funcionar imediatamente."),confirmButtonText:"Sim, gerar senha e reenviar",onConfirm:async()=>{try{var a;e(!0,"Gerando senha e enviando email");let n=await J.ZP.post("/user/resend-admin-credentials/".concat(t.id));if(e(),null===(a=n.data)||void 0===a?void 0:a.error)return et.Am.error(n.data.error.message);et.Am.success("Email reenviado para ".concat(t.email))}catch(t){e(),et.Am.error((null==t?void 0:t.message)||"Erro ao reenviar email")}}})},[e]),Z=l.useCallback(t=>{(0,em.Z)({title:"Excluir acesso",icon:"warning",text:"Remover <b>".concat(t.name||t.email,"</b> de <b>todos os eventos</b>?<br/><br/>A pessoa deixa de ter acesso ao admin desses eventos."),confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{var a;e(!0,"Excluindo acesso");let n=await J.ZP.delete("/admin-permission/users/".concat(t.id));if(e(),null===(a=n.data)||void 0===a?void 0:a.error)return et.Am.error(n.data.error.message);v(),(0,K.Mr)(),et.Am.success("Acesso exclu\xeddo")}catch(t){e(),et.Am.error((null==t?void 0:t.message)||"Erro ao excluir acesso")}}})},[v,e]);return{loadingData:m,items:x,numberOfItems:p,itemsLimit:20,itemsPage:d,setFilters:g,search:s,setSearch:i,error:h,addEvents:j,updateRules:f,removeEvent:k,removeEvents:N,resendCredentials:w,removeUser:Z,refreshData:v}};function eG(e){return String((null==e?void 0:e._id)||e.id||"")}let eW=e=>{let{user:t,events:a,onSave:n}=e,s=(t.events||[]).map(e=>e.id),i=(Array.isArray(a)?a:[]).filter(e=>!s.includes(eG(e))),[o,d]=l.useState([]),[c,u]=l.useState([]),[m,h]=l.useState([]),[x,p]=l.useState(!1),[g,j]=l.useState(!1),f=eG(o[0]||{});async function b(){if(!o.length)return et.Am.error("Selecione um evento");if(!m.length)return et.Am.error("Selecione as regras de acesso");try{j(!0),await n(o.map(e=>eG(e)),m.map(e=>e.id)),(0,K.Mr)()}catch(e){et.Am.error((null==e?void 0:e.message)||"Erro ao adicionar evento")}finally{j(!1)}}return l.useEffect(()=>{(async function(){var e;if(!f){u([]),h([]);return}p(!0);let t=await J.ZP.get("/access-rule/list?eventId=".concat(f,"&limit=200"));p(!1),null!==(e=t.data)&&void 0!==e&&e.error||u(t.data.items||[])})()},[f]),(0,r.jsx)("div",{className:"access-rules-form user-events-form",children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Adicionar evento \xb7 ".concat(t.name||t.email),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(e_.Z,{options:i,getOptionLabel:e=>e.title||"",isOptionEqualToValue:(e,t)=>
1eG(e)===eG(t),value:o,multiple:!0,onChange:(e,t)=>d(t),renderInput:e=>(0,r.jsx)(es.Z,{...e,label:"Eventos",helperText:"Selecione os eventos que essa pessoa pode acessar"})}),(0,r.jsx)(e_.Z,{options:c,getOptionLabel:e=>e.label||"",isOptionEqualToValue:(e,t)=>e.id===t.id,value:m,multiple:!0,loading:x,disabled:!f,onChange:(e,t)=>h(t),renderInput:e=>(0,r.jsx)(es.Z,{...e,label:"Regras de acesso",helperText:f?"Quais telas essa pessoa pode usar nesses eventos":"Escolha um evento primeiro"})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,disabled:g,children:"Salvar"})]})]})]})})})},e$=e=>{var t,a;let{user:n,onSave:s}=e,[i,o]=l.useState((null===(t=n.events)||void 0===t?void 0:null===(a=t[0])||void 0===a?void 0:a.id)||""),[d,c]=l.useState([]),[u,m]=l.useState([]),[h,x]=l.useState(!1),[p,g]=l.useState(!1);async function j(){if(!i)return et.Am.error("Selecione um evento");if(!u.length)return et.Am.error("Selecione ao menos uma regra");try{g(!0),await s(i,u.map(e=>e.id)),(0,K.Mr)()}catch(e){et.Am.error((null==e?void 0:e.message)||"Erro ao salvar regras")}finally{g(!1)}}return l.useEffect(()=>{(async function(){var e,t;if(!i){c([]),m([]);return}x(!0);let a=await J.ZP.get("/access-rule/list?eventId=".concat(i,"&limit=200"));if(x(!1),null===(e=a.data)||void 0===e?void 0:e.error)return;let s=a.data.items||[];c(s);let r=new Set(((null===(t=n.events.find(e=>e.id===i))||void 0===t?void 0:t.rules)||[]).map(e=>e.id));m(s.filter(e=>r.has(e.id)))})()},[i,n.events]),(0,r.jsx)("div",{className:"access-rules-form user-events-form",children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Editar regras \xb7 ".concat(n.name||n.email),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{select:!0,label:"Evento",value:i,onChange:e=>o(e.target.value),SelectProps:{native:!0},children:n.events.map(e=>(0,r.jsx)("option",{value:e.id,children:e.title},e.id))}),(0,r.jsx)(e_.Z,{options:d,getOptionLabel:e=>e.label||"",isOptionEqualToValue:(e,t)=>e.id===t.id,value:u,multiple:!0,loading:h,onChange:(e,t)=>
1m(t),renderInput:e=>(0,r.jsx)(es.Z,{...e,label:"Regras de acesso",helperText:"O que essa pessoa pode ver neste evento"})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:j,disabled:p||!i,children:"Salvar"})]})]})]})})})},eH=e=>{let{user:t,onRemoveEvents:a}=e,[n,s]=l.useState(t.events||[]),[i,o]=l.useState([]),d=n.filter(e=>i.includes(e.id)),c=n.length>0&&i.length===n.length,u=i.length>0&&!c;async function m(e){if(!e.length)return;let t=new Set(e);s(e=>e.filter(e=>!t.has(e.id))),o(e=>e.filter(e=>!t.has(e)))}async function h(e){await m(await a([e]))}async function x(){d.length&&await m(await a(d))}return(0,r.jsx)("div",{className:"access-rules-form user-events-form",children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Eventos de bilheteria",subTitle:[t.name,t.email].filter(Boolean).join(" - "),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[n.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"user-events-all-toolbar",children:[(0,r.jsxs)("label",{className:"user-events-all-select",children:[(0,r.jsx)(en.Z,{size:"small",checked:c,indeterminate:u,onChange:function(){o(c?[]:n.map(e=>e.id))}}),(0,r.jsx)("span",{children:c?"Desmarcar todos":"Selecionar todos"})]}),(0,r.jsx)(v.Z,{className:"remove-selected-btn",variant:"outlined",color:"error",startIcon:(0,r.jsx)(eg.Z,{}),disabled:!d.length,onClick:x,children:d.length?"Excluir ".concat(d.length):"Excluir selecionados"})]}),(0,r.jsx)("ul",{className:"user-events-all",children:n.map(e=>{let t=i.includes(e.id);return(0,r.jsxs)("li",{className:"user-events-all-item".concat(t?" is-selected":""),children:[(0,r.jsxs)("label",{className:"user-events-all-main",children:[(0,r.jsx)(en.Z,{size:"small",checked:t,onChange:()=>{var t;return t=e.id,void o(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:e.title}),(0,r.jsx)("div",{className:"user-events-chips",children:e.rules.length?e.rules.map(e=>(0,r.jsx)("span",{className:"user-events-chip",children:e.label},e.id)):(0,r.jsx)("span",{className:"user-events-chip muted",children:"Sem regras"})})]})]}),(0,r.jsx)(X.Z,{color:"error",title:"Remover evento",onClick:()=>h(e),children:(0,r.jsx)(eg.Z,{})})]},e.id)})})]}):(0,r.jsx)("div",{className:"user-events-all-empty",children:"Nenhum evento restante neste acesso."}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,startIcon:(0,r.jsx)(ec.Z,{}),children:"Fechar"})})]})]})})})},eJ={"super-admin":"Super Admin",admin:"Admin",professional:"Profissional",supplier:"Cotista",user:"Usu\xe1rio"},eQ=()=>{let{loadingData:e,items:t,numberOfItems:a,itemsPage:n,setFilters:s,search:i,setSearch:l,error:o,addEvents:d,updateRules:c,removeEvent:u,removeEvents:m,resendCredentials:h,removeUser:x}=eV(),{data:p}=(0,eh.Z)("/ticket/events/list?"),g=Array.isArray(p)?p:[];function j(e){(0,K.K4)((0,r.jsx)(eW,{user:e,events:g,onSave:(t,a)=>d(e.id,t,a)}))}return(0,r.jsxs)("div",{className:"user-events",children:[(0,r.jsx)("div",{className:"user-events-head",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{children:"N\xedveis de permiss\xe3o"}),(0,r.jsx)("p",{children:"Todos os usu\xe1rios com acesso, em todos os eventos."})]})}),(0,r.jsx)(eu,{value:i,onChange:e=>{var t;return l((null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value)||"")},className:"search",placeholder:"Buscar por nome ou email"}),o?(0,r.jsx)("div",{className:"empty",children:"N\xe3o foi poss\xedvel carregar os usu\xe1rios. Tente de novo."}):!e||(null==t?void 0:t.length)?(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Nome"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Perfil"}),(0,r.jsx)("th",{children:"Eventos"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),(0,r.jsxs)("tbody",{children:[t.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"name-cell",children:e.name||"-"}),(0,r.jsx)("td",{children:e.email||"-"}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"badge ".concat("super-admin"===e.role?"badge-on":"badge-off"),children:eJ[e.role||""]||e.role||"Sem perfil"})}),(0,r.jsx)("td",{children:function(e){let t=e.events||[],a=t.slice(0,2),n=t.length-a.length;return(0,r.jsxs)("div",{className:"user-events-cell",children:[a.map(t=>(0,r.jsxs)("span",{className:"user-events-chip",children:[t.title,(0,r.jsx)(X.Z,{size:"small",title:"Remover evento",onClick:()=>u(e,t),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},t.id)),n>0&&(0,r.jsxs)("button",{type:"button",className:"user-events-more",onClick:()=>{(0,K.K4)((0,r.jsx)(eH,{user:e,onRemoveEvents:t=>m(e,t)}))},children:[(0,r.jsx)(eB.Z,{})," Ver todos (",t.length,")"]}),(0,r.jsx)(eS.Z,{title:"Adicionar evento",children:(0,r.jsx)(X.Z,{className:"add-event-btn",onClick:()=>j(e),children:(0,r.jsx)(eU.Z,{})})})]})}(e)}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(v.Z,{className:"action-btn",variant:"outlined",startIcon:(0,r.jsx)(ep.Z,{}),onClick:()=>(function(e){var t;if(!(null===(t=e.events)||void 0===t?void 0:t.length))return j(e);(0,K.K4)((0,r.jsx)(e$,{user:e,onSave:(t,a)=>c(e.id,t,a)}))})(e),children:"Editar"}),(0,r.jsx)(v.Z,{className:"action-btn",variant:"outlined",startIcon:(0,r.jsx)(eO.Z,{}),onClick:()=>h(e),disabled:!e.email,children:"Reenviar email"}),(0,r.jsx)(v.Z,{className:"action-btn remove-btn",variant:"outlined",color:"error",startIcon:(0,r.jsx)(eg.Z,{}),onClick:()=>x(e),children:"Excluir"})]})]},e.id)),!e&&!t.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:5,className:"empty",children:"Nenhum usu\xe1rio com acesso encontrado"})})]})]})}):(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsx)(eZ,{numberOfItems:a,rowsPerPage:20,page:0===a?0:n,onPageChange:e=>s({itemsPage:e}),onRowsPerPageChange:()=>void 0})]})},eY={create_admin_user:{label:"Criou usu\xe1rio",tone:"ok",text:"criou o usu\xe1rio admin"},create_admin_permission:{label:"Criou acesso",tone:"ok",text:"criou um grupo de acesso"},update_admin_permission:{label:"Editou acesso",tone:"blue",text:"editou um grupo de acesso"},add_user_events:{label:"Adicionou evento",tone:"ok",text:"adicionou evento(s) para"},update_user_event_rules:{label:"Editou regras",tone:"blue",text:"alterou as regras de"}
1,resend_admin_credentials:{label:"Reenviou email",tone:"warn",text:"gerou senha nova e reenviou o email para"},remove_admin_permission_user:{label:"Excluiu acesso",tone:"danger",text:"tirou o acesso de"},remove_admin_permission:{label:"Excluiu grupo",tone:"danger",text:"removeu um grupo de acesso"},remove_user_event:{label:"Removeu evento",tone:"danger",text:"removeu um evento de"},remove_user_all_access:{label:"Excluiu acessos",tone:"danger",text:"removeu todos os acessos de"},delete_user:{label:"Excluiu usu\xe1rio",tone:"danger",text:"excluiu o usu\xe1rio"},delete_professional:{label:"Excluiu profissional",tone:"danger",text:"excluiu o profissional"},cancel_coupons:{label:"Cancelou cupons",tone:"warn",text:"cancelou cupons"},remove_ticket_blocked_days:{label:"Liberou dias",tone:"blue",text:"removeu dias bloqueados de"},set_campaign_success:{label:"CRM ok",tone:"ok",text:"enviou campanha com sucesso para"},set_campaign_error:{label:"CRM erro",tone:"danger",text:"falhou ao enviar campanha para"},set_campaign_skipped:{label:"CRM ignorado",tone:"warn",text:"ignorou a campanha de"},set_campaign_integrated_crm_pending:{label:"CRM pendente",tone:"warn",text:"deixou a campanha pendente de"},set_campaign_http_error:{label:"CRM HTTP",tone:"danger",text:"teve erro HTTP na campanha"}},eK=[{id:"system",label:"Sistema",hint:"Usu\xe1rios, permiss\xf5es, senhas, cupons e dias bloqueados — sem campanhas do CRM."},{id:"crm",label:"CRM",hint:"Envio de campanhas: sucesso, erro, ignorado, pendente e falha HTTP."}],eX=[{id:"",label:"Todos"},{id:"create,add_user_events",label:"Criou"},{id:"update,update_user_event_rules",label:"Editou"},{id:"resend",label:"Reenviou"},{id:"remove,delete,cancel",label:"Excluiu"},{id:"coupon,ticket",label:"Ingressos"},{id:"error,http_error",label:"Erros"}],e0=[{id:"",label:"Todos"},{id:"set_campaign_success",label:"Ok"},{id:"set_campaign_error",label:"Erro"},{id:"set_campaign_skipped",label:"Ignorado"},{id:"set_campaign_integrated_crm_pending",label:"Pendente"},{id:"set_campaign_http_error",label:"HTTP"}];function e1(e){return Array.isArray(e)?e:[]}let e2=()=>{var e;let{user:t}=(0,d.aC)(),[a,n]=l.useState(""),s=(0,ev.Nr)(a,300),[i,o]=l.useState("system"),[c,u]=l.useState(""),[m,h]=l.useState(0),v=(null==t?void 0:null===(e=t.email)||void 0===e?void 0:e.toLowerCase())==="[email protected]",x=eK.find(e=>e.id===i)||eK[0],p=new URLSearchParams;p.set("scope",i),s&&p.set("search",s),c&&p.set("actionMatch",c),p.set("page",String(m)),p.set("limit",String(20));let{data:g,isLoading:j}=(0,eh.Z)("/log-action/list?".concat(p.toString()),{enabled:v}),f=(null==g?void 0:g.logs)||[],b=(null==g?void 0:g.total)||0;return(l.useEffect(()=>{h(0)},[s,c,i]),v)?(0,r.jsxs)("div",{className:"access-logs",children:[(0,r.jsx)("div",{className:"access-logs-head",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{children:"Logs"}),(0,r.jsx)("p",{children:x.hint})]})}),(0,r.jsx)("div",{className:"access-logs-scopes",children:eK.map(e=>(0,r.jsx)("button",{type:"button",className:i===e.id?"active":"",onClick:()=>{o(e.id),u(""),n("")},children:e.label},e.id))}),(0,r.jsx)(eu,{value:a,onChange:e=>{var t;return n((null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value)||"")},className:"search",placeholder:"crm"===i?"Buscar por pessoa, email ou campanha":"Buscar por pessoa, email, a\xe7\xe3o ou cole\xe7\xe3o"}),(0,r.jsx)("div",{className:"access-logs-filters",children:("crm"===i?e0:eX).map(e=>(0,r.jsx)("button",{type:"button",className:c===e.id?"active":"",onClick:()=>u(e.id),children:e.label},e.id||"all"))}),j&&!f.length?(0,r.jsx)(ee.aN,{inline:!0}):f.length?(0,r.jsx)("ul",{className:"access-logs-list",children:f.map(e=>{let t=function(e){var t,a,n,s,i;let r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return String(e).replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}(e.action)||"A\xe7\xe3o",l=eY[e.action]||{label:r,tone:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.toLowerCase();return/(error|fail|delete|remove|cancel)/.test(t)?"danger":/(skip|pending|resend|warn|http)/.test(t)?"warn":/(success|create|add)/.test(t)?"ok":"blue"}(e.action),text:r.toLowerCase()},o=(null===(t=e.performedBy)||void 0===t?void 0:t.name)||(null===(a=e.performedBy)||void 0===a?void 0:a.email)||"Sistema",d=(null===(n=e.target)||void 0===n?void 0:n.name)||(null===(s=e.target)||void 0===s?void 0:s.email)||(null===(i=e.target)||void 0===i?void 0:i.id);return{...l,who:o,target:d,sentence:d?"".concat(o," ").concat(l.text," ").concat(d):"".concat(o," ").concat(l.text),detail:function(e){var t,a,n,s;let i=e.payload&&"object"==typeof e.payload?e.payload:{},r=e.result&&"object"==typeof e.result?e.result:{},l=(null===(t=e.target)||void 0===t?void 0:t.data)||{},o=[];if((null===(a=e.target)||void 0===a?void 0:a.email)&&o.push(e.target.email),(null===(n=e.target)||void 0===n?void 0:n.collection)&&!["users","admin-permissions"].includes(e.target.collection)&&o.push(e.target.collection),i.campaignType&&o.push(i.campaignType),"add_user_events"===e.action&&e1(i.eventIds).length&&o.push("".concat(i.eventIds.length," evento(s)")),"update_user_event_rules"===e.action&&e1(i.accessRulesIds).length&&o.push("".concat(i.accessRulesIds.length," regra(s)")),"remove_user_event"===e.action){let e=e1(i.events).map(e=>
1null==e?void 0:e.title).filter(Boolean),t=e1(i.eventIds);e.length?o.push(e.join(", ")):i.eventTitle?o.push(i.eventTitle):t.length?o.push("".concat(t.length," evento(s)")):l.eventId&&o.push("1 evento")}return"remove_user_all_access"===e.action&&e1(null===(s=i.result)||void 0===s?void 0:s.removed).length&&o.push("".concat(i.result.removed.length," evento(s)")),"cancel_coupons"===e.action&&(null!=r.cancelled&&o.push("".concat(r.cancelled," cancelado(s)")),null!=r.submitted&&o.push("".concat(r.submitted," enviado(s)"))),"remove_ticket_blocked_days"===e.action&&null!=r.removedCount&&o.push("".concat(r.removedCount," dia(s)")),"string"==typeof e.result&&o.push(e.result),r.status&&"string"==typeof r.status&&o.push(r.status),[...new Set(o.filter(Boolean))].join(" \xb7 ")}(e)}}(e);return(0,r.jsxs)("li",{className:"access-logs-item",children:[(0,r.jsx)("span",{className:"badge tone-".concat(t.tone),children:t.label}),(0,r.jsxs)("div",{className:"access-logs-body",children:[(0,r.jsx)("strong",{children:t.sentence}),t.detail?(0,r.jsx)("span",{children:t.detail}):null]}),(0,r.jsx)("time",{children:e.createdAt?(0,ej.p6)(e.createdAt,"Pp"):"-"})]},e.id)})}):(0,r.jsx)("div",{className:"access-logs-empty",children:"Nenhum log encontrado"}),(0,r.jsx)(eZ,{numberOfItems:b,rowsPerPage:20,page:m,onPageChange:h,onRowsPerPageChange:()=>void 0})]}):(0,r.jsx)("div",{className:"access-logs",children:(0,r.jsx)("div",{className:"access-logs-empty",children:"Voc\xea n\xe3o tem permiss\xe3o para ver estes logs."})})},e3={credit_card:"Cr\xe9dito",debit_card:"D\xe9bito",pix:"PIX",cash:"Dinheiro"},e6={email_already_exists:"J\xe1 existe um usu\xe1rio com este email",email_required:"Email obrigat\xf3rio",email_invalid:"Email inv\xe1lido",name_required:"Nome obrigat\xf3rio",card_machine_device_required:"Selecione uma maquininha",card_machine_device_not_found:"Maquininha n\xe3o encontrada",card_machine_device_event_mismatch:"A maquininha n\xe3o pertence a este evento",card_machine_serial_already_exists:"J\xe1 existe uma maquininha com este n\xfamero de s\xe9rie neste evento",card_machine_device_has_operators:"Esta maquininha ainda tem operadores vinculados. Desvincule ou exclua os operadores antes.",not_a_card_machine_operator:"Este usu\xe1rio n\xe3o \xe9 um operador de maquininha",cannot_delete_self:"N\xe3o \xe9 poss\xedvel excluir a pr\xf3pria conta por aqui",cannot_reset_own_password_here:"N\xe3o \xe9 poss\xedvel redefinir a pr\xf3pria senha por aqui",user_not_found:"Operador n\xe3o encontrado",card_machine_device_event_required:"Selecione um evento",card_machine_device_model_name_required:"Modelo obrigat\xf3rio",card_machine_device_serial_number_required:"N\xfamero de s\xe9rie obrigat\xf3rio",card_machine_device_description_required:"Descri\xe7\xe3o obrigat\xf3ria"};function e5(e){var t,a,n;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Erro ao processar",i=(null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:null===(n=a.error)||void 0===n?void 0:n.message)||(null==e?void 0:e.message)||"";if(e6[i])return e6[i];if("string"==typeof i&&i.trim()){let e=i.split("\n").map(e=>e6[e]||e).join("\n");return e}return s}function e8(e){return e?[e.modelName,e.serialNumber,e.description].filter(Boolean).join(" \xb7 "):"Sem maquininha"}var e7=a(96406);let e4=e=>{let{password:t,emailSent:a,email:n,title:s,onClose:i}=e;async function l(){try{await navigator.clipboard.writeText(t),et.Am.success("Senha copiada")}catch(e){et.Am.error("N\xe3o foi poss\xedvel copiar a senha")}}return(0,r.jsx)("div",{className:"add-form modal-container forms operators-password-notice",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:s||"Senha do operador",onGoBack:i}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("p",{children:a?"A senha foi enviada para ".concat(n||"o email do operador",". Guarde uma c\xf3pia se precisar entregar no balc\xe3o."):"O email n\xe3o foi enviado. Copie a senha e entregue ao operador."}),(0,r.jsxs)("div",{className:"password-box",children:[(0,r.jsx)(es.Z,{label:"Senha",value:t,InputProps:{readOnly:!0}}),(0,r.jsx)(X.Z,{onClick:l,title:"Copiar senha",children:(0,r.jsx)(e7.Z,{})})]}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:i,children:"Entendi"})})]})]})})},e9="cardMachineOperatorFilters",te=()=>{var e,t,a,n;let{toggleLoader:s}=(0,ee.U2)(),{storedState:i,setStoredState:d}=(0,o.oR)(),{currentSelectedEvent:c}=i||{},u=(null==c?void 0:c._id)||"",m=(null==i?void 0:i[e9])||{},[h,v]=l.useState(m.tab||"operators"),[x,p]=l.useState(m.search||""),g=(0,ev.Nr)(x,300),{itemsLimit:j=20,itemsPage:f=0,devicesLimit:b=20,devicesPage:y=0}=m,N=new URLSearchParams;u&&N.set("eventId",u),g&&N.set("search",g),N.set("limit",String(j)),N.set("page",String(f));let k=new URLSearchParams;u&&k.set("eventId",u),g&&k.set("search",g),k.set("limit",String(b)),k.set("page",String(y));let w=(0,eh.Z)("/user-card-machine-operators?".concat(N.toString()),{enabled:!!u}),Z=(0,eh.Z)("/card-machine-devices?".concat(k.toString()),{enabled:!!u}),C=(null===(e=w.data)||void 0===e?void 0:e.items)||[],S=(null===(t=Z.data)||void 0===t?void 0:t.items)||[],_=Number(null===(a=w.data)||void 0===a?void 0:a.numberOfItems)||0,D=Number(null===(n=Z.data)||void 0===n?void 0:n.numberOfItems)||0,E=l.useCallback(e=>{d({[e9]:{...m,...e}})},[m,d]),P=l.useCallback(e=>{v(e),E({tab:e})},[E]),I=l.useCallback(()=>{w.refresh(),Z.refresh()},[w,Z]),A=l.useCallback(e=>{e.password&&window.setTimeout(()=>{(0,K.K4)((0,r.jsx)(e4,{password:e.password,emailSent:!!e.emailSent,email:e.email,title:e.title,onClose:K.Mr}))},250)},[]),T=l.useCallback(e=>{if(!(null==e?void 0:e.id)||!e.email)return et.Am.error("Este operador n\xe3o tem email cadastrado");(0,em.Z)({title:"Gerar nova senha",text:"Uma nova senha ser\xe1 gerada para <b>".concat(e.name||e.email,"</b> (").concat(e.email,") e enviada por email.<br/><br/>A senha atual deixa de funcionar imediatamente."),confirmButtonText:"Sim, gerar senha e enviar email",onConfirm:async()=>{try{var t;s(!0,"Gerando senha");let a=await J.ZP.post("/user-card-machine-operators/".concat(e.id,"/regenerate-password"),{sendEmail:!0});if(s(),null===(t=a.data)||void 0===t?void 0:t.error)return et.Am.error(e5(a.data.error));I(),A({password:a.data.generatedPassword,emailSent:a.data.emailSent,email:e.email,title:"Nova senha do operador"}),a.data.emailSent?et.Am.success("Email enviado para ".concat(e.email)):et.Am.warn("Senha gerada, mas o email n\xe3o foi enviado. Copie a senha no aviso.")}
1catch(e){s(),et.Am.error(e5(e,"Erro ao gerar senha"))}}})},[I,A,s]),R=l.useCallback(e=>{(0,em.Z)({title:"Excluir operador",icon:"warning",text:"Remover o operador <b>".concat(e.name||e.email,"</b>?<br/><br/>Ele deixa de acessar a maquininha deste evento."),confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{var t;s(!0,"Excluindo operador");let a=await J.ZP.delete("/user-card-machine-operators/".concat(e.id));if(s(),null===(t=a.data)||void 0===t?void 0:t.error)return et.Am.error(e5(a.data.error));I(),(0,K.Mr)(),et.Am.success("Operador exclu\xeddo")}catch(e){s(),et.Am.error(e5(e,"Erro ao excluir operador"))}}})},[I,s]),L=l.useCallback(e=>{(0,em.Z)({title:"Excluir maquininha",icon:"warning",text:"Remover a maquininha <b>".concat(e.modelName," \xb7 ").concat(e.serialNumber,"</b>?<br/><br/>S\xf3 \xe9 poss\xedvel se n\xe3o houver operador vinculado."),confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{var t;s(!0,"Excluindo maquininha");let a=await J.ZP.delete("/card-machine-devices/".concat(e.id));if(s(),null===(t=a.data)||void 0===t?void 0:t.error)return et.Am.error(e5(a.data.error));I(),(0,K.Mr)(),et.Am.success("Maquininha exclu\xedda")}catch(e){s(),et.Am.error(e5(e,"Erro ao excluir maquininha"))}}})},[I,s]);return{eventId:u,eventTitle:(null==c?void 0:c.title)||"",tab:h,onChangeTab:P,search:x,setSearch:p,operators:C,devices:S,operatorsCount:_,devicesCount:D,operatorsLoading:w.isLoading,devicesLoading:Z.isLoading,itemsLimit:j,itemsPage:f,devicesLimit:b,devicesPage:y,setFilters:E,refresh:I,regeneratePassword:T,removeOperator:R,removeDevice:L,showGeneratedPassword:A}};var tt=a(94054),ta=a(54109),tn=a(18360),ts=a(23599),ti=a(56815),tr=a(45843);let tl=e=>{var t;let{operator:a,eventId:n,eventTitle:s,onSave:i}=e,o=!!(null==a?void 0:a.id),{toggleLoader:d}=(0,ee.U2)(),[c,u]=l.useState([]),[m,h]=l.useState((null==a?void 0:a.name)||""),[x,p]=l.useState((null==a?void 0:a.email)||""),[g,j]=l.useState((null==a?void 0:null===(t=a.cardMachineDevice)||void 0===t?void 0:t.id)||(null==a?void 0:a.cardMachineDeviceId)||""),[f,b]=l.useState(!o),[y,N]=l.useState(""),[k,w]=l.useState(!o),[Z,C]=l.useState({});async function S(){try{var e;if(!n)return et.Am.error("Selecione um evento primeiro!");if(!function(){let e={};return m.trim()||(e.name="Nome obrigat\xf3rio"),x.trim()?(0,eD.oH)(x.trim())||(e.email="Email inv\xe1lido"):e.email="Email obrigat\xf3rio",g||(e.cardMachineDeviceId="Selecione uma maquininha"),f||o&&!y||(y?!(y.length<8)&&(0,eD.hi)(y)||(e.password="Use no m\xednimo 8 caracteres, com letra mai\xfascula, min\xfascula e n\xfamero"):e.password="Senha obrigat\xf3ria"),C(e),!Object.keys(e).length}())return et.Am.error("Preencha os campos obrigat\xf3rios");d(!0,o?"Salvando operador":"Criando operador");let t={name:m.trim(),email:x.trim(),cardMachineDeviceId:g,eventId:n,sendEmail:k};f?(t.generatePassword=!0,t.password=""):y&&(t.password=y);let s=o?await J.ZP.put("/user-card-machine-operators/".concat(a.id),t):await J.ZP.post("/user-card-machine-operators",t);if(d(),null===(e=s.data)||void 0===e?void 0:e.error)throw Error(e5(s.data.error));(0,K.Mr)(),i({generatedPassword:s.data.generatedPassword,emailSent:s.data.emailSent,email:x.trim()}),et.Am.success(o?"Operador atualizado":"Operador criado")}catch(e){d(),et.Am.error(e5(e,"Erro ao salvar operador"))}}return l.useEffect(()=>{n&&J.ZP.get("/card-machine-devices?eventId=".concat(n,"&limit=200")).then(e=>{var t;return u((null===(t=e.data)||void 0===t?void 0:t.items)||[])}).catch(()=>u([]))},[n]),(0,r.jsx)("div",{className:"add-form modal-container forms operators-form",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:o?"Editar operador":"Novo operador",subTitle:s?"Evento: ".concat(s):void 0,onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{label:"Nome",value:m,onChange:e=>h(e.target.value),error:!!Z.name,helperText:Z.name}),(0,r.jsx)(es.Z,{label:"Email",value:x,onChange:e=>p(e.target.value),error:!!Z.email,helperText:Z.email}),(0,r.jsxs)(tt.Z,{fullWidth:!0,error:!!Z.cardMachineDeviceId,children:[(0,r.jsx)(ta.Z,{id:"operator-device",children:"Maquininha"}),(0,r.jsxs)(tn.Z,{labelId:"operator-device",label:"Maquininha",value:g,onChange:e=>j(String(e.target.value)),children:[(0,r.jsx)(ts.Z,{value:"",disabled:!0,children:"Selecione a maquininha"}),c.map(e=>(0,r.jsx)(ts.Z,{value:e.id,children:e8(e)}
1,e.id))]}),(0,r.jsx)(ti.Z,{children:Z.cardMachineDeviceId||(c.length?" ":"Cadastre uma maquininha neste evento antes")})]}),(0,r.jsx)(ea.Z,{className:"switch",label:o?"Gerar nova senha":"Gerar senha automaticamente",control:(0,r.jsx)(tr.Z,{checked:f,onChange:e=>{b(e.target.checked),e.target.checked&&N("")}})}),!f&&(0,r.jsx)(es.Z,{label:o?"Nova senha (opcional)":"Senha",type:"text",value:y,onChange:e=>N(e.target.value),error:!!Z.password,helperText:Z.password||"M\xednimo 8 caracteres, com mai\xfascula, min\xfascula e n\xfamero"}),(0,r.jsx)(ea.Z,{className:"switch",label:o?"Enviar email se a senha mudar":"Enviar senha por email",control:(0,r.jsx)(tr.Z,{checked:k,onChange:e=>w(e.target.checked)})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:S,disabled:!c.length,children:o?"Salvar":"Criar operador"})]})]})]})})};var to=a(5270);let td=["credit_card","debit_card","pix"],tc=e=>{let{device:t,eventId:a,eventTitle:n,onSave:s}=e,i=!!(null==t?void 0:t.id),{toggleLoader:o}=(0,ee.U2)(),[d,c]=l.useState((null==t?void 0:t.modelName)||""),[u,m]=l.useState((null==t?void 0:t.serialNumber)||""),[h,x]=l.useState((null==t?void 0:t.description)||""),[p,g]=l.useState(((null==t?void 0:t.acceptedPaymentMethods)||[]).filter(e=>"cash"!==e)),[j,f]=l.useState({});async function b(){try{var e;if(!a)return et.Am.error("Selecione um evento primeiro!");let n={};if(d.trim()||(n.modelName="Modelo obrigat\xf3rio"),u.trim()||(n.serialNumber="N\xfamero de s\xe9rie obrigat\xf3rio"),h.trim()||(n.description="Descri\xe7\xe3o obrigat\xf3ria"),f(n),Object.keys(n).length)return et.Am.error("Preencha os campos obrigat\xf3rios");o(!0,i?"Salvando maquininha":"Cadastrando maquininha");let r={id:null==t?void 0:t.id,eventId:a,modelName:d.trim(),serialNumber:u.trim(),description:h.trim(),acceptedPaymentMethods:p},l=i?await J.ZP.put("/card-machine-devices/".concat(t.id),r):await J.ZP.post("/card-machine-devices",r);if(o(),null===(e=l.data)||void 0===e?void 0:e.error)throw Error(e5(l.data.error));(0,K.Mr)(),s(),et.Am.success(i?"Maquininha atualizada":"Maquininha cadastrada")}catch(e){o(),et.Am.error(e5(e,"Erro ao salvar maquininha"))}}return(0,r.jsx)("div",{className:"add-form modal-container forms operators-form",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:i?"Editar maquininha":"Nova maquininha",subTitle:n?"Evento: ".concat(n):void 0,onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{label:"Modelo",value:d,onChange:e=>c(e.target.value),error:!!j.modelName,helperText:j.modelName}),(0,r.jsx)(es.Z,{label:"N\xfamero de s\xe9rie",value:u,onChange:e=>m(e.target.value),error:!!j.serialNumber,helperText:j.serialNumber||"\xdanico neste evento"}),(0,r.jsx)(es.Z,{label:"Descri\xe7\xe3o",value:h,onChange:e=>x(e.target.value),multiline:!0,rows:3,error:!!j.description,helperText:j.description||"Apelido no balc\xe3o, ponto de venda, etc."}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{children:"M\xe9todos de pagamento aceitos"}),(0,r.jsx)("div",{className:"operators-methods",children:td.map(e=>(0,r.jsx)(to.Z,{label:e3[e],checked:p.includes(e),onChange:t=>{g(a=>t?[...a.filter(t=>t!==e),e]:a.filter(t=>t!==e))}},e))}),(0,r.jsx)("p",{className:"operators-hint",children:"Dinheiro entra automaticamente no terminal."})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,children:i?"Salvar":"Cadastrar maquininha"})]})]})]})})},tu=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},{eventId:a,eventTitle:n,tab:s,onChangeTab:i,search:l,setSearch:d,operators:c,devices:u,operatorsCount:m,devicesCount:h,operatorsLoading:x,devicesLoading:p,itemsLimit:g,itemsPage:j,devicesLimit:f,devicesPage:b,setFilters:y,refresh:N,regeneratePassword:k,removeOperator:w,removeDevice:Z,showGeneratedPassword:C}=te();function S(e){return a?(null==e?void 0:e.id)||h?void(0,K.K4)((0,r.jsx)(tl,{operator:e,eventId:a,eventTitle:n,onSave:t=>{N(),(null==t?void 0:t.generatedPassword)&&C({password:t.generatedPassword,emailSent:t.emailSent,email:t.email,title:(null==e?void 0:e.id)?"Nova senha do operador":"Senha do operador"})}})):et.Am.error("Cadastre uma maquininha neste evento antes de criar o operador."):et.Am.error("Selecione um evento primeiro!")}function _(e){if(!a)return et.Am.error("Selecione um evento primeiro!");(0,K.K4)((0,r.jsx)(tc,{device:e,eventId:a,eventTitle:n,onSave:N}))}return(0,r.jsxs)("div",{className:"operators-admin",children:[(0,r.jsxs)("div",{className:"operators-head",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{children:"Operadores de maquininha"}
1),(0,r.jsx)("p",{children:(null==t?void 0:t.title)?"Terminais e operadores de ".concat(t.title):"Selecione um evento para gerenciar maquininhas e operadores"})]}),(0,r.jsx)("div",{className:"operators-head-actions",children:"devices"===s?(0,r.jsx)(v.Z,{variant:"contained",startIcon:(0,r.jsx)(V.Z,{}),onClick:()=>_(),children:"Nova maquininha"}):(0,r.jsx)(v.Z,{variant:"contained",startIcon:(0,r.jsx)(eM.Z,{}),onClick:()=>S(),children:"Novo operador"})})]}),(0,r.jsxs)("div",{className:"operators-tabs",children:[(0,r.jsxs)("button",{type:"button",className:"operators"===s?"is-active":"",onClick:()=>i("operators"),children:["Operadores ",(0,r.jsx)("b",{children:m})]}),(0,r.jsxs)("button",{type:"button",className:"devices"===s?"is-active":"",onClick:()=>i("devices"),children:["Maquininhas ",(0,r.jsx)("b",{children:h})]})]}),(0,r.jsx)("div",{className:"operators-toolbar",children:(0,r.jsx)(eu,{className:"search",placeholder:"devices"===s?"Buscar por modelo, s\xe9rie ou descri\xe7\xe3o":"Buscar por nome ou email",value:l||"",onChange:e=>{d((null==e?void 0:e.target.value)||""),y({search:(null==e?void 0:e.target.value)||"",itemsPage:0,devicesPage:0})}})}),a?("operators"===s?x:p)?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):"operators"===s?(0,r.jsxs)(r.Fragment,{children:[!m&&(0,r.jsxs)("div",{className:"operators-empty",children:[(0,r.jsx)("strong",{children:"Nenhum operador neste evento"}),(0,r.jsx)("span",{children:"Cadastre a maquininha e depois o operador com email e senha."})]}),!!m&&(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Operador"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Maquininha"}),(0,r.jsx)("th",{children:"S\xe9rie"}),(0,r.jsx)("th",{className:"actions",children:"A\xe7\xf5es"})]})}),(0,r.jsx)("tbody",{children:c.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"name-cell",children:e.name}),(0,r.jsx)("td",{children:e.email}),(0,r.jsx)("td",{children:e8(e.cardMachineDevice)}),(0,r.jsx)("td",{children:(null===(t=e.cardMachineDevice)||void 0===t?void 0:t.serialNumber)||"—"}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{title:"Editar",children:(0,r.jsx)(X.Z,{onClick:()=>S(e),children:(0,r.jsx)(ep.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Gerar nova senha e enviar email",children:(0,r.jsx)(X.Z,{onClick:()=>k(e),children:(0,r.jsx)(eO.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Excluir",children:(0,r.jsx)(X.Z,{onClick:()=>w(e),children:(0,r.jsx)(eg.Z,{})})})]})]},e.id)})})]})}),(0,r.jsx)(eZ,{numberOfItems:m,rowsPerPage:g,page:j,onPageChange:e=>y({itemsPage:e}),onRowsPerPageChange:e=>y({itemsPage:0,itemsLimit:e})})]}):(0,r.jsxs)(r.Fragment,{children:[!h&&(0,r.jsxs)("div",{className:"operators-empty",children:[(0,r.jsx)("strong",{children:"Nenhuma maquininha neste evento"}),(0,r.jsx)("span",{children:"Cadastre o terminal com modelo e n\xfamero de s\xe9rie para vincular operadores."})]}),!!h&&(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Modelo"}),(0,r.jsx)("th",{children:"N\xfamero de s\xe9rie"}),(0,r.jsx)("th",{children:"Descri\xe7\xe3o"}),(0,r.jsx)("th",{children:"Pagamentos"}),(0,r.jsx)("th",{className:"actions",children:"A\xe7\xf5es"})]})}),(0,r.jsx)("tbody",{children:u.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"name-cell",children:e.modelName}),(0,r.jsx)("td",{children:e.serialNumber}),(0,r.jsx)("td",{children:e.description}),(0,r.jsx)("td",{children:function(e){let t=((null==e?void 0:e.acceptedPaymentMethods)||[]).filter(e=>"cash"!==e);return t.length?t.map(e=>e3[e]||e).join(" \xb7 "):"Dinheiro"}(e)}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{title:"Editar",children:(0,r.jsx)(X.Z,{onClick:()=>_(e),children:(0,r.jsx)(ep.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Excluir",children:(0,r.jsx)(X.Z,{onClick:()=>Z(e),children:(0,r.jsx)(eg.Z,{})})})]})]},e.id))})]})}),(0,r.jsx)(eZ,{numberOfItems:h,rowsPerPage:f,page:b,onPageChange:e=>y({devicesPage:e}),onRowsPerPageChange:e=>y({devicesPage:0,devicesLimit:e})})]}):(0,r.jsxs)("div",{className:"operators-empty",children:[(0,r.jsx)("strong",{children:"Selecione um evento"}),(0,r.jsx)("span",{children:"O cadastro de operadores e maquininhas \xe9 por evento."})]})]})},tm={email_already_exists:"J\xe1 existe um usu\xe1rio com este email",email_required:"Email obrigat\xf3rio",email_invalid:"Email inv\xe1lido",name_required:"Nome obrigat\xf3rio",event_id_required:"Selecione um evento",event_not_found:"Evento n\xe3o encontrado",not_a_check_in_operator:"Este usu\xe1rio n\xe3o \xe9 um operador de check-in",cannot_delete_self:"N\xe3o \xe9 poss\xedvel excluir a pr\xf3pria conta por aqui",cannot_reset_own_password_here:"N\xe3o \xe9 poss\xedvel redefinir a pr\xf3pria senha por aqui",user_not_found:"Operador n\xe3o encontrado"};function th(e){var t,a,n;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Erro ao processar",i=(null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:null===(n=a.error)||void 0===n?void 0:n.message)||(null==e?void 0:e.message)||"";return tm[i]?tm[i]:"string"==typeof i&&i.trim()?i.split("\n").map(e=>tm[e]||e).join("\n"):s}let tv="checkInOperatorFilters",tx=()=>{var e,t;let{toggleLoader:a}=(0,ee.U2)(),{storedState:n,setStoredState:s}=(0,o.oR)(),{currentSelectedEvent:i}=n||{},d=(null==i?void 0:i._id)||"",c=(null==n?void 0:n[tv])||{},[u,m]=l.useState(c.search||""),h=(0,ev.Nr)(u,300),{itemsLimit:v=20,itemsPage:x=0}=c,p=new URLSearchParams;d&&p.set("eventId",d),h&&p.set("search",h),p.set("limit",String(v)),p.set("page",String(x));let g=(0,eh.Z)("/user-check-in-operators?".concat(p.toString()),{enabled:!!d}),j=(null===(e=g.data)||void 0===e?void 0:e.items)||[],f=Number(null===(t=g.data)||void 0===t?void 0:t.numberOfItems)||0,b=l.useCallback(e=>{s({[tv]:{...c,...e}})},[c,s]),y=l.useCallback(()=>{g.refresh()},[g]),N=l.useCallback(e=>{e.password&&window.setTimeout(()=>{(0,K.K4)((0,r.jsx)(e4,{password:e.password,emailSent:!!e.emailSent,email:e.email,title:e.title,onClose:K.Mr}))},250)},[]),k=l.useCallback(e=>{if(!(null==e?void 0:e.id)||!e.email)return et.Am.error("Este operador n\xe3o tem email cadastrado");(0,em.Z)({title:"Gerar nova senha",text:"Uma nova senha ser\xe1 gerada para <b>".concat(e.name||e.email,"</b> (").concat(e.email,") e enviada por email.<br/><br/>A senha atual deixa de funcionar imediatamente."),confirmButtonText:"Sim, gerar senha e enviar email",onConfirm:async()=>{try{var t;a(!0,"Gerando senha");let n=await J.ZP.post("/user-check-in-operators/".concat(e.id,"/regenerate-password"),{sendEmail:!0});if(a(),null===(t=n.data)||void 0===t?void 0:t.error)return et.Am.error(th(n.data.error));y(),N({password:n.data.generatedPassword,emailSent:n.data.emailSent,email:e.email,title:"Nova senha do operador"})}catch(e){a(),et.Am.error(th(e,"Erro ao gerar senha"))}}})}
1,[y,N,a]),w=l.useCallback(e=>{(0,em.Z)({title:"Excluir operador",icon:"warning",text:"Remover o operador <b>".concat(e.name||e.email,"</b>?<br/><br/>Ele deixa de acessar o check-in deste evento."),confirmButtonText:"Sim, excluir",onConfirm:async()=>{try{var t;a(!0,"Excluindo operador");let n=await J.ZP.delete("/user-check-in-operators/".concat(e.id));if(a(),null===(t=n.data)||void 0===t?void 0:t.error)return et.Am.error(th(n.data.error));y(),(0,K.Mr)(),et.Am.success("Operador exclu\xeddo")}catch(e){a(),et.Am.error(th(e,"Erro ao excluir operador"))}}})},[y,a]);return{eventId:d,eventTitle:(null==i?void 0:i.title)||"",search:u,setSearch:m,operators:j,operatorsCount:f,operatorsLoading:g.isLoading,itemsLimit:v,itemsPage:x,setFilters:b,refresh:y,regeneratePassword:k,removeOperator:w,showGeneratedPassword:N}},tp=e=>{let{operator:t,eventId:a,eventTitle:n,onSave:s}=e,i=!!(null==t?void 0:t.id),{toggleLoader:o}=(0,ee.U2)(),[d,c]=l.useState((null==t?void 0:t.name)||""),[u,m]=l.useState((null==t?void 0:t.email)||""),[h,x]=l.useState(!i),[p,g]=l.useState(""),[j,f]=l.useState(!i),[b,y]=l.useState({});async function N(){try{var e;if(!a)return et.Am.error("Selecione um evento primeiro!");if(!function(){let e={};return d.trim()||(e.name="Nome obrigat\xf3rio"),u.trim()?(0,eD.oH)(u.trim())||(e.email="Email inv\xe1lido"):e.email="Email obrigat\xf3rio",h||i&&!p||(p?!(p.length<8)&&(0,eD.hi)(p)||(e.password="Use no m\xednimo 8 caracteres, com letra mai\xfascula, min\xfascula e n\xfamero"):e.password="Senha obrigat\xf3ria"),y(e),!Object.keys(e).length}())return et.Am.error("Preencha os campos obrigat\xf3rios");o(!0,i?"Salvando operador":"Criando operador");let n={name:d.trim(),email:u.trim(),eventId:a,sendEmail:j};h?(n.generatePassword=!0,n.password=""):p&&(n.password=p);let r=i?await J.ZP.put("/user-check-in-operators/".concat(t.id),n):await J.ZP.post("/user-check-in-operators",n);if(o(),null===(e=r.data)||void 0===e?void 0:e.error)throw Error(th(r.data.error));(0,K.Mr)(),s({generatedPassword:r.data.generatedPassword,emailSent:r.data.emailSent,email:u.trim()}),et.Am.success(i?"Operador atualizado":"Operador criado")}catch(e){o(),et.Am.error(th(e,"Erro ao salvar operador"))}}return(0,r.jsx)("div",{className:"add-form modal-container forms operators-form",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:i?"Editar operador de check-in":"Novo operador de check-in",subTitle:n?"Evento: ".concat(n):void 0,onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{label:"Nome",value:d,onChange:e=>c(e.target.value),error:!!b.name,helperText:b.name,fullWidth:!0}),(0,r.jsx)(es.Z,{label:"Email",value:u,onChange:e=>m(e.target.value),error:!!b.email,helperText:b.email,fullWidth:!0}),(0,r.jsx)(ea.Z,{className:"switch",label:i?"Gerar nova senha":"Gerar senha automaticamente",control:(0,r.jsx)(tr.Z,{checked:h,onChange:(e,t)=>
1{x(t),t&&g("")}})}),!h&&(0,r.jsx)(es.Z,{label:i?"Nova senha (opcional)":"Senha",type:"password",value:p,onChange:e=>g(e.target.value),error:!!b.password,helperText:b.password||"M\xednimo 8 caracteres, com mai\xfascula, min\xfascula e n\xfamero",fullWidth:!0}),(0,r.jsx)(ea.Z,{className:"switch",label:i?"Enviar email se a senha mudar":"Enviar senha por email",control:(0,r.jsx)(tr.Z,{checked:j,onChange:(e,t)=>f(t)})}),!j&&h&&(0,r.jsx)(ti.Z,{children:"A senha ser\xe1 exibida na tela ap\xf3s salvar."}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:N,children:i?"Salvar":"Criar operador"})]})]})]})})},tg=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},{eventId:a,eventTitle:n,search:s,setSearch:i,operators:l,operatorsCount:d,operatorsLoading:c,itemsLimit:u,itemsPage:m,setFilters:h,refresh:x,regeneratePassword:p,removeOperator:g,showGeneratedPassword:j}=tx();function f(e){if(!a)return et.Am.error("Selecione um evento primeiro!");(0,K.K4)((0,r.jsx)(tp,{operator:e,eventId:a,eventTitle:n,onSave:t=>{x(),(null==t?void 0:t.generatedPassword)&&j({password:t.generatedPassword,emailSent:t.emailSent,email:t.email,title:(null==e?void 0:e.id)?"Nova senha do operador":"Senha do operador"})}}))}return(0,r.jsxs)("div",{className:"operators-admin",children:[(0,r.jsxs)("div",{className:"operators-head",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{children:"Operadores de check-in"}),(0,r.jsx)("p",{children:(null==t?void 0:t.title)?"Contas de portaria/check-in para ".concat(t.title):"Selecione um evento para gerenciar operadores de check-in"})]}),(0,r.jsx)("div",{className:"operators-head-actions",children:(0,r.jsx)(v.Z,{variant:"contained",startIcon:(0,r.jsx)(eM.Z,{}),onClick:()=>f(),children:"Novo operador"})})]}),(0,r.jsx)("div",{className:"operators-toolbar",children:(0,r.jsx)(eu,{className:"search",placeholder:"Buscar por nome ou email",value:s||"",onChange:e=>{i((null==e?void 0:e.target.value)||""),h({search:(null==e?void 0:e.target.value)||"",itemsPage:0})}})}),a?c?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!d&&(0,r.jsxs)("div",{className:"operators-empty",children:[(0,r.jsx)("strong",{children:"Nenhum operador de check-in neste evento"}),(0,r.jsx)("span",{children:"Crie login e senha para a equipe da portaria."})]}),!!d&&(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Operador"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Acesso"}),(0,r.jsx)("th",{className:"actions",children:"A\xe7\xf5es"})]})}),(0,r.jsx)("tbody",{children:l.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"name-cell",children:e.name}),(0,r.jsx)("td",{children:e.email}),(0,r.jsxs)("td",{children:[(0,r.jsx)(G.Z,{fontSize:"small",style:{verticalAlign:"middle",marginRight:6}}),"Check-in (Pesquisa)"]}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{title:"Editar",children:(0,r.jsx)(X.Z,{onClick:()=>f(e),children:(0,r.jsx)(ep.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Gerar nova senha e enviar email",children:(0,r.jsx)(X.Z,{onClick:()=>p(e),children:(0,r.jsx)(eO.Z,{})})}),(0,r.jsx)(eS.Z,{title:"Excluir",children:(0,r.jsx)(X.Z,{onClick:()=>g(e),children:(0,r.jsx)(eg.Z,{})})})]})]},e.id))})]})}),(0,r.jsx)(eZ,{numberOfItems:d,rowsPerPage:u,page:m,onPageChange:e=>h({itemsPage:e}),onRowsPerPageChange:e=>h({itemsPage:0,itemsLimit:e})})]}):(0,r.jsxs)("div",{className:"operators-empty",children:[(0,r.jsx)("strong",{children:"Selecione um evento"}),(0,r.jsx)("span",{children:"O cadastro \xe9 por evento. O operador s\xf3 acessa a pesquisa de ingressos e check-in."})]})]})};var tj=a(8100),tf=a(2916),tb=a(16092),ty=a(33454),tN=a(96420),tk=a(78298),tw=a(47212),tZ=a(29383),tC=a(3151),tS=a(77349),t_=a(78343),tD=a(69119),tE=a(54957),tP=a(83894),tI=a(584),tA=a(67090),tT=a(38148),tR=a(10876),tL=a(63500),tq=a(21593),tM=a(47073);let tO=[{name:"Usu\xe1rio",selector:"name"},{name:"Email",selector:"email"},{name:"Data cria\xe7āo",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPPPp")}],tF=[{name:"Produto t\xedtulo",selector:"productTitle"},{name:"Produto descri\xe7\xe3o",selector:"productDescription"},{name:"Produto marca",selector:"productBrand",renderCell:e=>{var t;return null===(t=e.productBrand)||void 0===t?void 0:t.join(", ")}},{name:"Produto link",selector:"productLink"}],tB=[...tF,{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],tU=[...tF,{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data acesso",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],tz=[...tF,{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data acesso",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],tV=[...tF,{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data acesso",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],tG=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],tW=["Domingo","Segunda","Ter\xe7a","Quarta","Quinta","Sexta","S\xe1bado"],t$=["Janeiro","Fevereiro","Mar\xe7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],tH={newUsers:{week:"Novos usu\xe1rios",month:"Novos usu\xe1rios",custom:"Novos usu\xe1rios"},accesses:{week:"Acessos",month:"Acessos m\xeas",custom:"Acessos"},productsFav:{week:"Produtos favoritados",month:"Produtos favoritados",custom:"Produtos favoritados"},environmentsFav:{week:"Ambientes favoritados",month:"Ambientes favoritados",custom:"Ambientes favoritados"},professionalsFav:{week:"Profissionais favoritados",month:"Profissionais favoritados",custom:"Profissionais favoritados"},seeMore:{week:"Ver mais clicks",month:"Ver mais clicks",custom:"Ver mais clicks"},knowMore:{week:"Saber mais clicks",month:"Saber mais clicks",custom:"Saber mais clicks"},purshaseInterest:{week:"Interesse em compra produto clicks",month:"Interesse em compra produto clicks",custom:"Interesse em compra produto clicks"}},tJ={new_users:[{name:"Usu\xe1rio",selector:"name"},{name:"Email",selector:"email"},{name:"Sistema",selector:"device"},{name:"Data cria\xe7āo",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPPPp")}],access:[{name:"Nome",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data acesso",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],favorite_environment:[{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],favorite_professional:[{name:"Profissional",selector:"professional"},{name:"Ambiente",selector:"environment"},{name:"Evento",selector:"event"},{name:"Usu\xe1rio",selector:"userName"},{name:"Email",selector:"userEmail"},{name:"Sistema",selector:"device"},{name:"Data",selector:"createdAt",renderCell:e=>(0,ej.p6)(e.createdAt,"PPp")}],favorite_product:tB,see_more:tU,know_more:tz,purshase_interest:tV,professionals:tO,admins:tO};var tQ=a(12487),tY=a(81481),tK=a(98456),tX=a(39327),t0=a(84105);let t1=e=>{let{fileName:t,url:a,columns:n,dataAccessor:s}=e,[i,o]=l.useState(!1),d=async()=>{try{o(!0);let e=await (0,J.ZP)(a);o(!1);let i={};null==n||n.map(e=>{i[e.selector]=e.name});let r=[];if(e.data[s].map(e=>{let t={};Object.keys(e).map(a=>{if(i[a]){let n=e[a];t[i[a]]=Array.isArray(n)?n.join(", "):n}}),r.push(t)}),e.data){let e=t0.P6.json_to_sheet(r),a=t0.P6.book_new();t0.P6.book_append_sheet(a,e,"Sheet1"),t0.NC(a,t+".xlsx")}}catch(e){}};return(0,r.jsxs)(v.Z,{onClick:d,className:"export-table-btn",variant:"outlined",children:[i?(0,r.jsx)(tK.Z,{size:20}):(0,r.jsx)(tX.Z,{}),(0,r.jsx)("div",{children:i?"processando":"Exportar tabela"})]})};var t2=l.memo(t1),t3=a(53816),t6=a(53252),t5=a(55113),t8=a(7906),t7=a(53184),t4=a(295);let t9=e=>{var t,a,n;let{dateRange:s,dateRangeStart:i,dateRangeEnd:o,selectedTableItem:d}=e,[c,u]=l.useState(0),[m,h]=l.useState(20),[v,x]=l.useState(0),[p,g]=l.useState({createdAt:-1}),j=d.type;l.useEffect(()=>{u(0)},[j]);let f=(0,tj.ZP)("/report/list?table=true&range=".concat(s,"&start_at=").concat(i,"&end_at=").concat(o,"&type=").concat(j,"&page=").concat(c,"&limit=").concat(m,"&sort=").concat(JSON.stringify(p))),b=!f.error&&!f.data;null===(t=f.data)||void 0===t||null===(a=t.data)||void 0===a||a.error;let y=null===(n=f.data)||void 0===n?void 0:n.data;l.useEffect(()=>{v||x((null==y?void 0:y.totalOfDocs)||0)},[y]);let N=l.useCallback(e=>(0,r.jsx)(t3.Z,{children:e.map(e=>(0,r.jsx)(t6.Z,{className:e.selector+"-coll",style:{width:(null==e?void 0:e.width)||void 0},onClick:()=>{var t;return t=e.selector,void g(e=>t in e?{[t]:-1*e[t]}:{[t]:-1})},children:(0,r.jsxs)("div",{className:"th",children:[e.selector in p&&(-1===p[e.selector]?(0,r.jsx)(tQ.Z,{}):(0,r.jsx)(tY.Z,{})),(0,r.jsx)("div",{children:(null==e?void 0:e.cell)||e.name})]})},e.selector+"-coll"))}),[p]),k=l.useCallback((e,t)=>null==t?void 0:t.map((t,a)=>(0,r.jsx)(t3.Z,{className:a%2==0?"even":"odd",children:e.map((e,a)=>{let n;if(e.selector){let a=e.selector.split("."),s=t;a.map(e=>s="object"==typeof s?s[e]:""),n=s}else n=t[e.name];return(0,r.jsx)(t6.Z,{component:"th",scope:"row",className:e.selector+"-cell",children:(0,r.jsx)("div",{style:{whiteSpace:"normal",height:"100%"},children:e.renderCell?e.renderCell(t):(0,r.jsx)("span",{children:n||e.defaultValue||"--"})})},a)})},a)),[]),w=l.useMemo(()=>tJ[j],[j]);return(0,r.jsx)("div",{className:"tables",children:(0,r.jsxs)(t5.Z,{className:"paper",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("h2",{children:[null==d?void 0:d.label," por per\xedodo"]}
1),(0,r.jsx)(t2,{fileName:null==d?void 0:d.label,dataAccessor:"data",url:"/report/list?table=true&range=".concat(s,"&start_at=").concat(i,"&end_at=").concat(o,"&type=").concat(j,"&sort=").concat(JSON.stringify(p)),columns:w})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)(t8.Z,{stickyHeader:!0,size:"small",children:[(0,r.jsx)(t7.Z,{children:N(w)}),(0,r.jsx)(t4.Z,{children:k(w,null==y?void 0:y.data)})]})}),!b&&!(null==y?void 0:y.totalOfDocs)&&(0,r.jsx)("div",{className:"not-found",children:"Nenhum registro encontrado"}),(0,r.jsx)(eZ,{numberOfItems:v,rowsPerPage:m,page:c,onPageChange:u,onRowsPerPageChange:h})]})})};tf.kL.register(tf.uw,tf.f$,tf.od,tf.jn,tf.Dx,tf.u,tf.De);let ae={responsive:!0,type:"line",maintainAspectRatio:!1,plugins:{title:{display:!1},legend:{position:"bottom",labels:{boxWidth:15}}}},at={week:()=>tW,month:()=>t$,year:()=>{let e=new Date().getFullYear(),t=[];for(let a=0;a<7;a++)t.push((e-a).toString());return t.reverse()},custom:(e,t)=>{let a=(0,tZ.Z)(t,e);if((0,tC.Z)(t,e))return tG;let n=[];for(let t=0;t<=a;t++)n.push((0,ej.p6)((0,tS.Z)(e,t),"dd/MM"));return n}};function aa(e){var t,a,n;let s,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,l=arguments.length>3?arguments[3]:void 0,o=[];if("month"===e){s=12;for(let e=0;e<s;e++)o[e]=(null===(t=i.find(t=>t.month===e+1))||void 0===t?void 0:t.total)||0}else if("week"===e){s=7;for(let e=0;e<s;e++)o[e]=(null===(a=i.find(t=>t.day===e+1))||void 0===a?void 0:a.total)||0}else{let e=(0,tC.Z)(r,l);s=e?23:(0,tZ.Z)(l,r);let t=new Date;for(let a=0;a<=s;a++)o[a]=(null===(n=i.find(n=>{let s;return(t.setFullYear(n.year,n.month-1,n.day),e)?(t.setHours(n.hour),s=(0,t_.Z)((0,tD.Z)(r),a),(0,tC.Z)(t,s)&&(0,tE.Z)(t,s)):(s=(0,tS.Z)(r,a),(0,tC.Z)(t,s))}))||void 0===n?void 0:n.total)||0}return o}let an=()=>{var e;let{t}=(0,p.$)("admin"),{storedState:a,setStoredState:n}=(0,o.oR)(),{currentSelectedEvent:s}=a||{},[i,d]=l.useState("week"),[c,u]=l.useState((0,tS.Z)(new Date,-15)),[m,h]=l.useState(new Date),[v,x]=l.useState({type:"new_users",label:"Novos usu\xe1rios",data:[]}),g=(0,tD.Z)(c),j=(0,tP.Z)(m),f=(0,tC.Z)(c,m);"week"===i?(g=(0,tI.Z)(g),j=(0,tA.Z)(g)):"month"===i&&(g=(0,tT.Z)(g),j=(0,tR.Z)(g));let{data:b,error:y}=(0,tj.ZP)("/report/list?resume=true&range=".concat(i,"&start_at=").concat(g,"&end_at=").concat(j,"&is_same_day=").concat(f,"&eventId=").concat(null==s?void 0:s._id)),N=!!(null==b?void 0:null===(e=b.data)||void 0===e?void 0:e.error),k=(e,t)=>{t&&d(t)},w=l.useMemo(()=>{var e,t,a,n,s,r,l,o,d,u;let h={accesses:[],newUsers:[],professionals:[],admins:[],favorites:{environments:[],professionals:[],products:[]},...null==b?void 0:b.data},v=(e,t)=>
1parseInt(e)+parseInt(t.total);return{data:{labels:at[i](c,m),datasets:[{label:tH.newUsers[i],data:aa(i,h.newUsers,c,m),borderColor:"#4e8bd8",backgroundColor:"#4e8bd8"},{label:tH.accesses[i],data:aa(i,h.accesses,c,m),borderColor:"#13a01b",backgroundColor:"#13a01b"},{label:tH.environmentsFav[i],data:aa(i,h.favorites.environments,c,m),borderColor:"#bc1d01",backgroundColor:"#bc1d01"},{label:tH.professionalsFav[i],data:aa(i,h.favorites.professionals,c,m),borderColor:"grey",backgroundColor:"grey"},{label:tH.productsFav[i],data:aa(i,h.favorites.products,c,m),borderColor:"#eeb703",backgroundColor:"#eeb703"},{label:tH.seeMore[i],data:aa(i,h.seeMore,c,m),borderColor:"#24522e",backgroundColor:"#24522e"},{label:tH.knowMore[i],data:aa(i,h.knowMore,c,m),borderColor:"#45e3ff",backgroundColor:"#45e3ff"},{label:tH.purshaseInterest[i],data:aa(i,h.purshaseInterest,c,m),borderColor:"orange",backgroundColor:"orange"}]},totalNewUsers:null===(e=h.newUsers)||void 0===e?void 0:e.reduce(v,[0]),totalAccesses:null===(t=h.accesses)||void 0===t?void 0:t.reduce(v,[0]),totalFavoritesEnvironments:null===(a=h.favorites.environments)||void 0===a?void 0:a.reduce(v,[0]),totalFavoritesProfessionals:null===(n=h.favorites.professionals)||void 0===n?void 0:n.reduce(v,[0]),totalFavoritesProducts:null===(s=h.favorites.products)||void 0===s?void 0:s.reduce(v,[0]),totalSeeMoreClicks:null===(r=h.seeMore)||void 0===r?void 0:r.reduce(v,[0]),totalKnowMoreClicks:null===(l=h.knowMore)||void 0===l?void 0:l.reduce(v,[0]),totalPurshaseInterestClicks:null===(o=h.purshaseInterest)||void 0===o?void 0:o.reduce(v,[0]),totalProfessionals:null===(d=h.professionals)||void 0===d?void 0:d.reduce(v,[0]),totalAdmins:null===(u=h.admins)||void 0===u?void 0:u.reduce(v,[0])}},[b,!y&&!b,N]),Z=l.useMemo(()=>"week"===i?"De ".concat((0,tI.Z)(c).getDate()," \xe0 ").concat((0,tA.Z)(c).getDate()," de ").concat((0,ej.p6)(c,"MMMM yyyy")):"Ano ".concat((0,ej.p6)(c,"yyyy")),[i,c]);return(0,r.jsxs)("div",{className:"statistics",children:[(0,r.jsx)("h2",{children:"Evolu\xe7\xe3o do eventos por per\xedodo"}),(0,r.jsxs)("div",{className:"header",children:[(0,r.jsxs)(ty.Z,{color:"primary",size:"small",value:i,exclusive:!0,onChange:k,className:"range-selector",children:[(0,r.jsx)(tN.Z,{value:"week",children:"Semana"}),(0,r.jsx)(tN.Z,{value:"month",children:"M\xeas"}),(0,r.jsx)(tN.Z,{value:"custom",children:"Custom"})]}),"custom"===i?(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsx)(tM.Z,{label:t("start"),className:"input",value:c||null,onChange:u,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(tM.Z,{label:t("end"),className:"input",value:m||null,onChange:h,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})})]}):(0,r.jsxs)("div",{className:"date-select",children:[(0,r.jsx)(X.Z,{onClick:function(){u(e=>"week"===i?(0,tL.Z)(e,-1):(0,tq.Z)(e,-1))},children:(0,r.jsx)(tk.Z,{})}),(0,r.jsx)("div",{children:Z}),(0,r.jsx)(X.Z,{onClick:function(){u(e=>"week"===i?(0,tL.Z)(e,1):(0,tq.Z)(e,1))},children:(0,r.jsx)(tw.Z,{})})]})]}),(0,r.jsx)("div",{className:"accesses-chart",children:(0,r.jsx)(tb.x1,{options:ae,data:w.data})}),(0,r.jsx)("div",{className:"cards-container",children:[{type:"professionals",label:"Profissionais",data:w.totalProfessionals},{type:"admins",label:"Administradores",data:w.totalAdmins},{type:"new_users",label:"Novos usu\xe1rios",data:w.totalNewUsers},{type:"access",label:"Acessos",data:w.totalAccesses},{type:"favorite_environment",label:"Ambientes favoritados",data:w.totalFavoritesEnvironments},{type:"favorite_professional",label:"Profissionais favoritados",data:w.totalFavoritesProfessionals},{type:"favorite_product",label:"Produtos favoritados",data:w.totalFavoritesProducts},{type:"see_more",label:"Ver mais clicks",data:w.totalSeeMoreClicks},{type:"know_more",label:"Saber mais clicks",data:w.totalKnowMoreClicks},{type:"purshase_interest",label:"Interesse compra produto clicks",data:w.totalPurshaseInterestClicks}].map(e=>(0,r.jsxs)("div",{className:"card "+(v.type===e.type?"selected":""),onClick:()=>x(e),children:[(0,r.jsx)("div",{className:"key",children:e.label}),(0,r.jsx)("div",{className:"value",children:e.data})]},e.type))}),(0,r.jsx)(t9,{dateRange:i,dateRangeStart:g,dateRangeEnd:j,selectedTableItem:v})]})};var as=a(62286),ai=a(9669),ar=a.n(ai);let al=ar().create({baseURL:"https://api-events-environments.appcasacor.com.br"});al.interceptors.request.use(async e=>{let t=(0,as.parseCookies)(),a=t[d.Y5];return a&&e.headers&&(e.headers.Authorization="Bearer ".concat(a)),e});let ao=e=>al.get(e).then(e=>e),ad=e=>{var t;let[a,n]=l.useState(0),{data:s,error:i}=(0,tj.ZP)(e.includes("?")?e+"&refresh="+a:e+"?refresh="+a,ao),r=!i&&!s,o=l.useRef([]);return l.useEffect(()=>{var e;(null==s?void 0:null===(e=s.data)||void 0===e?void 0:e.error)?((null==s?void 0:s.data.error.message)&&et.Am.error(null==s?void 0:s.data.error.message,{toastId:"useSWR.error"}),et.Am.error(JSON.stringify(null==s?void 0:s.data.error),{toastId:"useSWR.error"})):(null==s?void 0:s.data)&&(o.current=s.data)},[s]),{isLoading:r,refresh:()=>n(Date.now()),data:r?o.current:(null==s?void 0:null===(t=s.data)||void 0===t?void 0:t.error)?void 0:null==s?void 0:s.data,error:null==s?void 0:s.data.error}};var ac=a(89755),au=a.n(ac),am=a(77872),ah=a(32101),av=a(313);let ax=e=>{let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),{environmentPhotosFilter:i={},currentSelectedEvent:d}=n||{},[c,u]=l.useState({}),[m,h]=l.useState({}),x=(null==d?void 0:d._id)||null,{data:g,isLoading:j}=ad("/environment-photos/filters?eventId=".concat(x)),{startDate:f,endDate:b,search:y,environments:N}=c;function k(e){u({...c,...e})}function w(){if(f&&b&&(0,av.Z)((0,tD.Z)(new Date(b)),(0,tD.Z)(new Date(f))))return h({sellEndDate:!0}),et.Am.error("Data de in\xedcio n\xe3o deve ser maior que a data fim!");h({sellStartDate:!1,sellEndDate:!1});let e={...i};e[x]=c,Object.keys(e[x]).map(t=>{let a=e[x][t];a&&"string"==typeof a&&"Invalid Date"!==new Date(a).toString()&&(e[x][t]=new Date(a))}),s({environmentPhotosFilter:e})}l.useEffect(()=>{if(!x)return;let e={...i[x]};u(e)},[x]);let Z=l.useRef(!1);return l.useEffect(()=>{Object.keys(c).length&&(Z.current||(w(),Z.current=!0))},[c]),(0,r.jsxs)("div",{className:"filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(am.Z,{options:(null==g?void 0:g.environments)||[],value:N,label:"Filtrar por ambientes",cleanable:!0,multiple:!0,onChange:e=>k({environments:e})}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome/email do usu\xe1rio, tags, ambiente",value:y||"",onValueChange:e=>k({search:e})}),!!y&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>k({search:""}),children:(0,r.jsx)(ec.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data in\xedcio",className:"input",value:f||null,onChange:e=>k({startDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:m.startDate})}),!!f&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>k({startDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data fim",className:"input",shouldDisableDate:e=>!!f&&(0,tS.Z)(new Date(e),1)<new Date(f),value:b||null,onChange:e=>k({endDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{error:m.endDate,...e})}),!!b&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>k({endDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...i};e[x]={},s({environmentPhotosFilter:e}),u({})},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:w,children:"Aplicar filtros"})]})]})},ap=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),{currentSelectedEvent:n,environmentPhotosFilter:s}=a||{};(0,ev.Nr)(null==a?void 0:a.eventSearch,300);let i=(null==n?void 0:n._id)||null,l=new URLSearchParams({...(null==s?void 0:s[i])||{},eventId:i}),{data:d,isLoading:c}=ad("/environment-photos/list?"+l),{items:u,numberOfItems:m}=d||{};return(0,r.jsxs)("div",{className:"environment-photos",children:[(0,r.jsx)("h3",{children:" Fotos usu\xe1rios por evento"}),(0,r.jsx)(ax,{}),(0,r.jsxs)("label",{children:[m," items encontrados"]}),(0,r.jsx)("div",{className:"images",children:null==u?void 0:u.map(e=>{var t,a;return(0,r.jsxs)("div",{className:"item",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(e.photo),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:"",draggable:!1})}),(0,r.jsx)("div",{className:"title",children:"Ambiente:"}),(0,r.jsx)("div",{className:"env-title",children:null===(t=e.environment)||void 0===t?void 0:t.t
1itle}),(0,r.jsx)("div",{className:"title",children:"Tags:"}),(0,r.jsx)("div",{className:"text",children:null===(a=e.tags)||void 0===a?void 0:a.join(", ")}),(0,r.jsx)("div",{className:"title",children:"Tirado por:"}),(0,r.jsx)("div",{className:"text",children:e.user.name}),(0,r.jsxs)("div",{className:"text",children:[e.user.email," ",(0,r.jsx)("span",{className:"date",children:(0,ej.p6)(e.createdAt,"Pp")})]})]},e._id)})})]})};var ag=a(71983),aj=a(35277),af=a(90143),ab=a(12832);let ay=ar().create({baseURL:"https://api-events-environments.appcasacor.com.br"});async function aN(e){var t,a;let{method:n="get",url:s,body:i,headers:r,onProcessing:l,onError:o,onSuccess:d}=e;try{l&&l(!0);let e=await ay({url:s,method:n,headers:r,data:i}),a=null===(t=e.data)||void 0===t?void 0:t.error;if(a)throw console.log("API request error (".concat(s,") =>"),a),Error(a);d&&d(e.data),l&&l(!1)}catch(e){if(l&&l(!1),o){if(e.message)return o(e.message);let t=null===(a=e.response)||void 0===a?void 0:a.request._response,n=t&&JSON.parse(t);o(null==n?void 0:n.error)}}}ay.interceptors.request.use(async e=>{let t=(0,as.parseCookies)(),a=t[d.Y5];return a&&e.headers&&(e.headers.Authorization="Bearer ".concat(a)),e}),ay.interceptors.response.use(e=>{var t,a;return(null===(t=e.data)||void 0===t?void 0:null===(a=t.error)||void 0===a?void 0:a.message)==="No token provided"&&ab.v.dispatch("logout_user"),{data:e.data,headers:e.headers}},e=>{var t,a,n,s;return(console.log("API ERROR ==>",e),"Network Error"===e.message)?{data:{error:{message:"No momento n\xe3o podemos processar sua requisi\xe7\xe3o. Tente novamente em alguns segundos.",status:502}}}:((null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:null===(n=a.error)||void 0===n?void 0:n.message)==="No token provided"&&ab.v.dispatch("logout_user"),{data:null===(s=e.response)||void 0===s?void 0:s.data})});let ak=(e,t)=>{let[a,n]=l.useState(!0),[s,i]=l.useState({}),[r,o]=l.useState({}),{toggleLoader:d}=(0,ee.U2)(),[c,u]=l.useState(!1),[m,h]=l.useState(!1);l.useRef();let v=l.useRef(!1);async function x(){try{var t;let a=await ay.get("/franchise/".concat(e));n(!1);let s=null===(t=a.data)||void 0===t?void 0:t.error;if(s)throw Error(s);i(a.data)}catch(e){n(!1),et.Am.error(e.message)}}function p(){let e={};o(e);let{name:t}=s;return t||(e.name_required=!0),!Object.keys(e).length||(o(e),et.Am.error("Formul\xe1rio incompleto!"),window.scrollTo(0,0),!1)}async function g(){try{if(!p())return;d(!0,"Criando Franquia");let e=await ay.post("/franchise",(0,eD.GZ)(s),{headers:{"Content-Type":"multipart/form-data"}});if(e.data.error)throw o(e.data.error.message),Error(e.data.error.message);i(e.data.franchise),d(),setTimeout(()=>h(!1),1e3),et.Am.success("Franquia criada com sucesso!"),o({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),d(),et.Am.error(e.message)}}async function j(){try{if(!p())return;d(!0,"Atualizando franquia");let a=await ay.put("/franchise/".concat(e),(0,eD.GZ)(s),{headers:{"Content-Type":"multipart/form-data"}});if(d(),a.data.error)throw o(a.data.error.message),Error(a.data.error.message);i({...s,...a.data.franchise}),setTimeout(()=>h(!1),1e3),et.Am.success("Franquia atualizada com sucesso!"),o({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),d(),et.Am.error(e.message)}}return l.useEffect(()=>{e?x():n(!1)},[e]),(0,ev.gt)(m,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{s&&i(s)},[s]),{loading:a,franchise:s,changeFranchiseData:function(e){i(t=>({...t,...e})),v.current&&h(!0)},onGoBack:function(){m?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitFranchise:(null==s?void 0:s.id)?j:g,errors:r,removeFranchise:function(){try{(0,em.Z)({text:"Deseja realmente remover esta franquia?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{d(!0,"Removendo franquia");let e=await ay.delete("/franchise/".concat(s.id));if(d(),e.data.error)throw o(e.data.error.message),Error("Erro ao remover franquia! \n\n"+e.data.error.message);et.Am.success("Franquia removida com sucesso!"),(0,K.Mr)()}})}catch(e){d(),et.Am.error(e.message)}},setShowAddressForm:u,showAddressForm:c,refreshData:x}};var aw=a(37276);let aZ=e=>{var t,a;let{t:n}=(0,p.$)("common"),[s,i]=l.useState(e.address||{}),[o,d]=l.useState({});function c(e){i(t=>({...t,...e}))}async function u(){try{return fetch("https://viacep.com.br/ws/"+s.zip+"/json/").then(e=>e.json().then(e=>{if(e.erro){(0,Q.C)(e.erro);return}i({zip:s.zip,street:e.logradouro,district:e.bairro,city:e.localidade,state:e.uf,number:void 0,coords:{}})}))}catch(e){et.Am.error(e.message)}}return(0,ev.ss)(()=>{var e,t;(null===(e=null===(t=s.zip)||void 0===t?void 0:t.toString())||void 0===e?void 0:e.length)===8&&u()},[s.zip]),(0,r.jsx)("div",{className:"address-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:n("address"),onGoBack:e.onClose}),(0,r.jsxs)("div",{className:"form-content address",children:[(0,r.jsx)(es.Z,{className:"textfield",label:n("address_zip"),value:s.zip||"",type:"text",inputProps:{maxLength:8},onChange:e=>{var t,a,n,s;
1c({zip:null===(t=null===(a=null==e?void 0:null===(n=e.target)||void 0===n?void 0:null===(s=n.value)||void 0===s?void 0:s.replace(/\D/g,""))||void 0===a?void 0:a.replace(/-(?!>)/g,""))||void 0===t?void 0:t.substring(0,8)})},error:!!o.zip,helperText:o.zip}),(0,r.jsx)(es.Z,{className:"textfield",label:n("address_street"),value:s.street||"",onChange:e=>c({street:e.target.value}),error:!!o.street,helperText:o.street}),(0,r.jsx)(es.Z,{className:"textfield",label:n("address_number"),value:s.number||"",onChange:e=>c({number:e.target.value}),error:!!o.number,helperText:o.number}),(0,r.jsx)(es.Z,{className:"textfield",label:n("address_district"),value:s.district||"",onChange:e=>c({district:e.target.value}),error:!!o.district,helperText:o.district}),(0,r.jsx)(es.Z,{className:"textfield",label:"* "+n("address_city"),value:s.city||"",onChange:e=>c({city:e.target.value}),error:!!o.city,helperText:o.city}),(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(e.stateLabel||n("address_state")),value:s.state||"",onChange:e=>c({state:e.target.value}),error:!!o.state,helperText:o.state}),e.showLatitude&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:n("address_coords_lat"),value:(null===(t=s.coords)||void 0===t?void 0:t.lat)||"",type:"number",onChange:e=>c({coords:{...s.coords,lat:Number(e.target.value)}})}),(0,r.jsx)(es.Z,{className:"textfield",label:n("address_coords_lng"),value:(null===(a=s.coords)||void 0===a?void 0:a.lng)||"",type:"number",onChange:e=>c({coords:{...s.coords,lng:Number(e.target.value)}})})]})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:e.onClose,children:"".concat(n("event.close"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:function(){let t={},a="Campo obrigat\xf3rio";if((null==s?void 0:s.street)||(t.street=a),(null==s?void 0:s.number)||(t.number=a),(null==s?void 0:s.zip)||(t.zip=a),(null==s?void 0:s.district)||(t.district=a),(null==s?void 0:s.city)||(t.city=a),(null==s?void 0:s.state)||(t.state=a),Object.keys(t).length)return d(t),et.Am.error("Formul\xe1rio incompleto!");e.onClose(),e.onChange(s)},children:"".concat(n(s.street?"address_update":"address_create"))})]})]})})},aC=(e,t,a,n)=>{let{toggleLoader:s}=(0,ee.U2)(),[i,r]=l.useState(!0),[o,d]=l.useState({visible:!0,visibleHomeSite:!1}),[c,u]=l.useState(null),m=l.useRef(void 0),[h,v]=l.useState({}),[x,p]=l.useState(!1),[g,j]=l.useState(""),[f,b]=l.useState([]),[y,N]=l.useState(!1),[k,w]=l.useState((null==o?void 0:o.professionals)||[]),Z=l.useRef([]),C=(0,ev.Nr)(g,300),[S,_]=l.useState(""),D=l.useRef(),E=l.useMemo(()=>k.map(e=>e.professionalId||e.id).filter(Boolean),[k]),[P,I]=l.useState(!1);function A(e){let t={...o,...e};d(t),I(!0)}async function T(){try{var t,a,i,r,l,c;let u={};if(!o.coverImage){u.cover_image_required=!0,et.Am.error("A imagem de capa \xe9 obrigat\xf3ria!"),v(u);return}if(!o.title){u.title_required=!0,et.Am.error("O t\xedtulo \xe9 obrigat\xf3rio!"),v(u);return}if(!(null==k?void 0:k.length)){u.professional_required=!0,et.Am.error("O profissional \xe9 obrigat\xf3rio!"),v(u);return}if(Object.keys(u).length){et.Am.error("Formul\xe1rio incompleto!");return}if(v({}),o.audioGuide&&!RegExp(/([A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ_ ]+)-([A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ_ ]+).mp3/).test(S)){et.Am.error('O formato do AudioGuide n\xe3o segue o padr\xe3o: "T\xedtulo da faixa-Autor.mp3"');return}s(!0,"Salvando ambiente");let m={...o,eventId:e,professionalsIds:E,productsToRemove:Z.current};(null==o?void 0:null===(t=o.images)||void 0===t?void 0:t.length)&&(m.images=null==o?void 0:null===(c=o.images)||void 0===c?void 0:c.filter(e=>"environment-catalogation-photos"!==e.source));let h=await ay.post("/environment/save",(0,eD.GZ)(m),{headers:{"Content-Type":"multipart/form-data"}});if(s(),h.data.error){console.log(JSON.stringify(h.data.error,null,2)),et.Am.error("Erro ao salvar ambiente! \n\n"+h.data.error.message);return}d({...h.data.environment,images:[...(null===(a=h.data)||void 0===a?void 0:null===(i=a.environment)||void 0===i?void 0:i.images)||[],...null===(r=null===(l=(null==o?void 0:o.images)||[])||void 0===l?void 0:l.filter(e=>e._id))||void 0===r?void 0:r.filter(e=>{var t,a,n;return!(null===(t=h.data)||void 0===t?void 0:null===(a=t.environment)||void 0===a?void 0:null===(n=a.images)||void 0===n?void 0:n.find(t=>t._id===e._id))})]}
1),I(!1),n(),!1===h.data.consolidatedSynced?et.Am.warning("Ambiente salvo, mas a sincroniza\xe7\xe3o com o consolidado falhou. Use o bot\xe3o Sincronizar na aba Imagens dos Ambientes."):et.Am.success("Ambiente salvo com sucesso!"),v({})}catch(e){console.log("\uD83D\uDE80 ~ onSaveEnvironment ~ err:",e),s(),et.Am.error(e.message)}}return(0,ev.gt)(P,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{async function e(){try{var e,a,n,s;let i=await ay.get("/environment/list?id=".concat(t,"&isFromAdminPanel=true")),l=null===(e=i.data)||void 0===e?void 0:e.error;if(l)throw Error(l);i.data&&d(i.data),(null===(a=i.data)||void 0===a?void 0:a.audioGuide)&&_(null===(n=i.data.audioGuide)||void 0===n?void 0:n.title),(null===(s=i.data)||void 0===s?void 0:s.professionals)&&w(i.data.professionals),r(!1)}catch(e){r(!1),et.Am.error(e.message)}}t?e():r(!1)},[t]),(0,ev.ss)(()=>{C&&(async()=>{try{var e,t;p(!0);let a=await (0,J.ZP)("/professional/list?search=".concat(encodeURIComponent(C),"&limit=20"));if(p(!1),null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.error)return;b(((null==a?void 0:null===(t=a.data)||void 0===t?void 0:t.professionals)||[]).map(e=>{var t;return{id:e.id,professionalId:e.id,name:e.name,avatar:e.avatar,slug:e.slug,email:null===(t=e.contacts)||void 0===t?void 0:t.email,members:e.members}}))}catch(e){p(!1),et.Am.error(e.message)}})()},[C]),{loading:i,environment:o,setEnvironmentData:A,selectedImageTag:c,setSelectedImageTag:(e,t)=>{u(e),m.current=t},selectedImageTagIndex:m.current,removeImage:function(e){(0,em.Z)({text:"Deseja realmente remover esta imagem? Todos os produtos contidos nela ser\xe3o exclu\xeddos tamb\xe9m.",confirmButtonText:"Sim, desejo remover",onConfirm:()=>{let t=[...o.images];Z.current=[...Z.current,...t[e].tags.map(e=>e.productId).filter(e=>e)],t.splice(e,1),A({images:t})}})},onImageTagsChange:function(e){if(void 0===m.current)return;let t={...o};t.images[m.current].tags=e,d(t)},onImageAltChange:function(e){if(void 0===m.current)return;let t={...o};t.images[m.current].imageAlt=e,d(t)},onSaveEnvironment:T,errors:h,onRemoveEnvironment:function(){try{(0,em.Z)({text:"Deseja realmente remover este ambiente?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{s(!0,"Removendo ambiente");let e=await ay.delete("/environment/remove/".concat(o.id));if(s(),e.data.error)throw v(e.data.error.message),Error("Erro ao remover ambiente! \n\n"+e.data.error.message);n(),et.Am.success("Ambiente removido com sucesso!"),I(!1),a()}})}catch(e){s(),et.Am.error(e.message)}},searchProfessional:g,setSearchProfessional:j,professionalOptions:f,setProfessionals:w,professionals:k,fetchingProfessionals:x,showProfessionalForm:y,setShowProfessionalForm:N,onGoBack:function(){P?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:a}):(I(!1),a())},audioGuideFileName:S,setAudioGuideFileName:_,professionalsIds:E,onDragStart:function(e){let t=e.target.closest(".draggable");D.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2},onDragEnd:function(e){e.target.style.opacity=1},onDragOver:function(e){e.preventDefault();let t=e.target.closest(".draggable");D.current!==(null==t?void 0:t.dataset.index)?t.style.transform="scale(0.9)":t.style.transform="initial"},onDragLeave:function(e){let t=e.target.closest(".draggable");t.style.transform="initial"},onDrop:function(e){e.preventDefault();let t=e.target.closest(".draggable");t.style.transform="initial";let a=null==t?void 0:t.dataset.index;if(D.current&&D.current!==a){let e=[...o.images],[t]=e.splice(D.current,1);e.splice(a,0,t),A({images:e.map((e,t)=>(e.order=t,e))})}}}};var aS=a(38876);function a_(e){return e.charAt(0).toUpperCase()+e.slice(1)}let aD=e=>{let{label:t,className:a,autoCompleteClassName:n,endpoint:s,multiple:i,defaultValue:o=[],onChange:d}=e,[c,u]=l.useState(!1),[m,h]=l.useState(o),[v,x]=l.useState(!1),p=l.useRef(!1);async function g(){try{x(!0);let{data:e}=await ay(s);x(!1),h(e),p.current=!0}catch(e){x(!1),et.Am.error(e.message)}}return l.useEffect(()=>{c&&!p.current&&g()},[c,s]),(0,r.jsx)(e_.Z,{multiple:i,open:c,onOpen:()=>{u(!0)},onClose:()=>{u(!1)},options:m,onChange:(e,t)=>
1d([...new Set(t)].map(a_)),autoComplete:!0,freeSolo:!0,className:n,loading:v,value:o,filterSelectedOptions:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,className:a,label:t,InputProps:{...e.InputProps,style:{textTransform:"capitalize"},endAdornment:(0,r.jsxs)(r.Fragment,{children:[v&&(0,r.jsx)(tK.Z,{color:"inherit",size:20}),e.InputProps.endAdornment]})}})})};var aE=l.memo(aD),aP=a(63893),aI=a(62798),aA=a(63375);let aT={mouseX:null,mouseY:null},aR=(e,t,a,s)=>{let{toggleLoader:i}=(0,ee.U2)(),r=null==a?void 0:a._id,[o,d]=l.useState(null==a?void 0:a.tags),[c,u]=l.useState(aT),[m,h]=l.useState(aT),[v,x]=l.useState(),p=l.useRef(),[g,j]=l.useState({});l.useEffect(()=>{let e=document.querySelector(".image-container img");function t(e){var t=e.target.getBoundingClientRect(),a=Math.round((e.clientX-t.left-10)*100/t.width*100)/100+"%",n=Math.round((e.clientY-t.top-10)*100/t.height*100)/100+"%";let s=[...o];s.push({position:{left:a,top:n}}),d(s)}return null==e||e.addEventListener("click",t),()=>null==e?void 0:e.removeEventListener("click",t)},[o]);let f=async e=>{e.preventDefault();let t=e.target.getAttribute("data-point");p.current=Number(t);let a=Number(t)-1,n=o[a];if(n){if(n.productId&&!n.product){i(!0,"Buscando produto...");let e=await ay.get("/product/list?id=".concat(n.productId,"&isFromAdminPanel=true"));i(),n={...n,product:e.data},d(e=>(e[a]=n,e))}x(n),u({mouseX:e.clientX,mouseY:e.clientY})}},b=()=>{p.current=void 0,u(aT),x(null)},y=async e=>{e.preventDefault(),h({mouseX:e.clientX,mouseY:e.clientY})};function N(e){if(p.current){let t=[...o],a=p.current-1,n={...t[p.current-1],...e};return x(n),t[a]=n,d(t),t}}async function k(n){try{var l,o;n=n||v;let d={};if((null==n?void 0:null===(l=n.product)||void 0===l?void 0:l.coverImage)||(d.cover_image_required=!0),(null==n?void 0:null===(o=n.product)||void 0===o?void 0:o.title)||(d.title_required=!0),Object.keys(d).length){et.Am.error("Formul\xe1rio incompleto!");return}i(!0,"Salvando produto");let c=await ay.post("/product/save",(0,eD.GZ)({...null==n?void 0:n.product,eventId:e,position:null==n?void 0:n.position,environmentId:t,imageId:r,source:a.source}),{headers:{"Content-Type":"multipart/form-data"}});if(i(),c.data.error)throw console.log(JSON.stringify(c.data.error,null,2)),j(c.data.error.message),Error("Erro ao salvar ambiente! \n\n"+c.data.error.message);let u=N({...n,_id:(null==n?void 0:n._id)||c.data.tagId,product:c.data.product,productId:c.data.product.id});s(u),et.Am.success("Produto salvo com sucesso!"),b(),j({})}catch(e){i(),et.Am.error(e.message)}}return{tags:o,selectedTag:v,removeTag:function(){try{if(!(null==v?void 0:v.productId)){let e=[...o];e.splice(p.current-1,1),d(e),s(e),b(),et.Am.success("produto removido com sucesso!");return}(0,em.Z)({text:"Deseja realmente remover este produto?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{i(!0,"Removendo produto");let e=await ay.delete("/product/remove/".concat(null==v?void 0:v.productId,"/").concat(r,"/").concat(null==v?void 0:v._id));if(i(),e.data.error)return j(e.data.error.message),et.Am.error("Erro ao remover produto! \n\n"+e.data.error.message);if(p.current){let e=[...o];e.splice(p.current-1,1),d(e),s(e),b(),et.Am.success("produto removido com sucesso!")}}})}catch(e){i(),et.Am.error(e.message)}},handleMenuOpen:f,handleMenuClose:b,menu:c,setTagInfo:N,saveProduct:k,errors:g,onDragAndDropTag:function(e){clearTimeout(n);let t=o[e.index];t.productId&&t._id&&(n=setTimeout(()=>{p.current=Number(e.index+1),k({...t,position:{top:e.top,left:e.left,referenceImageSize:e.referenceImageSize}})},500))},menuQrCode:m,onShowQrCode:y,onCloseQrCode:function(){h(aT)}}};var aL=a(1653),aq=a(48256),aM=a.n(aq),aO=function(e){let{targets:t}=e,[a,n]=(0,l.useState)(!1),[s,i]=(0,l.useState)(""),[r,o]=(0,l.useState)({}),d=(0,l.useCallback)(e=>{let{field:a,text:s}=e;try{if(!t.length||!s)return;(async()=>{n(!0),i(a);let{data:e}=await J.ZP.post("/translate",{targets:t,text:s}),r={[a]:e};setTimeout(()=>{o(e=>({...e,...r})),n(!1)},2e3)})()}catch(e){n(!1),(0,Q.C)("\uD83D\uDE80 ~ useEffect ~ error:",e)}},[t]);return{loading:a,translate:d,translatingField:s,translations:r}};let aF=e=>{var t,a,n,o,d,u,m,h,x,g,j,f,b,y,N,k,w,Z,C,S,_,D,E,P,I,A,T,R,L;let{t:q}=(0,p.$)("admin"),{translate:M,loading:O,translatingField:F,translations:B}=aO({targets:["en","es"]}),{data:U,environmentId:z,eventId:V,onClose:G,onChange:W,onImageAltChange:$,imageAlt:H}=e,{tags:J,handleMenuOpen:Q,handleMenuClose:Y,menu:K,removeTag:ee,setTagInfo:et,selectedTag:el,saveProduct:eo,errors:ed,onDragAndDropTag:ec,menuQrCode:eu,onShowQrCode:em,onCloseQrCode:eh}=aR(V,z,U,W),[ev,ex]=l.useState([]);return(l.useEffect(()=>{el&&e();async function e(){try{var e;let t=await ay.get("/advertising-brand/list");if(null===(e=t.data)||void 0===e?void 0:e.error)throw Error(t.data.error.message||t.data.error);ex(Array.isArray(t.data)?t.data:[])}catch(e){console.error(e)}}},[el]),l.useEffect(()=>{!O&&F&&(console.log("\uD83D\uDE80 ~ useEffect ~ translatingField:",F,"translateLoading:",O,"translations:",B),0!==Object.keys(B).length&&(null==B?void 0:B.description)&&"description"===F&&et({...el,product:{...null==el?void 0:el.product,descriptionEn:B.description.en,descriptionEs:B.description.es}}))},[O,F,B]),U)?(0,r.jsxs)("div",{className:"image-tags-form forms",children:[(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:q("environment.products"),onGoBack:G}),(0,r.jsxs)("div",{className:"image-container",onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"},onDrop:function(e){e.preventDefault();
1let[t,a]=s.children,n=Math.round((e.clientX-i.left-7)*100/i.width*100)/100+"%",r=Math.round((e.clientY-i.top-7)*100/i.height*100)/100+"%";t.style.top=r,t.style.left=n,a.style.top="calc(".concat(r," + 14px)"),a.style.left="calc(".concat(n," + 14px)"),ec({left:n,top:r,index:t.dataset.point-1,referenceImageSize:{width:i.width,height:i.height}})},children:[(0,r.jsx)("img",{src:(0,eD.e6)(U.image),alt:"",draggable:!1}),function(e,t){function a(e){e.target.style.opacity=.5,i=(s=e.target).parentElement.getBoundingClientRect(),initialX=e.clientX-i.top,initialY=e.clientY-i.left}function n(e){currentX=e.clientX-(null==i?void 0:i.left),currentY=e.clientY-(null==i?void 0:i.top)}function l(e){e.target.style.opacity=1}return null==e?void 0:e.map((e,s)=>{let{position:i,product:o}=e,d=null==o?void 0:o.onSale;return(0,r.jsxs)("div",{draggable:!0,onDragStart:a,onDragEnd:l,onDrag:n,children:[(0,r.jsx)("div",{onDoubleClick:t,className:"pulse","data-point":s+1,style:{top:i.top,left:i.left,backgroundColor:d?"transparent":"white"},children:!!d&&(0,r.jsx)(c.xh,{className:"price-tag-icon"})}),(0,r.jsx)("span",{className:"pulse-text",style:{top:"calc(".concat(i.top," + 14px)"),left:"calc(".concat(i.left," + 14px)")},children:s+1})]},s)})}(J,Q)]}),(0,r.jsx)("div",{className:"fields",style:{paddingLeft:20,paddingRight:20,marginLeft:0,marginTop:0},children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(q("environment.image_alt")),value:H||"",onChange:e=>{var t;return $((null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value)||"")}})}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"outlined",onClick:G,children:q("environment.close")})})]}),(0,r.jsx)(aA.Z,{disablePortal:!0,open:null!==K.mouseY,onClose:Y,anchorReference:"anchorPosition",PaperProps:{className:"product-form"},anchorPosition:null!==K.mouseY&&null!==K.mouseX?{top:K.mouseY,left:K.mouseX}:void 0,children:(0,r.jsxs)("div",{className:"tag-form",onKeyDown:e=>e.stopPropagation(),children:[(0,r.jsx)("h3",{children:q("environment.product_information")}),(0,r.jsx)(eE.Z,{refId:"product-cover-image",onChange:e=>et({...el,product:{...null==el?void 0:el.product,coverImage:e}}),defaultImage:(null==el?void 0:null===(t=el.product)||void 0===t?void 0:t.coverImage)?null:(0,eD.e6)(U.image),aspectRatio:16/9,renderBtn:(0,r.jsxs)("label",{className:"image"+((null==ed?void 0:ed.cover_image_required)?" error":""),children:[(0,r.jsx)(eP.Z,{src:null==el?void 0:null===(a=el.product)||void 0===a?void 0:a.coverImage,layout:"fill"}),(null==ed?void 0:ed.cover_image_required)&&(0,r.jsx)(ti.Z,{error:!0,className:"image-error",children:q("required_field")})]})}),(0,r.jsx)(es.Z,{className:"textfield",label:"T\xedtulo",value:(null==el?void 0:null===(n=el.product)||void 0===n?void 0:n.title)||"",onChange:e=>et({...el,product:{...null==el?void 0:el.product,title:e.target.value}})}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)("div",{className:"description-form",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(q("environment.product_description")," - pt-BR"),multiline:!0,rows:3,value:(null==el?void 0:null===(o=el.product)||void 0===o?void 0:o.description)||"",helperText:"".concat((null==el?void 0:null===(d=el.product)||void 0===d?void 0:null===(u=d.description)||void 0===u?void 0:u.length)||0,"/250"),error:((null==el?void 0:null===(m=el.product)||void 0===m?void 0:null===(h=m.description)||void 0===h?void 0:h.length)||0)>=250,onChange:e=>et({...el,product:{...null==el?void 0:el.product,description:e.target.value.substring(0,250)}})}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{var e,t;return(null==el?void 0:null===(e=el.product)||void 0===e?void 0:e.description)?M({field:"description",text:null==el?void 0:null===(t=el.product)||void 0===t?void 0:t.description}):null},disabled:O,children:O&&"description"===F?"".concat(q("translating")):"".concat(q("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(q("environment.product_description")," - en-US"),multiline:!0,rows:3,value:(null==el?void 0:null===(x=el.product)||void 0===x?void 0:x.descriptionEn)||"",helperText:"".concat((null==el?void 0:null===(g=el.product)||void 0===g?void 0:null===(j=g.descriptionEn)||void 0===j?void 0:j.length)||0,"/250"),error:((null==el?void 0:null===(f=el.product)||void 0===f?void 0:null===(b=f.descriptionEn)||void 0===b?void 0:b.length)||0)>=250,onChange:e=>et({...el,product:{...null==el?void 0:el.product,descriptionEn:e.target.value.substring(0,250)}})})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(q("environment.product_description")," - es-ES"),multiline:!0,rows:3,value:(null==el?void 0:null===(y=el.product)||void 0===y?void 0:y.descriptionEs)||"",helperText:"".concat((null==el?void 0:null===(N=el.product)||void 0===N?void 0:null===(k=N.descriptionEs)||void 0===k?void 0:k.length)||0,"/250"),error:((null==el?void 0:null===(w=el.product)||void 0===w?void 0:null===(Z=w.descriptionEs)||void 0===Z?void 0:Z.length)||0)>=250,onChange:e=>et({...el,product:{...null==el?void 0:el.product,descriptionEs:e.target.value.substring(0,250)}})})}]}),(0,r.jsx)(e_.Z,{className:"textfield",options:ev,getOptionLabel:e=>(null==e?void 0:e.name)||"",isOptionEqualToValue:(e,t)=>
1(null==e?void 0:e.id)===(null==t?void 0:t.id),value:ev.find(e=>{var t;return e.id===(null==el?void 0:null===(t=el.product)||void 0===t?void 0:t.advertisingBrandId)})||null,onChange:(e,t)=>et({...el,product:{...null==el?void 0:el.product,advertisingBrandId:null==t?void 0:t.id}}),renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"textfield",label:"Marcas Publicidades"})}),(0,r.jsx)(aE,{label:"Marca do produto",className:"textfield",multiple:!0,endpoint:"product/tags/brand",defaultValue:null==el?void 0:null===(C=el.product)||void 0===C?void 0:C.brand,onChange:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];et({...el,product:{...null==el?void 0:el.product,brand:e,internalTag:e.map(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toUpperCase()}).includes("CASACOR")}})}}),(0,r.jsx)(aE,{label:"Categorias do produto",multiple:!0,className:"textfield",endpoint:"product/tags/categories",defaultValue:null==el?void 0:null===(S=el.product)||void 0===S?void 0:S.categories,onChange:e=>et({...el,product:{...null==el?void 0:el.product,categories:e}})}),(0,r.jsx)(es.Z,{className:"textfield link",label:q("environment.product_link"),value:(null==el?void 0:null===(_=el.product)||void 0===_?void 0:_.externalLink)||"",disabled:null==el?void 0:null===(D=el.product)||void 0===D?void 0:D.internalTag,onChange:e=>et({...el,product:{...null==el?void 0:el.product,externalLink:e.target.value}})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ea.Z,{label:"Tag interna (Quero saber mais)",className:"checkbox",control:(0,r.jsx)(en.Z,{checked:!!(null==el?void 0:null===(E=el.product)||void 0===E?void 0:E.internalTag),onChange:e=>{var t,a;return et({...el,product:{...null==el?void 0:el.product,internalTag:e.target.checked,onSale:!1,brand:e.target.checked?[...(null==el?void 0:null===(t=el.product)||void 0===t?void 0:t.brand)||[],"CASACOR"]:[...(null==el?void 0:null===(a=el.product)||void 0===a?void 0:a.brand)||[]].filter(e=>"CASACOR"!==e)}})}})}),(0,r.jsx)(ea.Z,{label:"Liberar para venda",className:"checkbox",control:(0,r.jsx)(en.Z,{checked:!!(null==el?void 0:null===(P=el.product)||void 0===P?void 0:P.onSale),onChange:e=>et({...el,product:{...null==el?void 0:el.product,onSale:e.target.checked,internalTag:!1}})})})]}),(null==el?void 0:null===(I=el.product)||void 0===I?void 0:I.onSale)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{className:"textfield value",label:q("environment.product_currency"),value:(null==el?void 0:null===(A=el.product)||void 0===A?void 0:A.currency)||"",onChange:e=>et({...el,product:{...null==el?void 0:el.product,currency:e.target.value}})}),(0,r.jsx)(es.Z,{className:"textfield value",label:q("environment.product_value"),value:(null==el?void 0:null===(T=el.product)||void 0===T?void 0:T.value)||"",onChange:e=>et({...el,product:{...null==el?void 0:el.product,value:e.target.value}})})]}),(0,r.jsx)(es.Z,{className:"textfield",label:q("environment.product_sale_email_contact"),value:(null==el?void 0:null===(R=el.product)||void 0===R?void 0:R.saleEmailContact)||"",onChange:e=>et({...el,product:{...null==el?void 0:el.product,saleEmailContact:e.target.value}})})]}),(0,r.jsx)(aA.Z,{disablePortal:!0,open:null!==eu.mouseY,onClose:eh,anchorReference:"anchorPosition",PaperProps:{className:"product-form"},anchorPosition:null!==eu.mouseY&&null!==eu.mouseX?{top:eu.mouseY,left:eu.mouseX}:void 0,children:(0,r.jsx)(aM(),{filename:"".concat((0,eD.k6)((null==el?void 0:null===(L=el.product)||void 0===L?void 0:L.title)||""),"-qrcode.pdf"),children:e=>{var t;
1let{toPdf:a,targetRef:n}=e;return(0,r.jsxs)("div",{className:"qrcode-form",ref:n,children:[(0,r.jsxs)("h3",{children:[null==el?void 0:null===(t=el.product)||void 0===t?void 0:t.title," QRCode"]}),(0,r.jsx)(aL.ZP,{size:256,value:"".concat("https://apiv2.appcasacor.com.br","/deeplink?environment/").concat(z,"/").concat(null==el?void 0:el.productId)}),(0,r.jsx)("div",{className:"qrcode-link",children:"".concat("https://apiv2.appcasacor.com.br","/deeplink?environment/").concat(z,"/").concat(null==el?void 0:el.productId)}),(0,r.jsx)(v.Z,{variant:"contained",onClick:a,children:"Download"})]})}})}),(0,r.jsxs)("div",{className:"tag-actions",children:[(0,r.jsx)(X.Z,{size:"large",color:"error",className:"remove-btn",onClick:ee,children:(0,r.jsx)(er.Z,{})}),(0,r.jsx)(X.Z,{size:"large",color:"primary",className:"qrcode-btn",onClick:em,children:(0,r.jsx)(aI.Z,{})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:Y,children:q("environment.close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>eo(),children:q("environment.save")})]})]})})]}):null},aB=e=>{let{onProfessionalCreated:t}=e,{toggleLoader:a}=(0,ee.U2)(),{t:n}=(0,p.$)("admin"),[s,i]=l.useState({}),[o,d]=l.useState(!1),[c,u]=l.useState(!1),[m,h]=l.useState(""),{name:x,email:g}=s;function j(e){i(t=>({...t,...e}))}async function f(){try{var e,n,i,r;if(!x)throw Error("Informe o nome do profissional!");if(c&&!g)throw Error("Email \xe9 obrigat\xf3rio para criar conta de acesso!");a(!0,"Salvando novo profissional");let l=m.split(",").map(e=>e.trim()).filter(Boolean);if(!c||l.length){let e=l.length?[{name:x,contacts:g?{email:g}:void 0},...l.map(e=>({professionalId:e}))]:[{name:x,contacts:g?{email:g}:void 0}],n=await J.ZP.post("/professional",{name:x,contacts:g?{email:g}:void 0,members:e});if(a(),null==n?void 0:null===(r=n.data)||void 0===r?void 0:r.error)throw Error("Erro ao adicionar cadastro! \n\n"+(n.data.error.message||n.data.error));let s=n.data.professional;t({id:s.id,name:s.name,avatar:s.avatar,slug:s.slug}),d(!1),h(""),et.Am.success(l.length?"Cadastro conjunto criado. URL: "+s.slug:"Cadastro criado (sem conta de acesso)");return}let o=await J.ZP.post("/user/create-professional",(0,eD.GZ)({...s,createAccount:c}),{headers:{"Content-Type":"multipart/form-data"}});if(a(),null==o?void 0:null===(e=o.data)||void 0===e?void 0:e.error)throw Error("Erro ao adicionar profissional! \n\n"+o.data.error.message);let u=(null==o?void 0:null===(n=o.data)||void 0===n?void 0:n.user)||(null==o?void 0:null===(i=o.data)||void 0===i?void 0:i.professional);if(!u)throw Error("Erro ao adicionar profissional! \n\nN\xe3o foi poss\xedvel cadastrar!");t(u),d(!1),et.Am.success("Profissional adicionado com sucesso!")}catch(e){a(),et.Am.error(e.message)}}return(0,r.jsxs)("div",{className:"professional-form",children:[(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>d(!0),style:{width:240},children:"".concat(n("environment.new_professional"))}),(0,r.jsx)(K.ZP,{showAt:o,onClose:()=>d(!1),children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Novo Profissional",onGoBack:()=>d(!1)}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"avatar",children:(0,r.jsx)(eE.Z,{refId:"prof-avatar",round:!0,maxWidthOrHeight:500,onChange:e=>{j({avatar:e})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)(eP.Z,{src:s.avatar,layout:"fill"})})})}),(0,r.jsx)(es.Z,{className:"textfield",label:"*"+n("environment.professional_name"),value:x||"",helperText:"Um arquiteto. Para A+B, informe os ids dos outros abaixo.",onChange:e=>{e.stopPropagation(),j({name:e.target.value})}}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:c,onChange:(e,t)=>
1u(t)}),label:"Criar conta de acesso (login)"}),(0,r.jsx)(es.Z,{className:"textfield",label:c?"*Email":"Email (opcional)",value:g||"",helperText:c?"Mesmo email usado para login!":"Sem conta: email s\xf3 como contato p\xfablico.",type:"email",onChange:e=>{e.stopPropagation(),j({email:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"Cadastro conjunto — ids dos outros arquitetos",value:m,helperText:"Opcional. IDs j\xe1 cadastrados, separados por v\xedrgula. Cria a p\xe1gina A+B com URL dos nomes e link para cada perfil.",onChange:e=>h(e.target.value)}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>d(!1),children:"".concat(n("close"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:f,children:"".concat(n("professional.create"))})]})]})]})})})]})},aU=e=>{var t,a,n,s,i,o,d,c;let{t:u,i18n:m}=(0,p.$)("admin"),{translate:h,loading:x,translatingField:g,translations:j}=aO({targets:["en","es"]}),f=l.useRef(),{loading:b,environment:y,setEnvironmentData:N,selectedImageTag:k,setSelectedImageTag:w,selectedImageTagIndex:Z,onImageTagsChange:C,onImageAltChange:S,removeImage:_,onSaveEnvironment:D,errors:E,onRemoveEnvironment:P,setSearchProfessional:I,professionalOptions:A,setProfessionals:T,professionals:R,fetchingProfessionals:L,onGoBack:q,audioGuideFileName:M,setAudioGuideFileName:O,professionalsIds:F,onDragStart:B,onDragEnd:U,onDragOver:z,onDragLeave:V,onDrop:G}=aC(e.eventId,null===(t=e.environment)||void 0===t?void 0:t.id,e.onCloseModal,e.onChange),{id:W,coverImage:$,metaDataCoverImage:H={imageAlt:"",imageTitle:""},metaDataCoverImageEn:J={imageAlt:"",imageTitle:""},metaDataCoverImageEs:Q={imageAlt:"",imageTitle:""},title:Y,slug:en,copyright:el,description:eo,descriptionEn:ed,descriptionEs:eu,metaDescription:em="",metaDescriptionEn:eh="",metaDescriptionEs:ev="",images:ex,visible:ep,visibleHomeSite:eg,location:ej,environments:ef,audioGuide:eb,updatedAt:ey,lastUpdatedBy:eN,roboflowVersion:ek,confidence:ew}=y;return(console.log("enviroment:",y),l.useEffect(()=>{if(!x&&g&&(console.log("\uD83D\uDE80 ~ useEffect ~ translatingField:",g,"translateLoading:",x,"translations:",j),0!==Object.keys(j).length)){if((null==j?void 0:j.metaDataCoverImageTitle)&&"metaDataCoverImageTitle"===g||(null==j?void 0:j.metaDataCoverImageAlt)&&"metaDataCoverImageAlt"===g){N({metaDataCoverImageEn:{...J,imageAlt:j.metaDataCoverImageAlt.en,imageTitle:j.metaDataCoverImageTitle.en},metaDataCoverImageEs:{...Q,imageAlt:j.metaDataCoverImageAlt.es,imageTitle:j.metaDataCoverImageTitle.es}});return}if((null==j?void 0:j.description)&&"description"===g)return N({descriptionEn:j.description.en,descriptionEs:j.description.es});if((null==j?void 0:j.metaDescription)&&"metaDescription"===g)return N({metaDescriptionEn:j.metaDescription.en,metaDescriptionEs:j.metaDescription.es})}},[j,g,x]),b)?(0,r.jsx)("div",{className:"environment-form",children:(0,r.jsx)(ee.aN,{message:"Carregando ambiente"})}):(0,r.jsxs)("div",{className:"environment-form",children:[(0,r.jsx)(ei.Z,{title:u(W?"environment.edit":"environment.create"),onGoBack:q,data:{id:W,lastUpdatedBy:eN,updatedAt:ey}}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"A imagem de capa do Ambiente *"}),(0,r.jsx)(eE.Z,{refId:"environment-form.image",onChange:e=>N({coverImage:e}),aspectRatio:16/9,renderBtn:(0,r.jsx)("label",{className:"image"+((null==E?void 0:E.cover_image_required)?" error":""),children:(0,r.jsx)(au(),{src:(0,eD.e6)($),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:"",draggable:!1})})}),(0,r.jsx)(ea.Z,{label:String(u("environment.visible_app")),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!ep,onChange:e=>N({visible:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:String(u("environment.visible_home_site")),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eg,onChange:e=>N({visibleHomeSite:e.target.checked})})}),(0,r.jsx)("div",{className:"fields",style:{paddingLeft:0,marginLeft:0},children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)("div",{className:"meta-data-cover-image-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_alt")," - pt-BR"),value:(null==H?void 0:H.imageAlt)||"",onChange:e=>N({metaDataCoverImage:{...H,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==H?void 0:null===(a=H.imageAlt)||void 0===a?void 0:a.length)||0,"/").concat(u("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_title")," - pt-BR"),value:(null==H?void 0:H.imageTitle)||"",onChange:e=>N({metaDataCoverImage:{...H,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==H?void 0:null===(n=H.imageTitle)||void 0===n?void 0:n.length)||0,"/").concat(u("event.meta_data_cover_image_title_limit")),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{N({metaDataCoverImageEn:{imageAlt:"",imageTitle:""},metaDataCoverImageEs:{imageAlt:"",imageTitle:""}}),h({field:"metaDataCoverImageAlt",text:null==H?void 0:H.imageAlt}),h({field:"metaDataCoverImageTitle",text:null==H?void 0:H.imageTitle})},disabled:x,children:x&&("metaDataCoverImageAlt"===g||"metaDataCoverImageTitle"===g)?"".concat(u("translating")):"".concat(u("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_alt")," - en-US"),value:J.imageAlt||"",onChange:e=>N({metaDataCoverImageEn:{...J,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==J?void 0:null===(s=J.imageAlt)||void 0===s?void 0:s.length)||0,"/").concat(u("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_title")," - en-US"),value:J.imageTitle||"",onChange:e=>N({metaDataCoverImageEn:{...J,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==J?void 0:null===(i=J.imageTitle)||void 0===i?void 0:i.length)||0,"/").concat(u("event.meta_data_cover_image_title_limit")),disabled:x})]})},{id:2,label:"es-ES",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_alt")," - es-ES"),value:Q.imageAlt||"",onChange:e=>N({metaDataCoverImageEs:{...Q,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==Q?void 0:null===(o=Q.imageAlt)||void 0===o?void 0:o.length)||0,"/").concat(u("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_data_cover_image_title")," - es-ES"),value:Q.imageTitle||"",onChange:e=>N({metaDataCoverImageEs:{...Q,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==Q?void 0:null===(d=Q.imageTitle)||void 0===d?void 0:d.length)||0,"/").concat(u("event.meta_data_cover_image_title_limit")),disabled:x})]})}]})})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* "+u("environment.name"),value:Y||"",onChange:e=>N({title:e.target.value}),error:null==E?void 0:E.title_required}),(0,r.jsx)(aE,{label:"Ambientes",multiple:!0,className:"textfield",endpoint:"environment/tags/environments",defaultValue:ef,onChange:e=>N({environments:e})}),(0,r.jsxs)("div",{className:"audio-guide",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"AudioGuide (Formato: T\xedtulo da faixa-Autor.mp3)",value:M}),(0,r.jsxs)("div",{className:"audio-guide-actions",children:[(0,r.jsxs)(v.Z,{variant:"outlined",component:"label",children:["Carregar audio guide",(0,r.jsx)("input",{type:"file",accept:".mp3",hidden:!0,ref:f,onChange:e=>{var t;(null===(t=e.target.files)||void 0===t?void 0:t.length)&&(O(e.target.files[0].name),N({audioGuide:e.target.files[0]}))}})]}),!!eb&&(0,r.jsx)(X.Z,{onClick:()=>{O(""),f.current.value="",N({audioGuide:null})},children:(0,r.jsx)(er.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"Localiza\xe7\xe3o interna",value:ej||"",onChange:e=>N({location:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:String(u("environment.credit_photographer")),value:el||"",onChange:e=>N({copyright:e.target.value})})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{className:"textfield",label:String(u("environment.roboflowVersion")),value:ek||"",onChange:e=>N({roboflowVersion:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:String(u("environment.confidence")),value:ew||"",type:"number",onChange:e=>N({confidence:e.target.value})})]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_description")," - pt-BR"),value:em||"",multiline:!0,rows:3,onChange:e=>N({metaDescription:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(em.length,"/").concat(u("event.meta_description_limit")),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>h({field:"metaDescription",text:em}),disabled:x,children:x&&"metaDescription"===g?"".concat(u("translating")):"".concat(u("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_description")," - en-US"),value:eh||"",multiline:!0,rows:3,onChange:e=>N({metaDescriptionEn:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(eh.length,"/").concat(u("event.meta_description_limit")),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(u("event.meta_description")," - es-ES"),value:ev||"",multiline:!0,rows:3,onChange:e=>N({metaDescriptionEs:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(ev.length,"/").concat(u("event.meta_description_limit")),disabled:x})}]})]})]}),(0,r.jsx)("h2",{children:String(u("environment.professionals"))}),(0,r.jsx)("div",{className:"professional-select-container",children:(0,r.jsxs)("div",{style:{display:"flex"},children:[(0,r.jsx)(e_.Z,{id:"prof",className:"prof-select",options:A,includeInputInList:!0,freeSolo:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,multiple:!0,filterSelectedOptions:!0,loading:L,loadingText:"Carregando...",value:R,onChange:(e,t)=>
1{T(t)},onInputChange:(e,t)=>{I(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* ".concat(u("environment.select_profession")," (comece a digitar para buscar)"),error:!!(null==E?void 0:E.professional_required),inputProps:e.inputProps}),renderTags:(e,t)=>e.map(e=>(0,r.jsxs)("li",{...t,className:"prof-selected",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:e.avatar,width:40,height:40,placeholder:"blur",blurDataURL:eD.LG,objectFit:"contain",alt:""})}),(0,r.jsx)("span",{children:e.name}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>T(t=>{let a=t.filter(t=>t.id!==e.id);return a}),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e.id)),renderOption:(e,t)=>{let{name:a,avatar:n}=t;return(0,l.createElement)("li",{...e,key:t.id,className:"prof-list-opt",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:n,width:80,height:80,placeholder:"blur",blurDataURL:eD.LG,objectFit:"contain",alt:""})}),(0,r.jsx)("span",{children:a})]})}}),(0,r.jsx)(aB,{onProfessionalCreated:e=>{T(t=>[...t,e])}})]})}),(0,r.jsx)("h2",{children:String(u("environment.about"))}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:eo||"",onChange:e=>N({description:e}),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{h({field:"description",text:eo})},disabled:x,children:x&&"description"===g?"".concat(u("translating")):"".concat(u("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:ed||"",onChange:e=>N({descriptionEn:e}),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:eu||"",onChange:e=>N({descriptionEs:e}),disabled:x})}]}),y.id&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{children:String(u("environment.images"))}),(0,r.jsxs)("div",{className:"images-container",children:[null==ex?void 0:ex.map((e,t)=>(0,r.jsxs)("div",{className:"draggable",draggable:!0,"data-index":t,onDragStart:B,onDragEnd:U,onDragOver:z,onDragLeave:V,onDrop:G,children:[(0,r.jsx)("div",{className:"order",children:t+1}),(0,r.jsx)(eE.Z,{aspectRatio:.5,refId:"environment-form.image"+t,onChange:e=>{let a=[...ex||[]];a[t].image=e,N({images:a})},renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(au(),{className:"placeholder",src:(0,eD.e6)(e.image),layout:"fill",objectFit:"contain",unoptimized:!!e,alt:"",placeholder:"blur",blurDataURL:eD.LG,draggable:!1}),(0,r.jsxs)("div",{className:"btn-actions",children:[(0,r.jsx)(X.Z,{size:"large",onClick:()=>{if("string"!=typeof e.image)return et.Am.info("Voc\xea precisa salvar o ambiente antes de adicionar tags \xe0 esta imagem!");w(e,t)},children:(0,r.jsx)(aS.Z,{})}),"environment-catalogation-photos"===e.source?(0,r.jsx)("span",{children:"Origem cataloga\xe7\xe3o"}):(0,r.jsx)(X.Z,{size:"large",onClick:()=>_(t),children:(0,r.jsx)(er.Z,{})})]})]})})]},t)),(0,r.jsx)(eE.Z,{refId:"environment-form.image.add",aspectRatio:.5,onChange:e=>{let t=[...ex||[]];t.push({image:e,tags:[],status:"active"}),N({images:t})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)("img",{className:"placeholder",src:"/placeholder.png",alt:"",height:"100%",draggable:!1})})}),(0,r.jsx)(K.ZP,{showAt:!!k,onClose:()=>w(null),children:(0,r.jsx)(aF,{environmentId:y.id,eventId:e.eventId,data:k,imageAlt:null===(c=y.images[Z||0])||void 0===c?void 0:c.imageAlt,onClose:()=>w(null),onChange:C,onImageAltChange:S})})]})]}),(0,r.jsxs)("div",{className:"actions",children:[!!W&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:P,className:"remove-btn",children:String(u("environment.remove"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:D,children:String(u(W?"environment.update":"environment.create"))})]})]})]})},az=e=>
1{let[t,a]=l.useState([]),[n,s]=l.useState({}),[i,r]=l.useState(!1);return l.useEffect(()=>{(async function(){await aN({url:"/franchise/countries",onProcessing:r,onSuccess:e=>a(null==e?void 0:e.sort((e,t)=>e.name.localeCompare(t.name))),onError:e=>{et.Am.error(e.message)}})})()},[]),l.useEffect(()=>{if(e&&(null==t?void 0:t.length)>0){let a=t.find(t=>t.code===e);s(a||{name:""})}},[e,t]),{countries:t,fetchingCountries:i,country:n,setCountry:s}},aV={midwest:"Centro-Oeste",north:"Norte",northeast:"Nordeste",southeast:"Sudeste",south:"Sul",international:"Internacional"},aG={"pt-BR":"Portugu\xeas (pt-BR)","en-US":"Ingl\xeas (en-US)","es-ES":"Espanhol (es-ES)"},aW=e=>{var t;let{t:a}=(0,p.$)("admin"),[n,s]=l.useState(),{loading:i,franchise:o,changeFranchiseData:d,onGoBack:c,submitFranchise:u,errors:m,removeFranchise:h,setShowAddressForm:x,showAddressForm:g,refreshData:j}=ak(e.franchiseId,e.onChange),{countries:f,fetchingCountries:b,country:y,setCountry:N}=az(null==o?void 0:null===(t=o.countryCode)||void 0===t?void 0:t.code),{id:k,name:w,description:Z,coverImage:C,region:S,address:_,lastUpdatedBy:D,updatedAt:E}=o;return i?(0,r.jsx)("div",{className:"franchise-form",children:(0,r.jsx)(ee.aN,{message:"Carregando Franquias"})}):(0,r.jsxs)("div",{className:"franchise-form",children:[(0,r.jsx)(ei.Z,{title:a(k?"franchise.edit":"franchise.create"),onGoBack:c,data:{id:k,lastUpdatedBy:{name:(null==D?void 0:D.name)||""},updatedAt:E&&(0,ej.p6)(E,"Pp")||""}}),(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-franchise",children:[(0,r.jsxs)("div",{className:"form",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"logo",children:"Imagem da Franquia"}),(0,r.jsx)(eE.Z,{refId:"evtimg",onChange:e=>d({coverImage:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(C),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* "+a("franchise.name_franchise"),value:w||"",onChange:e=>d({name:e.target.value}),error:null==m?void 0:m.title_required}),(0,r.jsx)(am.Z,{label:"* Regi\xe3o do Brasil",options:Object.entries(aV).map(e=>{let[t,a]=e;return{value:t,label:a}}),value:S,onChange:e=>d({region:e}),className:"region-select"}),"international"===S&&(0,r.jsx)("div",{className:"country-select",children:(0,r.jsx)(e_.Z,{id:"country-select",options:f,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,disablePortal:!0,loading:b,loadingText:"Carregando...",value:(null==y?void 0:y.name)?y:{name:""},onChange:(e,t)=>
1{N(t||{}),d({countryCode:null==t?void 0:t.code})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"".concat(a("country.select")),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-country",children:(0,r.jsx)(eP.Z,{src:t.flag,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.name})]})})}),(0,r.jsx)(am.Z,{label:"Idioma Padr\xe3o",options:Object.entries(aG).map(e=>{let[t,a]=e;return{value:t,label:a}}),value:(null==o?void 0:o.languageCode)||"pt-BR",onChange:e=>d({languageCode:e}),className:"language-select"}),(0,r.jsx)("div",{className:"row address",children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(a("franchise.address")),value:(0,eD.Cy)(_)||"",onClick:()=>x(!0),error:null==m?void 0:m.address_required})}),(0,r.jsx)(K.ZP,{showAt:g,onClose:()=>x(!1),children:(0,r.jsx)(aZ,{address:_,onChange:e=>d({address:e}),onClose:()=>x(!1),showLatitude:!0})})]})]}),(0,r.jsx)("h2",{children:String(a("franchise.about"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:Z,onChange:e=>d({description:e})})}),(0,r.jsxs)("div",{className:"actions",children:[!!k&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:h,className:"remove-btn",children:String(a("franchise.remove"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:u,size:"large",className:"submit-franchise",children:String(a(k?"franchise.update":"franchise.create"))})]})]})}),(0,r.jsx)(K.ZP,{showAt:n,onClose:()=>s(null),children:(0,r.jsx)(aU,{franchiseId:e.franchiseId,environment:n,onCloseModal:()=>s(null),onChange:j})})]})},a$=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(0,ev.Nr)(null==n?void 0:n.franchiseSearch,300),{data:d=[],isLoading:c,refresh:u}=(0,eh.Z)("/franchise/list-admin?&search=".concat(i)),[m,h]=l.useState([]),x=l.useRef();function g(e){let t=e.target.closest(".list-item-card");x.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function j(e){e.target.style.opacity=1}function f(e){e.prfranchiseDefault();let t=e.target.closest(".list-item-card");x.current!==(null==t?void 0:t.dataset.index)?t.style.left="40px":t.style.left="0px"}function b(e){let t=e.target.closest(".list-item-card");t.style.left="0px"}function y(e){e.preventDefault();let t=e.target.closest(".list-item-card");t.style.left="0px";let a=null==t?void 0:t.dataset.index;if(x.current&&x.current!==a){let e=[...m],[t]=e.splice(x.current,1);e.splice(a,0,t),h(e),N(e.map(e=>e.id))}}async function N(e){try{let t=await J.ZP.put("/franchise/update-order",e);if(t.data.error)throw Error(t.data.error.message);et.Am.success("Franquias reordenadas com sucesso!")}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{Array.isArray(d.franchises)&&h(d.franchises)},[d]),(0,r.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Franquias dispon\xedveis"}),(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(es.Z,{className:"search",placeholder:t("franchise.search"),value:(null==n?void 0:n.franchiseSearch)||"",onChange:e=>s({franchiseSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==n?void 0:null===(e=n.franchiseSearch)||void 0===e?void 0:e.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>s({franchiseSearch:""}),children:(0,r.jsx)(ec.Z,{})})})}}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>(0,K.K4)((0,r.jsx)(aW,{onChange:u})),children:"".concat(t("franchise.create"))})]}),!c||(null==m?void 0:m.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:110,rowCount:(null==m?void 0:m.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=m[a];return(0,r.jsx)("div",{"data-index":a,"data-id":i.id,className:"list-item-card franchise",style:s,draggable:!0,onDragStart:g,onDragEnd:j,onDragOver:f,onDragLeave:b,onDrop:y,onClick:()=>(0,K.K4)((0,r.jsx)(aW,{franchiseId:i.id,onChange:u})),children:(0,r.jsxs)("div",{className:"card-content "+("active"===i.status?"active":"inactive"),children:[(0,r.jsx)("div",{style:{borderRadius:"10px",width:"100%",maxWidth:"200px"},className:"cover",children:(0,r.jsx)(eP.Z,{src:i.coverImage,layout:"fill",objectFit:"cover"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",a+1]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"title",children:[" ",i.name," "]}),(0,r.jsxs)("span",{className:"status",children:[" ","".concat(t(i.status?"franchise.active":"franchise.inactive"))]})]}),(0,r.jsxs)("div",{className:"locale",children:[(0,r.jsx)(ag.Z,{className:"icon-text"}),(0,r.jsx)("p",{children:(0,eD.Cy)(i.address)})]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})};
1var aH=a(84918),aJ=a(10783),aQ=a(33913),aY=a(82644);let aK=(e,t,a)=>{let[n,s]=l.useState(!0),[i,r]=l.useState([]),[o,d]=l.useState({name:""}),[c,u]=l.useState(!1),[m,h]=l.useState({visible:!0,visibleHomeSiteEnvironments:!1,sendWhatsappWebsite:!0,sendWhatsappCardMachine:!0,type:t||"default"}),[v,x]=l.useState({}),{toggleLoader:p}=(0,ee.U2)(),[g,j]=l.useState(!1),[f,b]=l.useState(!1),y=l.useRef(),N=l.useRef(!1);async function k(){try{var t;let a=await ay.get("/event/list-admin?eventId=".concat(e));s(!1);let n=null===(t=a.data)||void 0===t?void 0:t.error;if(n)throw Error(n);h(a.data)}catch(e){s(!1),et.Am.error(e.message)}}async function w(e){try{let t=await ay.put("/event/enviroment-update-order",e);if(t.data.error)throw Error(t.data.error.message);et.Am.success("Eventos reordenados com sucesso!")}catch(e){et.Am.error(e.message)}}function Z(e){h(t=>({...t,...e})),N.current&&b(!0)}function C(){let e={};x(e);let{image:t,title:a,franchiseId:n,address:s,startAt:i,endAt:r}=m;return(t||(e.image_required=!0),a||(e.title_required=!0),n||(e.franchise_required=!0),(null==s?void 0:s.city)||(e.address_required=!0),(null==s?void 0:s.state)||(e.address_required=!0),i&&r&&(0,av.Z)(new Date(r),new Date(i)))?(et.Am.error("Data de in\xedcio do evento maior que a data fim!"),!1):!Object.keys(e).length||(x(e),et.Am.error("Formul\xe1rio incompleto!"),window.scrollTo(0,0),!1)}async function S(){try{var e,t,n,s,i,r,l;if(!C())return;p(!0,"Criando evento");let o=await ay.post("/event/create",(0,eD.GZ)(m),{headers:{"Content-Type":"multipart/form-data"}});if(o.data.error)throw x(o.data.error.message),Error(o.data.error.message);if(!(null==o?void 0:null===(e=o.data)||void 0===e?void 0:e.event)){(0,em.Z)({text:"Erro ao criar evento! E precisamos recarregar a p\xe1gina para continuar. \n\n"+(null==o?void 0:null===(r=o.data)||void 0===r?void 0:null===(l=r.error)||void 0===l?void 0:l.message),onConfirm:()=>{window.location.reload()}});return}h({...(null==o?void 0:null===(t=o.data)||void 0===t?void 0:t.event)||{},lastUpdatedBy:(null==o?void 0:null===(n=o.data)||void 0===n?void 0:null===(s=n.event)||void 0===s?void 0:null===(i=s.lastUpdatedBy)||void 0===i?void 0:i.name)?o.data.event.lastUpdatedBy:m.lastUpdatedBy}),p(),setTimeout(()=>b(!1),1e3),et.Am.success("Evento criado com sucesso!"),x({}),a()}catch(e){console.log(JSON.stringify(e,null,2)),p(),et.Am.error(e.message)}}async function _(){try{var e,t;if(!C())return;p(!0,"Atualizando evento");let n=await ay.put("/event/update",(0,eD.GZ)(m),{headers:{"Content-Type":"multipart/form-data"}});if(p(),n.data.error)throw x(n.data.error.message),Error(n.data.error.message);h({...m,...n.data.event,lastUpdatedBy:(null===(e=n.data.event)||void 0===e?void 0:null===(t=e.lastUpdatedBy)||void 0===t?void 0:t.name)?n.data.event.lastUpdatedBy:m.lastUpdatedBy}),setTimeout(()=>b(!1),1e3),et.Am.success("Evento atualizado com sucesso!"),x({}),a()}catch(e){console.log(JSON.stringify(e,null,2)),p(),et.Am.error(e.message)}}l.useEffect(()=>{e?k():s(!1)},[e]),l.useEffect(()=>{(async function(){await aN({url:"/franchise/list-admin",onProcessing:u,onSuccess:e=>{var t;return r((null==e?void 0:null===(t=e.franchises)||void 0===t?void 0:t.sort((e,t)=>e.name.localeCompare(t.name)))||[])},onError:e=>{et.Am.error(e.message)}})})()},[]),l.useEffect(()=>{if(m.franchiseId){let e=i.find(e=>e.id===m.franchiseId);d(e||{name:""})}},[m.franchiseId,i]),(0,ev.gt)(f,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{m&&h(m)},[m]),(0,ev.ss)(()=>{if(m.startAt&&m.endAt){let e="deleted"===m.status?"deleted":(0,aQ.Z)((0,tP.Z)(new Date(m.endAt)))?"ended":(0,aY.Z)((0,tD.Z)(new Date(m.startAt)))?"comming_soon":"happening";Z({status:e}),N.current=!0}},[m.startAt,m.endAt]);let D=(e,t)=>{let a=e.target.value;a=a.replace(/ /g,"_"),t(/[^a-zA-Z0-9_]/.test(a)?"Caractere inv\xe1lido!":""),Z({tag:a=a.replace(/[^a-zA-Z0-9_]/g,"")})},[E,P]=l.useState(!1),[I,A]=l.useState({current:0,total:0,currentTitle:""});async function T(){(null==m?void 0:m.id)&&!E&&(0,em.Z)({text:"Sincronizar todos os ambientes deste evento (produ\xe7\xe3o → consolidado)? Isso atualiza visibilidade, status, imagens e profissionais no app.",confirmButtonText:"Sim, sincronizar",onConfirm:async()=>{try{var e,t,a,n;P(!0),A({current:0,total:0,currentTitle:"Preparando…"});let s=await ay.get("/environment/sync-event/".concat(m.id,"/plan"));if(null===(e=s.data)||void 0===e?void 0:e.error)throw Error(s.data.error.message||"Falha ao obter plano de sincroniza\xe7\xe3o");let i=(null===(t=s.data)||void 0===t?void 0:t.environments)||[],r=i.length;if(!r){et.Am.info("Nenhum ambiente encontrado para sincronizar neste evento."),P(!1),A({current:0,total:0,currentTitle:""});return}A({current:0,total:r,currentTitle:(null===(a=i[0])||void 0===a?void 0:a.title)||""});let l=0;for(let e=0;e<i.length;e++){let t=i[e];A({current:e,total:r,currentTitle:t.title||t.id});try{let e=await ay.post("/environment/sync/".concat(t.id));(null===(n=e.data)||void 0===n?void 0:n.error)&&(l+=1,console.error("sync failed",t.id,e.data.error))}catch(e){l+=1,console.error("sync failed",t.id,e)}A({current:e+1,total:r,currentTitle:t.title||t.id})}P(!1),l?et.Am.warning("Sincroniza\xe7\xe3o conclu\xedda com ".concat(l," falha(s) de ").concat(r,".")):et.Am.success("".concat(r," ambiente(s) sincronizado(s) para o consolidado.")),await k()}catch(e){P(!1),A({current:0,total:0,currentTitle:""}),et.Am.error(e.message||"Erro ao sincronizar ambientes")}}})}return{loading:n,franchises:i,fetchingFranchises:c,franchise:o,setFranchise:d,event:m,changeEventData:Z,onGoBack:function(){f?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitEvent:m.id?_:S,errors:v,removeEvent:function(){try{(0,em.Z)({text:"Deseja realmente remover este evento?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{p(!0,"Removendo ambiente");let e=await ay.delete("/event/remove/".concat(m.id));if(p(),e.data.error)throw x(e.data.error.message),Error("Erro ao remover evento! \n\n"+e.data.error.message);et.Am.success("Ambiente removido com sucesso!"),(0,K.Mr)()}})}catch(e){p(),et.Am.error(e.message)}},removeImage:function(e){(0,em.Z)({text:"Deseja realmente remover esta imagem?",confirmButtonText:"Sim, desejo remover",onConfirm:()=>{let t=[...m.images];t.splice(e,1),Z({images:t})}})},setShowAddressForm:j,showAddressForm:g,onDragStart:function(e){let t=e.target.closest(".environment-card");y.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2},onDragEnd:function(e){e.target.style.opacity=1},onDragOver:function(e){e.preventDefault();let t=e.target.closest(".environment-card");y.current!==(null==t?void 0:t.dataset.index)?t.style.transform="scale(0.9)":t.style.transform="initial"},onDragLeave:function(e){let t=e.target.closest(".environment-card");t.style.transform="initial"},onDrop:function(e){e.preventDefault();let t=e.target.closest(".environment-card");t.style.transform="initial";let a=null==t?void 0:t.dataset.index;if(y.current&&y.current!==a){let e=[...m.environments],[t]=e.splice(y.current,1);e.splice(a,0,t),h(t=>({...t,environments:e})),w(e.map(e=>e.id))}},type:t,handleChangeTag:D,refreshData:k,syncEnvironmentsToConsolidated:T,syncingConsolidated:E,syncProgress:I}};var aX=a(66242),a0=a(44267),a1=a(15861),a2=a(40476),a3=a(68061),a6=a(36872),a5=a(81458),a8=a(86209),a7=a(4475),a4=a(7083),a9=a(93752);let ne=e=>{let t=(null==e?void 0:e.startAt)||(null==e?void 0:e.endAt);if(!t)return null;let a=new Date(t).getFullYear();return Number.isFinite(a)?a:null},nt=(e,t)=>
1{let{storedState:a,setStoredState:n}=(0,o.oR)(),[s,i]=l.useState(),{currentSelectedEvent:r,currentSelectedYear:d}=a||{},{data:c=[],isLoading:u}=(0,eh.Z)("/ticket/events/list?"),m="super-admin"===Y.userRole||!Y.allowedEventsIds.length,h=m?c:c.filter(e=>{var t;return null===(t=Y.allowedEventsIds)||void 0===t?void 0:t.includes(e._id)}),v=l.useMemo(()=>{let e=new Set;return null==h||h.forEach(t=>{let a=ne(t);null!==a&&e.add(a)}),Array.from(e).sort((e,t)=>t-e)},[h]),x=l.useMemo(()=>d&&v.includes(d)?d:v[0],[d,v]),p=l.useMemo(()=>x?null==h?void 0:h.filter(e=>ne(e)===x):h,[h,x]),g=null==p?void 0:p.find(e=>e._id===t);return l.useEffect(()=>{if(u)return;let e=p.find(e=>e._id===(null==r?void 0:r._id));e?i(e):s&&i(void 0)},[u,p]),{events:e?null==p?void 0:p.filter(e=>!e.relatedEventId):p,loadingEvents:u,selectedEvent:t?g:s,availableYears:v,selectedYear:x,onSelectYear:e=>{n({currentSelectedYear:e,currentSelectedEvent:void 0}),i(void 0)},onSelectEvent:e=>{i(e),n({currentSelectedEvent:e})}}},na=e=>{let{hideRelated:t,onChange:a,defaultValue:n}=e,{t:s,i18n:i}=(0,p.$)("admin"),{events:o,loadingEvents:d,selectedEvent:c,onSelectEvent:u,availableYears:m,selectedYear:h,onSelectYear:v}=nt(!!t,n),x=l.useCallback((e,t,a)=>{if(!e)return null;let{_id:n,slug:s,title:o,image:d,status:c,startAt:u,endAt:m,address:h}=e;return(0,l.createElement)("li",{...t,key:n,className:"event-list-opt "+a,children:[(0,r.jsx)("span",{className:"opt-image",children:(0,r.jsx)(eP.Z,{src:d,width:120,height:80})}),!!o&&(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("a",{className:"title",href:"".concat("https://appcasacor.com.br","/events/").concat(s),target:"_blank",rel:"noreferrer",children:o}),(0,r.jsxs)("span",{className:"status",children:["(",(0,eD.ii)(c),")"]})]}),!!u&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(a4.Z,{className:"icon-text"}),"De ",(0,ej.p6)(u,"P",i.language)," \xe0 ",(0,ej.p6)(m,"P",i.language)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(a9.Z,{className:"icon-text"}),(0,r.jsx)("span",{children:(0,eD.Cy)(h)})]})]})]})},[]);return(0,r.jsxs)("div",{className:"event-select",children:[(0,r.jsx)("h3",{children:"Ano:"}),(0,r.jsxs)(tn.Z,{className:"year-select",value:null!=h?h:"",onChange:e=>{let t=e.target.value;v(""===t?null:Number(t))},displayEmpty:!0,disabled:!m.length,children:[!m.length&&(0,r.jsx)(ts.Z,{value:"",disabled:!0,children:"-"}),m.map(e=>(0,r.jsx)(ts.Z,{value:e,children:e},e))]}),(0,r.jsx)("h3",{children:"Franquia:"}),(0,r.jsx)(e_.Z,{id:"autocomplete-event-select",options:o,disablePortal:!0,getOptionLabel:e=>(null==e?void 0:e.title)||"",isOptionEqualToValue:(e,t)=>e.title===t.title,filterSelectedOptions:!0,loading:d,loadingText:"Carregando...",value:c||".",onChange:(e,t)=>
1{a?a(t):u(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",placeholder:c?"":"Selecione um evento para carregar os dados",inputProps:{...e.inputProps,autoComplete:"new-password"}}),renderTags:(e,t)=>x(e,t,"selected-option"),renderOption:(e,t)=>x(t,e)})]})};var nn=l.memo(na),ns=a(50267),ni=a(42166);let nr={event_created:{label:"Criou evento",tone:"ok",text:"criou o evento"},event_updated:{label:"Alterou evento",tone:"blue",text:"alterou o evento"},event_deleted:{label:"Excluiu evento",tone:"danger",text:"excluiu o evento"},image_created:{label:"Cadastrou imagem",tone:"ok",text:"cadastrou uma imagem"},image_updated:{label:"Alterou imagem",tone:"blue",text:"alterou uma imagem"},image_deleted:{label:"Excluiu imagem",tone:"danger",text:"excluiu uma imagem"},tag_created:{label:"Criou tag",tone:"ok",text:"criou a tag"},tag_updated:{label:"Alterou tag",tone:"blue",text:"alterou a tag"},tag_deleted:{label:"Excluiu tag",tone:"danger",text:"excluiu a tag"}},nl=[{id:"",label:"Todos"},{id:"event",label:"Evento"},{id:"image",label:"Imagens"},{id:"tag",label:"Tags"}],no=new Set(["event_created","event_updated","event_deleted"]),nd=new Set(["image_created","image_updated","image_deleted"]),nc=new Set(["tag_created","tag_updated","tag_deleted"]);function nu(e){if(null==e||""===e)return"(vazio)";
1if("boolean"==typeof e)return e?"sim":"n\xe3o";if("number"==typeof e)return String(e);if("string"==typeof e){if(/^\d{4}-\d{2}-\d{2}T/.test(e)){let t=new Date(e);if(!Number.isNaN(t.getTime()))return(0,ej.p6)(t.toISOString(),"Pp")}return e}try{return JSON.stringify(e)}catch(t){return String(e)}}function nm(e){if(!e||"object"!=typeof e||Array.isArray(e))return"";let t={image:"arquivo",imageAlt:"texto alternativo",order:"ordem",position:"posi\xe7\xe3o",productId:"produto"};return Object.keys(e).map(e=>t[e]||e).join(", ")}let nh=e=>{let{eventId:t}=e,[a,n]=l.useState(""),s=(0,ev.Nr)(a,300),[i,o]=l.useState(""),[d,c]=l.useState(0),[u,m]=l.useState([]),[h,v]=l.useState(0),[x,p]=l.useState(!1);return(l.useEffect(()=>{c(0)},[s,i,t]),l.useEffect(()=>{if(!t)return;let e=!1;return async function(){try{var a,n,r,l;p(!0);let o=new URLSearchParams;o.set("eventId",t),s&&o.set("search",s),o.set("page","0"),o.set("limit","50");let[c,u]=await Promise.all([ay.get("/event-log/list?".concat(o.toString())),ay.get("/environment-image-log/list?".concat(o.toString()))]);if(e)return;let h=(null===(a=c.data)||void 0===a?void 0:a.error)?[]:(null===(n=c.data)||void 0===n?void 0:n.logs)||[],x=(null===(r=u.data)||void 0===r?void 0:r.error)?[]:(null===(l=u.data)||void 0===l?void 0:l.logs)||[],g=[...h,...x].filter(e=>!i||("event"===i?no.has(e.action):"image"===i?nd.has(e.action):"tag"===i?nc.has(e.action):e.action===i)).sort((e,t)=>new Date(t.createdAt||0).getTime()-new Date(e.createdAt||0).getTime());v(g.length),m(g.slice(20*d,20*d+20))}catch(t){e||(m([]),v(0))}finally{e||p(!1)}}(),()=>{e=!0}},[t,s,i,d]),t)?(0,r.jsxs)("div",{className:"environment-image-logs",children:[(0,r.jsx)("div",{className:"environment-image-logs-head",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Logs"}),(0,r.jsx)("p",{children:"Quem criou, alterou ou excluiu o evento, inclusive flags, textos, imagens e tags dos ambientes."})]})}),(0,r.jsx)(eu,{value:a,onChange:e=>{var t;return n((null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value)||"")},className:"search",placeholder:"Buscar por pessoa, campo, ambiente ou tag"}),(0,r.jsx)("div",{className:"environment-image-logs-filters",children:nl.map(e=>(0,r.jsx)("button",{type:"button",className:i===e.id?"active":"",onClick:()=>o(e.id),children:e.label},e.id||"all"))}),x&&!u.length?(0,r.jsx)(ee.aN,{inline:!0}):u.length?(0,r.jsx)("ul",{className:"environment-image-logs-list",children:u.map(e=>{let t=function(e){var t,a,n,s;let i=nr[e.action]||{label:e.action,tone:"blue",text:e.action},r=(null===(t=e.performedBy)||void 0===t?void 0:t.name)||(null===(a=e.performedBy)||void 0===a?void 0:a.email)||"Sistema",l=e.productTitle||e.tagName,o=l&&String(e.action).startsWith("tag_")?"".concat(r," ").concat(i.text," ").concat(l):"".concat(r," ").concat(i.text),d=no.has(e.action)&&Array.isArray(s=e.changes)&&s.length?s.slice(0,12).map(e=>{let t=e.label||e.field||"campo",a=void 0!==e.from,n=void 0!==e.to;return a&&n?"".concat(t,": ").concat(nu(e.from)," → ").concat(nu(e.to)):n?"".concat(t,": ").concat(nu(e.to)):a?"".concat(t,": ").concat(nu(e.from)):t}).join(" \xb7 "):"",c=[e.eventTitle&&no.has(e.action)?e.eventTitle:"",e.environmentTitle,"cover"===e.imageType?"capa do ambiente":"catalogation"===e.imageType?"cataloga\xe7\xe3o":"",d,nm(e.changes)?"alterou ".concat(nm(e.changes)):"",null===(n=e.performedBy)||void 0===n?void 0:n.email].filter(Boolean);return{...i,sentence:o,details:c.join(" \xb7 ")}}(e),a=no.has(e.action);return(0,r.jsxs)("li",{className:a?"environment-image-logs-item event-logs-item":"environment-image-logs-item",children:[a?null:e.imageUrl?(0,r.jsx)("img",{src:(0,eD.e6)(e.imageUrl),alt:"",className:"environment-image-logs-thumb"}):(0,r.jsx)("span",{className:"environment-image-logs-thumb placeholder"}),(0,r.jsx)("span",{className:"badge tone-".concat(t.tone),children:t.label}),(0,r.jsxs)("div",{className:"environment-image-logs-body",children:[(0,r.jsx)("strong",{children:t.sentence}),t.details?(0,r.jsx)("span",{children:t.details}):null]}),(0,r.jsx)("time",{children:e.createdAt?(0,ej.p6)(e.createdAt,"Pp"):"-"})]},"".concat(e.action,"-").concat(e.id))})}):(0,r.jsx)("div",{className:"environment-image-logs-empty",children:"Nenhum log encontrado para este evento"}),(0,r.jsx)(eZ,{numberOfItems:h,rowsPerPage:20,page:d,onPageChange:c,onRowsPerPageChange:()=>void 0})]}):(0,r.jsx)("div",{className:"environment-image-logs",children:(0,r.jsx)("div",{className:"environment-image-logs-empty",children:"Salve o evento para visualizar o hist\xf3rico de altera\xe7\xf5es."})})},nv=e=>{var t,a,n,s,i,o,c,u;let{t:m}=(0,p.$)("admin"),{translate:h,loading:x,translatingField:g,translations:j}=aO({targets:["en","es"]}),{user:f}=(0,d.aC)(),[b,y]=l.useState(),[N,k]=(0,l.useState)(""),[w,Z]=(0,l.useState)(!1),{loading:C,franchises:S,fetchingFranchises:_,franchise:D,setFranchise:E,event:P,changeEventData:I,onGoBack:A,submitEvent:T,errors:R,removeEvent:L,removeImage:q,setShowAddressForm:M,showAddressForm:O,onDragStart:F,onDragEnd:B,onDragOver:U,onDragLeave:z,onDrop:V,type:G,handleChangeTag:W,refreshData:$,syncEnvironmentsToConsolidated:H,syncingConsolidated:J,syncProgress:Q}=aK(e.eventId,e.type,e.onChange),{id:Y,slug:et,image:en,imageCover:el,imageObjectPosition:eo="center",rightLogo:ed,imageMap:ec,status:eu,title:em,presentationTitle:eh,hours:ev,hoursEn:ex,hoursEs:ep,description:eg,descriptionEn:ej,descriptionEs:ef,metaDescription:eb="",metaDescriptionEn:ey="",metaDescriptionEs:eN="",history:ek="",historyEn:ew="",historyEs:eZ="",additionalInformation:eC="",additionalInformationEn:eS="",additionalInformationEs:eI="",questionsAndAnswers:eA=[],questionsAndAnswersEn:eT=[],questionsAndAnswersEs:eR=[],visible:eL,visibleMobileApp:eq,visibleWeb:eM,visibleCardMachine:eO,visibleHomeSite:eF,visibleHomeSiteEnvironments:eB,visibleHomeSiteMostras:eU,visibleTicketSold:ez,operational:eV,isLecture:eG,isExhibition:eW,aboutSectionType:e$,address:eH,updatedAt:eJ,lastUpdatedBy:eQ,ticketsPurchaseUrl:eY,ticketsDiscount:eK,ticketsCoupomCode:eX,signLanguageLink:e0,digitalYearbookLink:e1,digitalYearbookSlug:e2,tag:e3,zaptMapId:e6,relatedEventId:e5,environments:e8,images:e7,visibleHomeSiteImages:e4,sellGivexGiftCard:e9,sellGivexGiftCardGroupPurchase:te,isGenerateLinkQrCodeTicketPurchases:ta,isEnableSponsorValidation:tn=!0,isShowPriceTicketList:ts=!0,sendWhatsappWebsite:ti=!0,sendWhatsappCardMachine:tl=!0,givexPageHeaderBanner:to,givexPageCardBanner:td,givexPageTextInfo:tc,givexPageTextInfoB2C:tu,chart:tm,customEmailText:th}=P,tv=()=>{if(e8&&e8.length>0){let e=e8.filter(e=>e.id);e.length>0?(localStorage.setItem("qr-codes-environments",JSON.stringify(e)),encodeURIComponent(JSON.stringify(e)),window.open("/admin/event/qr-codes-print","_blank")):console.warn("Nenhum ambiente com ID v\xe1lido encontrado")}},{metaDataCoverImage:tx={imageAlt:"",imageTitle:""},metaDataCoverImageEn:tp={imageAlt:"",imageTitle:""},metaDataCoverImageEs:tg={imageAlt:"",imageTitle:""}}=P;return((null==tp?void 0:tp.imageAlt)&&(tp={imageAlt:"",imageTitle:""}),(null==tg?void 0:tg.imageAlt)&&(tg={imageAlt:"",imageTitle:""}),(0,l.useEffect)(()=>
1{if(!x&&g&&(console.log("\uD83D\uDE80 ~ useEffect ~ translatingField:",g,"translateLoading:",x,"translations:",j),0!==Object.keys(j).length)){if((null==j?void 0:j.metaDataCoverImageTitle)&&"metaDataCoverImageTitle"===g||(null==j?void 0:j.metaDataCoverImageAlt)&&"metaDataCoverImageAlt"===g){var e,t,a,n;I({metaDataCoverImageEn:{...tp,imageAlt:null==j?void 0:null===(e=j.metaDataCoverImageAlt)||void 0===e?void 0:e.en,imageTitle:null==j?void 0:null===(t=j.metaDataCoverImageTitle)||void 0===t?void 0:t.en},metaDataCoverImageEs:{...tg,imageAlt:null==j?void 0:null===(a=j.metaDataCoverImageAlt)||void 0===a?void 0:a.es,imageTitle:null==j?void 0:null===(n=j.metaDataCoverImageTitle)||void 0===n?void 0:n.es}});return}if((null==j?void 0:j.hours)&&"hours"===g)return I({hoursEn:j.hours.en,hoursEs:j.hours.es});if((null==j?void 0:j.description)&&"description"===g)return I({descriptionEn:j.description.en,descriptionEs:j.description.es});if((null==j?void 0:j.metaDescription)&&"metaDescription"===g)return I({metaDescriptionEn:j.metaDescription.en,metaDescriptionEs:j.metaDescription.es});if((null==j?void 0:j.history)&&"history"===g)return I({historyEn:j.history.en,historyEs:j.history.es});if((null==j?void 0:j.additionalInformation)&&"additionalInformation"===g)return I({additionalInformationEn:j.additionalInformation.en,additionalInformationEs:j.additionalInformation.es});if(g.startsWith("qaQuestion")||g.startsWith("qaAnswer")){let e=Number(g.split("-")[1]);return I({questionsAndAnswersEn:eT.map((t,a)=>{var n;return a===e?{question:j["qaQuestion-".concat(a)].en||"",answer:(null===(n=j["qaAnswer-".concat(a)])||void 0===n?void 0:n.en)||""}:t}),questionsAndAnswersEs:eR.map((t,a)=>{var n;return a===e?{question:j["qaQuestion-".concat(a)].es||"",answer:(null===(n=j["qaAnswer-".concat(a)])||void 0===n?void 0:n.es)||""}:t})})}}},[j,g,x]),C)?(0,r.jsx)("div",{className:"event-form",children:(0,r.jsx)(ee.aN,{message:"Carregando evento"})}):(0,r.jsxs)("div",{className:"event-form",children:[(0,r.jsx)(ei.Z,{title:m(Y?"event.edit":"event.create"),onGoBack:A,data:{id:Y,lastUpdatedBy:eQ,updatedAt:eJ,linkForId:Y&&"".concat("https://appcasacor.com.br","/events/").concat(et)}}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"Dados do Evento",content:(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"container-event",children:[(0,r.jsx)(aX.Z,{sx:{mb:3},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",component:"h3",sx:{mb:2,fontWeight:"bold"},children:"Configura\xe7\xf5es Editorial"}),(0,r.jsx)(ea.Z,{label:m("event.visible_app"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eL,onChange:e=>I({visible:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_home_site_environments"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eB,onChange:e=>I({visibleHomeSiteEnvironments:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_mobile_app"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eq,onChange:e=>I({visibleMobileApp:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_home_site"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eF,onChange:e=>I({visibleHomeSite:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_home_site_mostras"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eU,onChange:e=>I({visibleHomeSiteMostras:e.target.checked})})})]})}),(0,r.jsx)(aX.Z,{sx:{mb:3},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",component:"h3",sx:{mb:2,fontWeight:"bold"},children:"Configura\xe7\xf5es Bilheteria"}),(0,r.jsx)(ea.Z,{label:m("event.visible_web"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eM,onChange:e=>I({visibleWeb:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_card_machine"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eO,onChange:e=>I({visibleCardMachine:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.send_whatsapp_website"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!1!==ti,onChange:e=>I({sendWhatsappWebsite:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.send_whatsapp_card_machine"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!1!==tl,onChange:e=>I({sendWhatsappCardMachine:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.operational"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!eV,onChange:e=>I({operational:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.sell_givex_giftcard"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!e9,onChange:e=>I({sellGivexGiftCard:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.sell_givex_giftcard_group_purchase"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!te,onChange:e=>I({sellGivexGiftCardGroupPurchase:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.visible_ticket_sold"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!ez,onChange:e=>I({visibleTicketSold:e.target.checked})})}),(0,r.jsx)("div",{className:"about-section-type-field",children:(0,r.jsx)(am.Z,{label:"Tipo",className:"about-section-type-select",value:(0,ni.lM)({aboutSectionType:e$,isLecture:eG,isExhibition:eW}),options:ni.mH.map(e=>({value:e.value,label:m("event.about_section_".concat(e.value))})),onChange:e=>{let t=e||"mostra";I({aboutSectionType:t,isLecture:"palestra"===t,isExhibition:!1})}})}),(0,r.jsx)(ea.Z,{label:ta?m("event.is_generate_link_qr_code_ticket_purchases"):m("event.not_generate_link_qr_code_ticket_purchases"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!ta,onChange:e=>I({isGenerateLinkQrCodeTicketPurchases:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.is_enable_sponsor_validation"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!tn,onChange:e=>I({isEnableSponsorValidation:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:m("event.is_show_price_ticket_list"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!ts,onChange:e=>I({isShowPriceTicketList:e.target.checked})})})]})}),(0,r.jsxs)("div",{className:"form",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"logo",children:"Imagem do evento - Venda de Ingresso"}),(0,r.jsx)("div",{children:"Tamanho recomendado: 620x440px"}),(0,r.jsxs)(tt.Z,{children:[(0,r.jsx)(a2.Z,{id:"radio-buttons-group-label-image-object-position",children:"Alinhamento"}),(0,r.jsxs)(a3.Z,{row:!0,"aria-labelledby":"radio-buttons-group-label-image-object-position",defaultValue:"center",n
1ame:"radio-buttons-group",value:eo,onChange:e=>I({imageObjectPosition:e.target.value}),children:[(0,r.jsx)(ea.Z,{value:"0% 50%",control:(0,r.jsx)(a6.Z,{}),label:"\xe0 esquerda",disabled:"0% 50%"!==eo&&"center"!==eo&&"100% 50%"!==eo}),(0,r.jsx)(ea.Z,{value:"center",control:(0,r.jsx)(a6.Z,{}),label:"ao centro",disabled:"0% 50%"!==eo&&"center"!==eo&&"100% 50%"!==eo}),(0,r.jsx)(ea.Z,{value:"100% 50%",control:(0,r.jsx)(a6.Z,{}),label:"\xe0 direita",disabled:"0% 50%"!==eo&&"center"!==eo&&"100% 50%"!==eo})]})]}),"0% 50%"!==eo&&"center"!==eo&&"100% 50%"!==eo&&(0,r.jsxs)("div",{className:"error",children:["Valor fixado pelo sistema: ",eo]}),(0,r.jsx)(eE.Z,{refId:"evtimg",onChange:e=>I({image:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image"+((null==R?void 0:R.image_required)?" error":""),children:(0,r.jsx)(au(),{src:(0,eD.e6)(en),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"logo",children:"Imagem do evento na p\xe1gina de mostras no Site Casacor"}),(0,r.jsx)("div",{style:{fontSize:"0.8rem",color:"gray"},children:"Quando n\xe3o houver, ser\xe1 usada a imagem acima"}),(0,r.jsx)(eE.Z,{refId:"evtimg-cover",onChange:e=>I({imageCover:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(el),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"fields",style:{paddingLeft:0},children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)("div",{className:"meta-data-cover-image-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_alt")," - pt-BR"),value:tx.imageAlt||"",onChange:e=>I({metaDataCoverImage:{...tx,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tx?void 0:null===(t=tx.imageAlt)||void 0===t?void 0:t.length)||0,"/").concat(m("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_title")," - pt-BR"),value:tx.imageTitle||"",onChange:e=>I({metaDataCoverImage:{...tx,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tx?void 0:null===(a=tx.imageTitle)||void 0===a?void 0:a.length)||0,"/").concat(m("event.meta_data_cover_image_title_limit")),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{I({metaDataCoverImageEn:{imageAlt:"",imageTitle:""},metaDataCoverImageEs:{imageAlt:"",imageTitle:""}}),h({field:"metaDataCoverImageAlt",text:tx.imageAlt}),h({field:"metaDataCoverImageTitle",text:tx.imageTitle})},disabled:x,children:x&&("metaDataCoverImageAlt"===g||"metaDataCoverImageTitle"===g)?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_alt")," - en-US"),value:tp.imageAlt||"",onChange:e=>I({metaDataCoverImageEn:{...tp,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tp?void 0:null===(n=tp.imageAlt)||void 0===n?void 0:n.length)||0,"/").concat(m("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_title")," - en-US"),value:tp.imageTitle||"",onChange:e=>I({metaDataCoverImageEn:{...tp,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tp?void 0:null===(s=tp.imageTitle)||void 0===s?void 0:s.length)||0,"/").concat(m("event.meta_data_cover_image_title_limit")),disabled:x})]})},{id:2,label:"es-ES",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_alt")," - es-ES"),value:tg.imageAlt||"",onChange:e=>I({metaDataCoverImageEs:{...tg,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tg?void 0:null===(i=tg.imageAlt)||void 0===i?void 0:i.length)||0,"/").concat(m("event.meta_data_cover_image_alt_limit")),disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_data_cover_image_title")," - es-ES"),value:tg.imageTitle||"",onChange:e=>I({metaDataCoverImageEs:{...tg,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==tg?void 0:null===(o=tg.imageTitle)||void 0===o?void 0:o.length)||0,"/").concat(m("event.meta_data_cover_image_title_limit")),disabled:x})]})}]})}),(0,r.jsx)("div",{className:"logo",children:"Logo direito app"}),(0,r.jsx)(eE.Z,{refId:"right-logo",onChange:e=>I({rightLogo:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image image-mini",children:(0,r.jsx)(au(),{src:(0,eD.e6)(ed),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"logo",children:"Mapa do Evento"}),(0,r.jsx)(eE.Z,{refId:"image-map",onChange:e=>I({imageMap:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image image-mini",children:(0,r.jsx)(au(),{src:(0,eD.e6)(ec),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(te||e9)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"logo",children:"Banner da p\xe1gina de compra do Gift Card Givex"}),(0,r.jsx)(eE.Z,{refId:"givex-page-header-banner",onChange:e=>I({givexPageHeaderBanner:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image image-mini",children:(0,r.jsx)(au(),{src:(0,eD.e6)(to),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"logo",children:"Banner do card do Gift Card Givex"}),(0,r.jsx)(eE.Z,{refId:"givex-page-card-banner",onChange:e=>I({givexPageCardBanner:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image image-mini",children:(0,r.jsx)(au(),{src:(0,eD.e6)(td),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})})]})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"franchise-select",options:S,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,disablePortal:!0,loading:_,loadingText:"Carregando...",value:D,onChange:(e,t)=>
1{E(t||{}),I({franchiseId:null==t?void 0:t.id})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+m("franchise.select"),error:!!(null==R?void 0:R.franchise_required),helperText:!!(null==R?void 0:R.franchise_required)&&m("required_field"),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImage,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.name})]})})}),"related"===G&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{children:"Evento relacionado"}),(0,r.jsx)(nn,{defaultValue:e5||"null",onChange:e=>{I({relatedEventId:e._id,address:e.address,startAt:e.startAt,endAt:e.endAt})}})]}),(0,r.jsx)(es.Z,{className:"textfield",label:"* "+m("event.name_event"),value:em||"",onChange:e=>I({title:e.target.value}),error:null==R?void 0:R.title_required}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.presentation_name")),value:eh||"",onChange:e=>I({presentationTitle:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.slug")),value:et||""}),(0,r.jsx)("div",{className:"row address",children:(0,r.jsx)(es.Z,{className:"textfield",label:"* "+m("event.event_address"),value:(0,eD.Cy)(eH)||"",onClick:()=>M(!0),error:null==R?void 0:R.address_required})}),(0,r.jsx)(K.ZP,{showAt:O,onClose:()=>M(!1),children:(0,r.jsx)(aZ,{address:eH,stateLabel:"Nome da Franquia",onChange:e=>I({address:e}),onClose:()=>M(!1),showLatitude:!0})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(a7.Z,{label:String(m("event.start_event")),className:"input",minutesStep:10,value:P.startAt||null,onChange:e=>I({startAt:e}),renderInput:e=>(0,r.jsx)(es.Z,{...e})}),(0,r.jsx)(a7.Z,{label:String(m("event.end_event")),className:"input",minutesStep:10,value:P.endAt||null,onChange:e=>I({endAt:e}),renderInput:e=>(0,r.jsx)(es.Z,{...e})}),(0,r.jsx)(es.Z,{className:"status",label:"Status",disabled:!0,value:"comming_soon"===eu?"Em breve":"ended"===eu?"Encerrado":"happening"===eu?"No Ar":""})]}),(0,r.jsx)(es.Z,{className:"sign-language",label:String(m("event.signLanguageLink")),value:e0||"",onChange:e=>I({signLanguageLink:e.target.value})}),(0,r.jsx)(es.Z,{className:"sign-language",label:String(m("event.digitalYearbookLink")),value:e1||"",onChange:e=>I({digitalYearbookLink:e.target.value})}),(0,r.jsx)(es.Z,{className:"sign-language",label:String(m("event.digitalYearbookSlug")),value:e2||"",onChange:e=>I({digitalYearbookSlug:e.target.value})}),(0,r.jsx)(es.Z,{className:"sign-language",label:String(m("event.tag")),value:e3||"",onChange:e=>W(e,k),error:Boolean(N),helperText:N}),(0,r.jsx)(es.Z,{className:"sign-language",label:String(m("event.zapMapId")),value:e6||"",onChange:e=>I({zaptMapId:e.target.value}),error:Boolean(N),helperText:N}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.event_times")," - pt-BR"),value:ev||"",multiline:!0,rows:5,onChange:e=>I({hours:e.target.value}),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>h({field:"hours",text:ev}),disabled:x,children:x&&"hours"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.event_times")," - en-US"),value:ex||"",multiline:!0,rows:5,onChange:e=>I({hoursEn:e.target.value}),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.event_times")," - es-ES"),value:ep||"",multiline:!0,rows:5,onChange:e=>I({hoursEs:e.target.value}),disabled:x})}]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_description")," - pt-BR"),value:eb||"",multiline:!0,rows:3,onChange:e=>I({metaDescription:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(eb.length,"/").concat(m("event.meta_description_limit")),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>h({field:"metaDescription",text:eb}),disabled:x,children:x&&"metaDescription"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_description")," - en-US"),value:ey||"",multiline:!0,rows:3,onChange:e=>I({metaDescriptionEn:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(ey.length,"/").concat(m("event.meta_description_limit")),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.meta_description")," - es-ES"),value:eN||"",multiline:!0,rows:3,onChange:e=>I({metaDescriptionEs:"".concat(e.target.value).substring(0,200)}),helperText:"".concat(eN.length,"/").concat(m("event.meta_description_limit")),disabled:x})}]}),te&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Texto da p\xe1gina de compra do Gift Card Givex - B2B"}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:tc,onChange:e=>I({givexPageTextInfo:e})})})]}),e9&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Texto da p\xe1gina de compra do Gift Card Givex - B2C"}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:tu,onChange:e=>I({givexPageTextInfoB2C:e})})})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{type:"color",className:"textfield",label:String(m("event.chart_color1")),value:(null==tm?void 0:tm.color1)||"#".concat(Math.floor(16777215*Math.random()).toString(16)),onChange:e=>I({chart:{...tm,color1:e.target.value}})}),(0,r.jsx)(es.Z,{type:"color",className:"textfield",label:String(m("event.chart_color2")),value:(null==tm?void 0:tm.color2)||"#".concat(Math.floor(16777215*Math.random()).toString(16)),onChange:e=>I({chart:{...tm,color2:e.target.value}})})]})]})]})]}),(0,r.jsx)("h2",{children:String(m("event.contacts"))}),(0,r.jsxs)("div",{className:"contacts-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:String(m("event.email")),value:(null==P?void 0:null===(c=P.contacts)||void 0===c?void 0:c.email)||"",onChange:e=>{let t=(null==P?void 0:P.contacts)||{};t.email=e.target.value,I({contacts:t})}}),(0,r.jsx)(es.Z,{className:"textfield",label:String(m("event.Contact_phone")),value:(null==P?void 0:null===(u=P.contacts)||void 0===u?void 0:u.celphone)||"",onChange:e=>{let t=(null==P?void 0:P.contacts)||{};t.celphone=e.target.value,I({contacts:t})}})]}),(0,r.jsx)("h2",{children:String(m("event.add_ticket"))}),(0,r.jsxs)("div",{className:"row tickets-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:String(m("event.ticket_url")),value:eY||"",onChange:e=>I({ticketsPurchaseUrl:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:"% "+m("event.ticket_discount"),value:eK||"",type:"number",onChange:e=>I({ticketsDiscount:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:String(m("event.ticket_code")),value:eX||"",onChange:e=>I({ticketsCoupomCode:e.target.value})})]})]})},{id:0,label:"Sobre o Evento",content:(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-event",children:[(0,r.jsx)("h2",{children:String(m("event.about"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:eg||"",onChange:e=>I({description:e}),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{I({descriptionEn:"",descriptionEs:""}),h({field:"description",text:eg})},disabled:x,children:x&&"description"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:ej||"",onChange:e=>I({descriptionEn:e}),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:ef||"",onChange:e=>I({descriptionEs:e}),disabled:x})}]})}),(0,r.jsx)("h2",{children:String(m("event.history"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:ek||"",onChange:e=>I({history:e}),disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{I({historyEn:"",historyEs:""}),h({field:"history",text:ek})},disabled:x,children:x&&"history"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:ew||"",onChange:e=>I({historyEn:e}),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:eZ||"",onChange:e=>I({historyEs:e}),disabled:x})}]})}),(0,r.jsx)("h2",{children:String(m("event.additional_information"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:eC||"",onChange:e=>I({additionalInformation:e})}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{I({additionalInformationEn:"",additionalInformationEs:""}),h({field:"additionalInformation",text:eC})},disabled:x,children:x&&"additionalInformation"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:eS||"",onChange:e=>I({additionalInformationEn:e}),disabled:x})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:eI||"",onChange:e=>I({additionalInformationEs:e}),disabled:x})}]})}),(0,r.jsx)("h2",{children:String(m("event.custom_email_text"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:th||"",onChange:e=>I({customEmailText:e})})})]})})},{id:0,label:"Perguntas e Respostas",content:(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-event",children:[(0,r.jsx)("h2",{children:String(m("event.questions_and_answers"))}),(0,r.jsx)("div",{className:"qa-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[null==eA?void 0:eA.map((e,t)=>(0,r.jsxs)("div",{className:"qa",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.question")," - pt-BR"),value:e.question||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswers)||[];a[t].question=e.target.value,I({questionsAndAnswers:a})},disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.answer")," - pt-BR"),value:e.answer||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswers)||[];a[t].answer=e.target.value,I({questionsAndAnswers:a})},disabled:x}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{h({field:"qaQuestion-".concat(t),text:e.question}
1),h({field:"qaAnswer-".concat(t),text:e.answer})},disabled:x,children:x&&"questionsAndAnswers"===g?"".concat(m("translating")):"".concat(m("translate_to_other_languages"))}),(0,r.jsx)("div",{className:"separator"})]},t)),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>I({questionsAndAnswers:[...(null==P?void 0:P.questionsAndAnswers)||[],{question:"",answer:""}],questionsAndAnswersEn:[...(null==P?void 0:P.questionsAndAnswersEn)||[],{question:"",answer:""}],questionsAndAnswersEs:[...(null==P?void 0:P.questionsAndAnswersEs)||[],{question:"",answer:""}]}),disabled:x,children:String(m("event.add_question"))})]})},{id:1,label:"en-US",content:null==eT?void 0:eT.map((e,t)=>(0,r.jsxs)("div",{className:"qa",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.question")," - en-US"),value:e.question||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswersEn)||[];a[t].question=e.target.value,I({questionsAndAnswersEn:a})},disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.answer")," - en-US"),value:e.answer||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswersEn)||[];a[t].answer=e.target.value,I({questionsAndAnswersEn:a})},disabled:x}),(0,r.jsx)("div",{className:"separator"})]},t))},{id:2,label:"es-ES",content:null==eR?void 0:eR.map((e,t)=>(0,r.jsxs)("div",{className:"qa",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.question")," - es-ES"),value:e.question||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswersEs)||[];a[t].question=e.target.value,I({questionsAndAnswersEs:a})},disabled:x}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(m("event.answer")," - es-ES"),value:e.answer||"",onChange:e=>{let a=(null==P?void 0:P.questionsAndAnswersEs)||[];a[t].answer=e.target.value,I({questionsAndAnswersEs:a})},disabled:x}),(0,r.jsx)("div",{className:"separator"})]},t))}]})})]})})},{id:0,label:"Imagens do Evento",content:(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(ea.Z,{label:"event"===e4?String(m("event.visible_home_site_event_images")):String(m("event.visible_home_site_environment_images")),className:"switch",control:(0,r.jsx)(tr.Z,{checked:"event"===e4,onChange:e=>I({visibleHomeSiteImages:e.target.checked?"event":"environment"})})})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h2",{children:String(m("event.images"))})}),(0,r.jsxs)("div",{className:"images-container",children:[null==e7?void 0:e7.map((e,t)=>(0,r.jsxs)("div",{className:"draggable",children:[(0,r.jsx)("div",{className:"order",children:t+1}),(0,r.jsx)(eE.Z,{aspectRatio:.5,refId:"environment-form.image"+t,onChange:e=>{let a=[...(null==P?void 0:P.images)||[]];a[t].image=e,I({images:a})},renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(au(),{className:"placeholder",src:(0,eD.e6)(e.image),layout:"fill",objectFit:"contain",unoptimized:!!e,alt:"",placeholder:"blur",blurDataURL:eD.LG,draggable:!1}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>q(t),children:(0,r.jsx)(er.Z,{})})})]})})]},t)),(0,r.jsx)(eE.Z,{refId:"environment-form.image.add",aspectRatio:.5,onChange:e=>{let t=[...(null==P?void 0:P.images)||[]];t.push({image:e,tags:[],status:"active"}),I({images:t})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)("img",{className:"placeholder",src:"/placeholder.png",alt:"",height:"100%",draggable:!1})})})]})]})})},{id:0,label:"Imagens dos Ambientes",content:(0,r.jsx)("div",{className:"content",children:"default"===G&&!!Y&&(0,r.jsxs)("div",{className:"container container-environment",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("h2",{children:String(m("environment.event_environments"))}),(0,r.jsxs)("div",{className:"buttons-container",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>y({}),className:"add-environment",children:String(m("environment.create"))}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:H,className:"sync-consolidated",startIcon:(0,r.jsx)(ns.Z,{}),disabled:!Y||J,children:J?"Sincronizando…":"Sincronizar consolidado"}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>Z(!w),className:"qr-code-toggle",startIcon:(0,r.jsx)(aI.Z,{}),children:w?"Ocultar QR Codes":"Mostrar QR Codes"}),w&&(0,r.jsx)(v.Z,{variant:"contained",onClick:tv,className:"print-qr-codes",startIcon:(0,r.jsx)(aI.Z,{}),children:"Abrir para Impress\xe3o"})]}),J&&(0,r.jsxs)("div",{className:"sync-progress",children:[(0,r.jsxs)(a1.Z,{variant:"body2",sx:{mb:1},children:["Sincronizando ",Q.current,"/",Q.total,Q.currentTitle?": ".concat(Q.currentTitle):""]}),(0,r.jsx)(a5.Z,{variant:"determinate",value:Q.total?Q.current/Q.total*100:0})]})]}),!w&&(0,r.jsx)("div",{className:"environments",children:null==e8?void 0:e8.map((e,t)=>{var a;let{title:n,coverImage:s,imagesLength:i=null==e?void 0:null===(a=e.images)||void 0===a?void 0:a.length}=e,l=function(e){var t;let a=(null==e?void 0:null===(t=e.professionals)||void 0===t?void 0:t.length)?e.professionals:(null==e?void 0:e.cadastroProfessionals)||[];return a.map(e=>{var t;let a=null==e?void 0:null===(t=e.members)||void 0===t?void 0:t[0];return{id:(null==e?void 0:e.id)||(null==e?void 0:e.professionalId)||(null==e?void 0:e._id),name:(null==e?void 0:e.name)||(null==a?void 0:a.name),avatar:(null==e?void 0:e.avatar)||(null==a?void 0:a.avatar)}}).filter(e=>e.name||e.avatar)}(e);return(0,r.jsxs)("div",{className:"environment-card placeholder",onClick:()=>y({id:e.id}),draggable:!0,"data-index":t,"data-id":e.id,onDragStart:F,onDragEnd:B,onDragOver:U,onDragLeave:z,onDrop:V,children:[(0,r.jsxs)("div",{className:"order",children:["Ordem: ",t+1]}),(0,r.jsx)("div",{className:"cover-image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(s),placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"left-side",children:(0,r.jsx)(a8.Z,{max:3,children:null==l?void 0:l.map(e=>(0,r.jsx)("div",{className:"avatar",children:(0,r.jsx)(au(),{src:(0,eD.e6)(null==e?void 0:e.avatar),placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:null==e?void 0:e.name})},(null==e?void 0:e.id)||(null==e?void 0:e.name)))})}),(0,r.jsxs)("div",{className:"right-side",children:[(0,r.jsx)("div",{className:"title",children:n}),null==l?void 0:l.map(e=>(0,r.jsx)("div",{className:"prof",children:null==e?void 0:e.name},(null==e?void 0:e.id)||(null==e?void 0:e.name))),(0,r.jsxs)("div",{className:"images",children:["".concat(m("environment.featured_images")),(0,r.jsx)("div",{children:i})]})]})]})]},t)})}),w&&e8&&e8.length>0&&(0,r.jsxs)("div",{className:"qr-codes-section",children:[(0,r.jsx)("h3",{children:"QR Codes dos Ambientes"}),(0,r.jsx)("div",{className:"qr-codes-grid",children:e8.filter(e=>e.id).map((e,t)=>{let a="https://apiv2.appcasacor.com.br/deeplink?environment/".concat(e.id);return(0,r.jsxs)("div",{className:"qr-code-item",children:[(0,r.jsx)("div",{className:"qr-code-container",children:(0,r.jsx)(aL.ZP,{value:a,size:200,style:{height:"auto",maxWidth:"100%",width:"100%"},viewBox:"0 0 200 200",bgColor:"#ffffff",fgColor:"#000000"})}),(0,r.jsxs)("div",{className:"qr-code-title",children:[e.title," (Ordem: ",t+1,")"]})]},"qr-".concat(e.id))})})]})]})})},{id:0,label:"Logs",content:(0,r.jsx)("div",{className:"content",children:(0,r.jsx)(nh,{eventId:Y})})}]}),(0,r.jsxs)("div",{className:"actions",children:[!!Y&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:L,className:"remove-btn",children:String(m("event.remove"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:T,size:"large",className:"submit-event",children:String(m(Y?"event.update":"event.create"))})]}),(0,r.jsx)(K.ZP,{showAt:b,onClose:()=>y(null),children:(0,r.jsx)(aU,{eventId:e.eventId,environment:b,onCloseModal:()=>y(null),onChange:$})})]})},nx=e=>{var t;let{type:a}=e,{t:n,i18n:s}=(0,p.$)("admin"),{storedState:i,setStoredState:d}=(0,o.oR)(),{currentSelectedEvent:c}=i||{},u=(0,ev.Nr)(null==i?void 0:i.eventSearch,300),[m,h]=l.useState(void 0),[x,g]=l.useState(void 0),{data:j,isLoading:f}=ad("/event/editions-by-years"),b=l.useMemo(()=>j?Object.keys(j).sort((e,t)=>
1parseInt(t)-parseInt(e)).map(e=>({label:e,value:e})):[],[j]),y=l.useMemo(()=>[{label:"Por ordem (padr\xe3o)",value:"order"},{label:"T\xedtulo - Crescente",value:"title:asc"},{label:"T\xedtulo - Decrescente",value:"title:desc"},{label:"Data de in\xedcio - Crescente",value:"startAt:asc"},{label:"Data de in\xedcio - Decrescente",value:"startAt:desc"},{label:"Data de fim - Crescente",value:"endAt:asc"},{label:"Data de fim - Decrescente",value:"endAt:desc"},{label:"Status",value:"status"},{label:"Pra\xe7a - Crescente",value:"franchise:asc"},{label:"Pra\xe7a - Decrescente",value:"franchise:desc"}],[]),N=l.useMemo(()=>{let e=new URLSearchParams;return"related"===a&&(null==c?void 0:c._id)&&e.append("parentEventId",c._id),e.append("type",a),u&&e.append("search",u),m&&e.append("year",m),x&&e.append("sort",x),e.toString()},[a,null==c?void 0:c._id,u,m,x]),{data:k=[],isLoading:w,refresh:Z}=ad("/event/list-admin?".concat(N)),[C,S]=l.useState([]),_=l.useRef();function D(e){let t=e.target.closest(".list-item-card");_.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function E(e){e.target.style.opacity=1}function P(e){e.preventDefault();let t=e.target.closest(".list-item-card");_.current!==(null==t?void 0:t.dataset.index)?t.style.left="40px":t.style.left="0px"}function I(e){let t=e.target.closest(".list-item-card");t.style.left="0px"}function A(e){e.preventDefault();let t=e.target.closest(".list-item-card");t.style.left="0px";let a=null==t?void 0:t.dataset.index;if(_.current&&_.current!==a){let e=[...C],[t]=e.splice(_.current,1);e.splice(a,0,t),S(e),T(e.map(e=>e.id))}}async function T(e){try{let t=await ay.put("/event/update-order",e);if(t.data.error)throw Error(t.data.error.message);et.Am.success("Eventos reordenados com sucesso!")}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{Array.isArray(k.events)&&S(k.events)},[k]),(0,r.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsxs)("h3",{style:{padding:"0 10px"},children:["Eventos ","related"===a?"relacionados":""," dispon\xedveis"]}),(0,r.jsxs)("div",{className:"head",style:{display:"flex",flexDirection:"column",gap:"10px",padding:"10px"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(am.Z,{options:b,value:m,label:"Ano",cleanable:!0,onChange:e=>h(e||void 0),isLoading:f})}),(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(am.Z,{options:y,value:x,label:"Ordena\xe7\xe3o",cleanable:!0,onChange:e=>g(e||void 0)})})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[(0,r.jsx)(es.Z,{className:"search",placeholder:n("search.events"),value:(null==i?void 0:i.eventSearch)||"",onChange:e=>d({eventSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==i?void 0:null===(t=i.eventSearch)||void 0===t?void 0:t.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>d({eventSearch:""}),children:(0,r.jsx)(ec.Z,{})})})},style:{flex:1}}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>(0,K.K4)((0,r.jsx)(nv,{type:a,onChange:Z})),children:"".concat(n("event.create"))})]})]}),!w||(null==C?void 0:C.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:t+10,rowHeight:110,rowCount:(null==C?void 0:C.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:n,style:i}=e,l=C[t],o=l.visible;return(0,r.jsx)("div",{"data-index":t,"data-id":l.id,className:"list-item-card event",style:i,draggable:!0,onDragStart:D,onDragEnd:E,onDragOver:P,onDragLeave:I,onDrop:A,onClick:()=>(0,K.K4)((0,r.jsx)(nv,{type:a,eventId:l.id,onChange:Z})),children:(0,r.jsxs)("div",{className:"card-content "+(o?"active":"inactive"),children:[(0,r.jsxs)("div",{className:"cover",children:[(0,r.jsx)(eP.Z,{src:l.image,layout:"fill"}),!o&&(0,r.jsx)(aJ.Z,{className:"hidden-icon"})]}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",t+1]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"title",children:[" ",l.title," "]}),(0,r.jsxs)("span",{className:"status",children:[" (",(0,eD.ii)(l.status),")"]})]}),!!l.startAt&&(0,r.jsxs)("div",{className:"dates",children:[(0,r.jsx)(aH.Z,{className:"icon-text"}),"De ",(0,ej.p6)(l.startAt,"P",s.language)," \xe0 ",(0,ej.p6)(l.endAt,"P",s.language)]}),(0,r.jsxs)("div",{className:"locale",children:[(0,r.jsx)(ag.Z,{className:"icon-text"}),(0,r.jsx)("p",{children:(0,eD.Cy)(l.address)})]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},np=e=>{var t,a;let{onNotificationSaved:n}=e,{toggleLoader:s}=(0,ee.U2)(),{t:i}=(0,p.$)("admin"),[o,d]=l.useState({filters:{locations:["Todos"]}}),[c,u]=l.useState([]),[m,h]=l.useState({}),[x,g]=l.useState(!1),{title:j,message:f,externalLink:b,image:y,category:N,send:k,sendAt:w,filters:Z}=o;function C(e){d(t=>({...t,...e}))}async function S(){try{let e={};if(h(e),f||(e.message="Campo obrigat\xf3rio"),!b||(null==b?void 0:b.startsWith("https://"))||(e.externalLink='Deve iniciar com "https://"'),N||(e.category="Campo obrigat\xf3rio"),k||
1(e.send="Campo obrigat\xf3rio"),"scheduled"!==k||w||(e.sendAt="Campo obrigat\xf3rio"),w&&(0,aQ.Z)(new Date(w))&&(e.sendAt="Data n\xe3o pode ser passado"),Object.keys(e).length)throw h(e),Error("Formul\xe1rio incompleto!");s(!0,"Salvando notifica\xe7\xe3o");let t=await J.ZP.post("/notification/save",(0,eD.GZ)(o),{headers:{"Content-Type":"multipart/form-data"}});if(s(),t.data.error)throw Error("Erro ao adicionar notifica\xe7\xe3o! \n\n"+t.data.error.message);n(),g(!1),et.Am.success("Notifica\xe7\xe3o adicionada com sucesso!")}catch(e){s(),et.Am.error(e.message)}}return l.useEffect(()=>{(async function(){let e=await (0,J.ZP)("/event/locations");Array.isArray(e.data)&&u(["Todos","Testes",...e.data])})()},[]),(0,r.jsxs)("div",{className:"notification-form",children:[(0,r.jsx)(v.Z,{startIcon:(0,r.jsx)(eU.Z,{}),variant:"contained",onClick:()=>g(!0),style:{width:240},children:i("notification.create")}),(0,r.jsx)(K.ZP,{showAt:x,onClose:()=>g(!1),children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Nova notifica\xe7\xe3o",onGoBack:()=>g(!1)}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(eE.Z,{refId:"notification-image",aspectRatio:2,maxWidthOrHeight:300,onChange:e=>{C({image:e})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)(eP.Z,{src:y,layout:"fill"})})})}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(es.Z,{className:"textfield",label:i("notification.title"),value:j||"",onChange:e=>{e.stopPropagation(),C({title:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"*"+i("notification.message"),value:f||"",multiline:!0,rows:7,onChange:e=>{e.stopPropagation(),C({message:e.target.value})},helperText:m.message,error:!!m.message})]})]}),(0,r.jsxs)("div",{className:"row category",children:[(0,r.jsx)(es.Z,{className:"textfield",label:i("notification.link"),value:b||"",onChange:e=>{e.stopPropagation(),C({externalLink:e.target.value})},helperText:m.externalLink||'Deve iniciar com "https://"',error:!!m.externalLink}),(0,r.jsxs)(tt.Z,{fullWidth:!0,error:!!m.category,children:[(0,r.jsx)(ta.Z,{id:"demo-simple-select-label",children:"*"+i("notification.category")}),(0,r.jsxs)(tn.Z,{label:"*"+i("notification.category"),value:N||"",onChange:e=>{e.stopPropagation(),C({category:e.target.value})},children:[(0,r.jsx)(ts.Z,{value:"default",children:"Default"}),(0,r.jsx)(ts.Z,{value:"news",children:"Not\xedcias"}),(0,r.jsx)(ts.Z,{value:"products",children:"Produtos"}),(0,r.jsx)(ts.Z,{value:"professionals",children:"Profissionais"}),(0,r.jsx)(ts.Z,{value:"calendar",children:"Calend\xe1rio"}),(0,r.jsx)(ts.Z,{value:"tickets",children:"Ingresso"})]}),(0,r.jsx)(ti.Z,{error:!!m.category,children:m.category})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)(tt.Z,{fullWidth:!0,error:!!m.send,children:[(0,r.jsx)(ta.Z,{id:"demo-simple-select-label",children:"*"+i("notification.send")}),(0,r.jsxs)(tn.Z,{label:"*"+i("notification.send"),value:k||"",onChange:e=>{e.stopPropagation(),C({send:e.target.value})},children:[(0,r.jsx)(ts.Z,{value:"direct",children:"Imediato"}),(0,r.jsx)(ts.Z,{value:"scheduled",children:"Programado"})]}),(0,r.jsx)(ti.Z,{error:!!m.send,children:m.send})]}
1),"scheduled"===k&&(0,r.jsx)("div",{className:"date",children:(0,r.jsx)(a7.Z,{label:"*"+i("notification.send_at"),value:w||null,onChange:e=>{C({sendAt:e})},renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:m.sendAt,error:!!m.sendAt})})})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(am.Z,{label:"*"+i("notification.locations"),options:c,value:null==Z?void 0:Z.locations,multiple:!0,onChange:e=>{let t="Todos"===e[e.length-1];d(a=>({...a,filters:{...a.filters,locations:t?["Todos"]:e.filter(e=>"Todos"!==e)}}))},error:!!(null===(t=m.filters)||void 0===t?void 0:t.locations),errorMessage:null===(a=m.filters)||void 0===a?void 0:a.locations})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>g(!1),children:i("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:S,children:i("notification.create")})]})]})]})})})]})};var ng=a(16890);let nj=e=>{let{notification:t}=e,{t:a,i18n:n}=(0,p.$)("admin"),{storedState:s,setStoredState:i}=(0,o.oR)(),{notificationUserClickLimit:l=30,notificationUserClickPage:d=0}=s,{id:c,image:u,title:m,category:h,send:v,sendAt:x,createdAt:g,readNotificationsCount:j,audience:f,lastUpdatedBy:b}=t||{},{data:y,isLoading:N}=(0,eh.Z)("/notification/list?id=".concat(c,"&limit=").concat(l,"&page=").concat(d)),{userList:k,numberOfItems:w,sizeUserList:Z,sizeUserRemove:C}=y||{};return(0,r.jsxs)("div",{className:"notification-details",children:[(0,r.jsxs)("div",{className:"notification",children:[(0,r.jsx)("div",{className:"cover",children:(0,r.jsx)(eP.Z,{src:u,layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"title",children:m}),(0,r.jsx)("div",{className:"send",children:"Enviado"}),(0,r.jsxs)("div",{className:"created_at",children:["Data cria\xe7\xe3o: ",(0,ej.p6)(g,"Pp",n.language)]}),(0,r.jsxs)("div",{className:"created_at",children:["Criado por: ",void 0===b?"-":b.name]})]})]}),(0,r.jsxs)("div",{className:"clicks",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"number",children:Z}),(0,r.jsx)("div",{className:"label",children:"Cliques/Enviados"})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"number",children:[0===Z&&0===C?0:Math.floor((Z-C)/Z*100),"%"]}),(0,r.jsx)("div",{className:"label",children:"Desempenho"})]})]}),(0,r.jsxs)("div",{className:"users",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("h3",{children:"Usu\xe1rios"}),(0,r.jsx)(t2,{fileName:(0,eD.k6)(m),url:"/notification/list?id=".concat(c,"&limit=10000&page=0"),dataAccessor:"userList",columns:[{name:"Nome",selector:"name"},{name:"Email",selector:"email"},{name:"Data",selector:"sendAt"}]})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Nome"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{style:{width:150},children:"Data"})]})}),N?(0,r.jsx)(ee.aN,{inline:!0}):(0,r.jsx)("tbody",{children:null==k?void 0:k.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:void 0===e.name?"-":e.name}),(0,r.jsx)("td",{children:void 0===e.email?"-":e.email}),(0,r.jsx)("td",{children:(0,ej.p6)(x,"dd/MM/yyyy",n.language)})]},t))})]}),(0,r.jsx)(eZ,{numberOfItems:w,rowsPerPage:l,page:d,onPageChange:e=>i({notificationUserClickPage:e}),onRowsPerPageChange:e=>i({notificationUserClickPage:0,notificationUserClickLimit:e})})]})]})},nf=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a,setStoredState:n}=(0,o.oR)(),s=(0,ev.Nr)(null==a?void 0:a.notificationsSearch,300),{data:i,isLoading:l,refresh:d}=(0,eh.Z)("/notification/list?limit=500&search="+s),c=null==i?void 0:i.notifications;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(eu,{className:"search",placeholder:e("search.notifications"),value:(null==a?void 0:a.notificationsSearch)||"",onChange:e=>n({notificationsSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(np,{onNotificationSaved:d})]}),(0,r.jsx)("div",{className:"flex1",children:l?(0,r.jsx)(ee.aN,{inline:!0}):(0,r.jsxs)(r.Fragment,{children:[!(null==c?void 0:c.length)&&(0,r.jsx)("div",{children:"Nenhum item cadastrado!"}),(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:150,rowCount:(null==c?void 0:c.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=c[a],{image:l,title:o,message:d,send:u,sendAt:m,externalLink:h,createdAt:v,readNotificationsCount:x,audience:p,lastUpdatedBy:g}=i;return(0,r.jsx)("div",{style:s,className:"list-item-card notification",onClick:()=>{(0,ng.FJ)((0,r.jsx)(nj,{notification:i}))},children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"cover",children:(0,r.jsx)(eP.Z,{src:l,layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"title",children:o}),(0,r.jsx)("div",{className:"message",children:d}),(0,r.jsx)("div",{className:"send",children:"direct"===u||new Date(m)<new Date?"Enviado":"Envio programado para "+(0,ej.p6)(m,"Pp",t.language)}),(0,r.jsxs)("div",{className:"link",children:["Link: ",h]})]}),(0,r.jsxs)("div",{className:"col",children:[(0,r.jsxs)("div",{className:"created_at",children:["Data cria\xe7\xe3o: ",(0,ej.p6)(v,"Pp",t.language)]}),(0,r.jsxs)("div",{className:"created_at",children:["Criado por: ",void 0===g?"-":g.name]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})]})})]})},nb=(e,t,a)=>{let[n,s]=l.useState(!0),[i,r]=l.useState({}),[o,d]=l.useState({}),{toggleLoader:c}=(0,ee.U2)(),[u,m]=l.useState(!1),[h,v]=l.useState(!1);l.useRef();let x=l.useRef(!1);async function p(){try{var t;let a=await J.ZP.get("/banner/".concat(e,"?isFromAdminPainel=true"));s(!1);let n=null===(t=a.data)||void 0===t?void 0:t.error;if(n)throw Error(n);r(a.data.banner)}catch(e){s(!1),et.Am.error(e.message)}}function g(){let e={};d(e);let{title:t,subTitle:a,description:n,coverImage:s,backgroundColor:r,link:l}=i;return t||(e.title_required=!0),a||(e.subTitle_required=!0),n||(e.description_required=!0),s||(e.coverImage_required=!0),!Object.keys(e).length||(d(e),et.Am.error("Formul\xe1rio incompleto!"),window.scrollTo(0,0),!1)}async function j(){try{if(!g())return;c(!0,"Criando banner");let e=await J.ZP.post("/banner",(0,eD.GZ)(i),{headers:{"Content-Type":"multipart/form-data"}});if(e.data.error)throw d(e.data.error.message),Error(e.data.error.message);r(e.data),c(),setTimeout(()=>v(!1),1e3),et.Am.success("Banner criado com sucesso!"),d({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}async function f(){try{if(!g())return;c(!0,"Atualizando banner");let a=await J.ZP.put("/banner/".concat(e),(0,eD.GZ)(i),{headers:{"Content-Type":"multipart/form-data"}});if(c(),a.data.error)throw d(a.data.error.message),Error(a.data.error.message);r({...i,...a.data}),setTimeout(()=>v(!1),1e3),et.Am.success("Banner atualizada com sucesso!"),d({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}async function b(){try{c(!0,"Publicando banner");let e=await J.ZP.put("/banner/".concat(i.id,"/publish"));if(e.data.error)throw Error(e.data.error.message);r(e=>({...e,status:"published"})),et.Am.success("Banner publicada com sucesso!"),d({}),t(),c()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}return l.useEffect(()=>{e?p():s(!1)},[e]),(0,ev.gt)(h,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{i&&r(i)},[i]),{loading:n,banner:i,changeBannerData:function(e){r(t=>({...t,...e})),x.current&&v(!0)},onGoBack:function(){h?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitBanner:(null==i?void 0:i.id)?f:j,errors:o,removeBanner:function(){try{(0,em.Z)({text:"Deseja realmente remover este banner?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{c(!0,"Removendo banner");let e=await J.ZP.delete("/banner/".concat(i.id));if(c(),e.data.error)throw d(e.data.error.message),Error("Erro ao remover banner! \n\n"+e.data.error.message);"function"==typeof a&&a(),et.Am.success("banner removida com sucesso!"),(0,K.Mr)()}})}catch(e){c(),et.Am.error(e.message)}},publishBanner:b,setShowAddressForm:m,showAddressForm:u,refreshData:p}},ny=e=>
1{let[t,a]=l.useState([]),[n,s]=l.useState({}),[i,r]=l.useState(!1);return l.useEffect(()=>{(async function(){var e;await aN({url:"/franchise/list-admin",onProcessing:r,onSuccess:t=>a((null!==(e=null==t?void 0:t.franchises)&&void 0!==e?e:[]).sort((e,t)=>e.name.localeCompare(t.name))),onError:e=>{et.Am.error(e.message)}})})()},[]),l.useEffect(()=>{if(e&&t.length>0){let a=t.find(t=>t.id===e);s(a||{name:""})}},[e,t]),{franchises:t,fetchingFranchises:i,franchise:n,setFranchise:s}},nN=e=>{var t,a,n,s,i,o;let{t:d}=(0,p.$)("admin"),{translate:c,loading:u,translatingField:m,translations:h}=aO({targets:["en","es"]}),{loading:x,banner:g,changeBannerData:j,onGoBack:f,submitBanner:b,errors:y,removeBanner:N,publishBanner:k}=nb(e.bannerId,e.onChange,e.onDelete),{franchises:w,fetchingFranchises:Z,franchise:C,setFranchise:S}=ny(null==g?void 0:g.franchiseId),{id:_,status:D,title:E,titleEn:P,titleEs:I,subTitle:A,subTitleEn:T,subTitleEs:R,description:L,descriptionEn:q,descriptionEs:M,coverImage:O,metaDataCoverImage:F={imageAlt:"",imageTitle:""},metaDataCoverImageEn:B={imageAlt:"",imageTitle:""},metaDataCoverImageEs:U={imageAlt:"",imageTitle:""},backgroundColor:z,link:V,slug:G,lastUpdatedBy:W,updatedAt:$}=g;return((0,l.useEffect)(()=>{var e,t,a,n,s,i,r,l,o,d,c,v,x,p,g,f,b,y,N,k,w,Z,C,S,_,D,E,A,L,O,F,z,V,G,W,$;if(!u&&m&&(console.log("\uD83D\uDE80 ~ useEffect ~ translatingField:",m,"translateLoading:",u,"translations:",h),0!==Object.keys(h).length)){if((null==h?void 0:h.metaDataCoverImageTitle)&&"metaDataCoverImageTitle"===m||(null==h?void 0:h.metaDataCoverImageAlt)&&"metaDataCoverImageAlt"===m){j({titleEn:(null==h?void 0:null===(E=h.title)||void 0===E?void 0:E.en)||P,titleEs:(null==h?void 0:null===(A=h.title)||void 0===A?void 0:A.es)||I,subTitleEn:(null==h?void 0:null===(L=h.subTitle)||void 0===L?void 0:L.en)||T,subTitleEs:(null==h?void 0:null===(O=h.subTitle)||void 0===O?void 0:O.es)||R,descriptionEn:(null==h?void 0:null===(F=h.description)||void 0===F?void 0:F.en)||q,descriptionEs:(null==h?void 0:null===(z=h.description)||void 0===z?void 0:z.es)||M,metaDataCoverImageEn:{...B,imageAlt:null==h?void 0:null===(V=h.metaDataCoverImageAlt)||void 0===V?void 0:V.en,imageTitle:null==h?void 0:null===(G=h.metaDataCoverImageTitle)||void 0===G?void 0:G.en},metaDataCoverImageEs:{...U,imageAlt:null==h?void 0:null===(W=h.metaDataCoverImageAlt)||void 0===W?void 0:W.es,imageTitle:null==h?void 0:null===($=h.metaDataCoverImageTitle)||void 0===$?void 0:$.es}});return}if((null==h?void 0:h.title)&&"title"===m)return j({titleEn:null==h?void 0:null===(e=h.title)||void 0===e?void 0:e.en,titleEs:null==h?void 0:null===(t=h.title)||void 0===t?void 0:t.es,subTitleEn:(null==h?void 0:null===(a=h.subTitle)||void 0===a?void 0:a.en)||T,subTitleEs:(null==h?void 0:null===(n=h.subTitle)||void 0===n?void 0:n.es)||R,descriptionEn:(null==h?void 0:null===(s=h.description)||void 0===s?void 0:s.en)||q,descriptionEs:(null==h?void 0:null===(i=h.description)||void 0===i?void 0:i.es)||M,metaDataCoverImageEn:{...B,imageAlt:(null==h?void 0:null===(r=h.metaDataCoverImageAlt)||void 0===r?void 0:r.en)||B.imageAlt,imageTitle:(null==h?void 0:null===(l=h.metaDataCoverImageTitle)||void 0===l?void 0:l.en)||B.imageTitle},metaDataCoverImageEs:{...U,imageAlt:(null==h?void 0:null===(o=h.metaDataCoverImageAlt)||void 0===o?void 0:o.es)||U.imageAlt,imageTitle:(null==h?void 0:null===(d=h.metaDataCoverImageTitle)||void 0===d?void 0:d.es)||U.imageTitle}});if((null==h?void 0:h.subTitle)&&"subTitle"===m)return j({titleEn:(null==h?void 0:null===(c=h.title)||void 0===c?void 0:c.en)||P,titleEs:(null==h?void 0:null===(v=h.title)||void 0===v?void 0:v.es)||I,subTitleEn:h.subTitle.en,subTitleEs:h.subTitle.es,descriptionEn:(null==h?void 0:null===(x=h.description)||void 0===x?void 0:x.en)||q,descriptionEs:(null==h?void 0:null===(p=h.description)||void 0===p?void 0:p.es)||M,metaDataCoverImageEn:{...B,imageAlt:(null==h?void 0:null===(g=h.metaDataCoverImageAlt)||void 0===g?void 0:g.en)||B.imageAlt,imageTitle:(null==h?void 0:null===(f=h.metaDataCoverImageTitle)||void 0===f?void 0:f.en)||B.imageTitle},metaDataCoverImageEs:{...U,imageAlt:(null==h?void 0:null===(b=h.metaDataCoverImageAlt)||void 0===b?void 0:b.es)||U.imageAlt,imageTitle:(null==h?void 0:null===(y=h.metaDataCoverImageTitle)||void 0===y?void 0:y.es)||U.imageTitle}});if((null==h?void 0:h.description)&&"description"===m)return j({titleEn:(null==h?void 0:null===(N=h.title)||void 0===N?void 0:N.en)||P,titleEs:(null==h?void 0:null===(k=h.title)||void 0===k?void 0:k.es)||I,subTitleEn:(null==h?void 0:null===(w=h.subTitle)||void 0===w?void 0:w.en)||T,subTitleEs:(null==h?void 0:null===(Z=h.subTitle)||void 0===Z?void 0:Z.es)||R,descriptionEn:h.description.en,descriptionEs:h.description.es,metaDataCoverImageEn:{...B,imageAlt:(null==h?void 0:null===(C=h.metaDataCoverImageAlt)||void 0===C?void 0:C.en)||B.imageAlt,imageTitle:(null==h?void 0:null===(S=h.metaDataCoverImageTitle)||void 0===S?void 0:S.en)||B.imageTitle},metaDataCoverImageEs:{...U,imageAlt:(null==h?void 0:null===(_=h.metaDataCoverImageAlt)||void 0===_?void 0:_.es)||U.imageAlt,imageTitle:(null==h?void 0:null===(D=h.metaDataCoverImageTitle)||void 0===D?void 0:D.es)||U.imageTitle}})}},[h,m,u]),x)?(0,r.jsx)("div",{className:"banner-form",children:(0,r.jsx)(ee.aN,{message:"Carregando Banners"})}):(0,r.jsxs)("div",{className:"banner-form",children:[(0,r.jsx)(ei.Z,{title:d(_?"banner.edit":"banner.create"),onGoBack:f,data:{id:_,lastUpdatedBy:{name:(null==W?void 0:W.name)||""},updatedAt:$&&(0,ej.p6)($,"Pp")||""}}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"Cabe\xe7alho",content:(0,r.jsx)("div",{className:"container-banner",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"logo",children:"Imagem do Banner"}
1),(0,r.jsx)(eE.Z,{refId:"coverImage",onChange:e=>j({coverImage:e}),aspectRatio:1.65,renderBtn:(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(O),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"fields",style:{paddingLeft:0},children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)("div",{className:"meta-data-cover-image-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_alt")," - pt-BR"),value:F.imageAlt||"",onChange:e=>j({metaDataCoverImage:{...F,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==F?void 0:null===(t=F.imageAlt)||void 0===t?void 0:t.length)||0,"/").concat(d("event.meta_data_cover_image_alt_limit")),disabled:u}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_title")," - pt-BR"),value:F.imageTitle||"",onChange:e=>j({metaDataCoverImage:{...F,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==F?void 0:null===(a=F.imageTitle)||void 0===a?void 0:a.length)||0,"/").concat(d("event.meta_data_cover_image_title_limit")),disabled:u}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{j({metaDataCoverImageEn:{imageAlt:"",imageTitle:""},metaDataCoverImageEs:{imageAlt:"",imageTitle:""}}),c({field:"metaDataCoverImageAlt",text:F.imageAlt}),c({field:"metaDataCoverImageTitle",text:F.imageTitle})},disabled:u,children:u&&("metaDataCoverImageAlt"===m||"metaDataCoverImageTitle"===m)?"".concat(d("translating")):"".concat(d("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_alt")," - en-US"),value:B.imageAlt||"",onChange:e=>j({metaDataCoverImageEn:{...B,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==B?void 0:null===(n=B.imageAlt)||void 0===n?void 0:n.length)||0,"/").concat(d("event.meta_data_cover_image_alt_limit")),disabled:u}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_title")," - en-US"),value:B.imageTitle||"",onChange:e=>j({metaDataCoverImageEn:{...B,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==B?void 0:null===(s=B.imageTitle)||void 0===s?void 0:s.length)||0,"/").concat(d("event.meta_data_cover_image_title_limit")),disabled:u})]})},{id:2,label:"es-ES",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_alt")," - es-ES"),value:U.imageAlt||"",onChange:e=>j({metaDataCoverImageEs:{...U,imageAlt:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==U?void 0:null===(i=U.imageAlt)||void 0===i?void 0:i.length)||0,"/").concat(d("event.meta_data_cover_image_alt_limit")),disabled:u}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("event.meta_data_cover_image_title")," - es-ES"),value:U.imageTitle||"",onChange:e=>j({metaDataCoverImageEs:{...U,imageTitle:"".concat(e.target.value).substring(0,50)}}),helperText:"".concat((null==U?void 0:null===(o=U.imageTitle)||void 0===o?void 0:o.length)||0,"/").concat(d("event.meta_data_cover_image_title_limit")),disabled:u})]})}]})})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"franchise-select",options:w,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,disablePortal:!0,loading:Z,loadingText:"Carregando...",value:(null==C?void 0:C.name)?C:{name:""},onChange:(e,t)=>
1{S(t||{}),j({franchiseId:null==t?void 0:t.id})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"".concat(d("franchise.select")," (Opcional)"),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImage,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.name})]})})}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(d("banner.title")," - pt-BR"),value:E||"",onChange:e=>j({title:e.target.value}),error:null==y?void 0:y.title_required,disabled:u}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>c({field:"title",text:E}),disabled:u,children:u&&"title"===m?"".concat(d("translating")):"".concat(d("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("banner.title")," - en-US"),value:P||"",onChange:e=>j({titleEn:e.target.value}),disabled:u})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("banner.title")," - es-ES"),value:I||"",onChange:e=>j({titleEs:e.target.value}),disabled:u})})}]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(d("banner.subtitle")," - pt-BR"),value:A||"",onChange:e=>j({subTitle:e.target.value}),error:null==y?void 0:y.subTitle_required}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>c({field:"subTitle",text:A}),disabled:u,children:u&&"subTitle"===m?"".concat(d("translating")):"".concat(d("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("banner.subtitle")," - en-US"),value:T||"",onChange:e=>j({subTitleEn:e.target.value}),disabled:u})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("banner.subtitle")," - es-ES"),value:R||"",onChange:e=>j({subTitleEs:e.target.value}),disabled:u})})}]}),(0,r.jsx)(es.Z,{className:"textfield",label:"* "+d("banner.link"),value:V||"",onChange:e=>j({link:e.target.value})}),(0,r.jsx)(es.Z,{type:"color",className:"textfield",label:"* "+d("banner.background_color"),value:z||"",onChange:e=>j({backgroundColor:e.target.value})}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(d("banner.slug")),value:G||""})]})]})})},{id:1,label:"Descri\xe7\xe3o",content:(0,r.jsxs)("div",{className:"container-banner",children:[(0,r.jsx)("h2",{children:String(d("banner.description"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:L||"",onChange:e=>j({description:e}),disabled:u}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{j({descriptionEn:"",descriptionEs:""}),c({field:"description",text:L})},disabled:u,children:u&&"description"===m?"".concat(d("translating")):"".concat(d("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:q||"",onChange:e=>j({descriptionEn:e}),disabled:u})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:M||"",onChange:e=>j({descriptionEs:e}),disabled:u})}]})})]})}]}),(0,r.jsxs)("div",{className:"actions",children:[!!_&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:N,className:"remove-btn",children:String(d("banner.remove"))}),(0,r.jsxs)("div",{children:["published"!==D&&(0,r.jsx)(v.Z,{variant:"contained",onClick:k,size:"large",className:"submit-banner",children:String(d("banner.publish"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,size:"large",className:"submit-banner",children:String(d(_?"banner.update":"banner.create"))})]})]})]})]})},nk=()=>{var e;let{t}=(0,p.$)("admin"),{storedState:a,setStoredState:n}=(0,o.oR)(),s=(0,ev.Nr)(null==a?void 0:a.bannerSearch,300),{data:i=[],isLoading:d,refresh:c}=(0,eh.Z)("/banner/list-admin?&search=".concat(s)),[u,m]=l.useState([]),h=l.useRef();function x(e){let t=e.target.closest(".list-item-card");h.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function g(e){e.target.style.opacity=1}function j(e){e.preventDefault();let t=e.target.closest(".list-item-card");h.current!==(null==t?void 0:t.dataset.index)?t.style.left="40px":t.style.left="0px"}function f(e){let t=e.target.closest(".list-item-card");t.style.left="0px"}function b(e){e.preventDefault();let t=e.target.closest(".list-item-card");t.style.left="0px";let a=null==t?void 0:t.dataset.index;if(h.current&&h.current!==a){let e=[...u],[t]=e.splice(h.current,1);e.splice(a,0,t),m(e),y(e.map(e=>e.id))}}async function y(e){try{let t=await J.ZP.put("/banner/reorder",{order:e});if(t.data.error)throw Error(t.data.error.message);
1et.Am.success("Banners reordenados com sucesso!")}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{Array.isArray(i.banners)&&m(i.banners)},[i]),(0,r.jsxs)("div",{className:"banner",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Banners dispon\xedveis"}),(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(es.Z,{className:"search",placeholder:t("banner.search"),value:(null==a?void 0:a.bannerSearch)||"",onChange:e=>n({bannerSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==a?void 0:null===(e=a.bannerSearch)||void 0===e?void 0:e.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>n({bannerSearch:""}),children:(0,r.jsx)(ec.Z,{})})})}}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>(0,K.K4)((0,r.jsx)(nN,{onChange:c})),children:"".concat(t("banner.create"))})]}),!d||(null==u?void 0:u.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:130,rowCount:(null==u?void 0:u.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=u[a];return(0,r.jsx)("div",{"data-index":a,"data-id":i.id,className:"list-item-card banner",style:s,draggable:!0,onDragStart:x,onDragEnd:g,onDragOver:j,onDragLeave:f,onDrop:b,onClick:()=>(0,K.K4)((0,r.jsx)(nN,{bannerId:i.id,onChange:c,onDelete:c})),children:(0,r.jsxs)("div",{className:"card-content "+("published"===i.status?"active":"inactive"),children:[(0,r.jsx)("div",{style:{borderRadius:"10px",width:"100%",maxWidth:"200px"},className:"cover",children:(0,r.jsx)(eP.Z,{src:i.coverImage,layout:"fill",objectFit:"cover"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",a+1]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"title",children:[" ",i.title," "]}),(0,r.jsxs)("span",{className:"status",children:[" ","".concat(t("banner.".concat(i.status)))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"subtitle",children:i.subTitle}),(0,r.jsx)("div",{style:{backgroundColor:i.backgroundColor}
1,className:"banner-color-picker",children:"Background color: ".concat(i.backgroundColor)})]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},nw=()=>{var e;let{storedState:t,setStoredState:a}=(0,o.oR)(),n=null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id,{user:s}=(0,d.aC)(),{ticketDistributionLimit:i=20,ticketDistributionPage:r=0,ticketDistributionSearch:c=""}=t,[u,m]=l.useState(0),h=(0,ev.Nr)(c,300),{data:v,error:x}=(0,tj.ZP)("/ticket-distribution?limit=".concat(i,"&page=").concat(r,"&search=").concat(h,"&refetch=").concat(u,"&userId=").concat(null==s?void 0:s.id,"&eventId=").concat(n)),{data:p,numberOfItems:g}=(null==v?void 0:v.data)||{},[j,f]=l.useState();return{setRefetch:m,items:p,numberOfItems:g,isLoading:!x&&!v,selectedItem:j,setSelectedItem:f,closeForm:function(e){f(null),e&&m(Date.now())},setStoredState:a,ticketDistributionLimit:i,ticketDistributionPage:r,ticketDistributionSearch:c}};var nZ=a(77331),nC=a(39702),nS=a(52149),n_=a(46901),nD=a(93162),nE=a.n(nD);let nP=e=>{let{onChange:t,error:a}=e,{t:n}=(0,p.$)("admin"),{storedState:s}=(0,o.oR)(),{_id:i}=(null==s?void 0:s.currentSelectedEvent)||{},[d,c]=l.useState([]),[u,m]=l.useState(!1),[h,v]=l.useState();return l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list?"+new URLSearchParams({event_id:i||"",limit:"100",admin:"true"}),onProcessing:m,onSuccess:e=>c(null==e?void 0:e.tickets),onError:e=>{et.Am.error(e.message)}})}i&&e()},[i]),(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"ticket",options:d,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.title,disablePortal:!0,loading:u,loadingText:"Carregando...",value:h||null,onChange:(e,a)=>{v(a),t(a)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+n("ticket_distribution.select_ticket"),error:a,inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImageUrl,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.title})]})})})},nI=e=>{let{options:t=[],value:a,onChange:n,className:s}=e;return l.useEffect(()=>{1===t.length&&n(t[0].value)},[t]),(0,r.jsx)(ty.Z,{value:a,exclusive:!0,className:s,onChange:(e,t)=>
1n(t),children:t.map(e=>(0,r.jsx)(tN.Z,{value:e.value,disabled:e.disabled,children:e.label},e.value))})};var nA=a(50811),nT=a(87357);let nR=e=>{let{ticket:t,eventPriceRules:a,availableDays:n,onChange:s,error:i,helperText:d}=e,{t:c,i18n:u}=(0,p.$)("admin"),{storedState:m}=(0,o.oR)(),h=(0,ev.L6)(),v=(null==m?void 0:m.currentSelectedEvent)||{},x=l.useRef((null==n?void 0:n.includes(new Date().getDay().toString()))?new Date:void 0),g=l.useRef(""),[j,f]=l.useState(!1),b=l.useRef({}),y=l.useRef(""),N=l.useRef([]),k=l.useCallback(async function(e,a){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{f(!0);let s=await J.ZP.get("/ticket/get-hours?ticketId=".concat(null==t?void 0:t.id,"&date=").concat(e,"&selectedDayOfWeek=").concat(a)),{error:i,availableHoursOfSelectedDay:r,ticketsPurchasedAmount:l}=s.data;if(i)throw Error(i.message);if(N.current=r,b.current=l,g.current=n,1===r.length){let{id:e,startTime:t,endTime:a}=r[0];g.current=t+"-"+a,y.current=e}f(!1)}catch(e){et.Am.error(e.message),f(!1)}},[null==t?void 0:t.id]),w=l.useCallback(e=>{if(e){let t=e.getDay().toString();g.current="",x.current=(null==n?void 0:n.includes(t))?e:null,(null==n?void 0:n.includes(t))&&k(e,t)}},[n]);l.useEffect(()=>{w(x.current)},[n]);let Z=l.useCallback(e=>{if(!e)return g.current="";let[t,a]=e.split(",");g.current=a,y.current=t,s({day:x.current,hour:g.current,ticketHourId:t}),h()},[]),C=l.useMemo(()=>{var e;return null===(e=N.current)||void 0===e?void 0:e.map(e=>{let{id:t,startTime:n,endTime:s,qty:i,price:r}=e,{sold:l={}}=b.current||{},o="".concat(n,"-").concat(s),d=l[o]||0,c=1===N.current.length?"".concat(n,"-").concat(s,"h"):"".concat(n,"h"),u=[];try{if(!a||!Array.isArray(a))throw Error("eventPriceRules n\xe3o \xe9 um array v\xe1lido");u=[...a].map(e=>{var t;let a=e.type.replace(" (esgotado)",""),n=b.current["limit-percent-"+a],s=(null===(t=b.current["sold-"+a])||void 0===t?void 0:t[o])||0;return s>=i*n/100?(e.type=a+" (esgotado)",e.disabled=!0):(e.type=a,e.disabled=!1),e})}catch(e){console.error("Erro ao processar eventPriceRules:",e),et.Am.error("regra de price do evento n\xe3o configurado"),u=[]}return{label:c+" (".concat(d,"/").concat(i,")"),time:o,available:i,sold:d,value:t+","+n+"-"+s,disabled:i<=d,price:r,purchaseLimit:e.limit,availablePriceRules:u}})},[N.current,b.current,a]);return(0,r.jsxs)(nT.Z,{className:"ticket-date-selector"+(i?" ticket-date-selector--error":""),children:[(0,r.jsxs)("div",{className:"date-picker",children:[(0,r.jsxs)("div",{className:"dates",children:[(0,r.jsx)("div",{children:c("ticket_distribution.available_dates")}),(0,r.jsx)(nA.Z,{displayStaticWrapperAs:"desktop",openTo:"day",disablePast:!0,value:x.current,minDate:new Date(t.sellStartDate||v.startAt),maxDate:new Date(t.sellEndDate||v.endAt),onChange:w,renderInput:e=>(0,r.jsx)(es.Z,{...e,error:!!i}),shouldDisableDate:e=>{let t=e.getDay();return!(null==n?void 0:n.includes(t.toString()))}})]}),(0,r.jsxs)("div",{className:"variations",children:[(0,r.jsx)("div",{children:c("ticket_distribution.available_hours")}),j?(0,r.jsxs)("div",{className:"loading",children:[(0,r.jsx)(tK.Z,{}),(0,r.jsx)("span",{children:"Carregando hor\xe1rios dispon\xedveis"})]}):(0,r.jsx)(nI,{options:C,value:y.current+","+g.current,onChange:Z})]})]}),d?(0,r.jsx)(ti.Z,{error:!!i,sx:{mx:0},children:d}):null]})},nL="ticket-invitation",nq=0;function nM(){return nq+=1,"inv-row-".concat(nq)}function nO(e){return e._rowId?e:{...e,_rowId:nM()}}function nF(e){let{name:t,email:a,whatsapp:n,qty:s}=e;return{name:t,email:a,whatsapp:n,qty:s}}let nB=["xlsx","xlsb","xlsm","xls","xml","csv"].map(function(e){return"."+e}).join(","),nU={name:"Nome",email:"Email",whatsapp:"Whatsapp",qty:"Quantidade",obs:"Observa\xe7\xe3o"};function nz(e){return null==e?"":String(e).trim()}function nV(e){if(null==e||""===e)return!1;let t=Number(e);return!Number.isNaN(t)&&t>0}function nG(e){return!!(nz(null==e?void 0:e.name)&&nz(null==e?void 0:e.email)&&nV(null==e?void 0:e.qty))}function nW(e){let t=null==e?void 0:e.qty,a=null==t||""===t||"number"==typeof t&&Number.isNaN(t);return!nz(null==e?void 0:e.name)&&!nz(null==e?void 0:e.email)&&a}function n$(e){return!nW(e)&&!nG(e)}function nH(e){let t={},{hasPresetTicket:a,ticketId:n,selectDateAndTime:s,selectedTime:i,users:r}=e;a||n||(t.ticket=!0),s&&!nz(i)&&(t.ticketDate=!0);let l={};r.forEach((e,t)=>{n$(e)?l[t]={name:!nz(null==e?void 0:e.name),email:!nz(null==e?void 0:e.email),qty:!nV(null==e?void 0:e.qty)}:nG(e)&&!(0,eD.oH)(nz(e.email))&&(l[t]={email:!0})});let o=0===r.length||r.every(nW),d=r.some(n$),c=r.filter(nG).filter(e=>(0,eD.oH)(nz(e.email))),u=Object.keys(l).length>0;o&&(t.tableEmpty=!0),Object.keys(l).length&&(t.rows=l);let m=!t.ticket&&!t.ticketDate&&!o&&!d&&c.length>0&&!u;return{ok:m,errors:m?{}:t,validUsers:m?c:[]}}let nJ=e=>{var t,a;let{ticketsAvailable:n,onClose:s,setTaskId:i,setTask:d}=e,{t:c}=(0,p.$)("admin"),{toggleLoader:u,setLoaderProgress:m}=(0,ee.U2)(),h=(0,ev.L6)(),x=l.useRef([{_rowId:nM()}]),[g,j]=l.useState(e.ticket||{}),[f,b]=l.useState(!1),y=(0,l.useRef)(),N=(0,l.useRef)(),k=l.useRef(""),w=l.useRef(""),[Z,C]=l.useState({}),[S,_]=l.useState(),D=l.useRef(),E=l.useCallback(e=>{C(e=>({...e,ticket:!1})),j(e)},[]);l.useEffect(()=>{if(!S)return;u(!0,c("ticket_invitation.importing_file")),m({variant:"indeterminate"});let t=new FileReader,a=!!t.readAsBinaryString,s=0,i=()=>{m(null),u(!1),D.current&&(D.current.value=""),_(null)};t.onerror=()=>{et.Am.error(c("ticket_invitation.import_file_read_error")),i()},t.onprogress=e=>{let t=Date.now(),a=e.lengthComputable?e.total:0,n=e.loaded;(a>0&&n>=a||!(t-s<100))&&(s=t,e.lengthComputable&&a>0&&n<a?m({variant:"determinate",value:Math.min(99,Math.round(n/a*100))}):e.lengthComputable&&0!==a||m({variant:"indeterminate"}))},t.onload=t=>{u(!0,c("ticket_invitation.processing_spreadsheet")),m({variant:"indeterminate"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{try{let s=t.target.result,i=(0,t0.ij)(s,{type:a?"binary":"array",bookVBA:!0,cellDates:!0}),r=i.SheetNames[0],o=i.Sheets[r],d=t0.P6.sheet_to_json(o,{raw:!0,defval:"",rawNumbers:!0}),u=[];
1d.forEach(e=>{u.push({name:e[nU.name],email:e[nU.email],whatsapp:"".concat(e[nU.whatsapp]),qty:e[nU.qty]})});let m=n?n-x.current.length:1/0,v=u;u.length>m&&(et.Am.warn(c("ticket_distribution.import_limit_exceeded")+m+c("ticket_distribution.import_limit_exceeded_imported_qty")),v=u.slice(0,m));let p=x.current.filter(e=>e.name||e.email).map(nO),j=v.map(e=>({...e,_rowId:nM()}));x.current=[...p,...j];let{errors:b}=nH({hasPresetTicket:!!e.ticket,ticketId:null==g?void 0:g.id,selectDateAndTime:f,selectedTime:N.current,users:x.current});C(b),l.startTransition(()=>{h()})}catch(e){et.Am.error((null==e?void 0:e.message)||c("ticket_invitation.import_file_read_error"))}finally{i()}})})},a?t.readAsBinaryString(S):t.readAsArrayBuffer(S)},[S]),l.useEffect(()=>{f||(y.current=void 0,N.current=void 0)},[f]),l.useEffect(()=>{b(!1)},[g.id]);let P=()=>{let e=t0.P6.json_to_sheet([{[nU.name]:""},{[nU.email]:""},{[nU.whatsapp]:""},{[nU.qty]:""}]),t=(0,t0.cW)({Sheets:{data:e},SheetNames:["data"]},{bookType:"xlsx",type:"array"}),a=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(a,"Modelo-exportacao-convite-em-massa.xlsx")},I=l.useCallback((e,t)=>{C(a=>{if(!a.rows||!a.rows[e])return a;let n=a.rows[e],s={...n};nz(t.name)&&delete s.name;let i=nz(t.email);n.email&&(i&&(0,eD.oH)(i)?delete s.email:s.email=!0),nV(t.qty)&&delete s.qty;let r={...a.rows};return Object.keys(s).length?r[e]=s:delete r[e],{...a,rows:Object.keys(r).length?r:void 0}})},[]),A=l.useCallback((e,t)=>{let a=[...x.current];a[t]={...a[t],...e},x.current=a,I(t,a[t])},[I]);async function T(){let{ok:t,errors:a,validUsers:n}=nH({hasPresetTicket:!!e.ticket,ticketId:null==g?void 0:g.id,selectDateAndTime:f,selectedTime:N.current,users:x.current});if(C(a),h(),!t){if(a.ticket)et.Am.error(c("incomplete_form"));else if(a.ticketDate)et.Am.error(c("ticket_invitation.need_select_date"));else if(a.tableEmpty)et.Am.error(c("ticket_invitation.no_users_to_send_invitation"));else if(x.current.some(n$))et.Am.error(c("incomplete_table_form"));else{let e=function(e){let t=e.findIndex(e=>nG(e)&&!(0,eD.oH)(nz(e.email)));return t}(x.current);e>-1?et.Am.error(c("ticket_invitation.invalid_email")+(e+1)):et.Am.error(c("incomplete_form"))}return}let s={users:n.map(nF),obs:w.current,userTimezoneOffset:(0,ej.Y5)(),ticketData:{id:g.id,date:y.current,time:N.current,dayOfWeek:y.current?new Date(y.current).getDay():null,ticketHourId:k.current}};(0,em.Z)({text:c("ticket_invitation.send_invitation"),confirmButtonText:c("ticket_invitation.send_invitation_yes"),onConfirm:async()=>{try{u(!0,"Preparando para enviar convites em massa");let{data:e}=await J.ZP.post("/task",{title:"Envio de convites em massa",screen:nL,description:"Preparando para enviar convites em massa"}),t=localStorage.getItem(o.rR),a=t?JSON.parse(t):[],n=[...a.filter(t=>t.screen!==e.screen),e];localStorage.setItem(o.rR,JSON.stringify(n)),i(e.id),d(e);let r=await J.ZP.post("/ticket-invitation?taskId=".concat(e.id),s);if(r.data.error)throw u(),Error(c("error_on_processing")+"\n\n"+r.data.error.message);u(!1)}catch(e){u(),et.Am.error(e.message)}}})}return(0,r.jsx)("div",{className:"ticket-invitation-form forms",children:(0,r.jsxs)("div",{className:"form",style:{maxWidth:1500},children:[(0,r.jsx)(ei.Z,{title:c("ticket_invitation.create")+(n?" ("+c("ticket_invitation.qty_available")+" "+n+")":""),onGoBack:()=>s(!1)}),(0,r.jsxs)("div",{className:"form-content",children:[!e.ticket&&(0,r.jsx)(nP,{onChange:E,error:!!Z.ticket}),(0,r.jsx)(to.Z,{label:c("ticket_invitation.choose_date"),onChange:e=>{b(e),C(e=>({...e,ticketDate:!1}))},checked:f,disabled:!(null==g?void 0:g.id)||["passport","pack"].includes(g.type)}),f&&(0,r.jsx)(nR,{ticket:g,eventPriceRules:g.eventPriceRules,availableDays:null==g?void 0:g.availableDays,onChange:e=>{let{day:t,hour:a,ticketHourId:n}=e;y.current=t,N.current=a,k.current=n,C(e=>({...e,ticketDate:!1}))},error:!!Z.ticketDate,helperText:Z.ticketDate?c("ticket_invitation.need_select_date"):void 0}),(0,r.jsxs)("div",{className:"import-actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:P,startIcon:(0,r.jsx)(nC.Z,{}),children:c("ticket_invitation.download_model")}),(0,r.jsx)("input",{type:"file",accept:nB,style:{display:"none"},onChange:e=>{let t=e.target.files;t&&t[0]&&_(t[0])},ref:D,id:"button-file"}),(0,r.jsx)(v.Z,{variant:"outlined",component:"label",htmlFor:"button-file",startIcon:(0,r.jsx)(nS.Z,{}),children:c("ticket_invitation.import_table")})]}),Z.tableEmpty?(0,r.jsx)(n_.Z,{severity:"warning",sx:{mt:2,mb:1},children:c("ticket_invitation.no_users_to_send_invitation")}):null,(0,r.jsxs)("table",{className:"import-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"import-table__line-col",children:c("ticket_invitation.line_number")}),(0,r.jsx)("th",{children:c("name")}
1),(0,r.jsx)("th",{children:c("email")}),(0,r.jsx)("th",{children:c("whatsapp")}),(0,r.jsx)("th",{children:c("qty")}),(0,r.jsx)("th",{children:c("action")})]})}),(0,r.jsx)("tbody",{children:null===(t=x.current)||void 0===t?void 0:t.map((e,t)=>{var n,s,i,l,o,d,u,m,v,p,g,j;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"import-table__line-col import-table__line-num",children:t+1}),(0,r.jsx)("td",{children:(0,r.jsx)(ah.Z,{defaultValue:e.name,onBlur:e=>A({name:e},t),error:!!(null===(n=Z.rows)||void 0===n?void 0:null===(s=n[t])||void 0===s?void 0:s.name),helperText:(null===(i=Z.rows)||void 0===i?void 0:null===(l=i[t])||void 0===l?void 0:l.name)?c("required_field"):void 0})}),(0,r.jsx)("td",{children:(0,r.jsx)(ah.Z,{type:"email",defaultValue:e.email,onBlur:e=>A({email:e},t),autoComplete:"email",error:!!(null===(o=Z.rows)||void 0===o?void 0:null===(d=o[t])||void 0===d?void 0:d.email),helperText:(null===(u=Z.rows)||void 0===u?void 0:null===(m=u[t])||void 0===m?void 0:m.email)?nz(e.email)&&!(0,eD.oH)(nz(e.email))?c("ticket_invitation.invalid_email")+(t+1):c("required_field"):void 0})}),(0,r.jsx)("td",{children:(0,r.jsx)(ah.Z,{type:"tel",defaultValue:e.whatsapp,onBlur:e=>A({whatsapp:e},t),autoComplete:"tel"})}),(0,r.jsx)("td",{children:(0,r.jsx)(ah.Z,{type:"number",defaultValue:e.qty,onBlur:e=>A({qty:parseInt(e,10)},t),error:!!(null===(v=Z.rows)||void 0===v?void 0:null===(p=v[t])||void 0===p?void 0:p.qty),helperText:(null===(g=Z.rows)||void 0===g?void 0:null===(j=g[t])||void 0===j?void 0:j.qty)?c("required_field"):void 0})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{className:"table-actions",children:(0,r.jsx)(X.Z,{onClick:()=>{let e=[...x.current];e.splice(t,1),x.current=e,C(e=>{if(!e.rows)return{...e,tableEmpty:!1};let a={};return Object.entries(e.rows).forEach(e=>{let[n,s]=e,i=Number(n);i<t?a[i]=s:i>t&&(a[i-1]=s)}),{...e,tableEmpty:!1,rows:Object.keys(a).length?a:void 0}}),h()},children:(0,r.jsx)(eg.Z,{})})})})]},null!==(a=e._rowId)&&void 0!==a?a:"fallback-".concat(t))})})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:function(){x.current=[...x.current,{_rowId:nM()}],h()},startIcon:(0,r.jsx)(eU.Z,{}),className:"add-row",disabled:!!n&&x.current.length>=n,children:c("ticket_distribution.add_row")}),(0,r.jsx)(ah.Z,{label:c("obs"),onValueChange:e=>w.current=e}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>s(!1),className:"close-btn",children:c("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:T,className:"save-btn",children:c("ticket_invitation.create")})]})]})]})})};var nQ=a(10718),nY=a(11802);let nK="@inv_invite_task_panel_minimized",nX=e=>{let{open:t,title:a,description:n,progress:s,starting:i}=e,{t:o}=(0,p.$)("admin"),[d,c]=l.useState(()=>"undefined"!=typeof sessionStorage&&"1"===sessionStorage.getItem(nK)),u=l.useCallback(e=>{c(e);try{sessionStorage.setItem(nK,e?"1":"0")}catch(e){}},[]);if(!t)return null;let m="number"!=typeof s||Number.isNaN(s)?0:Math.min(100,Math.max(0,s)),h=i?"indeterminate":"determinate",v=a||o("ticket_invitation.bulk_task_progress_title"),x=n||o("ticket_invitation.bulk_task_sending");return d?(0,r.jsxs)(t5.Z,{elevation:8,sx:{position:"fixed",right:16,bottom:16,zIndex:1450,maxWidth:360,px:1.5,py:1,display:"flex",alignItems:"center",gap:1,borderRadius:1},children:[(0,r.jsxs)(nT.Z,{sx:{flex:1,minWidth:0},children:[(0,r.jsx)(a1.Z,{variant:"subtitle2",noWrap:!0,children:v}),(0,r.jsx)(a1.Z,{variant:"caption",color:"text.secondary",noWrap:!0,children:i?o("ticket_invitation.bulk_task_connecting"):"".concat(m,"% \xb7 ").concat(x)})]}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>u(!1),"aria-label":o("ticket_invitation.bulk_task_maximize"),children:(0,r.jsx)(nQ.Z,{fontSize:"small"})})]}):(0,r.jsxs)(t5.Z,{elevation:12,sx:{position:"fixed",left:"50%",bottom:24,transform:"translateX(-50%)",zIndex:1450,width:"min(560px, calc(100vw - 32px))",p:2,borderRadius:1},children:[(0,r.jsxs)(nT.Z,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1,mb:1.5},children:[(0,r.jsx)(a1.Z,{variant:"h6",component:"h2",sx:{fontSize:"1.05rem",pr:1},children:v}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>u(!0),"aria-label":o("ticket_invitation.bulk_task_minimize"),children:(0,r.jsx)(nY.Z,{fontSize:"small"})})]}),(0,r.jsx)(a1.Z,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:x}),(0,r.jsx)(a5.Z,{variant:h,value:"determinate"===h?m:void 0,sx:{height:8,borderRadius:1}}),i?null:(0,r.jsxs)(a1.Z,{variant:"caption",color:"text.secondary",sx:{dis
1play:"block",mt:1},children:[m,"%"]})]})};var n0=a(67642);let n1=null,n2=0;function n3(e){return n2+=1,n1?(n1.auth={token:e},n1.connected||n1.connect()):n1=(0,n0.io)(J.T5,{auth:{token:e},transports:["websocket","polling"],autoConnect:!0}),n1}function n6(){0===(n2=Math.max(0,n2-1))&&n1&&(n1.removeAllListeners(),n1.disconnect(),n1=null)}let n5=e=>{let{screen:t}=e,a=function(e){try{let t=localStorage.getItem(o.rR);if(!t)return{id:null,task:{}};let a=JSON.parse(t),n=a.find(t=>t.screen===e&&t.id&&"in_progress"===t.status);if(n)return{id:n.id,task:n}}catch(e){}return{id:null,task:{}}}(t),[n,s]=(0,l.useState)(a.task),[i,r]=(0,l.useState)(a.id),[c,u]=(0,l.useState)(!!a.id),m=l.useCallback(e=>{let t=JSON.parse(localStorage.getItem(o.rR)||"[]"),a=[...t.filter(t=>t.screen!==e.screen),e];localStorage.setItem(o.rR,JSON.stringify(a))},[]),h=l.useCallback(e=>{(null==e?void 0:e.id)&&((0,Q.C)("useTaskListener data:",e),u(!1),s(e),m(e))},[m]);return l.useEffect(()=>{let e,t;if(!i){u(!1);return}u(!0);let a=(0,as.parseCookies)()[d.Y5],n=async()=>{let{data:e}=await J.ZP.get("/task/".concat(i));if(!(!(null==e?void 0:e.id)||Array.isArray(e)))return e},s=async()=>{let t=await n();t&&(h(t),"in_progress"!==t.status&&e&&(clearInterval(e),e=void 0))},r=()=>{s(),e=setInterval(s,2e3)};if(a){t=n3(a);let n=t=>{(t.id===i||t.requestId===i)&&(h(t),"in_progress"!==t.status&&e&&(clearInterval(e),e=void 0))};return t.on("task:update",n),t.on("connect_error",()=>{e||r()}),t.on("connect",()=>{s()}),t.connected?s():r(),()=>{null==t||t.off("task:update",n),n6(),e&&clearInterval(e)}}return r(),()=>{e&&clearInterval(e)}},[i,h]),{...n,setTask:s,setTaskId:r,starting:c}},n8=e=>{var t,a,n;let{item:s,onClose:i}=e,{storedState:c}=(0,o.oR)(),{user:u}=(0,d.aC)(),{startAt:m,endAt:h}=(null==c?void 0:c.currentSelectedEvent)||{},{toggleLoader:x}=(0,ee.U2)(),{t:g,i18n:j}=(0,p.$)("admin"),[f,y]=l.useState(),{data:N,error:k}=(0,tj.ZP)("/ticket/list?id=".concat(null==s?void 0:s.ticket.id)),w=(0,tj.ZP)("/ticket-purchase/list?ticketId=".concat(null==s?void 0:s.ticket.id,"&ticketTypeId=invitation&invitedByUserId=").concat(null==u?void 0:u.id,"&refetch=").concat(f)),[Z,C]=l.useState(!1),{id:S,status:_,setTaskId:D,setTask:E,description:P,progress:I,title:A,starting:T}=n5({screen:nL});(0,l.useEffect)(()=>{if("completed"===_&&S){x(!0,g("ticket_invitation.bulk_task_finalizing"));let e=setTimeout(()=>{x(!1),et.Am.success(g("success_on_processing")),q(!0),D(null),E({})},3e3);return()=>clearTimeout(e)}},[_,S]),(0,l.useEffect)(()=>{"error"===_&&S&&(x(!1),et.Am.error(g("error_on_processing")),D(null),E({}))},[_,S]);let R=(null==N?void 0:null===(t=N.data)||void 0===t?void 0:t.tickets[0])||{};w.error||w.data;let L=null==w?void 0:null===(a=w.data)||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:n.items;function q(e){C(!1),e&&y(Date.now())}async function M(e,t){try{x(!0,"Gerando PDF");let t=await J.ZP.get("/ticket-purchase/download/".concat(e),{responseType:"blob"});if(x(),t.data.error)throw Error(g("error_on_processing")+"\n\n"+t.data.error.message);let a=window.URL.createObjectURL(t.data),n=document.createElement("a");n.href=a,n.target="_blank",n.rel="noopener noreferrer",n.click()}catch(e){x()}}let O=l.useMemo(()=>{var e;return(null==L?void 0:L.length)||(null==s?void 0:null===(e=s.used)||void 0===e?void 0:e.length)},[s,L]),{title:F,coverImageUrl:B}=R;if(!s)return null;let{qty:U}=s,z=U-O;return(0,r.jsx)("div",{className:"ticket-item forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:g("ticket_distribution.edit"),onGoBack:()=>i(!1)}),(0,r.jsxs)("div",{className:"ticket-info form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:B,width:3200/9,height:200})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"title",children:F}),(0,r.jsxs)("div",{children:["Data evento: ",(0,ej.p6)(m,"P",j.language)," \xe0 ",(0,ej.p6)(h,"P",j.language)]}),(0,r.jsx)("div",{className:"available-tickets",children:g("ticket_distribution.available_tickets")+":"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"stats",children:[(0,r.jsx)("div",{className:"number",children:U}),(0,r.jsx)("div",{className:"label",children:g("ticket_distribution.amount")})]}),(0,r.jsxs)("div",{className:"stats",children:[(0,r.jsx)("div",{className:"number",children:O}),(0,r.jsx)("div",{className:"label",children:g("ticket_distribution.used")})]}),(0,r.jsxs)("div",{className:"stats",children:[(0,r.jsx)("div",{className:"number",children:z}),(0,r.jsx)("div",{className:"label",children:g("ticket_distribution.available")})]})]})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("h3",{children:g("ticket_distribution.invited_list")}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>C(!0),className:"add-ticket",startIcon:(0,r.jsx)(b.Z,{}),disabled:!z,children:g("ticket_distribution.send_invitation")})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:g("name")}
1),(0,r.jsx)("th",{children:g("email")}),(0,r.jsx)("th",{children:g("ticket_distribution.time")}),(0,r.jsx)("th",{children:g("status")}),(0,r.jsx)("th",{children:g("last_update")}),(0,r.jsx)("th",{children:g("action")})]})}),(0,r.jsx)("tbody",{children:null==L?void 0:L.map((e,t)=>{var a,n;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:null===(a=e.user)||void 0===a?void 0:a.name}),(0,r.jsx)("td",{children:null===(n=e.user)||void 0===n?void 0:n.email}),(0,r.jsx)("td",{children:e.time?(0,ej.p6)(e.date,"P",j.language)+" "+e.time:g("ticket_distribution.no_date_set")}),(0,r.jsx)("td",{children:g("ticket_distribution."+e.status)}),(0,r.jsx)("td",{children:(0,ej.p6)(e.updatedAt,"Pp",j.language)}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"table-actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:g("ticket_distribution.resend_invitation"),children:(0,r.jsx)(X.Z,{onClick:()=>{var t;return t=e.id,void(0,em.Z)({text:g("ticket_distribution.resend_invitation")+"?",confirmButtonText:g("ticket_distribution.resend_invitation_yes"),onConfirm:async()=>{x(!0);let e=await (0,J.ZP)("/ticket-invitation/send-invitation-email/".concat(t));if(x(),e.data.error)throw Error(g("error_on_processing")+"\n\n"+e.data.error.message);et.Am.success(g("success_on_processing"))}})},children:(0,r.jsx)(eO.Z,{})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:g("ticket_distribution.download_invitation"),children:(0,r.jsx)(X.Z,{onClick:()=>M(e.id,"Convite "+e.user.name),children:(0,r.jsx)(nC.Z,{})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:g("ticket_distribution.cancel_invitation"),children:(0,r.jsx)(X.Z,{onClick:()=>{var t;return t=e.id,void(0,em.Z)({text:g("ticket_distribution.cancel_invitation?"),confirmButtonText:g("ticket_distribution.cancel_invitation_yes"),onConfirm:async()=>{x(!0);let e=await J.ZP.delete("/ticket-purchase/".concat(t));if(x(),e.data.error)throw Error(g("error_on_processing")+"\n\n"+e.data.error.message);et.Am.success(g("success_on_processing")),y(Date.now())}})},children:(0,r.jsx)(eg.Z,{})})})]})})]},t)})})]}),(0,r.jsx)(nX,{open:!!S&&("in_progress"===_||T),title:A,description:P,progress:I,starting:T}),(0,r.jsx)(K.ZP,{showAt:Z,onClose:q,children:(0,r.jsx)(nJ,{ticket:R,setTaskId:D,setTask:E,onClose:q,ticketsAvailable:z})})]})]})})},n7=()=>{let{t:e}=(0,p.$)("admin"),{items:t,numberOfItems:a,isLoading:n,selectedItem:s,setSelectedItem:i,setStoredState:l,ticketDistributionLimit:o,ticketDistributionPage:d,ticketDistributionSearch:c,closeForm:u}=nw();return(0,r.jsxs)("div",{className:"prof-tickets",children:[(0,r.jsx)("h3",{children:"Distribui\xe7\xe3o dos ingressos"}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(es.Z,{className:"search",placeholder:e("ticket_distribution.search_ticket"),value:c,onChange:e=>l({ticketDistributionSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!c&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>l({ticketDistributionSearch:""}),children:(0,r.jsx)(ec.Z,{})})})}})}),!!n&&(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Quantidade"}),(0,r.jsx)("th",{children:"Usados"}),(0,r.jsx)("th",{children:"Dispon\xedveis"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),(0,r.jsx)("tbody",{children:null==t?void 0:t.map((e,t)=>{var a;let n=e.used.length;return(0,r.jsxs)("tr",{onDoubleClick:()=>i(e),children:[(0,r.jsx)("td",{children:null===(a=e.ticket)||void 0===a?void 0:a.title}),(0,r.jsx)("td",{children:e.qty}),(0,r.jsx)("td",{children:n}),(0,r.jsx)("td",{children:e.qty-n}),(0,r.jsx)("td",{children:(0,r.jsx)(X.Z,{onClick:()=>i(e),children:(0,r.jsx)(nZ.Z,{})})})]},t)})})]}),!n&&!(null==t?void 0:t.length)&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),(0,r.jsx)(eZ,{numberOfItems:a,rowsPerPage:o,page:d,onPageChange:e=>l({ticketDistributionPage:e}),onRowsPerPageChange:e=>l({ticketDistributionPage:0,ticketDistributionLimit:e})}),(0,r.jsx)(K.ZP,{showAt:!!s,onClose:()=>u(!1),children:(0,r.jsx)(n8,{item:s,onClose:u})})]})};var n4=a(50891),n9=a(15364);let se=e=>String((null==e?void 0:e.professionalId)||(null==e?void 0:e.id)||""),st=()=>{let{t:e}=(0,p.$)("admin"),{storedState:t,setStoredState:a}=(0,o.oR)(),{toggleLoader:n}=(0,ee.U2)(),{data:s,isLoading:i,refresh:d}=(0,eh.Z)("/professional/list?limit=0&compact=1"),{professionals:c}=s||{},[u,m]=l.useState({}),[h,x]=l.useState(!1),g=l.useMemo(()=>(c||[]).map(e=>{var t,a,n,s;let i=u[se(e)];return i?{...e,name:null!==(t=i.name)&&void 0!==t?t:e.name,avatar:null!==(a=i.avatar)&&void 0!==a?a:e.avatar,contacts:null!==(n=i.contacts)&&void 0!==n?n:e.contacts,slug:null!==(s=i.slug)&&void 0!==s?s:e.slug}:e}
1),[c,u]),j=(null==t?void 0:t.professionalSearch)?g.filter(e=>{var a;let n=RegExp(t.professionalSearch,"i");return n.test(e.name||"")||n.test((null===(a=e.contacts)||void 0===a?void 0:a.email)||e.email||"")}):g;function f(e){let t=se(e);t&&m(a=>({...a,[t]:e})),d()}function b(e){(0,K.K4)((0,r.jsx)(n9.Z,{professionalId:e,inModal:!0,onSaved:f}))}async function y(){if(!h)try{var e,t;x(!0),n(!0,"Gerando CSV...");let a=await J.ZP.get("/professional/export-csv",{responseType:"blob"}),s=a.data;if(s instanceof Blob&&s.type&&s.type.includes("application/json")){let e=JSON.parse(await s.text());throw Error((null==e?void 0:null===(t=e.error)||void 0===t?void 0:t.message)||"Erro ao exportar CSV")}if(null==s?void 0:s.error)throw Error(s.error.message||"Erro ao exportar CSV");let i=(null===(e=a.headers)||void 0===e?void 0:e["content-disposition"])||"",r=i.match(/filename=['"]?([^'";\n]+)/i),l=(null==r?void 0:r[1])||"profissionais.csv",o=s instanceof Blob?await s.arrayBuffer():s,d=new Blob([o],{type:"text/csv;charset=utf-8"}),c=window.URL.createObjectURL(d),u=document.createElement("a");u.href=c,u.download=l,u.click(),u.remove(),window.URL.revokeObjectURL(c)}catch(e){et.Am.error((null==e?void 0:e.message)||"Erro ao baixar CSV")}finally{x(!1),n()}}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{style:{padding:10,paddingTop:0,margin:0},children:"Profissionais"}),(0,r.jsxs)("div",{className:"head professionals-list-toolbar",children:[(0,r.jsx)(eu,{className:"search",placeholder:e("search.professionals"),value:(null==t?void 0:t.professionalSearch)||"",onChange:e=>a({professionalSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(v.Z,{className:"btn-download",variant:"outlined",startIcon:(0,r.jsx)(nC.Z,{}),onClick:y,disabled:h,children:"Baixar CSV"}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>b(),children:"Novo cadastro"})]}),(0,r.jsx)("div",{className:"flex1",children:!i||(null==j?void 0:j.length)?(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:115,rowCount:(null==j?void 0:j.length)||0,overscanRowCount:8,data:j,rowRenderer:e=>{var t;let{index:a,key:n,style:s}=e,i=j[a];return(0,r.jsx)("div",{style:s,className:"list-item-card",onClick:()=>b(i.professionalId||i.id),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"cover",children:(0,r.jsx)(eP.Z,{src:i.avatar,layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"title",children:i.name}),(0,r.jsxs)("div",{className:"locale",children:[(0,r.jsx)(n4.Z,{className:"icon-text"}),(0,r.jsx)("p",{children:(null===(t=i.contacts)||void 0===t?void 0:t.email)||i.email})]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}}):(0,r.jsx)("div",{className:"loader",children:(0,r.jsx)(ee.aN,{})})})]})};var sa=a(43703),sn=a(4135),ss=a(11640);let si=["Janeiro","Fevereiro","Mar\xe7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],sr=e=>{let{eventId:t,onConfirm:a}=e,{t:n}=(0,p.$)("admin"),[s,i]=l.useState("today"),[o,d]=l.useState(new Date),[c,u]=l.useState(new Date),m=(e,t)=>{t&&i(t),"today"===t&&(d(new Date),u(new Date))},h=l.useCallback(()=>{let e=(0,tD.Z)(o),t=(0,tP.Z)(c);"today"===s?(e=(0,tD.Z)(new Date),t=(0,tP.Z)(new Date)):"day"===s?t=e:"week"===s?(e=(0,tI.Z)(e),t=(0,tA.Z)(e)):"month"===s?(e=(0,sa.Z)(e),t=(0,sn.Z)(e)):"year"===s&&(e=(0,tT.Z)(e),t=(0,tR.Z)(e)),a({dateRange:s,startDate:e,endDate:t,isSameDay:(0,tC.Z)(o,c),todayDate:new Date})},[a,s,o,c]);l.useEffect(()=>{h()},[s,h,t]);let x=l.useMemo(()=>"day"===s||"today"===s?"".concat(o.getDate()," de ").concat((0,ej.p6)(o,"MMMM yyyy")):"week"===s?"De ".concat((0,tI.Z)(o).getDate()," \xe0 ").concat((0,tA.Z)(o).getDate()," de ").concat((0,ej.p6)(o,"MMMM yyyy")):"month"===s?"".concat(si[o.getMonth()]):"year"===s?"Ano ".concat((0,ej.p6)(o,"yyyy")):"future"===s?"A Receber":void 0,[s,o]);return(0,r.jsxs)("div",{className:"date-range-select",children:[(0,r.jsxs)(ty.Z,{color:"primary",size:"small",value:s,exclusive:!0,onChange:m,className:"range-selector",children:[(0,r.jsx)(tN.Z,{value:"today",children:"Hoje"}),(0,r.jsx)(tN.Z,{value:"week",onClick:h,children:"Semana"}),(0,r.jsx)(tN.Z,{value:"month",onClick:h,children:"M\xeas"}),(0,r.jsx)(tN.Z,{value:"year",onClick:h,children:"Ano"}),(0,r.jsx)(tN.Z,{value:"custom",children:"Per\xedodo"})]}),"custom"===s?(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsx)(tM.Z,{label:n("start"),className:"input",value:o||null,onChange:e=>d(e),disableFuture:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(tM.Z,{label:n("end"),className:"input",value:c||null,onChange:e=>u(e),renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:h,children:"filtrar"})]}):(0,r.jsxs)("div",{className:"date-select",children:[(0,r.jsx)(X.Z,{onClick:function(){d(e=>"today"===s?(i("day"),(0,tS.Z)(e,-1)):"day"===s?(0,tS.Z)(e,-1):"week"===s?(0,tL.Z)(e,-1):"month"===s?(0,ss.Z)(e,-1):(0,tq.Z)(e,
1-1))},children:(0,r.jsx)(tk.Z,{})}),(0,r.jsx)("div",{children:x}),(0,r.jsx)(X.Z,{onClick:function(){d(e=>"today"===s?(i("day"),(0,tS.Z)(e,1)):"day"===s?(0,tS.Z)(e,1):"week"===s?(0,tL.Z)(e,1):"month"===s?(0,ss.Z)(e,1):(0,tq.Z)(e,1))},children:(0,r.jsx)(tw.Z,{})})]})]})};var sl=a(88078);let so=e=>{let{searchPeriod:t}=e,{t:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),{currentSelectedEvent:i}=n||{},{toggleLoader:d}=(0,ee.U2)(),{usersSearch:c=""}=n,u=(0,ev.Nr)(c,300),[m,h]=l.useState(-1),[x,g]=l.useState(10),[j,f]=l.useState(!1),b=new URLSearchParams({...Object.fromEntries(e.query),search:u}),{data:y={},isLoading:N}=(0,eh.Z)("/user-favorite/environment-users?"+b),{items:k,numberOfItems:w}=y||{};async function Z(){if(x<=0){(0,em.Z)({text:"Informe o tempo de dura\xe7\xe3o do sorteio",confirmButtonText:"Ok",showCancelButton:!1,icon:"warning"});return}let e=x;d(!0,"Sorteando ".concat(e,"s")),f(!0);let t=-1,a=0,n=setInterval(()=>{h(t=(0,eD.lv)(0,w-1)),console.log("\uD83D\uDE80 ~ interval ~ randomNumber:",t),1e3===(a+=500)&&(a=0,e-=1,d(!0,"Sorteando ".concat(e,"s")))},500);setTimeout(()=>{clearInterval(n),d();let e=k[t];(0,em.Z)({title:"Sorteado",text:"Usu\xe1rio ".concat((null==e?void 0:e.name)?e.name:"").concat((null==e?void 0:e.name)?" - ".concat(e.email):e.email,");"),confirmButtonText:"Ok",showCancelButton:!1,icon:"success"})},1e3*x)}return(0,r.jsxs)("div",{className:"environment-favorite-users",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:"Usu\xe1rios que curtiram no per\xedodo ".concat(t)}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(v.Z,{variant:"contained",onClick:Z,children:"Sortear"}),(0,r.jsx)(ah.Z,{type:"number",label:"Dura\xe7\xe3o do sorteio (em segundos)",value:x,onValueChange:e=>g(Number(e)),inputProps:{min:1}})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID do Usu\xe1rio"}),(0,r.jsx)("th",{children:"Nome"}),(0,r.jsx)("th",{children:"Email"})]})}),(0,r.jsx)("tbody",{children:N?(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:8,children:(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})})})}):null==k?void 0:k.map((e,t)=>(0,r.jsxs)("tr",{className:t===m?"random-selection":"",children:[(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:e.name}),(0,r.jsx)("td",{children:e.email})]},t))})]})]})]})},sd=e=>{let{t}=(0,p.$)("admin"),{eventId:a,startDate:n=new Date,endDate:s=new Date,data:i,isLoading:l}=e,{rankingEnvironmentFavorites:o}=i||{};if(console.log("\uD83D\uDE80 ~ Statistics ~ rankingEnvironmentFavorites:",o),!i)return null;let d=n&&s?" de ".concat((0,ej.p6)(n,"P")," \xe0 ").concat((0,ej.p6)(s,"P")):n&&!s?" a partir de ".concat((0,ej.p6)(n,"P")):!n&&s?" at\xe9 ".concat((0,ej.p6)(s,"P")):"";return l?(0,r.jsxs)("div",{className:"environment-favorite-statistics",children:[(0,r.jsx)("div",{className:"totals",children:[1,2,3,4].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}),(0,r.jsx)("div",{className:"totals",children:[6,7,8,9].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))})]}):(0,r.jsx)("div",{className:"environment-favorite-statistics",children:(null==o?void 0:o.length)?(0,r.jsx)("div",{className:"totals",children:o.map((e,t)=>(0,r.jsxs)("div",{className:"total-value card",style:{backgroundImage:"url(".concat((0,eD.e6)(e.environmentCoverImage),")")},onClick:()=>{(0,ng.FJ)((0,r.jsx)(so,{searchPeriod:d,query:new URLSearchParams({environmentId:e.environmentId})}))},children:[(0,r.jsx)("div",{className:"title",children:e.environmentName}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Curtidas"}),e.qty]})]},"".concat(e.eventId,"-").concat(e.environmentId,"-").concat(t)))}):(0,r.jsx)("div",{className:"no-data",children:(0,r.jsx)("h3",{children:"N\xe3o h\xe1 dados para exibir"})})})},sc=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},[a,n]=l.useState(),[s,i]=(0,l.useState)(!1),[d,c]=(0,l.useState)({}),u=null==t?void 0:t._id,m=l.useCallback(e=>{var t;n(e);let a=new URLSearchParams({eventId:u,startDate:e.startDate.toString(),endDate:null==e?void 0:null===(t=e.endDate)||void 0===t?void 0:t.toString()});(async()=>{try{i(!0);let e=await J.ZP.get("/user-favorite/ranking-environments?"+a);c(e.data),i(!1)}catch(e){console.log("\uD83D\uDE80 ~ useEffect ~ error:",e)}})()},[u]);return(0,r.jsxs)("div",{className:"environment-favorite",children:[(0,r.jsx)("h1",{children:"Ambientes Favoritos"}),(0,r.jsx)("h2",{children:"Filtro por per\xedodo"}),(0,r.jsx)(sr,{eventId:u,onConfirm:m}),(0,r.jsx)(sd,{eventId:u,startDate:null==a?void 0:a.startDate,endD
1ate:null==a?void 0:a.endDate,data:d,isLoading:s})]})};var su=a(6336),sm=a(64666),sh=a(37645),sv=a(6514),sx=a(31425),sp=a(38679),sg=a(99964),sj=a(96120),sf=a.n(sj);a(96167);var sb=a(40221);let sy=Math.PI/180;async function sN(e){var t,a,n;let{reqWidth:s=500,reqHeight:i=120,borderMax:r=2,deltaRGB:l=20,alphaTol:o=0,minCoverage:d=.95,sampleStep:c=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=await createImageBitmap(e),{width:m,height:h}=u;if(m!==s||h!==i)return null===(a=u.close)||void 0===a||a.call(u),{ok:!1,reason:"WRONG_SIZE",width:m,height:h};let v="OffscreenCanvas"in window?new OffscreenCanvas(m,h):Object.assign(document.createElement("canvas"),{width:m,height:h}),x=v.getContext("2d");if(!x)return null===(n=u.close)||void 0===n||n.call(u),{ok:!1,reason:"CANVAS_ERROR",width:m,height:h};x.drawImage(u,0,0),null===(t=u.close)||void 0===t||t.call(u);let{data:p}=x.getImageData(0,0,m,h),g=0,j=0,f=0,b=0;for(let[e,t]of[[0,0],[m-1,0],[0,h-1],[m-1,h-1],[Math.floor(m/2),0],[Math.floor(m/2),h-1],[0,Math.floor(h/2)],[m-1,Math.floor(h/2)]]){let a=(t*m+e)*4;g+=p[a],j+=p[a+1],f+=p[a+2],b++}let y={r:Math.round(g/b),g:Math.round(j/b),b:Math.round(f/b)},N=(e,t,a,n,s,i)=>{let r=e-n,l=t-s,o=a-i;return r*r+l*l+o*o},k=l*l,w=m,Z=h,C=-1,S=-1,_=0;for(let e=0;e<h;e+=c)for(let t=0;t<m;t+=c){let a=(e*m+t)*4,n=p[a],s=p[a+1],i=p[a+2],r=p[a+3],l=r<255-o,d=N(n,s,i,y.r,y.g,y.b)>k;(l||d)&&(_++,t<w&&(w=t),e<Z&&(Z=e),t>C&&(C=t),e>S&&(S=e))}if(0===_)return{ok:!1,reason:"NO_CONTENT",bg:y,width:m,height:h};c>1&&(w=Math.max(0,w-c+1),Z=Math.max(0,Z-c+1),C=Math.min(m-1,C+c-1),S=Math.min(h-1,S+c-1));let D=_/Math.ceil(m*h/(c*c)),E={left:w,top:Z,right:m-1-C,bottom:h-1-S},P=E.left<=r&&E.top<=r&&E.right<=r&&E.bottom<=r,I=P&&D>=d;return{ok:I,reason:I?"OK":P?"LOW_COVERAGE":"EXCESS_MARGIN",width:m,height:h,bg:y,margins:E,coverage:D,params:{reqWidth:s,reqHeight:i,borderMax:r,deltaRGB:l,alphaTol:o,minCoverage:d,sampleStep:c}}}async function sk(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=t.getContext("2d");if(!i)throw Error("No 2d context");let r=e.naturalWidth/e.width,l=e.naturalHeight/e.height,o=window.devicePixelRatio;t.width=Math.floor(a.width*r*o),t.height=Math.floor(a.height*l*o),i.scale(o,o),i.imageSmoothingQuality="high";let d=a.x*r,c=a.y*l,u=e.naturalWidth/2,m=e.naturalHeight/2;i.save(),i.translate(-d,-c),i.translate(u,m),i.rotate(s*sy),i.scale(n,n),i.translate(-u,-m),i.drawImage(e,0,0,e.naturalWidth,e.naturalHeight,0,0,e.naturalWidth,e.naturalHeight),i.restore()}function sw(e){var t;let{refId:a="imgcrop",renderBtn:n=(0,r.jsx)("label",{children:(0,r.jsx)("div",{className:"placeholder-btn",children:(0,r.jsx)(au(),{className:"placeholder",src:"/placeholder.png",layout:"fill",objectFit:"contain",unoptimized:!0,alt:""})})}),onChange:s,round:i,aspectRatio:o,changeable:d=!0,className:c="",maxWidthOrHeight:u=1920,defaultImage:m,enableSponsorValidation:h=!0,sponsorValidationMessage:x="A imagem deve ter exatamente 500x120 pixels e o conte\xfado deve ocupar toda a imagem sem bordas vazias.",requiredWidth:p=500,requiredHeight:g=120,minCoverage:j=.95,borderMax:f=2,deltaRGB:b=20,alphaTol:y=0}=e,[N,k]=(0,l.useState)(""),w=(0,l.useRef)(null),Z=(0,l.useRef)(null),C=l.useRef(),S=l.useRef(),[_,D]=(0,l.useState)(),[E,P]=(0,l.useState)(),[I,A]=(0,l.useState)(1),[T,R]=l.useState(500),[L,q]=(0,l.useState)(0),[M,O]=(0,l.useState)(i?1:void 0),F=l.useRef(M),[B,U]=l.useState(!1),[z,V]=l.useState(!1);async function G(e){if(!h){V(!0);try{let t=await sN(e,{reqWidth:p,reqHeight:g,borderMax:f,deltaRGB:b,alphaTol:y,minCoverage:j,sampleStep:2});if(!t.ok)return new Promise(e=>{let a=[];switch(t.reason){case"WRONG_SIZE":"A imagem deve ter exatamente ".concat(p,"x").concat(g," pixels. Dimens\xe3o atual: ").concat(t.width,"x").concat(t.height),a.push("❌ Dimens\xf5es incorretas: ".concat(t.width,"x").concat(t.height," (deveria ser ").concat(p,"x").concat(g,")"));break;case"NO_CONTENT":a.push("❌ Imagem sem conte\xfado vis\xedvel");break;case"EXCESS_MARGIN":var n,s,i,l,o,d,c,u;"A imagem tem margens muito grandes. Margens atuais: L".concat(null===(n=t.margins)||void 0===n?void 0:n.left,"px T").concat(null===(s=t.margins)||void 0===s?void 0:s.top,"px R").concat(null===(i=t.margins)||void 0===i?void 0:i.right,"px B").concat(null===(l=t.margins)||void 0===l?void 0:l.bottom,"px. M\xe1ximo permitido: ").concat(f,"px em c
1ada lado."),a.push("❌ Margens excessivas: L".concat(null===(o=t.margins)||void 0===o?void 0:o.left,"px T").concat(null===(d=t.margins)||void 0===d?void 0:d.top,"px R").concat(null===(c=t.margins)||void 0===c?void 0:c.right,"px B").concat(null===(u=t.margins)||void 0===u?void 0:u.bottom,"px (m\xe1ximo ").concat(f,"px)"));break;case"LOW_COVERAGE":let m=t.coverage||0;"O conte\xfado ocupa apenas ".concat((100*m).toFixed(1),"% da imagem. M\xednimo necess\xe1rio: ").concat((100*j).toFixed(0),"%."),a.push("❌ Baixa cobertura: ".concat((100*m).toFixed(1),"% (m\xednimo ").concat((100*j).toFixed(0),"%)"))}(0,em.Z)({text:(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{style:{marginBottom:"16px"},children:(0,r.jsx)("strong",{children:"⚠️ Imagem n\xe3o atende aos requisitos recomendados"})}),(0,r.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,r.jsx)("strong",{children:"Problemas encontrados:"}),(0,r.jsx)("ul",{style:{margin:"8px 0",paddingLeft:"20px"},children:a.map((e,t)=>(0,r.jsx)("li",{style:{color:"#d32f2f",marginBottom:"4px"},children:e},t))})]}),(0,r.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,r.jsx)("strong",{children:"Recomenda\xe7\xf5es ideais:"}),(0,r.jsxs)("ul",{style:{margin:"8px 0",paddingLeft:"20px"},children:[(0,r.jsxs)("li",{children:["Dimens\xf5es exatas:"," ",(0,r.jsxs)("strong",{children:[p,"x",g," pixels"]})]}),(0,r.jsxs)("li",{children:["Conte\xfado deve ocupar ",(0,r.jsxs)("strong",{children:[(100*j).toFixed(0),"% ou mais"]})," da imagem"]}),(0,r.jsxs)("li",{children:["Margens m\xe1ximas de ",(0,r.jsxs)("strong",{children:[f,"px"]})," em cada lado"]}),(0,r.jsx)("li",{children:"Evitar imagens com muito espa\xe7o vazio ao redor do conte\xfado"})]})]}),(0,r.jsx)("div",{style:{fontSize:"14px",color:"#666"},children:"Deseja continuar mesmo assim? A imagem ser\xe1 aceita sem valida\xe7\xe3o."})]}),confirmButtonText:"Sim, continuar mesmo assim",cancelButtonText:"Cancelar e corrigir",onConfirm:()=>e(!0),onCancel:()=>e(!1)})});return!0}catch(e){return console.error("Erro na valida\xe7\xe3o manual de patrocinador:",e),et.Am.error("Erro ao validar a imagem. Tente novamente."),!1}finally{V(!1)}}V(!0);try{let i=await sN(e,{reqWidth:p,reqHeight:g,borderMax:f,deltaRGB:b,alphaTol:y,minCoverage:j,sampleStep:2});if(!i.ok){let e=x;switch(i.reason){case"WRONG_SIZE":e="A imagem deve ter exatamente ".concat(p,"x").concat(g," pixels. Dimens\xe3o atual: ").concat(i.width,"x").concat(i.height);break;case"NO_CONTENT":e="A imagem n\xe3o cont\xe9m conte\xfado vis\xedvel.";break;case"EXCESS_MARGIN":var t,a,n,s;e="A imagem tem margens muito grandes. Margens atuais: L".concat(null===(t=i.margins)||void 0===t?void 0:t.left,"px T").concat(null===(a=i.margins)||void 0===a?void 0:a.top,"px R").concat(null===(n=i.margins)||void 0===n?void 0:n.right,"px B").concat(null===(s=i.margins)||void 0===s?void 0:s.bottom,"px. M\xe1ximo permitido: ").concat(f,"px em cada lado.");break;case"LOW_COVERAGE":let r=i.coverage||0;e="O conte\xfado ocupa apenas ".concat((100*r).toFixed(1),"% da imagem. M\xednimo necess\xe1rio: ").concat((100*j).toFixed(0),"%.")}return et.Am.error(e),!1}return!0}catch(e){return console.error("Erro na valida\xe7\xe3o de patrocinador:",e),et.Am.error("Erro ao validar a imagem. Tente novamente."),!1}finally{V(!1)}}async function W(e){if(e.target.files&&e.target.files.length>0){let t=e.target.files[0],a=await G(t);if(!a){C.current&&(C.current.value="");return}D(void 0);let n=new FileReader;n.addEventListener("load",()=>{var e;return k((null===(e=n.result)||void 0===e?void 0:e.toString())||"")}),n.readAsDataURL(t),S.current=t}}function $(){C.current&&(C.current.value=""),k(""),O(void 0)}return l.useEffect(()=>{O(i?1:void 0)},[i]),l.useEffect(()=>{"string"==typeof m&&m.includes("http")?ar().get(m,{responseType:"blob",headers:{"Access-Control-Allow-Origin":"*"}}).then(e=>{setTimeout(()=>{k(URL.createObjectURL(e.data))},500)}):m&&k(m)},[m]),t=async()=>{(null==E?void 0:E.width)&&(null==E?void 0:E.height)&&Z.current&&w.current&&sk(Z.current,w.current,E,I,L)},(0,l.useEffect)(()=>{let e=setTimeout(()=>{t()},100);return()=>{clearTimeout(e)}},[E,I,L]),(0,r.jsxs)("div",{className:"image-cropper "+(c||a),children:[(0,r.jsx)("input",{type:"file",accept:"image/*",onChange:W,className:"d-none",ref:C,id:a,name:"file",disabled:!d||z}),(0,r.jsx)("input",{id:"scale-input",type:"number",step:"0.1",value:I,disabled:!N,onChange:e=>A(Number(e.target.value))}),(0,r.jsxs)("div",{className:"processing",style:{position:"relative"},children:[l.cloneElement(n||(0,r.jsx)("label",{children:"Open File"}),{htmlFor:a}),B&&(0,r.jsx)(ee.aN,{message:"Processando imagem"}),z&&(0,r.jsx)("div",{className:"validation-message",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 16px",borderRadius:"4px",fontSize:"14px",zIndex:1e3,pointerEvents:"none"},children:"Validando imagem de patrocinador..."})]}),(0,r.jsx)(sg.Z,{open:Boolean(N),disablePortal:!0,children:(0,r.jsxs)("div",{className:"modal",children:[(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"title",children:"Edi\xe7\xe3o imagem"}),(0,r.jsx)(sf(),{crop:_,onDragStart:()=>O(o),onChange:(e,t)=>
1{let{height:a,width:n}=e;F.current=n/a,D(t)},onComplete:e=>P(e),aspect:M,circularCrop:i,ruleOfThirds:!0,children:(0,r.jsx)("img",{ref:Z,alt:"Crop me",src:N,style:{transform:"scale(".concat(I,") rotate(").concat(L,"deg)")},onLoad:function(e){let{width:t,height:a}=e.currentTarget;M?D((0,sj.centerCrop)((0,sj.makeAspectCrop)({unit:"%",width:90},M,t,a),t,a)):F.current=t/a},draggable:!1})}),(0,r.jsxs)("div",{className:"modal-actions",children:[(0,r.jsxs)("div",{className:"sliders",children:[(0,r.jsxs)("div",{className:"slider",children:[(0,r.jsx)("span",{children:"Zoom:"}),(0,r.jsx)(sp.Z,{}),(0,r.jsx)(su.ZP,{value:I,min:1,max:5,step:.1,onChange:(e,t)=>A(Number(t))}),(0,r.jsx)(eU.Z,{})]}),(0,r.jsxs)("div",{className:"slider slider2",children:[(0,r.jsx)("span",{className:"item",children:"Tamanho imagem (kb):"}),(0,r.jsx)(su.ZP,{value:T,min:300,max:800,step:100,onChange:(e,t)=>R(Number(t)),marks:[{value:300,label:"300"},{value:400,label:"400"},{value:500,label:"500"},{value:600,label:"600"},{value:700,label:"700"},{value:800,label:"800"}]})]})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:$,size:"large",children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:function(){function e(e){(0,sb.Z)(e,{maxSizeMB:T/1e3,maxWidthOrHeight:u}).then(e=>{s(e,F.current),U(!1)}).catch(function(e){U(!1),(0,Q.C)(e.message)})}if(U(!0),_){var t;null===(t=w.current)||void 0===t||t.toBlob(e)}else e(S.current);$()},size:"large",className:"submit",children:"Salvar imagem"})]})]}),(0,r.jsx)("canvas",{ref:w,style:{display:"none",objectFit:"contain",width:null==E?void 0:E.width,height:null==E?void 0:E.height}})]})})]})}let sZ=e=>{let[t,a]=l.useState([]),[n,s]=l.useState({}),[i,r]=l.useState(!1);return l.useEffect(()=>{(async function(){await aN({url:"/franchise/franchises-countries-list",onProcessing:r,onSuccess:e=>a(e||[]),onError:e=>{et.Am.error(e.message)}})})()},[]),l.useEffect(()=>{if(e&&(null==t?void 0:t.length)>0){let a=t.find(t=>t.id===e);s(a||{countryName:""})}},[e,t]),{franchiseCountries:t,fetchingFranchiseCountries:i,franchise:n,setFranchise:s}},sC=e=>{let{eventId:t,enabled:a=!0}=e,{data:n,isLoading:s,error:i,refresh:r}=ad((t?"/event/list-admin?eventId=".concat(t):null)||""),o=l.useMemo(()=>(null==n?void 0:n.isEnableSponsorValidation)===!0,[null==n?void 0:n.isEnableSponsorValidation]);return{event:n,isLoading:s,error:i,refresh:r,isSponsorValidationEnabled:o}},sS=e=>{let{sponsor:t,index:a,onChange:n,onRemove:s}=e,{toggleLoader:i}=(0,ee.U2)(),{t:o}=(0,p.$)("admin"),[d,c]=l.useState(t||{}),{franchiseCountries:u,fetchingFranchiseCountries:m,franchise:h,setFranchise:x}=sZ(null==t?void 0:t.franchiseId),[g,j]=l.useState(!1),{event:f,isSponsorValidationEnabled:b}=sC({eventId:null==t?void 0:t.eventId,enabled:!!(null==t?void 0:t.eventId)}),{id:y,eventId:N,title:k,link:w,image:Z,visibleWeb:C,visibleHomeSiteMostras:S,backgroundSize:_}=d;function D(e){c(t=>({...t,...e}))}async function E(){try{if(!Z)throw Error("Formul\xe1rio incompleto!");i(!0,o("processing"));let e=await J.ZP.post("/ticket-config-sponsor/save",(0,eD.GZ)({eventId:N||"all",franchiseId:null==h?void 0:h.id,image:Z,backgroundSize:_,id:y,order:a,title:k,link:w,visibleWeb:C,visibleHomeSiteMostras:S},!1),{headers:{"Content-Type":"multipart/form-data"}});if(i(),(0,K.Mr)(),e.data.error)throw Error(o("error_on_processing")+" \n\n"+e.data.error.message);n(e.data.sponsor),et.Am.success("".concat(o("success_on_processing")," ").concat(k))}catch(e){i(),et.Am.error(e.message)}}async function P(){(0,em.Z)({text:"Deseja realmente remover este patrocinador?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{try{i(!0,o("processing"));let e=await J.ZP.delete("/ticket-config-sponsor/".concat(y));if(e.data.error)throw Error(e.data.error.message);i(),et.Am.success("".concat(o("success_on_processing")," ").concat(k)),s&&s(y),(0,K.Mr)()}catch(e){et.Am.error(e.message)}},onError:()=>{i()}})}return(0,r.jsxs)("div",{className:"sponsor-form",children:[(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:o(y?"sponsor.edit":"sponsor.new"),onGoBack:()=>(0,K.Mr)()}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"sponsor-image-requirements",style:{background:b?"#e3f2fd":"#fff3e0",border:"1px solid ".concat(b?"#2196f3":"#ff9800"),borderRadius:"8px",padding:"12px 16px",marginBottom:"20px",color:b?"#1565c0":"#e65100",fontSize:"14px"},children:(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:"12px"},children:[(0,r.jsxs)("div",{style:{flex:"1",minWidth:"200px"},children:[(0,r.jsx)("strong",{children:b?"\uD83D\uDCCF Requisitos da imagem de patrocinador:":"⚠️ Valida\xe7\xe3o de imagem de patrocinador desabilitada"}),(0,r.jsxs)("ul",{style:{margin:"8px 0 0 0",paddingLeft:"20px"},children:[(0,r.jsxs)("li",{children:["Dimens\xf5es ",b?"exatas":"recomendadas",": ",(0,r.jsx)("strong",{children:"500x117 pixels"})]}),(0,r.jsxs)("li",{children:["O conte\xfado deve ocupar ",(0,r.jsx)("strong",{children:"60% ou mais"})," da imagem"]}),(0,r.jsxs)("li",{children:["Margens ",b?"m\xe1ximas":"recomendadas"," de ",(0,r.jsx)("strong",{children:"2px"})," em cada lado"]}),(0,r.jsx)("li",{children:"Evitar imagens com muito espa\xe7o vazio ao redor do conte\xfado"}),!b&&(0,r.jsx)("li",{style:{color:"#ff9800",fontWeight:"bold"},children:"⚠️ A valida\xe7\xe3o autom\xe1tica est\xe1 desabilitada para este evento"})]})]}),(0,r.jsx)(v.Z,{variant:"outlined",size:"small",onClick:()=>j(!0),style:{fontSize:"12px",minWidth:"140px",borderColor:b?"#2196f3":"#ff9800",color:b?"#2196f3":"#ff9800",flexShrink:0},children:"\uD83D\uDC41️ Ver exemplo de imagem"})]})}),(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(sw,{refId:"sponsor-image",maxWidthOrHeight:500,aspectRatio:500/117,enableSponsorValidation:b,requiredWidth:500,requiredHeight:117,minCoverage:.6,borderMax:2,deltaRGB:20,alphaTol:0,sponsorValidationMessage:"A imagem de patrocinador deve ter exatamente 500x117 pixels e o conte\xfado deve ocupar toda a imagem sem bordas vazias.",onChange:e=>{D({image:e})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)(eP.Z,{src:Z,layout:"fill"})})})}),(0,r.jsxs)("div",{className:"sponsor-form-switch-container",children:[(0,r.jsx)(ea.Z,{label:o("event.visible_web"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!C,onChange:e=>D({visibleWeb:e.target.checked})})}),(0,r.jsx)(ea.Z,{label:o("event.visible_home_site_mostras"),className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!S,onChange:e=>D({visibleHomeSiteMostras:e.target.checked})})})]}),(0,r.jsx)("div",{className:"franchise-select",children:(0,r.jsx)(e_.Z,{id:"franchise-select",options:u,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.countryName,disablePortal:!0,loading:m,loadingText:"Carregando...",value:(null==h?void 0:h.countryName)?h:{countryName:""},onChange:(e,t)=>
1{x(t||{}),D({franchiseId:null==t?void 0:t.id})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"".concat(o("franchise.select")," (Pa\xeds)"),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-franchise",children:(0,r.jsx)(eP.Z,{src:t.countryFlag,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.countryName})]})})}),(0,r.jsx)(es.Z,{className:"textfield",label:"T\xedtulo",value:k||"",onChange:e=>{e.stopPropagation(),D({title:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"Link",value:w||"",onChange:e=>{e.stopPropagation(),D({link:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"Tamanho do Zoom da imagem",value:_?"".concat(_,"%"):"100%",onChange:e=>{e.stopPropagation(),D({backgroundSize:e.target.value})},disabled:!0}),!!Z&&(0,r.jsx)("a",{className:"logo-sponsor-preview",href:w,style:{backgroundImage:"url(".concat((0,eD.e6)(Z),")"),backgroundSize:_?"".concat(_,"%"):"contain"}}),(0,r.jsx)(su.ZP,{value:_?Number(_):100,min:1,max:500,step:1,"aria-labelledby":"Zoom",onChange:(e,t)=>
1{e.stopPropagation(),D({backgroundSize:"".concat(t)})}}),(0,r.jsxs)("div",{className:"actions",children:[!!y&&(0,r.jsx)(X.Z,{size:"large",className:"remove-btn",onClick:()=>P(),children:(0,r.jsx)(er.Z,{})}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"".concat(o("close"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:E,children:"".concat(o("save"))})]})]})]})}),(0,r.jsxs)(sm.Z,{open:g,onClose:()=>j(!1),maxWidth:"md",fullWidth:!0,children:[(0,r.jsx)(sh.Z,{children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("span",{children:"\uD83D\uDCCF"}),"Exemplo de Imagem de Patrocinador"]})}),(0,r.jsx)(sv.Z,{children:(0,r.jsxs)("div",{style:{textAlign:"center",padding:"20px 0"},children:[(0,r.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px 0",fontSize:"14px",color:"#666"},children:"Esta \xe9 uma imagem de exemplo que atende aos requisitos:"}),(0,r.jsxs)("ul",{style:{textAlign:"left",display:"inline-block",margin:"0",fontSize:"14px",color:"#666"},children:[(0,r.jsx)("li",{children:"Dimens\xf5es: 500x117 pixels"}),(0,r.jsx)("li",{children:"Conte\xfado ocupa 60% ou mais da imagem"}),(0,r.jsx)("li",{children:"Sem bordas vazias excessivas"})]})]}),(0,r.jsx)("div",{style:{border:"2px solid #e0e0e0",borderRadius:"8px",padding:"16px",backgroundColor:"#f9f9f9",display:"inline-block"},children:(0,r.jsx)(au(),{src:"/sponsor_good_example.webp",alt:"Exemplo de imagem de patrocinador",width:500,height:117,style:{maxWidth:"100%",height:"auto",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}})}),(0,r.jsx)("div",{style:{marginTop:"16px",fontSize:"12px",color:"#999"},children:(0,r.jsxs)("p",{style:{margin:"0"},children:[(0,r.jsx)("strong",{children:"Dica:"})," Sua imagem deve seguir este padr\xe3o de preenchimento e propor\xe7\xe3o."]})})]})}),(0,r.jsx)(sx.Z,{children:(0,r.jsx)(v.Z,{onClick:()=>j(!1),children:"Fechar"})})]})]})},s_=e=>{let{eventId:t="all"}=e,{t:a}=(0,p.$)("admin"),{data:n,isLoading:s}=(0,eh.Z)("/ticket-config-sponsor?eventId="+t),[i,o]=l.useState((null==n?void 0:n.sponsors)||[]),d=l.useRef();function c(e){let t=e.target.closest(".sponsor");d.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function u(e){e.target.style.opacity=1}function m(e){e.preventDefault();let t=e.target.closest(".sponsor");d.current!==(null==t?void 0:t.dataset.index)?t.style.transform="scale(0.9)":t.style.transform="initial"}function h(e){let t=e.target.closest(".sponsor");t.style.transform="initial"}async function x(e){e.preventDefault();let n=e.target.closest(".sponsor");n.style.transform="initial";let s=null==n?void 0:n.dataset.index;if(d.current&&d.current!==s){let e=[...i],[n]=e.splice(d.current,1);e.splice(s,0,n),o(e);try{let n=await J.ZP.put("/ticket-config-sponsor/reorder",{order:e.map((e,a)=>({order:a,eventId:t,id:e.id}))});if(n.data.error)throw Error(a("error_on_processing")+" \n\n"+n.data.error.message)}catch(e){et.Am.error(e.message)}}}return l.useEffect(()=>{(null==n?void 0:n.sponsors)&&o(n.sponsors)},[n]),(0,r.jsxs)("div",{className:"sponsors",children:[(0,r.jsx)("h3",{children:"all"===t?"Patrocinadores":"Patrocinadores do evento"}),(0,r.jsxs)("div",{className:"list",children:[null==i?void 0:i.map((e,t)=>(0,r.jsxs)("div",{className:"sponsor placeholder",draggable:!0,"data-index":t,"data-id":e.id,onDragStart:c,onDragEnd:u,onDragOver:m,onDragLeave:h,onDrop:x,onClick:()=>(0,K.K4)((0,r.jsx)(sS,{index:t,sponsor:e,onChange:e=>{let a=[...i];a[t]=e,o(a)},onRemove:e=>{let t=[...i].filter(t=>t.id!==e);o(t)}})),children:[(0,r.jsx)("div",{className:"title",children:e.title}),(0,r.jsx)("div",{className:"sponsor-image",children:(0,r.jsx)(eP.Z,{src:e.image,layout:"fill"})}),(0,r.jsx)("div",{className:"link",children:e.link})]},t)),(0,r.jsx)(v.Z,{variant:"outlined",className:"sponsor add-sponsor",onClick:()=>(0,K.K4)((0,r.jsx)(sS,{index:i.length,sponsor:{eventId:t},onChange:e=>{o(t=>[...t,e])}})),children:"".concat(a("sponsor.create"))})]})]})};var sD=a(11163);let sE=e=>{let{onSupplierCreated:t}=e,{toggleLoader:a}=(0,ee.U2)(),{t:n}=(0,p.$)("admin"),[s,i]=l.useState({}),[o,d]=l.useState(!1),[c,u]=l.useState(!0),{name:m,email:h}=s;function x(e){i(t=>({...t,...e}))}async function g(){try{if(!m||!h)throw Error("Formul\xe1rio incompleto!");a(!0,n("supplier.saving"));let e=await J.ZP.post("/user/create-supplier",(0,eD.GZ)({...s,sendInvitationEmail
1:c}),{headers:{"Content-Type":"multipart/form-data"}});if(a(),e.data.error)throw Error(n("supplier.saving_error")+" \n\n"+e.data.error.message);t(e.data.user),d(!1),et.Am.success(n("supplier.added"))}catch(e){a(),et.Am.error(e.message)}}return(0,r.jsxs)("div",{className:"supplier-form",children:[(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>d(!0),style:{width:240},children:n("supplier.create")}),(0,r.jsx)(K.ZP,{showAt:o,onClose:()=>d(!1),children:(0,r.jsx)("div",{className:"forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:n("supplier.new"),onGoBack:()=>d(!1)}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"avatar",children:(0,r.jsx)(eE.Z,{refId:"supplier-avatar",round:!0,maxWidthOrHeight:500,onChange:e=>{x({avatar:e})},renderBtn:(0,r.jsx)("label",{children:(0,r.jsx)(eP.Z,{src:s.avatar,layout:"fill"})})})}),(0,r.jsx)(es.Z,{className:"textfield",label:"*"+n("supplier.name"),value:m||"",onChange:e=>{e.stopPropagation(),x({name:e.target.value})}}),(0,r.jsx)(es.Z,{className:"textfield",label:"*Email",value:h||"",helperText:n("supplier.login_email"),type:"email",onChange:e=>{e.stopPropagation(),x({email:e.target.value})}}),(0,r.jsx)(ea.Z,{label:n("supplier.send_invitation_email"),control:(0,r.jsx)(en.Z,{checked:c,onChange:e=>u(e.target.checked)})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>d(!1),children:n("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:g,children:n("supplier.create")})]})]})]})})})]})},sP=()=>{let{t:e}=(0,p.$)("admin"),t=(0,sD.useRouter)(),{storedState:a,setStoredState:n}=(0,o.oR)(),[s,i]=l.useState(0),d=(0,ev.Nr)(null==a?void 0:a.supplierSearch,300),{data:c,error:u}=(0,tj.ZP)("/user/list?limit=500&name=".concat(d,"&refetch=").concat(s,"&role=supplier")),{users:m}=(null==c?void 0:c.data)||{};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(eu,{className:"search",placeholder:e("supplier.search"),value:(null==a?void 0:a.supplierSearch)||"",onChange:e=>n({supplierSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(sE,{onSupplierCreated:()=>i(Date.now())})]}),(0,r.jsx)("div",{className:"flex1",children:u||c?(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:115,rowCount:(null==m?void 0:m.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=m[a];return(0,r.jsx)("div",{style:s,className:"list-item-card",onClick:()=>t.push("admin/supplier/".concat(i.id)),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"cover",children:(0,r.jsx)(eP.Z,{src:i.avatar,layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"title",children:i.name}),(0,r.jsxs)("div",{className:"locale",children:[(0,r.jsx)(n4.Z,{className:"icon-text"}),(0,r.jsx)("p",{children:i.email})]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}}):(0,r.jsx)("div",{className:"loader",children:(0,r.jsx)(ee.aN,{})})})]})},sI=(e,t)=>(l.useEffect(()=>(ab.v.subscribe(e,t),()=>ab.v.unsubscribe(e)),[]),null),sA=()=>{var e;let{t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),n=(null==a?void 0:null===(e=a.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{givexgiftcardLimit:s=20,givexgiftcardPage:i=0,givexgiftcardSearch:r=""}=a,d=(0,ev.Nr)(r,300),{data:c,isLoading:u,refresh:m}=(0,eh.Z)("/givex?limit=".concat(s,"&page=").concat(i,"&search=").concat(d,"&eventId=").concat(n)),h=(null==c?void 0:c.items)||[],v=(null==c?void 0:c.numberOfItems)||0,[x,g]=l.useState(!1),[j,f]=l.useState({});return sI("refresh_givexgiftcard_table",m),{eventId:n,givexGiftCards:h,givexgiftcard:j,addGivexGiftCard:function(){g(!0)},editGivexGiftCard:function(e){f(e),g(!0)},showGivexGiftCardForm:x,closeGivexGiftCardForm:function(){g(!1)},refresh:m,isLoading:u,numberOfItems:v,givexgiftcardLimit:s,givexgiftcardPage:i,givexgiftcardSearch:r}};var sT=a(56495);let sR=e=>{let{givexgiftcard:t={},onSave:a,onClose:n}=e,{toggleLoader:s}=(0,ee.U2)(),{t:i}=(0,p.$)("admin"),[o,d]=l.useState(t),[c,u]=l.useState({}
1),{orderSender:m,confirmationEmail:h,orderTotal:x,itemQuantity:g,customerName:j}=o;function f(e){d(t=>({...t,...e}))}async function b(){try{let e={};if(u(e),m||(e.orderSender=!0),j||(e.customerName=!0),x||(e.orderTotal=!0),g||(e.itemQuantity=!0),Object.keys(e).length)return u(e),et.Am.error(i("incomplete_form"));s(!0,i("processing"));let t={...o,orderSender:m,confirmationEmail:m,orderTotal:x,itemQuantity:g,customerName:j},n=await J.ZP.post("/givex/create-card",t);if(s(),n.data.error)throw Error(i("error_on_processing")+" \n\n"+n.data.error.message);a(),et.Am.success(i("success_on_processing"))}catch(e){s(),et.Am.error(e.message)}}return(0,r.jsx)("div",{className:"add-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:(null==t?void 0:t.id)?i("givexgiftcard.edit"):i("givexgiftcard.newSolicitation"),onGoBack:e.onClose}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{label:"* "+i("givexgiftcard.orderSendToEmail"),value:m||"",className:"textfield",onChange:e=>{var t;e.stopPropagation(),f({orderSender:null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value})},error:!!c.orderSender,helperText:!!c.orderSender&&i("required_field")}),(0,r.jsx)(es.Z,{label:"* "+i("givexgiftcard.customerName"),value:j||"",onChange:e=>{e.stopPropagation(),f({customerName:e.target.value})},error:!!c.customerName,helperText:!!c.value&&i("required_field")}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(sT.Z,{label:"* "+i("givexgiftcard.itemValue")+" (Valor inicial de ca
1da cart\xe3o)",sx:{width:"100%"},defaultValue:isNaN(x)?"":x,onValueChange:e=>{f({orderTotal:e})},error:!!c.orderTotal,helperText:!!c.orderTotal&&i("required_field")})}),(0,r.jsx)(es.Z,{label:"* "+i("givexgiftcard.itemQuantity"),value:g||"",type:"number",onChange:e=>{e.stopPropagation(),f({itemQuantity:e.target.value})},error:!!c.itemQuantity,helperText:!!c.value&&i("required_field")}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:n,children:i("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,children:i("givexgiftcard.create")})]})]})]})})};var sL=a(504);let sq=()=>{let{t:e}=(0,p.$)("admin"),{setStoredState:t}=(0,o.oR)(),{givexGiftCards:a,givexgiftcard:n,addGivexGiftCard:s,editGivexGiftCard:i,showGivexGiftCardForm:l,closeGivexGiftCardForm:d,refresh:c,isLoading:u,numberOfItems:m,givexgiftcardLimit:h,givexgiftcardPage:v,givexgiftcardSearch:x}=sA();return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"givexgiftcard",children:[(0,r.jsx)("div",{className:"header",children:(0,r.jsx)("h3",{children:"Givex - Gift Cards"})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(eu,{className:"search",placeholder:e("givexgiftcard.search"),value:x||"",onChange:e=>t({givexgiftcardSearch:(null==e?void 0:e.target.value)||""})})}),u?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!m&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:e("givexgiftcard.status")}),(0,r.jsx)("th",{children:e("givexgiftcard.orderAddressID")}),(0,r.jsx)("th",{children:e("givexgiftcard.checkoutOrderID")}),(0,r.jsx)("th",{children:e("givexgiftcard.giftCardNumber")}),(0,r.jsx)("th",{children:e("givexgiftcard.pin")}),(0,r.jsx)("th",{children:e("givexgiftcard.orderSender")}),(0,r.jsx)("th",{children:e("givexgiftcard.customerName")}),(0,r.jsx)("th",{children:e("givexgiftcard.itemQuantity")}),(0,r.jsx)("th",{children:e("givexgiftcard.itemValue")}),(0,r.jsx)("th",{children:e("ticket_distribution.payment_type")}),(0,r.jsx)("th",{children:e("ticket_distribution.payment_status")})]})}),(0,r.jsx)("tbody",{children:null==a?void 0:a.map((t,a)=>{var n,s,i;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:"WAITING_PAYMENT"===t.paymentStatus?"".concat(e("ticket_distribution.".concat(null==t?void 0:t.paymentStatus))):"".concat(e("givexgiftcard.".concat(null==t?void 0:t.status)))}),(0,r.jsx)("td",{children:null==t?void 0:null===(n=t.giftCardNumbers)||void 0===n?void 0:n.orderAddressID}),(0,r.jsx)("td",{children:null==t?void 0:t.checkoutOrderID}),(0,r.jsx)("td",{children:null==t?void 0:null===(s=t.giftCardNumbers)||void 0===s?void 0:s.giftCardNumber}),(0,r.jsx)("td",{children:null==t?void 0:null===(i=t.giftCardNumbers)||void 0===i?void 0:i.pin}),(0,r.jsxs)("td",{children:[null==t?void 0:t.orderSender," "]}),(0,r.jsx)("td",{children:null==t?void 0:t.customerName}),(0,r.jsx)("td",{children:null==t?void 0:t.itemQuantity}),(0,r.jsx)("td",{children:(0,sL.n)(null==t?void 0:t.orderTotal)}),(0,r.jsx)("td",{children:"".concat(e("ticket_distribution.".concat(null==t?void 0:t.paymentMethod)))}),(0,r.jsx)("td",{children:"".concat(e("ticket_distribution.".concat(null==t?void 0:t.paymentStatus)))})]},a)})})]})}),(0,r.jsx)(eZ,{numberOfItems:m,rowsPerPage:h,page:v,onPageChange:e=>t({givexgiftcardPage:e}),onRowsPerPageChange:e=>t({givexgiftcardPage:0,givexgiftcardLimit:e})})]}),(0,r.jsx)(K.ZP,{showAt:!!l,onClose:d,children:(0,r.jsx)(sR,{givexgiftcard:n,onSave:()=>{c(),d()},onClose:d})})]})})};var sM=l.memo(sq),sO=a(25675),sF=a.n(sO);let sB=e=>{let{eventId:t}=e,{data:a,isLoading:n}=(0,eh.Z)("/ticket-config-image?eventId="+t),[s,i]=l.useState({});async function o(e){try{if(!e)return;i({...s,...e});let a=await J.ZP.post("/ticket-config-image/save",(0,eD.GZ)({eventId:t,...e}),{headers:{"Content-Type":"multipart/form-data"}});if(a.data.error)throw Error(a.data.error.message)}catch(e){et.Am.error(e.message)}}async function d(e){try{let a={...s};delete a[e],i(a);let n=await J.ZP.delete("/ticket-config-image/".concat(t,"/").concat(e));if(n.data.error)throw Error(n.data.error.message)}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{i(a||{})},[a]),(0,r.jsxs)("div",{className:"ticket-banner",children:[(0,r.jsx)("h3",{children:"Banner p\xe1gina de ingressos"}),(0,r.jsx)(eE.Z,{aspectRatio:6.4,refId:"ticket-banner",onChange:e=>o({pageHeaderImage:e}),renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(sF(),{className:"placeholder",src:(0,eD.e6)(null==s?void 0:s.pageHeaderImage),unoptimized:!!(null==s?void 0:s.pageHeaderImage),fill:!0,alt:"",placeholder:"blur",blurDataURL:eD.LG}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>d("pageHeaderImage"),children:(0,r.jsx)(er.Z,{})})})]})}),(0,r.jsx)("div",{className:"ticket-banner-description",children:(0,r.jsx)("p",{children:"A imagem do banner ser\xe1 exibida na p\xe1gina de ingressos do evento. Tamanho recomendado: 1920x450px"})})]})},sU=()=>{var e;let{storedState:t}=(0,o.oR)(),a=null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id,[n,s]=l.useState(),{toggleLoader:i}=(0,ee.U2)(),{data:r,isLoading:d,refresh:c}=(0,eh.Z)("/ticket-config-prices-rule/list?admin=true&eventId="+a);function u(){s(null)}let m=l.useCallback(e=>{(0,em.Z)({text:"Deseja realmente remover esta regra?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{i(!0,"Removendo regra");let t=await J.ZP.delete("/ticket-config-prices-rule/".concat(e));if(i(),t.data.error)return et.Am.error(t.data.error.message);null==r||r.filter(t=>t.id!==e),c(),et.Am.success("Regra removida com sucesso!")},onError:()=>{i()}})},[null==r?void 0:r.length]);return{priceRules:r,addPriceRule:function(){s({eventId:a})},editPriceRule:function(e){s(e)},selectedPriceRule:n,closePriceRuleForm:u,refreshPriceRulesTable:()=>{c(),u()},removePriceRule:m}};
1var sz=a(53457);let sV=e=>{let[t,a]=l.useState(e.priceRule),[n,s]=l.useState({}),{id:i,type:o,description:d,discount:c,availability:u,enabledAllowedPaymentMethods:m,updatedAt:h,lastUpdatedBy:x}=t||{},{toggleLoader:p}=(0,ee.U2)();function g(e){a(t=>({...t,...e}))}function j(e,t,n){a(a=>{let s;let i=a.allowedPaymentMethods||{website:[],app:[],cardMachine:[]},r=i[e]||[];return s=n?[...r,t]:r.filter(e=>e!==t),{...a,allowedPaymentMethods:{...i,[e]:s}}})}function f(e,a){var n;let s=(null===(n=t.allowedPaymentMethods)||void 0===n?void 0:n[e])||[];return s.includes(a)}async function b(){try{let a={};if(s(a),o||(a.type=!0),d||(a.description=!0),(0,eD.Ft)(c)&&(a.discount=!0),u||(a.availability=!0),Object.keys(a).length)return s(a),et.Am.error("Formul\xe1rio incompleto!");t.type=t.type.trim(),t.description=t.description.trim(),p(!0,"Salvando regra de pre\xe7o");let n=await J.ZP.post("/ticket-config-prices-rule",t);if(n.data.error)throw Error(n.data.error.message);e.onChange(),p(),et.Am.success("Regra salva com sucesso!")}catch(e){console.log(JSON.stringify(e,null,2)),p(),et.Am.error(e.message)}}return(0,r.jsx)("div",{className:"modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:i?"Adicionar regras de pre\xe7os":"Editar regras de pre\xe7os",onGoBack:e.onClose,data:{id:i,updatedAt:h,lastUpdatedBy:x}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* Tipo",value:o||"",onChange:e=>{e.stopPropagation(),g({type:e.target.value})},error:null==n?void 0:n.type}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Descri\xe7\xe3o",multiline:!0,rows:4,value:d||"",onChange:e=>{e.stopPropagation(),g({description:e.target.value})},error:null==n?void 0:n.description}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Desconto (%)",type:"number",value:(0,eD.Ft)(c)?"":c,onChange:e=>{e.stopPropagation(),g({discount:e.target.value})},error:null==n?void 0:n.discount}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Disponibilidade (%)",type:"number",value:u||"",onChange:e=>{e.stopPropagation(),g({availability:e.target.value})},error:null==n?void 0:n.availability}),(0,r.jsxs)(nT.Z,{sx:{mt:3,mb:2,display:"flex",alignItems:"center",gap:2},children:[(0,r.jsx)(tr.Z,{checked:!!m,onChange:e=>g({enabledAllowedPaymentMethods:e.target.checked})}),(0,r.jsx)(a1.Z,{variant:"h6",sx:{fontWeight:"bold"},children:"Habilitar M\xe9todos de Pagamento Permitidos"})]}),m&&(0,r.jsxs)(nT.Z,{sx:{mt:2,mb:2},children:[(0,r.jsx)(a1.Z,{variant:"h6",sx:{mb:2,fontWeight:"bold"},children:"M\xe9todos de Pagamento Permitidos"}),(0,r.jsxs)(nT.Z,{sx:{mb:3,p:2,border:"1px solid #e0e0e0",borderRadius:1},children:[(0,r.jsx)(a1.Z,{variant:"subtitle1",sx:{mb:1,fontWeight:"bold"},children:"Website"}),(0,r.jsxs)(sz.Z,{children:[(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("website","pix"),onChange:e=>j("website","pix",e.target.checked)}),label:"PIX"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("website","credit_card"),onChange:e=>j("website","credit_card",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("website","credit_card_brb"),onChange:e=>j("website","credit_card_brb",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB (25% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("website","credit_card_dux"),onChange:e=>j("website","credit_card_dux",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB DUX (50% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("website","credit_card_infinity"),onChange:e=>j("website","credit_card_infinity",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB Infinity (50% OFF)"})]})]}),(0,r.jsxs)(nT.Z,{sx:{mb:3,p:2,border:"1px solid #e0e0e0",borderRadius:1},children:[(0,r.jsx)(a1.Z,{variant:"subtitle1",sx:{mb:1,fontWeight:"bold"},children:"App"}),(0,r.jsxs)(sz.Z,{children:[(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("app","pix"),onChange:e=>j("app","pix",e.target.checked)}),label:"PIX"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("app","credit_card"),onChange:e=>j("app","credit_card",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("app","credit_card_brb"),onChange:e=>j("app","credit_card_brb",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB (25% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("app","credit_card_dux"),onChange:e=>j("app","credit_card_dux",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB DUX (50% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("app","credit_card_infinity"),onChange:e=>j("app","credit_card_infinity",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB Infinity (50% OFF)"})]})]}),(0,r.jsxs)(nT.Z,{sx:{mb:3,p:2,border:"1px solid #e0e0e0",borderRadius:1},children:[(0,r.jsx)(a1.Z,{variant:"subtitle1",sx:{mb:1,fontWeight:"bold"},children:"M\xe1quina de Cart\xe3o"}),(0,r.jsxs)(sz.Z,{children:[(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","pix"),onChange:e=>j("cardMachine","pix",e.target.checked)}),label:"PIX"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","credit_card"),onChange:e=>j("cardMachine","credit_card",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","credit_card_brb"),onChange:e=>j("cardMachine","credit_card_brb",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB CASACOR (25% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","credit_card_dux"),onChange:e=>j("cardMachine","credit_card_dux",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB DUX (50% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","credit_card_infinity"),onChange:e=>j("cardMachine","credit_card_infinity",e.target.checked)}),label:"Cart\xe3o de Cr\xe9dito BRB Infinity (50% OFF)"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","debit_card"),onChange:e=>j("cardMachine","debit_card",e.target.checked)}),label:"Cart\xe3o de D\xe9bito"}),(0,r.jsx)(ea.Z,{control:(0,r.jsx)(en.Z,{checked:f("cardMachine","cash"),onChange:e=>j("cardMachine","cash",e.target.checked)}),label:"Dinheiro"})]})]})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:e.onClose,className:"close-btn",children:"Fechar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:b,className:"save-btn",children:i?"Atualizar regra":"Salvar regra"})]})]})]})})},sG=e=>{let{eventId:t}=e,{t:a}=(0,p.$)("admin"),{storedState:n}=(0,o.oR)(),s=null==n?void 0:n.currentSelectedEvent,{priceRules:i,addPriceRule:l,editPriceRule:d,selectedPriceRule:c,closePriceRuleForm:u,refreshPriceRulesTable:m,removePriceRule:h}=sU();return(0,r.jsxs)("div",{className:"price-rules",children:[(0,r.jsx)("h3",{children:"Regras de pre\xe7os"}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Tipo"}),(0,r.jsx)("th",{children:"Regra"}),(0,r.jsx)("th",{children:"Desconto"}),(0,r.jsx)("th",{children:"Disponibilidade (%)"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),(0,r.jsx)("tbody",{children:Array.isArray(i)&&(null==i?void 0:i.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.type}),(0,r.jsx)("td",{children:e.description}),(0,r.jsx)("td",{children:e.discount}),(0,r.jsx)("td",{children:e.availability}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:()=>d(e),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>h(e.id),children:(0,r.jsx)(eg.Z,{})})]})]},t)))})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:l,className:"add-btn",disabled:!(null==s?void 0:s.status)||(null==s?void 0:s.status)==="ended",children:a("ticket.add_rule")}),(0,r.jsx)(K.ZP,{showAt:!!c,onClose:u,children:(0,r.jsx)(sV,{priceRule:c,onChange:m,onClose:u})})]})};var sW=a(69697),s$=a(86455),sH=a.n(s$);let sJ=e=>{var t,a,n,s;let{eventId:i}=e,{data:o,isLoading:d}=(0,eh.Z)("/ticket-config-info/list?eventId="+i);console.log("\uD83D\uDE80 ~ ProductorInfo ~ data:",o);let[c,u]=l.useState({name:"",cnpj:"",share:0,accountId:"",eventId:i,pixKey:"",totalTicketsPurchasesInGroup:0,budget:{totalPaying:0,totalPayingMedian:0,totalTicketOffice:0,tkm:0}}),[m,h]=l.useState(),[x,p]=l.useState(!1),[g,j]=l.useState({});async function f(){try{p(!0);let e=await J.ZP.get("/ticket-config-info/get-authorization-link/".concat(i));if(p(!1),e.data.error)throw Error(e.data.error.message);navigator.clipboard.writeText(e.data),sH().fire({title:"Link copiado para o clipboard!",text:"Envie este link para a franquia. Assim que ela autorizar o id da conta ser\xe1 gerado com sucesso.",confirmButtonText:"Ok",allowOutsideClick:!1})}catch(e){et.Am.error(e.message)}}async function b(){try{let e={};if(j(e),c.cnpj&&!sW.s3.isValid(c.cnpj)&&(e.cnpj="Campo inv\xe1lido"),Object.keys(e).length)return j(e),
1!1;let t=await J.ZP.post("/ticket-config-info",c);if(et.Am.success("Informa\xe7\xf5es salvas com sucesso"),t.data.error)throw Error(t.data.error.message)}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{u(o||{name:"",cnpj:"",share:0,accountId:"",eventId:i,pixKey:"",totalTicketsPurchasesInGroup:0,budget:{totalPaying:0,totalPayingMedian:0,totalTicketOffice:0,tkm:0}}),(async()=>{let{data:e}=await J.ZP.get("/gateway-payment/active");console.log("\uD83D\uDE80 ~ activeGatewayPayment:",e),h(e)})()},[o]),(0,r.jsxs)("div",{className:"productor-info",children:[(0,r.jsx)("h3",{children:"Informa\xe7\xf5es da franquia"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{label:"Nome*",value:c.name,onValueChange:e=>{u(t=>({...t,name:e}))},onBlur:b}),(0,r.jsx)(ah.Z,{label:"CNPJ*",value:c.cnpj,onValueChange:e=>{u(t=>({...t,cnpj:(0,eD.i6)(e)}))},error:!!g.cnpj,helperText:g.cnpj,onBlur:b})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{label:"Repasse das vendas (%)*",value:c.share,type:"number",onValueChange:e=>{u(t=>({...t,share:parseFloat(e.replace(",","."))}))},onBlur:b}),(0,r.jsx)(ah.Z,{label:"".concat((null==m?void 0:m.codename)==="PAGARME"?"Id da conta Pagar.me":"Id da conta (gerado pelo sistema)"),value:c.accountId,onValueChange:e=>{u(t=>({...t,accountId:e}))},onBlur:b,disabled:(null==m?void 0:m.codename)!=="PAGARME"}),(0,r.jsx)(ah.Z,{label:"Chave PIX (Open Pix - Woovi)",value:c.pixKey||"",onValueChange:e=>{u(t=>({...t,pixKey:e}))},onBlur:b}),(null==m?void 0:m.codename)==="PAGSEGURO"&&(0,r.jsx)(v.Z,{variant:"outlined",onClick:f,startIcon:x&&(0,r.jsx)(tK.Z,{size:30}),children:"Gerar Link de Autoriza\xe7āo"})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"total-tickets-purchases-in-group",children:[(0,r.jsx)("h3",{children:"Total de ingressos vendidos de vendas em grupo"}),(0,r.jsx)(sT.Z,{defaultValue:isNaN(c.totalTicketsPurchasesInGroup)?"":c.totalTicketsPurchasesInGroup,onValueChange:e=>{u(t=>({...t,totalTicketsPurchasesInGroup:e}))}}),(0,r.jsx)(v.Z,{variant:"contained",className:"total-tickets-purchases-in-group-button",onClick:b,children:"Salvar"})]})}),(0,r.jsxs)("div",{className:"budget",children:[(0,r.jsx)("h3",{children:"Or\xe7amento"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"budget-item",children:[(0,r.jsx)("h4",{children:"Pagantes"}),(0,r.jsx)(ah.Z,{value:(null===(t=c.budget)||void 0===t?void 0:t.totalPaying)||"",type:"number",onValueChange:e=>{u(t=>({...t,budget:{...t.budget,totalPaying:parseFloat(e.replace(",","."))}}))}})]}),(0,r.jsxs)("div",{className:"budget-item",children:[(0,r.jsx)("h4",{children:"M\xe9dia de Pagantes"}),(0,r.jsx)(ah.Z,{value:(null===(a=c.budget)||void 0===a?void 0:a.totalPayingMedian)||"",type:"number",onValueChange:e=>{u(t=>({...t,budget:{...t.budget,totalPayingMedian:parseFloat(e.replace(",","."))}}))}})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"budget-item",children:[(0,r.jsx)("h4",{children:"Bilheteria"}),(0,r.jsx)(sT.Z,{defaultValue:(null===(n=c.budget)||void 0===n?void 0:n.totalTicketOffice)||"",onValueChange:e=>{u(t=>({...t,budget:{...t.budget,totalTicketOffice:e}}))}})]}),(0,r.jsxs)("div",{className:"budget-item",children:[(0,r.jsx)("h4",{children:"TKM"}),(0,r.jsx)(sT.Z,{defaultValue:(null===(s=c.budget)||void 0===s?void 0:s.tkm)||"",onValueChange:e=>{u(t=>({...t,budget:{...t.budget,tkm:e}}))}})]})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(v.Z,{variant:"contained",className:"budget-button",onClick:b,children:"Salvar"})})]})]})},sQ=e=>{let{toggleLoader:t}=(0,ee.U2)(),{t:a}=(0,p.$)("admin"),[n,s]=l.useState(e.installmentRule),[i,o]=l.useState({}),{id:d,amount:c,times:u,obs:m="",updatedAt:h,eventId:x,lastUpdatedBy:g}=n||{};function j(e){s(t=>({...t,...e}))}async function f(){try{let a={};if(o(a),c||(a.amount=!0),u||(a.times=!0),Object.keys(a).length)return o(a),et.Am.error("Formul\xe1rio incompleto!");t(!0);let n=await J.ZP.post("/ticket-config-installments-rule",{id:d,amount:c,times:u,obs:m.trim(),eventId:x});if(n.data.error)throw Error(n.data.error.message);t(),e.onChange(),et.Am.success("Regra salva com sucesso!")}catch(e){console.log(JSON.stringify(e,null,2)),t(),et.Am.error(e.message)}}return(0,r.jsx)("div",{className:"modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:a(d?"edit":"create")+" "+a("ticket.installment_rule"),onGoBack:e.onClose,data:{id:d,updatedAt:h,lastUpdatedBy:g}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(sT.Z,{label:a("ticket.installment_amount"),defaultValue:c,onValueChange:e=>{j({amount:e})},error:!!i.amount}),(0,r.jsx)(am.Z,{label:a("ticket.installment_time"),value:u,options:[1,2,3,4,5,6,7,8,9,10,11,12].map(e=>({label:"".concat(e,"X"),value:e})),onChange:e=>j({times:e}),error:!!i.times}),(0,r.jsx)(ah.Z,{label:a("obs"),multiline:!0,rows:5,value:m,onValueChange:e=>{j({obs:e})}}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:e.onClose,className:"close-btn",children:"Fechar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:f,className:"save-btn",children:d?"Atualizar regra":"Salvar regra"})]})]})]})})},sY=e=>
1{let[t,a]=l.useState(),{toggleLoader:n}=(0,ee.U2)(),{data:s,isLoading:i,refresh:r}=(0,eh.Z)("/ticket-config-installments-rule/list?admin=true&eventId="+e);function o(){a(null)}let d=l.useCallback(e=>{(0,em.Z)({text:"Deseja realmente remover esta regra?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{n(!0,"Removendo regra");let t=await J.ZP.delete("/ticket-config-installments-rule/".concat(e));if(t.data.error)return et.Am.error(t.data.error.message);r(),n(),et.Am.success("Regra removida com sucesso!")},onError:()=>{n()}})},[null==s?void 0:s.length]);return{purchaseInstallments:s,addPurchaseInstallment:function(){a({eventId:e})},editPurchaseInstallment:function(e){a(e)},selectedPurchaseInstallment:t,closePurchaseInstallmentForm:o,removePurchaseInstallment:d,refreshData:()=>{r(),o()}}},sK=e=>{let{eventId:t}=e,{t:a}=(0,p.$)("admin"),{purchaseInstallments:n,addPurchaseInstallment:s,editPurchaseInstallment:i,selectedPurchaseInstallment:l,closePurchaseInstallmentForm:o,removePurchaseInstallment:d,refreshData:c}=sY(t);return(0,r.jsxs)("div",{className:"purchase-installments",children:[(0,r.jsx)("h3",{children:a("ticket.installments_rules")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:a("ticket.installment_amount")}),(0,r.jsx)("th",{children:a("ticket.installment_time")}),(0,r.jsx)("th",{children:a("obs")}),(0,r.jsx)("th",{children:a("ticket.action")})]})}),(0,r.jsx)("tbody",{children:Array.isArray(n)&&(null==n?void 0:n.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,sL.n)(e.amount)}),(0,r.jsx)("td",{children:e.times}),(0,r.jsx)("td",{children:e.obs}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:()=>i(e),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>d(e.id),children:(0,r.jsx)(eg.Z,{})})]})]},t)))})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>s(),className:"add-btn",children:a("ticket.add_rule")}),(0,r.jsx)(K.ZP,{showAt:!!l,onClose:o,children:(0,r.jsx)(sQ,{installmentRule:l,onChange:c,onClose:o})})]})},sX=Math.PI/180;async function s0(e){let{sampleStep:t=1,threshold:a=254}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("image/jpeg"===e.type)return{hasAlphaChannel:!1,hasAnyTransparentPixel:!1,format:e.type};try{var n;let s=await createImageBitmap(e),i=s.width,r=s.height,l="OffscreenCanvas"in window?new OffscreenCanvas(i,r):Object.assign(document.createElement("canvas"),{width:i,height:r}),o=l.getContext("2d");if(!o)throw Error("N\xe3o foi poss\xedvel obter contexto 2D");o.drawImage(s,0,0),null===(n=s.close)||void 0===n||n.call(s);let{data:d}=o.getImageData(0,0,i,r),c=!1;for(let e=0;e<r;e+=t){for(let n=0;n<i;n+=t){let t=(e*i+n)*4,s=d[t+3];if(s<=a){c=!0;break}}if(c)break}return{hasAlphaChannel:!0,hasAnyTransparentPixel:c,format:e.type,width:i,height:r,sampleStep:t,threshold:a}}catch(t){return console.error("Erro ao detectar transpar\xeancia:",t),{hasAlphaChannel:!1,hasAnyTransparentPixel:!1,format:e.type}}}async function s1(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=t.getContext("2d");if(!i)throw Error("No 2d context");let r=e.naturalWidth/e.width,l=e.naturalHeight/e.height,o=window.devicePixelRatio;t.width=Math.floor(a.width*r*o),t.height=Math.floor(a.height*l*o),i.scale(o,o),i.imageSmoothingQuality="high";let d=a.x*r,c=a.y*l,u=e.naturalWidth/2,m=e.naturalHeight/2;i.save(),i.translate(-d,-c),i.translate(u,m),i.rotate(s*sX),i.scale(n,n),i.translate(-u,-m),i.drawImage(e,0,0,e.naturalWidth,e.naturalHeight,0,0,e.naturalWidth,e.naturalHeight),i.restore()}function s2(e){var t,a;let{refId:n="imgcrop",renderBtn:s=(0,r.jsx)("label",{children:(0,r.jsx)("div",{className:"placeholder-btn",children:(0,r.jsx)(au(),{className:"placeholder",src:"/placeholder.png",layout:"fill",objectFit:"contain",unoptimized:!0,alt:"",width:"100%",height:"100%"})})}),onChange:i,round:o,aspectRatio:d,changeable:c=!0,className:u="",maxWidthOrHeight:m=1920,defaultImage:h,enableTransparencyValidation:x=!0,transparencyValidationMessage:p="Imagens com fundo transparente n\xe3o s\xe3o permitidas. Por favor, use uma imagem com fundo branco."}=e,[g,j]=(0,l.useState)(""),f=(0,l.useRef)(null),b=(0,l.useRef)(null),y=l.useRef(),N=l.useRef(),[k,w]=(0,l.useState)(),[Z,C]=(0,l.useState)(),[S,_]=(0,l.useState)(1),[D,E]=l.useState(500),[P,I]=(0,l.useState)(0),[A,T]=(0,l.useState)(o?1:void 0),R=l.useRef(A),[L,q]=l.useState(!1),[M,O]=l.useState(!1);async function F(e){if(!x)return!0;O(!0);try{let t=await s0(e,{sampleStep:2});if(t.hasAnyTransparentPixel)return et.Am.error(p),!1;return!0}catch(e){return console.error("Erro na valida\xe7\xe3o de transpar\xeancia:",e),et.Am.error("Erro ao validar a imagem. Tente novamente."),!1}finally{O(!1)}}async function B(e){if(e.target.files&&e.target.files.length>0){let t=e.target.files[0],a=await F(t);if(!a){y.current&&(y.current.value="");return}w(void 0);let n=new FileReader;n.addEventListener("load",()=>{var e;return j((null===(e=n.result)||void 0===e?void 0:e.toString())||"")}),n.readAsDataURL(t),N.current=t}}function U(){y.current&&(y.current.value=""),j(""),T(void 0)}return l.useEffect(()=>{T(o?1:void 0)},[o]),l.useEffect(()=>{(null==h?void 0:h.includes("http"))?ar().get(h,{responseType:"blob",headers:{"Access-Control-Allow-Origin":"*"}}).then(e=>{setTimeout(()=>{j(URL.createObjectURL(e.data))},500)}):j(h)},[h]),t=async()=>{(null==Z?void 0:Z.width)&&(null==Z?void 0:Z.height)&&b.current&&f.current&&s1(b.current,f.current,Z,S,P)},a=[Z,S,P],(0,l.useEffect)(()=>{let e=setTimeout(()=>{t.apply(void 0,a)},100);return()=>{clearTimeout(e)}},a),(0,r.jsxs)("div",{className:"image-cropper "+(u||n),children:[(0,r.jsx)("input",{type:"file",accept:"image/*",onChange:B,className:"d-none",ref:y,id:n,name:"file",disabled:!c||M}),(0,r.jsx)("input",{id:"scale-input",type:"number",step:"0.1",value:S,disabled:!g,onChange:e=>_(Number(e.target.value))}),(0,r.jsxs)("div",{className:"processing",style:{position:"relative"},children:[l.cloneElement(s||(0,r.jsx)("label",{children:"Open File"}),{htmlFor:n}),L&&(0,r.jsx)(ee.aN,{message:"Processando imagem"}),M&&(0,r.jsx)("div",{className:"validation-message",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 16px",borderRadius:"4px",fontSize:"14px",zIndex:1e3,pointerEvents:"none"},children:"Validando transpar\xeancia..."})]}),(0,r.jsx)(sg.Z,{open:Boolean(g),disablePortal:!0,children:(0,r.jsxs)("div",{className:"modal",children:[(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"title",children:"Edi\xe7\xe3o imagem"}),(0,r.jsx)(sf(),{crop:k,onDragStart:()=>T(d),onChange:(e,t)=>
1{let{height:a,width:n}=e;R.current=n/a,w(t)},onComplete:e=>C(e),aspect:A,circularCrop:o,ruleOfThirds:!0,children:(0,r.jsx)("img",{ref:b,alt:"Crop me",src:g,style:{transform:"scale(".concat(S,") rotate(").concat(P,"deg)")},onLoad:function(e){let{width:t,height:a}=e.currentTarget;A?w((0,sj.centerCrop)((0,sj.makeAspectCrop)({unit:"%",width:90},A,t,a),t,a)):R.current=t/a},draggable:!1})}),(0,r.jsxs)("div",{className:"modal-actions",children:[(0,r.jsxs)("div",{className:"sliders",children:[(0,r.jsxs)("div",{className:"slider",children:[(0,r.jsx)("span",{children:"Zoom:"}),(0,r.jsx)(sp.Z,{}),(0,r.jsx)(su.ZP,{value:S,min:1,max:5,step:.1,onChange:(e,t)=>_(Number(t))}),(0,r.jsx)(eU.Z,{})]}),(0,r.jsxs)("div",{className:"slider slider2",children:[(0,r.jsx)("span",{className:"item",children:"Tamanho imagem (kb):"}),(0,r.jsx)(su.ZP,{value:D,min:300,max:800,step:100,onChange:(e,t)=>E(Number(t)),marks:[{value:300,label:"300"},{value:400,label:"400"},{value:500,label:"500"},{value:600,label:"600"},{value:700,label:"700"},{value:800,label:"800"}]})]})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:U,size:"large",children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:function(){function e(e){(0,sb.Z)(e,{maxSizeMB:D/1e3,maxWidthOrHeight:m}).then(e=>{i(e,R.current),q(!1)}).catch(function(e){q(!1),(0,Q.C)(e.message)})}if(q(!0),k){var t;null===(t=f.current)||void 0===t||t.toBlob(e)}else e(N.current);U()},size:"large",className:"submit",children:"Salvar imagem"})]})]}),(0,r.jsx)("canvas",{ref:f,style:{display:"none",objectFit:"contain",width:null==Z?void 0:Z.width,height:null==Z?void 0:Z.height}})]})})]})}let s3=e=>{let{eventId:t}=e,{data:a,isLoading:n}=(0,eh.Z)("/ticket-config-image?eventId="+t),[s,i]=l.useState({});async function o(e){try{if(!e)return;i({...s,...e});let a=await J.ZP.post("/ticket-config-image/save",(0,eD.GZ)({eventId:t,...e}),{headers:{"Content-Type":"multipart/form-data"}});if(a.data.error)throw Error(a.data.error.message)}catch(e){et.Am.error(e.message)}}async function d(e){try{let a={...s};delete a[e],i(a);let n=await J.ZP.delete("/ticket-config-image/".concat(t,"/").concat(e));if(n.data.error)throw Error(n.data.error.message)}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{i(a||{})},[a]),(0,r.jsxs)("div",{className:"ticket-image",children:[(0,r.jsxs)("div",{className:"transparency-warning",style:{background:"#fff3cd",border:"1px solid #ffeaa7",borderRadius:"8px",padding:"12px 16px",marginBottom:"20px",color:"#856404"},children:[(0,r.jsx)("strong",{children:"⚠️ Importante:"})," Imagens com fundo transparente n\xe3o s\xe3o permitidas. Certifique-se de que suas imagens tenham fundo branco antes do upload."]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"email-header-image",children:[(0,r.jsx)("h3",{children:"Imagem Header Email"}),(0,r.jsx)(s2,{refId:"email-header-image",onChange:e=>o({emailHeaderImage:e}),aspectRatio:600/155,enableTransparencyValidation:!0,transparencyValidationMessage:"Imagens com fundo transparente n\xe3o s\xe3o permitidas. Por favor, use uma imagem com fundo branco.",renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(s.emailHeaderImage),layout:"fill"}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>d("emailHeaderImage"),children:(0,r.jsx)(er.Z,{})})})]})}),(0,r.jsx)("div",{className:"email-header-image-description",children:(0,r.jsxs)("p",{children:["A imagem ser\xe1 exibida no header do email enviado para o cliente ap\xf3s a compra. ",(0,r.jsx)("br",{}),"Tamanho recomendado: 1920x450px ",(0,r.jsx)("br",{}),(0,r.jsx)("strong",{children:"⚠️ N\xe3o use imagens com fundo transparente"})]})})]}),(0,r.jsxs)("div",{className:"pdf-ticket-image",children:[(0,r.jsx)("h3",{children:"Imagem Ingresso PDF"}),(0,r.jsx)(s2,{aspectRatio:204/114,refId:"pdf-ticket-image",onChange:e=>o({pdfTicketImage:e}),enableTransparencyValidation:!0,transparencyValidationMessage:"Imagens com fundo transparente n\xe3o s\xe3o permitidas. Por favor, use uma imagem com fundo branco.",renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(s.pdfTicketImage),layout:"fill"}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>d("pdfTicketImage"),children:(0,r.jsx)(er.Z,{})})})]})}),(0,r.jsx)("div",{className:"pdf-ticket-image-description",children:(0,r.jsxs)("p",{children:["A imagem ser\xe1 exibida no ingresso PDF. ",(0,r.jsx)("br",{}),"Tamanho recomendado: 620x440px ",(0,r.jsx)("br",{}),(0,r.jsx)("strong",{children:"⚠️ N\xe3o use imagens com fundo transparente"})]})})]})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"pdf-sponsers-image",children:[(0,r.jsx)("h3",{children:"Imagem Patrocinadores PDF e Email"}
1),(0,r.jsx)(s2,{refId:"pdf-sponsers-image",onChange:(e,t)=>o({pdfSponsorsImage:e,pdfSponsorsImageAspectRatio:t}),enableTransparencyValidation:!0,transparencyValidationMessage:"Imagens com fundo transparente n\xe3o s\xe3o permitidas. Por favor, use uma imagem com fundo branco.",renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(s.pdfSponsorsImage),layout:"fill"}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>d("pdfSponsorsImage"),children:(0,r.jsx)(er.Z,{})})})]})}),(0,r.jsx)("div",{className:"pdf-sponsers-image-description",children:(0,r.jsxs)("p",{children:["A imagem ser\xe1 exibida no PDF e no email. ",(0,r.jsx)("br",{}),"Tamanho recomendado: 1920x450px ",(0,r.jsx)("br",{}),(0,r.jsx)("strong",{children:"⚠️ N\xe3o use imagens com fundo transparente"})]})})]})})]})},s6=e=>{let{toggleLoader:t}=(0,ee.U2)(),{t:a}=(0,p.$)("admin"),{data:n,isLoading:s,refresh:i}=(0,eh.Z)("/ticket-config-availability-limit/list?admin=true&eventId="+e);sI("refresh_tickets_availability_table",i);let r=l.useCallback(e=>{(0,em.Z)({text:a("ticket_coupon.delete_all?"),confirmButtonText:a("remove"),onConfirm:async()=>{try{t(!0,a("processing"));let n=await J.ZP.delete("/ticket-config-availability-limit/".concat(e));if(t(),n.data.error)throw Error(a("error_on_processing")+" \n\n"+n.data.error.message);et.Am.success(a("success_on_processing")),i(),ab.v.dispatch("refresh_tickets_availability_table")}catch(e){et.Am.error(e.message)}}})},[]);return{items:n,removeItem:r}},s5=e=>{var t;let{item:a={}}=e,{t:n}=(0,p.$)("admin"),{toggleLoader:s}=(0,ee.U2)(),{storedState:i}=(0,o.oR)(),d=null==i?void 0:null===(t=i.currentSelectedEvent)||void 0===t?void 0:t._id,[c,u]=l.useState({eventId:d,...a}),[m,h]=l.useState({}),{type:x,periodFrom:g,periodTo:j,purshaseAmount:f,courtesyAmount:b,updatedAt:y,lastUpdatedBy:N}=c;async function k(){try{let e={};if(h(e),x||(e.type_required=!0),"hourly"!==x&&"daily"!==x&&"period"!==x||f||(e.purchase_amount_required=!0),"period"!==x||g||(e.period_from_required=!0),"period"!==x||j||(e.period_to_required=!0),Object.keys(e).length)return h(e),et.Am.error(n("form_incomplete"));s(!0,n("processing"));let t=await J.ZP.post("/ticket-config-availability-limit",c);if(t.data.error)throw Error(t.data.error.message);s(),et.Am.success(n("success_on_processing")),ab.v.dispatch("refresh_tickets_availability_table"),(0,K.Mr)()}catch(e){console.log(JSON.stringify(e,null,2)),s(),et.Am.error(e.message)}}return(0,r.jsx)("div",{className:"ticket-config-limit-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:n("ticket.config.limits"),onGoBack:K.Mr,data:{updatedAt:y,lastUpdatedBy:N}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(am.Z,{label:"* "+n("ticket.config.tickets_limit_type"),options:["hourly","daily","unlimited","period"].map(e=>({label:n("ticket.config.tickets_limit_type_"+e),value:e})),value:x,onChange:e=>u(t=>({...t,type:e})),error:null==m?void 0:m.type_required}),"period"===x&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{className:"textfield",label:"* "+n("ticket.config.tickets_limit_type_period_from"),value:g||"",onValueChange:e=>u(t=>({...t,periodFrom:(0,eD.yL)(e)})),error:null==m?void 0:m.period_from_required}),(0,r.jsx)(ah.Z,{className:"textfield",label:"* "+n("ticket.config.tickets_limit_type_period_to"),value:j||"",onValueChange:e=>u(t=>({...t,periodTo:(0,eD.yL)(e)})),error:null==m?void 0:m.period_to_required})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{className:"textfield",label:"* "+n("ticket.config.tickets_limit_purchase_amount"),value:f||"",type:"number",onValueChange:e=>u(t=>({...t,purshaseAmount:parseInt(e)})),error:null==m?void 0:m.purchase_amount_required,disabled:"unlimited"===x}),(0,r.jsx)(ah.Z,{className:"textfield",label:n("ticket.config.tickets_limit_courtesy_amount"),value:b||"",type:"number",onValueChange:e=>u(t=>({...t,courtesyAmount:parseInt(e)}))})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:n("event.close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:k,children:n("save")})]})]})]})})},s8=e=>{let{eventId:t}=e,{t:a}=(0,p.$)("admin"),{items:n,removeItem:s}=s6(t);return(0,r.jsxs)("div",{className:"visitors-limits",children:[(0,r.jsx)("h3",{children:a("ticket.config.limits")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:a("ticket.config.tickets_limit_type")}),(0,r.jsx)("th",{children:a("ticket.config.tickets_limit_type_period_from")}),(0,r.jsx)("th",{children:a("ticket.config.tickets_limit_type_period_to")}),(0,r.jsx)("th",{children:a("ticket.config.tickets_limit_purchase_amount")}),(0,r.jsx)("th",{children:a("ticket.config.tickets_limit_courtesy_amount")}),(0,r.jsx)("th",{children:a("action")})]})}),(0,r.jsx)("tbody",{children:Array.isArray(n)&&(null==n?void 0:n.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:a("ticket.config.tickets_limit_type_"+e.type)}),(0,r.jsx)("td",{children:"period"===e.type?e.periodFrom:"-"}),(0,r.jsx)("td",{children:"period"===e.type?e.periodTo:"-"}),(0,r.jsx)("td",{children:e.purshaseAmount}),(0,r.jsx)("td",{children:e.courtesyAmount}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:()=>(0,K.K4)((0,r.jsx)(s5,{item:e})),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>s(e.id),children:(0,r.jsx)(eg.Z,{})})]})]},t)))})]}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>(0,K.K4)((0,r.jsx)(s5,{})),className:"add-btn",children:a("ticket.add_rule")})]})},s7=e=>{let{eventId:t}=e,{data:a,isLoading:n}=(0,eh.Z)("/ticket-config-info/list?eventId="+t);console.log("\uD83D\uDE80 ~ SponsorText ~ data:",a);let[s,i]=l.useState({id:null==a?void 0:a.id,sponsorText:(null==a?void 0:a.sponsorText)||""});async function o(){try{let e=await J.ZP.patch("/ticket-config-info/sponsor-text/".concat(s.id),s);if(et.Am.success("Texto do patrocinador salvo com sucesso"),e.data.error)throw Error(e.data.error.message)}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{i(a||{sponsorText:""})},[a]),(0,r.jsx)("div",{className:"productor-info",children:(0,r.jsxs)("div",{className:"budget",children:[(0,r.jsx)("h3",{children:"Texto do patrocinador"}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:s.sponsorText,onChange:e=>i({...s,sponsorText:e})})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(v.Z,{variant:"contained",className:"budget-button",onClick:o,children:"Salvar"})})]})})};var s4=a(60666);let s9=e=>{let{banner:t,bannerIndex:a,eventId:n,onChange:s}=e,[i,o]=l.useState({coverImage:(null==t?void 0:t.coverImage)||"",link:(null==t?void 0:t.link)||""}),[d,c]=l.useState({}),{toggleLoader:u}=(0,ee.U2)();function m(e){o(t=>({...t,...e}))}async function h(){try{let e;let t={};if(c(t),/^https?:\/\/.+/.test(i.link)||(t.link=!0),i.coverImage||(t.coverImage=!0),Object.keys(t).length)return c(t),et.Am.error("Formul\xe1rio incompleto! Verifique se a imagem foi selecionada e o link \xe9 uma URL v\xe1lida (http:// ou https://)");u(!0,void 0!==a?"Atualizando banner":"Salvando banner");let r={link:i.link};i.coverImage instanceof Blob&&(r.coverImage=i.coverImage);let l=(0,eD.GZ)(r);if((e=void 0!==a?await J.ZP.patch("/ticket-config-image/banners/".concat(n,"/").concat(a),l,{headers:{"Content-Type":"multipart/form-data"}}):await J.ZP.post("/ticket-config-image/banners/".concat(n),l,{headers:{"Content-Type":"multipart/form-data"}})).data.error)throw Error(e.data.error.message);s(),u(),et.Am.success(void 0!==a?"Banner atualizado com sucesso!":"Banner salvo com sucesso!"),(0,K.Mr)()}catch(e){console.log(JSON.stringify(e,null,2)),u(),et.Am.error(e.message||"Erro ao salvar banner")}}return l.useEffect(()=>{t?o({coverImage:t.coverImage||"",link:t.link||""}):o({coverImage:"",link:""}),c({})},[t]),(0,r.jsx)("div",{className:"modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:void 0!==a?"Editar banner":"Adicionar banner",onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"banner-cover-image",children:[(0,r.jsx)(s2,{refId:"banner-cover-image",onCh
1ange:e=>m({coverImage:e}),aspectRatio:1600/761,enableTransparencyValidation:!1,renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(i.coverImage),layout:"fill"}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:e=>{e.preventDefault(),e.stopPropagation(),m({coverImage:null})},children:(0,r.jsx)(er.Z,{})})})]})}),d.coverImage&&(0,r.jsx)("div",{style:{color:"red",marginTop:"8px"},children:"Imagem \xe9 obrigat\xf3ria"})]}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Link",value:i.link||"",onChange:e=>{e.stopPropagation(),m({link:e.target.value})},error:null==d?void 0:d.link,helperText:(null==d?void 0:d.link)?"Link deve come\xe7ar com http:// ou https://":"URL completa do banner (ex: https://example.com)",placeholder:"https://example.com"}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,className:"close-btn",children:"Cancelar"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:h,className:"save-btn",children:void 0!==a?"Atualizar banner":"Salvar banner"})]})]})]})})},ie=e=>{let{eventId:t}=e,{data:a,isLoading:n,refresh:s}=(0,eh.Z)("/ticket-config-image/banners/".concat(t)),[i,o]=l.useState([]),d=l.useRef();function c(e){let t=e.target.closest(".draggable");d.current=t?parseInt(t.dataset.index):void 0,e.target.style.opacity=.2}function u(e){e.target.style.opacity=1}function m(e){e.preventDefault();let t=e.target.closest(".draggable");if(void 0!==d.current&&t){let e=parseInt(t.dataset.index);d.current!==e?t.style.transform="scale(0.9)":t.style.transform="initial"}}function h(e){let t=e.target.closest(".draggable");t&&(t.style.transform="initial")}async function x(e){e.preventDefault();let a=e.target.closest(".draggable");a&&(a.style.transform="initial");let n=a?parseInt(a.dataset.index):void 0;if(void 0!==d.current&&void 0!==n&&d.current!==n){let e=i.map((e,t)=>t),[a]=e.splice(d.current,1);e.splice(n,0,a);let r=[...i],[l]=r.splice(d.current,1);r.splice(n,0,l),o(r);try{let a=await J.ZP.put("/ticket-config-image/banners/".concat(t,"/update-order"),e);if(a.data.error)throw Error(a.data.error.message);et.Am.success("Banners reordenados com sucesso!"),s()}catch(e){o(i),et.Am.error(e.message||"Erro ao reordenar banners")}}}async function p(e){(0,em.Z)({title:"Remover banner",text:"Tem certeza que deseja remover este banner?",icon:"warning",confirmButtonText:"Sim, remover",cancelButtonText:"Cancelar",endpoint:"/ticket-config-image/banners/".concat(t,"/").concat(e),endpointConfig:{method:"DELETE"},successMessage:"Banner removido com sucesso!",onSuccess:()=>{s()}})}function g(e,a){(0,K.K4)((0,r.jsx)(s9,{banner:e,bannerIndex:a,eventId:t,onChange:s}))}return l.useEffect(()=>{Array.isArray(a)?o(a):Array.isArray(null==a?void 0:a.banners)?o(a.banners):(null==a?void 0:a.banners)?o([a.banners]):o([])},[a]),(0,r.jsxs)("div",{className:"ticket-banners",children:[(0,r.jsx)("h3",{children:"Banners"}),!n||(null==i?void 0:i.length)?(null==i?void 0:i.length)?(0,r.jsx)("div",{className:"banners-list",children:i.map((e,t)=>(0,r.jsx)("div",{className:"list-item-card draggable",draggable:!0,"data-index":t,onDragStart:c,onDragEnd:u,onDragOver:m,onDragLeave:h,onDrop:x,children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"cover",children:(0,r.jsx)(eP.Z,{src:(0,eD.e6)(e.coverImage),layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",t+1]}),(0,r.jsxs)("div",{className:"link",children:[(0,r.jsx)("strong",{children:"Link:"})," ",(0,r.jsx)("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:e.link.length>50?"".concat(e.link.substring(0,50),"..."):e.link})]})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:a=>{a.stopPropagation(),g(e,t)},children:(0,r.jsx)(s4.Z,{})}),(0,r.jsx)(X.Z,{onClick:e=>{e.stopPropagation(),p(t)},children:(0,r.jsx)(er.Z,{})})]})]})},t))}):(0,r.jsx)("div",{className:"data-info",children:"Nenhum banner cadastrado para este evento!"}):(0,r.jsx)("div",{className:"data-info",children:"Carregando banners..."}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>g(),className:"btn-create",style:{marginTop:"20px"},children:"Adicionar banner"})]})},it=()=>{let{storedState:e}=(0,o.oR)(),t=null==e?void 0:e.currentSelectedEvent,a=null==t?void 0:t._id;return(0,r.jsx)("div",{className:"ticket-configurations",children:!!a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sB,{eventId:a}),(0,r.jsx)(sJ,{eventId:a}),(0,r.jsx)(s8,{eventId:a}),(0,r.jsx)(sG,{eventId:a}),(0,r.jsx)(sK,{eventId:a}),(0,r.jsx)(s3,{eventId:a}),(0,r.jsx)(ie,{eventId:a}),(0,r.jsx)(s7,{eventId:a}),(0,r.jsx)(s_,{eventId:a})]})})},ia=()=>{var e;let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),{storedState:n}=(0,o.oR)(),s=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketCompensationLimit:i=20,ticketCompensationPage:r=0,ticketCompensationSearch:d=""}=n,c=(0,ev.Nr)(d,300),{data:u,isLoading:m,refresh:h}=(0,eh.Z)("/ticket-compensation?limit=".concat(i,"&page=").concat(r,"&search=").concat(c,"&eventId=").concat(s)),v=(null==u?void 0:u.items)||[],x=(null==u?void 0:u.numberOfItems)||0,[g,j]=l.useState(!1),[f,b]=l.useState({});sI("refresh_compensation_table",h);let y=l.useCallback(e=>{(0,em.Z)({text:t("ticket_compensation.delete?"),confirmButtonText:t("remove"),onConfirm:async()=>{try{a(!0,t("processing"));let n=await J.ZP.delete("/ticket-compensation/".concat(e));if(a(),n.data.error)throw Error(t("error_on_processing")+" \n\n"+n.data.error.message);et.Am.success(t("success_on_processing")),h(),ab.v.dispatch("refresh_compensation_table")}catch(e){et.Am.error(e.message)}}})},[]);async function N(){try{var e;a(!0,"Baixando tabela");let n=await J.ZP.get("/ticket-compensation?eventId=".concat(s));if(n.data.error)throw Error(t("error_on_processing")+"\n\n"+n.data.error.message);a(!0,"Gerando tabela"),console.log(n.data);let i={Ingresso:{selector:"ticket.title"},"C\xf3digo grupo":{selector:"code"},Descricao:{selector:"description"},"Desconto(%)":{selector:"discount"},"Quantidade dispon\xedvel":{selector:"totalQty"},Resgatado:{selector:"redeemed"},"Data de expira\xe7\xe3o":{selector:"expireAt",formatValue:e=>(0,ej.p6)(e,"dd/MM/yyyy")}
1,Observação:{selector:"obs"}},r=null===(e=n.data.items)||void 0===e?void 0:e.map(e=>{let t={};return Object.keys(i).map(a=>{let n;let{selector:s,formatValue:r}=i[a];s.split(".").map(t=>{n=(n||e)[t]}),r&&(n=r(n)),t[a]=n}),t}),l=t0.P6.json_to_sheet(r),o=(0,t0.cW)({Sheets:{data:l},SheetNames:["data"]},{bookType:"xlsx",type:"array",cellDates:!0}),d=new Blob([o],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(d,"Cupons.xlsx"),a()}catch(e){a()}}return{eventId:s,compensations:v,compensation:f,addCompensation:function(){j(!0)},editCompensation:function(e){b(e),j(!0)},removeCompensation:y,showCompensationForm:g,closeCompensationForm:function(){j(!1)},refresh:h,isLoading:m,numberOfItems:x,ticketCompensationLimit:i,ticketCompensationPage:r,ticketCompensationSearch:d,downloadTable:N}},is=e=>{let{compensation:t={},onSave:a,onClose:n}=e,{storedState:s}=(0,o.oR)(),{_id:i}=(null==s?void 0:s.currentSelectedEvent)||{},{toggleLoader:d}=(0,ee.U2)(),{t:c}=(0,p.$)("admin"),[u,m]=l.useState(t),[h,x]=l.useState(!1),[g,j]=l.useState([]),[f,b]=l.useState({}),{ticket:y,name:N,smallDescription:k,description:w,value:Z,isRequired:C=!1}=u;function S(e){m(t=>({...t,...e}))}async function _(){try{let e={};if(b(e),(null==y?void 0:y.id)||(e.ticket=!0),N||(e.name=!0),k||(e.smallDescription=!0),w||(e.description=!0),Z||(e.value=!0),Object.keys(e).length)return b(e),et.Am.error(c("incomplete_form"));d(!0,c("processing"));let n=new FormData;n.append("id",null==t?void 0:t.id),y&&n.append("ticket",JSON.stringify({id:y.id,title:y.title})),n.append("eventId",i),n.append("name",N),n.append("smallDescription",k),n.append("description",w),n.append("value","".concat(Z)),n.append("isRequired","".concat(C)),(null==u?void 0:u.emailFooterImage)&&n.append("emailFooterImage",u.emailFooterImage),(null==u?void 0:u.emailFooterImageAspectRatio)&&n.append("emailFooterImageAspectRatio","".concat(u.emailFooterImageAspectRatio));let s=await J.ZP.post("/ticket-compensation",n);if(d(),s.data.error)throw Error(c("error_on_processing")+" \n\n"+s.data.error.message);a(),et.Am.success(c("success_on_processing"))}catch(e){d(),et.Am.error(e.message)}}return l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list?"+new URLSearchParams({event_id:i||"",limit:"100",admin:"true"}),onProcessing:x,onSuccess:e=>j(null==e?void 0:e.tickets),onError:e=>{et.Am.error(e.message)}})}i&&e()},[i]),(0,r.jsx)("div",{className:"add-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:(null==t?void 0:t.id)?c("ticket_compensation.edit"):c("ticket_compensation.new"),onGoBack:e.onClose}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"ticket",options:g,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.title,disablePortal:!0,loading:h,loadingText:"Carregando...",value:y,onChange:(e,t)=>
1{S({ticket:t})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+c("ticket_distribution.select_ticket"),error:!!(null==f?void 0:f.ticket),helperText:!!(null==f?void 0:f.ticket)&&c("required_field"),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImageUrl,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.title})]})})}),(0,r.jsx)(es.Z,{label:"* "+c("ticket_compensation.name"),value:N||"",className:"textfield",onChange:e=>{var t,a,n;e.stopPropagation(),S({name:null===(t=null==e?void 0:null===(a=e.target)||void 0===a?void 0:null===(n=a.value)||void 0===n?void 0:n.toUpperCase())||void 0===t?void 0:t.substring(0,20)})},error:!!f.name,helperText:!!f.name&&c("required_field")}),(0,r.jsx)(es.Z,{label:"* "+c("ticket_compensation.small_description"),value:k||"",className:"textfield",onChange:e=>{var t,a;e.stopPropagation(),S({smallDescription:null==e?void 0:null===(t=e.target)||void 0===t?void 0:null===(a=t.value)||void 0===a?void 0:a.substring(0,40)})},error:!!f.smallDescription,helperText:!!f.smallDescription&&c("required_field")}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(sT.Z,{label:"* "+c("ticket_compensation.value"),defaultValue:isNaN(Z)?"":Z,onValueChange:e=>{S({value:e})},error:!!f.value,helperText:!!f.value&&c("required_field")})}),(0,r.jsx)(es.Z,{label:"* "+c("ticket_compensation.description"),value:w||"",onChange:e=>{e.stopPropagation(),S({description:e.target.value})},multiline:!0,rows:4,error:!!f.description,helperText:!!f.value&&c("required_field")}),(0,r.jsx)(to.Z,{label:c("ticket_compensation.is_required"),onChange:e=>S({isRequired:e})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"compensation-email-footer-image",children:[(0,r.jsx)("h5",{children:"Imagem Footer Email"}),(0,r.jsx)(eE.Z,{refId:"email-footer-image",onChange:(e,t)=>
1S({emailFooterImage:e,emailFooterImageAspectRatio:t}),renderBtn:(0,r.jsxs)("label",{className:"image",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(u.emailFooterImage),layout:"fill"}),(0,r.jsx)("div",{className:"btn-actions",children:(0,r.jsx)(X.Z,{size:"large",onClick:()=>S({emailFooterImage:void 0,emailFooterImageAspectRatio:void 0}),children:(0,r.jsx)(er.Z,{})})})]})})]})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:n,children:c("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:_,children:c("ticket_compensation.create")})]})]})]})})},ii=()=>{let{t:e}=(0,p.$)("admin"),{setStoredState:t}=(0,o.oR)(),{compensations:a,compensation:n,addCompensation:s,editCompensation:i,removeCompensation:l,showCompensationForm:d,closeCompensationForm:c,refresh:u,isLoading:m,numberOfItems:h,ticketCompensationLimit:x,ticketCompensationPage:g,ticketCompensationSearch:j,downloadTable:f}=ia();return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"compensations",children:[(0,r.jsxs)("div",{className:"header",children:[(0,r.jsx)("h3",{children:"Compensa\xe7\xf5es"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:s,children:"Adicionar"})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(eu,{className:"search",placeholder:e("ticket_compensation.search"),value:j||"",onChange:e=>t({ticketCompensationSearch:(null==e?void 0:e.target.value)||""})})}),m?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!h&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:e("ticket_compensation.ticket")}),(0,r.jsx)("th",{children:e("ticket_compensation.name")}),(0,r.jsx)("th",{children:e("ticket_compensation.small_description")}),(0,r.jsx)("th",{children:e("ticket_compensation.description")}),(0,r.jsx)("th",{children:e("ticket_compensation.value")}),(0,r.jsx)("th",{children:e("ticket.action")})]})}),(0,r.jsx)("tbody",{children:null==a?void 0:a.map((e,t)=>{var a;return(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{children:[null==e?void 0:null===(a=e.ticket)||void 0===a?void 0:a.title," "]}),(0,r.jsx)("td",{children:e.name}),(0,r.jsx)("td",{children:e.smallDescription}),(0,r.jsx)("td",{children:e.description}),(0,r.jsx)("td",{children:(0,sL.n)(e.value)}),(0,r.jsxs)("td",{width:150,children:[(0,r.jsx)(X.Z,{onClick:()=>i(e),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>l(e.id),children:(0,r.jsx)(eg.Z,{})})]})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:h,rowsPerPage:x,page:g,onPageChange:e=>t({ticketCompensationPage:e}),onRowsPerPageChange:e=>t({ticketCompensationPage:0,ticketCompensationLimit:e})})]}),(0,r.jsx)(K.ZP,{showAt:!!d,onClose:c,children:(0,r.jsx)(is,{compensation:n,onSave:()=>{u(),c()},onClose:c})})]})})};var ir=l.memo(ii);function il(e){var t;let a=new URLSearchParams({eventId:e.eventId||""});return void 0!==e.limit&&a.set("limit",String(e.limit)),void 0!==e.page&&a.set("page",String(e.page)),e.search&&a.set("search",e.search),(null===(t=e.ticketIds)||void 0===t?void 0:t.length)&&a.set("ticketIds",e.ticketIds.join(",")),e.includeGlobal&&a.set("includeGlobal","true"),a.toString()}let io=()=>{var e;let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketCouponLimit:r=20,ticketCouponPage:d=0,ticketCouponSearch:c=""}=n,u=(0,ev.Nr)(c,300),[m,h]=l.useState([]),[v,x]=l.useState(!1),[g,j]=l.useState([]),[f,b]=l.useState(!1),y=il({eventId:i,limit:r,page:d,search:u,ticketIds:g,includeGlobal:f}),{data:N,isLoading:k,refresh:w}=(0,eh.Z)("/coupon/list?".concat(y),{enabled:!!i}),Z=(null==N?void 0:N.items)||[],C=(null==N?void 0:N.numberOfItems)||0,[S,_]=l.useState(void 0),[D,E]=l.useState(!1),[P,I]=l.useState(!1);sI("refresh_coupom_table",w),l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list-admin?"+new URLSearchParams({event_id:i||"",limit:"100",admin:"true"}),onProcessing:x,onSuccess:e=>h((null==e?void 0:e.tickets)||[]),onError:e=>{et.Am.error(e.message)}})}i&&e()},[i]);let A=l.useRef(i);l.useEffect(()=>{A.current&&A.current!==i&&(j([]),b(!1),s({ticketCouponPage:0}),h([])),A.current=i},[i]);let T=l.useMemo(()=>m.filter(e=>g.includes(e.id)),[m,g]),R=l.useCallback(e=>{(0,em.Z)({text:t("ticket_coupon.delete_all?"),confirmButtonText:t("remove"),onConfirm:async()=>{try{a(!0,t("processing"));let n=await J.ZP.delete("/coupon",{data:{group:e}});if(a(),n.data.error)throw Error(t("error_on_processing")+" \n\n"+n.data.error.message);et.Am.success(t("success_on_processing")),w(),ab.v.dispatch("refresh_coupom_table")}catch(e){et.Am.error(e.message)}}})},[]);async function L(){try{var e;a(!0,"Baixando tabela");let n=il({eventId:i,ticketIds:g,includeGlobal:f,search:u}),s=await J.ZP.get("/coupon/list?".concat(n));if(s.data.error)throw Error(t("error_on_processing")+"\n\n"+s.data.error.message);a(!0,"Gerando tabela");let r={Ingresso:{selector:"ticket.title"},"C\xf3digo grupo":{selector:"code"},Descricao:{selector:"description"},"Desconto(%)":{selector:"discount"},"Quantidade dispon\xedvel":{selector:"totalQty"},Resgatado:{selector:"redeemed"},"Data de expira\xe7\xe3o":{selector:"expireAt",formatValue:e=>(0,ej.p6)(e,"dd/MM/yyyy")}
1,Observação:{selector:"obs"}},l=null===(e=s.data.items)||void 0===e?void 0:e.map(e=>{let t={};return Object.keys(r).map(a=>{let n;let{selector:s,formatValue:i}=r[a];s.split(".").map(t=>{n=(n||e)[t]}),i&&(n=i(n)),t[a]=n}),t}),o=t0.P6.json_to_sheet(l),d=(0,t0.cW)({Sheets:{data:o},SheetNames:["data"]},{bookType:"xlsx",type:"array",cellDates:!0}),c=new Blob([d],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(c,"Cupons.xlsx"),a()}catch(e){a()}}return{eventId:i,couponId:S,coupons:Z,addCoupon:function(){E(!0),_(void 0)},editCoupon:function(e){_(e),E(!0)},removeCoupon:R,showCouponForm:D,closeCouponForm:function(){E(!1)},showCancelForm:P,openCancelForm:function(){I(!0)},closeCancelForm:function(){I(!1)},refresh:w,isLoading:k,numberOfItems:C,ticketCouponLimit:r,ticketCouponPage:d,ticketCouponSearch:c,tickets:m,fetchingTickets:v,selectedTickets:T,ticketCouponIncludeGlobal:f,setTicketFilter:function(e){j(e.map(e=>e.id)),s({ticketCouponPage:0})},setIncludeGlobalFilter:function(e){b(e),s({ticketCouponPage:0})},clearFilters:function(){j([]),b(!1),s({ticketCouponSearch:"",ticketCouponPage:0})},downloadTable:L}};var id=a(59869),ic=a(39673);let iu={0:"Domingo",1:"Segunda-Feira",2:"Ter\xe7a-Feira",3:"Quarta-Feira",4:"Quinta-Feira",5:"Sexta-Feira",6:"S\xe1bado"},im=e=>{var t,a;let{onSave:n,onClose:s,id:i}=e,{storedState:c}=(0,o.oR)(),{_id:u,startAt:m,endAt:h}=(null==c?void 0:c.currentSelectedEvent)||{},{toggleLoader:x}=(0,ee.U2)(),{t:g}=(0,p.$)("admin"),[j,f]=l.useState({}),[b,y]=l.useState(!1),[N,k]=l.useState(!0),[w,Z]=l.useState([]),[C,S]=l.useState(null),[_,D]=l.useState({}),{user:E}=(0,d.aC)(),{verifyIsExpiredTicket:P}=(0,ic.Z)(),{id:I,ticket:A,qty:T,expireAt:R,code:L,discount:q,description:M,obs:O,random:F,limitedByDocument:B,availableDays:U=[],isGlobal:z,lastUpdatedBy:V,updatedAt:G,applicableOnlyFromVisitDate:W,applicableOnlyUntilVisitDate:$}=j;function H(e){f(t=>({...t,...e}))}async function Q(){try{let e={};if(D(e),A||z||(e.ticket=!0),T||(e.qty=!0),L||(e.code=!0),q||(e.discount=!0),Object.keys(e).length)return D(e),et.Am.error(g("incomplete_form"));x(!0,g("processing"));let t={id:i,ticket:A?{id:A.id,title:A.title}:null,qty:T,eventId:u,expireAt:R,code:L,discount:q,description:M,obs:O,random:F,limitedByDocument:B,availableDays:U,applicableOnlyFromVisitDate:W,applicableOnlyUntilVisitDate:$,isGlobal:z};if(console.log(t),I){let e=await J.ZP.put("/coupon/".concat(I),t);if(x(),e.data.error)throw Error(g("error_on_processing")+" \n\n"+e.data.error.message);n(),et.Am.success(g("success_on_processing"));return}let a=await J.ZP.post("/coupon",t);if(x(),a.data.error)throw Error(g("error_on_processing")+" \n\n"+a.data.error.message);n(),et.Am.success(g("success_on_processing"))}catch(e){x(),et.Am.error(e.message)}}return l.useEffect(()=>{async function e(){try{k(!0);let e=await J.ZP.get("/coupon/code/".concat(i));if(e.data.error)throw Error(g("error_on_processing")+" \n\n"+e.data.error.message);f(e.data),S(w.find(t=>t.id===e.data.ticket.id)||null),k(!1)}catch(e){et.Am.error(e.message)}}i&&(null==w?void 0:w.length)&&e(),i||k(!1)},[i,w]),l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list-admin?"+new URLSearchParams({event_id:u||"",limit:"100",admin:"true"}),onProcessing:y,onSuccess:e=>Z(null==e?void 0:e.tickets),onError:e=>{et.Am.error(e.message)}})}u&&e()},[u]),(0,r.jsx)("div",{className:"coupon-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:g(i?"ticket_coupon.edit":"ticket_coupon.new"),onGoBack:e.onClose,data:{id:i?"".concat(I?"".concat(I," - "):""," ").concat(i):"",lastUpdatedBy:V||{name:""},updatedAt:G}}),(0,r.jsxs)("div",{className:"form-content",children:[(null==E?void 0:E.role)==="super-admin"&&(0,r.jsx)("div",{children:(0,r.jsx)(ea.Z,{label:"Cupom Global",className:"switch",control:(0,r.jsx)(tr.Z,{checked:z,onChange:e=>H({isGlobal:e.target.checked}),disabled:!!i})})}),!z&&!b&&!N&&(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"ticket",options:w,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.title,disablePortal:!0,loading:b,loadingText:"Carregando...",value:A,onChange:(e,t)=>
1{H({ticket:t})},disabled:z||!!i,renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+g("ticket_distribution.select_ticket"),error:!!(null==_?void 0:_.ticket),helperText:!!(null==_?void 0:_.ticket)&&g("required_field"),inputProps:e.inputProps,disabled:!!i}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImageUrl,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.title})]}),hidden:!!I})}),C&&(0,r.jsxs)("div",{className:"coupon-card-content",children:[(0,r.jsx)("div",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:C.coverImageUrl,layout:"fill"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"icon",children:null===(t=id._.find(e=>e.id===C.type))||void 0===t?void 0:t.icon}),(0,r.jsxs)("div",{className:"title",children:[" ",C.title," "]}),P(C.sellEndDate,C.hours)&&(0,r.jsx)("span",{className:"expired-label",children:" Expirado!"})]}),(0,r.jsxs)("div",{children:["Canais de venda: ",null===(a=C.sellChannels)||void 0===a?void 0:a.map(e=>"web"===e?"Website":"card-machine"===e?"Maquininha":"").join(", ")]})]})]}),(0,r.jsx)("label",{children:"Selecione os dias v\xe1lidos para este cupom:"}),(0,r.jsx)("div",{className:"available-days",children:Object.keys(iu).map(e=>{let t=parseInt(e),a=iu[t];return(0,r.jsx)(to.Z,{checked:U.includes(t),label:a,onChange:e=>{let a=[...U];
1e?(a.push(t),H({availableDays:[...new Set(a)]})):H({availableDays:a.filter(e=>e!==t)})},disabled:!!i},t)})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{label:"*"+g("ticket_coupon.code"),value:L||"",className:"textfield",onChange:e=>{e.stopPropagation(),H({code:e.target.value.toUpperCase()})},error:!!_.code,helperText:!!_.code&&g("required_field"),disabled:!!i}),(0,r.jsx)(es.Z,{label:"*"+g("ticket_coupon.discount"),type:"number",className:"textfield",value:q||"",onChange:e=>{e.stopPropagation(),H({discount:e.target.value})},error:!!_.discount,helperText:!!_.discount&&g("required_field"),disabled:!!i}),(0,r.jsx)(es.Z,{label:"*"+g("ticket_coupon.qty"),type:"number",className:"textfield",value:T||"",onChange:e=>{e.stopPropagation(),H({qty:e.target.value})},error:!!_.qty,helperText:!!_.qty&&g("required_field"),disabled:!!i})]}),(0,r.jsx)(es.Z,{label:g("ticket_coupon.description"),value:M||"",onChange:e=>{e.stopPropagation(),H({description:e.target.value})},error:!!_.description}),(0,r.jsx)(es.Z,{label:g("ticket_coupon.obs"),value:O||"",multiline:!0,rows:2,onChange:e=>{e.stopPropagation(),H({obs:e.target.value})}}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(tM.Z,{clearable:!0,label:"Aplic\xe1vel somente a partir da data da visita",disablePast:!0,value:W||null,minDate:m?new Date(m):null,maxDate:h?new Date(h):null,onChange:e=>{H({applicableOnlyFromVisitDate:e})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"textfield"})}),(0,r.jsx)(tM.Z,{clearable:!0,label:"Aplic\xe1vel somente at\xe9 a data da visita",disablePast:!0,value:$||null,minDate:m?new Date(m):null,maxDate:h?new Date(h):null,onChange:e=>{H({applicableOnlyUntilVisitDate:e})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"textfield"}),shouldDisableDate:e=>!!W&&(0,tS.Z)(new Date(e||""),1)<new Date(W)})]}),!z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tM.Z,{label:g("ticket_coupon.expiration"),maxDate:new Date(h),onError:e=>D({..._,expireAt:!0}),value:R||null,onChange:e=>{H({expireAt:e})},renderInput:e=>(0,r.jsx)(es.Z,{...e}),disabled:!!i}),_.expireAt&&(0,r.jsx)(ti.Z,{error:!0,children:g("invalid_date")})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:16,flexWrap:"wrap"},children:[(0,r.jsx)(to.Z,{label:g("ticket_coupon.random_generate"),checked:!!F,onChange:e=>H({random:e,...e?{limitedByDocument:!1}:{}}),disabled:!!i||!!B}),(0,r.jsx)(to.Z,{label:g("ticket_coupon.limited_by_document"),checked:!!B,onChange:e=>H({limitedByDocument:e,...e?{random:!1}:{}}),disabled:!!i||!!F})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:s,children:g("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:Q,children:g("ticket_coupon.create")})]})]})]})})};var ih=a(4250);let iv=e=>{var t;let{onDone:a,onClose:n}=e,{t:s}=(0,p.$)("admin"),{storedState:i}=(0,o.oR)(),d=(null==i?void 0:null===(t=i.currentSelectedEvent)||void 0===t?void 0:t._id)||"",[c,u]=l.useState(""),[m,h]=l.useState(!1),[x,g]=l.useState(0),[j,f]=l.useState(0),[b,y]=l.useState(0),[N,k]=l.useState(0),[w,Z]=l.useState([]),C=l.useRef(null),S=j>0?Math.min(100,Math.round(x/j*100)):0,_=w.join("\n");l.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[w]);let D=l.useCallback(async()=>{let e=function(e){let t=new Set,a=[];for(let n of e.split(/[;\n\r]+/)){let e=n.trim();if(!e)continue;let s=e.toUpperCase();t.has(s)||(t.add(s),a.push(e))}return a}(c);if(!d){et.Am.error(s("ticket_coupon.cancel_event_required"));return}if(!e.length){et.Am.error(s("ticket_coupon.cancel_codes_required"));return}if(e.length>500){et.Am.error(s("ticket_coupon.cancel_codes_limit"));return}(0,em.Z)({text:s("ticket_coupon.cancel_confirm",{total:e.length}),confirmButtonText:s("ticket_coupon.cancel_confirm_button"),onConfirm:async()=>{h(!0),g(0),f(e.length),y(0),k(0),Z([]);let t=0,n=0,i=0,r=[];try{let c=function(e,t){let a=[];for(let n=0;n<e.length;n+=t)a.push(e.slice(n,n+t));return a}(e,40);for(let e of c){var l,o;let a=await J.ZP.post("/coupon/cancel-by-codes",{codes:e,eventId:d});if(null===(l=a.data)||void 0===l?void 0:l.error)throw Error(s("error_on_processing")+" \n\n"+(a.data.error.message||a.data.error));let c=a.data;for(let a of(t+=c.found||0,n+=c.cancelled||0,i+=e.length,c.items||[]))r.push((o=a,"cancelled"===o.status?"".concat(o.code," — ").concat(s("ticket_coupon.cancel_log_found")," — ").concat(s("ticket_coupon.cancel_log_cancelled")):"already_cancelled"===o.status?"".concat(o.code," — ").concat(s("ticket_coupon.cancel_log_found")," — ").concat(s("ticket_coupon.cancel_log_already")):"".concat(o.code," — ").concat(s("ticket_coupon.cancel_log_not_found"))));y(t),k(n),g(i),Z([...r])}r.push("",s("ticket_coupon.cancel_log_summary",{found:t,cancelled:n,total:e.length})),Z([...r]),et.Am.success(s("ticket_coupon.cancel_done")),ab.v.dispatch("refresh_coupom_table"),a()}catch(e){et.Am.error((0,ih.j)(e,s("error_on_processing")))}finally{h(!1)}}})},[c,d,a,s]);return(0,r.jsx)("div",{className:"coupon-form cancel-coupons-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:s("ticket_coupon.cancel_title"),onGoBack:m?()=>void 0:n}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"text.secondary",children:s("ticket_coupon.cancel_helper")}),(0,r.jsx)(es.Z,{multiline:!0,minRows:8,maxRows:16,fullWidth:!0,value:c,disabled:m,onChange:e=>u(e.target.value),placeholder:s("ticket_coupon.cancel_placeholder")}),(m||j>0)&&(0,r.jsxs)("div",{className:"cancel-progress",children:[(0,r.jsx)(a5.Z,{variant:m&&0===x?"indeterminate":"determinate",value:S}),(0,r.jsx)(a1.Z,{variant:"body2",sx:{mt:1},children:s("ticket_coupon.cancel_progress",{processed:x,total:j,percent:S,found:b,cancelled:N})})]}),_?(0,r.jsx)(es.Z,{inputRef:C,label:s("ticket_coupon.cancel_log_label"),multiline:!0,minRows:6,maxRows:12,fullWidth:!0,value:_,InputProps:{readOnly:!0}}):null,(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:n,disabled:m,children:s("close")}),(0,r.jsx)(v.Z,{variant:"contained",color:"error",onClick:D,disabled:m,children:s("ticket_coupon.cancel_submit")})]})]})]})})};var ix=a(32912);let ip=e=>{let{t}=(0,p.$)("admin"),{ticket:a,group:n,random:s,description:i,expireAt:d,eventId:c,discount:u,obs:m,totalQty:h,totalRedeemed:x}=e.coupon,{toggleLoader:g}=(0,ee.U2)(),{storedState:j,setStoredState:f}=(0,o.oR)(),{couponLimit:b=20,couponPage:y=0,couponSearch:N=""}=j,k=(0,ev.Nr)(N,300),{id:w,status:Z,setTaskId:C,title:S,starting:_,setTask:D}
1=n5({screen:"coupon-details"}),{data:E,isLoading:P,refresh:I}=(0,eh.Z)("/coupon/group/list?group=".concat(n,"&eventId=").concat(c,"&limit=").concat(b,"&page=").concat(y,"&search=").concat(k)),A=(null==E?void 0:E.coupons)||[],T=(null==E?void 0:E.numberOfItems)||0,R=l.useCallback(e=>{(0,em.Z)({text:t("ticket_coupon.delete?"),confirmButtonText:t("remove"),onConfirm:async()=>{try{g(!0,t("processing"));let a=await J.ZP.delete("/coupon",{data:{id:e}});if(g(),a.data.error)throw Error(t("error_on_processing")+" \n\n"+a.data.error.message);et.Am.success("".concat(t("success_on_processing"))),I(),ab.v.dispatch("refresh_coupom_table")}catch(e){et.Am.error(e.message)}}})},[]);async function L(){try{g(!0,"Preparando tabela para download");let{data:e}=await J.ZP.post("/task",{title:"Tabela de cupons - Grupo - ".concat(n),screen:"coupon-details",description:"Preparando tabela para download"}),t=localStorage.getItem(o.rR),a=t?JSON.parse(t):[];console.log("\uD83D\uDE80 ~ startDownloadFullTableCsv ~ storedTaskData:",a);let s=[...a.filter(t=>t.screen!==e.screen),e];console.log("\uD83D\uDE80 ~ startDownloadFullTableCsv ~ taskDatas:",s),localStorage.setItem(o.rR,JSON.stringify(s));let i=new URLSearchParams({eventId:c,group:n,search:N,taskId:e.id});C(e.id),console.log("\uD83D\uDE80 ~ startDownloadFullTableCsv ~ data:",e),await J.ZP.get("/coupon/download-full-table?".concat(i)),g()}catch(e){et.Am.error(e.message),g()}}async function q(){try{var e,a;g(!0,"Baixando tabela");let n=await J.ZP.get("/task/".concat(w,"/download"),{responseType:"blob"});if(g(),null==n?void 0:null===(e=n.data)||void 0===e?void 0:e.error)throw Error(t("error_on_processing")+"\n\n"+n.data.error.message);if(!(null==n?void 0:null===(a=n.headers)||void 0===a?void 0:a["content-disposition"]))throw Error("".concat(t("error_on_processing"),". Arquivo j\xe1 foi baixado, recarregue a p\xe1gina, gere de novo e tente novamente."));let s=window.URL.createObjectURL(n.data),i=document.createElement("a");i.href=s,i.target="_blank",i.rel="noopener noreferrer";let r=n.headers["content-disposition"].replace("attachment; filename='","").replace("'","");i.download=r,i.click(),D(e=>({...e,status:"completed"}))}catch(e){et.Am.error(e.message),g()}}async function M(){try{let e=new URLSearchParams({eventId:c,group:n,search:N});g(!0,"Baixando tabela");let a=await J.ZP.get("/coupon/download-table?".concat(e),{responseType:"blob"});if(g(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=s,i.target="_blank",i.rel="noopener noreferrer";let r=a.headers["content-disposition"].replace("attachment; filename='","").replace("'","");i.download=r,i.click()}catch(e){et.Am.error(e.message),g()}}return(0,r.jsxs)("div",{className:"coupon-details",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:t("ticket_coupon.details")}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.ticket"))}),": ",null==a?void 0:a.title]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.code"))}),": ",n]}),!!i&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.description"))}),": ",i]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.discount"))}),": ",u]}),!!d&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.expiration"))}),": ",(0,ej.p6)(d,"P")]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.qty"))}),": ",h]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.redeemeds"))}),": ",x]}),!!m&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"".concat(t("ticket_coupon.obs"))}),": ",m]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(eu,{className:"search",placeholder:"Pesquisar c\xf3digo",value:N||"",onChange:e=>f({couponSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(v.Z,{sx:{width:"100%",display:"block",mb:"1rem"},variant:"contained",onClick:M,children:"Exportar somente resgatados"}),(0,r.jsx)(v.Z,{sx:{width:"100%",display:"block",mb:"1rem"},variant:"contained",onClick:"waiting_download"===Z?q:L,disabled:_||"in_progress"===Z,children:"in_progress"===Z?"Gerando ".concat(S," para download..."):"waiting_download"===Z?"Pronto para baixar ".concat(S):"Exportar tabela completa"})]}),P&&(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"".concat(t("ticket_coupon.redeem_code"))}),(0,r.jsx)("th",{children:"".concat(t("ticket_coupon.redeemed"))}),(0,r.jsx)("th",{children:"".concat(t("ticket_coupon.redeemedAt"))}),(0,r.jsx)("th",{children:"Usado por"}),(0,r.jsx)("th",{children:"".concat(t("ticket.action"))})]})}),(0,r.jsx)("tbody",{children:null==A?void 0:A.map((e,t)=>{var a;let n=e.random?e.redeemed+"/1":x+"/"+h;return(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{children:[e.code," "]}),(0,r.jsx)("td",{children:n}),(0,r.jsx)("td",{children:(null==e?void 0:e.redeemedAt)?(0,ix.Z)(new Date(e.redeemedAt),"dd/MM/yyyy HH:mm:ss"):" - "}),(0,r.jsx)("td",{children:e.user?e.user.name+", "+(null===(a=e.user)||void 0===a?void 0:a.email):""}),(0,r.jsx)("td",{children:(0,r.jsx)(X.Z,{onClick:()=>R(e.id),disabled:"deleted"===e.status||1===e.redeemed,children:(0,r.jsx)(eg.Z,{})})})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:T,rowsPerPage:b,page:y,onPageChange:e=>f({couponPage:e}),resetPageOnFirstLoad:!0,onRowsPerPageChange:e=>f({couponPage:0,couponLimit:e})})]})]})},ig=()=>{let{t:e}=(0,p.$)("admin"),{setStoredState:t}=(0,o.oR)(),{coupons:a,couponId:n,addCoupon:s,editCoupon:i,removeCoupon:l,showCouponForm:d,closeCouponForm:c,showCancelForm:u,openCancelForm:m,closeCancelForm:h,refresh:x,isLoading:g,numberOfItems:j,ticketCouponLimit:f,ticketCouponPage:b,ticketCouponSearch:y,tickets:N,fetchingTickets:k,selectedTickets:w,ticketCouponIncludeGlobal:Z,setTicketFilter:C,setIncludeGlobalFilter:S,clearFilters:_,downloadTable:D}=io(),E=!!y||w.length>0||Z;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"professionals-and-suppliers coupons",children:[(0,r.jsxs)("div",{className:"row header-row",children:[(0,r.jsx)("h3",{children:"Cupons de desconto"}),(0,r.jsxs)("div",{className:"header-actions",children:[(0,r.jsx)(v.Z,{variant:"contained",onClick:D,children:"Download tabela"}),(0,r.jsx)(v.Z,{variant:"outlined",color:"error",onClick:m,children:"Cancelar cupons"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:s,children:"Adicionar cupom"})]})]}),(0,r.jsxs)("div",{className:"row filters-row",children:[(0,r.jsx)(eu,{className:"search",size:"small",placeholder:e("ticket_coupon.search"),value:y||"",onChange:e=>t({ticketCouponSearch:(null==e?void 0:e.target.value)||"",ticketCouponPage:0})}),(0,r.jsx)(e_.Z,{multiple:!0,size:"small",className:"ticket-filter",options:N,value:w,loading:k,disableCloseOnSelect:!0,getOptionLabel:e=>(null==e?void 0:e.title)||"",isOptionEqualToValue:(e,t)=>
1e.id===t.id,onChange:(e,t)=>C(t),renderInput:e=>(0,r.jsx)(es.Z,{...e,placeholder:"Filtrar por ingresso",size:"small"})}),(0,r.jsx)(to.Z,{label:"Cupons globais",checked:Z,onChange:S}),E&&(0,r.jsx)(v.Z,{variant:"text",onClick:_,children:"Limpar filtros"})]}),g?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!j&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:e("ticket_coupon.ticket")}),(0,r.jsx)("th",{children:e("ticket_coupon.code")}),(0,r.jsx)("th",{children:e("ticket_coupon.createdBy")}),(0,r.jsx)("th",{children:e("ticket_coupon.description")}),(0,r.jsx)("th",{children:e("ticket_coupon.discount")}),(0,r.jsx)("th",{children:e("ticket_coupon.qty")}),(0,r.jsx)("th",{children:e("ticket_coupon.days")}),(0,r.jsx)("th",{children:e("ticket_coupon.redeemed")}),(0,r.jsx)("th",{children:e("ticket_coupon.expiration")}),(0,r.jsx)("th",{children:e("ticket_coupon.obs")}),(0,r.jsx)("th",{children:e("ticket.action")})]})}),(0,r.jsx)("tbody",{children:null==a?void 0:a.map((e,t)=>{var a,n,s;return(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{children:[e.isGlobal?"Global — ".concat(e.description||""):null==e?void 0:null===(a=e.ticket)||void 0===a?void 0:a.title," "]}),(0,r.jsx)("td",{children:e.group}),(0,r.jsx)("td",{children:null===(n=e.lastUpdatedBy)||void 0===n?void 0:n.name}),(0,r.jsx)("td",{children:e.description}),(0,r.jsx)("td",{children:e.discount}),(0,r.jsx)("td",{children:e.totalQty}),(0,r.jsx)("td",{children:null===(s=e.availableDays)||void 0===s?void 0:s.map(e=>iu[e]).join(", ")}),(0,r.jsx)("td",{children:e.totalRedeemed}),(0,r.jsx)("td",{children:e.isGlobal?"Sem Expira\xe7\xe3o":e.expireAt?(0,ej.p6)(e.expireAt,"P"):null}),(0,r.jsx)("td",{children:e.obs}),(0,r.jsxs)("td",{width:150,children:[(0,r.jsx)(X.Z,{onClick:()=>i(e.group),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>l(e.group),children:(0,r.jsx)(eg.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(ip,{coupon:e})),children:(0,r.jsx)(nZ.Z,{})})]})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:j,rowsPerPage:f,page:b,onPageChange:e=>t({ticketCouponPage:e}),onRowsPerPageChange:e=>t({ticketCouponPage:0,ticketCouponLimit:e})})]}),(0,r.jsx)(K.ZP,{showAt:!!d,onClose:c,children:(0,r.jsx)(im,{id:n,onSave:()=>{x(),c()},onClose:c})}),(0,r.jsx)(K.ZP,{showAt:!!u,onClose:h,children:(0,r.jsx)(iv,{onDone:()=>{x()},onClose:h})})]})})};var ij=l.memo(ig);let ib=()=>{var e;let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),{storedState:n}=(0,o.oR)(),s=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketGiftcardLimit:i=20,ticketGiftcardPage:r=0,ticketGiftcardSearch:d=""}=n,c=(0,ev.Nr)(d,300),{data:u,isLoading:m,refresh:h}=(0,eh.Z)("/giftcard/list?limit=".concat(i,"&page=").concat(r,"&search=").concat(c,"&eventId=").concat(s)),v=(null==u?void 0:u.items)||[],x=(null==u?void 0:u.numberOfItems)||0,[g,j]=l.useState(!1);sI("refresh_giftcard_table",h);let f=l.useCallback(e=>{(0,em.Z)({text:t("ticket_giftcard.delete_all?"),confirmButtonText:t("remove"),onConfirm:async()=>{try{a(!0,t("processing"));let n=await J.ZP.delete("/giftcard",{data:{group:e}});if(a(),n.data.error)throw Error(t("error_on_processing")+" \n\n"+n.data.error.message);et.Am.success(t("success_on_processing")),h(),ab.v.dispatch("refresh_giftcard_table")}catch(e){et.Am.error(e.message)}}})},[]);async function b(){try{var e;a(!0,"Baixando tabela");let n=await J.ZP.get("/giftcard/list?eventId=".concat(s));if(n.data.error)throw Error(t("error_on_processing")+"\n\n"+n.data.error.message);a(!0,"Gerando tabela"),console.log(n.data);let i={Ingresso:{selector:"ticket.title"},"C\xf3digo grupo":{selector:"code"},Descricao:{selector:"description"},"Desconto(%)":{selector:"discount"},"Quantidade dispon\xedvel":{selector:"totalQty"},Resgatado:{selector:"redeemed"},"Data de expira\xe7\xe3o":{selector:"expireAt",formatValue:e=>(0,ej.p6)(e,"dd/MM/yyyy")},Observação:{selector:"obs"}},r=null===(e=n.data.items)||void 0===e?void 0:e.map(e=>{let t={};return Object.keys(i).map(a=>{let n;let{selector:s,formatValue:r}=i[a];s.split(".").map(t=>{n=(n||e)[t]}),r&&(n=r(n)),t[a]=n}),t}),l=t0.P6.json_to_sheet(r),o=(0,t0.cW)({Sheets:{data:l},SheetNames:["data"]},{bookType:"xlsx",type:"array",cellDates:!0}),d=new Blob([o],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(d,"Cupons.xlsx"),a()}catch(e){a()}}return{eventId:s,giftcards:v,addGiftcard:function(){j(!0)},removeGiftcard:f,showGiftcardForm:g,closeGiftcardForm:function(){j(!1)}
1,refresh:h,isLoading:m,numberOfItems:x,ticketGiftcardLimit:i,ticketGiftcardPage:r,ticketGiftcardSearch:d,downloadTable:b}},iy={0:"Domingo",1:"Segunda-Feira",2:"Ter\xe7a-Feira",3:"Quarta-Feira",4:"Quinta-Feira",5:"Sexta-Feira",6:"S\xe1bado"},iN=e=>{let{onSave:t,onClose:a}=e,{storedState:n}=(0,o.oR)(),{_id:s,endAt:i}=(null==n?void 0:n.currentSelectedEvent)||{},{toggleLoader:d}=(0,ee.U2)(),{t:c}=(0,p.$)("admin"),[u,m]=l.useState({}),[h,x]=l.useState(!1),[g,j]=l.useState([]),[f,b]=l.useState({}),{qty:y,expireAt:N,code:k,discount:w,description:Z,obs:C,random:S,availableDays:_=[]}=u;function D(e){m(t=>({...t,...e}))}async function E(){try{let e={};if(b(e),y||(e.qty=!0),k||(e.code=!0),w||(e.discount=!0),Object.keys(e).length)return b(e),et.Am.error(c("incomplete_form"));d(!0,c("processing"));let a=await J.ZP.post("/giftcard",{qty:y,eventId:s,expireAt:N,code:k,discount:w,description:Z,obs:C,random:S,availableDays:_});if(d(),a.data.error)throw Error(c("error_on_processing")+" \n\n"+a.data.error.message);t(),et.Am.success(c("success_on_processing"))}catch(e){d(),et.Am.error(e.message)}}return l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list?"+new URLSearchParams({event_id:s||"",limit:"100",admin:"true"}),onProcessing:x,onSuccess:e=>j(null==e?void 0:e.tickets),onError:e=>{et.Am.error(e.message)}})}s&&e()},[s]),(0,r.jsx)("div",{className:"add-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:c("ticket_giftcard.new"),onGoBack:e.onClose}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("label",{children:"Selecione os dias v\xe1lidos para este cart\xe3o de presente:"}),(0,r.jsx)("div",{className:"available-days",children:Object.keys(iy).map(e=>{let t=parseInt(e),a=iy[t];return(0,r.jsx)(to.Z,{checked:_.includes(t),label:a,onChange:e=>{let a=[..._];
1e?(a.push(t),D({availableDays:[...new Set(a)]})):D({availableDays:a.filter(e=>e!==t)})}},t)})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(es.Z,{label:"*"+c("ticket_giftcard.code"),value:k||"",className:"textfield",onChange:e=>{e.stopPropagation(),D({code:e.target.value.toUpperCase()})},error:!!f.code,helperText:!!f.code&&c("required_field")}),(0,r.jsx)(es.Z,{label:"*"+c("ticket_giftcard.discount"),type:"number",className:"textfield",value:w||"",onChange:e=>{e.stopPropagation(),D({discount:e.target.value})},error:!!f.discount,helperText:!!f.discount&&c("required_field")}),(0,r.jsx)(es.Z,{label:"*"+c("ticket_giftcard.qty"),type:"number",className:"textfield",value:y||"",onChange:e=>{e.stopPropagation(),D({qty:e.target.value})},error:!!f.qty,helperText:!!f.qty&&c("required_field")})]}),(0,r.jsx)(es.Z,{label:c("ticket_giftcard.description"),value:Z||"",onChange:e=>{e.stopPropagation(),D({description:e.target.value})},error:!!f.description}),(0,r.jsx)(es.Z,{label:c("ticket_giftcard.obs"),value:C||"",multiline:!0,rows:2,onChange:e=>{e.stopPropagation(),D({obs:e.target.value})}}),(0,r.jsx)(tM.Z,{label:c("ticket_giftcard.expiration"),maxDate:new Date(i),onError:e=>b({...f,expireAt:!0}),value:N||null,onChange:e=>{D({expireAt:e})},renderInput:e=>(0,r.jsx)(es.Z,{...e})}),f.expireAt&&(0,r.jsx)(ti.Z,{error:!0,children:c("invalid_date")}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:a,children:c("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:E,children:c("ticket_giftcard.create")})]})]})]})})},ik=e=>{let{t}=(0,p.$)("admin"),{ticket:a,group:n,random:s,description:i,expireAt:d,eventId:c,discount:u,obs:m,totalQty:h,totalRedeemed:x}=e.giftcard,{toggleLoader:g}=(0,ee.U2)(),{storedState:j,setStoredState:f}=(0,o.oR)(),{giftcardLimit:b=20,giftcardPage:y=0,giftcardSearch:N=""}=j,k=(0,ev.Nr)(N,300),{data:w,isLoading:Z,refresh:C}=(0,eh.Z)("/giftcard/group/list?group=".concat(n,"&eventId=").concat(c,"&limit=").concat(b,"&page=").concat(y,"&search=").concat(k)),S=w.giftcards||[],_=w.numberOfItems,D=l.useCallback(e=>{(0,em.Z)({text:t("ticket_giftcard.delete?"),confirmButtonText:t("remove"),onConfirm:async()=>{try{g(!0,t("processing"));let a=await J.ZP.delete("/giftcard",{data:{id:e}});if(g(),a.data.error)throw Error(t("error_on_processing")+" \n\n"+a.data.error.message);et.Am.success(t("success_on_processing")),C(),ab.v.dispatch("refresh_giftcard_table")}catch(e){et.Am.error(e.message)}}})},[]);async function E(){try{var e;let a=new URLSearchParams({eventId:c,group:n,page:"0",limit:"1000000"});g(!0,"Baixando tabela");let s=await J.ZP.get("/giftcard/group/list?"+a);if(s.data.error)throw Error(t("error_on_processing")+"\n\n"+s.data.error.message);g(!0,"Gerando tabela");let i={Ingresso:{selector:"ticket.title"},"Cupom grupo":{selector:"group"},"C\xf3digo resgate":{selector:"code"},Descrição:{selector:"description"},"Desconto(%)":{selector:"discount"},"Quantidade dispon\xedvel":{selector:"qty"},Resgatado:{selector:"redeemed"},Observação:{selector:"obs"},"Data cria\xe7\xe3o":{selector:"createdAt",formatValue:e=>(0,ej.p6)(e,"Pp")},"Data expira\xe7\xe3o":{selector:"expireAt",formatValue:e=>(0,ej.p6)(e,"Pp")},"Usado por":{selector:"user.name"},Email:{selector:"user.email"},"Data utiliza\xe7\xe3o":{selector:"updatedAt",formatValue:e=>(0,ej.p6)(e,"Pp")}},r=null===(e=s.data.giftcards)||void 0===e?void 0:e.map(e=>{let t={};return Object.keys(i).map(a=>{let n;let{selector:s,formatValue:r}=i[a];s.split(".").map(t=>{n=(n||e)[t]}),r&&(n=r(n)),t[a]=n}),t}),l=t0.P6.json_to_sheet(r),o=(0,t0.cW)({Sheets:{data:l},SheetNames:["data"]},{bookType:"xlsx",type:"array",cellDates:!0}),d=new Blob([o],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(d,"Tabela Cupons "+n+".xlsx"),g()}catch(e){g()}}return(0,r.jsxs)("div",{className:"giftcard-details",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:t("ticket_giftcard.details")}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.ticket")}),": ",null==a?void 0:a.title]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.code")}),": ",n]}),!!i&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.description")}),": ",i]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.discount")}
1),": ",u]}),!!d&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.expiration")}),": ",(0,ej.p6)(d,"P")]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.qty")}),": ",h]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.redeemeds")}),": ",x]}),!!m&&(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:t("ticket_giftcard.obs")}),": ",m]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(eu,{className:"search",placeholder:"Pesquisar c\xf3digo",value:N||"",onChange:e=>f({giftcardSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:E,children:"Exportar tabela"})]}),Z&&(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:t("ticket_giftcard.redeem_code")}),(0,r.jsx)("th",{children:t("ticket_giftcard.redeemed")}),(0,r.jsx)("th",{children:"Usado por"}),(0,r.jsx)("th",{children:t("ticket.action")})]})}),(0,r.jsx)("tbody",{children:null==S?void 0:S.map((e,t)=>{var a;let n=e.random?e.redeemed+"/1":x+"/"+h;return(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{children:[e.code," "]}),(0,r.jsx)("td",{children:n}),(0,r.jsx)("td",{children:e.user?e.user.name+", "+(null===(a=e.user)||void 0===a?void 0:a.email):""}),(0,r.jsx)("td",{children:(0,r.jsx)(X.Z,{onClick:()=>D(e.id),disabled:"deleted"===e.status||1===e.redeemed,children:(0,r.jsx)(eg.Z,{})})})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:_,rowsPerPage:b,page:y,onPageChange:e=>f({giftcardPage:e}),resetPageOnFirstLoad:!0,onRowsPerPageChange:e=>f({giftcardPage:0,giftcardLimit:e})})]})]})},iw=()=>{let{t:e}=(0,p.$)("admin"),{setStoredState:t}=(0,o.oR)(),{giftcards:a,addGiftcard:n,removeGiftcard:s,showGiftcardForm:i,closeGiftcardForm:l,refresh:d,isLoading:c,numberOfItems:u,ticketGiftcardLimit:m,ticketGiftcardPage:h,ticketGiftcardSearch:x,downloadTable:g}=ib();return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"professionals-and-suppliers giftcards",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("h3",{children:"Cart\xe3o presente"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:n,children:"Adicionar"})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(eu,{className:"search",placeholder:e("ticket_giftcard.search"),value:x||"",onChange:e=>t({ticketGiftcardSearch:(null==e?void 0:e.target.value)||""})})}),c?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!u&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:e("ticket_giftcard.code")}),(0,r.jsx)("th",{children:e("ticket_giftcard.description")}),(0,r.jsx)("th",{children:e("ticket_giftcard.discount")}),(0,r.jsx)("th",{children:e("ticket_giftcard.qty")}),(0,r.jsx)("th",{children:e("ticket_giftcard.days")}),(0,r.jsx)("th",{children:e("ticket_giftcard.redeemed")}),(0,r.jsx)("th",{children:e("ticket_giftcard.expiration")}),(0,r.jsx)("th",{children:e("ticket_giftcard.obs")}),(0,r.jsx)("th",{children:e("ticket.action")})]})}),(0,r.jsx)("tbody",{children:null==a?void 0:a.map((e,t)=>{var a;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.group}),(0,r.jsx)("td",{children:e.description}),(0,r.jsx)("td",{children:e.discount}),(0,r.jsx)("td",{children:e.totalQty}),(0,r.jsx)("td",{children:null===(a=e.availableDays)||void 0===a?void 0:a.map(e=>iy[e]).join(", ")}),(0,r.jsx)("td",{children:e.totalRedeemed}),(0,r.jsx)("td",{children:e.expireAt?(0,ej.p6)(e.expireAt,"P"):null}),(0,r.jsx)("td",{children:e.obs}),(0,r.jsxs)("td",{width:150,children:[(0,r.jsx)(X.Z,{onClick:()=>s(e.group),children:(0,r.jsx)(eg.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(ik,{giftcard:e})),children:(0,r.jsx)(nZ.Z,{})})]})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:u,rowsPerPage:m,page:h,onPageChange:e=>t({ticketGiftcardPage:e}),onRowsPerPageChange:e=>t({ticketGiftcardPage:0,ticketGiftcardLimit:e})})]}),(0,r.jsx)(K.ZP,{showAt:!!i,onClose:l,children:(0,r.jsx)(iN,{onSave:()=>{d(),l()},onClose:l})})]})})};var iZ=l.memo(iw),iC=a(53416);let iS=ar().create({baseURL:"https://api-general.appcasacor.com.br"});iS.interceptors.request.use(async e=>{let t=(0,as.parseCookies)(),a=t[d.Y5];return a&&e.headers&&(e.headers.Authorization="Bearer ".concat(a)),e}),iS.interceptors.response.use(e=>{var t,a;return(null===(t=e.data)||void 0===t?void 0:null===(a=t.error)||void 0===a?void 0:a.message)==="No token provided"&&ab.v.dispatch("logout_user"),{data:e.data,headers:e.headers}},e=>{var t,a,n,s;return(console.log("API ERROR ==>",e),"Network Error"===e.message)?{data:{error:{message:"No momento n\xe3o podemos processar sua requisi\xe7\xe3o. Tente novamente em alguns segundos.",status:502}}}:((null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:null===(n=a.error)||void 0===n?void 0:n.message)==="No token provided"&&ab.v.dispatch("logout_user"),{data:null===(s=e.response)||void 0===s?void 0:s.data})});var i_=a(42699);let iD=e=>
1{let{onConfirm:t,selectedSellStartDate:a,selectedSellEndDate:n}=e,{t:s}=(0,p.$)("admin"),[i,o]=l.useState([]),[d,c]=l.useState(null),[u,m]=l.useState(null),[h,x]=l.useState({});return(0,r.jsx)("div",{className:"ticket-edit-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Adicione os per\xedodo(s) de data(s) de venda que deseja excluir dentro do per\xedodo selecionado (".concat((0,ix.Z)(a,"dd/MM/yyyy")," - ").concat((0,ix.Z)(n,"dd/MM/yyyy"),")?"),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",style:{position:"relative",width:"36%"},children:[(0,r.jsx)(tM.Z,{label:"Data venda - in\xedcio",className:"input",value:d||null,minDate:a,maxDate:n,onChange:e=>c(e?new Date(e).toString():null),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:h.sellStartDate||h.startDate,fullWidth:!0})}),!!d&&(0,r.jsx)(X.Z,{style:{position:"absolute",top:8,right:35},onClick:()=>c(null),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",style:{position:"relative",width:"36%"},children:[(0,r.jsx)(tM.Z,{label:"Data venda - fim",className:"input",shouldDisableDate:e=>!!d&&(0,tS.Z)(new Date(e),1)<new Date(d),value:u||null,minDate:d||a,maxDate:n,onChange:e=>m(e?new Date(e).toString():null),renderInput:e=>(0,r.jsx)(es.Z,{error:h.sellEndDate,...e,fullWidth:!0})}),!!u&&(0,r.jsx)(X.Z,{style:{position:"absolute",top:8,right:35},onClick:()=>m(null),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)("div",{className:"actions",style:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:0},children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>{if(!d||!u){x({sellStartDate:!d,sellEndDate:!u});return}o([...i,{sellStartDate:d,sellEndDate:u}]),c(null),m(null)},fullWidth:!0,children:"".concat(s("add"))})})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Data Venda - In\xedcio"}),(0,r.jsx)("th",{children:"Data Venda - Fim"}),(0,r.jsx)("th",{children:"".concat(s("action"))})]})}),(0,r.jsx)("tbody",{children:i.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(null==e?void 0:e.sellStartDate)?(0,ix.Z)(new Date(e.sellStartDate),"dd/MM/yyyy"):"-"}),(0,r.jsx)("td",{children:(null==e?void 0:e.sellEndDate)?(0,ix.Z)(new Date(e.sellEndDate),"dd/MM/yyyy"):"-"}),(0,r.jsx)("td",{children:(0,r.jsx)(X.Z,{onClick:()=>{o(i.filter((e,a)=>a!==t))},children:(0,r.jsx)(ec.Z,{})})})]},t))})]})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"".concat(s("cancel"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>t(i),children:"".concat(s("confirm"))})]})]})]})})};var iE=a(13263);let iP=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n}=(0,o.oR)(),{toggleLoader:s}=(0,ee.U2)(),[i,d]=(0,l.useState)(),[c,u]=(0,l.useState)({items:[],numberOfItems:0}),[m,h]=(0,l.useState)(!1),{onListenerEndpoint:v,clearListener:x,response:g,error:j}=(0,iE.Z)(),f=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketsLimit:b=20,ticketsPage:y=0,ticketsFilter:N}=n;async function k(){s(!0,"O processamento est\xe1 demorando mais que o esperado. Aguarde mais alguns instantes.");let e=localStorage.getItem(o.cp);v("/task/".concat(e))}let w=(0,l.useCallback)(function(){let{ticketsFilterParams:e,ticketsPageParams:t,ticketsLimitParams:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(async()=>{try{if(!f)return;let n=e?e[f]:(null==N?void 0:N[f])||{};if(0===Object.keys(n).length)return;h(!0);let s=(0,iC.x0)();localStorage.setItem(o.cp,s);let{withCompensations:i,...r}=n,l=new URLSearchParams({...r,eventId:f,page:"number"==typeof t?t:y,limit:"number"==typeof a?a:b,requestId:s,withCompensations:!0===i?"true":"false"}),d=await J.ZP.get("/ticket-purchase/list-table?".concat(l));if(d.data.error){if(502===d.data.error.status){k();return}return h(!1),et.Am.error(d.data.error.message)}u(d.data),h(!1)}catch(e){if(console.log("\uD83D\uDE80 ~ onLoadData ~ error:",e),502===e.status){k();return}h(!1),s()}})()},[N,y,b,f,s]),Z=async e=>{try{s(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("/ticket-purchase/resend-email/order/".concat(e)),et.Am.success("Ingressos enviados no email com sucesso!"),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},C=async e=>{try{s(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("ticket-purchase/resend-email/order-multi-files/".concat(e)),et.Am.success("Ingressos enviados em m\xfaltiplos arquivos com sucesso!"),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},S=async e=>{try{(0,em.Z)({title:"Enviar ingressos comprados no email",text:"Como deseja que os arquivos de ingressos comprados sejam enviados?",confirmButtonText:"Enviar em um arquivo",cancelButtonText:"Enviar em m\xfaltiplos arquivos",onConfirm:()=>{Z(e)},onCancel:()=>{C(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};async function _(e){let{link:t,fileName:a}=e;try{console.log("\uD83D\uDD17 Link recebido:",t);let e=localStorage.getItem(o.cp);if(!e){et.Am.error("Erro ao baixar ingressos comprados em m\xfaltiplos arquivos, tente novamente.");return}if(!t||"string"!=typeof t||""===t.trim()){et.Am.error("Link inv\xe1lido para download dos arquivos.");return}(0,em.Z)({title:"Arquivo gerado com sucesso",text:"Arquivo de ingressos comprados em PDF de m\xfaltiplos arquivos gerado com sucesso",confirmButtonText:"Baixar",onConfirm:()=>{s();try{console.log("\uD83D\uDE80 Tentando baixar arquivo com link:",t);let n=document.createElement("a");n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.download=a,n.style.display="none",document.body.appendChild(n),n.click(),console.log("✅ Clique executado no link"),setTimeout(()=>{document.body.contains(n)&&document.body.removeChild(n)},100),J.ZP.delete("/task/".concat(e))}catch(e){console.error("❌ Erro ao tentar baixar arquivo:",e),et.Am.error("Erro ao baixar arquivo. Tente novamente.")}},onCancel:()=>{s(),J.ZP.delete("/task/".concat(e))}})}catch(a){var n,i,r,l,d,c,u,m,h,v;if(console.log(a),s(),"string"==typeof(null==a?void 0:null===(n=a.response)||void 0===n?void 0:null===(i=n.data)||void 0===i?void 0:i.error))return et.Am.error(null==a?void 0:null===(h=a.response)||void 0===h?void 0:null===(v=h.data)||void 0===v?void 0:v.error);let e=(null==a?void 0:null===(r=a.response)||void 0===r?void 0:null===(l=r.request)||void 0===l?void 0:l._response)||(null==a?void 0:null===(d=a.response)||void 0===d?void 0:null===(c=d.request)||void 0===c?void 0:c.response)||(null==a?void 0:null===(u=a.response)||void 0===u?void 0:null===(m=u.request)||void 0===m?void 0:m.responseText),t=e&&JSON.parse(e);"string"==typeof(null==t?void 0:t.message)&&et.Am.error(t.message)}}async function D(e){try{s(!0,"Gerando download de ingressos comprados em PDF de m\xfaltiplos arquivos...");let t=(0,iC.x0)();localStorage.setItem(o.cp,t);let a=await J.ZP.get("/order/download-tickets-pdf-multi-files/".concat(e,"?requestId=").concat(t));if(a.data.error){if(502===a.data.error.status){k();return}return h(!1),s(),et.Am.error(a.data.error.message)}if(!a.data.fileLink){console.error("❌ fileLink n\xe3o encontrado na resposta:",a.data),et.Am.error("Link de download n\xe3o encontrado na resposta do servidor."),s();return}_({link:a.data.fileLink,fileName:a.data.fileName})}catch(e){console.error("❌ Erro na requisi\xe7\xe3o:",e),et.Am.error(e.message),console.log(e),s()}}async function E(e){try{s(!0,"Gerando ingressos comprados em PDF");let a=await J.ZP.get("/ticket-purchase/download/".concat(e),{responseType:"blob"});if(s(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let n=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=n,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){s()}}let P=async e=>{let{orderId:t,ticketPurchaseId:a}=e;try{(0,em.Z)({title:"Download de PDF de ingressos comprados",text:"Como deseja que os arquivos de ingressos comprados sejam baixados?",confirmButtonText:"Baixar em um arquivo PDF",cancelButtonText:"Gerar download em m\xfaltiplos arquivos PDF zipados",onConfirm:()=>{E(a)},onCancel:()=>{D(t)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};
1async function I(){try{s(!0,"Baixando relat\xf3rio...");let e=await J.ZP.get("/task/".concat(i,"/download"));if(s(),e.data.error)throw Error(t("error_on_processing")+"\n\n"+e.data.error.message);let a=window.URL.createObjectURL(new Blob([e.data])),n=document.createElement("a");n.href=a;let r=e.headers["content-disposition"].replace("attachment; filename='","").replace("'","");n.target="_blank",n.rel="noopener noreferrer",n.download=r,n.click(),n.remove()}catch(h){var e,a,n,r,l,o,d,c,u,m;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(e=h.response)||void 0===e?void 0:null===(a=e.data)||void 0===a?void 0:a.error))return et.Am.error(null==h?void 0:null===(u=h.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.error);let t=(null==h?void 0:null===(n=h.response)||void 0===n?void 0:null===(r=n.request)||void 0===r?void 0:r._response)||(null==h?void 0:null===(l=h.response)||void 0===l?void 0:null===(o=l.request)||void 0===o?void 0:o.response)||(null==h?void 0:null===(d=h.response)||void 0===d?void 0:null===(c=d.request)||void 0===c?void 0:c.responseText),i=t&&JSON.parse(t);"string"==typeof(null==i?void 0:i.message)&&et.Am.error(i.message)}}async function A(){let{sellStartDate:e,sellEndDate:t}=(null==N?void 0:N[f])||{},a=e&&new Date(e),n=t?new Date(t):new Date;if((0,i_.Z)(n,a)){(0,em.Z)({text:"Deseja excluir per\xedodo(s) de data(s) de venda dentro do per\xedodo selecionado (".concat((0,ix.Z)(a,"dd/MM/yyyy")," - ").concat((0,ix.Z)(n,"dd/MM/yyyy"),")?"),cancelButtonText:"N\xe3o",confirmButtonText:"Sim",onConfirm:async()=>{(0,K.K4)((0,r.jsx)(iD,{selectedSellStartDate:a,selectedSellEndDate:n,onConfirm:async e=>{try{let t=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset(),excludesSellDates:JSON.stringify(e)});t.forEach((e,a)=>{""==e&&t.delete(a)}),s(!0,"Gerando relat\xf3rio");let a=await J.ZP.get("/ticket-purchase/download-table?"+t);d(a.data.taskId),v("/task/".concat(a.data.taskId)),(0,K.Mr)()}catch(h){var t,a,n,i,r,l,o,c,u,m;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(t=h.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.error))return et.Am.error(null==h?void 0:null===(u=h.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.error);let e=(null==h?void 0:null===(n=h.response)||void 0===n?void 0:null===(i=n.request)||void 0===i?void 0:i._response)||(null==h?void 0:null===(r=h.response)||void 0===r?void 0:null===(l=r.request)||void 0===l?void 0:l.response)||(null==h?void 0:null===(o=h.response)||void 0===o?void 0:null===(c=o.request)||void 0===c?void 0:c.responseText),d=e&&JSON.parse(e);"string"==typeof(null==d?void 0:d.message)&&et.Am.error(d.message)}},onClose:()=>{(0,K.Mr)()}}))},onCancel:async()=>{try{let e=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset()});e.forEach((t,a)=>{""==t&&e.delete(a)}),s(!0,"Gerando relat\xf3rio");let t=await J.ZP.get("/ticket-purchase/download-table?"+e);d(t.data.taskId),v("/task/".concat(t.data.taskId))}catch(h){var e,t,a,n,i,r,l,o,c,u;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(e=h.response)||void 0===e?void 0:null===(t=e.data)||void 0===t?void 0:t.error))return et.Am.error(null==h?void 0:null===(c=h.response)||void 0===c?void 0:null===(u=c.data)||void 0===u?void 0:u.error);let d=(null==h?void 0:null===(a=h.response)||void 0===a?void 0:null===(n=a.request)||void 0===n?void 0:n._response)||(null==h?void 0:null===(i=h.response)||void 0===i?void 0:null===(r=i.request)||void 0===r?void 0:r.response)||(null==h?void 0:null===(l=h.response)||void 0===l?void 0:null===(o=l.request)||void 0===o?void 0:o.responseText),m=d&&JSON.parse(d);"string"==typeof(null==m?void 0:m.message)&&et.Am.error(m.message)}}});return}try{let e=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset()});e.forEach((t,a)=>{""==t&&e.delete(a)}),s(!0,"Gerando relat\xf3rio");let t=await J.ZP.get("/ticket-purchase/download-table?"+e);d(t.data.taskId),v("/task/".concat(t.data.taskId))}catch(a){var i,l,o,c,u,m,h,x,p,g;if(console.log(a),s(),"string"==typeof(null==a?void 0:null===(i=a.response)||void 0===i?void 0:null===(l=i.data)||void 0===l?void 0:l.error))return et.Am.error(null==a?void 0:null===(p=a.response)||void 0===p?void 0:null===(g=p.data)||void 0===g?void 0:g.error);let e=(null==a?void 0:null===(o=a.response)||void 0===o?void 0:null===(c=o.request)||void 0===c?void 0:c._response)||(null==a?void 0:null===(u=a.response)||void 0===u?void 0:null===(m=u.request)||void 0===m?void 0:m.response)||(null==a?void 0:null===(h=a.response)||void 0===h?void 0:null===(x=h.request)||void 0===x?void 0:x.responseText),t=e&&JSON.parse(e);"string"==typeof(null==t?void 0:t.message)&&et.Am.error(t.message)}}async function T(e){try{s(!0,"Gerando PDF de Border\xf4 da Bilheteria");let a=new URLSearchParams({...e,eventId:f}),n=await iS.get("ticket-purchase/download-tickets-office-report-pdf?".concat(a),{responseType:"blob"});if(s(),n.data.error)throw Error(t("error_on_processing")+"\n\n"+n.data.error.message);let i=n.headers["content-disposition"].replace('attachment; filename="',"").replace('"',""),r=window.URL.createObjectURL(n.data),l=document.createElement("a");l.href=r,l.target="_blank",l.rel="noopener noreferrer",l.download=i,l.click()}catch(e){s()}}(0,l.useEffect)(()=>
1{if(g&&!("error"in g)){if(console.log("\uD83D\uDE80 ~ useEffect ~ taskResponse:",g),"in_progress"===g.status&&"list-table-ticket-purchase"===g.screen){s(!0,"Ainda estamos processando. Aguarde mais alguns instantes.");return}if("completed"===g.status&&"list-table-ticket-purchase"===g.screen){u(g.dataResult),h(!1),s(),x();return}if("waiting_download"===g.status){if("download-csv-ticket-purchase"===g.screen){console.log("\uD83D\uDE80 ~ useEffect ~ taskResponse: download-csv-ticket-purchase",g),I(),x();return}if("download-pdf-tickets-multi-files"===g.screen){_({link:g.filePath,fileName:g.fileName}),x();return}}}},[g]);let R=async e=>{try{s(!0,"Atualizando transa\xe7\xe3o..."),await J.ZP.get("/payment/updateStatus/".concat(e)),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ updateStatusOrder ~ error:",e)}};return{items:(null==c?void 0:c.items)||[],numberOfItems:(null==c?void 0:c.numberOfItems)||0,isLoading:m,ticketsLimit:b,ticketsPage:y,onDownloadOrderTicketsPdf:E,downloadOrderTicketsPdf:P,resendTicketOrderEmail:S,downloadTable:A,downloadTicketsOfficeReportPdf:T,updateStatusOrder:R,onLoadData:w}};var iI=a(42249);let iA={active:"Ativo",cancelled:"Cancelado"},iT={WAITING_PAYMENT:"Aguardando pagamento",IN_ANALYSIS:"Pagamento em an\xe1lise",PAID:"Pago",DECLINED:"Pagamento recusado",PIX_EXPIRED:"Pix expirado",PAYMENT_REFUNDED:"Pagamento estornado",CANCELED:"Cancelado"},iR=e=>{let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),[n,s]=l.useState({}),[i,o]=l.useState({}),{updatedAt:d,lastUpdatedBy:c}=e.item,{date:u,orderStatus:m,status:h,time:x,user:g}=n;async function j(){try{var s,i;let r={};if(o(r),(null===(s=n.user)||void 0===s?void 0:s.name)||(r.useName=!0),(null===(i=n.user)||void 0===i?void 0:i.email)||(r.useEmail=!0),n.time||(r.time=!0),n.orderStatus||(r.orderStatus=!0),n.date||(r.date=!0),Object.keys(r).length)return o(r),et.Am.error(t("form_incomplete"));a(!0,t("processing"));let l=await J.ZP.put("/ticket-purchase",n);if(l.data.error)throw Error(l.data.error.message);a(),e.onClose()}catch(e){console.log(JSON.stringify(e,null,2)),a(),et.Am.error(e.message)}}return l.useEffect(()=>{s({id:e.item.id,user:e.item.user,date:e.item.date,time:e.item.time,status:e.item.status,orderStatus:e.item.orderStatus})},[e.item]),(0,r.jsx)("div",{className:"ticket-edit-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Editar ingresso",onGoBack:K.Mr,data:{updatedAt:d,lastUpdatedBy:c}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{className:"textfield",label:"Nome usu\xe1rio",value:(null==g?void 0:g.name)||"",onValueChange:e=>s(t=>({...t,user:{...t.user,name:e}}))}),(0,r.jsx)(ah.Z,{className:"textfield",label:"Email usu\xe1rio",value:(null==g?void 0:g.email)||"",type:"email",onValueChange:e=>s(t=>({...t,user:{...t.user,email:e}}))})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(a7.Z,{label:"Data visita",minutesStep:30,value:u||null,onChange:e=>{if(!e||!x)return;let t=new Date(e).toISOString(),a=new Date(e).toTimeString().slice(0,5)+"-"+x.split("-")[1];s(e=>({...e,date:t,time:a}))},renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:i.sellStartDate,error:!!i.sellStartDate})})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(am.Z,{label:"Status",className:"select",disabled:!0,options:Object.keys(iA).map(e=>({label:iA[e],value:e})),value:h,onChange:e=>s(t=>({...t,status:e}))}),(0,r.jsx)(am.Z,{label:"Status do pedido",className:"select",options:Object.keys(iT).map(e=>({label:iT[e],value:e})),value:m,onChange:e=>s(t=>({...t,orderStatus:e,status:["WAITING_PAYMENT","IN_ANALYSIS","PAID"].includes(e)?"active":"cancelled"}))})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:t("event.close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:j,children:t("save")})]})]})]})})},iL=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),{toggleLoader:n}=(0,ee.U2)(),[s,i]=(0,l.useState)({items:[],numberOfItems:0}),[r,d]=(0,l.useState)(!1),{onListenerEndpoint:c,clearListener:u,response:m,error:h}=(0,iE.Z)(),{_id:v,slug:x}=(null==a?void 0:a.currentSelectedEvent)||{},{ordersLimit:g=20,ordersPage:j=0,ordersFilter:f}=a;async function b(){n(!0,"O processamento est\xe1 demorando mais que o esperado. Aguarde mais alguns instantes.");let e=localStorage.getItem(o.cp);c("/task/".concat(e))}new URLSearchParams({...(null==f?void 0:f[v])||{},eventId:v,page:j,limit:g});let y=(0,l.useCallback)(function(){let{ordersFilterParams:e,ordersPageParams:t,ordersLimitParams:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(async()=>{try{if(!v)return;let s=e?e[v]:(null==f?void 0:f[v])||{};if(0===Object.keys(s).length)return;d(!0),n(!0,"Carregando dados...");let r=(0,iC.x0)();localStorage.setItem(o.cp,r);let l=new URLSearchParams({...s,eventId:v,page:"number"==typeof t?t:j,limit:"number"==typeof a?a:g,requestId:r}),c=await J.ZP.get("/order/list-table?".concat(l));if(c.data.error){if(502===c.data.error.status){b();return}return d(!1),n(),et.Am.error(c.data.error.message)}i(c.data),d(!1),n()}catch(e){if(console.log("\uD83D\uDE80 ~ onLoadData ~ error:",e),502===e.status){b();return}d(!1),n()}})()},[f,j,g,v,n]);async function N(){try{n(!0,"Baixando relat\xf3rio...");let t=localStorage.getItem(o.cp),a=await J.ZP.get("/task/".concat(t,"/download"));if(n(),a.data.error)throw Error(e("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(new Blob([a.data])),i=document.createElement("a");i.href=s;let r=a.headers["content-disposition"].replace("attachment; filename='","").replace("'","");i.target="_blank",i.rel="noopener noreferrer",i.download=r,i.click(),i.remove()}catch(h){var t,a,s,i,r,l,d,c,u,m;if(console.log(h),n(),"string"==typeof(null==h?void 0:null===(t=h.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.error))return et.Am.error(null==h?void 0:null===(u=h.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.error);let e=(null==h?void 0:null===(s=h.response)||void 0===s?void 0:null===(i=s.request)||void 0===i?void 0:i._response)||(null==h?void 0:null===(r=h.response)||void 0===r?void 0:null===(l=r.request)||void 0===l?void 0:l.response)||(null==h?void 0:null===(d=h.response)||void 0===d?void 0:null===(c=d.request)||void 0===c?void 0:c.responseText),o=e&&JSON.parse(e);"string"==typeof(null==o?void 0:o.message)&&et.Am.error(o.message)}}async function k(){try{let e=(0,iC.x0)();localStorage.setItem(o.cp,e);let t=new URLSearchParams({...(null==f?void 0:f[v])||{},eventId:v,timezone:new Date().getTimezoneOffset(),requestId:e});t.forEach((e,a)=>{""==e&&t.delete(a)}),n(!0,"Gerando relat\xf3rio");let a=await J.ZP.get("/order/download-table?"+t);if(a.data.error){if(502===a.data.error.status){b();return}return d(!1),n(),et.Am.error(a.data.error.message)}N()}catch(e){if(console.log("\uD83D\uDE80 ~ downloadTable ~ error:",e),502===e.status){b();return}et.Am.error(e.message),n()}}async function w(t){try{n(!0,"Gerando ingressos comprados em PDF em m\xfaltiplos arquivos...");let a=await J.ZP.get("/order/download-tickets-pdf-multi-files/".concat(t),{responseType:"arraybuffer"});if(n(),a.data.error)throw Error(e("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(new Blob([a.data])),i=document.createElement("a");i.href=s;let r=a.headers["content-disposition"].replace("attachment; filename='","").replace("'","");i.target="_blank",i.rel="noopener noreferrer",i.download=r,i.click(),i.remove()}catch(e){et.Am.error(e.message),console.log(e),n()}}async function Z(t){try{n(!0,"Gerando ingressos comprados em PDF");let a=await J.ZP.get("/order/download-tickets-pdf/".concat(t),{responseType:"blob"});if(n(),a.data.error)throw Error(e("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=s,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){et.Am.error(e.message),n()}}(0,l.useEffect)(()=>
1{if(m&&!("error"in m)){if("in_progress"===m.status&&"list-table-order"===m.screen){n(!0,"Ainda estamos processando. Aguarde mais alguns instantes.");return}if("completed"===m.status&&"list-table-order"===m.screen){i(m.dataResult),d(!1),n(),u();return}"waiting_download"===m.status&&"download-csv-order"===m.screen&&(N(),u())}},[m]);let C=async e=>{try{(0,em.Z)({title:"Download de PDF de ingressos comprados",text:"Como deseja que os arquivos de ingressos comprados sejam baixados?",confirmButtonText:"Baixar em um arquivo PDF",cancelButtonText:"Baixar m\xfaltiplos arquivos PDF zipados",onConfirm:()=>{Z(e)},onCancel:()=>{w(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},S=async e=>{try{n(!0,"Cancelando transa\xe7\xe3o..."),await J.ZP.get("/card-machine-payment/cancel/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ cancelOrder ~ error:",e)}},_=async e=>{try{n(!0,"Cancelando transa\xe7\xe3o..."),await J.ZP.get("/order/cancel-free-order/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ cancelFreeOrder ~ error:",e)}},D=async e=>
1{try{n(!0,"Atualizando transa\xe7\xe3o..."),await J.ZP.get("/payment/updateStatus/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ updateStatusOrder ~ error:",e)}},E=async e=>{try{n(!0,"Enviando mensagem de compra estornada..."),await J.ZP.get("/order/send-refunded-to-whatsapp/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendRefundedToWhatsapp ~ error:",e)}},P=async e=>{try{n(!0,"Enviando mensagem de compra estornada..."),await J.ZP.get("/order/send-refunded-to-email/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendRefundedToEmail ~ error:",e)}},I=async e=>{try{n(!0,"Enviando ingressos comprados no whatsapp..."),await J.ZP.get("/order/send-pdf-to-whatsapp/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendToWhatsapp ~ error:",e)}},A=async e=>{try{n(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("/ticket-purchase/resend-email/order/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},T=async e=>{try{n(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("ticket-purchase/resend-email/order-multi-files/".concat(e)),y(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},R=async e=>{try{(0,em.Z)({title:"Enviar ingressos comprados no email",text:"Como deseja que os arquivos de ingressos comprados sejam enviados?",confirmButtonText:"Enviar em um arquivo",cancelButtonText:"Enviar em m\xfaltiplos arquivos",onConfirm:()=>{A(e)},onCancel:()=>{T(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};return{items:s.items,numberOfItems:s.numberOfItems,isLoading:r,ordersLimit:g,ordersPage:j,onLoadData:y,downloadTable:k,onDownloadOrderTicketsPdf:Z,cancelOrder:S,cancelFreeOrder:_,updateStatusOrder:D,downloadOrderTicketsPdf:C,sendToWhatsapp:I,sendRefundedToWhatsapp:E,sendRefundedToEmail:P,sendToEmail:R}};var iq=a(72456),iM=a(93429);let iO=e=>{let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),[n,s]=l.useState(new Date),[i,o]=l.useState({}),{id:d,updatedAt:c,lastUpdatedBy:u}=e.ticket;async function m(){try{let s={};if(o(s),n||(s.checkinDate=!0),Object.keys(s).length)return o(s),et.Am.error(t("form_incomplete").toString());a(!0,"Realizando check-in");let i=encodeURIComponent(n.toISOString()),r=await J.ZP.post("/ticket-purchase/checking/".concat(d,"/").concat(i));if(r.data.error)throw Error(r.data.error);a(),et.Am.success("Check-in realizado com sucesso!"),e.onSuccess(),e.onClose()}catch(e){console.log(JSON.stringify(e,null,2)),a(),et.Am.error(e.message)}}return(0,r.jsx)("div",{className:"ticket-checkin-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Realizar Check-in",onGoBack:K.Mr,data:{updatedAt:c,lastUpdatedBy:u}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(a7.Z,{label:"Data e hora do check-in",minutesStep:30,value:n,onChange:e=>s(e),renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:i.checkinDate?"Data do check-in \xe9 obrigat\xf3ria":"",error:!!i.checkinDate})})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:t("event.close").toString()}),(0,r.jsx)(v.Z,{variant:"contained",onClick:m,children:"Realizar Check-in"})]})]})]})})};var iF=a(85362);let iB=new Set(["free","invitation","100%_discount"]),iU=new Set(["cancelled","deleted"]),iz=new Set(["CANCELED","PAYMENT_REFUNDED","PAYMENT_PARTIAL_REFUNDED"]);function iV(e){var t,a,n,s,i,r;return!(iU.has(String(e.status||""))||iz.has(String(e.orderStatus||"")))&&((null===(t=e.ticket)||void 0===t?void 0:t.type)==="passport"||"passport"===e.type||Boolean((null===(n=(a=e).inviter)||void 0===n?void 0:n.id)||(null===(s=a.inviter)||void 0===s?void 0:s.name)||(null===(i=a.inviter)||void 0===i?void 0:i.email))||(null===(r=a.order)||void 0===r?void 0:r.channel)==="invitation"||function(e){var t;let a=(null===(t=e.order)||void 0===t?void 0:t.paymentMethod)||e.paymentMethod;return iB.has(String(a||""))||0===Number(e.totalValue)}(e))}let iG="<p>O ingresso ser\xe1 marcado como cancelado no sistema.</p><p><strong>Aten\xe7\xe3o: esta a\xe7\xe3o n\xe3o estorna o ingresso no gateway de pagamento.</strong> Nenhum valor ser\xe1 devolvido automaticamente.</p><p>Deseja continuar?</p>",iW={ticket_already_cancelled:"Este ingresso j\xe1 est\xe1 cancelado.",ticket_not_eligible_for_local_cancel:"Este ingresso n\xe3o pode ser cancelado sem estorno no gateway.",ticket_purchase_not_found:"Ingresso n\xe3o encontrado.",order_not_found:"Pedido n\xe3o encontrado."};function i$(e){let t="string"==typeof e?e:String((null==e?void 0:e.message)||e||"");return iW[t]||t||"N\xe3o foi poss\xedvel cancelar o ingresso."}let iH=e=>{var t,a,n,s,i,o,c,u,m,h,x,g,j,f,b,y,N;let{onChange:k}=e||{},{t:w,i18n:Z}=(0,p.$)("admin"),{toggleLoader:C}=(0,ee.U2)(),{user:S}=(0,d.aC)(),{data:_,isLoading:D,refresh:E}=(0,eh.Z)("/ticket-purchase/list?id=".concat(e.ticket.id,"&withOrder=true")),{sendToEmail:P,sendToWhatsapp:I}=iL(),[A,T]=l.useState(!1),{id:R,ticket:L,date:q,ticketDiscount:M,coupon:O,couponDiscount:F,order:B,orderStatus:U,orderId:z,status:V,ticketType:G,time:W,totalValue:$,updatedAt:H,user:Q,value:Y,inviter:ea,useLimit:en,creditCardDiscount:es,checkInDates:er,promotion:el,lastUpdatedBy:eo,compensations:ed,compensationValue:ec}=(null==_?void 0:_.items)?(null===(t=_.items)||void 0===t?void 0:t[0])||{}:e.ticket,eu=(null==er?void 0:er.length)?"".concat(null==er?void 0:er.map(e=>(0,ej.p6)(e.date,"Pp",Z.language)).join(", ")," (").concat((null==er?void 0:er.length)||0,"/").concat(en||0,")"):"",ev=!!ea,ex=iV({ticket:L,inviter:ea,order:B,totalValue:$,status:V,orderStatus:U,type:null==L?void 0:L.type,paymentMethod:null==B?void 0:B.paymentMethod}),ep=!ex&&((null==B?void 0:B.paymentStatus)==="AUTHORIZED"||(null==B?void 0:B.paymentStatus)==="PAID")&&"active"===V&&"CANCELED"!==U&&"PAYMENT_REFUNDED"!==U,{paymentStatus:eg,payerInfo:ef}=B||{};async function eb(){(0,em.Z)({text:"Deseja realmente realizar o cancelamento desse ingresso? Ser\xe1 realizada a devolu\xe7\xe3o somente do valor desse ingresso (R$ ".concat((0,sL.n)(Y),") e o status ser\xe1 alterado para ").concat(w("ticket_distribution.PAYMENT_REFUNDED")),confirmButtonText:"Sim, desejo cancelar",onConfirm:async()=>{C(!0,"Realizando devolu\xe7\xe3o pagamento");let e=await J.ZP.post("/order/return-payment",{orderId:z,ticketPurchaseId:R});if(C(),e.data.error)return et.Am.error(e.data.error.message);
1E(),k()},onError:()=>{C()}})}async function ey(){(0,em.Z)({title:"Cancelar ingresso",icon:"warning",text:iG,confirmButtonText:"Sim, cancelar sem estorno",onConfirm:async()=>{C(!0,"Cancelando ingresso");let e=await J.ZP.post("/ticket-purchase/cancel/".concat(R));if(C(),e.data.error)return et.Am.error(i$(e.data.error.message));et.Am.success("Ingresso cancelado. Nenhum estorno foi enviado ao gateway."),E(),k()},onError:()=>{C()}})}async function eN(){try{C(!0,"Atualizando status de pagamento"),T(!0);let e=await J.ZP.get("/order/get-transaction/".concat(z));if(e.data.error)throw Error("order_payment_refunded"===e.data.error.message?w("ticket_purchase.order_payment_refunded"):JSON.stringify(e.data.error.message));E(),k(),T(!1),C()}catch(e){return T(!1),et.Am.error(e.message)}}function ek(){E(),k()}return(0,r.jsxs)("div",{className:"ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:(null==L?void 0:L.title)||"",onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(eP.Z,{src:(null==L?void 0:L.coverImageUrl)||"",width:350,height:188})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",(null==L?void 0:L.title)||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do ingresso:"})," ",R||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo ingresso:"})," ",(null==G?void 0:G.type)||""]}),ev&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",(null==ea?void 0:ea.name)||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Portador:"})," ",(null==Q?void 0:Q.name)?(null==Q?void 0:Q.name)+" ("+(null==Q?void 0:Q.email)+")":"Indefinido"]}),!!(null==Q?void 0:Q.celphone)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio celular:"})," ",(null==Q?void 0:Q.celphone)||""]}),!!(null==Q?void 0:Q.docType)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio documento:"})," ",(null==Q?void 0:Q.docType)+": "+(null==Q?void 0:Q.docNumber)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data visita:"})," ",q?(0,ej.p6)(q||"","P",Z.language)+" "+W:""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status do ingresso:"})," ","".concat(w("ticket_distribution."+U))]}),"DECLINED"===U&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",(0,iF.pH)(null==B?void 0:null===(a=B.transaction)||void 0===a?void 0:null===(n=a.charges)||void 0===n?void 0:null===(s=n[0])||void 0===s?void 0:null===(i=s.payment_response)||void 0===i?void 0:i.message,null==B?void 0:B.transaction)||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"C\xf3digo erro:"})," ",(null==B?void 0:null===(o=B.transaction)||void 0===o?void 0:null===(c=o.charges)||void 0===c?void 0:null===(u=c[0])||void 0===u?void 0:null===(m=u.payment_response)||void 0===m?void 0:m.code)||""]})]}),!!W&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(Y)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto ingresso:"})," ",M||"","%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto ingresso:"})," ",(0,sL.n)(Y*(1-(M||0)/100))]})]}),!!F&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cupom aplicado:"})," ",(null==O?void 0:O.code)||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto cupom:"})," ",F||"","%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto cupom:"})," ",(0,sL.n)(Y*(1-(F||0)/100))]})]}),es?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto Cart\xe3o BRB:"})," ","".concat((null==es?void 0:es.discount)||"","%")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cart\xe3o:"})," ",(null==es?void 0:es.card)||""]})]}):null,el&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Promo\xe7\xe3o:"})," ",(null==el?void 0:el.promotionName)||""]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(H||"","Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Checkin:"})," ",eu||"Indefinido"]}),(null!==(N=null==ed?void 0:ed.length)&&void 0!==N?N:0)>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row compensation-highlight",style:{marginTop:8,marginBottom:8,padding:12,background:"var(--color-info-light, #e3f2fd)",borderRadius:8,display:"flex",alignItems:"center",gap:12},children:[(0,r.jsx)("img",{src:"/compensation-icon.svg",alt:"Compensa\xe7\xe3o ambiental",width:48,height:48}),(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:"Compensa\xe7\xe3o ambiental:"})," Este ingresso escolheu compensa\xe7\xe3o."]})]}),null!=ec&&ec>0&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor da compensa\xe7\xe3o:"})," ",(0,sL.n)(ec)]}),(null!=ed?ed:[]).map(e=>(0,r.jsx)("div",{className:"row",style:{marginLeft:8},children:(0,r.jsxs)("div",{children:[(0,r.jsx)("b",{children:e.name}),e.smallDescription&&" — ".concat(e.smallDescription),null!=e.value&&" — ".concat((0,sL.n)(e.value))]})},e.id))]}),ex&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:ey,children:"Cancelar ingresso"})}),ep&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:eb,children:"Realizar devolu\xe7\xe3o"})}),(0,r.jsxs)("div",{className:"title",children:["Detalhes do pedido:",(0,r.jsx)(X.Z,{onClick:eN,className:"reload-btn "+(A?"rotate":""),children:(0,r.jsx)(iq.Z,{})})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data do pedido:"})," ",(0,ej.p6)((null==B?void 0:B.createdAt)||"","Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do pedido:"})," ",z||""]}),!ev&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Comprador:"}),(null==B?void 0:null===(h=B.payerInfo)||void 0===h?void 0:h.name)?(null==B?void 0:null===(x=B.payerInfo)||void 0===x?void 0:x.name)+" ("+(null==B?void 0:null===(g=B.payerInfo)||void 0===g?void 0:g.email)+", "+(null==B?void 0:null===(j=B.payerInfo)||void 0===j?void 0:j.docType)+": "+(null==B?void 0:null===(f=B.payerInfo)||void 0===f?void 0:f.docNumber)+")":"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total ingressos:"})," ",(0,sL.n)((null==B?void 0:B.itemsAmount)||0)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total doa\xe7\xf5es:"})," ",(0,sL.n)((null==B?void 0:B.donationAmount)||0)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total (ingressos + doa\xe7\xf5es):"})," ",(0,sL.n)((null==B?void 0:B.totalAmount)||0)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Pagamento:"}),(null==B?void 0:B.installments)||0,"x ",(0,sL.n)((null==B?void 0:B.totalAmount)/((null==B?void 0:B.installments)||1))]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"M\xe9todo de pagamento:"})," ",(null==B?void 0:B.paymentMethod)?"".concat(w("ticket_distribution."+(null==B?void 0:B.paymentMethod))):"N\xe3o aplicad
1o"]}),(null==B?void 0:B.splitInfo)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Repasse:"})," ",(null==B?void 0:null===(b=B.splitInfo)||void 0===b?void 0:b.name)||""," (",(0,sL.n)(((null==B?void 0:B.itemsAmount)||0)*((null==B?void 0:null===(y=B.splitInfo)||void 0===y?void 0:y.share)||0)/100),")"]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Canal de venda:"})," ","".concat(w("ticket_distribution."+(null==B?void 0:B.channel)))]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)((null==B?void 0:B.updatedAt)||"","Pp")]}),"PAID"===eg&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>P(z||""),startIcon:(0,r.jsx)(eO.Z,{}),children:"Enviar ingressos comprados no email"}),(null==ef?void 0:ef.celphone)&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>I(z||""),startIcon:(0,r.jsx)(iM.Z,{}),children:"Enviar ingressos comprados no whatsapp"}),(null==S?void 0:S.role)==="super-admin"&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"contained",onClick:()=>{var t;return(0,K.K4)((0,r.jsx)(iO,{ticket:(null==_?void 0:_.items)?(null===(t=_.items)||void 0===t?void 0:t[0])||{}:e.ticket,onClose:()=>{(0,K.Mr)(),k()},onSuccess:ek}))},children:"Realizar Check-in"})]})]})]})},iJ=e=>{var t,a;let{t:n,i18n:s}=(0,p.$)("admin"),{storedState:i,setStoredState:d}=(0,o.oR)(),{ticketsFilter:c={},currentSelectedEvent:u}=i||{},[m,h]=l.useState(""),x=(0,ev.Nr)(m,300),[g,j]=l.useState(!1),[f,b]=l.useState([]),[y,N]=l.useState(null),[k,w]=l.useState({}),[Z,C]=l.useState({}),S=(null==u?void 0:u._id)||null,{data:_,isLoading:D}=(0,eh.Z)("/ticket-purchase/filters?eventId=".concat(S));l.useEffect(()=>{async function e(){var e;j(!0);let t=await J.ZP.get("/ticket-purchase/emails-users?eventId=".concat(S,"&search=").concat(x,"&byEvent=true"));null!=t&&null!==(e=t.data)&&void 0!==e&&e.error||(b(t.data.emails||[]),j(!1))}(null==x?void 0:x.length)>4&&e()},[x]);let{ticketPurchaseId:E,sellStartDate:P,sellEndDate:I,visitStartDate:A,visitEndDate:T,ticketTitle:R,ticketType:L,promotionName:q,paymentType:M,paymentStatus:O,userNameEmail:F,userEmail:B,checkInFilter:U,withCompensations:z}=k;function V(e){w({...k,...e})}function G(){if(!A&&!P)return C({startDate:!0}),et.Am.error("Data in\xedcio obrigat\xf3ria para visita ou venda!");if(A&&T&&(0,av.Z)((0,tD.Z)(new Date(T)),(0,tD.Z)(new Date(A)))||P&&I&&(0,av.Z)((0,tD.Z)(new Date(I)),(0,tD.Z)(new Date(P))))return C({sellEndDate:!0}),et.Am.error("Data de in\xedcio n\xe3o deve ser maior que a data fim!");C({sellStartDate:!1,sellEndDate:!1});let t={...c};t[S]=k,Object.keys(t[S]).map(e=>{let a=t[S][e];a&&"string"==typeof a&&"userNameEmail"!==e&&"Invalid Date"!==new Date(a).toString()&&(t[S][e]=new Date(a))}),d({ticketsFilter:t,ticketsPage:0}),e.onLoadData({ticketsFilterParams:t,ticketsPageParams:0})}l.useEffect(()=>{B&&(b([{_id:B,qty:0}]),N({_id:B,qty:0}))},[B]),l.useEffect(()=>{if(!S)return;let e={ticketPurchaseId:null,paymentStatus:["PAID"],sellStartDate:new Date,sellEndDate:new Date,withCompensations:!1},t={...e,...c[S]};w(t)},[S]);let W=l.useRef(!1);return l.useEffect(()=>{Object.keys(k).length&&(W.current||(G(),W.current=!0))},[k]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{label:"ID Ingresso",value:E||"",onValueChange:e=>V({ticketPurchaseId:e})}),(0,r.jsx)(am.Z,{options:(null==_?void 0:_.tickets)||[],value:R,label:"Ingresso",cleanable:!0,multiple:!0,onChange:e=>V({ticketTitle:e}),isLoading:D}),(0,r.jsx)(am.Z,{options:(null==_?void 0:_.ticketTypes)||[],value:L,label:"Tipo ingresso",cleanable:!0,multiple:!0,onChange:e=>V({ticketType:e}),isLoading:D})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome, email ou telefone do comprador",value:F||"",onValueChange:e=>V({userNameEmail:e})}),!!F&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>V({userNameEmail:""}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(e_.Z,{id:"users",className:"user-select",options:f,getOptionLabel:e=>e._id,multiple:!1,loading:g,loadingText:"Carregando...",noOptionsText:(null==x?void 0:x.length)>4?"Nenhum email encontrado":"Digite ao menos 5 caracteres para iniciar a busca de emails relacionados aos portadores",value:y,onChange:(e,t)=>
1{N(t),V({userEmail:null==t?void 0:t._id})},onInputChange:(e,t)=>{h(t),V({userEmail:""})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"Email do portador",inputProps:e.inputProps}),renderTags:(e,t)=>e.map(e=>(0,r.jsxs)("li",{...t,className:"user-select-selected",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(e._id," - ").concat(e.qty," ingresso(s)")})}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>N(null),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e._id)),renderOption:(e,t)=>{let{_id:a,qty:n}=t;return(0,l.createElement)("li",{...e,key:a,className:"user-select-list-opt"},(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(a," - ").concat(n," ingresso(s)")})}))}}),B||y||f.length?(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:30},onClick:()=>{b([]),N(null),V({userEmail:""})},children:(0,r.jsx)(ec.Z,{})}):null]}),(0,r.jsx)(am.Z,{options:(null==_?void 0:_.promotionNames)||[],value:q,label:"Promo\xe7\xe3o",cleanable:!0,multiple:!0,onChange:e=>V({promotionName:e}),isLoading:D})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ea.Z,{label:"Apenas com compensa\xe7\xe3o",className:"switch",control:(0,r.jsx)(tr.Z,{checked:!!z,onChange:e=>V({withCompensations:e.target.checked})})}),(0,r.jsx)(am.Z,{options:[{label:"Todos",value:"all"},{label:"Com Check-in",value:"checked"},{label:"Sem Check-in",value:"not-checked"}],value:U,label:"Check-in",onChange:e=>V({checkInFilter:e}),isLoading:D}),(0,r.jsx)(am.Z,{options:(null==_?void 0:null===(t=_.paymentMethods)||void 0===t?void 0:t.filter(e=>!!e).map(e=>({label:n("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:M,label:"M\xe9todo de pagamento",onChange:e=>V({paymentType:e}),isLoading:D}),(0,r.jsx)(am.Z,{options:(null==_?void 0:null===(a=_.paymentStatus)||void 0===a?void 0:a.filter(e=>!!e).map(e=>({label:n("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:O,label:"Status do pedido",onChange:e=>{V({paymentStatus:e})},isLoading:D})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data venda - in\xedcio",className:"input",value:P||null,onChange:e=>V({sellStartDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:Z.sellStartDate||Z.startDate})}),!!P&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>V({sellStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data venda - fim",className:"input",shouldDisableDate:e=>!!P&&(0,tS.Z)(new Date(e),1)<new Date(P),value:I||null,onChange:e=>V({sellEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{error:Z.sellEndDate,...e})}),!!I&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>V({sellEndDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data visita - in\xedcio",className:"input",value:A||null,onChange:e=>V({visitStartDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:Z.visitStartDate||Z.startDate})}),!!A&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>V({visitStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data visita - fim",className:"input",value:T||null,onChange:e=>V({visitEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:Z.visitEndDate})}),!!T&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>V({visitEndDate:null}),children:(0,r.jsx)(ec.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row last",children:[e.numberOfItems&&!Object.keys(Z).filter(e=>!!Z[e]).length?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:e.onRequestDownload,children:"Download tabela"})}):null,(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...c};e[S]={},d({ticketsFilter:e}),w({})},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:G,children:"Aplicar filtros"})]})]})};var iQ=a(21714);
1let iY=e=>{let{email:t,onSuccess:a,disabled:n=!1}=e,{t:s}=(0,p.$)("admin"),[i,o]=(0,l.useState)(""),[d,c]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),h=()=>{t&&(0,em.Z)({title:"Gerar Link de Altera\xe7\xe3o de Data",text:"Ser\xe1 enviado um link para o email ".concat(t," para que o comprador possa alterar a data de visita do ingresso. Ap\xf3s a gera\xe7\xe3o, voc\xea poder\xe1 copiar o link ou escanear o QR Code gerado."),icon:"info",confirmButtonText:"Gerar Link",cancelButtonText:"Cancelar",endpoint:"/order-payer-user/ticket-purchase-link?email=".concat(encodeURIComponent(t)),onSuccess:e=>{var t;(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.link)&&(o(e.data.link),c(!0),null==a||a())},onError:()=>{console.error("Erro ao gerar link")}})},x=async()=>{try{await navigator.clipboard.writeText(i)}catch(e){console.error("Erro ao copiar link:",e)}},g=()=>{c(!1),o("")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eS.Z,{arrow:!0,title:"Gerar link para alterar data de visita",children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:h,disabled:n||!t,size:"small",children:(0,r.jsx)(iQ.Z,{})})})}),(0,r.jsxs)(sm.Z,{open:d,onClose:g,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(sh.Z,{children:"Link Gerado com Sucesso"}),(0,r.jsx)(sv.Z,{children:(0,r.jsxs)(nT.Z,{sx:{mt:2},children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Link para altera\xe7\xe3o de data de visita:"}),(0,r.jsx)(es.Z,{fullWidth:!0,value:i,InputProps:{readOnly:!0,endAdornment:(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:x,size:"small",children:(0,r.jsx)(e7.Z,{})})})},sx:{mb:3}}),(0,r.jsx)(a1.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Ou escaneie o QR Code:"}),(0,r.jsx)(nT.Z,{sx:{display:"flex",justifyContent:"center",mb:2},children:(0,r.jsx)(aL.ZP,{value:i,size:200,style:{height:"auto",maxWidth:"100%",width:"100%"},viewBox:"0 0 200 200",bgColor:"#ffffff",fgColor:"#000000"})})]})}),(0,r.jsx)(sx.Z,{children:(0,r.jsx)(v.Z,{onClick:g,variant:"contained",children:"Fechar"})})]})]})},iK=()=>{var e;let{storedState:t,setStoredState:a}=(0,o.oR)();null==t||null===(e=t.currentSelectedEvent)||void 0===e||e._id,null==t||t.ticketsFilter;let{t:n,i18n:s}=(0,p.$)("admin"),{items:i,numberOfItems:d,isLoading:c,ticketsLimit:u,ticketsPage:m,onLoadData:h,onDownloadOrderTicketsPdf:v,downloadOrderTicketsPdf:x,resendTicketOrderEmail:g,downloadTable:j,downloadTicketsOfficeReportPdf:f,updateStatusOrder:b}
1=iP();return l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Tabela de ingressos"})}),(0,r.jsx)(iJ,{numberOfItems:d,onLoadData:h,onRequestDownload:j,onRequestDownloadTicketOfficeReport:f}),c?(0,r.jsx)(ee.aN,{inline:!0}):!d&&(0,r.jsx)("div",{className:"nothing-found",children:"".concat(n("nothing_found"))}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Transa\xe7\xe3o Id"}),(0,r.jsx)("th",{children:"Ingresso Id"}),(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Usu\xe1rio"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Comprador telefone"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"}),(0,r.jsx)("th",{children:"Compensa\xe7\xe3o"}),(0,r.jsx)("th",{children:"".concat(n("action"))})]})}),(0,r.jsx)("tbody",{children:null==i?void 0:i.map((e,t)=>{var a,i,l,o,d,c,u,m,p,j,f,y,N,k,w,Z;let C=e.date?(0,ej.p6)(e.date,"P",s.language)+" "+(e.time||(0,ej.p6)(e.date,"HH:mm",s.language)):"",S=e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",s.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"",_=(0,ej.p6)(e.createdAt,"Pp",s.language),D=e.checkInDates.length===e.useLimit,E="PAID"===e.orderStatus,P=!E,I=D||!E||!(null===(a=e.user)||void 0===a?void 0:a.email),A=null===(i=e.order)||void 0===i?void 0:i._id;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:A}),(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:e.ticket.title}),(0,r.jsx)("td",{children:null===(l=e.ticketType)||void 0===l?void 0:l.type}),(0,r.jsx)("td",{children:null===(o=e.user)||void 0===o?void 0:o.name}),(0,r.jsx)("td",{children:null===(d=e.user)||void 0===d?void 0:d.email}),(0,r.jsx)("td",{children:(null==e?void 0:null===(c=e.order)||void 0===c?void 0:null===(u=c.payerInfo)||void 0===u?void 0:u.celphone)||"-"}),(0,r.jsx)("td",{children:C}),(0,r.jsx)("td",{children:_}),(0,r.jsx)("td",{children:"".concat(n("ticket_distribution."+e.order.channel))}),(0,r.jsx)("td",{children:(null===(m=e.order)||void 0===m?void 0:null===(p=m.machineOperator)||void 0===p?void 0:p.name)||"-"}),(0,r.jsx)("td",{children:null===(j=e.order.transaction)||void 0===j?void 0:j.terminalSerialNumber}),(0,r.jsx)("td",{children:e.orderStatus?"".concat(n("ticket_distribution."+e.orderStatus)):"-"}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:e.order.paymentMethod?"".concat(n("ticket_distribution."+e.order.paymentMethod)):"-"}),(0,r.jsx)("td",{children:S}),(0,r.jsx)("td",{children:(null!==(w=null===(f=e.compensations)||void 0===f?void 0:f.length)&&void 0!==w?w:0)>0||(null!==(Z=e.compensationValue)&&void 0!==Z?Z:0)>0?(0,r.jsx)(eS.Z,{arrow:!0,title:"Compensa\xe7\xe3o ambiental",children:(0,r.jsx)("img",{src:"/compensation-icon.svg",alt:"Compensa\xe7\xe3o",width:48,height:48,style:{verticalAlign:"middle"}})}):"-"}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.update_status"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>b(e.orderId),children:(0,r.jsx)(ns.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.resend_email"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:I,onClick:()=>g(e.orderId),children:(0,r.jsx)(eO.Z,{className:I?"disabled":(null===(y=e.order)||void 0===y?void 0:y.emailSent)===!1?"email-not-sent":""})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.download_tickets_pdf"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:P,onClick:()=>v(e.id),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.download_tickets"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:P,onClick:()=>x({orderId:e.orderId,ticketPurchaseId:e.id}),children:(0,r.jsx)(nC.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.edit_ticket"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:D,onClick:()=>(0,K.K4)((0,r.jsx)(iR,{item:e,onClose:()=>{(0,K.Mr)(),h()}})),children:(0,r.jsx)(ep.Z,{})})})}),(0,r.jsx)(iY,{email:(null===(N=e.order)||void 0===N?void 0:null===(k=N.payerInfo)||void 0===k?void 0:k.email)||"",onSuccess:h,disabled:!E}),(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(iH,{ticket:e,onChange:h})),children:(0,r.jsx)(nZ.Z,{})})})})]})]},t)})})]})}),(0,r.jsx)(eZ,{numberOfItems:d,rowsPerPage:u,page:m,onPageChange:e=>{a({ticketsPage:e}),h({ticketsPageParams:e})},onRowsPerPageChange:e=>{a({ticketsPage:0,ticketsLimit:e}),h({ticketsPageParams:0,ticketsLimitParams:e})}})]})},iX=()=>(0,r.jsx)("div",{className:"ticket-dashboard",children:(0,r.jsx)(iK,{})}),i0=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),{toggleLoader:n}=(0,ee.U2)(),{_id:s}=(null==a?void 0:a.currentSelectedEvent)||{},i="tickets-purchases-users-event-all",{ticketsLimit:r=20,ticketsPage:l=0,ticketsPurchaseUserFilter:d}=a,c=(null==d?void 0:d[i])||{},u=new URLSearchParams({...(null==d?void 0:d[i])||{},eventId:s,page:l,limit:r}),{data:m,isLoading:h,refresh:v}=(0,eh.Z)("/ticket-purchase/list-table-user-to-admin?"+u,{enabled:!!c.email}),{items:x,numberOfItems:g}=m||{},j=async e=>{try{n(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("/ticket-purchase/resend-email/order/".concat(e)),et.Am.success("Ingressos enviados no email com sucesso!"),v(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},f=async e=>{try{n(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("ticket-purchase/resend-email/order-multi-files/".concat(e)),et.Am.success("Ingressos enviados em m\xfaltiplos arquivos com sucesso!"),v(),n()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},b=async e=>{try{(0,em.Z)({title:"Enviar ingressos comprados no email",text:"Como deseja que os arquivos de ingressos comprados sejam enviados?",confirmButtonText:"Enviar em um arquivo",cancelButtonText:"Enviar em m\xfaltiplos arquivos",onConfirm:()=>{j(e)},onCancel:()=>{f(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};async function y(t){try{n(!0,"Gerando ingressos comprados em PDF em m\xfaltiplos arquivos...");let a=await J.ZP.get("/order/download-tickets-pdf-multi-files/".concat(t),{responseType:"arraybuffer"});if(n(),a.data.error)throw Error(e("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(new Blob([a.data])),i=document.createElement("a");i.href=s;let r=a.headers["content-disposition"].replace("attachment; filename='","").replace("'","");i.target="_blank",i.rel="noopener noreferrer",i.download=r,i.click(),i.remove()}catch(e){et.Am.error(e.message),console.log(e),n()}}async function N(t){try{n(!0,"Gerando ingressos comprados em PDF");let a=await J.ZP.get("/ticket-purchase/download/".concat(t),{responseType:"blob"});if(n(),a.data.error)throw Error(e("error_on_processing")+"\n\n"+a.data.error.message);let s=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=s,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){n()}}let k=async e=>{let{orderId:t,ticketPurchaseId:a}=e;try{(0,em.Z)({title:"Download de PDF de ingressos comprados",text:"Como deseja que os arquivos de ingressos comprados sejam baixados?",confirmButtonText:"Baixar em um arquivo PDF",cancelButtonText:"Baixar m\xfaltiplos arquivos PDF zipados",onConfirm:()=>{N(a)},onCancel:()=>{y(t)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},w=async e=>
1{try{n(!0,"Atualizando transa\xe7\xe3o..."),await J.ZP.get("/payment/updateStatus/".concat(e)),v(),n()}catch(e){console.log("\uD83D\uDE80 ~ updateStatusOrder ~ error:",e)}};return{items:x,numberOfItems:g,isLoading:h,ticketsLimit:r,ticketsPage:l,refresh:v,downloadOrderTicketsPdf:k,resendTicketOrderEmail:b,updateStatusOrder:w,filters:c}},i1={active:"Ativo",cancelled:"Cancelado"},i2={WAITING_PAYMENT:"Aguardando pagamento",IN_ANALYSIS:"Pagamento em an\xe1lise",PAID:"Pago",DECLINED:"Pagamento recusado",PIX_EXPIRED:"Pix expirado",PAYMENT_REFUNDED:"Pagamento estornado",CANCELED:"Cancelado"},i3=e=>{let{t}=(0,p.$)("admin"),{toggleLoader:a}=(0,ee.U2)(),[n,s]=l.useState({}),[i,o]=l.useState({}),{updatedAt:d,lastUpdatedBy:c}=e.item,{date:u,orderStatus:m,status:h,time:x,user:g}=n;async function j(){try{var s,i;let r={};if(o(r),(null===(s=n.user)||void 0===s?void 0:s.name)||(r.useName=!0),(null===(i=n.user)||void 0===i?void 0:i.email)||(r.useEmail=!0),n.time||(r.time=!0),n.orderStatus||(r.orderStatus=!0),n.date||(r.date=!0),Object.keys(r).length)return o(r),et.Am.error(t("form_incomplete"));a(!0,t("processing"));let l=await J.ZP.put("/ticket-purchase",n);if(l.data.error)throw Error(l.data.error.message);a(),e.onClose()}catch(e){console.log(JSON.stringify(e,null,2)),a(),et.Am.error(e.message)}}return l.useEffect(()=>{s({id:e.item.id,user:e.item.user,date:e.item.date,time:e.item.time,status:e.item.status,orderStatus:e.item.orderStatus})},[e.item]),(0,r.jsx)("div",{className:"ticket-edit-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Editar ingresso",onGoBack:K.Mr,data:{updatedAt:d,lastUpdatedBy:c}}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(ah.Z,{className:"textfield",label:"Nome usu\xe1rio",value:(null==g?void 0:g.name)||"",onValueChange:e=>s(t=>({...t,user:{...t.user,name:e}}))}),(0,r.jsx)(ah.Z,{className:"textfield",label:"Email usu\xe1rio",value:(null==g?void 0:g.email)||"",type:"email",onValueChange:e=>s(t=>({...t,user:{...t.user,email:e}}))})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(a7.Z,{label:"Data visita",minutesStep:30,value:u||null,onChange:e=>{if(!e||!x)return;let t=new Date(e).toISOString(),a=new Date(e).toTimeString().slice(0,5)+"-"+x.split("-")[1];s(e=>({...e,date:t,time:a}))},renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:i.sellStartDate,error:!!i.sellStartDate})})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(am.Z,{label:"Status",className:"select",disabled:!0,options:Object.keys(i1).map(e=>({label:i1[e],value:e})),value:h,onChange:e=>s(t=>({...t,status:e}))}),(0,r.jsx)(am.Z,{label:"Status do pedido",className:"select",options:Object.keys(i2).map(e=>({label:i2[e],value:e})),value:m,onChange:e=>s(t=>({...t,orderStatus:e,status:["WAITING_PAYMENT","IN_ANALYSIS","PAID"].includes(e)?"active":"cancelled"}))})]}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:t("event.close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:j,children:t("save")})]})]})]})})},i6=e=>{var t,a,n,s,i,o,d,c,u,m,h,x,g;let{onChange:j}=e||{},{toggleLoader:f}=(0,ee.U2)(),{t:b,i18n:y}=(0,p.$)("admin"),{data:N,isLoading:k,refresh:w}=(0,eh.Z)("/ticket-purchase/list?id=".concat(e.ticket.id,"&withOrder=true")),{sendToEmail:Z,sendToWhatsapp:C}=iL(),[S,_]=l.useState(!1),{id:D,ticket:E,date:P,ticketDiscount:I,coupon:A,couponDiscount:T,order:R,orderStatus:L,orderId:q,status:M,ticketType:O,time:F,totalValue:B,updatedAt:U,user:z,value:V,inviter:G,useLimit:W,creditCardDiscount:$,checkInDates:H,lastUpdatedBy:Q}=(null==N?void 0:N.items)?N.items[0]:e.ticket,Y=H.length?"".concat(H.map(e=>(0,ej.p6)(e.date,"Pp",y.language)).join(", ")," (").concat(H.length,"/").concat(W,")"):"",K=!!G,ea=iV({ticket:E,inviter:G,order:R,totalValue:B,status:M,orderStatus:L,type:null==E?void 0:E.type,paymentMethod:null==R?void 0:R.paymentMethod}),en=!ea&&((null==R?void 0:R.paymentStatus)==="AUTHORIZED"||(null==R?void 0:R.paymentStatus)==="PAID")&&(null==R?void 0:R.channel)!=="card-machine"&&"active"===M&&"CANCELED"!==L&&"PAYMENT_REFUNDED"!==L,{paymentStatus:es,payerInfo:er}=R||{};async function el(){(0,em.Z)({text:"Deseja realmente realizar o cancelamento deste pedido?",confirmButtonText:"Sim, desejo cancelar",onConfirm:async()=>{f(!0,"Realizando devolu\xe7\xe3o pagamento");let e=await J.ZP.post("/order/return-payment",{orderId:q,ticketPurchaseId:D});if(f(),e.data.error)return et.Am.error(e.data.error.message);w(),j()},onError:()=>{f()}})}async function eo(){(0,em.Z)({title:"Cancelar ingresso",icon:"warning",text:iG,confirmButtonText:"Sim, cancelar sem estorno",onConfirm:async()=>{f(!0,"Cancelando ingresso");let e=await J.ZP.post("/ticket-purchase/cancel/".concat(D));if(f(),e.data.error)return et.Am.error(i$(e.data.error.message));et.Am.success("Ingresso cancelado. Nenhum estorno foi enviado ao gateway."),w(),j()},onError:()=>{f()}})}async function ed(){try{f(!0,"Atualizando status de pagamento"),_(!0);let e=await J.ZP.get("/order/get-transaction/".concat(q));if(e.data.error)throw Error("order_payment_refunded"===e.data.error.message?b("ticket_purchase.order_payment_refunded"):JSON.stringify(e.data.error.message));w(),j(),_(!1),f()}catch(e){return _(!1),et.Am.error(e.message)}}
1return(0,r.jsxs)("div",{className:"ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:E.title,onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(eP.Z,{src:E.coverImageUrl,width:350,height:188})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",E.title]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do ingresso:"})," ",D]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo ingresso:"})," ",O.type]}),K&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",G.name]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Portador:"}),"  ",(null==z?void 0:z.name)?z.name+" ("+(null==z?void 0:z.email)+")":"Indefinido"]}),!!(null==z?void 0:z.celphone)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio celular:"})," ",null==z?void 0:z.celphone]}),!!(null==z?void 0:z.docType)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio documento:"})," ",z.docType+": "+z.docNumber]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data visita:"})," ",P?(0,ej.p6)(P,"P",y.language)+" "+F:""]}),!!F&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(V)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto ingresso:"})," ",I,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto ingresso:"})," ",(0,sL.n)(V*(1-I/100))]})]}),!!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cupom aplicado:"})," ",null==A?void 0:A.code]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto cupom:"})," ",T,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto cupom:"})," ",(0,sL.n)(V*(1-T/100))]})]}),$?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto Cart\xe3o BRB:"})," ","".concat($.discount,"%")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cart\xe3o:"})," ",$.card]})]}):null,(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(U,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Checkin:"})," ",Y||"Indefinido"]}),(0,r.jsxs)("div",{className:"title",children:["Detalhes do pedido:",(0,r.jsx)(X.Z,{onClick:ed,className:"reload-btn "+(S?"rotate":""),children:(0,r.jsx)(iq.Z,{})})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data do pedido:"})," ",(0,ej.p6)(R.createdAt,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do pedido:"})," ",q]}),!K&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status do pedido:"})," ","".concat(b("ticket_distribution."+L))]}),"DECLINED"===L&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",(0,iF.pH)(null==R?void 0:null===(t=R.transaction)||void 0===t?void 0:null===(a=t.charges)||void 0===a?void 0:null===(n=a[0])||void 0===n?void 0:null===(s=n.payment_response)||void 0===s?void 0:s.message,null==R?void 0:R.transaction)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"C\xf3digo erro:"})," ",null==R?void 0:null===(i=R.transaction)||void 0===i?void 0:null===(o=i.charges)||void 0===o?void 0:null===(d=o[0])||void 0===d?void 0:null===(c=d.payment_response)||void 0===c?void 0:c.code]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Comprador:"}),(null===(u=R.payerInfo)||void 0===u?void 0:u.name)?(null===(m=R.payerInfo)||void 0===m?void 0:m.name)+" ("+(null===(h=R.payerInfo)||void 0===h?void 0:h.email)+", "+(null===(x=R.payerInfo)||void 0===x?void 0:x.docType)+": "+(null===(g=R.payerInfo)||void 0===g?void 0:g.docNumber)+")":"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total ingressos:"})," ",(0,sL.n)(R.itemsAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total doa\xe7\xf5es:"})," ",(0,sL.n)(R.donationAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total (ingressos + doa\xe7\xf5es):"})," ",(0,sL.n)(R.totalAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Pagamento:"}),R.installments,"x ",(0,sL.n)(R.totalAmount/R.installments)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"M\xe9todo de pagamento:"})," ",R.paymentMethod?"".concat(b("ticket_distribution."+R.paymentMethod)):"N\xe3o aplicad
1o"]}),R.splitInfo&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Repasse:"})," ",R.splitInfo.name," (",(0,sL.n)(R.itemsAmount*R.splitInfo.share/100),")"]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Canal de venda:"})," ","".concat(b("ticket_distribution."+R.channel))]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(R.updatedAt,"Pp")]}),ea&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:eo,children:"Cancelar ingresso"})}),en&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:el,children:"Realizar devolu\xe7\xe3o"})}),"PAID"===es&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>Z(q),startIcon:(0,r.jsx)(eO.Z,{}),children:"Enviar ingressos comprados no email"}),(null==er?void 0:er.celphone)&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>C(q),startIcon:(0,r.jsx)(iM.Z,{}),children:"Enviar ingressos comprados no whatsapp"})]})]})]})},i5=e=>{let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),{ticketsPurchaseUserFilter:i={},currentSelectedEvent:d}=n||{},[c,u]=l.useState(""),m=(0,ev.Nr)(c,300),[h,x]=l.useState(!1),[g,j]=l.useState([]),[f,b]=l.useState(null),[y,N]=l.useState({}),[k,w]=l.useState({}),Z=(null==d?void 0:d._id)||null,C="tickets-purchases-users-event-all",{sellStartDate:S,sellEndDate:_,visitStartDate:D,visitEndDate:E,email:P}=y;function I(e){N({...y,...e})}function A(){if(D&&E&&(0,av.Z)((0,tD.Z)(new Date(E)),(0,tD.Z)(new Date(D))))return w({sellEndDate:!0}),et.Am.error("Data de in\xedcio da visita n\xe3o deve ser maior que a data fim!");if(S&&_&&(0,av.Z)((0,tD.Z)(new Date(_)),(0,tD.Z)(new Date(S))))return w({sellEndDate:!0}),et.Am.error("Data de in\xedcio da venda n\xe3o deve ser maior que a data fim!");if(!P)return w({email:!0}),et.Am.error("Email do usu\xe1rio \xe9 obrigat\xf3rio!");w({sellStartDate:!1,sellEndDate:!1,email:!1});let e={...i};e[C]=y,s({ticketsPurchaseUserFilter:e,ticketsPage:0})}l.useEffect(()=>{async function e(){var e;x(!0);let t=await J.ZP.get("/ticket-purchase/emails-users?eventId=".concat(Z,"&search=").concat(m));null!=t&&null!==(e=t.data)&&void 0!==e&&e.error||(j(t.data.emails||[]),x(!1))}(null==m?void 0:m.length)>4&&e()},[m]),l.useEffect(()=>{if(!C)return;let e={...i[C]};N(e)},[C]);let T=l.useRef(!1);return l.useEffect(()=>{Object.keys(y).length&&(T.current||(A(),T.current=!0))},[y]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(e_.Z,{id:"users",className:"user-select",options:g,getOptionLabel:e=>e._id,multiple:!1,loading:h,loadingText:"Carregando...",value:f,onChange:(e,t)=>
1{b(t),I({email:null==t?void 0:t._id})},onInputChange:(e,t)=>{u(t),I({email:""})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"Informe um email do usu\xe1rio para pesquisar",inputProps:e.inputProps,helperText:"Digite ao menos 5 caracteres para iniciar a busca"}),renderTags:(e,t)=>e.map(e=>(0,r.jsxs)("li",{...t,className:"user-select-selected",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(e._id," - ").concat(e.qty," ingresso(s)")})}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>b(null),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e._id)),renderOption:(e,t)=>{let{_id:a,qty:n}=t;return(0,l.createElement)("li",{...e,key:a,className:"user-select-list-opt"},(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(a," - ").concat(n," ingresso(s)")})}))}}),!!P&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>I({email:""}),children:(0,r.jsx)(ec.Z,{})})]})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data venda - in\xedcio",className:"input",value:S||null,onChange:e=>I({sellStartDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:k.sellStartDate||k.startDate})}),!!S&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>I({sellStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data venda - fim",className:"input",shouldDisableDate:e=>!!S&&(0,tS.Z)(new Date(e),1)<new Date(S),value:_||null,onChange:e=>I({sellEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{error:k.sellEndDate,...e})}),!!_&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>I({sellEndDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data visita - in\xedcio",className:"input",value:D||null,onChange:e=>I({visitStartDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:k.visitStartDate||k.startDate})}),!!D&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>I({visitStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data visita - fim",className:"input",value:E||null,onChange:e=>I({visitEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:k.visitEndDate})}),!!E&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>I({visitEndDate:null}),children:(0,r.jsx)(ec.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row last",children:[(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...i};e[C]={},s({ticketsPurchaseUserFilter:e}),N({})},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:A,children:"Aplicar filtros"})]})]})},i8=()=>{let{setStoredState:e}=(0,o.oR)(),{t,i18n:a}=(0,p.$)("admin"),{items:n,numberOfItems:s,isLoading:i,ticketsLimit:d,ticketsPage:c,refresh:u,downloadOrderTicketsPdf:m,resendTicketOrderEmail:h,updateStatusOrder:v,filters:x}=i0();return l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Meus Ingressos do Usu\xe1rio"})}),(0,r.jsx)(i5,{numberOfItems:s}),i?(0,r.jsx)(ee.aN,{inline:!0}):x.email?!s&&(0,r.jsx)("div",{className:"nothing-found",children:"".concat(t("nothing_found"))}):(0,r.jsx)("div",{className:"nothing-found",children:"".concat(t("email_required_to_init_search"))}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Transa\xe7\xe3o Id"}),(0,r.jsx)("th",{children:"Ingresso Id"}),(0,r.jsx)("th",{children:"Evento"}),(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Usu\xe1rio"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Comprador telefone"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"}),(0,r.jsx)("th",{children:"".concat(t("action"))})]})}),(0,r.jsx)("tbody",{children:null==n?void 0:n.map((e,n)=>{var s,i,l,o,d,c,x,p,g,j,f,b,y,N;let k=e.date?(0,ej.p6)(e.date,"P",a.language)+" "+(e.time||(0,ej.p6)(e.date,"HH:mm",a.language)):"",w=e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",a.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"",Z=(0,ej.p6)(e.createdAt,"Pp",a.language),C=e.checkInDates.length===e.useLimit,S="PAID"===e.orderStatus,_=C||!S||!(null===(s=e.user)||void 0===s?void 0:s.email),D=null===(i=e.order)||void 0===i?void 0:i._id;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:D}),(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:null===(l=e.event)||void 0===l?void 0:l.title}),(0,r.jsx)("td",{children:e.ticket.title}),(0,r.jsx)("td",{children:null===(o=e.ticketType)||void 0===o?void 0:o.type}),(0,r.jsx)("td",{children:null===(d=e.user)||void 0===d?void 0:d.name}),(0,r.jsx)("td",{children:null===(c=e.user)||void 0===c?void 0:c.email}),(0,r.jsx)("td",{children:(null==e?void 0:null===(x=e.order)||void 0===x?void 0:null===(p=x.payerInfo)||void 0===p?void 0:p.celphone)||"-"}),(0,r.jsx)("td",{children:k}),(0,r.jsx)("td",{children:Z}),(0,r.jsx)("td",{children:"".concat(t("ticket_distribution."+e.order.channel))}),(0,r.jsx)("td",{children:(null===(g=e.order)||void 0===g?void 0:null===(j=g.machineOperator)||void 0===j?void 0:j.name)||"-"}),(0,r.jsx)("td",{children:null===(f=e.order.transaction)||void 0===f?void 0:f.terminalSerialNumber}),(0,r.jsx)("td",{children:e.orderStatus?"".concat(t("ticket_distribution."+e.orderStatus)):"-"}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:e.order.paymentMethod?"".concat(t("ticket_distribution."+e.order.paymentMethod)):"-"}),(0,r.jsx)("td",{children:w}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.update_status"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>v(e.orderId),children:(0,r.jsx)(ns.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.resend_email"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:_,onClick:()=>h(e.orderId),children:(0,r.jsx)(eO.Z,{className:_?"disabled":(null===(b=e.order)||void 0===b?void 0:b.emailSent)===!1?"email-not-sent":""})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.download_tickets"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:!S,onClick:()=>m({orderId:e.orderId,ticketPurchaseId:e.id}),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(iY,{email:(null===(y=e.order)||void 0===y?void 0:null===(N=y.payerInfo)||void 0===N?void 0:N.email)||"",onSuccess:u,disabled:!S}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.edit_ticket"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:C,onClick:()=>(0,K.K4)((0,r.jsx)(i3,{item:e,onClose:()=>{(0,K.Mr)(),u()}})),children:(0,r.jsx)(ep.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(i6,{ticket:e,onChange:u})),children:(0,r.jsx)(nZ.Z,{})})})})]})]},n)})})]})}),(0,r.jsx)(eZ,{numberOfItems:s,rowsPerPage:d,page:c,onPageChange:t=>e({ticketsPage:t}),onRowsPerPageChange:t=>e({ticketsPage:0,ticketsLimit:t})})]})},i7=()=>(0,r.jsx)("div",{className:"ticket-purchases-users",children:(0,r.jsx)(i8,{})}),i4=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketInvitationLimit:r=20,ticketInvitationPage:d=0,ticketInvitationSearch:c="",tableInvitationFilters:u}=n,{toggleLoader:m}=(0,ee.U2)(),{onListenerEndpoint:h,clearListener:v,response:x}=(0,iE.Z)(),g=new URLSearchParams({...(null==u?void 0:u[i])||{},eventId:i,ticketTypeId:"invitation",page:d,limit:r,userTimeZone:(0,ej.Y5)(),isDateAndTime:!0,groupedByOrderId:!0}),{data:j,isLoading:f,refresh:b}=(0,eh.Z)("/ticket-purchase/list?".concat(g)),{items:y,numberOfItems:N}=j||{},[k,w]=l.useState(!1),Z=async e=>{try{m(!0,"Reenviando convites no email..."),await J.ZP.get("/ticket-purchase/resend-email/order/".concat(e)),et.Am.success("Convites reenviados no email com sucesso!"),b(),m()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},C=async e=>{try{m(!0,"Reenviando convites em m\xfaltiplos arquivos..."),await J.ZP.get("ticket-purchase/resend-email/order-multi-files/".concat(e)),et.Am.success("Convites reenviados em m\xfaltiplos arquivos com sucesso!"),b(),m()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},S=async e=>{try{(0,em.Z)({title:"Reenviar convites no email",text:"Como deseja que os arquivos de convites sej
1am reenviados?",confirmButtonText:"Reenviar em um arquivo",cancelButtonText:"Reenviar em m\xfaltiplos arquivos",onConfirm:()=>{Z(e)},onCancel:()=>{C(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};async function _(){m(!0,"O processamento est\xe1 demorando mais que o esperado. Aguarde mais alguns instantes.");let e=localStorage.getItem(o.cp);h("/task/".concat(e))}async function D(e){let{link:t,fileName:a}=e;try{let e=localStorage.getItem(o.cp);if(!e){et.Am.error("Erro ao baixar convites em m\xfaltiplos arquivos, tente novamente.");return}if(!t||"string"!=typeof t||""===t.trim()){et.Am.error("Link inv\xe1lido para download dos arquivos.");return}(0,em.Z)({title:"Arquivo gerado com sucesso",text:"Arquivo de convites em PDF (m\xfaltiplos arquivos) gerado com sucesso",confirmButtonText:"Baixar",onConfirm:()=>{m();try{let n=document.createElement("a");n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.download=a,n.style.display="none",document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.contains(n)&&document.body.removeChild(n)},100),J.ZP.delete("/task/".concat(e))}catch(e){console.error("Erro ao tentar baixar arquivo:",e),et.Am.error("Erro ao baixar arquivo. Tente novamente.")}},onCancel:()=>{m(),J.ZP.delete("/task/".concat(e))}})}catch(a){var n,s,i,r,l,d,c,u,h,v;if(console.log(a),m(),"string"==typeof(null==a?void 0:null===(n=a.response)||void 0===n?void 0:null===(s=n.data)||void 0===s?void 0:s.error))return et.Am.error(null==a?void 0:null===(h=a.response)||void 0===h?void 0:null===(v=h.data)||void 0===v?void 0:v.error);let e=(null==a?void 0:null===(i=a.response)||void 0===i?void 0:null===(r=i.request)||void 0===r?void 0:r._response)||(null==a?void 0:null===(l=a.response)||void 0===l?void 0:null===(d=l.request)||void 0===d?void 0:d.response)||(null==a?void 0:null===(c=a.response)||void 0===c?void 0:null===(u=c.request)||void 0===u?void 0:u.responseText),t=e&&JSON.parse(e);"string"==typeof(null==t?void 0:t.message)&&et.Am.error(t.message)}}async function E(e){try{m(!0,"Gerando convites em m\xfaltiplos arquivos para download...");let t=(0,iC.x0)();localStorage.setItem(o.cp,t);let a=await J.ZP.get("/order/download-tickets-pdf-multi-files/".concat(e,"?requestId=").concat(t));if(a.data.error){if(502===a.data.error.status){_();return}return m(),et.Am.error(a.data.error.message)}if(!a.data.fileLink){et.Am.error("Link de download n\xe3o encontrado na resposta do servidor."),m();return}D({link:a.data.fileLink,fileName:a.data.fileName})}catch(e){var t;if((null==e?void 0:e.status)===502||(null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.status)===502){_();return}et.Am.error(null==e?void 0:e.message),console.log(e),m()}}async function P(e){try{m(!0,"Gerando convites em um arquivo para download...");let a=await J.ZP.get("/order/download-tickets-pdf/".concat(e),{responseType:"blob"});if(m(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let n=window.URL.createObjectURL(a.data),s=document.createElement("a");s.href=n,s.target="_blank",s.rel="noopener noreferrer",s.click()}catch(e){et.Am.error(e.message),m()}}(0,l.useEffect)(()=>{x&&("error"in x||"waiting_download"!==x.status||"download-pdf-tickets-multi-files"!==x.screen||(D({link:x.filePath,fileName:x.fileName}),v()))},[x]);let I=async e=>{try{(0,em.Z)({title:"Download de PDF de convites",text:"Como deseja que os arquivos de convites sejam baixados?",confirmButtonText:"Baixar em um arquivo PDF",cancelButtonText:"Baixar m\xfaltiplos arquivos PDF zipados",onConfirm:()=>{P(e)},onCancel:()=>{E(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};async function A(e){try{var a;m(!0,"Baixando tabela");let n=new URLSearchParams({...(null==u?void 0:u[i])||{},eventId:i,ticketTypeId:"invitation",page:0,limit:5e3,userTimeZone:(0,ej.Y5)()}),s=await J.ZP.get("/ticket-purchase/list?".concat(n));if(s.data.error)throw Error(t("error_on_processing")+"\n\n"+s.data.error.message);if(null===(a=s.data)||void 0===a?void 0:a.items.length){let t=[];s.data.items.map(a=>{var n;let s={};null===(n=Object.keys(e))||void 0===n||n.map(t=>{let n=t.split("."),i=e[t];n.map((e,t)=>{let r=a[e];"object"==typeof r&&(r=a[e][n[t+1]],n.pop()),s[i]=Array.isArray(r)?r.join(", "):r})}),t.push(s)});let a=t0.P6.json_to_sheet(t),n=(0,t0.cW)({Sheets:{data:a},SheetNames:["data"]},{bookType:"xlsx",type:"array"}),i=new Blob([n],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(i,"Distribuicao convites.xlsx")}m()}catch(e){m()}}return{refresh:b,items:y,numberOfItems:N,isLoading:f,showInvitationForm:k,openInvitationForm:function(){w(!0)},closeInvitationForm:function(){w(!1)},setStoredState:s,ticketInvitationLimit:r,ticketInvitationPage:d,ticketInvitationSearch:c,resendOrderInvitationsEmail:S,cancelOrderInvitation:function(e){(0,em.Z)({text:t("ticket_distribution.cancel_invitation?"),confirmButtonText:t("ticket_distribution.cancel_invitation_yes"),onConfirm:async()=>{m(!0);let a=await J.ZP.post("/ticket-invitation/cancel-order/".concat(e));if(m(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);et.Am.success(t("success_on_processing")),b()}})},downloadTable:A,downloadOrderTicketsPdf:I}},i9=e=>{var t;
1let{t:a,i18n:n}=(0,p.$)("admin"),{storedState:s,setStoredState:i}=(0,o.oR)(),{tableInvitationFilters:d,currentSelectedEvent:c}=s||{},u=(null==c?void 0:c._id)||null,m=(null==d?void 0:d[u])||{},{data:h,isLoading:x}=(0,eh.Z)("/ticket-purchase/filters?invitations=true&eventId=".concat(u)),{startDate:g,endDate:j,ticketTitle:f,status:b,userNameEmail:y}=m,[N,k]=l.useState(y),w=(0,ev.Nr)(N,300);function Z(e){let t={...d};t[u]={...m,...e},i({tableInvitationFilters:t,ticketInvitationPage:0})}return l.useEffect(()=>{k(y)},[u]),l.useEffect(()=>{Z({userNameEmail:w})},[w]),(0,r.jsxs)("div",{className:"table-invite-filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome/email do convidado",value:N||"",onValueChange:e=>k(e)}),!!N&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>k(""),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)(am.Z,{options:(null==h?void 0:h.tickets)||[],value:f,label:"Ingresso",cleanable:!0,multiple:!0,className:"select",onChange:e=>Z({ticketTitle:e})}),(0,r.jsx)(am.Z,{options:(null==h?void 0:null===(t=h.status)||void 0===t?void 0:t.filter(e=>!!e).map(e=>({label:a("ticket_distribution."+e),value:e})))||[],value:b,label:"Status",cleanable:!0,multiple:!0,className:"select",onChange:e=>Z({status:e})}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(a7.Z,{label:"Data de in\xedcio do envio",className:"input",value:g||null,onChange:e=>Z({startDate:e}),renderInput:e=>(0,r.jsx)(es.Z,{...e})}),!!g&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>Z({startDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(a7.Z,{label:"Data de fim do envio",className:"input",minDate:g?new Date(g):null,value:j||null,onChange:e=>Z({endDate:e?e.toISOString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e})}),!!j&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>Z({endDate:null}),children:(0,r.jsx)(ec.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:e.onRequestDownload,children:"Download tabela"}),(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...d};e[u]={},i({tableInvitationFilters:e,ticketInvitationPage:0}),k("")},children:"Limpar filtros"})]})]})},re=e=>{let{orderId:t,eventId:a}=e||{},{toggleLoader:n}=(0,ee.U2)(),{t:s,i18n:i}=(0,p.$)("admin"),{data:l,isLoading:o,refresh:d}=(0,eh.Z)("/ticket-purchase/list?orderId=".concat(t,"&eventId=").concat(a,"&withOrder=true")),{items:c,numberOfItems:u}=l;async function m(e){try{n(!0,"Gerando PDF");let t=await J.ZP.get("/ticket-purchase/download/".concat(e),{responseType:"blob"});if(n(),t.data.error)throw Error(s("error_on_processing")+"\n\n"+t.data.error.message);let a=window.URL.createObjectURL(t.data),i=document.createElement("a");i.href=a,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){n()}}let{ticket:h,order:v,obs:x,user:g,inviter:j}=(null==c?void 0:c[0])||{};return(0,r.jsx)("div",{className:"ticket-invitations-details",children:o?(0,r.jsx)(ee.aN,{}):u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ei.Z,{title:"Convite",onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(eP.Z,{src:h.coverImageUrl,width:250,height:250/1.8})}),(0,r.jsxs)("div",{className:"col",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",h.title]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",j.name," (",j.email,")"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Portador:"})," ",g.name," (",g.email,")"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data do pedido:"})," ",(0,ej.p6)(v.createdAt,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do pedido:"})," ",t]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Quantidade:"})," ",u]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Obs:"})," ",x]})]})]}),(0,r.jsx)("div",{className:"table-container",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Id"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:s("ticket_invitation.visit_date")}),(0,r.jsx)("th",{children:"Checkin"}),(0,r.jsx)("th",{children:s("updated_at")}),(0,r.jsx)("th",{children:s("action")})]})}),(0,r.jsx)("tbody",{children:null==c?void 0:c.map((e,t)=>{let a=e.date?(0,ej.p6)(e.date,"P",i.language)+" "+e.time:(null==e?void 0:e.ticket.type)==="passport"?"Indefinida":s("ticket_distribution.no_date_set"),l=e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",i.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"-",o=(0,ej.p6)(e.updatedAt,"Pp",i.language),c=(null==e?void 0:e.ticket.type)!=="passport"&&!e.date||"PAID"!==e.orderStatus,u=e.checkInDates.length===e.useLimit;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:s("ticket_distribution."+e.status)}),(0,r.jsx)("td",{children:a}),(0,r.jsx)("td",{children:l}),(0,r.jsx)("td",{children:o}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:s("ticket_distribution.resend_invitation"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>{var t;return t=e.id,void(0,em.Z)({text:s("ticket_distribution.resend_invitation")+"?",confirmButtonText:s("ticket_distribution.resend_invitation_yes"),onConfirm:async()=>{n(!0);let e=await (0,J.ZP)("/ticket-purchase/resend-email/ticket-purchase/".concat(t));if(n(),e.data.error)throw Error(s("error_on_processing")+"\n\n"+e.data.error.message);et.Am.success(s("success_on_processing"))}})},disabled:u,children:(0,r.jsx)(eO.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:"Ver convite",children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:c,onClick:()=>m(e.id),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:s("ticket_distribution.cancel_invitation"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:u,onClick:()=>{var t;return t=e.id,void(0,em.Z)({text:s("ticket_distribution.cancel_invitation?"),confirmButtonText:s("ticket_distribution.cancel_invitation_yes"),onConfirm:async()=>{n(!0);let e=await J.ZP.post("/ticket-invitation/cancel-invitation/".concat(t));if(n(),e.data.error)throw Error(s("error_on_processing")+"\n\n"+e.data.error.message);et.Am.success(s("success_on_processing")),d()}})},children:(0,r.jsx)(eg.Z,{})})})})]})})]},t)})})]})})]})]}):(0,r.jsx)("div",{children:"Nenhum item encontrado!"})})},rt=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),n=null==a?void 0:a.currentSelectedEvent,{toggleLoader:s}=(0,ee.U2)(),{id:i,status:d,setTaskId:c,setTask:u,description:m,progress:h,title:x,starting:g}=n5({screen:nL}),{refresh:j,items:f,numberOfItems:b,isLoading:y,showInvitationForm:N,openInvitationForm:k,closeInvitationForm:w,setStoredState:Z,ticketInvitationLimit:C,ticketInvitationPage:S,ticketInvitationSearch:_,resendOrderInvitationsEmail:D,cancelOrderInvitation:E,downloadTable:P,downloadOrderTicketsPdf:I}=i4();return(0,l.useEffect)(()=>
1{if("completed"===d&&i){s(!0,e("ticket_invitation.bulk_task_finalizing"));let t=setTimeout(()=>{s(!1),et.Am.success(e("success_on_processing")),j(),w(),c(null),u({})},3e3);return()=>clearTimeout(t)}},[d,i]),(0,l.useEffect)(()=>{"error"===d&&i&&(s(!1),et.Am.error(e("error_on_processing")),c(null),u({}))},[d,i]),(0,r.jsxs)("div",{className:"professionals-and-suppliers invitations",children:[(0,r.jsxs)("div",{className:"header",children:[(0,r.jsx)("h3",{children:"Distribui\xe7\xe3o dos convites"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>k(),className:"add-ticket",disabled:!(null==n?void 0:n.status)||(null==n?void 0:n.status)==="ended",children:e("ticket_invitation.create")})]}),(0,r.jsx)(i9,{onRequestDownload:()=>P({id:"id","user.name":e("ticket_invitation.user_name"),"user.email":e("ticket_invitation.user_email"),"ticket.title":e("ticket_distribution.ticket"),orderId:"Pedido",checkInDates:"Checkin",date:"Data visita",status:"Status",time:e("ticket_invitation.visit_date"),"inviter.name":"Enviado por (nome)","inviter.email":"Enviado por (email)",obs:"Obs",updatedAt:e("updated_at"),link:"link"})}),y?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!(null==f?void 0:f.length)&&(0,r.jsx)("div",{className:"nothing-found",children:e("nothing_found")}),!!b&&(0,r.jsxs)("div",{className:"number-of-items",children:[b," convites encontrados"]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:e("ticket_invitation.user_name")}),(0,r.jsx)("th",{children:e("ticket_invitation.user_email")}),(0,r.jsx)("th",{children:e("ticket_distribution.ticket")}),(0,r.jsx)("th",{children:"Quantidade convites"}),(0,r.jsx)("th",{children:e("ticket_invitation.sent_by")}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:e("obs")}),(0,r.jsx)("th",{children:e("updated_at")}),(0,r.jsx)("th",{children:e("action")})]})}),(0,r.jsx)("tbody",{children:null==f?void 0:f.map((a,s)=>{var i,l,o;a.date?((0,ej.p6)(a.date,"P",t.language),a.time):(null==a?void 0:a.ticket.type)==="passport"||e("ticket_distribution.no_date_set"),a.checkInDates.length&&"".concat(a.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",t.language)).join(", ")," (").concat(a.checkInDates.length,"/").concat(a.useLimit,")");let d=(0,ej.p6)(a.updatedAt,"Pp",t.language),c=(null==a?void 0:a.ticket.type)!=="passport"&&!a.date||"PAID"!==a.orderStatus,u=a.checkInDates.length===a.useLimit;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:a.orderId}),(0,r.jsx)("td",{children:null===(i=a.user)||void 0===i?void 0:i.name}),(0,r.jsx)("td",{children:null===(l=a.user)||void 0===l?void 0:l.email}),(0,r.jsx)("td",{children:null==a?void 0:a.ticket.title}),(0,r.jsx)("td",{children:(null==a?void 0:a.totalQty)||0}),(0,r.jsx)("td",{children:null===(o=a.inviter)||void 0===o?void 0:o.name}),(0,r.jsx)("td",{children:e("ticket_distribution."+a.status)}),(0,r.jsx)("td",{children:a.obs}),(0,r.jsx)("td",{children:d}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:e("ticket_distribution.resend_invitation"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>D(a.orderId),disabled:u,children:(0,r.jsx)(eO.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:e("ticket_distribution.download_invitation"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:c,onClick:()=>I(a.orderId),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:e("ticket_distribution.cancel_invitation"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:u,onClick:()=>E(a.orderId),children:(0,r.jsx)(eg.Z,{})})})}),(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(re,{orderId:a.orderId,eventId:n._id})),children:(0,r.jsx)(nZ.Z,{})})]})})]},s)})})]}),(0,r.jsx)(eZ,{numberOfItems:b,rowsPerPage:C,page:S,onPageChange:e=>Z({ticketInvitationPage:e}),onRowsPerPageChange:e=>Z({ticketInvitationPage:0,ticketInvitationLimit:e})})]}),(0,r.jsx)(nX,{open:!!i&&("in_progress"===d||g),title:x,description:m,progress:h,starting:g}),(0,r.jsx)(K.ZP,{showAt:!!N,onClose:w,children:(0,r.jsx)(nJ,{setTaskId:c,setTask:u,onClose:e=>{e&&j(),w()}})})]})},ra=e=>{var t,a,n,s,i,l,o;let{orderId:d,onChange:c}=e||{},{toggleLoader:u}=(0,ee.U2)(),{t:m,i18n:h}=(0,p.$)("admin"),{cancelOrder:x,cancelFreeOrder:g,sendRefundedToEmail:j,sendRefundedToWhatsapp:f,sendToEmail:b,sendToWhatsapp:y}=iL(),{data:N={},isLoading:k}=(0,eh.Z)("/ticket-purchase/list?orderId=".concat(d,"&withOrder=true")),w=N.items||[],{paymentStatus:Z,channel:C,transaction:S,itemsAmount:_,donationAmount:D=0,paymentMethod:E,installments:P,splitInfo:I,createdAt:A,totalAmount:T,payerInfo:R,updatedAt:L}=(null==N?void 0:null===(t=N.items)||void 0===t?void 0:t[0].order)||{},q=("AUTHORIZED"===Z||"PAID"===Z)&&"free"!==E;async function M(){(0,em.Z)({text:"Deseja realmente realizar o cancelamento deste pedido?",confirmButtonText:"Sim, desejo cancelar",onConfirm:async()=>{u(!0,"Realizando devolu\xe7\xe3o pagamento");let e=await J.ZP.post("/order/return-payment",{orderId:d});if(u(),e.data.error)return et.Am.error(e.data.error.message);et.Am.success("Devolu\xe7\xe3o realizada com sucesso"),c()},onError:()=>{u()}})}
1return(0,r.jsxs)("div",{className:"ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:"Detalhes do pedido",onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[k&&(0,r.jsx)(ee.aN,{message:"Buscando detalhes da compra e ingressos",inline:!0}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id:"})," ",d]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data:"})," ",(0,ej.p6)(A,"Pp")]}),"invitation"!==C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status:"})," ",m("ticket_distribution."+Z)]}),"DECLINED"===Z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",(0,iF.pH)(null==S?void 0:null===(a=S.charges)||void 0===a?void 0:null===(n=a[0])||void 0===n?void 0:null===(s=n.payment_response)||void 0===s?void 0:s.message,S)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"C\xf3digo erro:"})," ",null==S?void 0:null===(i=S.charges)||void 0===i?void 0:null===(l=i[0])||void 0===l?void 0:null===(o=l.payment_response)||void 0===o?void 0:o.code]})]}),(0,r.jsx)("b",{children:"Comprador:"}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Nome:"}),(null==R?void 0:R.name)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Email:"}),(null==R?void 0:R.email)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Documento:"}),(null==R?void 0:R.docType)?(null==R?void 0:R.docType)+": "+(null==R?void 0:R.docNumber):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total ingressos:"})," ",(0,sL.n)(_)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total doa\xe7\xf5es:"})," ",(0,sL.n)(D)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total (ingressos + doa\xe7\xf5es):"})," ",(0,sL.n)(T)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Pagamento:"}),P,"x ",(0,sL.n)(T/P)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"M\xe9todo de pagamento:"})," ",E?m("ticket_distribution."+E):"N\xe3o aplicado"]}),I&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Repasse:"}),(0,sL.n)(_*I.share/100)," (",I.name,")"]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Canal de venda:"})," ",m("ticket_distribution."+C)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(L,"Pp")]}),q&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:M,children:"Realizar devolu\xe7\xe3o (Estorno)"})}),!q&&"CANCELED"!==Z&&"PAYMENT_REFUNDED"!==Z&&"card-machine"===C&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:()=>x(d),children:"Cancelar pedido"})}),"PAID"===Z&&"free"===E&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:()=>g(d),children:"Cancelar pedido"})}),"PAYMENT_REFUNDED"===Z&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>j(d),startIcon:(0,r.jsx)(eO.Z,{}),children:"Enviar Mensagem de Estorno por Email"}),(null==R?void 0:R.celphone)&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>f(d),startIcon:(0,r.jsx)(iM.Z,{}),children:"Enviar Mensagem de Estorno no Whatsapp"})]}),"PAID"===Z&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>b(d),startIcon:(0,r.jsx)(eO.Z,{}),children:"Enviar ingressos comprados no email"}),(null==R?void 0:R.celphone)&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>y(d),startIcon:(0,r.jsx)(iM.Z,{}),children:"Enviar ingressos comprados no whatsapp"})]}),(0,r.jsxs)("div",{className:"tickets",children:[(0,r.jsx)("h4",{children:"Ingressos:"}),w.map(e=>{let{id:t,ticket:a,date:n,ticketDiscount:s,discount:i,coupon:l,couponDiscount:o,donationValue:d,creditCardDiscount:c,ticketType:u,time:v,totalValue:x,updatedAt:p,user:g,value:j,orderStatus:f,inviter:b,checkInDates:y,useLimit:N,lastUpdatedBy:k,promotion:w}=e,Z=y.length?"".concat(y.map(e=>(0,ej.p6)(e.date,"Pp",h.language)).join(", ")," (").concat(y.length,"/").concat(N,")"):"";return(0,r.jsxs)("div",{className:"ticket",style:{marginBottom:10,padding:15,border:"solid 1px lightgrey"},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",a.title]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do ingresso:"})," ",t]}),"invitation"===C&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",b.name]}),(0,r.jsx)("b",{children:"Portador:"}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Nome:"}),(null==g?void 0:g.name)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Email:"}),(null==g?void 0:g.email)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Documento:"}),(null==g?void 0:g.docType)?(null==g?void 0:g.docType)+": "+(null==g?void 0:g.docNumber):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data visita:"})," ",n?(0,ej.p6)(n,"P",h.language)+" "+(v||""):"Indefinido"]}),i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(100*j/90)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto geral ingresso:"})," ",i,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor ingresso com desconto:"})," ",(0,sL.n)(j)]})]}):(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(j)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status do ingresso:"})," ","".concat(m("ticket_distribution."+f))]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo ingresso:"})," ",u.type]}),!!s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto tipo ingresso:"})," ",s,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor ingresso com desconto:"})," ",(0,sL.n)(j*(1-s/100))]})]}),!!d&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor doa\xe7\xf5es:"})," ",(0,sL.n)(d)]}),!!l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cupom aplicado:"})," ",null==l?void 0:l.code]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto cupom:"})," ",o,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto do cupom:"})," ",(0,sL.n)(j*(1-o/100))]})]}),c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto Cart\xe3o BRB:"})," ","".concat(c.discount,"%")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cart\xe3o:"})," ",c.card]})]}):null,(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Checkin:"})," ",Z||"Indefinido"]}),w&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Promo\xe7\xe3o:"})," ",w.promotionName]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(p,"Pp")]})]},a.id)})]})]})]})},rn={processed:"Disparado (aceito pelo SendGrid)",delivered:"Enviado (chegou ao provedor)",deferred:"Adiado",bounce:"Erro (bounce)",dropped:"Erro (drop)",open:"Aberto",click:"Clique",spamreport:"Marcado como spam",unsubscribe:"Unsubscribe",group_unsubscribe:"grupo",group_resubscribe:"grupo"},rs={website:"Site",app:"App","card-machine":"Maquininha",invitation:"Convite"},ri={bounce:"Bounce (permanente)",blocked:"Bloqueado"},rr={"Invalid Address":"Endere\xe7o inv\xe1lido",Technical:"T\xe9cnico",Content:"Conte\xfado",Reputation:"Reputa\xe7\xe3o","Frequency/Volume":"Frequ\xeancia/volume","Mailbox Unavailable":"Caixa indispon\xedvel",Unclassified:"N\xe3o classificado"},rl=e=>{let{orderId:t}=e,{data:a,isLoading:n}=(0,eh.Z)("/email-event/timeline/".concat(t)),s=a&&!Array.isArray(a)?a:void 0,i=[...(null==s?void 0:s.items)||[]].sort((e,t)=>
1new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());return(0,r.jsxs)("div",{className:"email-timeline ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:"Hist\xf3rico do e-mail — pedido ".concat(t),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"content",children:[n&&(0,r.jsx)(ee.aN,{message:"Carregando hist\xf3rico do e-mail",inline:!0}),!n&&!i.length&&(0,r.jsx)("div",{className:"nothing-found",children:"Nenhum evento SendGrid ainda. O rastreio come\xe7a ap\xf3s configurar o webhook e reenviar/novos envios."}),!n&&!!i.length&&(0,r.jsx)("ul",{className:"timeline-list",children:i.map(e=>{var t,a;return(0,r.jsxs)("li",{className:"timeline-item ".concat("open"===(t=e.event)||"click"===t?"success":"bounce"===t||"dropped"===t||"spamreport"===t?"error":"default"),children:[(0,r.jsx)("div",{className:"timeline-dot"}),(0,r.jsxs)("div",{className:"timeline-body",children:[(0,r.jsx)("div",{className:"timeline-time",children:(0,ej.p6)(e.timestamp,"Pp")}),(0,r.jsx)("div",{className:"timeline-label",children:rn[a=e.event]||a}),e.email&&(0,r.jsxs)("div",{className:"timeline-meta",children:[(0,r.jsx)("b",{children:"E-mail:"})," ",e.email]}),e.reason&&(0,r.jsxs)("div",{className:"timeline-meta",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",e.reason]}),e.bounceType&&(0,r.jsxs)("div",{className:"timeline-meta",children:[(0,r.jsx)("b",{children:"Tipo de bounce:"})," ",e.bounceType]}),e.url&&(0,r.jsxs)("div",{className:"timeline-meta",children:[(0,r.jsx)("b",{children:"URL:"})," ",e.url]})]})]},e.id)})})]})]})},ro=e=>{var t,a,n;let{t:s,i18n:i}=(0,p.$)("admin"),{storedState:d,setStoredState:c}=(0,o.oR)(),{ordersFilter:u={},currentSelectedEvent:m}=d||{},[h,x]=l.useState(""),g=(0,ev.Nr)(h,300),[j,f]=l.useState(!1),[b,y]=l.useState([]),[N,k]=l.useState(null),[w,Z]=l.useState({}),[C,S]=l.useState({}),_=(null==m?void 0:m._id)||null,{data:D,isLoading:E}=(0,eh.Z)("/order/filters?eventId=".concat(_));l.useEffect(()=>{async function e(){var e;f(!0);let t=await J.ZP.get("/ticket-purchase/emails-users?eventId=".concat(_,"&search=").concat(g,"&byEvent=true"));null!=t&&null!==(e=t.data)&&void 0!==e&&e.error||(y(t.data.emails||[]),f(!1))}(null==g?void 0:g.length)>4&&e()},[g]);let{sellStartDate:P,sellEndDate:I,orderId:A,paymentType:T,paymentStatus:R,payerNameEmail:L,channel:q,userEmail:M}=w;function O(e){Z({...w,...e})}function F(){if(!P)return S({startDate:!0}),et.Am.error("Data in\xedcio obrigat\xf3ria para venda!");if(P&&I&&(0,av.Z)((0,tD.Z)(new Date(I)),(0,tD.Z)(new Date(P))))return S({sellEndDate:!0}),et.Am.error("Data de in\xedcio n\xe3o deve ser maior que a data fim!");S({sellStartDate:!1,sellEndDate:!1});let t={...u};t[_]=w,Object.keys(t[_]).map(e=>{let a=t[_][e];a&&"string"==typeof a&&"payerNameEmail"!==e&&"Invalid Date"!==new Date(a).toString()&&(t[_][e]=new Date(a))}),c({ordersFilter:t,ordersPage:0}),e.onLoadData({ordersFilterParams:t,ordersPageParams:0})}l.useEffect(()=>{M&&(y([{_id:M,qty:0}]),k({_id:M,qty:0}))},[M]),l.useEffect(()=>{if(!_)return;let e={paymentStatus:["PAID"],sellStartDate:new Date,sellEndDate:new Date},t={...e,...u[_]};Z(t)},[_]);let B=l.useRef(!1);return l.useEffect(()=>{Object.keys(w).length&&(B.current||(F(),B.current=!0))},[w]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Id da transa\xe7\xe3o",value:A||"",onValueChange:e=>O({orderId:e})}),!!A&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>O({orderId:""}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome, email ou telefone do comprador",value:L||"",onValueChange:e=>O({payerNameEmail:e})}),!!L&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>O({payerNameEmail:""}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(e_.Z,{id:"users",className:"user-select",options:b,getOptionLabel:e=>e._id,multiple:!1,loading:j,loadingText:"Carregando...",value:N,onChange:(e,t)=>
1{k(t),O({userEmail:null==t?void 0:t._id})},onInputChange:(e,t)=>{x(t),O({userEmail:""})},noOptionsText:(null==g?void 0:g.length)>4?"Nenhum email encontrado":"Digite ao menos 5 caracteres para iniciar a busca de emails relacionados aos portadores",renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"Email do portador",inputProps:e.inputProps}),renderTags:(e,t)=>e.map(e=>(0,r.jsxs)("li",{...t,className:"user-select-selected",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(e._id)})}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>k(null),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e._id)),renderOption:(e,t)=>{let{_id:a,qty:n}=t;return(0,l.createElement)("li",{...e,key:a,className:"user-select-list-opt"},(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:"".concat(a)})}))}}),M||N||b.length?(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:30},onClick:()=>{y([]),k(null),O({userEmail:""})},children:(0,r.jsx)(ec.Z,{})}):null]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data in\xedcio",className:"input",value:P||null,onChange:e=>O({sellStartDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:C.sellStartDate||C.startDate})}),!!P&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>O({sellStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data fim",className:"input",shouldDisableDate:e=>!!P&&(0,tS.Z)(new Date(e),1)<new Date(P),value:I||null,onChange:e=>O({sellEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{error:C.sellEndDate,...e})}),!!I&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>O({sellEndDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)(am.Z,{options:(null==D?void 0:null===(t=D.channels)||void 0===t?void 0:t.filter(e=>!!e).map(e=>({label:s("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:q,label:"Canal de venda",onChange:e=>O({channel:e}),isLoading:E}),(0,r.jsx)(am.Z,{options:(null==D?void 0:null===(a=D.paymentMethods)||void 0===a?void 0:a.filter(e=>!!e).map(e=>({label:s("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:T,label:"M\xe9todo de pagamento",onChange:e=>O({paymentType:e}),isLoading:E}),(0,r.jsx)(am.Z,{options:(null==D?void 0:null===(n=D.paymentStatus)||void 0===n?void 0:n.filter(e=>!!e).map(e=>({label:s("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:R,label:"Status do pedido",onChange:e=>{O({paymentStatus:e})},isLoading:E})]}),(0,r.jsxs)("div",{className:"row last",children:[(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:e.onRequestDownload,children:"Download tabela"}),(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...u};e[_]={},c({ordersFilter:e,ordersPage:0}),Z({})},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:F,children:"Aplicar filtros"})]})]})},rd=()=>{let{setStoredState:e}=(0,o.oR)(),{t,i18n:a}=(0,p.$)("admin"),{items:n,numberOfItems:s,isLoading:i,ordersLimit:d,ordersPage:c,onLoadData:u,downloadTable:m,onDownloadOrderTicketsPdf:h,downloadOrderTicketsPdf:v,updateStatusOrder:x}=iL();return l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Transa\xe7\xf5es"})}),(0,r.jsx)(ro,{onRequestDownload:m,onLoadData:u}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Id"}),(0,r.jsx)("th",{children:"Tipo de Transa\xe7\xe3o"}),(0,r.jsx)("th",{children:"ID Transa\xe7\xe3o Pagamento"}),(0,r.jsx)("th",{children:"Gateway de Pagamento"}),(0,r.jsx)("th",{children:"Comprador nome"}),(0,r.jsx)("th",{children:"Comprador email"}),(0,r.jsx)("th",{children:"Comprador telefone"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Valor do pedido"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:t("action")})]})}),(0,r.jsx)("tbody",{children:null==n?void 0:n.map((e,n)=>{var s,i,l,o,d;let c=(0,ej.p6)(e.createdAt,"Pp",a.language),m="PAID"===e.paymentStatus;return null==e||e.channel,(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:"".concat(null==e?void 0:e.type).includes("GIVEX")?e.type:"COMPRA DE INGRESSO"}),(0,r.jsx)("td",{children:e.transactionId||"N\xe3o identificado"}),(0,r.jsx)("td",{children:e.gatewayPaymentName||"N\xe3o identificado"}),(0,r.jsx)("td",{children:null===(s=e.payerInfo)||void 0===s?void 0:s.name}),(0,r.jsx)("td",{children:null===(i=e.payerInfo)||void 0===i?void 0:i.email}),(0,r.jsx)("td",{children:(null===(l=e.payerInfo)||void 0===l?void 0:l.celphone)||"-"}),(0,r.jsx)("td",{children:t("ticket_distribution."+e.channel)}),(0,r.jsx)("td",{children:(null==e?void 0:null===(o=e.machineOperator)||void 0===o?void 0:o.name)||""}),(0,r.jsx)("td",{children:(null==e?void 0:null===(d=e.transaction)||void 0===d?void 0:d.terminalSerialNumber)||""}),(0,r.jsx)("td",{children:t("ticket_distribution."+e.paymentStatus)}),(0,r.jsx)("td",{children:t("ticket_distribution."+(e.paymentMethod||"not-registered"))}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalAmount)}),(0,r.jsx)("td",{children:c}),(0,r.jsxs)("td",{className:"actions",children:[!"".concat(null==e?void 0:e.type).includes("GIVEX")&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.update_status"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>x(e.id),children:(0,r.jsx)(ns.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.download_tickets_pdf"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:!m,onClick:()=>h(e.id),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.download_tickets"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:!m,onClick:()=>v(e.id),children:(0,r.jsx)(nC.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:"Hist\xf3rico do e-mail",children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:!m,onClick:()=>(0,K.K4)((0,r.jsx)(rl,{orderId:e.id})),children:(0,r.jsx)(eO.Z,{})})})})]}),(0,r.jsx)(eS.Z,{arrow:!0,title:t("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(ra,{orderId:e.id,onChange:u}
1)),disabled:"".concat(null==e?void 0:e.type).includes("GIVEX"),children:(0,r.jsx)(nZ.Z,{})})})})]})]},n)})})]})}),(0,r.jsx)(eZ,{numberOfItems:s,rowsPerPage:d,page:c,onPageChange:t=>{e({ordersPage:t}),u({ordersPageParams:t})},onRowsPerPageChange:t=>{e({ordersPage:0,ordersLimit:t}),u({ordersPageParams:0,ordersLimitParams:t})}})]})},rc=["Janeiro","Fevereiro","Mar\xe7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],ru=e=>{let{status:t,onDateChange:a}=e,{t:n}=(0,p.$)("admin"),[s,i]=l.useState(),[o,d]=l.useState(new Date),[c,u]=l.useState(new Date),m=(e,t)=>{t&&i(t),"today"===t&&(d(new Date),u(new Date))},h=(0,l.useCallback)(()=>{let e=(0,tD.Z)(o),t=(0,tP.Z)(c);"today"===s?(e=(0,tD.Z)(new Date),t=(0,tP.Z)(new Date)):"day"===s?(e=(0,tD.Z)(e),t=(0,tP.Z)(e)):"week"===s?(e=(0,tI.Z)(e),t=(0,tA.Z)(e)):"month"===s?(e=(0,sa.Z)(e),t=(0,sn.Z)(e)):"year"===s&&(e=(0,tT.Z)(e),t=(0,tR.Z)(e)),console.log("\uD83D\uDE80 ~ React.useEffect ~ dateRange:",s),a({dateRange:s,startDate:e,endDate:t,isSameDay:(0,tC.Z)(o,c),todayDate:new Date})},[s,o,c,a]),x=l.useMemo(()=>"day"===s||"today"===s?"".concat(o.getDate()," de ").concat((0,ej.p6)(o,"MMMM yyyy")):"week"===s?"De ".concat((0,tI.Z)(o).getDate()," \xe0 ").concat((0,tA.Z)(o).getDate()," de ").concat((0,ej.p6)(o,"MMMM yyyy")):"month"===s?"".concat(rc[o.getMonth()]):"Ano ".concat((0,ej.p6)(o,"yyyy")),[s,o]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Selecione um periodo e aplique o filtro"}),(0,r.jsxs)("div",{className:"date-range-select",children:[(0,r.jsxs)(ty.Z,{color:"primary",size:"small",value:s,exclusive:!0,onChange:m,className:"range-selector",disabled:"in_progress"===t,children:[(0,r.jsx)(tN.Z,{value:"today",children:"Hoje"}),(0,r.jsx)(tN.Z,{value:"day",children:"Dia Espec\xedfico"}),(0,r.jsx)(tN.Z,{value:"week",children:"Semana"}),(0,r.jsx)(tN.Z,{value:"month",children:"M\xeas"}),(0,r.jsx)(tN.Z,{value:"year",children:"Ano"}),(0,r.jsx)(tN.Z,{value:"custom",children:"Custom"})]}),s&&("custom"===s?(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsx)(tM.Z,{label:"".concat(n("start")),className:"input",value:o||null,onChange:e=>d(e),renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"}),disabled:"in_progress"===t}),(0,r.jsx)(tM.Z,{label:"".concat(n("end")),className:"input",value:c||null,onChange:e=>u(e),renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"}),disabled:"in_progress"===t}),(0,r.jsx)(v.Z,{variant:"contained",onClick:h,disabled:"in_progress"===t,children:"Aplicar filtro"})]}):(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsxs)("div",{className:"date-select",children:[(0,r.jsx)(X.Z,{onClick:function(){d(e=>"today"===s?(i("day"),(0,tS.Z)(e,-1)):"day"===s?(0,tS.Z)(e,-1):"week"===s?(0,tL.Z)(e,-1):"month"===s?(0,ss.Z)(e,-1):(0,tq.Z)(e,-1))},disabled:"in_progress"===t,children:(0,r.jsx)(tk.Z,{})}),"day"===s?(0,r.jsx)(tM.Z,{label:"Dia espec\xedfico",value:o||null,onChange:e=>{e&&d(e)},renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"}),disabled:"in_progress"===t}):(0,r.jsx)("div",{children:x}),(0,r.jsx)(X.Z,{onClick:function(){d(e=>"today"===s?(i("day"),(0,tS.Z)(e,1)):"day"===s?(0,tS.Z)(e,1):"week"===s?(0,tL.Z)(e,1):"month"===s?(0,ss.Z)(e,1):(0,tq.Z)(e,1))},disabled:"in_progress"===t,children:(0,r.jsx)(tw.Z,{})})]}),(0,r.jsx)(v.Z,{variant:"contained",onClick:h,disabled:"in_progress"===t,children:"Aplicar filtro"})]}))]})]})},rm=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},a=null==t?void 0:t._id,[n,s]=(0,l.useState)(null),{toggleLoader:i}=(0,ee.U2)(),r=null==n?void 0:n.startDate,d=null==n?void 0:n.endDate,c=Boolean(a&&r&&d),u=new URLSearchParams;a&&u.set("eventId",a),r&&u.set("startDate",r.toISOString()),d&&u.set("endDate",d.toISOString());let{data:m,isLoading:h}=(0,eh.Z)("/email-event/report?".concat(u),{enabled:c}),v=m&&!Array.isArray(m)?m:void 0,x=(0,l.useCallback)(e=>{s(e)},[]),p=async()=>{if(c)try{i(!0,"Exportando relat\xf3rio...");let e=await J.ZP.get("/email-event/report/export?".concat(u),{responseType:"blob"});i(),nE().saveAs(e.data,"emails-evento.xlsx")}catch(e){i(),et.Am.error((null==e?void 0:e.message)||"Erro ao exportar relat\xf3rio")}};return{eventId:a,filters:n,onDateChange:x,report:v,isLoading:c&&h,canFetch:c,exportExcel:p}};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.qi,tf.Dx,tf.u,tf.De);let rh={responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!0,text:"E-mails por dia"},legend:{position:"bottom",labels:{boxWidth:15}}}},rv={responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!0,text:"Entregues x erros"},legend:{position:"bottom"}}};function rx(e){let{byDay:t=[]}=e,a=l.useMemo(()=>({labels:t.map(e=>(function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[,t,a]=e.slice(0,10).split("-");return"".concat(a,"/").concat(t)}return(0,ej.p6)(e,"dd/MM")||e})(e.date)),datasets:[{label:"Enviados",data:t.map(e=>e.sent||0),backgroundColor:"#4e8bd8",borderColor:"#4e8bd8"},{label:"Entregues",data:t.map(e=>e.delivered||0),backgroundColor:"#2ab038",borderColor:"#2ab038"},{label:"Abertos",data:t.map(e=>e.opened||0),backgroundColor:"#2a18ed",borderColor:"#2a18ed"}]}),[t]);return t.length?(0,r.jsx)("div",{className:"chart-box",children:(0,r.jsx)(tb.$Q,{options:rh,data:a,height:300})}):null}function rp(e){let{totals:t}=e,a=(null==t?void 0:t.delivered)||0,n=(null==t?void 0:t.bounced)||0,s=(null==t?void 0:t.dropped)||0;return a||n||s?(0,r.jsx)("div",{className:"chart-box pie",children:(0,r.jsx)(tb.by,{options:rv,data:{labels:["Entregues","Erros (bounce)","Erros (drop)"],datasets:[{data:[a,n,s],backgroundColor:["#2ab038","#d32f2f","#9e9e9e"],borderColor:["#2ab038","#d32f2f","#9e9e9e"],borderWidth:1}]}})}):null}function rg(e){return"bounce"===e||"dropped"===e}function rj(e,t){return t?Math.round(e/t*1e4)/100:0}let rf=["website","app","card-machine"];function rb(e){let{items:t=[]}=e,{labels:a,sent:n,errors:s,totalSent:i,totalErrors:o}=l.useMemo(()=>{let e={};rf.forEach(t=>{e[t]={sent:0,errors:0}}),t.forEach(t=>{let a=rf.includes(t.channel)?t.channel:t.channel||"unknown";e[a]||(e[a]={sent:0,errors:0}),e[a].sent+=1,rg(t.status)&&(e[a].errors+=1)});let a=Object.keys(e).filter(e=>!rf.includes(e)),n=[...rf,...a].filter(t=>e[t]&&(e[t].sent>0||e[t].errors>0)),s=n.length?n:[...rf];return{labels:s.map(e=>rs[e]||("unknown"===e?"Sem canal":e)),sent:s.map(t=>e[t].sent),errors:s.map(t=>e[t].errors),totalSent:t.length,totalErrors:t.filter(e=>rg(e.status)).length}},[t]);return t.length?(0,r.jsx)("div",{className:"chart-box channel-outcome",children:(0,r.jsx)(tb.$Q,{options:{responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!0,text:"Canal de venda \xd7 sucesso / erro"},legend:{position:"bottom",labels:{boxWidth:15}},tooltip:{callbacks:{label(e){let t=n[e.dataIndex]||0,a=s[e.dataIndex]||0;return 0===e.datasetIndex?"Enviados: ".concat(t," (").concat(rj(t,i),"% dos envios)"):"Erros: ".concat(a," (").concat(rj(a,t),"% deste canal \xb7 ").concat(rj(a,o),"% dos erros)")}}}},scales:{x:{stacked:!1},y:{beginAtZero:!0,ticks:{precision:0}}}},data:{labels:a,datasets:[{label:"Enviados",data:n,backgroundColor:"#4e8bd8",borderColor:"#4e8bd8"},{label:"Erros",data:s,backgroundColor:"#d32f2f",borderColor:"#d32f2f"}]}})}):null}let ry=["website","app","card-machine"];function rN(e,t){return t?Math.round(e/t*1e4)/100:0}function rk(e){return e?rs[e]||e:"Sem canal"}function rw(e){return"bounce"===e||"dropped"===e}function rZ(e){return e.bounceClassification?rr[e.bounceClassification]||e.bounceClassification:"dropped"===e.status?"E-mail descartado pelo SendGrid":e.bounceType?ri[e.bounceType]||e.bounceType:"Falha na entrega"}let rC=e=>{let{eventId:t,date:a}=e,[n,s]=(0,l.useState)(!0),[i,o]=(0,l.useState)(""),[d,c]=(0,l.useState)(""),[u,m]=(0,l.useState)(""),{data:h,isLoading:x}=(0,eh.Z)("/email-event/report/day?eventId=".concat(encodeURIComponent(t),"&date=").concat(encodeURIComponent(a))),p=h&&!Array.isArray(h)?h:void 0,g=(null==p?void 0:p.items)||[],j=(0,l.useMemo)(()=>g.filter(e=>rw(e.status)),[g]),f=g.length,b=j.length,y=(0,l.useMemo)(()=>{let e={website:{sent:0,errors:0},app:{sent:0,errors:0},"card-machine":{sent:0,errors:0}};return g.forEach(t=>{let a=t.channel&&e[t.channel]?t.channel:null;a&&(e[a].sent+=1,rw(t.status)&&(e[a].errors+=1))}),e},[g]),N=(0,l.useMemo)(()=>{let e=u.trim().toLowerCase();return g.filter(t=>(!n||!!rw(t.status))&&(!i||t.channel===i)&&(!e||[t.email,t.orderId,t.reason,t.bounceClassification,t.status,t.channel,rk(t.channel),rZ(t)].filter(
1Boolean).some(t=>String(t).toLowerCase().includes(e))))},[g,n,i,u]),k=N.filter(e=>rw(e.status)),w=n?[]:N.filter(e=>!rw(e.status)),Z=(0,l.useMemo)(()=>{let e={};return k.forEach(t=>{let a=rZ(t);e[a]||(e[a]=[]),e[a].push(t)}),Object.entries(e).map(e=>{let[t,a]=e;return{title:t,items:a,count:a.length,percent:rN(a.length,k.length||b)}}).sort((e,t)=>t.count-e.count)},[k,b]);return(0,r.jsxs)("div",{className:"email-day-sends ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:"Envios de ".concat(function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[t,a,n]=e.slice(0,10).split("-");return"".concat(n,"/").concat(a,"/").concat(t)}return(0,ej.p6)(e,"P")||e}(a)),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"content",children:[x&&(0,r.jsx)(ee.aN,{message:"Carregando envios do dia",inline:!0}),!x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"channel-cards",children:[(0,r.jsxs)("div",{className:"card total-errors",children:[(0,r.jsx)("div",{className:"title",children:"Erros"}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Total"}),b]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Taxa do dia"}),rN(b,f),"%"]})]}),ry.map(e=>{let t=y[e];return(0,r.jsxs)("button",{type:"button",className:"card channel-card ".concat(i===e?"is-active":""),onClick:()=>o(t=>t===e?"":e),children:[(0,r.jsx)("div",{className:"title",children:rs[e]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"% dos envios"}),rN(t.sent,f),"%"]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Enviados"}),t.sent]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"% erro deste canal"}),rN(t.errors,t.sent),"%"]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Erros"}),t.errors]})]},e)})]}),(0,r.jsx)(rb,{items:g}),(0,r.jsxs)("div",{className:"day-toolbar",children:[(0,r.jsx)(es.Z,{size:"small",label:"Buscar e-mail, pedido, canal ou motivo",value:u,onChange:e=>m(e.target.value)}),(0,r.jsxs)(v.Z,{variant:n?"contained":"outlined",onClick:()=>s(e=>!e),children:["Somente erros (",b,")"]})]}),(0,r.jsxs)("p",{className:"day-summary",children:[N.length," de ",g.length," envios",(null==p?void 0:p.truncated)?" (lista limitada aos primeiros 2.000)":""]}),!g.length&&(0,r.jsx)("div",{className:"nothing-found",children:"Nenhum envio SendGrid neste dia."}),!!g.length&&!N.length&&(0,r.jsx)("div",{className:"nothing-found",children:"Nenhum envio corresponde ao filtro."}),!!Z.length&&(0,r.jsxs)("section",{className:"error-section",children:[(0,r.jsx)("h4",{children:"Erros do dia"}),(0,r.jsx)("div",{className:"error-groups",children:Z.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"error-group card ".concat(d===e.title?"is-open":""),onClick:()=>c(t=>t===e.title?"":e.title),children:[(0,r.jsx)("div",{className:"bar",style:{width:"".concat(e.percent,"%")}}),(0,r.jsx)("div",{className:"ticket-title",children:e.title}),(0,r.jsxs)("div",{className:"numbers",children:["QTY: ",e.count," | ",e.percent,"%"]})]}),d===e.title&&(0,r.jsx)("div",{className:"table-wrapper nested",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Hor\xe1rio"}),(0,r.jsx)("th",{children:"E-mail"}),(0,r.jsx)("th",{children:"Canal"}),(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:"Detalhe"})]})}),(0,r.jsx)("tbody",{children:e.items.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.timestamp?(0,ej.p6)(e.timestamp,"p"):"—"}),(0,r.jsx)("td",{className:"email-cell",children:e.email||"—"}),(0,r.jsx)("td",{children:rk(e.channel)}),(0,r.jsx)("td",{children:e.orderId||"—"}),(0,r.jsx)("td",{className:"reason-cell",children:function(e){let t=[];return e.bounceType&&t.push(ri[e.bounceType]||e.bounceType),e.reason&&t.push(e.reason),e.smtpStatus&&t.push("SMTP ".concat(e.smtpStatus)),t.join(" \xb7 ")}(e)||"—"})]},e.identity))})]})})]},e.title))})]}),!!w.length&&(0,r.jsxs)("section",{className:"sends-section",children:[(0,r.jsx)("h4",{children:"Demais envios"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Hor\xe1rio"}),(0,r.jsx)("th",{children:"E-mail"}),(0,r.jsx)("th",{children:"Canal"}),(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Aberto"})]})}),(0,r.jsx)("tbody",{children:w.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.timestamp?(0,ej.p6)(e.timestamp,"p"):"—"}),(0,r.jsx)("td",{className:"email-cell",children:e.email||"—"}),(0,r.jsx)("td",{children:rk(e.channel)}),(0,r.jsx)("td",{children:e.orderId||"—"}),(0,r.jsx)("td",{children:rn[t=e.status]||t}),(0,r.jsx)("td",{children:e.opened?"Sim":"N\xe3o"})]},e.identity)})})]})})]})]})]})]})};function rS(e){if(null==e||Number.isNaN(Number(e)))return"—";let t=Number(e);return"".concat((t<=1?100*t:t).toFixed(1),"%")}let r_=()=>
1{let{eventId:e,onDateChange:t,report:a,isLoading:n,canFetch:s,exportExcel:i}=rm(),l=(null==a?void 0:a.unique)||{sent:0,delivered:0,opened:0,bounced:0},o=null==a?void 0:a.rates,d=(null==a?void 0:a.byDay)||[];return(0,r.jsxs)("div",{className:"ticket-dashboard email-events-report",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"E-mails de confirma\xe7\xe3o"})}),(0,r.jsx)("p",{className:"note",children:"Filtrado pelo evento selecionado no header."}),!e&&(0,r.jsx)("div",{className:"nothing-found",children:"Selecione um evento no header"}),!!e&&(0,r.jsx)(ru,{status:void 0,onDateChange:t}),!!e&&s&&(0,r.jsx)("div",{className:"row last",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:i,disabled:n,children:"Exportar Excel"})}),n&&(0,r.jsx)(ee.aN,{message:"Carregando relat\xf3rio de e-mails",inline:!0}),!!e&&s&&!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"kpis",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Enviados"}),(0,r.jsx)("div",{className:"value",children:l.sent||0})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Entregues"}),(0,r.jsxs)("div",{className:"value",children:[l.delivered||0,(0,r.jsx)("span",{children:rS(null==o?void 0:o.deliveryRate)})]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Abertos"}),(0,r.jsxs)("div",{className:"value",children:[l.opened||0,(0,r.jsx)("span",{children:rS(null==o?void 0:o.openRate)})]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Erros"}),(0,r.jsxs)("div",{className:"value",children:[l.bounced||0,(0,r.jsx)("span",{children:rS(null==o?void 0:o.bounceRate)})]})]})]}),(0,r.jsxs)("div",{className:"charts",children:[(0,r.jsx)(rx,{byDay:d}),(0,r.jsx)(rp,{totals:null==a?void 0:a.totals})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Data"}),(0,r.jsx)("th",{children:"Enviados"}),(0,r.jsx)("th",{children:"Entregues"}),(0,r.jsx)("th",{children:"Abertos"}),(0,r.jsx)("th",{children:"Erros (bounce)"}),(0,r.jsx)("th",{children:"Erros (drop)"})]})}),(0,r.jsx)("tbody",{children:d.length?d.map(t=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("button",{type:"button",className:"day-link",onClick:()=>{e&&(0,K.K4)((0,r.jsx)(rC,{eventId:e,date:t.date}))},children:function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[t,a,n]=e.slice(0,10).split("-");return"".concat(n,"/").concat(a,"/").concat(t)}return(0,ej.p6)(e,"P")||e}(t.date)})}),(0,r.jsx)("td",{children:t.sent||0}),(0,r.jsx)("td",{children:t.delivered||0}),(0,r.jsx)("td",{children:t.opened||0}),(0,r.jsx)("td",{children:t.bounced||0}),(0,r.jsx)("td",{children:t.dropped||0})]},t.date)):(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,children:"Nenhum evento SendGrid no per\xedodo."})})})]})})]})]})},rD=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},a=null==t?void 0:t._id,[n,s]=(0,l.useState)(null),{toggleLoader:i}=(0,ee.U2)(),r=null==n?void 0:n.startDate,d=null==n?void 0:n.endDate,c=Boolean(a&&r&&d),u=new URLSearchParams;a&&u.set("eventId",a),r&&u.set("startDate",r.toISOString()),d&&u.set("endDate",d.toISOString());let{data:m,isLoading:h}=(0,eh.Z)("/whatsapp-event/report?".concat(u),{enabled:c}),v=m&&!Array.isArray(m)?m:void 0,x=(0,l.useCallback)(e=>{s(e)},[]),p=async()=>{if(c)try{i(!0,"Exportando relat\xf3rio...");let e=await J.ZP.get("/whatsapp-event/report/export?".concat(u),{responseType:"blob"});i(),nE().saveAs(e.data,"whatsapp-evento.xlsx")}catch(e){i(),et.Am.error((null==e?void 0:e.message)||"Erro ao exportar relat\xf3rio")}};return{eventId:a,filters:n,onDateChange:x,report:v,isLoading:c&&h,canFetch:c,exportExcel:p}},rE="#4e8bd8",rP="#2ab038",rI="#d32f2f",rA="#2a18ed",rT="#f9a825";tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.qi,tf.Dx,tf.u,tf.De);let rR={id:"casacorWhatsappValueLabels",afterDatasetsDraw(e){let{ctx:t}=e;if(t.save(),"pie"===e.config.type){let a=e.getDatasetMeta(0);a.data.forEach((a,n)=>{var s,i;let r=Number((null===(s=e.data.datasets[0])||void 0===s?void 0:null===(i=s.data)||void 0===i?void 0:i[n])||0);if(!r)return;let l=a.tooltipPosition();t.fillStyle="#fff",t.font="600 13px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(String(r),l.x,l.y)}
1),t.restore();return}e.data.datasets.forEach((a,n)=>{let s=e.getDatasetMeta(n);s.hidden||s.data.forEach((e,n)=>{var s;let i=Number((null===(s=a.data)||void 0===s?void 0:s[n])||0);i&&(t.fillStyle="#222",t.font="600 12px sans-serif",t.textAlign="center",t.textBaseline="bottom",t.fillText(String(i),e.x,e.y-4))})}),t.restore()}};function rL(e){let{byDay:t=[]}=e,a=l.useMemo(()=>{let e=t.map(e=>e.sent||0),a=t.map(e=>e.failed||0),n=t.map(e=>e.delivered||0),s=t.map(e=>e.read||0),i=t.map(e=>e.clicked||0),r=e=>e.some(e=>e>0),l=[{label:"Enviados",data:e,backgroundColor:rE,borderColor:rE},{label:"Entregues",data:n,backgroundColor:rP,borderColor:rP},{label:"Falha",data:a,backgroundColor:rI,borderColor:rI}];return r(s)&&l.push({label:"Lidos",data:s,backgroundColor:rA,borderColor:rA}),r(i)&&l.push({label:"Cliques",data:i,backgroundColor:rT,borderColor:rT}),{labels:t.map(e=>(function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[,t,a]=e.slice(0,10).split("-");return"".concat(a,"/").concat(t)}return(0,ej.p6)(e,"dd/MM")||e})(e.date)),datasets:l}},[t]),n=l.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,layout:{padding:{top:18}},plugins:{title:{display:!0,text:"WhatsApp por dia"},legend:{position:"bottom",labels:{boxWidth:15}}},scales:{y:{beginAtZero:!0,grace:"18%",ticks:{precision:0}}}}),[]);return t.length?(0,r.jsx)("div",{className:"chart-box",children:(0,r.jsx)(tb.$Q,{options:n,data:a,plugins:[rR],height:300})}):null}function rq(e){let{totals:t}=e,a=(null==t?void 0:t.sent)||0,n=(null==t?void 0:t.delivered)||0,s=(null==t?void 0:t.failed)||0;if(!a&&!n&&!s)return null;let i=[{label:"Enviados",value:a,color:rE},{label:"Entregues",value:n,color:rP},{label:"Falha",value:s,color:rI}],l=i.filter(e=>e.value>0),o=l.map(e=>e.value),d=l.map(e=>e.color),c=l.map(e=>e.label);return(0,r.jsx)("div",{className:"chart-box pie",children:(0,r.jsx)(tb.by,{options:{responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!0,text:"Enviados \xd7 entregues \xd7 falha"},legend:{position:"bottom",labels:{generateLabels:()=>i.map(e=>({text:"".concat(e.label,": ").concat(e.value),fillStyle:e.color,strokeStyle:e.color,hidden:!1,index:l.findIndex(t=>t.label===e.label)}))}}}},data:{labels:c,datasets:[{data:o,backgroundColor:d,borderColor:d,borderWidth:1}]},plugins:[rR]})})}function rM(e){return"failed"===e}function rO(e,t){return t?Math.round(e/t*1e4)/100:0}let rF=["website","app","card-machine"];function rB(e){let{items:t=[]}=e,{labels:a,sent:n,errors:s,totalSent:i,totalErrors:o}=l.useMemo(()=>{let e={};rF.forEach(t=>{e[t]={sent:0,errors:0}}),t.forEach(t=>{let a=rF.includes(t.channel)?t.channel:t.channel||"unknown";e[a]||(e[a]={sent:0,errors:0}),e[a].sent+=1,rM(t.status)&&(e[a].errors+=1)});let a=Object.keys(e).filter(e=>!rF.includes(e)),n=[...rF,...a].filter(t=>e[t]&&(e[t].sent>0||e[t].errors>0)),s=n.length?n:[...rF];return{labels:s.map(e=>rs[e]||("unknown"===e?"Sem canal":e)),sent:s.map(t=>e[t].sent),errors:s.map(t=>e[t].errors),totalSent:t.length,totalErrors:t.filter(e=>rM(e.status)).length}},[t]);return t.length?(0,r.jsx)("div",{className:"chart-box channel-outcome",children:(0,r.jsx)(tb.$Q,{options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{top:18}},plugins:{title:{display:!0,text:"Canal de venda \xd7 sucesso / erro"},legend:{position:"bottom",labels:{boxWidth:15}},tooltip:{callbacks:{label(e){let t=n[e.dataIndex]||0,a=s[e.dataIndex]||0;return 0===e.datasetIndex?"Enviados: ".concat(t," (").concat(rO(t,i),"% dos envios)"):"Falha: ".concat(a," (").concat(rO(a,t),"% deste canal \xb7 ").concat(rO(a,o),"% das falhas)")}}}},scales:{x:{stacked:!1},y:{beginAtZero:!0,grace:"18%",ticks:{precision:0}}}},data:{labels:a,datasets:[{label:"Enviados",data:n,backgroundColor:rE,borderColor:rE},{label:"Falha",data:s,backgroundColor:rI,borderColor:rI}]},plugins:[rR]})}):null}let rU={queued:"Na fila",sent:"Enviado (aceito pelo provedor)",delivered:"Entregue no aparelho",read:"Lido",failed:"Falha",skipped:"N\xe3o enviado",clicked:"Clique"},rz=["website","app","card-machine"];function rV(e,t){return t?Math.round(e/t*1e4)/100:0}function rG(e){return e?rs[e]||e:"Sem canal"}function rW(e){return"failed"===e}function r$(e){return e.errorTitle?e.errorTitle:e.errorCode?"Erro ".concat(e.errorCode):"Falha no envio"}let rH=e=>{let{eventId:t,date:a}=e,[n,s]=(0,l.useState)(!0),[i,o]=(0,l.useState)(""),[d,c]=(0,l.useState)(""),[u,m]=(0,l.useState)(""),{data:h,isLoading:x}=(0,eh.Z)("/whatsapp-event/report/day?eventId=".concat(encodeURIComponent(t),"&date=").concat(encodeURIComponent(a))),p=h&&!Array.isArray(h)?h:void 0,g=(null==p?void 0:p.items)||[],j=(0,l.useMemo)(()=>g.filter(e=>rW(e.status)),[g]),f=g.length,b=j.length,y=(0,l.useMemo)(()=>{let e={website:{sent:0,errors:0},app:{sent:0,errors:0},"card-machine":{sent:0,errors:0}};return g.forEach(t=>{let a=t.channel&&e[t.channel]?t.channel:null;a&&(e[a].sent+=1,rW(t.status)&&(e[a].errors+=1))}),e},[g]),N=(0,l.useMemo)(()=>{let e=u.trim().toLowerCase();return g.filter(t=>
1(!n||!!rW(t.status))&&(!i||t.channel===i)&&(!e||[t.phone,t.email,t.orderId,t.reason,t.errorCode,t.status,t.channel,rG(t.channel),r$(t)].filter(Boolean).some(t=>String(t).toLowerCase().includes(e))))},[g,n,i,u]),k=N.filter(e=>rW(e.status)),w=n?[]:N.filter(e=>!rW(e.status)),Z=(0,l.useMemo)(()=>{let e={};return k.forEach(t=>{let a=r$(t);e[a]||(e[a]=[]),e[a].push(t)}),Object.entries(e).map(e=>{let[t,a]=e;return{title:t,items:a,count:a.length,percent:rV(a.length,k.length||b)}}).sort((e,t)=>t.count-e.count)},[k,b]);return(0,r.jsxs)("div",{className:"email-day-sends ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:"Disparos de ".concat(function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[t,a,n]=e.slice(0,10).split("-");return"".concat(n,"/").concat(a,"/").concat(t)}return(0,ej.p6)(e,"P")||e}(a)),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"content",children:[x&&(0,r.jsx)(ee.aN,{message:"Carregando disparos do dia",inline:!0}),!x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"channel-cards",children:[(0,r.jsxs)("div",{className:"card total-errors",children:[(0,r.jsx)("div",{className:"title",children:"Erros"}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Total"}),b]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Taxa do dia"}),rV(b,f),"%"]})]}),rz.map(e=>{let t=y[e];return(0,r.jsxs)("button",{type:"button",className:"card channel-card ".concat(i===e?"is-active":""),onClick:()=>o(t=>t===e?"":e),children:[(0,r.jsx)("div",{className:"title",children:rs[e]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"% dos envios"}),rV(t.sent,f),"%"]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Enviados"}),t.sent]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"% erro deste canal"}),rV(t.errors,t.sent),"%"]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Erros"}),t.errors]})]},e)})]}),(0,r.jsx)(rB,{items:g}),(0,r.jsxs)("div",{className:"day-toolbar",children:[(0,r.jsx)(es.Z,{size:"small",label:"Buscar telefone, e-mail, pedido, canal ou motivo",value:u,onChange:e=>m(e.target.value)}),(0,r.jsxs)(v.Z,{variant:n?"contained":"outlined",onClick:()=>s(e=>!e),children:["Somente erros (",b,")"]})]}),(0,r.jsxs)("p",{className:"day-summary",children:[N.length," de ",g.length," disparos",(null==p?void 0:p.truncated)?" (lista limitada aos primeiros 2.000)":""]}),!g.length&&(0,r.jsx)("div",{className:"nothing-found",children:"Nenhum disparo WhatsApp neste dia."}),!!g.length&&!N.length&&(0,r.jsx)("div",{className:"nothing-found",children:"Nenhum disparo corresponde ao filtro."}),!!Z.length&&(0,r.jsxs)("section",{className:"error-section",children:[(0,r.jsx)("h4",{children:"Erros do dia"}),(0,r.jsx)("div",{className:"error-groups",children:Z.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"error-group card ".concat(d===e.title?"is-open":""),onClick:()=>c(t=>t===e.title?"":e.title),children:[(0,r.jsx)("div",{className:"bar",style:{width:"".concat(e.percent,"%")}}),(0,r.jsx)("div",{className:"ticket-title",children:e.title}),(0,r.jsxs)("div",{className:"numbers",children:["QTY: ",e.count," | ",e.percent,"%"]})]}),d===e.title&&(0,r.jsx)("div",{className:"table-wrapper nested",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Hor\xe1rio"}),(0,r.jsx)("th",{children:"WhatsApp"}),(0,r.jsx)("th",{children:"Canal"}),(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:"Detalhe"})]})}),(0,r.jsx)("tbody",{children:e.items.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.timestamp?(0,ej.p6)(e.timestamp,"p"):"—"}),(0,r.jsx)("td",{className:"email-cell",children:e.phone||"—"}),(0,r.jsx)("td",{children:rG(e.channel)}),(0,r.jsx)("td",{children:e.orderId||"—"}),(0,r.jsx)("td",{className:"reason-cell",children:function(e){let t=[];return e.errorCode&&t.push("c\xf3digo ".concat(e.errorCode)),e.reason&&t.push(e.reason),e.errorTitle&&t.push(e.errorTitle),t.join(" \xb7 ")}(e)||"—"})]},e.identity))})]})})]},e.title))})]}),!!w.length&&(0,r.jsxs)("section",{className:"sends-section",children:[(0,r.jsx)("h4",{children:"Demais disparos"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Hor\xe1rio"}),(0,r.jsx)("th",{children:"WhatsApp"}),(0,r.jsx)("th",{children:"Canal"}),(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Lido"}),(0,r.jsx)("th",{children:"Clicou"})]})}),(0,r.jsx)("tbody",{children:w.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.timestamp?(0,ej.p6)(e.timestamp,"p"):"—"}),(0,r.jsx)("td",{className:"email-cell",children:e.phone||"—"}),(0,r.jsx)("td",{children:rG(e.channel)}),(0,r.jsx)("td",{children:e.orderId||"—"}),(0,r.jsx)("td",{children:rU[t=e.status]||t}),(0,r.jsx)("td",{children:e.read?"Sim":"N\xe3o"}),(0,r.jsx)("td",{children:e.clicked?"Sim":"N\xe3o"})]},e.identity)})})]})})]})]})]})]})};function rJ(e){if(null==e||Number.isNaN(Number(e)))return"—";let t=Number(e);return"".concat((t<=1?100*t:t).toFixed(1),"%")}let rQ=()=>
1{let{eventId:e,onDateChange:t,report:a,isLoading:n,canFetch:s,exportExcel:i}=rD(),l=(null==a?void 0:a.unique)||{sent:0,delivered:0,read:0,clicked:0,failed:0},o=null==a?void 0:a.rates,d=(null==a?void 0:a.byDay)||[];return(0,r.jsxs)("div",{className:"ticket-dashboard email-events-report whatsapp-events-report",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Disparos de WhatsApp"})}),(0,r.jsx)("p",{className:"note",children:"Filtrado pelo evento selecionado no header. Entrega e leitura v\xeam do webhook do provedor. Clique \xe9 registrado quando o link rastre\xe1vel \xe9 aberto ou o provedor envia evento de bot\xe3o."}),!e&&(0,r.jsx)("div",{className:"nothing-found",children:"Selecione um evento no header"}),!!e&&(0,r.jsx)(ru,{status:void 0,onDateChange:t}),!!e&&s&&(0,r.jsx)("div",{className:"row last",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:i,disabled:n,children:"Exportar Excel"})}),n&&(0,r.jsx)(ee.aN,{message:"Carregando relat\xf3rio de WhatsApp",inline:!0}),!!e&&s&&!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"kpis",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Enviados"}),(0,r.jsx)("div",{className:"value",children:l.sent||0})]}),(0,r.jsxs)("div",{className:"card kpi-delivered",children:[(0,r.jsx)("div",{className:"title",children:"Entregues"}),(0,r.jsxs)("div",{className:"value",children:[l.delivered||0,(0,r.jsx)("span",{children:rJ(null==o?void 0:o.deliveryRate)})]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Lidos"}),(0,r.jsxs)("div",{className:"value",children:[l.read||0,(0,r.jsx)("span",{children:rJ(null==o?void 0:o.readRate)})]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("div",{className:"title",children:"Cliques"}),(0,r.jsxs)("div",{className:"value",children:[l.clicked||0,(0,r.jsx)("span",{children:rJ(null==o?void 0:o.clickRate)})]})]}),(0,r.jsxs)("div",{className:"card kpi-errors",children:[(0,r.jsx)("div",{className:"title",children:"Falha"}),(0,r.jsxs)("div",{className:"value",children:[l.failed||0,(0,r.jsx)("span",{children:rJ(null==o?void 0:o.failRate)})]})]})]}),(0,r.jsxs)("div",{className:"charts",children:[(0,r.jsx)(rL,{byDay:d}),(0,r.jsx)(rq,{totals:null==a?void 0:a.totals})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Data"}),(0,r.jsx)("th",{children:"Enviados"}),(0,r.jsx)("th",{children:"Entregues"}),(0,r.jsx)("th",{children:"Lidos"}),(0,r.jsx)("th",{children:"Cliques"}),(0,r.jsx)("th",{children:"Falha"})]})}),(0,r.jsx)("tbody",{children:d.length?d.map(t=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("button",{type:"button",className:"day-link",onClick:()=>{e&&(0,K.K4)((0,r.jsx)(rH,{eventId:e,date:t.date}))},children:function(e){if(/^\d{4}-\d{2}-\d{2}/.test(e)){let[t,a,n]=e.slice(0,10).split("-");return"".concat(n,"/").concat(a,"/").concat(t)}return(0,ej.p6)(e,"P")||e}(t.date)})}),(0,r.jsx)("td",{children:t.sent||0}),(0,r.jsx)("td",{children:t.delivered||0}),(0,r.jsx)("td",{children:t.read||0}),(0,r.jsx)("td",{children:t.clicked||0}),(0,r.jsx)("td",{children:t.failed||0})]},t.date)):(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,children:"Nenhum disparo WhatsApp no per\xedodo."})})})]})})]})]})},rY=e=>{var t,a;let{item:n}=e,s=(null==n?void 0:n.banner)||{},i=(null==n?void 0:n.event)||{},l=(null==n?void 0:n.order)||{};return(0,r.jsxs)("div",{className:"ticket-dashboard-details banner-clicks-details",children:[(0,r.jsx)(ei.Z,{title:"Detalhes do clique no banner",onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"ID:"})," ",n.id]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo:"})," ",n.type]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Slug:"})," ",n.slug]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Quantidade:"})," ",n.count]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Criado em:"})," ",(0,ej.p6)(n.createdAt,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Atualizado em:"})," ",(0,ej.p6)(n.updatedAt,"Pp")]}),(0,r.jsx)("div",{className:"title",children:"Banner"}),(0,r.jsx)("div",{className:"banner-preview",children:s.coverImage?(0,r.jsx)("img",{src:s.coverImage,alt:s.link||n.bannerId}):(0,r.jsx)("div",{children:"Imagem indispon\xedvel"})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"ID do banner:"})," ",n.bannerId]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Link:"})," ",s.link?(0,r.jsx)("a",{href:s.link,target:"_blank",rel:"noreferrer",children:s.link}):"Indefinido"]}),(0,r.jsx)("div",{className:"title",children:"Evento"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"T\xedtulo:"})," ",i.title||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Slug:"})," ",i.slug||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status:"})," ",i.status||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"In\xedcio:"})," ",i.startAt?(0,ej.p6)(i.startAt,"Pp"):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Fim:"})," ",i.endAt?(0,ej.p6)(i.endAt,"Pp"):"Indefinido"]}),(0,r.jsx)("div",{className:"title",children:"Pedido"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"ID:"})," ",l._id||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Short ID:"})," ",l.shortId||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status:"})," ",l.status||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Total:"})," ","number"==typeof l.totalAmount?(0,sL.n)(l.totalAmount):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data do pedido:"})," ",l.createdAt?(0,ej.p6)(l.createdAt,"Pp"):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Comprador:"})," ",(null===(t=l.payerInfo)||void 0===t?void 0:t.name)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Email:"})," ",(null===(a=l.payerInfo)||void 0===a?void 0:a.email)||"Indefinido"]})]})]})};var rK=a(87918),rX=a(23855);let r0={periodFrom:null,periodTo:null,bannerIds:[],payerEmails:[]},r1=e=>{var t;let{storedState:a,setStoredState:n}=(0,o.oR)(),{currentSelectedEvent:s,bannerClicksFilter:i={}}=a||{},d=(null==s?void 0:s._id)||null,[c,u]=l.useState(r0),[m,h]=l.useState({}),{data:x,isLoading:p}=(0,eh.Z)("/click/banner/metrics/filters?eventId=".concat(d),{enabled:!!d}),g=x||{},j=(null==s?void 0:s.startAt)?(0,rX.Z)(s.startAt):null,f=(null==s?void 0:s.endAt)?(0,rX.Z)(s.endAt):null,b=(null==g?void 0:g.banners)||[],y=(null==g?void 0:null===(t=g.payers)||void 0===t?void 0:t.map(e=>{var t;return{label:"".concat(e.count,"x - ").concat((null===(t=e.payer)||void 0===t?void 0:t.name)||e.email).concat(e.email?" (".concat(e.email,")"):""),value:e.email}}))||[],N=l.useMemo(()=>y.reduce((e,t)=>
1(e[t.value]=t.label,e),{}),[y]);function k(e){u({...c,...e})}return l.useEffect(()=>{if(!d)return;let e=i[d]||{};u({periodFrom:e.periodFrom||null,periodTo:e.periodTo||null,bannerIds:e.bannerIds||[],payerEmails:e.payerEmails||[]})},[d]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Per\xedodo De",className:"input",minDate:j||void 0,maxDate:f||void 0,value:c.periodFrom?new Date(c.periodFrom):null,onChange:e=>k({periodFrom:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:m.periodFrom})}),!!c.periodFrom&&(0,r.jsx)(X.Z,{className:"clear-btn",onClick:()=>k({periodFrom:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Per\xedodo At\xe9",className:"input",minDate:j||void 0,maxDate:f||void 0,shouldDisableDate:e=>!!c.periodFrom&&(0,tS.Z)(new Date(e),1)<new Date(c.periodFrom),value:c.periodTo?new Date(c.periodTo):null,onChange:e=>k({periodTo:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:m.periodTo})}),!!c.periodTo&&(0,r.jsx)(X.Z,{className:"clear-btn",onClick:()=>k({periodTo:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)(e_.Z,{multiple:!0,options:b,loading:p,value:b.filter(e=>c.bannerIds.includes(e.bannerId)),isOptionEqualToValue:(e,t)=>e.bannerId===t.bannerId,getOptionLabel:e=>"Banner ".concat(e.count,"x"),onChange:(e,t)=>
1k({bannerIds:t.map(e=>e.bannerId)}),renderTags:(e,t)=>e.map((e,a)=>{var n;let s=t({index:a});return(0,l.createElement)(rK.Z,{...s,key:e.bannerId,avatar:(null===(n=e.banner)||void 0===n?void 0:n.coverImage)?(0,r.jsx)("img",{src:e.banner.coverImage,alt:"Banner ".concat(e.count,"x"),style:{width:18,height:18,objectFit:"cover",borderRadius:4}}):void 0,label:"Banner ".concat(e.count,"x")})}),renderOption:(e,t)=>{var a;return(0,l.createElement)("li",{...e,key:t.bannerId,className:"banner-select-list-opt"},(0,r.jsxs)("div",{className:"banner-option",style:{display:"flex",alignItems:"center",gap:12,width:"100%"},children:[(null===(a=t.banner)||void 0===a?void 0:a.coverImage)?(0,r.jsx)("img",{src:t.banner.coverImage,alt:"Banner ".concat(t.count,"x"),style:{width:72,height:42,objectFit:"cover",borderRadius:6,border:"1px solid #ddd",flexShrink:0}}):(0,r.jsx)("div",{className:"banner-option-placeholder",style:{width:72,height:42,borderRadius:6,background:"#f0f0f0",flexShrink:0}}),(0,r.jsx)("div",{className:"banner-option-text",style:{display:"flex",flexDirection:"column",lineHeight:1.2,overflow:"hidden"},children:(0,r.jsx)("span",{children:"".concat(t.count,"x cliques")})})]}))},renderInput:e=>(0,r.jsx)(es.Z,{...e,label:"Banners",placeholder:"Selecione banners"})}),(0,r.jsx)(am.Z,{options:y,cleanable:!0,multiple:!0,value:c.payerEmails,label:"Compradores",onChange:e=>k({payerEmails:Array.isArray(e)?e:[]}),isLoading:p,selectProps:{renderValue:e=>{let t=Array.isArray(e)?e:"".concat(e).split(",");if(!t.length||!t[0])return"Todos";let a=t.map(e=>N[e]||e);return a.length>2?"".concat(a.slice(0,2).join(", ")," +").concat(a.length-2):a.join(", ")}}})]}),(0,r.jsxs)("div",{className:"row last",children:[(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:e.onRequestDownload,children:"Download tabela"}),(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){if(!d)return;let e={...i};
1e[d]={},n({bannerClicksFilter:e,bannerClicksPage:0}),u(r0)},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:function(){if(c.periodFrom&&c.periodTo&&(0,av.Z)((0,tD.Z)(new Date(c.periodTo)),(0,tD.Z)(new Date(c.periodFrom))))return h({periodTo:!0}),et.Am.error("A data inicial n\xe3o deve ser maior que a data final.");if(!d)return;let t={...i};t[d]={...c},Object.keys(t[d]).forEach(e=>{let a=t[d][e];"string"==typeof a&&a&&"Invalid Date"!==new Date(a).toString()&&"bannerIds"!==e&&"payerEmails"!==e&&(t[d][e]=new Date(a).toString())}),h({}),n({bannerClicksFilter:t,bannerClicksPage:0}),e.onLoadData({bannerClicksFilterParams:t,bannerClicksPageParams:0})},children:"Aplicar filtros"})]})]})};function r2(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":(0,ix.Z)(t,"yyyy-MM-dd")}let r3=()=>{var e;let{storedState:t}=(0,o.oR)(),{toggleLoader:a}=(0,ee.U2)(),[n,s]=(0,l.useState)({data:[],total:0,page:0,limit:20}),[i,r]=(0,l.useState)(!1),[d,c]=(0,l.useState)(null),{onListenerEndpoint:u,clearListener:m,response:h}=(0,iE.Z)(),v=(null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{bannerClicksLimit:x=20,bannerClicksPage:p=0,bannerClicksFilter:g={}}=t||{},j=(0,l.useCallback)(function(){let{bannerClicksFilterParams:e,bannerClicksPageParams:t,bannerClicksLimitParams:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(async()=>{var i,l,o,d,c,u,m;try{if(!v){s({data:[],total:0,page:0,limit:x});return}let o=e?e[v]:(null==g?void 0:g[v])||{},d="number"==typeof n?n:x;r(!0),a(!0,"Carregando dados...");let c=new URLSearchParams({eventId:v,page:("number"==typeof t?t:p).toString(),limit:d.toString()}),u=r2(o.periodFrom),m=r2(o.periodTo);if(u&&(c.set("periodFrom",u),c.set("startDate",u),c.set("startAt",u)),m&&(c.set("periodTo",m),c.set("endDate",m),c.set("endAt",m)),null===(i=o.bannerIds)||void 0===i?void 0:i.length){let e=o.bannerIds.join(",");c.set("bannerIds",e),c.set("bannerId",e)}if(null===(l=o.payerEmails)||void 0===l?void 0:l.length){let e=o.payerEmails.join(",");c.set("payerEmails",e),c.set("payerEmail",e)}let h=await J.ZP.get("/click/banner/metrics?".concat(c));if(h.data.error)return r(!1),a(),et.Am.error(h.data.error.message);s({data:h.data.data||[],total:h.data.total||0,page:h.data.page||0,limit:h.data.limit||d}),r(!1),a()}catch(e){console.log("\uD83D\uDE80 ~ onLoadData ~ error:",e),r(!1),a(),et.Am.error((null==e?void 0:null===(o=e.response)||void 0===o?void 0:null===(d=o.data)||void 0===d?void 0:null===(c=d.error)||void 0===c?void 0:c.message)||(null==e?void 0:null===(u=e.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.message)||(null==e?void 0:e.message)||"Erro ao carregar os banners clicks")}})()},[g,x,p,v,a]);async function f(){var e,t,n,s,i,r;try{if(!d)return;a(!0,"Baixando relat\xf3rio...");let t=await J.ZP.get("/task/".concat(d,"/download"),{responseType:"blob"});a();let n=null===(e=t.headers)||void 0===e?void 0:e["content-disposition"],s="banner-clicks.csv";if(n){let e=n.match(/filename['"]?=(?:['"]?)([^'";\n]+)(?:['"]?)/i);(null==e?void 0:e[1])&&(s=e[1].trim())}let i=window.URL.createObjectURL(t.data),r=document.createElement("a");r.href=i,r.download=s,r.target="_blank",r.rel="noopener noreferrer",r.click(),r.remove(),window.URL.revokeObjectURL(i)}catch(l){a();let e=(null==l?void 0:null===(t=l.response)||void 0===t?void 0:null===(n=t.data)||void 0===n?void 0:null===(s=n.error)||void 0===s?void 0:s.message)||(null==l?void 0:null===(i=l.response)||void 0===i?void 0:null===(r=i.data)||void 0===r?void 0:r.message)||(null==l?void 0:l.message)||"Erro ao baixar relat\xf3rio.";et.Am.error(e)}}(0,l.useEffect)(()=>{if(h&&!("error"in h)){if("in_progress"===h.status){a(!0,"Ainda estamos processando. Aguarde mais alguns instantes.");return}"waiting_download"===h.status&&(f(),m())}},[h]);let b=(0,l.useCallback)(async()=>{var e,t,n,s,i,r,l,o,d,m,h,x;try{if(!v)return et.Am.error("Selecione um evento para fazer o download.");let o=(null==g?void 0:g[v])||{};a(!0,"Gerando relat\xf3rio...");let d=new URLSearchParams({eventId:v}),m=r2(o.periodFrom),h=r2(o.periodTo);m&&(d.set("periodFrom",m),d.set("startDate",m),d.set("startAt",m)),h&&(d.set("periodTo",h),d.set("endDate",h),d.set("endAt",h)),(null===(e=o.bannerIds)||void 0===e?void 0:e.length)&&(d.set("bannerIds",o.bannerIds.join(",")),d.set("bannerId",o.bannerIds.join(","))),(null===(t=o.payerEmails)||void 0===t?void 0:t.length)&&(d.set("payerEmails",o.payerEmails.join(",")),d.set("payerEmail",o.payerEmails.join(",")));let x=await J.ZP.get("/click/banner/metrics/download?".concat(d));if(null===(n=x.data)||void 0===n?void 0:n.error)return a(),et.Am.error((null===(i=x.data)||void 0===i?void 0:null===(r=i.error)||void 0===r?void 0:r.message)||(null===(l=x.data)||void 0===l?void 0:l.message)||"Erro ao iniciar download.");let p=null===(s=x.data)||void 0===s?void 0:s.taskId;
1if(!p)return a(),et.Am.error("Resposta inv\xe1lida do servidor (taskId n\xe3o encontrado).");c(p),u("/task/".concat(p))}catch(e){a(),et.Am.error((null==e?void 0:null===(o=e.response)||void 0===o?void 0:null===(d=o.data)||void 0===d?void 0:null===(m=d.error)||void 0===m?void 0:m.message)||(null==e?void 0:null===(h=e.response)||void 0===h?void 0:null===(x=h.data)||void 0===x?void 0:x.message)||(null==e?void 0:e.message)||"Erro ao gerar download.")}},[g,v,a,u]);return{items:n.data,numberOfItems:n.total,isLoading:i,bannerClicksLimit:x,bannerClicksPage:p,onLoadData:j,downloadTable:b}},r6=()=>{var e;let{storedState:t,setStoredState:a}=(0,o.oR)(),{t:n,i18n:s}=(0,p.$)("admin"),{items:i,numberOfItems:d,isLoading:c,bannerClicksLimit:u,bannerClicksPage:m,onLoadData:h,downloadTable:v}=r3(),x=(null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id)||null;return l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"banner-clicks",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Banners clicks"})}),(0,r.jsx)(r1,{onLoadData:h,onRequestDownload:v}),x?null:(0,r.jsx)("div",{className:"nothing-found",children:"Selecione um evento para visualizar os cliques dos banners."}),c?(0,r.jsx)(ee.aN,{inline:!0}):null,c||!x||d?null:(0,r.jsx)("div",{className:"nothing-found",children:n("nothing_found")}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"Banner"}),(0,r.jsx)("th",{children:"Cliques"}),(0,r.jsx)("th",{children:"Pagador"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Pedido"}),(0,r.jsx)("th",{children:"Criado em"}),(0,r.jsx)("th",{children:"Atualizado em"}),(0,r.jsx)("th",{children:n("action")})]})}),(0,r.jsx)("tbody",{children:null==i?void 0:i.map(e=>{var t,a,i,l,o,d,c;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",minWidth:220},children:(null===(t=e.banner)||void 0===t?void 0:t.coverImage)?(0,r.jsx)("img",{src:e.banner.coverImage,alt:(null===(a=e.banner)||void 0===a?void 0:a.link)||e.bannerId,style:{width:72,height:40,objectFit:"cover",borderRadius:6,border:"1px solid #ddd",flexShrink:0}}):null})}),(0,r.jsx)("td",{children:"".concat(e.count||0,"x")}),(0,r.jsx)("td",{children:(null===(i=e.order)||void 0===i?void 0:null===(l=i.payerInfo)||void 0===l?void 0:l.name)||"-"}),(0,r.jsx)("td",{children:(null===(o=e.order)||void 0===o?void 0:null===(d=o.payerInfo)||void 0===d?void 0:d.email)||"-"}),(0,r.jsx)("td",{children:(null===(c=e.order)||void 0===c?void 0:c.shortId)||e.orderId}),(0,r.jsx)("td",{children:(0,ej.p6)(e.createdAt,"Pp",s.language)}),(0,r.jsx)("td",{children:(0,ej.p6)(e.updatedAt,"Pp",s.language)}),(0,r.jsx)("td",{className:"actions",children:(0,r.jsx)(eS.Z,{arrow:!0,title:n("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(rY,{item:e})),children:(0,r.jsx)(nZ.Z,{})})})})})]},e.id)})})]})}),(0,r.jsx)(eZ,{numberOfItems:d,rowsPerPage:u,page:m,onPageChange:e=>{a({bannerClicksPage:e}),h({bannerClicksPageParams:e})},onRowsPerPageChange:e=>{a({bannerClicksPage:0,bannerClicksLimit:e}),h({bannerClicksPageParams:0,bannerClicksLimitParams:e})}})]})},r5=()=>{let{storedState:e}=(0,o.oR)(),{user:t}=(0,d.aC)(),{_id:a}=(null==e?void 0:e.currentSelectedEvent)||{},{data:n,isLoading:s,refresh:i}=(0,eh.Z)((null==t?void 0:t.role)==="super-admin"?"/payment/get-all-waiting-payment-with-transaction":a?"/payment/get-all-waiting-payment-with-transaction?eventId=".concat(a):""),r=n||{numberOfOrders:0,orders:[]},l=((null==r?void 0:r.orders)||[]).sort((e,t)=>
1{var a,n,s,i;let r=((null==e?void 0:null===(a=e.event)||void 0===a?void 0:a.title)||"").localeCompare((null==t?void 0:null===(n=t.event)||void 0===n?void 0:n.title)||"");return 0!==r?r:new Date((null==t?void 0:null===(s=t.transaction)||void 0===s?void 0:s.created_at)||"").getTime()-new Date((null==e?void 0:null===(i=e.transaction)||void 0===i?void 0:i.created_at)||"").getTime()});return{items:l,numberOfItems:(null==r?void 0:r.numberOfOrders)||0,isLoading:s,onLoadData:i}};var r8=a(92401),r7=a(86886),r4=a(67720),r9=a(84424);let le=e=>{var t,a,n,s,i,l,o,d,c,u,m,h,x,g,j,f,b,y,N,k,w,Z,C,S,_,D,E,P,I,A,T,R,L,q,M,O,F,B,U,z,V,G,W,$,H,J,Q,Y,K,X;let{order:ee,onChange:ea}=e,{t:en,i18n:es}=(0,p.$)("admin"),er=e=>{navigator.clipboard.writeText(e),et.Am.success("Copiado para a \xe1rea de transfer\xeancia")},el=e=>(0,ej.p6)(e,"PPPP, HH:mm:ss",es.language),eo=(e,t)=>{if(!e||!t)return"N/A";let a=new Date(e),n=new Date(t),s=n.getTime()-a.getTime(),i=Math.floor(s/1e3),r=Math.floor(i/60),l=Math.floor(r/60),o=Math.floor(l/24);return o>0?"".concat(o,"d ").concat(l%24,"h"):l>0?"".concat(l,"h ").concat(r%60,"m"):r>0?"".concat(r,"m ").concat(i%60,"s"):"".concat(i<0?0:i,"s")},ed=e=>{switch(e.toLowerCase()){case"waiting_payment":return"warning";case"pending":return"info";default:return"default"}},ec=e=>{switch(e.toLowerCase()){case"waiting_payment":return"Aguardando Pagamento";case"pending":return"Pendente";default:return e}};return(0,r.jsxs)(nT.Z,{sx:{p:2},children:[(0,r.jsx)(ei.Z,{title:"Detalhes do pedido - ".concat((null==ee?void 0:ee.id)||"N/A"," - Evento: ").concat((null==ee?void 0:null===(t=ee.event)||void 0===t?void 0:t.title)||"N/A"),onGoBack:ng.dL}),(0,r.jsx)(aX.Z,{sx:{mb:2},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Informa\xe7\xf5es do Pedido"}),(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"ID do Pedido:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:ee.id)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"ID Curto:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:ee.shortId)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Data da Venda:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:el((null==ee?void 0:ee.createdAt)||"")})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Data Cria\xe7\xe3o Gateway:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:el((null==ee?void 0:null===(a=ee.transaction)||void 0===a?void 0:a.created_at)||"")})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Diferen\xe7a de Tempo (Venda → Gateway):"}),(0,r.jsx)(a1.Z,{variant:"body1",style:{color:"N/A"!==eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(n=ee.transaction)||void 0===n?void 0:n.created_at)||"")&&eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(s=ee.transaction)||void 0===s?void 0:s.created_at)||"").includes("h")?"#ff5722":"N/A"!==eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(i=ee.transaction)||void 0===i?void 0:i.created_at)||"")&&eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(l=ee.transaction)||void 0===l?void 0:l.created_at)||"").includes("m")&&parseInt(eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(o=ee.transaction)||void 0===o?void 0:o.created_at)||"").split("m")[0])>5?"#ff9800":"#4caf50",fontWeight:"bold"},children:eo((null==ee?void 0:ee.createdAt)||"",(null==ee?void 0:null===(d=ee.transaction)||void 0===d?void 0:d.created_at)||"")})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Canal:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:ee.channel)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"M\xe9todo de Pagamento:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:ee.paymentMethod)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Status da Transa\xe7\xe3o:"}),(0,r.jsx)(rK.Z,{label:ec((null==ee?void 0:null===(c=ee.transaction)||void 0===c?void 0:c.status)||""),color:ed((null==ee?void 0:null===(u=ee.transaction)||void 0===u?void 0:u.status)||""),size:"small"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Valor Total:"}),(0,r.jsx)(a1.Z,{variant:"body1",fontWeight:"bold",children:(0,sL.n)((null==ee?void 0:null===(m=ee.transaction)||void 0===m?void 0:m.amount)||0)})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Data de Cria\xe7\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:el((null==ee?void 0:null===(h=ee.transaction)||void 0===h?void 0:h.created_at)||"")})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Data de Expira\xe7\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(x=ee.transaction)||void 0===x?void 0:null===(g=x.qr_codes)||void 0===g?void 0:null===(j=g[0])||void 0===j?void 0:j.expiration_date)?el(ee.transaction.qr_codes[0].expiration_date):"N/A"})]})]})]})}),(0,r.jsx)(aX.Z,{sx:{mb:2},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Informa\xe7\xf5es do Comprador"}),(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Nome:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(f=ee.payerInfo)||void 0===f?void 0:f.name)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Email:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(b=ee.payerInfo)||void 0===b?void 0:b.email)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Telefone:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(y=ee.payerInfo)||void 0===y?void 0:y.celphone)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Documento:"}),(0,r.jsxs)(a1.Z,{variant:"body1",children:[(null==ee?void 0:null===(N=ee.payerInfo)||void 0===N?void 0:N.docType)||"N/A",": ",(null==ee?void 0:null===(k=ee.payerInfo)||void 0===k?void 0:k.docNumber)||"N/A"]})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Data de Nascimento:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(w=ee.payerInfo)||void 0===w?void 0:w.birthday)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Profiss\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(Z=ee.payerInfo)||void 0===Z?void 0:Z.profession)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Endere\xe7o:"}),(0,r.jsxs)(a1.Z,{variant:"body1",children:[(null==ee?void 0:null===(C=ee.payerInfo)||void 0===C?void 0:null===(S=C.address)||void 0===S?void 0:S.street)||"N
1/A",", ",(null==ee?void 0:null===(_=ee.payerInfo)||void 0===_?void 0:null===(D=_.address)||void 0===D?void 0:D.district)||"N/A",(0,r.jsx)("br",{}),(null==ee?void 0:null===(E=ee.payerInfo)||void 0===E?void 0:null===(P=E.address)||void 0===P?void 0:P.city)||"N/A"," - ",(null==ee?void 0:null===(I=ee.payerInfo)||void 0===I?void 0:null===(A=I.address)||void 0===A?void 0:A.state)||"N/A",(0,r.jsx)("br",{}),"CEP: ",(null==ee?void 0:null===(T=ee.payerInfo)||void 0===T?void 0:null===(R=T.address)||void 0===R?void 0:R.zip)||"N/A"]})]})]})]})}),(0,r.jsx)(aX.Z,{sx:{mb:2},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Informa\xe7\xf5es da Transa\xe7\xe3o"}),(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"ID da Transa\xe7\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(L=ee.transaction)||void 0===L?void 0:L.id)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"C\xf3digo da Transa\xe7\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(q=ee.transaction)||void 0===q?void 0:q.code)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Moeda:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(M=ee.transaction)||void 0===M?void 0:M.currency)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Fechada:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==ee?void 0:null===(O=ee.transaction)||void 0===O?void 0:O.closed)?"Sim":"N\xe3o"})]})]}),(0,r.jsx)(r4.Z,{sx:{my:2}}),(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Itens da Transa\xe7\xe3o"}),null==ee?void 0:null===(F=ee.transaction)||void 0===F?void 0:null===(B=F.items)||void 0===B?void 0:B.map((e,t)=>(0,r.jsx)(aX.Z,{variant:"outlined",sx:{mb:1},children:(0,r.jsx)(a0.Z,{children:(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Descri\xe7\xe3o:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:e.description)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:3,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Quantidade:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:e.quantity)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:3,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Valor:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(0,sL.n)((null==e?void 0:e.amount)||0)})]})]})})},t))]})}),(null==ee?void 0:null===(U=ee.transaction)||void 0===U?void 0:U.charges)&&ee.transaction.charges.length>0&&(0,r.jsx)(aX.Z,{sx:{mb:2},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Informa\xe7\xf5es de Pagamento"}),null==ee?void 0:null===(z=ee.transaction)||void 0===z?void 0:null===(V=z.charges)||void 0===V?void 0:V.map((e,t)=>{var a,n,s;return(0,r.jsxs)(nT.Z,{children:[(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"ID da Cobran\xe7a:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:e.id)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Gateway ID:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:e.gateway_id)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Status:"}),(0,r.jsx)(rK.Z,{label:ec((null==e?void 0:e.status)||""),color:ed((null==e?void 0:e.status)||""),size:"small"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Valor:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(0,sL.n)((null==e?void 0:e.amount)||0)})]})]}),(null==e?void 0:e.last_transaction)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r4.Z,{sx:{my:2}}),(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"QR Code PIX"}),(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"C\xf3digo PIX:"}),(0,r.jsxs)(nT.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(a1.Z,{variant:"body1",sx:{wordBreak:"break-all",fontSize:"0.8rem"},children:(null==e?void 0:null===(a=e.last_transaction)||void 0===a?void 0:a.qr_code)||"N
1/A"}),(0,r.jsx)(v.Z,{size:"small",startIcon:(0,r.jsx)(r9.Z,{}),onClick:()=>{var t;return er((null==e?void 0:null===(t=e.last_transaction)||void 0===t?void 0:t.qr_code)||"")},children:"Copiar"})]})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"URL do QR Code:"}),(0,r.jsxs)(nT.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(a1.Z,{variant:"body1",sx:{wordBreak:"break-all",fontSize:"0.8rem"},children:(null==e?void 0:null===(n=e.last_transaction)||void 0===n?void 0:n.qr_code_url)||"N/A"}),(0,r.jsx)(v.Z,{size:"small",startIcon:(0,r.jsx)(r9.Z,{}),onClick:()=>{var t;return er((null==e?void 0:null===(t=e.last_transaction)||void 0===t?void 0:t.qr_code_url)||"")},children:"Copiar"})]})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Expira em:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:el((null==e?void 0:null===(s=e.last_transaction)||void 0===s?void 0:s.expires_at)||"")})]})]})]})]},t)})]})}),(null==ee?void 0:null===(G=ee.transaction)||void 0===G?void 0:null===(W=G.charges)||void 0===W?void 0:null===($=W[0])||void 0===$?void 0:null===(H=$.last_transaction)||void 0===H?void 0:H.split)&&ee.transaction.charges[0].last_transaction.split.length>0&&(0,r.jsx)(aX.Z,{sx:{mb:2},children:(0,r.jsxs)(a0.Z,{children:[(0,r.jsx)(a1.Z,{variant:"h6",gutterBottom:!0,children:"Divis\xe3o de Pagamento"}),null==ee?void 0:null===(J=ee.transaction)||void 0===J?void 0:null===(Q=J.charges)||void 0===Q?void 0:null===(Y=Q[0])||void 0===Y?void 0:null===(K=Y.last_transaction)||void 0===K?void 0:null===(X=K.split)||void 0===X?void 0:X.map((e,t)=>{var a,n,s;return(0,r.jsx)(aX.Z,{variant:"outlined",sx:{mb:1},children:(0,r.jsx)(a0.Z,{children:(0,r.jsxs)(r7.ZP,{container:!0,spacing:2,children:[(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Destinat\xe1rio:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:null===(a=e.recipient)||void 0===a?void 0:a.name)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Documento:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:null===(n=e.recipient)||void 0===n?void 0:n.document)||"N/A"})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Valor:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(0,sL.n)((null==e?void 0:e.amount)||0)})]}),(0,r.jsxs)(r7.ZP,{item:!0,xs:12,sm:6,children:[(0,r.jsx)(a1.Z,{variant:"body2",color:"textSecondary",children:"Respons\xe1vel:"}),(0,r.jsx)(a1.Z,{variant:"body1",children:(null==e?void 0:null===(s=e.options)||void 0===s?void 0:s.liable)?"Sim":"N\xe3o"})]})]})})},t)})]})})]})},lt=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{user:a}=(0,d.aC)(),{toggleLoader:n}=(0,ee.U2)(),{items:s,numberOfItems:i,isLoading:o,onLoadData:c}=r5(),[u,m]=l.useState(!1);l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]);let h=e=>(0,ej.p6)(e,"dd/MM/yyyy HH:mm:ss",t.language),x=e=>{let t=new Date,a=new Date(e),n=t.getTime()-a.getTime(),s=Math.floor(n/1e3),i=Math.floor(s/60),r=M
1ath.floor(i/60),l=Math.floor(r/24);return l>0?"".concat(l,"d ").concat(r%24,"h"):r>0?"".concat(r,"h ").concat(i%60,"m"):i>0?"".concat(i,"m ").concat(s%60,"s"):"".concat(s<0?0:s,"s")},g=(e,t)=>{if(!e||!t)return"N/A";let a=new Date(e),n=new Date(t),s=n.getTime()-a.getTime(),i=Math.floor(s/1e3),r=Math.floor(i/60),l=Math.floor(r/60),o=Math.floor(l/24);return o>0?"".concat(o,"d ").concat(l%24,"h"):l>0?"".concat(l,"h ").concat(r%60,"m"):r>0?"".concat(r,"m ").concat(i%60,"s"):"".concat(i<0?0:i,"s")},j=e=>{if("N/A"===e)return"#4caf50";if(e.includes("h")||e.includes("d"))return"#ff5722";if(e.includes("m")){let t=parseInt(e.split("m")[0]);if(t>10)return"#ff9800"}return"#4caf50"},f=e=>e<=10?"#4caf50":e<=30?"#ff9800":"#f44336",b=()=>{let e=(null==s?void 0:s.reduce((e,t)=>{var a;let n=(null==t?void 0:null===(a=t.event)||void 0===a?void 0:a.title)||"Evento n\xe3o identificado";return e[n]=(e[n]||0)+1,e},{}))||{},t=Object.values(e),a=t.every(e=>e<=10),n=t.every(e=>e>=11&&e<=30),i=t.some(e=>e>30);return a?{severity:"success",color:"#4caf50",title:"Situa\xe7\xe3o Geral Normal",message:"Todos os eventos com menos de 10 pedidos aguardando pagamento."}:n&&!i?{severity:"warning",color:"#ff9800",title:"Aten\xe7\xe3o Geral Necess\xe1ria",message:"Todos os eventos com 11-30 pedidos aguardando pagamento."}:{severity:"error",color:"#f44336",title:"Situa\xe7\xe3o Geral Cr\xedtica",message:"Alguns eventos com mais de 30 pedidos aguardando pagamento!"}},y=async()=>{try{m(!0),n(!0,"Atualizando status de todos os pedidos...");
1let e=await J.ZP.get("/payment/update-status-all-waiting-payment");if("started update all waiting payment"===e.data.message)et.Am.success("Atualiza\xe7\xe3o iniciada com sucesso! Os pedidos ser\xe3o atualizados em breve.");else throw Error("Resposta inesperada do servidor")}catch(a){var e,t;console.error("Erro ao atualizar pedidos:",a),et.Am.error((null==a?void 0:null===(e=a.response)||void 0===e?void 0:null===(t=e.data)||void 0===t?void 0:t.message)||(null==a?void 0:a.message)||"Erro ao atualizar status dos pedidos. Tente novamente.")}finally{m(!1),n(!1)}};return(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsxs)("div",{className:"row",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[(0,r.jsx)("h3",{children:(null==a?void 0:a.role)==="super-admin"?"Pedidos de Todos as Franquias Aguardando Pagamento (Somente Super Admin)":"Pedidos Aguardando Pagamento"}),(0,r.jsx)(v.Z,{variant:"contained",color:"primary",onClick:y,disabled:u||o,children:u?"Atualizando...":"For\xe7ar atualiza\xe7\xe3o de status de todos os pedidos"})]}),o&&(0,r.jsx)(ee.aN,{inline:!0}),i>0&&(0,r.jsxs)("div",{style:{marginTop:"20px",marginBottom:"20px"},children:[(0,r.jsxs)(n_.Z,{severity:b().severity,sx:{mb:2,"& .MuiAlert-icon":{color:b().color}},children:[(0,r.jsx)(r8.Z,{children:b().title}),b().message,(0,r.jsxs)("p",{children:["Total de pedidos aguardando pagamento: ",i]})]}),(0,r.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,r.jsx)("h4",{style:{marginBottom:"10px",fontSize:"16px",fontWeight:"600"},children:"Quantidade por Evento:"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px"},children:Object.entries((null==s?void 0:s.reduce((e,t)=>{var a;let n=(null==t?void 0:null===(a=t.event)||void 0===a?void 0:a.title)||"Evento n\xe3o identificado";return e[n]=(e[n]||0)+1,e},{}))||{}).map(e=>{let[t,a]=e;return(0,r.jsxs)("div",{style:{padding:"8px 12px",borderRadius:"6px",backgroundColor:"#f5f5f5",border:"2px solid ".concat(f(a)),display:"flex",alignItems:"center",gap:"8px",minWidth:"200px"},children:[(0,r.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:f(a)}}),(0,r.jsx)("span",{style:{fontWeight:"500",fontSize:"14px"},children:t}),(0,r.jsxs)("span",{style:{fontWeight:"bold",color:f(a),fontSize:"14px"},children:["(",a,")"]})]},t)})})]})]}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Evento"}),(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"ID Transa\xe7\xe3o"}),(0,r.jsx)("th",{children:"Comprador"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Telefone"}),(0,r.jsx)("th",{children:"Canal"}),(0,r.jsx)("th",{children:"Operador"}),(0,r.jsx)("th",{children:"M\xe9todo Pagamento"}),(0,r.jsx)("th",{children:"Valor"}),(0,r.jsx)("th",{children:"Data Venda"}),(0,r.jsx)("th",{children:"Data Gateway"}),(0,r.jsx)("th",{children:"Tempo Aguardando"}),(0,r.jsx)("th",{children:e("action").toString()})]})}),(0,r.jsx)("tbody",{children:null==s?void 0:s.map((t,a)=>{var n,s,i,l,o,d,u,m,v;let p=h((null==t?void 0:t.createdAt)||""),f=h((null==t?void 0:null===(n=t.transaction)||void 0===n?void 0:n.created_at)||"");g((null==t?void 0:t.createdAt)||"",(null==t?void 0:null===(s=t.transaction)||void 0===s?void 0:s.created_at)||"");let b=(null==t?void 0:null===(i=t.transaction)||void 0===i?void 0:i.created_at)?x(t.transaction.created_at):"N/A";return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(null==t?void 0:null===(l=t.event)||void 0===l?void 0:l.title)||"N/A"}),(0,r.jsx)("td",{children:(null==t?void 0:t.id)||"N/A"}),(0,r.jsx)("td",{children:(null==t?void 0:t.transactionId)||"N/A"}),(0,r.jsx)("td",{children:(null==t?void 0:null===(o=t.payerInfo)||void 0===o?void 0:o.name)||"N/A"}),(0,r.jsx)("td",{children:(null==t?void 0:null===(d=t.payerInfo)||void 0===d?void 0:d.email)||"N/A"}),(0,r.jsx)("td",{children:(null==t?void 0:null===(u=t.payerInfo)||void 0===u?void 0:u.celphone)||"N/A"}),(0,r.jsx)("td",{children:e("ticket_distribution."+((null==t?void 0:t.channel)||"not-registered")).toString()}),(0,r.jsx)("td",{children:(null==t?void 0:null===(m=t.machineOperator)||void 0===m?void 0:m.name)||""}),(0,r.jsx)("td",{children:e("ticket_distribution."+((null==t?void 0:t.paymentMethod)||"not-registered")).toString()}),(0,r.jsx)("td",{children:(0,sL.n)((null==t?void 0:null===(v=t.transaction)||void 0===v?void 0:v.amount)||0)}),(0,r.jsx)("td",{children:p}),(0,r.jsx)("td",{children:f}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{style:{color:j(b),fontWeight:"bold"},children:b})}),(0,r.jsx)("td",{className:"actions",children:(0,r.jsx)(eS.Z,{arrow:!0,title:e("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(le,{order:t,onChange:c})),children:(0,r.jsx)(nZ.Z,{})})})})})]},a)})})]})})]})},la=e=>
1{let{onConfirm:t,selectedSellStartDate:a,selectedSellEndDate:n}=e,{t:s}=(0,p.$)("admin"),[i,o]=l.useState([]),[d,c]=l.useState(null),[u,m]=l.useState(null),[h,x]=l.useState({});return(0,r.jsx)("div",{className:"ticket-edit-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:"Adicione os per\xedodo(s) de data(s) de venda que deseja excluir dentro do per\xedodo selecionado (".concat((0,ix.Z)(a,"dd/MM/yyyy")," - ").concat((0,ix.Z)(n,"dd/MM/yyyy"),")?"),onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",style:{position:"relative",width:"36%"},children:[(0,r.jsx)(tM.Z,{label:"Data venda - in\xedcio",className:"input",value:d||null,minDate:a,maxDate:n,onChange:e=>c(e?new Date(e).toString():null),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:h.sellStartDate||h.startDate,fullWidth:!0})}),!!d&&(0,r.jsx)(X.Z,{style:{position:"absolute",top:8,right:35},onClick:()=>c(null),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsxs)("div",{className:"group",style:{position:"relative",width:"36%"},children:[(0,r.jsx)(tM.Z,{label:"Data venda - fim",className:"input",shouldDisableDate:e=>!!d&&(0,tS.Z)(new Date(e),1)<new Date(d),value:u||null,minDate:d||a,maxDate:n,onChange:e=>m(e?new Date(e).toString():null),renderInput:e=>(0,r.jsx)(es.Z,{error:h.sellEndDate,...e,fullWidth:!0})}),!!u&&(0,r.jsx)(X.Z,{style:{position:"absolute",top:8,right:35},onClick:()=>m(null),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)("div",{className:"actions",style:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:0},children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>{if(!d||!u){x({sellStartDate:!d,sellEndDate:!u});return}o([...i,{sellStartDate:d,sellEndDate:u}]),c(null),m(null)},fullWidth:!0,children:"".concat(s("add"))})})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Data Venda - In\xedcio"}),(0,r.jsx)("th",{children:"Data Venda - Fim"}),(0,r.jsx)("th",{children:"".concat(s("action"))})]})}),(0,r.jsx)("tbody",{children:i.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(null==e?void 0:e.sellStartDate)?(0,ix.Z)(new Date(e.sellStartDate),"dd/MM/yyyy"):"-"}),(0,r.jsx)("td",{children:(null==e?void 0:e.sellEndDate)?(0,ix.Z)(new Date(e.sellEndDate),"dd/MM/yyyy"):"-"}),(0,r.jsx)("td",{children:(0,r.jsx)(X.Z,{onClick:()=>{o(i.filter((e,a)=>a!==t))},children:(0,r.jsx)(ec.Z,{})})})]},t))})]})}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:K.Mr,children:"".concat(s("cancel"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>t(i),children:"".concat(s("confirm"))})]})]})]})})},ln=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n}=(0,o.oR)(),{toggleLoader:s}=(0,ee.U2)(),[i,d]=(0,l.useState)(),[c,u]=(0,l.useState)({items:[],numberOfItems:0}),[m,h]=(0,l.useState)(!1),{onListenerEndpoint:v,clearListener:x,response:g,error:j}=(0,iE.Z)(),f=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketsLimit:b=20,ticketsPage:y=0,ticketsFilter:N}=n;async function k(){s(!0,"O processamento est\xe1 demorando mais que o esperado. Aguarde mais alguns instantes.");let e=localStorage.getItem(o.cp);v("/task/".concat(e))}let w=(0,l.useCallback)(function(){let{ticketsFilterParams:e,ticketsPageParams:t,ticketsLimitParams:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(async()=>{try{if(!f)return;let n=e?e[f]:(null==N?void 0:N[f])||{};if(0===Object.keys(n).length)return;h(!0),s(!0,"Carregando dados...");let i=(0,iC.x0)();localStorage.setItem(o.cp,i);let r=new URLSearchParams({...n,eventId:f,page:"number"==typeof t?t:y,limit:"number"==typeof a?a:b,requestId:i}),l=await J.ZP.get("/ticket-purchase/list-table?".concat(r));if(l.data.error){if(502===l.data.error.status){k();return}return h(!1),s(),et.Am.error(l.data.error.message)}u(l.data),h(!1),s()}catch(e){if(console.log("\uD83D\uDE80 ~ onLoadData ~ error:",e),502===e.status){k();return}h(!1),s()}})()},[N,y,b,f,s]),Z=async e=>{try{s(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("/ticket-purchase/resend-email/order/".concat(e)),et.Am.success("Ingressos enviados no email com sucesso!"),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},C=async e=>{try{s(!0,"Enviando ingressos comprados no email..."),await J.ZP.get("ticket-purchase/resend-email/order-multi-files/".concat(e)),et.Am.success("Ingressos enviados em m\xfaltiplos arquivos com sucesso!"),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}},S=async e=>{try{(0,em.Z)({title:"Enviar ingressos comprados no email",text:"Como deseja que os arquivos de ingressos comprados sejam enviados?",confirmButtonText:"Enviar em um arquivo",cancelButtonText:"Enviar em m\xfaltiplos arquivos",onConfirm:()=>{Z(e)},onCancel:()=>{C(e)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};async function _(e){let{link:t,fileName:a}=e;try{console.log("\uD83D\uDD17 Link recebido:",t);let e=localStorage.getItem(o.cp);if(!e){et.Am.error("Erro ao baixar ingressos comprados em m\xfaltiplos arquivos, tente novamente.");return}if(!t||"string"!=typeof t||""===t.trim()){et.Am.error("Link inv\xe1lido para download dos arquivos.");return}(0,em.Z)({title:"Arquivo gerado com sucesso",text:"Arquivo de ingressos comprados em PDF de m\xfaltiplos arquivos gerado com sucesso",confirmButtonText:"Baixar",onConfirm:()=>{s();try{console.log("\uD83D\uDE80 Tentando baixar arquivo com link:",t);let n=document.createElement("a");n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.download=a,n.style.display="none",document.body.appendChild(n),n.click(),console.log("✅ Clique executado no link"),setTimeout(()=>{document.body.contains(n)&&document.body.removeChild(n)},100),J.ZP.delete("/task/".concat(e))}catch(e){console.error("❌ Erro ao tentar baixar arquivo:",e),et.Am.error("Erro ao baixar arquivo. Tente novamente.")}},onCancel:()=>{s(),J.ZP.delete("/task/".concat(e))}})}catch(a){var n,i,r,l,d,c,u,m,h,v;if(console.log(a),s(),"string"==typeof(null==a?void 0:null===(n=a.response)||void 0===n?void 0:null===(i=n.data)||void 0===i?void 0:i.error))return et.Am.error(null==a?void 0:null===(h=a.response)||void 0===h?void 0:null===(v=h.data)||void 0===v?void 0:v.error);let e=(null==a?void 0:null===(r=a.response)||void 0===r?void 0:null===(l=r.request)||void 0===l?void 0:l._response)||(null==a?void 0:null===(d=a.response)||void 0===d?void 0:null===(c=d.request)||void 0===c?void 0:c.response)||(null==a?void 0:null===(u=a.response)||void 0===u?void 0:null===(m=u.request)||void 0===m?void 0:m.responseText),t=e&&JSON.parse(e);"string"==typeof(null==t?void 0:t.message)&&et.Am.error(t.message)}}async function D(e){try{s(!0,"Gerando download de ingressos comprados em PDF de m\xfaltiplos arquivos...");let t=(0,iC.x0)();localStorage.setItem(o.cp,t);let a=await J.ZP.get("/order/download-tickets-pdf-multi-files/".concat(e,"?requestId=").concat(t));if(a.data.error){if(502===a.data.error.status){k();return}return h(!1),s(),et.Am.error(a.data.error.message)}if(!a.data.fileLink){console.error("❌ fileLink n\xe3o encontrado na resposta:",a.data),et.Am.error("Link de download n\xe3o encontrado na resposta do servidor."),s();return}_({link:a.data.fileLink,fileName:a.data.fileName})}catch(e){console.error("❌ Erro na requisi\xe7\xe3o:",e),et.Am.error(e.message),console.log(e),s()}}async function E(e){try{s(!0,"Gerando ingressos comprados em PDF");let a=await J.ZP.get("/ticket-purchase/download/".concat(e),{responseType:"blob"});if(s(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let n=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=n,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){s()}}let P=async e=>{let{orderId:t,ticketPurchaseId:a}=e;try{(0,em.Z)({title:"Download de PDF de ingressos comprados",text:"Como deseja que os arquivos de ingressos comprados sejam baixados?",confirmButtonText:"Baixar em um arquivo PDF",cancelButtonText:"Gerar download em m\xfaltiplos arquivos PDF zipados",onConfirm:()=>{E(a)},onCancel:()=>{D(t)}})}catch(e){console.log("\uD83D\uDE80 ~ sendToEmail ~ error:",e)}};
1async function I(){try{s(!0,"Baixando relat\xf3rio...");let e=await J.ZP.get("/task/".concat(i,"/download"));if(s(),e.data.error)throw Error(t("error_on_processing")+"\n\n"+e.data.error.message);let a=window.URL.createObjectURL(new Blob([e.data])),n=document.createElement("a");n.href=a;let r=e.headers["content-disposition"].replace("attachment; filename='","").replace("'","");n.target="_blank",n.rel="noopener noreferrer",n.download=r,n.click(),n.remove()}catch(h){var e,a,n,r,l,o,d,c,u,m;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(e=h.response)||void 0===e?void 0:null===(a=e.data)||void 0===a?void 0:a.error))return et.Am.error(null==h?void 0:null===(u=h.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.error);let t=(null==h?void 0:null===(n=h.response)||void 0===n?void 0:null===(r=n.request)||void 0===r?void 0:r._response)||(null==h?void 0:null===(l=h.response)||void 0===l?void 0:null===(o=l.request)||void 0===o?void 0:o.response)||(null==h?void 0:null===(d=h.response)||void 0===d?void 0:null===(c=d.request)||void 0===c?void 0:c.responseText),i=t&&JSON.parse(t);"string"==typeof(null==i?void 0:i.message)&&et.Am.error(i.message)}}async function A(){let{sellStartDate:e,sellEndDate:t}=(null==N?void 0:N[f])||{},a=e&&new Date(e),n=t?new Date(t):new Date;if((0,i_.Z)(n,a)){(0,em.Z)({text:"Deseja excluir per\xedodo(s) de data(s) de venda dentro do per\xedodo selecionado (".concat((0,ix.Z)(a,"dd/MM/yyyy")," - ").concat((0,ix.Z)(n,"dd/MM/yyyy"),")?"),cancelButtonText:"N\xe3o",confirmButtonText:"Sim",onConfirm:async()=>{(0,K.K4)((0,r.jsx)(la,{selectedSellStartDate:a,selectedSellEndDate:n,onConfirm:async e=>{try{let t=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset(),excludesSellDates:JSON.stringify(e)});t.forEach((e,a)=>{""==e&&t.delete(a)}),s(!0,"Gerando relat\xf3rio");let a=await J.ZP.get("/ticket-purchase/download-table?"+t);d(a.data.taskId),v("/task/".concat(a.data.taskId)),(0,K.Mr)()}catch(h){var t,a,n,i,r,l,o,c,u,m;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(t=h.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.error))return et.Am.error(null==h?void 0:null===(u=h.response)||void 0===u?void 0:null===(m=u.data)||void 0===m?void 0:m.error);let e=(null==h?void 0:null===(n=h.response)||void 0===n?void 0:null===(i=n.request)||void 0===i?void 0:i._response)||(null==h?void 0:null===(r=h.response)||void 0===r?void 0:null===(l=r.request)||void 0===l?void 0:l.response)||(null==h?void 0:null===(o=h.response)||void 0===o?void 0:null===(c=o.request)||void 0===c?void 0:c.responseText),d=e&&JSON.parse(e);"string"==typeof(null==d?void 0:d.message)&&et.Am.error(d.message)}},onClose:()=>{(0,K.Mr)()}}))},onCancel:async()=>{try{let e=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset()});e.forEach((t,a)=>{""==t&&e.delete(a)}),s(!0,"Gerando relat\xf3rio");let t=await J.ZP.get("/ticket-purchase/download-table?"+e);d(t.data.taskId),v("/task/".concat(t.data.taskId))}catch(h){var e,t,a,n,i,r,l,o,c,u;if(console.log(h),s(),"string"==typeof(null==h?void 0:null===(e=h.response)||void 0===e?void 0:null===(t=e.data)||void 0===t?void 0:t.error))return et.Am.error(null==h?void 0:null===(c=h.response)||void 0===c?void 0:null===(u=c.data)||void 0===u?void 0:u.error);let d=(null==h?void 0:null===(a=h.response)||void 0===a?void 0:null===(n=a.request)||void 0===n?void 0:n._response)||(null==h?void 0:null===(i=h.response)||void 0===i?void 0:null===(r=i.request)||void 0===r?void 0:r.response)||(null==h?void 0:null===(l=h.response)||void 0===l?void 0:null===(o=l.request)||void 0===o?void 0:o.responseText),m=d&&JSON.parse(d);"string"==typeof(null==m?void 0:m.message)&&et.Am.error(m.message)}}});return}try{let e=new URLSearchParams({...(null==N?void 0:N[f])||{},eventId:f,withOrder:!0,timezone:new Date().getTimezoneOffset()});e.forEach((t,a)=>{""==t&&e.delete(a)}),s(!0,"Gerando relat\xf3rio");let t=await J.ZP.get("/ticket-purchase/download-table?"+e);d(t.data.taskId),v("/task/".concat(t.data.taskId))}catch(a){var i,l,o,c,u,m,h,x,p,g;if(console.log(a),s(),"string"==typeof(null==a?void 0:null===(i=a.response)||void 0===i?void 0:null===(l=i.data)||void 0===l?void 0:l.error))return et.Am.error(null==a?void 0:null===(p=a.response)||void 0===p?void 0:null===(g=p.data)||void 0===g?void 0:g.error);let e=(null==a?void 0:null===(o=a.response)||void 0===o?void 0:null===(c=o.request)||void 0===c?void 0:c._response)||(null==a?void 0:null===(u=a.response)||void 0===u?void 0:null===(m=u.request)||void 0===m?void 0:m.response)||(null==a?void 0:null===(h=a.response)||void 0===h?void 0:null===(x=h.request)||void 0===x?void 0:x.responseText),t=e&&JSON.parse(e);"string"==typeof(null==t?void 0:t.message)&&et.Am.error(t.message)}}async function T(e){try{s(!0,"Gerando PDF de Border\xf4 da Bilheteria");let a=new URLSearchParams({...e,eventId:f}),n=await iS.get("ticket-purchase/download-tickets-office-report-pdf?".concat(a),{responseType:"blob"});if(s(),n.data.error)throw Error(t("error_on_processing")+"\n\n"+n.data.error.message);let i=n.headers["content-disposition"].replace('attachment; filename="',"").replace('"',""),r=window.URL.createObjectURL(n.data),l=document.createElement("a");l.href=r,l.target="_blank",l.rel="noopener noreferrer",l.download=i,l.click()}catch(e){s()}}(0,l.useEffect)(()=>
1{if(g&&!("error"in g)){if("in_progress"===g.status&&"list-table-ticket-purchase"===g.screen){s(!0,"Ainda estamos processando. Aguarde mais alguns instantes.");return}if("completed"===g.status&&"list-table-ticket-purchase"===g.screen){u(g.dataResult),h(!1),s(),x();return}if("waiting_download"===g.status){if("download-csv-ticket-purchase"===g.screen){I(),x();return}if("download-pdf-tickets-multi-files"===g.screen){_({link:g.filePath,fileName:g.fileName}),x();return}}}},[g]);let R=async e=>{try{s(!0,"Atualizando transa\xe7\xe3o..."),await J.ZP.get("/payment/updateStatus/".concat(e)),w(),s()}catch(e){console.log("\uD83D\uDE80 ~ updateStatusOrder ~ error:",e)}};return{items:(null==c?void 0:c.items)||[],numberOfItems:(null==c?void 0:c.numberOfItems)||0,isLoading:m,ticketsLimit:b,ticketsPage:y,onDownloadOrderTicketsPdf:E,downloadOrderTicketsPdf:P,resendTicketOrderEmail:S,downloadTable:A,downloadTicketsOfficeReportPdf:T,updateStatusOrder:R,onLoadData:w}},ls=e=>{var t,a,n,s,i,o,c,u,m,h,x,g,j;let{onChange:f}=e||{},{user:b}=(0,d.aC)(),y=(null==b?void 0:b.role)==="check-in-operator",{toggleLoader:N}=(0,ee.U2)(),{t:k,i18n:w}=(0,p.$)("admin"),{data:Z,isLoading:C,refresh:S}=(0,eh.Z)("/ticket-purchase/list?id=".concat(e.ticket.id,"&withOrder=true")),{sendToEmail:_,sendToWhatsapp:D}=iL(),[E,P]=l.useState(!1),{id:I,ticket:A,date:T,ticketDiscount:R,coupon:L,couponDiscount:q,order:M,orderStatus:O,orderId:F,status:B,ticketType:U,time:z,totalValue:V,updatedAt:G,user:W,value:$,inviter:H,useLimit:Q,creditCardDiscount:Y,checkInDates:K,promotion:ea,lastUpdatedBy:en}=(null==Z?void 0:Z.items)?Z.items[0]:e.ticket,es=K.length?"".concat(K.map(e=>(0,ej.p6)(e.date,"Pp",w.language)).join(", ")," (").concat(K.length,"/").concat(Q,")"):"",er=!!H,el=iV({ticket:A,inviter:H,order:M,totalValue:V,status:B,orderStatus:O,type:null==A?void 0:A.type,paymentMethod:null==M?void 0:M.paymentMethod}),eo=!el&&((null==M?void 0:M.paymentStatus)==="AUTHORIZED"||(null==M?void 0:M.paymentStatus)==="PAID")&&(null==M?void 0:M.channel)!=="card-machine"&&"active"===B&&"CANCELED"!==O&&"PAYMENT_REFUNDED"!==O,{paymentStatus:ed,payerInfo:ec}=M||{};async function eu(){(0,em.Z)({text:"Deseja realmente realizar o cancelamento deste pedido?",confirmButtonText:"Sim, desejo cancelar",onConfirm:async()=>{N(!0,"Realizando devolu\xe7\xe3o pagamento");let e=await J.ZP.post("/order/return-payment",{orderId:F,ticketPurchaseId:I});if(N(),e.data.error)return et.Am.error(e.data.error.message);S(),f()},onError:()=>{N()}})}async function ev(){(0,em.Z)({title:"Cancelar ingresso",icon:"warning",text:iG,confirmButtonText:"Sim, cancelar sem estorno",onConfirm:async()=>{N(!0,"Cancelando ingresso");let e=await J.ZP.post("/ticket-purchase/cancel/".concat(I));if(N(),e.data.error)return et.Am.error(i$(e.data.error.message));et.Am.success("Ingresso cancelado. Nenhum estorno foi enviado ao gateway."),S(),f()},onError:()=>{N()}})}async function ex(){try{N(!0,"Atualizando status de pagamento"),P(!0);let e=await J.ZP.get("/order/get-transaction/".concat(F));if(e.data.error)throw Error("order_payment_refunded"===e.data.error.message?k("ticket_purchase.order_payment_refunded"):JSON.stringify(e.data.error.message));S(),f(),P(!1),N()}catch(e){return P(!1),et.Am.error(e.message)}}return(0,r.jsxs)("div",{className:"ticket-dashboard-details",children:[(0,r.jsx)(ei.Z,{title:A.title,onGoBack:ng.dL}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(eP.Z,{src:A.coverImageUrl,width:350,height:188})}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",A.title]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do ingresso:"})," ",I]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo ingresso:"})," ",U.type]}),er&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",H.name]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Portador:"})," ",(null==W?void 0:W.name)?W.name+" ("+(null==W?void 0:W.email)+")":"Indefinido"]}),!!(null==W?void 0:W.celphone)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio celular:"})," ",null==W?void 0:W.celphone]}),!!(null==W?void 0:W.docType)&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Usu\xe1rio documento:"})," ",W.docType+": "+W.docNumber]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data visita:"})," ",T?(0,ej.p6)(T,"P",w.language)+" "+z:""]}),!!z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)($)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto ingresso:"})," ",R,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto ingresso:"})," ",(0,sL.n)($*(1-R/100))]})]}),!!q&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cupom aplicado:"})," ",null==L?void 0:L.code]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto cupom:"})," ",q,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto cupom:"})," ",(0,sL.n)($*(1-q/100))]})]}),Y?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto Cart\xe3o BRB:"})," ","".concat(Y.discount,"%")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cart\xe3o:"})," ",Y.card]})]}):null,ea&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Promo\xe7\xe3o:"})," ",ea.promotionName]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(G,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Checkin:"})," ",es||"Indefinido"]}),(y||(null==b?void 0:b.role)==="super-admin"||(null==b?void 0:b.role)==="admin")&&"PAID"===O&&"active"===B&&((null==K?void 0:K.length)||0)<(Q||1)&&(0,r.jsx)("div",{style:{marginTop:16},children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>{var t;return showModal((0,r.jsx)(iO,{ticket:(null==Z?void 0:null===(t=Z.items)||void 0===t?void 0:t[0])||e.ticket,onClose:()=>{closeModal(),S(),f()},onSuccess:()=>{S(),f()}}))},children:"Realizar Check-in"})}),!y&&el&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:ev,children:"Cancelar ingresso"})}),!y&&eo&&(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(v.Z,{variant:"outlined",className:"return-payment-btn",onClick:eu,children:"Realizar devolu\xe7\xe3o"})}),(0,r.jsxs)("div",{className:"title",children:["Detalhes do pedido:",(0,r.jsx)(X.Z,{onClick:ex,className:"reload-btn "+(E?"rotate":""),children:(0,r.jsx)(iq.Z,{})})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data do pedido:"})," ",(0,ej.p6)(M.createdAt,"Pp")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do pedido:"})," ",F]}),!er&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status do pedido:"})," ","".concat(k("ticket_distribution."+O))]}),"DECLINED"===O&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",(0,iF.pH)(null==M?void 0:null===(t=M.transaction)||void 0===t?void 0:null===(a=t.charges)||void 0===a?void 0:null===(n=a[0])||void 0===n?void 0:null===(s=n.payment_response)||void 0===s?void 0:s.message,null==M?void 0:M.transaction)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"C\xf3digo erro:"})," ",null==M?void 0:null===(i=M.transaction)||void 0===i?void 0:null===(o=i.charges)||void 0===o?void 0:null===(c=o[0])||void 0===c?void 0:null===(u=c.payment_response)||void 0===u?void 0:u.code]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Comprador:"}),(null===(m=M.payerInfo)||void 0===m?void 0:m.name)?(null===(h=M.payerInfo)||void 0===h?void 0:h.name)+" ("+(null===(x=M.payerInfo)||void 0===x?void 0:x.email)+", "+(null===(g=M.payerInfo)||void 0===g?void 0:g.docType)+": "+(null===(j=M.payerInfo)||void 0===j?void 0:j.docNumber)+")":"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total ingressos:"})," ",(0,sL.n)(M.itemsAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total doa\xe7\xf5es:"})," ",(0,sL.n)(M.donationAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total (ingressos + doa\xe7\xf5es):"})," ",(0,sL.n)(M.totalAmount)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Pagamento:"}),M.installments,"x ",(0,sL.n)(M.totalAmount/M.installments)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"M\xe9todo de pagamento:"})," ",M.paymentMethod?"".concat(k("ticket_distribution."+M.paymentMethod)):"N\xe3o aplicad
1o"]}),M.splitInfo&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Repasse:"})," ",M.splitInfo.name," (",(0,sL.n)(M.itemsAmount*M.splitInfo.share/100),")"]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Canal de venda:"})," ","".concat(k("ticket_distribution."+M.channel))]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(M.updatedAt,"Pp")]}),!y&&"PAID"===ed&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>_(F),startIcon:(0,r.jsx)(eO.Z,{}),children:"Enviar ingressos comprados no email"}),(null==ec?void 0:ec.celphone)&&(0,r.jsx)(v.Z,{sx:{mt:2},variant:"outlined",onClick:()=>D(F),startIcon:(0,r.jsx)(iM.Z,{}),children:"Enviar ingressos comprados no whatsapp"})]})]})]})},li=e=>{let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),{ticketsSimpleSearchFilter:i={},currentSelectedEvent:d}=n||{},[c,u]=l.useState({}),[m,h]=l.useState({}),x=(null==d?void 0:d._id)||null,{userNameEmail:g}=c;function j(e){u({...c,...e})}return l.useEffect(()=>{if(!x)return;let e=i[x]||{};u({userNameEmail:e.userNameEmail||""})},[x]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome, email, telefone ou documento do comprador/portador",value:g||"",onValueChange:e=>j({userNameEmail:e}),helperText:"Digite o nome, email, telefone ou documento do comprador/portador e clique em pesquisar",error:m.userNameEmail}),!!g&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>j({userNameEmail:""}),children:(0,r.jsx)(ec.Z,{})})]})}),(0,r.jsx)("div",{className:"row last",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:function(){var t;if((null!==(t=null==g?void 0:g.length)&&void 0!==t?t:0)<3)return h({userNameEmail:!0}),et.Am.error("Digite pelo menos 3 caracteres para pesquisar!");h({});let a={...i};a[x]=c,s({ticketsSimpleSearchFilter:a,ticketsPage:0}),e.onLoadData({ticketsFilterParams:a,ticketsPageParams:0})},children:"Pesquisar"})})]})},lr=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),ll=(e,t)=>{if(!t||!e||"-"===e)return e;try{let a=t.trim().split(/\s+/).filter(e=>e.length>0);if(0===a.length)return e;let n=[e];return a.forEach(e=>{let t=lr(e);RegExp("(".concat(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),")"),"gi");let a=[];n.forEach(n=>{if("string"==typeof n){let s;let i=lr(n),l=[],o=RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi");for(;null!==(s=o.exec(i));)l.push({start:s.index,end:s.index+s[0].length,original:n.substring(s.index,s.index+s[0].length)});if(l.length>0){let t=0;l.forEach((s,i)=>{s.start>t&&a.push(n.substring(t,s.start)),a.push((0,r.jsx)("mark",{style:{backgroundColor:"#ffeb3b",padding:"1px 2px",borderRadius:"2px",fontWeight:"bold",color:"#000"},children:s.original},"".concat(e,"-").concat(i))),t=s.end}),t<n.length&&a.push(n.substring(t))}else a.push(n)}else a.push(n)}),n=a}),(0,r.jsx)(r.Fragment,{children:n})}catch(t){return console.warn("Erro ao processar highlight:",t),e}},lo=()=>{var e,t,a;let{setStoredState:n,storedState:s}=(0,o.oR)(),{t:i,i18n:d}=(0,p.$)("admin"),{items:c,numberOfItems:u,isLoading:m,ticketsLimit:h,ticketsPage:v,onLoadData:x,onDownloadOrderTicketsPdf:g,downloadOrderTicketsPdf:j,resendTicketOrderEmail:f,downloadTable:b,downloadTicketsOfficeReportPdf:y,updateStatusOrder:N}=ln(),k=null==s?void 0:null===(e=s.currentSelectedEvent)||void 0===e?void 0:e._id,w=(null==s?void 0:null===(t=s.ticketsSimpleSearchFilter)||void 0===t?void 0:null===(a=t[k])||void 0===a?void 0:a.userNameEmail)||"";return l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Tabela de ingressos (Pesquisa)"})}),(0,r.jsx)(li,{numberOfItems:u,onLoadData:x,onRequestDownload:b,onRequestDownloadTicketOfficeReport:y}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),w&&c.length>0&&(0,r.jsxs)("div",{style:{marginBottom:"10px",fontSize:"14px",color:"#666"},children:["Resultados destacados para: ",(0,r.jsxs)("strong",{children:['"',w,'"']})]}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Transa\xe7\xe3o Id"}),(0,r.jsx)("th",{children:"Ingresso Id"}),(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Comprador"}),(0,r.jsx)("th",{children:"Comprador Email"}),(0,r.jsx)("th",{children:"Comprador Documento"}),(0,r.jsx)("th",{children:"Comprador Telefone"}),(0,r.jsx)("th",{children:"Portador"}),(0,r.jsx)("th",{children:"Portador Email"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"}),(0,r.jsx)("th",{children:"".concat(i("action"))})]})}),(0,r.jsx)("tbody",{children:null==c?void 0:c.map((e,t)=>{var a,n,s,l,o,c,u,m,h,v,p,b,y,k,Z,C,S,_,D;let E=e.date?(0,ej.p6)(e.date,"P",d.language)+" "+(e.time||(0,ej.p6)(e.date,"HH:mm",d.language)):"",P=e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",d.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"",I=(0,ej.p6)(e.createdAt,"Pp",d.language),A=e.checkInDates.length===e.useLimit,T="PAID"===e.orderStatus,R=!T,L=A||!T||!(null===(a=e.user)||void 0===a?void 0:a.email),q=null===(n=e.order)||void 0===n?void 0:n._id;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:q}),(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:e.ticket.title}),(0,r.jsx)("td",{children:null===(s=e.ticketType)||void 0===s?void 0:s.type}),(0,r.jsx)("td",{children:ll((null===(l=e.order)||void 0===l?void 0:null===(o=l.payerInfo)||void 0===o?void 0:o.name)||"-",w)}),(0,r.jsx)("td",{children:ll((null===(c=e.order)||void 0===c?void 0:null===(u=c.payerInfo)||void 0===u?void 0:u.email)||"-",w)}),(0,r.jsx)("td",{children:ll((null===(m=e.order)||void 0===m?void 0:null===(h=m.payerInfo)||void 0===h?void 0:h.docNumber)||"-",w)}),(0,r.jsx)("td",{children:ll((null==e?void 0:null===(v=e.order)||void 0===v?void 0:null===(p=v.payerInfo)||void 0===p?void 0:p.celphone)||"-",w)}),(0,r.jsx)("td",{children:ll((null===(b=e.user)||void 0===b?void 0:b.name)||"-",w)}),(0,r.jsx)("td",{children:ll((null===(y=e.user)||void 0===y?void 0:y.email)||"-",w)}),(0,r.jsx)("td",{children:E}),(0,r.jsx)("td",{children:I}),(0,r.jsx)("td",{children:"".concat(i("ticket_distribution."+e.order.channel))}),(0,r.jsx)("td",{children:(null===(k=e.order)||void 0===k?void 0:null===(Z=k.machineOperator)||void 0===Z?void 0:Z.name)||"-"}),(0,r.jsx)("td",{children:null===(C=e.order.transaction)||void 0===C?void 0:C.terminalSerialNumber}),(0,r.jsx)("td",{children:e.orderStatus?"".concat(i("ticket_distribution."+e.orderStatus)):"-"}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:e.order.paymentMethod?"".concat(i("ticket_distribution."+e.order.paymentMethod)):"-"}),(0,r.jsx)("td",{children:P}),(0,r.jsxs)("td",{className:"actions",children:[(0,r.jsx)(eS.Z,{arrow:!0,title:i("ticket_distribution.update_status"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>N(e.orderId),children:(0,r.jsx)(ns.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:i("ticket_distribution.resend_email"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:L,onClick:()=>f(e.orderId),children:(0,r.jsx)(eO.Z,{className:L?"disabled":(null===(S=e.order)||void 0===S?void 0:S.emailSent)===!1?"email-not-sent":""})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:i("ticket_distribution.download_tickets_pdf"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:R,onClick:()=>g(e.id),children:(0,r.jsx)(iI.Z,{})})})}),(0,r.jsx)(eS.Z,{arrow:!0,title:i("ticket_distribution.download_tickets"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{disabled:R,onClick:()=>j({orderId:e.orderId,ticketPurchaseId:e.id}),children:(0,r.jsx)(nC.Z,{})})})}),(0,r.jsx)(iY,{email:(null===(_=e.order)||void 0===_?void 0:null===(D=_.payerInfo)||void 0===D?void 0:D.email)||"",onSuccess:x,disabled:!T}),(0,r.jsx)(eS.Z,{arrow:!0,title:i("ticket_distribution.view_details"),children:(0,r.jsx)("span",{children:(0,r.jsx)(X.Z,{onClick:()=>(0,ng.FJ)((0,r.jsx)(ls,{ticket:e,onChange:x})),children:(0,r.jsx)(nZ.Z,{})})})})]})]},t)})})]})}),(0,r.jsx)(eZ,{numberOfItems:u,rowsPerPage:h,page:v,onPageChange:e=>{n({ticketsPage:e}),x({ticketsPageParams:e})},onRowsPerPageChange:e=>{n({ticketsPage:0,ticketsLimit:e}),x({ticketsPageParams:0,ticketsLimitParams:e})}})]})},ld=()=>(0,r.jsx)("div",{className:"ticket-dashboard",children:(0,r.jsx)(lo,{})}),lc=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n}=(0,o.oR)(),{toggleLoader:s}=(0,ee.U2)(),i=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketsLimit:r=20,ticketsPage:l=0,ticketsFilter:d}=n,c=new URLSearchParams({...(null==d?void 0:d[i])||{},sellEndDate:((null==d?void 0:d[i])||{}).sellStartDate||"",eventId:i,page:l,limit:r}),{data:u,isLoading:m,refresh:h}=(0,eh.Z)("/ticket-purchase/list-table?withCrmIntegration=true&"+c),{items:v,numberOfItems:x}=u||{};async function g(e,a){try{s(!0,"Gerando PDF");let a=await J.ZP.get("/ticket-purchase/download/".concat(e),{responseType:"blob"});if(s(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let n=window.URL.createObjectURL(a.data),i=document.createElement("a");i.href=n,i.target="_blank",i.rel="noopener noreferrer",i.click()}catch(e){s()}}async function j(){try{let e=new URLSearchParams({...(null==d?void 0:d[i])||{},eventId:i,withOrder:!0,timezone:new Date().getTimezoneOffset()});e.forEach((t,a)=>{""==t&&e.delete(a)}),s(!0,"Gerando relat\xf3rio");let a=await J.ZP.get("/ticket-purchase/download-table?"+e,{responseType:"arraybuffer"});if(s(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);let n=window.URL.createObjectURL(new Blob([a.data])),r=document.createElement("a");r.href=n;let l=a.headers["content-disposition"].replace("attachment; filename='","").replace("'","");r.target="_blank",r.rel="noopener noreferrer",r.download=l,r.click(),r.remove()}catch(e){et.Am.error(e.message),console.log(e),s()}}return{items:v,numberOfItems:x,isLoading:m,ticketsLimit:r,ticketsPage:l,refresh:h,downloadInvitation:g,resendTicketOrderEmail:function(e){(0,em.Z)({text:"Deseja reenviar um email deste pedido para o comprador?",confirmButtonText:"Reenviar Email",onConfirm:async()=>{s(!0,"Enviando email");let a=await (0,J.ZP)("/ticket-purchase/resend-email/".concat(e));if(s(),a.data.error)throw Error(t("error_on_processing")+"\n\n"+a.data.error.message);et.Am.success(t("success_on_processing"))}})},sendContactToActiveCompaign:function(e){let{email:a,name:n,phone:i}=e;a||et.Am.warning("N\xe3o \xe9 possivel enviar contato sem email"),(0,em.Z)({text:"Deseja enviar esse contato para o Active Compaign?",confirmButtonText:"Enviar Contato para Active Compaign",onConfirm:async()=>{s(!0,"Enviando contato para Active Compaign");let e=await J.ZP.post("/crm-integration/create-contact",{email:a,name:n,phone:i});if(s(),e.data.error)throw Error(t("error_on_processing")+"\n\n"+e.data.error.message);h(),et.Am.success(t("success_on_processing"))}})},downloadTable:j}};var lu=a(70983),lm=a(92511);let lh=e=>{var t,a;let{t:n,i18n:s}=(0,p.$)("admin"),{storedState:i,setStoredState:d}=(0,o.oR)(),{ticketsFilter:c={},currentSelectedEvent:u}=i||{},[m,h]=l.useState({}),[x,g]=l.useState({}),j=(null==u?void 0:u._id)||null,{data:f,isLoading:b}=(0,eh.Z)("/ticket-purchase/filters?eventId=".concat(j)),{sellStartDate:y,sellEndDate:N,visitStartDate:k,visitEndDate:w,ticketTitle:Z,ticketType:C,paymentType:S,paymentStatus:_,userNameEmail:D}=m;function E(e){h({...m,...e})}function P(){if(!k&&!y)return g({startDate:!0}),et.Am.error("Data in\xedcio obrigat\xf3ria para visita ou venda!");if(k&&w&&(0,av.Z)((0,tD.Z)(new Date(w)),(0,tD.Z)(new Date(k)))||y&&N&&(0,av.Z)((0,tD.Z)(new Date(N)),(0,tD.Z)(new Date(y))))return g({sellEndDate:!0}),et.Am.error("Data de in\xedcio n\xe3o deve ser maior que a data fim!");g({sellStartDate:!1,sellEndDate:!1});let e={...c};e[j]=m,Object.keys(e[j]).map(t=>{let a=e[j][t];a&&"string"==typeof a&&"Invalid Date"!==new Date(a).toString()&&(e[j][t]=new Date(a))}),d({ticketsFilter:e,ticketsPage:0})}l.useEffect(()=>{if(!j)return;let e={paymentStatus:["PAID"],sellStartDate:new Date,sellEndDate:new Date},t={...e,...c[j]};h(t)},[j]);let I=l.useRef(!1);return l.useEffect(()=>{Object.keys(m).length&&(I.current||(P(),I.current=!0))},[m]),(0,r.jsxs)("div",{className:"tickets-filters",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(am.Z,{options:(null==f?void 0:f.tickets)||[],value:Z,label:"Ingresso",cleanable:!0,multiple:!0,onChange:e=>E({ticketTitle:e})}),(0,r.jsx)(am.Z,{options:(null==f?void 0:f.ticketTypes)||[],value:C,label:"Tipo ingresso",cleanable:!0,multiple:!0,onChange:e=>E({ticketType:e})}),(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(ah.Z,{label:"Nome/email do usu\xe1rio",value:D||"",onValueChange:e=>E({userNameEmail:e})}),!!D&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:10},onClick:()=>E({userNameEmail:""}),children:(0,r.jsx)(ec.Z,{})})]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"group",children:[(0,r.jsx)(tM.Z,{label:"Data venda - in\xedcio",className:"input",value:y||null,onChange:e=>
1E({sellStartDate:e?new Date(e).toString():null,sellEndDate:e?new Date(e).toString():null}),renderInput:e=>(0,r.jsx)(es.Z,{...e,error:x.sellStartDate||x.startDate})}),!!y&&(0,r.jsx)(X.Z,{className:"clear-btn",style:{right:35},onClick:()=>E({sellStartDate:null}),children:(0,r.jsx)(ec.Z,{})})]}),(0,r.jsx)(am.Z,{options:(null==f?void 0:null===(t=f.paymentMethods)||void 0===t?void 0:t.filter(e=>!!e).map(e=>({label:n("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:S,label:"M\xe9todo de pagamento",onChange:e=>E({paymentType:e})}),(0,r.jsx)(am.Z,{options:(null==f?void 0:null===(a=f.paymentStatus)||void 0===a?void 0:a.filter(e=>!!e).map(e=>({label:n("ticket_distribution."+e),value:e})))||[],cleanable:!0,multiple:!0,value:_,label:"Status do pedido",onChange:e=>{E({paymentStatus:e})}})]}),(0,r.jsxs)("div",{className:"row last",children:[e.numberOfItems?(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:e.onRequestDownload,children:"Download tabela"}):null,(0,r.jsx)(v.Z,{variant:"contained",color:"secondary",onClick:function(){let e={...c};e[j]={},d({ticketsFilter:e}),h({})},children:"Limpar filtros"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:P,children:"Aplicar filtros"})]})]})},lv=()=>{let{setStoredState:e}=(0,o.oR)(),{t,i18n:a}=(0,p.$)("admin"),{items:n,numberOfItems:s,isLoading:i,ticketsLimit:d,ticketsPage:c,sendContactToActiveCompaign:u,downloadTable:m}=lc();return console.log("\uD83D\uDE80 ~ CrmIntegrationTable ~ items:",n),l.useEffect(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"ticket-dashboard",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("h3",{children:"Tabela de Integra\xe7\xe3o CRM"})}),(0,r.jsx)(lh,{numberOfItems:s,onRequestDownload:m}),i?(0,r.jsx)(ee.aN,{inline:!0}):!s&&(0,r.jsx)("div",{className:"nothing-found",children:t("nothing_found")}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Usu\xe1rio"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"}),(0,r.jsx)("th",{children:"CRM"}),(0,r.jsx)("th",{children:t("action")})]})}),(0,r.jsx)("tbody",{children:null==n?void 0:n.map((e,n)=>{var s,i,l,o,d;let c=e.date?(0,ej.p6)(e.date,"P",a.language)+" "+(e.time||(0,ej.p6)(e.date,"HH:mm",a.language)):"",m=e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp",a.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"",h=(0,ej.p6)(e.createdAt,"Pp",a.language),v=e.checkInDates.length===e.useLimit,x="PAID"===e.orderStatus,p=null===(s=e.order)||void 0===s?void 0:s.channel;"card-machine"!==p&&!v&&x&&(null===(i=e.user)||void 0===i||i.email);let g=e.integratedCrm;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.ticket.title}),(0,r.jsx)("td",{children:null===(l=e.ticketType)||void 0===l?void 0:l.type}),(0,r.jsx)("td",{children:null===(o=e.user)||void 0===o?void 0:o.name}),(0,r.jsx)("td",{children:null===(d=e.user)||void 0===d?void 0:d.email}),(0,r.jsx)("td",{children:c}),(0,r.jsx)("td",{children:h}),(0,r.jsx)("td",{children:t("ticket_distribution."+e.order.channel)}),(0,r.jsx)("td",{children:e.orderStatus?t("ticket_distribution."+e.orderStatus):"-"}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:e.order.paymentMethod?t("ticket_distribution."+e.order.paymentMethod):"-"}),(0,r.jsx)("td",{children:m}),(0,r.jsx)("td",{children:g?(0,r.jsx)(lu.Z,{style:{color:"#00c735"}}):(0,r.jsx)(lm.Z,{style:{color:"#C70000"}})}),(0,r.jsx)("td",{className:"actions",children:!g&&(0,r.jsx)(X.Z,{title:"Enviar para Active Compaign",onClick:()=>{var t,a,n;return u({email:null===(t=e.user)||void 0===t?void 0:t.email,name:null===(a=e.user)||void 0===a?void 0:a.name,phone:null===(n=e.user)||void 0===n?void 0:n.celphone})},children:(0,r.jsx)(U.Z,{})})})]},n)})})]})}),(0,r.jsx)(eZ,{numberOfItems:s,rowsPerPage:d,page:c,onPageChange:t=>e({ticketsPage:t}),onRowsPerPageChange:t=>e({ticketsPage:0,ticketsLimit:t})})]})};var lx=a(30119);let lp=e=>{let{data:t={},onChange:a,onClose:n}=e,{storedState:s}=(0,o.oR)(),{_id:i,endAt:d}=(null==s?void 0:s.currentSelectedEvent)||{},{toggleLoader:c}=(0,ee.U2)(),{t:u}=(0,p.$)("admin"),[m,h]=l.useState({expireAt:d,...t}),[x,g]=l.useState([]),[j,f]=l.useState(!1),[b,y]=l.useState(""),N=(0,ev.Nr)(b,300),[k,w]=l.useState(!1),[Z,C]=l.useState([]),[S,_]=l.useState({}),{user:D,ticket:E,qty:P,obs:I,expireAt:A,status:T="active"}=m||{};function R(e){h(t=>({...t,...e}))}async function L(){try{let e={};if(_(e),D||(e.user=!0),E||(e.ticket=!0),P||(e.qty=!0),Object.keys(e).length)return _(e),et.Am.error(u("incomplete_form"));c(!0,u("processing"));let t=await J.ZP.post("/ticket-distribution",{id:m.id,user:{id:D.id,name:D.name,avatar:D.avatar},ticket:{id:E.id,title:E.title,coverImageUrl:E.coverImageUrl},qty:P,obs:I,eventId:i,expireAt:A,status:T});if(c(),t.data.error)throw Error(u("error_on_processing")+" \n\n"+t.data.error.message);a(t.data),et.Am.success(u("success_on_processing"))}catch(e){c(),et.Am.error(e.message)}}return l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list?"+new URLSearchParams({event_id:i||"",limit:"100",admin:"true"}),onProcessing:w,onSuccess:e=>C(null==e?void 0:e.tickets),onError:e=>{et.Am.error(e.message)}})}i&&e()},[i]),(0,ev.ss)(()=>{N&&(async()=>{f(!0);let e=await (0,J.ZP)("/user/list?name=".concat(N,"&role=professional,supplier"));f(!1),g(e.data.users)})()},[N]),(0,r.jsx)("div",{className:"add-form modal-container forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:(null==t?void 0:t.id)?u("ticket_distribution.edit"):u("ticket_distribution.new"),onGoBack:e.onClose,data:t}),(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsx)(lx.Z,{label:u("active"===T?"ticket_distribution.active":"ticket_distribution.inactive"),checked:"inactive"!==T,disabled:!["active","inactive"].includes(T),onChange:e=>R({status:e?"active":"inactive"})}),(0,r.jsx)("div",{className:"user-select-container",children:(0,r.jsx)(e_.Z,{id:"prof",options:x,freeSolo:!0,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,disablePortal:!0,filterSelectedOptions:!0,loading:j,loadingText:"Carregando...",value:D,onChange:(e,t)=>
1{R({user:t})},onInputChange:(e,t)=>{y(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+u("ticket_distribution.select_user"),error:!!(null==S?void 0:S.user),inputProps:e.inputProps}),renderOption:(e,t)=>{let{name:a,avatar:n}=t;return(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:n,width:60,height:60})}),(0,r.jsx)("span",{className:"opt-label",children:a})]})}})}),(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"ticket",options:Z,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.title,disablePortal:!0,filterSelectedOptions:!0,loading:k,loadingText:"Carregando...",value:E,onChange:(e,t)=>{R({ticket:t})},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"* "+u("ticket_distribution.select_ticket"),error:!!(null==S?void 0:S.ticket),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImageUrl,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.title})]})})}),(0,r.jsx)(es.Z,{label:"*"+u("ticket_distribution.qty"),value:P||"",type:"number",onChange:e=>{e.stopPropagation(),R({qty:e.target.value})},error:!!S.qty,helperText:S.qty}),(0,r.jsx)(es.Z,{label:"obs",value:I||"",multiline:!0,rows:3,onChange:e=>{e.stopPropagation(),R({obs:e.target.value})}}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",onClick:n,children:u("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:L,children:u((null==t?void 0:t.id)?"ticket_distribution.update":"ticket_distribution.create")})]})]})]})})},lg=()=>{var e;let{storedState:t,setStoredState:a}=(0,o.oR)(),n=(null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id)||null,{ticketDistributionLimit:s=20,ticketDistributionPage:i=0,ticketDistributionSearch:r=""}=t,{toggleLoader:d}=(0,ee.U2)(),c=(0,ev.Nr)(r,300),{data:u,isLoading:m,refresh:h}=(0,eh.Z)("/ticket-distribution?limit=".concat(s,"&page=").concat(i,"&search=").concat(c,"&eventId=").concat(n)),{data:v,numberOfItems:x}=u||{},[p,g]=l.useState(),j=l.useCallback(e=>{(0,em.Z)({text:"Deseja realmente remover este item?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{d(!0,"Removendo item");let t=await J.ZP.delete("/ticket-distribution/".concat(e));if(d(),t.data.error)return et.Am.error(t.data.error.message);et.Am.success("Item removido com sucesso!"),h()},onError:()=>{d()}})},[]);return{refreshTable:h,items:v,numberOfItems:x,isLoading:m,selectedItem:p,addItem:function(){g({})},editItem:function(e){g(e)},removeItem:j,closeForm:function(){g(null)},setStoredState:a,ticketDistributionLimit:s,ticketDistributionPage:i,ticketDistributionSearch:r}},lj=e=>{let{t,i18n:a}=(0,p.$)("admin"),{storedState:n}=(0,o.oR)(),s=null==n?void 0:n.currentSelectedEvent,{refreshTable:i,items:l,numberOfItems:d,isLoading:c,selectedItem:u,addItem:m,editItem:h,removeItem:x,closeForm:g,setStoredState:j,ticketDistributionLimit:f,ticketDistributionPage:b,ticketDistributionSearch:y}=lg();return(0,r.jsxs)("div",{className:"professionals-and-suppliers",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("h3",{children:"Distribui\xe7\xe3o dos ingressos"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:m,className:"add-ticket",disabled:!(null==s?void 0:s.status)||(null==s?void 0:s.status)==="ended",children:t("ticket_distribution.create")})]}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(eu,{className:"search",placeholder:t("ticket_distribution.search"),value:y,onChange:e=>j({ticketDistributionSearch:(null==e?void 0:e.target.value)||""})})}),c?(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})}):(0,r.jsxs)(r.Fragment,{children:[!(null==l?void 0:l.length)&&(0,r.jsx)("div",{className:"nothing-found",children:t("nothing_found")}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:t("ticket_distribution.users")}),(0,r.jsx)("th",{children:t("ticket_distribution.ticket")}),(0,r.jsx)("th",{children:t("ticket_distribution.qty")}),(0,r.jsx)("th",{children:t("ticket_distribution.used")}),(0,r.jsx)("th",{children:t("status")}),(0,r.jsx)("th",{children:t("created_at")}),(0,r.jsx)("th",{children:t("obs")}),(0,r.jsx)("th",{children:t("action")})]})}),(0,r.jsx)("tbody",{children:null==l?void 0:l.map((e,n)=>{var s,i;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:null===(s=e.user)||void 0===s?void 0:s.name}),(0,r.jsx)("td",{children:null===(i=e.ticket)||void 0===i?void 0:i.title}),(0,r.jsx)("td",{children:e.qty}),(0,r.jsx)("td",{children:e.used.length}),(0,r.jsx)("td",{children:t(e.status)}),(0,r.jsx)("td",{children:(0,ej.p6)(e.createdAt,"P",a.language)}),(0,r.jsx)("td",{children:e.obs}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(X.Z,{onClick:()=>h(e),children:(0,r.jsx)(ep.Z,{})}),(0,r.jsx)(X.Z,{onClick:()=>x(e.id),children:(0,r.jsx)(eg.Z,{})})]})})]},n)})})]}),(0,r.jsx)(eZ,{numberOfItems:d,rowsPerPage:f,page:b,onPageChange:e=>j({ticketDistributionPage:e}),onRowsPerPageChange:e=>j({ticketDistributionPage:0,ticketDistributionLimit:e})})]}),(0,r.jsx)(K.ZP,{showAt:!!u,onClose:g,children:(0,r.jsx)(lp,{data:u,onChange:()=>{i(),g()},onClose:g})})]})};var lf=a(78046);let lb={"visits-expected":"Visitantes esperados",checkins:"Visitantes que realizaram checkin com a data de visita esperada","checkins-not-visit-date":"Visitantes que realizaram checkin, por\xe9m a data de visita do ingresso estava reservado para outro dia","checkins-not-registered":"Visitantes que n\xe3o realizaram checkin 
1na data de visita esperada"},ly=e=>{let{searchPeriod:t,type:a}=e,{t:n}=(0,p.$)("admin"),{storedState:s,setStoredState:i}=(0,o.oR)(),{currentSelectedEvent:l}=s||{},{toggleLoader:d}=(0,ee.U2)(),{visitsLimit:c=20,visitsPage:u=0,visitsSearch:m=""}=s,h=(0,ev.Nr)(m,300),x=new URLSearchParams({...Object.fromEntries(e.query),limit:c,page:u,search:h}),{data:g={},isLoading:j}=(0,eh.Z)("/ticket-purchase/checkins?"+x),{checkins:f,numberOfItems:b}=g;async function y(){try{var a;let s=new URLSearchParams({...Object.fromEntries(e.query),page:"0",limit:b,search:h});d(!0,"Baixando tabela");let i=await J.ZP.get("/ticket-purchase/checkins?"+s);if(i.data.error)throw Error(n("error_on_processing")+"\n\n"+i.data.error.message);d(!0,"Gerando tabela");let r={"Ingresso Id":{selector:"_id"},Nome:{selector:"user.name"},Email:{selector:"user.email"},"Data da Visita":{selector:"date",formatValue:e=>(0,ej.p6)(e,"Pp")},"Data checkin":{formatValue:e=>"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp")).join(", "))},Checkins:{formatValue:e=>"".concat(e.checkInDates.length,"/").concat(e.useLimit)}},o=null===(a=i.data.checkins)||void 0===a?void 0:a.map(e=>{let t={};return Object.keys(r).map(a=>{let n;let{selector:s,formatValue:i}=r[a];null==s||s.split(".").map(t=>{n=(n||e)[t]}),i&&(n=i(s?n:e)),t[a]=n}),t}),c=t0.P6.json_to_sheet(o),u=(0,t0.cW)({Sheets:{data:c},SheetNames:["data"]},{bookType:"xlsx",type:"array",cellDates:!0}),m=new Blob([u],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});nE().saveAs(m,(0,eD.k6)("Visitantes_".concat(null==l?void 0:l.title,"_").concat(t))+".xlsx"),d()}catch(e){d()}}return(0,r.jsxs)("div",{className:"checkins",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:"Visitantes ".concat(t),subTitle:lb[a]}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(eu,{className:"search",placeholder:"Pesquisar nome/email do visitante",value:m||"",onChange:e=>i({visitsSearch:(null==e?void 0:e.target.value)||""})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:y,children:"Exportar tabela"})]}),j&&(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Nome"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Data da Visita"}),(0,r.jsx)("th",{children:"Data checkin"})]})}),(0,r.jsx)("tbody",{children:null==f?void 0:f.map((e,t)=>{var a,n,s;let i=Array.isArray(e.checkInDates)&&e.checkInDates.length?"".concat(e.checkInDates.map(e=>(0,ej.p6)(e.date,"Pp")).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):(null==e?void 0:null===(a=e.checkInDates)||void 0===a?void 0:a.date)?(0,ej.p6)(e.checkInDates.date,"Pp"):"-";return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(null===(n=e.user)||void 0===n?void 0:n.name)||"-"}),(0,r.jsx)("td",{children:(null===(s=e.user)||void 0===s?void 0:s.email)||"-"}),(0,r.jsx)("td",{children:(0,ej.p6)(e.date,"Pp")}),(0,r.jsx)("td",{children:i})]},t)})})]}),(0,r.jsx)(eZ,{numberOfItems:b,rowsPerPage:c,page:u,onPageChange:e=>i({visitsPage:e}),resetPageOnFirstLoad:!0,onRowsPerPageChange:e=>i({visitsPage:0,visitsLimit:e})})]})]})},lN=e=>{var t,a,n,s,i,l,o,d;let{order:c}=e||{},{t:u,i18n:m}=(0,p.$)("common"),{id:h,paymentStatus:v,channel:x,itemsAmount:g,donationAmount:j=0,paymentMethod:f,installments:b,splitInfo:y,createdAt:N,totalAmount:k,payerInfo:w,updatedAt:Z}=c,{data:C={},isLoading:S}=(0,eh.Z)("/ticket-purchase/list?orderId=".concat(h)),_=C.items||[];return(0,r.jsxs)("div",{className:"ticket-dashboard-details bg-white",children:[(0,r.jsx)(ei.Z,{title:"Detalhes do pedido",onGoBack:K.Mr}),(0,r.jsxs)("div",{className:"content",style:{backgroundColor:"#f5f5f5"},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id:"})," ",h]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data:"})," ",(0,ej.p6)(N,"Pp")]}),"invitation"!==x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Status:"})," ",u("ticket_distribution."+v)]}),"DECLINED"===v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Motivo:"})," ",(0,iF.pH)(null==c?void 0:null===(t=c.transaction)||void 0===t?void 0:null===(a=t.charges)||void 0===a?void 0:null===(n=a[0])||void 0===n?void 0:null===(s=n.payment_response)||void 0===s?void 0:s.message,null==c?void 0:c.transaction)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"C\xf3digo erro:"})," ",null==c?void 0:null===(i=c.transaction)||void 0===i?void 0:null===(l=i.charges)||void 0===l?void 0:null===(o=l[0])||void 0===o?void 0:null===(d=o.payment_response)||void 0===d?void 0:d.code]})]}),(0,r.jsx)("b",{children:"Comprador:"}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Nome:"}),(null==w?void 0:w.name)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Email:"}),(null==w?void 0:w.email)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Documento:"}),(null==w?void 0:w.docType)?(null==w?void 0:w.docType)+": "+(null==w?void 0:w.docNumber):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total ingressos:"})," ",(0,sL.n)(g)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total doa\xe7\xf5es:"})," ",(0,sL.n)(j)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor total (ingressos + doa\xe7\xf5es):"})," ",(0,sL.n)(k)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Pagamento:"}),b,"x ",(0,sL.n)(k/b)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"M\xe9todo de pagamento:"}
1)," ",f?u("ticket_distribution."+f):"N\xe3o aplicado"]}),y&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Repasse:"}),(0,sL.n)(g*y.share/100)," (",y.name,")"]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Canal de venda:"})," ",u("ticket_distribution."+x)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(Z,"Pp")]}),S&&(0,r.jsx)(ee.aN,{message:"Buscando ingressos",inline:!0}),(0,r.jsxs)("div",{className:"tickets",children:[(0,r.jsx)("h4",{children:"Ingressos:"}),_.map(e=>{let{id:t,ticket:a,date:n,ticketDiscount:s,discount:i,coupon:l,couponDiscount:o,donationValue:d,creditCardDiscount:c,ticketType:u,time:h,updatedAt:v,user:p,value:g,inviter:j,checkInDates:f,useLimit:b}=e,y=f.length?"".concat(f.map(e=>(0,ej.p6)(e.date,"Pp",m.language)).join(", ")," (").concat(f.length,"/").concat(b,")"):"";return(0,r.jsxs)("div",{className:"ticket",style:{marginBottom:10,padding:15,border:"solid 1px lightgrey"},children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Ingresso:"})," ",a.title]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Id do ingresso:"})," ",t]}),"invitation"===x&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Convidado por:"})," ",j.name]}),(0,r.jsx)("b",{children:"Portador:"}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Nome:"}),(null==p?void 0:p.name)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Email:"}),(null==p?void 0:p.email)||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",style:{marginLeft:10},children:[(0,r.jsx)("b",{children:"Documento:"}),(null==p?void 0:p.docType)?(null==p?void 0:p.docType)+": "+(null==p?void 0:p.docNumber):"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Data visita:"})," ",n?(0,ej.p6)(n,"P",m.language)+" "+(h||""):"Indefinido"]}),i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(100*g/90)]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto geral ingresso:"})," ",i,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor ingresso com desconto:"})," ",(0,sL.n)(g)]})]}):(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor do ingresso:"})," ",(0,sL.n)(g)]}),c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto Cart\xe3o BRB:"})," ","".concat(c.discount,"%")]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cart\xe3o:"})," ",c.card]})]}):null,(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Tipo ingresso:"})," ",u.type]}),!!s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto tipo ingresso:"})," ",s,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor ingresso com desconto:"})," ",(0,sL.n)(g*(1-s/100))]})]}),!!d&&(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor doa\xe7\xf5es:"})," ",(0,sL.n)(d)]}),!!l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Cupom aplicado:"})," ",null==l?void 0:l.code]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Desconto cupom:"})," ",o,"%"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Valor com desconto do cupom:"})," ",(0,sL.n)(g*(1-o/100))]})]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"Checkin:"})," ",y||"Indefinido"]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("b",{children:"\xdaltima atualiza\xe7\xe3o:"})," ",(0,ej.p6)(v,"Pp")]})]},a.id)})]})]})]})},lk=e=>{let{t}=(0,p.$)("common"),{storedState:a,setStoredState:n}=(0,o.oR)(),{transactionsLimit:s=20,transactionsPage:i=0,transactionsSearch:l=""}=a,c=(0,ev.Nr)(l,300),{toggleLoader:u}=(0,ee.U2)(),{user:m}=(0,d.aC)(),h=new URLSearchParams({...Object.fromEntries(e.query),limit:s,page:i,search:c}),{data:v,isLoading:x}=(0,eh.Z)("/ticket-purchase/transactions?"+h),{transactions:g,countPerTotalValue:j,numberOfItems:f}=v||{};return console.log("\uD83D\uDE80 ~ Transactions ~ countPerTotalValue:",j),console.log("\uD83D\uDE80 ~ Transactions ~ transactions:",g),(0,r.jsxs)("div",{className:"reports-transactions",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:"Transa\xe7\xf5es do Operador ".concat(null==m?void 0:m.name," ").concat(e.title?" - ".concat(e.title):""," - ").concat(e.searchPeriod)}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"row"}),(0,r.jsx)("h4",{children:"Quantidade de Ingressos Vendidos por Valor"}),(0,r.jsx)("div",{className:"totals",children:null==j?void 0:j.map((e,t)=>(0,r.jsxs)("div",{className:"total-value card",children:[(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Ingressos vendidos no valor: "}),(0,sL.n)(e._id)]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Quantidade: "}),e.qty]})]},"".concat(e._id,"-").concat(t)))}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID Ingresso"}),(0,r.jsx)("th",{children:"ID Transa\xe7\xe3o"}),(0,r.jsx)("th",{children:"ID Pagar Me"}),(0,r.jsx)("th",{children:"Comprador nome"}),(0,r.jsx)("th",{children:"Comprador email"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Operador"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Valor do pedido"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"".concat(t("action"))})]})}),(0,r.jsx)("tbody",{children:x?(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:12,children:(0,r.jsx)("div",{className:"loading",children:(0,r.jsx)(ee.aN,{inline:!0})})})}):null==g?void 0:g.map((e,a)=>{var n,s,i,l;let o=(0,ix.Z)(new Date(e.order.createdAt),"dd/MM/yyyy HH:mm");return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.id||"N\xe3o identificado"}),(0,r.jsx)("td",{children:e.order.id||"N\xe3o identificado"}),(0,r.jsx)("td",{children:e.order.transactionId||"N\xe3o identificado"}),(0,r.jsx)("td",{children:null===(n=e.order.payerInfo)||void 0===n?void 0:n.name}),(0,r.jsx)("td",{children:null===(s=e.order.payerInfo)||void 0===s?void 0:s.email}),(0,r.jsx)("td",{children:t("ticket_distribution."+e.order.channel)}),(0,r.jsx)("td",{children:null===(i=e.order.machineOperator)||void 0===i?void 0:i.name}),(0,r.jsx)("td",{children:null===(l=e.order.transaction)||void 0===l?void 0:l.terminalSerialNumber}),(0,r.jsx)("td",{children:t("ticket_distribution."+e.order.paymentStatus)}),(0,r.jsx)("td",{children:t("ticket_distribution."+(e.order.paymentMethod||"not-registered"))}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:o}),(0,r.jsx)("td",{className:"actions",children:(0,r.jsx)(X.Z,{onClick:()=>(0,K.K4)((0,r.jsx)(lN,{order:e.order})),children:(0,r.jsx)(nZ.Z,{})})})]},a)})})]}),(0,r.jsx)(eZ,{numberOfItems:f,rowsPerPage:s,page:i,onPageChange:e=>n({transactionsPage:e}),resetPageOnFirstLoad:!0,onRowsPerPageChange:e=>n({transactionsPage:0,transactionsLimit:e})})]})]})},lw=e=>{var t;
1let{t:a}=(0,p.$)("admin"),{downloadTicketsOfficeReportPdf:n}=iP(),{data:s,isLoading:i,startDate:o=new Date,endDate:d=new Date,searchPeriod:c,query:u,eventId:m}=e,{totalValue:h=0,tickets:x=[],paymentMethods:g=[],channels:j=[],numberOfOrders:f=0,numberOfItems:b=0,checkins:y,checkinsNotVisitDate:N,checkinsNotRegistered:k,visitsExpected:w}=s||{},Z=l.useMemo(()=>{let e={};return g.map(t=>{let a=t._id.channel,n=t._id.paymentMethod||("invitation"===a?"invitation":"100%_discount");e[n]||(e[n]={channels:{},totalValue:0,totalQty:0}),e[n]={channels:{...e[n].channels,[a]:{value:t.totalValue,qty:null==t?void 0:t.qty}},totalValue:e[n].totalValue+(null==t?void 0:t.totalValue),totalQty:e[n].totalQty+(null==t?void 0:t.qty)}}),(0,eD.ab)(e)},[b]),C=l.useMemo(()=>{let e={};return j.map(t=>{let a=t._id.channel;e[a]||(e[a]={totalValue:0,totalQty:0}),e[a]={totalValue:e[a].totalValue+(null==t?void 0:t.totalValue),totalQty:e[a].totalQty+(null==t?void 0:t.qty)}}),(0,eD.ab)(e)},[b]);return s&&s.eventId===m?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"ticket-purchase-statistics",children:[!i&&h?(0,r.jsx)("div",{style:{marginTop:"-1rem",marginBottom:"1.5rem"},children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>n({sellStartDate:o.toString(),sellEndDate:d.toString()}),children:"Border\xf4 da Bilheteria"})}):null,(0,r.jsx)("div",{className:"totals",children:i?(0,r.jsx)(r.Fragment,{children:[1,2].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"total-value card",children:[(0,r.jsx)("div",{className:"title",children:"Totais vendas"}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total: "}),(0,sL.n)(h)]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"N\xfamero de Transa\xe7\xf5es: "}),f]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"N\xfamero de ingressos: "}),b]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Ingressos pagos: "}),Object.keys(Z).filter(e=>"free"!==e&&"100%_discount"!==e&&"invitation"!==e).reduce((e,t)=>e+Z[t].totalQty,0)]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Ingressos gr\xe1tis: "}),Object.keys(Z).filter(e=>"free"===e).reduce((e,t)=>e+Z[t].totalQty,0)]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Ingressos convites: "}),b-(b-((null===(t=Z.invitation)||void 0===t?void 0:t.totalQty)||0))]}),(0,r.jsx)(X.Z,{className:"see-more-btn",onClick:()=>{(0,ng.FJ)((0,r.jsx)(lk,{searchPeriod:c,query:u}))},children:(0,r.jsx)(lf.Z,{fontSize:"large"})})]}),(0,r.jsxs)("div",{className:"total-value card",children:[(0,r.jsx)("div",{className:"title",children:"Visitantes"}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Visitas previstas: "}),(0,r.jsxs)("div",{children:[w,(0,r.jsx)(X.Z,{className:"see-more-btn",onClick:()=>{(0,ng.FJ)((0,r.jsx)(ly,{type:"visits-expected",searchPeriod:c,query:u}))},children:(0,r.jsx)(lf.Z,{fontSize:"small"})})]})]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"CheckIns realizados (na data de visita): "}),(0,r.jsxs)("div",{children:[y,(0,r.jsx)(X.Z,{className:"see-more-btn",onClick:()=>{(0,ng.FJ)((0,r.jsx)(ly,{type:"checkins",searchPeriod:c,query:new URLSearchParams({...Object.fromEntries(u),type:"checkins"})}))},children:(0,r.jsx)(lf.Z,{fontSize:"small"})})]})]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"CheckIns realizados (fora da data de visita): "}),(0,r.jsxs)("div",{children:[N,(0,r.jsx)(X.Z,{className:"see-more-btn",onClick:()=>{(0,ng.FJ)((0,r.jsx)(ly,{type:"checkins-not-visit-date",searchPeriod:c,query:new URLSearchParams({...Object.fromEntries(u),type:"checkins-not-visit-date"})}))},children:(0,r.jsx)(lf.Z,{fontSize:"small"})})]})]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"CheckIns realizados (total): "}),(0,r.jsxs)("div",{children:[y+N,(0,r.jsx)(X.Z,{className:"see-more-btn",disabled:!0,onClick:()=>{(0,ng.FJ)((0,r.jsx)(ly,{type:"visits-expected",searchPeriod:c,query:u}))},children:(0,r.jsx)(lf.Z,{fontSize:"small",style:{color:"#fff"}})})]})]}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"CheckIns nao registrados: "}),(0,r.jsxs)("div",{children:[k,(0,r.jsx)(X.Z,{className:"see-more-btn",onClick:()=>
1{(0,ng.FJ)((0,r.jsx)(ly,{type:"checkins-not-registered",searchPeriod:c,query:new URLSearchParams({...Object.fromEntries(u),type:"checkins-not-registered"})}))},children:(0,r.jsx)(lf.Z,{fontSize:"small"})})]})]})]})]})}),(0,r.jsxs)("div",{className:"",children:[(0,r.jsx)("h3",{children:"Vendas por tipo"}),(0,r.jsx)("div",{className:"payment-types",children:i?(0,r.jsx)(r.Fragment,{children:[1,2,3,4].map(e=>(0,r.jsx)("div",{className:"placeholder2",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}):Object.keys(Z).map((e,t)=>{let{totalValue:n,totalQty:s,channels:i}=Z[e];return(0,r.jsxs)("div",{className:"payment-methods card",children:[(0,r.jsx)("div",{className:"title",children:"".concat(a("ticket_distribution."+e))}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Total: "}),(0,sL.n)(n)," (",s,")"]}),(0,r.jsx)("div",{className:"channels",children:Object.keys(i).map((e,t)=>{let{value:n,qty:s}=i[e]||{};return(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsxs)("span",{children:["".concat(a("ticket_distribution."+e)),": "]}),(0,r.jsxs)("span",{children:[(0,sL.n)(n)," (",s,")"]})]},t)})})]},t)})})]}),(0,r.jsxs)("div",{className:"",children:[(0,r.jsx)("h3",{children:"Vendas por canal"}),(0,r.jsx)("div",{className:"payment-types",children:i?(0,r.jsx)(r.Fragment,{children:[1,2].map(e=>(0,r.jsx)("div",{className:"placeholder2",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}):Object.keys(C).filter(e=>!!e).map((e,t)=>{let{totalValue:n,totalQty:s}=C[e];return(0,r.jsxs)("div",{className:"payment-methods card",children:[(0,r.jsx)("div",{className:"title",children:"".concat(a("ticket_distribution."+e))}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Total: "}),(0,sL.n)(n)]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"Porcentagem das vendas: "}),Math.round(n/h*1e4)/100+"%"]}),(0,r.jsxs)("div",{className:"channel",children:[(0,r.jsx)("span",{children:"N\xfamero de ingressos: "}),s]})]},t)})})]}),(0,r.jsxs)("div",{className:"",children:[(0,r.jsx)("h3",{children:"Ingressos vendidos"}),(0,r.jsx)("div",{className:"tickets",children:i?(0,r.jsx)(r.Fragment,{children:[1,2,3,4].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}):(0,eD.uY)(x,"qty").map((e,t)=>{let a=Math.round(e.totalValue/h*1e4)/100;return(0,r.jsxs)("div",{className:"ticket card",onClick:()=>{var t,a;(0,ng.FJ)((0,r.jsx)(lk,{title:"Ingresso ".concat(null==e?void 0:null===(t=e._id)||void 0===t?void 0:null===(a=t.ticketTitle)||void 0===a?void 0:a.replace("Ingresso","")),searchPeriod:c,query:new URLSearchParams({...Object.fromEntries(u),ticketId:e._id.ticketId})}))},children:[(0,r.jsx)("div",{className:"bar",style:{width:"".concat(a,"%")}}),(0,r.jsx)("div",{className:"ticket-title",children:e._id.ticketTitle}),(0,r.jsxs)("div",{className:"numbers",children:[(0,sL.n)(e.totalValue)," | QTY: ",e.qty," | ",a,"%"]})]},"".concat(e._id.ticketId,"-").concat(t))})})]})]})}):null},lZ=e=>{let{label:t,...a}=e;return(0,r.jsxs)(nT.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(nT.Z,{sx:{width:"100%",mr:1},children:(0,r.jsx)(a5.Z,{variant:"determinate",...a})}),(0,r.jsx)(nT.Z,{sx:{minWidth:35},children:(0,r.jsx)(a1.Z,{variant:"body2",color:"text.secondary",children:t})})]})},lC="ticket-purchase-statistics",lS=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},[a,n]=l.useState(),[s,i]=l.useState({}),[d,c]=l.useState(""),[u,m]=l.useState("purchase"),h=null==t?void 0:t._id,{id:v,status:x,setTaskId:p,dataResult:g,description:j,title:f,progress:b}=n5({screen:lC});async function y(e){try{n(e);let{startDate:t,endDate:a}=e,s=t&&a?" de ".concat((0,ej.p6)(t,"P")," \xe0 ").concat((0,ej.p6)(a,"P")):t&&!a?" a partir de ".concat((0,ej.p6)(t,"P")):!t&&a?" at\xe9 ".concat((0,ej.p6)(a,"P")):"";c(s);let{data:r}=await J.ZP.post("/task",{title:"Evolu\xe7\xe3o da Bilheteria - ".concat(s),screen:lC,description:"Preparando para gerar relat\xf3rio"}),l=localStorage.getItem(o.rR),d=l?JSON.parse(l):[];console.log("\uD83D\uDE80 ~ start ~ storedTaskData:",d);let m=[...d.filter(e=>e.screen!==r.screen),r];console.log("\uD83D\uDE80 ~ start ~ taskDatas:",m),localStorage.setItem(o.rR,JSON.stringify(m));let v=new URLSearchParams({eventId:h,startDate:t.toString(),endDate:a.toString(),taskId:r.id,dateFilterBy:u});i(v),p(r.id),console.log("\uD83D\uDE80 ~ start ~ data:",r),await J.ZP.get("/ticket-purchase/statistics?"+v)}catch(e){toast.error(e.message)}}return(0,r.jsxs)("div",{className:"reports",children:[(0,r.jsx)("h3",{children:"Evolu\xe7\xe3o da bilheteria por per\xedodo"}),(0,r.jsxs)(ty.Z,{color:"primary",size:"small",value:u,exclusive:!0,onChange:(e,t)=>
1{t&&m(t)},disabled:"in_progress"===x,className:"date-filter-selector",children:[(0,r.jsx)(tN.Z,{value:"purchase",children:"Data da compra"}),(0,r.jsx)(tN.Z,{value:"visit",children:"Data da visita"})]}),(0,r.jsx)(ru,{status:x,onDateChange:y}),((null==g?void 0:g.eventId)===h||!(null==g?void 0:g.eventId))&&j&&(0,r.jsx)("h4",{children:"".concat(f," - ").concat(j)}),"in_progress"===x&&(0,r.jsx)(lZ,{label:"".concat(b,"%"),value:b}),(0,r.jsx)(lw,{startDate:null==a?void 0:a.startDate,endDate:null==a?void 0:a.endDate,eventId:h,data:g,isLoading:"in_progress"===x,searchPeriod:d,query:s})]})},l_=()=>{var e;let{storedState:t}=(0,o.oR)(),a=(null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id)||null,n=new URLSearchParams({eventId:a}),{data:s,isLoading:i,refresh:r}=(0,eh.Z)("/ticket-purchase-flash/filters?"+n);return{items:s||[],isLoading:i,refresh:r}};var lD=a(44510);let lE=e=>{var t,a,n;let{selectedEventIds:s,currentEventId:i,currentEventStartAt:l,currentEventEndAt:o,endDate:d,onSelectedEventIds:c,onEndDateChange:u}=e,{items:m,isLoading:h}=l_();return h?(0,r.jsx)("div",{className:"dashboard-tickets-purchases-filters",children:(0,r.jsxs)("div",{className:"filters-container",children:[(0,r.jsx)("div",{className:"filters-header",children:(0,r.jsx)("h3",{children:"Eventos"})}),(0,r.jsx)("div",{className:"filters-items",children:null===(t=Array.from({length:4}))||void 0===t?void 0:t.map((e,t)=>(0,r.jsxs)("div",{className:"filter-item",children:[(0,r.jsx)(sl.Z,{height:40,width:40}),(0,r.jsx)(sl.Z,{height:40,width:160})]},t))})]})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-filters",children:(0,r.jsxs)("div",{className:"filters-container",children:[(0,r.jsx)("div",{className:"filters-date-picker",children:(0,r.jsxs)("div",{className:"input-date-picker",children:[(0,r.jsx)(tM.Z,{label:"Database...",className:"input",maxDate:o,minDate:l,value:d||null,onChange:e=>u(e),renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"}),openTo:"day",defaultCalendarMonth:o}),(0,r.jsx)(X.Z,{className:"clear-database-button",onClick:()=>u(null),children:(0,r.jsx)(lD.Z,{})})]})}),(0,r.jsx)("div",{className:"filters-header",children:(0,r.jsx)("h3",{children:"Eventos"})}),(0,r.jsx)("div",{className:"filters-items",children:null==m?void 0:m.map(e=>{var t;return(0,r.jsxs)("div",{className:"filter-item ".concat(e.id===i?"current-event":""),children:[(0,r.jsxs)("div",{className:"event-checkbox-container",children:[(0,r.jsx)(tr.Z,{checked:s.includes(null!==(a=e.id)&&void 0!==a?a:""),onChange:t=>{if(t.target.checked){var a;c([...s,null!==(a=e.id)&&void 0!==a?a:""])}else c(s.filter(t=>t!==e.id))}}),s.includes(null!==(n=e.id)&&void 0!==n?n:"")&&(0,r.jsx)("div",{className:"event-color-container",children:(0,r.jsx)("div",{className:"event-color",style:{backgroundColor:null==e?void 0:null===(t=e.chart)||void 0===t?void 0:t.color1}})})]}),(0,r.jsx)("h4",{children:e.title}),(0,r.jsx)("p",{className:"event-date",children:"".concat((0,ix.Z)((0,rX.Z)(e.startAt),"dd/MM/yyyy HH:mm")," a ").concat((0,ix.Z)((0,rX.Z)(e.endAt),"dd/MM/yyyy HH:mm"))})]},e.id)})})]})})};var lP=a(91819),lI=a(61120),lA=a.n(lI);let lT=async()=>{let e=document.createElement("style");try{e.innerHTML="\n      .dashboard-tickets-purchases {\n        width: 2048px !important;\n        max-width: 2048px !important;\n      }\n      .flash-bilheteria-content, .share-on-off-content, .share-payment-method-content,\n      .breakdown-dia-da-semana-content, .breakdown-visitor-profile-content {\n        width: 2048px !important;\n        max-width: 2048px !important;\n      }\n      /* Ajustes para garantir que os gr\xe1ficos ocupem 100% da largura */\n      .chart-content, .operations-chart-container, .totals-chart-container,\n      .chart-content-hour-of-day {\n        width: 100% !important;\n        max-width: 100% !important;\n        overflow: visible !important;\n      }\n      /* Garante que os canvas dos gr\xe1ficos tamb\xe9m ocupem toda a largura */\n      .chart-content canvas, .operations-chart-container canvas,\n      .totals-chart-container canvas, .chart-content-hour-of-day canvas {\n        width: 100% !important;\n        max-width: 100% !important;\n      }\n      /* Ajusta altura proporcional */\n      .totals-chart-item {\n        width: 100% !important;\n        height: auto !important;\n      }
1\n      /* Ajusta tabelas para garantir visibilidade completa */\n      table {\n        max-width: 100% !important;\n        table-layout: fixed !important;\n        word-break: break-word !important;\n      }\n    ",document.head.appendChild(e),await new Promise(e=>setTimeout(e,300));let t=new lP.default({orientation:"portrait",unit:"mm",format:"a4",compress:!0}),a=t.internal.pageSize.getWidth(),n=a-10,s=5,i=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return console.warn("Elemento n\xe3o encontrado para captura"),null;let a={width:e.style.width,maxWidth:e.style.maxWidth,position:e.style.position,overflow:e.style.overflow,display:e.style.display,transform:e.style.transform},n=[];if(e.style.width="".concat(2048,"px"),e.style.maxWidth="".concat(2048,"px"),e.style.position="absolute",e.style.overflow="visible",e.style.transform="scale(1)",t){e.style.display="block";let t=e.querySelectorAll("canvas");Array.from(t).forEach(e=>{n.push({width:e.style.width,height:e.style.height,maxWidth:e.style.maxWidth})}),t.forEach(e=>{e.style.width="100%",e.style.maxWidth="100%",e.style.height="auto"})}await new Promise(e=>setTimeout(e,500));try{let s=await lA()(e,{logging:!1,useCORS:!0,scale:1,width:2048,windowWidth:2048,onclone:function(e,a){if(t){let e=a.querySelectorAll("canvas");e.forEach(e=>{e.style.width="100%",e.style.maxWidth="100%"})}}});if(e.style.width=a.width,e.style.maxWidth=a.maxWidth,e.style.position=a.position,e.style.overflow=a.overflow,e.style.display=a.display,e.style.transform=a.transform,t){let t=e.querySelectorAll("canvas");t.forEach((e,t)=>{n[t]&&(e.style.width=n[t].width,e.style.height=n[t].height,e.style.maxWidth=n[t].maxWidth)})}return s}catch(t){return console.error("Erro ao capturar canvas:",t),e.style.width=a.width,e.style.maxWidth=a.maxWidth,e.style.position=a.position,e.style.overflow=a.overflow,e.style.display=a.display,e.style.transform=a.transform,null}},r=(e,t,a,s,i,r)=>{try{e.internal.pageSize.getHeight();let l=r;return l=r*(n/i),e.addImage({imageData:t,format:"PNG",x:a,y:s,width:n,height:l,compression:"FAST",alias:"img_"+Math.random().toString(36).substring(2,15)}),{success:!0,height:l}}catch(e){return console.error("Erro ao adicionar imagem:",e),{success:!1,height:0}}},l=e=>{e.forEach(e=>{e&&(e.style.visibility="visible",e.style.opacity="1")})},o=(e,t)=>{e.forEach((e,a)=>{e&&(e.style.visibility=t[a].visibility,e.style.opacity=t[a].opacity)})},d=document.querySelectorAll('[role="tab"]'),c=d[0];c&&(c.click(),c.setAttribute("aria-selected","true"),await new Promise(e=>setTimeout(e,500))),t.setFontSize(16),t.text("Flash Bilheteria",5,s),s+=10;let u=document.querySelector(".flash-bilheteria-content");if(u){let e=u.querySelector(".chart-content"),a=u.querySelector(".table-content"),d=document.querySelector(".totals-chart-container");document.querySelectorAll(".totals-chart-item");let c=document.querySelectorAll(".totals-chart-item canvas"),m=[e,a],h=null==m?void 0:m.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""})),v=(null==d?void 0:d.style.gridTemplateColumns)||"",x=document.createElement("style");x.innerHTML="\n        .totals-chart-container {\n          display: grid !important;\n          grid-template-columns: 1fr 1fr !important;\n          grid-gap: 20px !important;\n          width: ".concat(2048,"px !important;\n          max-width: ").concat(2048,"px !important;\n        }\n        .totals-chart-item {\n          width: 100% !important;\n          max-width: 100% !important;\n          height: auto !important;\n        }\n      "),document.head.appendChild(x),await new Promise(e=>setTimeout(e,500)),c.forEach(e=>{let t=e.width,a=e.height;e.style.width="100%",e.style.maxWidth="100%",e.style.height="auto",e.width=800,e.height=Math.round(800*(a/t))}),l(m),await new Promise(e=>setTimeout(e,1e3));let p=u.querySelector(".table-total-tickets");if(p){let e=await i(p);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela de totais")}}let g=u.querySelector(".totals-chart-container");if(g){let e=await i(g,!0);
1if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width;s+i>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem dos gr\xe1ficos de totais")}}let j=u.querySelector(".table-flash-bilheteria");if(j){t.addPage(),s=5;let e=await i(j);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela de flash bilheteria")}}let f=u.querySelector(".operations-chart-container");if(f){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(f,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico de opera\xe7\xf5es")}}x&&x.parentNode&&document.head.removeChild(x),d&&(d.style.gridTemplateColumns=v),o(m,h)}let m=document.querySelector('[role="tab"][aria-selected="false"]');if(m){m.click(),await new Promise(e=>setTimeout(e,1e3)),t.addPage(),s=5,t.setFontSize(16),t.text("Share On/Off",5,s),s+=10;let e=document.querySelector(".share-on-off-content");if(e){let a=e.querySelector(".chart-content"),d=e.querySelector(".table-content"),c=[a,d],u=null==c?void 0:c.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""}));l(c),await new Promise(e=>setTimeout(e,500));let m=e.querySelector(".table-share-on-off");if(m){let e=await i(m);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela Share On Off")}}let h=e.querySelector(".operations-chart-container");if(h){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(h,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico Share On Off")}}o(c,u)}let a=document.querySelector('[role="tab"][aria-selected="true"]');a&&a.click()}let h=document.querySelectorAll('[role="tab"]')[2];if(h){h.click(),await new Promise(e=>setTimeout(e,1e3)),t.addPage(),s=5,t.setFontSize(16),t.text("Share Pagamento",5,s),s+=10;let e=document.querySelector(".share-payment-method-content");if(e){let a=e.querySelector(".chart-content"),d=e.querySelector(".table-content"),c=[a,d],u=null==c?void 0:c.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""}));l(c),await new Promise(e=>setTimeout(e,500));let m=e.querySelector(".table-share-payment-method");if(m){let e=await i(m);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela Share Payment")}}let h=e.querySelector(".chart-content");if(h){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(h,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico Share Payment")}}o(c,u)}let a=document.querySelector('[role="tab"][aria-selected="true"]');a&&a.click()}let v=document.querySelectorAll('[role="tab"]')[3];if(v){v.click(),await new Promise(e=>setTimeout(e,1e3)),t.addPage(),s=5,t.setFontSize(16),t.text("Breakdown Dia da Semana X Hor\xe1rio",5,s),s+=10;let e=document.querySelector(".breakdown-dia-da-semana-content");if(e){let a=e.querySelector(".chart-content"),d=e.querySelector(".table-content"),c=[a,d],u=null==c?void 0:c.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""}));l(c),await new Promise(e=>setTimeout(e,500));let m=e.querySelector(".table-breakdown-day-of-week");if(m){let e=await i(m);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela Dia da Semana")}}let h=e.querySelector(".chart-content");
1if(h){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(h,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico Dia da Semana")}}let v=e.querySelector(".table-breakdown-hour-of-day");if(v){t.addPage(),s=5;let e=await i(v);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela Hora do Dia")}}let x=e.querySelector(".chart-content-hour-of-day"),p=null==x?void 0:x.querySelector("canvas");if(p){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5),x&&(x.style.display="block",x.style.visibility="visible",x.style.opacity="1"),await new Promise(e=>setTimeout(e,500));let e=await i(p,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico Hora do Dia")}x&&(x.style.display="",x.style.visibility="",x.style.opacity="")}o(c,u)}let a=document.querySelector('[role="tab"][aria-selected="true"]');a&&a.click()}let x=document.querySelectorAll('[role="tab"]')[4];if(x){x.click(),await new Promise(e=>setTimeout(e,1e3)),t.addPage(),s=5,t.setFontSize(16),t.text("Perfis de Usu\xe1rios",5,s),s+=10;let e=document.querySelector(".breakdown-visitor-profile-content");if(e){let a=e.querySelector(".chart-content"),d=e.querySelector(".table-content"),c=[a,d],u=null==c?void 0:c.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""}));l(c),await new Promise(e=>setTimeout(e,500));let m=e.querySelector(".table-breakdown-visitor-profile");if(m){let e=await i(m);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela de Perfis de Usu\xe1rios")}}let h=e.querySelector(".chart-content");if(h){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(h,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico de Perfis de Usu\xe1rios")}}o(c,u)}}let p=document.querySelectorAll('[role="tab"]')[5];if(p){p.click(),await new Promise(e=>setTimeout(e,1e3)),t.addPage(),s=5,t.setFontSize(16),t.text("Modalidade X Tipo de Ingresso",5,s),s+=10;let e=document.querySelector(".breakdown-ticket-type-content");if(e){let a=e.querySelectorAll(".chart-content, .chart-content-ticket-type"),d=e.querySelectorAll(".table-content"),c=[...Array.from(a),...Array.from(d)],u=null==c?void 0:c.map(e=>({visibility:(null==e?void 0:e.style.visibility)||"",opacity:(null==e?void 0:e.style.opacity)||""}));l(c),await new Promise(e=>setTimeout(e,500));let m=e.querySelector(".table-breakdown-ticket-modality-and-type");if(m){let e=await i(m);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela de Modalidade de Ingresso")}}let h=e.querySelector(".chart-content");if(h){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(h,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico de Modalidade de Ingresso")}}let v=e.querySelector(".table-breakdown-ticket-type");if(v){t.addPage(),s=5;let e=await i(v);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem da tabela de Tipo de Ingresso")}}let x=e.querySelector(".chart-content-ticket-type");if(x){s+100>t.internal.pageSize.getHeight()&&(t.addPage(),s=5);let e=await i(x,!0);if(e){let a=e.toDataURL("image/png",.8),i=e.height*n/e.width,l=r(t,a,5,s,n,i);l.success?s+=l.height+5:console.warn("N\xe3o foi poss\xedvel adicionar a imagem do gr\xe1fico de Tipo de Ingresso")}}o(c,u)}let a=document.querySelector('[role="tab"][aria-selected="true"]');a&&a.click()}console.log("Salvando PDF..."),t.save("relatorio-bilheteria.pdf"),console.log("PDF salvo com sucesso!")}catch(e){console.error("Erro ao gerar PDF:",e),alert("Erro ao gerar o PDF. Verifique o console para mais detalhes.")}finally{e&&e.parentNode&&document.head.removeChild(e)}},lR=()=>{let[e,t]=(0,l.useState)(!1),{toggleLoader:a}=(0,ee.U2)(),n=async()=>{t(!0),a(!0,"Gerando PDF");try{await lT()}finally{t(!1),a(!1)}};return(0,r.jsx)(v.Z,{variant:"contained",onClick:n,disabled:e,className:"download-pdf-button",children:e?"Gerando PDF...":"Download PDF"})},lL={1:"Jan",2:"Fev",3:"Mar",4:"Abr",5:"Mai",6:"Jun",7:"Jul",8:"Ago",9:"Set",10:"Out",11:"Nov",12:"Dez"};var lq=a(95570);let lM=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},lO=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-flash-bilheteria",children:(0,r.jsxs)("table",{className:"table-flash-bilheteria table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})},lF=e=>{let{eventId:t,operationDay:a}=e,n=new URLSearchParams({eventId:t,operationDay:a.toString()}),{data:s,isLoading:i,refresh:r}=(0,eh.Z)("/ticket-purchase-flash/tickets-by-operation-day?"+n);return{items:s||[],isLoading:i,refresh:r}},lB=()=>{var e;return(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)(ee.aN,{inline:!0}),(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Transa\xe7\xe3o Id"}),(0,r.jsx)("th",{children:"Ingresso Id"}),(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Usu\xe1rio"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Comprador telefone"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"})]})}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:30}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})}),(0,r.jsx)("td",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})]},t))})]})})]})},lU=e=>{var t;let{eventId:a,eventTitle:n,ticketPurchaseFlash:s}=e,{t:i}=(0,p.$)("admin"),{i18n:o}=(0,p.$)(),{items:d,isLoading:c}=lF({eventId:s.originalEventId,operationDay:s.operationDay});return(0,l.useEffect)(()=>{let e={top:0,left:0,x:0,y:0};!function t(){let a=document.querySelector(".dashboard-tickets-purchases-flash-bilheteria-details .table-wrapper");if(!a)return setTimeout(t,100);let n=function(t){e={left:a.scrollLeft,top:a.scrollTop,x:t.clientX,y:t.clientY},a.style.cursor="grabbing",a.addEventListener("mousemove",s),a.addEventListener("mouseup",i),a.addEventListener("mouseleave",i)},s=function(t){let n=t.clientX-e.x,s=t.clientY-e.y;a.scrollTop=e.top-s,a.scrollLeft=e.left-n},i=function(){a.style.cursor="grab",a.removeEventListener("mousemove",s),a.removeEventListener("mouseup",i),a.removeEventListener("mouseleave",i)};function r(e){(e.altKey||91===e.keyCode)&&a&&(a.style.cursor="grab",a.style.userSelect="none",a.addEventListener("mousedown",n))}function l(e){a&&(a.style.cursor="default",a.style.removeProperty("user-select"),a.removeEventListener("mousedown",n))}return document.addEventListener("keydown",r),document.addEventListener("keyup",l),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",l)}}()},[]),(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-flash-bilheteria-details",children:[(0,r.jsx)(ei.Z,{onGoBack:ng.dL,title:"".concat("related"===s.type?(null===(t=s.relatedEvent)||void 0===t?void 0:t.t
1itle)||"".concat(n," (Evento Relacionado)"):n," - Ingressos para visita no dia ").concat((0,ix.Z)(new Date(s.year,s.month-1,s.day),"dd/MM/yyyy")," - Opera\xe7\xe3o Dia N\xba: ").concat(s.operationDay)}),c?(0,r.jsx)(lB,{}):(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{children:"Segure alt + mouseDrag para rolar a tabela"}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Transa\xe7\xe3o Id"}),(0,r.jsx)("th",{children:"Ingresso Id"}),(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Tipo ingresso"}),(0,r.jsx)("th",{children:"Usu\xe1rio"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Comprador telefone"}),(0,r.jsx)("th",{children:"Data visita"}),(0,r.jsx)("th",{children:"Data venda"}),(0,r.jsx)("th",{children:"Canal de venda"}),(0,r.jsx)("th",{children:"Vendedor respons\xe1vel"}),(0,r.jsx)("th",{children:"SN maquininha"}),(0,r.jsx)("th",{children:"Status pedido"}),(0,r.jsx)("th",{children:"Pagamento"}),(0,r.jsx)("th",{children:"Tipo Pagamento"}),(0,r.jsx)("th",{children:"Checkin"})]})}),(0,r.jsx)("tbody",{children:null==d?void 0:d.map((e,t)=>{var a,n,s,l,d,c,u,m,h,v;let x=e.date?(0,ej.p6)(e.date,"P",o.language)+" "+(e.time||(0,ej.p6)(e.date,"HH:mm",o.language)):"",p=e.checkInDates.length?"".concat(null===(a=e.checkInDates)||void 0===a?void 0:a.map(e=>(0,ej.p6)(e.date,"Pp",o.language)).join(", ")," (").concat(e.checkInDates.length,"/").concat(e.useLimit,")"):"",g=(0,ej.p6)(e.createdAt,"Pp",o.language);e.checkInDates.length,e.useLimit,e.orderStatus;let j=null===(n=e.order)||void 0===n?void 0:n._id;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:j}),(0,r.jsx)("td",{children:e.id}),(0,r.jsx)("td",{children:e.ticket.title}),(0,r.jsx)("td",{children:null===(s=e.ticketType)||void 0===s?void 0:s.type}),(0,r.jsx)("td",{children:null===(l=e.user)||void 0===l?void 0:l.name}),(0,r.jsx)("td",{children:null===(d=e.user)||void 0===d?void 0:d.email}),(0,r.jsx)("td",{children:(null==e?void 0:null===(c=e.order)||void 0===c?void 0:null===(u=c.payerInfo)||void 0===u?void 0:u.celphone)||"-"}),(0,r.jsx)("td",{children:x}),(0,r.jsx)("td",{children:g}),(0,r.jsx)("td",{children:"".concat(i("ticket_distribution."+e.order.channel))}),(0,r.jsx)("td",{children:(null===(m=e.order)||void 0===m?void 0:null===(h=m.machineOperator)||void 0===h?void 0:h.name)||"-"}),(0,r.jsx)("td",{children:null===(v=e.order.transaction)||void 0===v?void 0:v.terminalSerialNumber}),(0,r.jsx)("td",{children:e.orderStatus?"".concat(i("ticket_distribution."+e.orderStatus)):"-"}),(0,r.jsx)("td",{children:(0,sL.n)(e.totalValue)}),(0,r.jsx)("td",{children:e.order.paymentMethod?"".concat(i("ticket_distribution."+e.order.paymentMethod)):"-"}),(0,r.jsx)("td",{children:p})]},t)})})]})})]})]})};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De);let lz={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Pagantes"}}};function lV(e){let{data:t}=e;return(0,r.jsx)(tb.$Q,{options:lz,data:t})}tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De);let lG={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"M\xe9dia de Pagantes"}}};function lW(e){let{data:t}=e;return(0,r.jsx)(tb.$Q,{options:lG,data:t})}tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De);let l$={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Bilheteria"}}};function lH(e){let{data:t}=e;return(0,r.jsx)(tb.$Q,{options:l$,data:t})}tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De);let lJ={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"TKM"}}};function lQ(e){let{data:t}=e;return(0,r.jsx)(tb.$Q,{options:lJ,data:t})}function lY(e){let{flashesBilheteria:t}=e,a=null==t?void 0:t.map(e=>({label:"".concat(e.event.title),data:[(0,eD.QV)(e.totals.totalTickets)],backgroundColor:e.chart.backgroundColor})),n=null==t?void 0:t.map(e=>({label:"".concat(e.event.title),data:[(0,eD.QV)(e.totals.totalTickets/e.totals.currentOperationDay)],backgroundColor:e.chart.backgroundColor})),s=null==t?void 0:t.map(e=>({label:"".concat(e.event.title),data:[(0,eD.QV)(e.totals.totalValue/100)],backgroundColor:e.chart.backgroundColor})),i=null==t?void 0:t.map(e=>({label:"".concat(e.event.title),data:[(0,eD.QV)((0,eD.QV)(e.totals.totalValue/e.totals.totalTickets)/100)],backgroundColor:e.chart.backgroundColor}));return(0,r.jsxs)("div",{className:"totals-chart-container",children:[(0,r.jsx)("div",{className:"totals-chart-item",children:(0,r.jsx)(lV,{data:{labels:["Pagantes"],datasets:a}})}),(0,r.jsx)("div",{className:"totals-chart-item",children:(0,r.jsx)(lW,{data:{labels:["M\xe9dia de Pagantes"],datasets:n}})}),(0,r.jsx)("div",{className:"totals-chart-item",children:(0,r.jsx)(lH,{data:{labels:["Bilheteria"],datasets:s}})}),(0,r.jsx)("div",{className:"totals-chart-item",children:(0,r.jsx)(lQ,{data:{labels:["TKM"],datasets:i}})})]})}var lK=a(28158);tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De,lK.Z);let lX={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Pagantes por dia de opera\xe7\xe3o"},annotation:{annotations:{line1:{type:"line",yMin:0,yMax:0,borderColor:"rgb(255, 99, 132)",borderWidth:2,label:{display:!0,content:"M\xe9dia",position:"end"}}}}}};function l0(e){let{data:t}=e,a=t.datasets.reduce((e,t,a)=>{let n=t.data,s=(null==n?void 0:n.length)>0?n.reduce((e,t)=>
1e+t,0)/n.length:0;return{...e,["line".concat(a)]:{type:"line",yMin:s,yMax:s,borderColor:t.backgroundColor,borderWidth:2,label:{display:!0,content:"M\xe9dia ".concat(t.label,": ").concat(s.toFixed(2)),position:"end"}}}},{}),n={...lX,plugins:{...lX.plugins,annotation:{annotations:a}}};return(0,r.jsx)(tb.$Q,{options:n,data:t})}function l1(e){var t,a;let{flashesBilheteria:n,currentEventId:s}=e,i=null===(t=n.find(e=>e.event.id===s))||void 0===t?void 0:null===(a=t.ticketPurchaseFlashes)||void 0===a?void 0:a.map(e=>"Op. ".concat(e.operationDay)),l=null==n?void 0:n.map(e=>{var t;return{label:"".concat(e.event.title),data:null===(t=e.ticketPurchaseFlashes)||void 0===t?void 0:t.map(e=>e.totalTickets),backgroundColor:e.chart.backgroundColor}});return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(l0,{data:{labels:i,datasets:l}})})}let l2=e=>{var t,a,n;let{items:s,isLoading:i,endDate:o,selectedEventIds:d,currentEventId:c,showChart:u}=e,[m,h]=(0,l.useState)(s),[v,x]=(0,l.useState)(i),[p,g]=(0,l.useState)(o),[j,f]=(0,l.useState)(c),[b,y]=(0,l.useState)(d);(0,l.useEffect)(()=>{f(c)},[c]),(0,l.useEffect)(()=>{y(d)},[d]),(0,l.useEffect)(()=>{g(o)},[o]),(0,l.useEffect)(()=>{h(s),x(i)},[s,i]);let N=null===(t=m.find(e=>e.event.id===j))||void 0===t?void 0:null===(a=t.ticketPurchaseFlashes)||void 0===a?void 0:a.map(e=>"".concat(e.day,"-").concat(lL[e.month])),k=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},w=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return v?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-flash-bilheteria",children:[(0,r.jsx)(lM,{}),(0,r.jsx)(lO,{})]}):(null==m?void 0:m.length)?(null==b?void 0:b.length)?(0,r.jsx)("div",{className:"dashboard-tickets-purchases-flash-bilheteria",children:(0,r.jsxs)("div",{className:"content-wrapper ".concat(u?"show-chart":"show-table"),children:[(0,r.jsxs)("div",{className:"table-content",children:[(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"".concat(800*b.length,"px")},children:(0,r.jsxs)("table",{children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"last-updated-header",children:(0,r.jsx)("div",{className:"last-updated-label",children:"Atualizado em"})}),null==m?void 0:m.map((e,t)=>{var a;let n=t-1,s=n>=0?m[n]:null;return(0,r.jsx)("th",{colSpan:s?4:3,children:(0,r.jsx)("div",{className:"last-updated-at-wrapper",children:(0,r.jsxs)("div",{className:"last-updated-label last-updated-at",children:[(0,r.jsx)("span",{children:e.lastUpdatedAt&&"".concat((0,ix.Z)(new Date(e.lastUpdatedAt),"dd/MM/yyyy HH:mm")," - ").concat(null==e?void 0:null===(a=e.lastUpdatedBy)||void 0===a?void 0:a.name)}),(0,r.jsx)("span",{children:e.event.startAt&&(0,lq.Z)(new Date(e.event.startAt))===(0,lq.Z)(new Date)?"Atualiza\xe7\xf5es as 11h, 15h e 20h":""})]})})},"header-".concat(e.event.id))})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"#"}),null==m?void 0:m.map((e,t)=>{let a=t-1,n=a>=0?m[a]:null;return(0,r.jsx)("th",{colSpan:n?4:3,children:"".concat(e.event.title," (").concat(e.totals.currentOperationDay,"/").concat(e.totals.totalOperationDays," dias)")},"header-".concat(e.event.id))})]}),(0,r.jsx)("tr",{children:null==m?void 0:m.map((e,t)=>{let a=t-1,n=a>=0?m[a]:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Or\xe7amento"},"header-budget-".concat(e.event.id)),(0,r.jsx)("th",{children:"Real"},"header-totals-".concat(e.event.id)),(0,r.jsx)("th",{children:"Varia\xe7\xe3o"},"header-totals-variation-".concat(e.event.id)),n&&(0,r.jsx)("th",{children:"Varia\xe7\xe3o com ".concat(null==n?void 0:n.event.title)},"header-variations-".concat(e.event.id))]})})})]}),(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:"Pagantes"}),null==m?void 0:m.map((e,t)=>{var a,n,s,i,l,o;let d=t>0?m[t-1]:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{children:(null===(a=e.totals)||void 0===a?void 0:null===(n=a.budget)||void 0===n?void 0:n.totalPaying)||"-"}
1,"row-budget-total-ticket-office-".concat(e.event.id)),(0,r.jsx)("td",{children:e.totals.totalTickets},"row-total-tickets-".concat(e.event.id)),(0,r.jsx)("td",{children:"".concat(e.totals.totalTickets-((null===(s=e.totals)||void 0===s?void 0:null===(i=s.budget)||void 0===i?void 0:i.totalPaying)||0)).concat(e.totals.totalTickets&&(null===(l=e.totals)||void 0===l?void 0:null===(o=l.budget)||void 0===o?void 0:o.totalPaying)?" (".concat(((e.totals.totalTickets-e.totals.budget.totalPaying)/e.totals.budget.totalPaying*100).toFixed(2),"%)"):"")},"row-total-tickets-variation-".concat(e.event.id)),d&&(0,r.jsx)("td",{children:d?"".concat(e.totals.totalTickets-d.totals.totalTickets).concat(e.totals.totalTickets&&d.totals.totalTickets?" (".concat(((e.totals.totalTickets-d.totals.totalTickets)/d.totals.totalTickets*100).toFixed(2),"%)"):""):"-"},"row-variation-".concat(e.event.id))]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:"M\xe9dia de Pagantes"}),null==m?void 0:m.map((e,t)=>{var a,n,s,i,l,o;let d=t>0?m[t-1]:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{children:(null===(a=e.totals)||void 0===a?void 0:null===(n=a.budget)||void 0===n?void 0:n.totalPayingMedian)||"-"},"row-budget-total-ticket-office-".concat(e.event.id)),(0,r.jsx)("td",{children:e.totals.totalTickets?(e.totals.totalTickets/e.totals.currentOperationDay).toFixed(2).replace(".",","):0},"row-total-tickets-".concat(e.event.id)),(0,r.jsx)("td",{children:"".concat(((e.totals.totalTickets?e.totals.totalTickets/e.totals.currentOperationDay:0)-((null===(s=e.totals)||void 0===s?void 0:null===(i=s.budget)||void 0===i?void 0:i.totalPayingMedian)||0)).toFixed(2).replace(".",",")).concat(e.totals.totalTickets&&(null===(l=e.totals)||void 0===l?void 0:null===(o=l.budget)||void 0===o?void 0:o.totalPayingMedian)?" (".concat(((e.totals.totalTickets/e.totals.currentOperationDay-e.totals.budget.totalPayingMedian)/e.totals.budget.totalPayingMedian*100).toFixed(2),"%)"):"")},"row-total-tickets-variation-".concat(e.event.id)),d&&(0,r.jsx)("td",{children:d?"".concat((e.totals.totalTickets/e.totals.currentOperationDay-d.totals.totalTickets/d.totals.currentOperationDay).toFixed(2).replace(".",",")).concat(e.totals.totalTickets&&d.totals.totalTickets?" (".concat(((e.totals.totalTickets/e.totals.currentOperationDay-d.totals.totalTickets/d.totals.currentOperationDay)/(d.totals.totalTickets/d.totals.currentOperationDay)*100).toFixed(2),"%)"):""):"-"},"row-variation-".concat(e.event.id))]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:"Bilheteria"}),null==m?void 0:m.map((e,t)=>{var a,n,s,i,l,o,d,c;let u=t>0?m[t-1]:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{children:(null===(a=e.totals)||void 0===a?void 0:null===(n=a.budget)||void 0===n?void 0:n.totalTicketOffice)?(0,eD.fe)(null===(s=e.totals)||void 0===s?void 0:null===(i=s.budget)||void 0===i?void 0:i.totalTicketOffice):"-"},"row-budget-total-ticket-office-".concat(e.event.id)),(0,r.jsx)("td",{children:(0,eD.fe)(e.totals.totalValue)},"row-total-value-".concat(e.event.id)),(0,r.jsx)("td",{children:"".concat((0,eD.fe)(e.totals.totalValue-((null===(l=e.totals)||void 0===l?void 0:null===(o=l.budget)||void 0===o?void 0:o.totalTicketOffice)||0))).concat(e.totals.totalValue&&(null===(d=e.totals)||void 0===d?void 0:null===(c=d.budget)||void 0===c?void 0:c.totalTicketOffice)?" (".concat(((e.totals.totalValue-e.totals.budget.totalTicketOffice)/e.totals.budget.totalTicketOffice*100).toFixed(2),"%)"):"")},"row-total-value-variation-".concat(e.event.id)),u&&(0,r.jsx)("td",{children:u?"".concat((0,eD.fe)(e.totals.totalValue-u.totals.totalValue)).concat(e.totals.totalValue&&u.totals.totalValue?" (".concat(((e.totals.totalValue-u.totals.totalValue)/u.totals.totalValue*100).toFixed(2),"%)"):""):"-"},"row-variation-".concat(e.event.id))]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:"TKM"}),null==m?void 0:m.map((e,t)=>{var a,n,s,i,l,o,d,c;let u=t>0?m[t-1]:null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{children:(null===(a=e.totals)||void 0===a?void 0:null===(n=a.budget)||void 0===n?void 0:n.tkm)?(0,eD.fe)(null===(s=e.totals)||void 0===s?void 0:null===(i=s.budget)||void 0===i?void 0:i.tkm):"-"}
1,"row-budget-total-ticket-office-".concat(e.event.id)),(0,r.jsx)("td",{children:(0,eD.fe)(e.totals.ticketMedianPrice)},"row-ticket-median-price-".concat(e.event.id)),(0,r.jsx)("td",{children:"".concat((0,eD.fe)(e.totals.ticketMedianPrice-((null===(l=e.totals)||void 0===l?void 0:null===(o=l.budget)||void 0===o?void 0:o.tkm)||0))).concat(e.totals.ticketMedianPrice&&(null===(d=e.totals)||void 0===d?void 0:null===(c=d.budget)||void 0===c?void 0:c.tkm)?" (".concat(((e.totals.ticketMedianPrice-e.totals.budget.tkm)/e.totals.budget.tkm*100).toFixed(2),"%)"):"")},"row-ticket-median-price-variation-".concat(e.event.id)),u&&(0,r.jsx)("td",{children:u?"".concat((0,eD.fe)(e.totals.ticketMedianPrice-u.totals.ticketMedianPrice)).concat(e.totals.ticketMedianPrice&&u.totals.ticketMedianPrice?" (".concat(((e.totals.ticketMedianPrice-u.totals.ticketMedianPrice)/u.totals.ticketMedianPrice*100).toFixed(2),"%)"):""):"-"},"row-variation-".concat(e.event.id))]})})]})]})]})}),(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-flash-bilheteria",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"last-updated-header",colSpan:2,children:(0,r.jsx)("div",{className:"last-updated-label",children:"Atualizado em"})}),null==m?void 0:m.map((e,t)=>{var a;let n=t-1,s=n>=0?m[n]:null;return(0,r.jsx)("th",{colSpan:s?4:3,children:(0,r.jsx)("div",{className:"last-updated-at-wrapper",children:(0,r.jsxs)("div",{className:"last-updated-label last-updated-at",children:[(0,r.jsx)("span",{children:e.lastUpdatedAt&&"".concat((0,ix.Z)(new Date(e.lastUpdatedAt),"dd/MM/yyyy HH:mm")," - ").concat(null==e?void 0:null===(a=e.lastUpdatedBy)||void 0===a?void 0:a.name)}),(0,r.jsx)("span",{children:e.event.startAt&&(0,lq.Z)(new Date(e.event.startAt))===(0,lq.Z)(new Date)?"Atualiza\xe7\xf5es as 11h, 15h e 20h":""})]})})},"header-".concat(e.event.id))})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"day-month",rowSpan:2,children:"Dia/M\xeas - ".concat(null===(n=m.find(e=>e.event.id===j))||void 0===n?void 0:n.event.title)}),(0,r.jsx)("th",{rowSpan:2,children:"Dia Op."}),null==m?void 0:m.map(e=>(0,r.jsx)("th",{colSpan:3,children:"".concat(e.event.title," (").concat(e.totals.currentOperationDay,"/").concat(e.totals.totalOperationDays," dias)")},"header-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==m?void 0:m.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Pagantes"},"subheader-pagantes-".concat(e.event.id)),(0,r.jsx)("th",{children:"Valor Total"},"subheader-valor-total-".concat(e.event.id)),(0,r.jsx)("th",{children:"TKM"},"subheader-tkm-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==N?void 0:N.map((e,t)=>{var a,n;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"day-month",children:e}),(0,r.jsx)("td",{children:null===(a=null===(n=m.find(e=>e.event.id===j))||void 0===n?void 0:n.ticketPurchaseFlashes[t])||void 0===a?void 0:a.operationDay}),null==m?void 0:m.map((a,n)=>{let s=a.ticketPurchaseFlashes[t];return s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,onClick:"group"!==s.type?()=>(0,ng.FJ)((0,r.jsx)(lU,{eventId:a.event.id,eventTitle:a.event.title,ticketPurchaseFlash:s})):()=>null,children:(null==s?void 0:s.totalTickets)?"".concat(null==s?void 0:s.totalTickets).concat((null==s?void 0:s.type)==="related"?" (Evt. Relacionado)":"").concat((null==s?void 0:s.type)==="group"?" (Venda em Grupo)":""):"".concat((null==s?void 0:s.type)==="related"?"Evt. Relacionado":(null==s?void 0:s.type)==="group"?"Venda em Grupo":"-")},"row-pagantes-".concat(a.event.id,"-").concat(e)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,onClick:"group"!==s.type?()=>(0,ng.FJ)((0,r.jsx)(lU,{eventId:a.event.id,eventTitle:a.event.title,ticketPurchaseFlash:s})):()=>null,children:(0,eD.fe)((null==s?void 0:s.totalValue)||0)},"row-valor-total-".concat(a.event.id,"-").concat(e)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,onClick:"group"!==s.type?()=>(0,ng.FJ)((0,r.jsx)(lU,{eventId:a.event.id,eventTitle:a.event.title,ticketPurchaseFlash:s})):()=>null,children:(null==s?void 0:s.ticketMedianPrice)?(0,eD.fe)(null==s?void 0:s.ticketMedianPrice):0},"row-tkm-".concat(a.event.id,"-").concat(e))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},e)})})]})})]}),(0,r.jsxs)("div",{className:"chart-content",children:[(0,r.jsx)(lY,{flashesBilheteria:m}),(0,r.jsx)(l1,{flashesBilheteria:m,currentEventId:j})]})]})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-flash-bilheteria",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-flash-bilheteria",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},l3=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},l6=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-share-on-off",children:(0,r.jsxs)("table",{className:"table-share-on-off table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De);let l5={responsive:!0,scales:{x:{stacked:!0},y:{stacked:!0,min:0,max:100,ticks:{callback:e=>"".concat(e,"%")}}},plugins:{legend:{position:"top"},title:{display:!1}}};function l8(e){let{data:t}=e;return(0,r.jsx)(tb.$Q,{options:l5,data:t})}function l7(e){var t,a,n,s,i,l,o;let{shareOnOffs:d,currentEventId:c}=e,u=d.find(e=>
1e.event.id===c),m=(null==u?void 0:null===(t=u.ticketPurchaseFlashes)||void 0===t?void 0:t.map(e=>"Op. ".concat(e.operationDay)))||[],h=(null==u?void 0:null===(a=u.ticketPurchaseFlashes)||void 0===a?void 0:a.map(e=>{let t=e.totalTicketsCardMachine+e.totalTicketsWebsite;return t>0?e.totalTicketsCardMachine/t*100:0}))||[],v=(null==u?void 0:null===(n=u.ticketPurchaseFlashes)||void 0===n?void 0:n.map(e=>{let t=e.totalTicketsCardMachine+e.totalTicketsWebsite;return t>0?e.totalTicketsWebsite/t*100:0}))||[],x={labels:m,datasets:[{label:"Online ".concat(null==u?void 0:u.event.title),data:v,backgroundColor:(null==u?void 0:null===(s=u.event)||void 0===s?void 0:null===(i=s.chart)||void 0===i?void 0:i.color1)||"#".concat(Math.floor(16777215*Math.random()).toString(16))},{label:"F\xedsico ".concat(null==u?void 0:u.event.title),data:h,backgroundColor:(null==u?void 0:null===(l=u.event)||void 0===l?void 0:null===(o=l.chart)||void 0===o?void 0:o.color2)||"#".concat(Math.floor(16777215*Math.random()).toString(16))}]};return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(l8,{data:x})})}let l4=e=>{var t,a,n;let{items:s,isLoading:i,endDate:o,selectedEventIds:d,currentEventId:c,showChart:u}=e,[m,h]=(0,l.useState)(o),[v,x]=(0,l.useState)(c),[p,g]=(0,l.useState)(d);(0,l.useEffect)(()=>{x(c)},[c]),(0,l.useEffect)(()=>{g(d)},[d]),(0,l.useEffect)(()=>{h(o)},[o]);let j=null===(t=null===(a=s.find(e=>e.event.id===v))||void 0===a?void 0:a.ticketPurchaseFlashes.filter(e=>"default"===e.type))||void 0===t?void 0:t.map(e=>"".concat(e.day,"-").concat(lL[e.month])),f=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},b=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return i?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-share-on-off",children:[(0,r.jsx)(l3,{}),(0,r.jsx)(l6,{})]}):(null==s?void 0:s.length)?(null==p?void 0:p.length)?(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-on-off",children:(0,r.jsxs)("div",{className:"content-wrapper ".concat(u?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-share-on-off",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"day-month",rowSpan:2,children:"Dia/M\xeas - ".concat(null===(n=s.find(e=>e.event.id===v))||void 0===n?void 0:n.event.title)}),(0,r.jsx)("th",{rowSpan:2,children:"Dia Op."}),null==s?void 0:s.map(e=>(0,r.jsx)("th",{colSpan:4,children:"".concat(e.event.title," (").concat(e.totals.currentOperationDay,"/").concat(e.totals.totalOperationDays," dias)")},"header-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==s?void 0:s.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Website"},"subheader-website-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-website-percent-".concat(e.event.id)),(0,r.jsx)("th",{children:"Bilheteria"},"subheader-card-machine-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-card-machine-percent-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==j?void 0:j.map((e,t)=>{var a,n;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"day-month",children:e}),(0,r.jsx)("td",{children:null===(a=null===(n=s.find(e=>e.event.id===v))||void 0===n?void 0:n.ticketPurchaseFlashes[t])||void 0===a?void 0:a.operationDay}),null==s?void 0:s.map((a,n)=>{let s=a.ticketPurchaseFlashes[t];return s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>f(n,e),onMouseLeave:b,children:null==s?void 0:s.totalTicketsWebsite},"row-website-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>f(n,e),onMouseLeave:b,children:(null==s?void 0:s.totalTicketsWebsite)&&(null==s?void 0:s.totalTicketsCardMachine)?"".concat(((null==s?void 0:s.totalTicketsWebsite)/((null==s?void 0:s.totalTicketsCardMachine)+(null==s?void 0:s.totalTicketsWebsite))*100).toFixed(2),"%"):"-"},"row-website-percent-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>f(n,e),onMouseLeave:b,children:null==s?void 0:s.totalTicketsCardMachine},"row-card-machine-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>f(n,e),onMouseLeave:b,children:(null==s?void 0:s.totalTicketsCardMachine)&&(null==s?void 0:s.totalTicketsWebsite)?"".concat(((null==s?void 0:s.totalTicketsCardMachine)/((null==s?void 0:s.totalTicketsCardMachine)+(null==s?void 0:s.totalTicketsWebsite))*100).toFixed(2),"%"):"-"},"row-card-machine-percent-".concat(a.event.id,"-").concat(e,"-").concat(t))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},e)})})]})})}),(0,r.jsx)("div",{className:"chart-content",children:(0,r.jsx)(l7,{shareO
1nOffs:s,currentEventId:v})})]})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-on-off",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-on-off",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},l9=e=>{var t;let{selectedEventIds:a,endDate:n}=e,{storedState:s}=(0,o.oR)(),i=(null==s?void 0:null===(t=s.currentSelectedEvent)||void 0===t?void 0:t._id)||null,r=new URLSearchParams({eventId:i,eventIds:a.join(","),endDate:n&&(0,ej.qb)(n)?(0,ix.Z)(n,"yyyy-MM-dd"):""}),{data:l,isLoading:d,refresh:c}=(0,eh.Z)("/ticket-purchase-flash/list?"+r);return{items:(null==l?void 0:l.map(e=>{var t,a;return{...e,chart:{backgroundColor:(null===(t=e.event)||void 0===t?void 0:null===(a=t.chart)||void 0===a?void 0:a.color1)||"#".concat(Math.floor(16777215*Math.random()).toString(16))}}}))||[],isLoading:d,refresh:c}},oe=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},ot=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-share-payment-method",children:(0,r.jsxs)("table",{className:"table-share-payment-method table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De,lK.Z);let oa={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Quantidade de M\xe9todo de Pagamento"},annotation:{annotations:{line1:{type:"line",yMin:0,yMax:0,borderColor:"rgb(255, 99, 132)",borderWidth:2,label:{display:!0,content:"M\xe9dia",position:"end"}}}}}};function on(e){let{data:t}=e,a=t.datasets.reduce((e,t,a)=>{let n=t.data,s=n.reduce((e,t)=>
1e+t,0)/n.length;return{...e,["line".concat(a)]:{type:"line",yMin:s,yMax:s,borderColor:t.backgroundColor,borderWidth:2,label:{display:!0,content:"M\xe9dia ".concat(t.label,": ").concat(s.toFixed(2)),position:"end"}}}},{}),n={...oa,plugins:{...oa.plugins,annotation:{annotations:a}}};return(0,r.jsx)(tb.$Q,{options:n,data:t})}function os(e){var t;let{items:a,currentEventId:n,paymentMethodsCurrentEvent:s}=e,{t:i}=(0,p.$)(),l=a.find(e=>e.event.id===n),o=null==l?void 0:null===(t=l.ticketPurchaseSharePaymentsMethods)||void 0===t?void 0:t.map(e=>"".concat(i("ticket_distribution.".concat(e.paymentMethod)))),d=[];for(let e of a){let t=[];for(let a of s){let n=null==e?void 0:e.ticketPurchaseSharePaymentsMethods.find(e=>e.paymentMethod===a);n?t.push(n.qty):t.push(0)}d.push({label:"".concat(e.event.title),data:t,backgroundColor:e.chart.backgroundColor})}return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(on,{data:{labels:o,datasets:d}})})}let oi=e=>{var t,a,n;let{items:s,isLoading:i,endDate:o,selectedEventIds:d,currentEventId:c,showChart:u}=e,{t:m}=(0,p.$)(),[h,v]=(0,l.useState)(o),[x,g]=(0,l.useState)(c),[j,f]=(0,l.useState)(d);(0,l.useEffect)(()=>{g(c)},[c]),(0,l.useEffect)(()=>{f(d)},[d]),(0,l.useEffect)(()=>{v(o)},[o]);let b=null===(t=s.find(e=>e.event.id===x))||void 0===t?void 0:null===(a=t.ticketPurchaseSharePaymentsMethods)||void 0===a?void 0:a.map(e=>"".concat(e.paymentMethod)),y=null===(n=s.find(e=>e.event.id===x))||void 0===n?void 0:n.event,N=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},k=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return i?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-share-payment-method",children:[(0,r.jsx)(oe,{}),(0,r.jsx)(ot,{})]}):(null==s?void 0:s.length)?(null==j?void 0:j.length)?(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-payment-method",children:(0,r.jsxs)("div",{className:"content-wrapper ".concat(u?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-share-payment-method",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"M\xe9todo de Pagamento - ".concat(null==y?void 0:y.title)},"subheader-payment-method-".concat(x)),null==s?void 0:s.map(e=>(0,r.jsx)("th",{colSpan:3,children:"".concat(e.event.title)},"header-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==s?void 0:s.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-qty-".concat(e.event.id)),(0,r.jsx)("th",{children:"Total"},"subheader-total-value-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-percentage-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==b?void 0:b.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"payment-method",children:"".concat(m("ticket_distribution.".concat(e)))}),null==s?void 0:s.map((a,n)=>{var s,i,l,o;let d=a.ticketPurchaseSharePaymentsMethods.find(t=>t.paymentMethod===e);return d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:null==d?void 0:d.qty},"row-qty-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:(0,eD.fe)(null==d?void 0:d.totalValue)},"row-total-value-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:(null===(s=a.totals)||void 0===s?void 0:null===(i=s.totalsPaymentMethod)||void 0===i?void 0:i.qty)&&(null==d?void 0:d.qty)?"".concat(((null==d?void 0:d.qty)/(null===(l=a.totals)||void 0===l?void 0:null===(o=l.totalsPaymentMethod)||void 0===o?void 0:o.qty)*100).toFixed(2),"%"):"-"},"row-percentage-".concat(a.event.id,"-").concat(e,"-").concat(t))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},"".concat(e,"-").concat(t)))})]})})}),(0,r.jsx)("div",{className:"chart-content",children:(0,r.jsx)(os,{items:s,currentEventId:x,paymentMethodsCurrentEvent:b||[]})})]})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-payment-method",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-share-payment-method",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},or=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},ol=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-breakdown-day-of-week",children:(0,r.jsxs)("table",{className:"table-breakdown-day-of-week table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De,lK.Z);let oo={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Visitas x Dia da Semana"},annotation:{annotations:{line1:{type:"line",yMin:0,yMax:0,borderColor:"rgb(255, 99, 132)",borderWidth:2,label:{display:!0,content:"M\xe9dia",position:"end"}}}}}};function od(e){let{data:t}=e,a=t.datasets.reduce((e,t,a)=>{let n=t.data,s=(null==n?void 0:n.length)>0?n.reduce((e,t)=>
1e+t,0)/n.length:0;return{...e,["line".concat(a)]:{type:"line",yMin:s,yMax:s,borderColor:t.backgroundColor,borderWidth:2,label:{display:!0,content:"M\xe9dia ".concat(t.label,": ").concat(s.toFixed(2)),position:"end"}}}},{}),n={...oo,plugins:{...oo.plugins,annotation:{annotations:a}}};return(0,r.jsx)(tb.$Q,{options:n,data:t})}let oc={0:"Domingo",1:"Segunda",2:"Ter\xe7a",3:"Quarta",4:"Quinta",5:"Sexta",6:"S\xe1bado"};function ou(e){var t;let{items:a,currentEventId:n,daysOfWeekCurrentEvent:s}=e,i=a.find(e=>e.event.id===n),l=null==i?void 0:null===(t=i.ticketPurchaseBreakdownDayOfWeeks)||void 0===t?void 0:t.map(e=>"".concat(oc[e.dayOfWeek])),o=[];for(let e of a){let t=[];for(let a of s){let n=null==e?void 0:e.ticketPurchaseBreakdownDayOfWeeks.find(e=>e.dayOfWeek===Number(a));n?t.push(n.qty):t.push(0)}o.push({label:"".concat(e.event.title),data:t,backgroundColor:e.chart.backgroundColor})}return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(od,{data:{labels:l,datasets:o}})})}tf.kL.register(tf.uw,tf.f$,tf.od,tf.jn,tf.Dx,tf.u,tf.De,lK.Z);let om={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Visitas x Hor\xe1rio"},annotation:{annotations:{line1:{type:"line",yMin:0,yMax:0,borderColor:"rgb(255, 99, 132)",borderWidth:2,label:{display:!0,content:"M\xe9dia",position:"end"}}}}},scales:{y:{beginAtZero:!0}}};function oh(e){var t;let{data:a}=e,n={...a,datasets:null===(t=a.datasets)||void 0===t?void 0:t.map(e=>({...e}))},s=a.datasets.reduce((e,t,a)=>{let n=t.data,s=n.reduce((e,t)=>e+t,0)/n.length;return{...e,["line".concat(a)]:{type:"line",yMin:s,yMax:s,borderColor:t.backgroundColor,borderWidth:2,label:{display:!0,content:"M\xe9dia ".concat(t.label,": ").concat(s.toFixed(2)),position:"end"}}}},{}),i={...om,plugins:{...om.plugins,annotation:{annotations:s}}};return(0,r.jsx)(tb.x1,{options:i,data:n})}function ov(e){var t;let{items:a,currentEventId:n,hoursOfDayCurrentEvent:s}=e,i=a.find(e=>e.event.id===n),l=null==i?void 0:null===(t=i.ticketPurchaseBreakdownHourOfDays)||void 0===t?void 0:t.map(e=>"".concat(e.hourOfDay,":00")),o=[];for(let e of a){let t=[];for(let a of s){let n=null==e?void 0:e.ticketPurchaseBreakdownHourOfDays.find(e=>e.hourOfDay===Number(a));n?t.push(n.qty):t.push(0)}o.push({label:"".concat(e.event.title),data:t,backgroundColor:e.chart.backgroundColor,borderColor:e.chart.backgroundColor,tension:0,fill:!1})}return(0,r.jsx)("div",{className:"breakdown-hour-of-day-chart-container",children:(0,r.jsx)(oh,{data:{labels:l,datasets:o}})})}let ox=e=>{var t,a,n,s,i;let{items:o,isLoading:d,endDate:c,selectedEventIds:u,currentEventId:m,showChart:h}=e,[v,x]=(0,l.useState)(c),[p,g]=(0,l.useState)(m),[j,f]=(0,l.useState)(u);(0,l.useEffect)(()=>{g(m)},[m]),(0,l.useEffect)(()=>{f(u)},[u]),(0,l.useEffect)(()=>{x(c)},[c]);let b=null===(t=o.find(e=>e.event.id===p))||void 0===t?void 0:null===(a=t.ticketPurchaseBreakdownDayOfWeeks)||void 0===a?void 0:a.map(e=>e.dayOfWeek),y=null===(n=o.find(e=>e.event.id===p))||void 0===n?void 0:null===(s=n.ticketPurchaseBreakdownHourOfDays)||void 0===s?void 0:s.map(e=>e.hourOfDay),N=null===(i=o.find(e=>e.event.id===p))||void 0===i?void 0:i.event,k=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},w=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return d?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-breakdown-day-of-week",children:[(0,r.jsx)(or,{}),(0,r.jsx)(ol,{})]}):(null==o?void 0:o.length)?(null==j?void 0:j.length)?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-breakdown-day-of-week",children:[(0,r.jsxs)("div",{className:"content-wrapper ".concat(h?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-breakdown-day-of-week",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"Dia da Semana - ".concat(null==N?void 0:N.title)},"subheader-day-of-week-".concat(p)),null==o?void 0:o.map(e=>(0,r.jsx)("th",{colSpan:3,children:"".concat(e.event.title)}
1,"header-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==o?void 0:o.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-qty-".concat(e.event.id)),(0,r.jsx)("th",{children:"Total"},"subheader-total-value-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-percentage-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==b?void 0:b.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"day-of-week",children:"".concat(oc[e])}),null==o?void 0:o.map((a,n)=>{var s,i,l,o;let d=a.ticketPurchaseBreakdownDayOfWeeks.find(t=>t.dayOfWeek===e);return d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:null==d?void 0:d.qty},"row-qty-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:(0,eD.fe)(null==d?void 0:d.totalValue)},"row-total-value-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:(null===(s=a.totals)||void 0===s?void 0:null===(i=s.totalsDayOfWeek)||void 0===i?void 0:i.qty)&&(null==d?void 0:d.qty)?"".concat(((null==d?void 0:d.qty)/(null===(l=a.totals)||void 0===l?void 0:null===(o=l.totalsDayOfWeek)||void 0===o?void 0:o.qty)*100).toFixed(2),"%"):"-"},"row-percentage-".concat(a.event.id,"-").concat(e,"-").concat(t))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},"".concat(e,"-").concat(t)))})]})})}),(0,r.jsx)("div",{className:"chart-content",children:(0,r.jsx)(ou,{items:o,currentEventId:p,daysOfWeekCurrentEvent:b||[]})})]}),(0,r.jsxs)("div",{className:"content-wrapper ".concat(h?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-breakdown-hour-of-day",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"Hora do Dia - ".concat(null==N?void 0:N.title)},"subheader-hour-of-day-".concat(p)),null==o?void 0:o.map(e=>(0,r.jsx)("th",{colSpan:3,children:"".concat(e.event.title)},"header-hour-of-day-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==o?void 0:o.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-hour-of-day-qty-".concat(e.event.id)),(0,r.jsx)("th",{children:"Total"},"subheader-hour-of-day-total-value-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-hour-of-day-percentage-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==y?void 0:y.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"hour-of-day",children:"".concat(e,"h")}),null==o?void 0:o.map((a,n)=>{var s,i,l,o;let d=a.ticketPurchaseBreakdownHourOfDays.find(t=>t.hourOfDay===e);return d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:null==d?void 0:d.qty},"row-hour-of-day-qty-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:(0,eD.fe)(null==d?void 0:d.totalValue)},"row-hour-of-day-total-value-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>k(n,e),onMouseLeave:w,children:(null===(s=a.totals)||void 0===s?void 0:null===(i=s.totalsHourOfDay)||void 0===i?void 0:i.qty)&&(null==d?void 0:d.qty)?"".concat(((null==d?void 0:d.qty)/(null===(l=a.totals)||void 0===l?void 0:null===(o=l.totalsHourOfDay)||void 0===o?void 0:o.qty)*100).toFixed(2),"%"):"-"},"row-hour-of-day-percentage-".concat(a.event.id,"-").concat(e,"-").concat(t))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},"".concat(e,"-").concat(t)))})]})})}),(0,r.jsx)("div",{className:"chart-content-hour-of-day",children:(0,r.jsx)(ov,{items:o,currentEventId:p,hoursOfDayCurrentEvent:y||[]})})]})]}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-day-of-week",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-day-of-week",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},op=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},og=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-breakdown-visitor-profile",children:(0,r.jsxs)("table",{className:"table-breakdown-visitor-profile table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})};tf.kL.register(tf.uw,tf.f$,tf.ZL,tf.Dx,tf.u,tf.De,lK.Z);let oj={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Visitas x Perfis de Usu\xe1rios"},annotation:{annotations:{line1:{type:"line",yMin:0,yMax:0,borderColor:"rgb(255, 99, 132)",borderWidth:2,label:{display:!0,content:"M\xe9dia",position:"end"}}}}}};function of(e){let{data:t}=e,a=t.datasets.reduce((e,t,a)=>{let n=t.data,s=(null==n?void 0:n.length)>0?n.reduce((e,t)=>
1e+t,0)/n.length:0;return{...e,["line".concat(a)]:{type:"line",yMin:s,yMax:s,borderColor:t.backgroundColor,borderWidth:2,label:{display:!0,content:"M\xe9dia ".concat(t.label,": ").concat(s.toFixed(2)),position:"end"}}}},{}),n={...oj,plugins:{...oj.plugins,annotation:{annotations:a}}};return(0,r.jsx)(tb.$Q,{options:n,data:t})}function ob(e){let{items:t,currentEventId:a,visitorProfilesCurrentEvent:n}=e,s=null==n?void 0:n.map(e=>"".concat("Unknown"===e?"Desconhecido":e)),i=[];for(let e of t){let t=[];for(let a of n){let n=null==e?void 0:e.ticketPurchaseBreakdownVisitorProfiles.find(e=>e.profile===a);n?t.push(n.qty):t.push(0)}i.push({label:"".concat(e.event.title),data:t,backgroundColor:e.chart.backgroundColor})}return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(of,{data:{labels:s,datasets:i}})})}let oy=e=>{var t,a,n;let{items:s,isLoading:i,endDate:o,selectedEventIds:d,currentEventId:c,showChart:u}=e,{t:m}=(0,p.$)(),[h,v]=(0,l.useState)(o),[x,g]=(0,l.useState)(c),[j,f]=(0,l.useState)(d);(0,l.useEffect)(()=>{g(c)},[c]),(0,l.useEffect)(()=>{f(d)},[d]),(0,l.useEffect)(()=>{v(o)},[o]);let b=null===(t=s.find(e=>e.event.id===x))||void 0===t?void 0:null===(a=t.ticketPurchaseBreakdownVisitorProfiles)||void 0===a?void 0:a.map(e=>"".concat(e.profile)),y=null===(n=s.find(e=>e.event.id===x))||void 0===n?void 0:n.event,N=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},k=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return i?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-breakdown-visitor-profile",children:[(0,r.jsx)(op,{}),(0,r.jsx)(og,{})]}):(null==s?void 0:s.length)?(null==j?void 0:j.length)?(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-visitor-profile",children:(0,r.jsxs)("div",{className:"content-wrapper ".concat(u?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-breakdown-visitor-profile",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"Perfil de Visitante - ".concat(null==y?void 0:y.title)},"subheader-visitor-profile-".concat(x)),null==s?void 0:s.map(e=>(0,r.jsx)("th",{colSpan:3,children:"".concat(e.event.title)},"header-".concat(e.event.id)))]}),(0,r.jsx)("tr",{children:null==s?void 0:s.map(e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-qty-".concat(e.event.id)),(0,r.jsx)("th",{children:"Total"},"subheader-total-value-".concat(e.event.id)),(0,r.jsx)("th",{children:"%"},"subheader-percentage-".concat(e.event.id))]}))})]}),(0,r.jsx)("tbody",{children:null==b?void 0:b.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"visitor-profile",children:"".concat("Unknown"===e?"Desconhecido":e)}),null==s?void 0:s.map((a,n)=>{var s,i,l,o;let d=a.ticketPurchaseBreakdownVisitorProfiles.find(t=>t.profile===e);return d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:null==d?void 0:d.qty},"row-qty-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:(0,eD.fe)(null==d?void 0:d.totalValue)},"row-total-value-".concat(a.event.id,"-").concat(e,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":n,onMouseEnter:e=>N(n,e),onMouseLeave:k,children:(null===(s=a.totals)||void 0===s?void 0:null===(i=s.totalsVisitorProfile)||void 0===i?void 0:i.qty)&&(null==d?void 0:d.qty)?"".concat(((null==d?void 0:d.qty)/(null===(l=a.totals)||void 0===l?void 0:null===(o=l.totalsVisitorProfile)||void 0===o?void 0:o.qty)*100).toFixed(2),"%"):"-"},"row-percentage-".concat(a.event.id,"-").concat(e,"-").concat(t))]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"no-data first",children:"-"}),(0,r.jsx)("td",{className:"no-data middle",children:"-"}),(0,r.jsx)("td",{className:"no-data last",children:"-"})]})})]},"".concat(e,"-").concat(t)))})]})})}),(0,r.jsx)("div",{className:"chart-content",children:(0,r.jsx)(ob,{items:s,currentEventId:x,visitorProfilesCurrentEvent:b||[]})})]})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-visitor-profile",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-visitor-profile",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},oN=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-total-tickets",style:{width:"100%",maxWidth:"800px"},children:(0,r.jsxs)("table",{className:"table-total-tickets table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"last-updated-header",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("th",{colSpan:2,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:4}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:24,width:100})})})]},t))})]})})},ok=()=>{var e;return(0,r.jsx)("div",{className:"table-wrapper table-breakdown-ticket-modality-and-type",children:(0,r.jsxs)("table",{className:"table-breakdown-ticket-modality-and-type table-skeleton",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,className:"day-month",children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{colSpan:3,children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})}),(0,r.jsx)("th",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:160})})})]})]}),(0,r.jsx)("tbody",{children:null===(e=Array.from({length:10}))||void 0===e?void 0:e.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:60})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{children:(0,r.jsx)(sl.Z,{height:20,width:100})})})]},t))})]})})};tf.kL.register(tf.qi,tf.u,tf.De);let ow={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Visitas X Modalidade de Ingresso"},tooltip:{callbacks:{label:function(e){let t=e.label||"",a=e.raw||0,n=e.chart.data.datasets[0].data.reduce((e,t)=>
1e+t,0);return"".concat(t,": ").concat(a," (").concat(Math.round(a/n*100),"%)")}}}}};function oZ(e){let{data:t}=e;return(0,r.jsx)(tb.by,{options:ow,data:t})}function oC(e){var t,a,n;let{items:s,currentEventId:i}=e,l=s.find(e=>e.event.id===i),o=null==l?void 0:null===(t=l.ticketPurchaseBreakdownTicketModalities)||void 0===t?void 0:t.map(e=>"".concat(e.modality)),d=(null==l?void 0:l.chart.backgroundColor)?Array.isArray(l.chart.backgroundColor)?l.chart.backgroundColor:[l.chart.backgroundColor,"#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#8AC926","#1982C4","#6A4C93","#FF595E"]:["#c1c1c1","#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#8AC926","#1982C4","#6A4C93","#FF595E"],c={labels:o,datasets:[{data:(null==l?void 0:l.ticketPurchaseBreakdownTicketModalities)&&null!==(n=null==l?void 0:null===(a=l.ticketPurchaseBreakdownTicketModalities)||void 0===a?void 0:a.map(e=>e.qty))&&void 0!==n?n:[],backgroundColor:d,borderWidth:1}]};return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(oZ,{data:c})})}tf.kL.register(tf.qi,tf.u,tf.De);let oS={responsive:!0,plugins:{legend:{position:"bottom"},title:{display:!0,text:"Visitas X Tipo de Ingresso"},tooltip:{callbacks:{label:function(e){let t=e.label||"",a=e.raw||0,n=e.chart.data.datasets[0].data.reduce((e,t)=>e+t,0);return"".concat(t,": ").concat(a," (").concat(Math.round(a/n*100),"%)")}}}}};function o_(e){let{data:t}=e;return(0,r.jsx)(tb.by,{options:oS,data:t})}function oD(e){var t,a,n;let{items:s,currentEventId:i}=e,l=s.find(e=>e.event.id===i),o=null==l?void 0:null===(t=l.ticketPurchaseBreakdownTicketTypes)||void 0===t?void 0:t.map(e=>"".concat(e.type)),d=(null==l?void 0:l.chart.backgroundColor)?Array.isArray(l.chart.backgroundColor)?l.chart.backgroundColor:[l.chart.backgroundColor,"#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#8AC926","#1982C4","#6A4C93","#FF595E"]:["#c1c1c1","#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#8AC926","#1982C4","#6A4C93","#FF595E"],c={labels:o,datasets:[{data:(null==l?void 0:l.ticketPurchaseBreakdownTicketTypes)&&null!==(n=null==l?void 0:null===(a=l.ticketPurchaseBreakdownTicketTypes)||void 0===a?void 0:a.map(e=>e.qty))&&void 0!==n?n:[],backgroundColor:d,borderWidth:1}]};return(0,r.jsx)("div",{className:"operations-chart-container",children:(0,r.jsx)(o_,{data:c})})}let oE=e=>{var t,a,n,s,i;let{items:o,isLoading:d,endDate:c,selectedEventIds:u,currentEventId:m,showChart:h}=e,[v,x]=(0,l.useState)(c),[p,g]=(0,l.useState)(m),[j,f]=(0,l.useState)(u);(0,l.useEffect)(()=>{g(m)},[m]),(0,l.useEffect)(()=>{f(u)},[u]),(0,l.useEffect)(()=>{x(c)},[c]);let b=null===(t=o.find(e=>e.event.id===p))||void 0===t?void 0:t.ticketPurchaseBreakdownTicketModalities,y=null===(a=o.find(e=>e.event.id===p))||void 0===a?void 0:a.ticketPurchaseBreakdownTicketTypes,N=null===(n=o.find(e=>e.event.id===p))||void 0===n?void 0:n.event,k=(e,t)=>{let a=t.target.closest("tr");a&&(a.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")}),a.querySelectorAll('td[data-event-index="'.concat(e,'"]')).forEach(e=>{e.classList.add("highlight")}))},w=e=>{let t=e.target.closest("tr");t&&t.querySelectorAll("td[data-event-index]").forEach(e=>{e.classList.remove("highlight")})};return d?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-breakdown-ticket-modality-and-type",children:[(0,r.jsx)(oN,{}),(0,r.jsx)(ok,{})]}):(null==o?void 0:o.length)?(null==j?void 0:j.length)?(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-breakdown-ticket-modality-and-type",children:[(0,r.jsxs)("div",{className:"content-wrapper ".concat(h?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-breakdown-ticket-modality-and-type",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"Modalidade de Ingresso - ".concat(null==N?void 0:N.title)},"subheader-ticket-modality-".concat(p)),(0,r.jsx)("th",{colSpan:3,children:"".concat(null==N?void 0:N.title)},"header-".concat(p))]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-qty-".concat(p)),(0,r.jsx)("th",{children:"Total"},"subheader-total-value-".concat(p)),(0,r.jsx)("th",{children:"%"},"subheader-percentage-".concat(p))]})]}),(0,r.jsx)("tbody",{children:null==b?void 0:b.map((e,t)=>{var a,n,i,l,d,c,u;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"ticket-modality",children:"".concat(e.modality)}),(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:null==e?void 0:e.qty},"row-qty-".concat(p,"-").concat(e.modality,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:(0,eD.fe)(null==e?void 0:e.totalValue)},"row-total-value-".concat(p,"-").concat(e.modality,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:(null===(a=o.find(e=>
1e.event.id===p))||void 0===a?void 0:null===(n=a.totals)||void 0===n?void 0:null===(i=n.totalsTicketModality)||void 0===i?void 0:i.qty)&&(null==e?void 0:e.qty)?"".concat(((null==e?void 0:e.qty)/(null!==(s=null==o?void 0:null===(l=o.find)||void 0===l?void 0:null===(d=l.call(o,e=>e.event.id===p))||void 0===d?void 0:null===(c=d.totals)||void 0===c?void 0:null===(u=c.totalsTicketModality)||void 0===u?void 0:u.qty)&&void 0!==s?s:0)*100).toFixed(2),"%"):"-"},"row-percentage-".concat(p,"-").concat(e.modality,"-").concat(t))]},"".concat(e,"-").concat(t))})})]})})}),(0,r.jsx)("div",{className:"chart-content",children:(0,r.jsx)(oC,{items:o,currentEventId:p})})]}),(0,r.jsxs)("div",{className:"content-wrapper ".concat(h?"show-chart":"show-table"),children:[(0,r.jsx)("div",{className:"table-content",children:(0,r.jsx)("div",{className:"table-wrapper",children:(0,r.jsxs)("table",{className:"table-breakdown-ticket-type",children:[(0,r.jsxs)("thead",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{rowSpan:2,children:"Tipo de Ingresso - ".concat(null==N?void 0:N.title)},"subheader-ticket-type-".concat(p)),(0,r.jsx)("th",{colSpan:3,children:"".concat(null==N?void 0:N.title)},"header-ticket-type-".concat(p))]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Quantidade"},"subheader-ticket-type-qty-".concat(p)),(0,r.jsx)("th",{children:"Total"},"subheader-ticket-type-total-value-".concat(p)),(0,r.jsx)("th",{children:"%"},"subheader-ticket-type-percentage-".concat(p))]})]}),(0,r.jsx)("tbody",{children:null==y?void 0:y.map((e,t)=>{var a,n,s,l,d,c,u;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"ticket-type",children:"".concat(e.type)}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:null==e?void 0:e.qty},"row-ticket-type-qty-".concat(p,"-").concat(e.type,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:(0,eD.fe)(null==e?void 0:e.totalValue)},"row-ticket-type-total-value-".concat(p,"-").concat(e.type,"-").concat(t)),(0,r.jsx)("td",{"data-event-index":t,onMouseEnter:e=>k(t,e),onMouseLeave:w,children:(null===(a=o.find(e=>e.event.id===p))||void 0===a?void 0:null===(n=a.totals)||void 0===n?void 0:null===(s=n.totalsTicketType)||void 0===s?void 0:s.qty)&&(null==e?void 0:e.qty)?"".concat(((null==e?void 0:e.qty)/(null!==(i=null==o?void 0:null===(l=o.find)||void 0===l?void 0:null===(d=l.call(o,e=>e.event.id===p))||void 0===d?void 0:null===(c=d.totals)||void 0===c?void 0:null===(u=c.totalsTicketType)||void 0===u?void 0:u.qty)&&void 0!==i?i:0)*100).toFixed(2),"%"):"-"},"row-ticket-type-percentage-".concat(p,"-").concat(e.type,"-").concat(t))]})]},"".concat(e.type,"-").concat(t))})})]})})}),(0,r.jsx)("div",{className:"chart-content-ticket-type",children:(0,r.jsx)(oD,{items:o,currentEventId:p})})]})]}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-ticket-modality-and-type",children:(0,r.jsx)("div",{className:"no-results",children:"Selecione ao menos um evento"})}):(0,r.jsx)("div",{className:"dashboard-tickets-purchases-breakdown-ticket-modality-and-type",children:(0,r.jsx)("div",{className:"no-results",children:"Nenhum resultado encontrado"})})},oP=()=>{var e,t,a;let{storedState:n}=(0,o.oR)(),{user:s}=(0,d.aC)(),i=(null==n?void 0:null===(e=n.currentSelectedEvent)||void 0===e?void 0:e._id)||null,[c,u]=(0,l.useState)(i),m=(null==n?void 0:null===(t=n.currentSelectedEvent)||void 0===t?void 0:t.endAt)||null,h=(null==n?void 0:null===(a=n.currentSelectedEvent)||void 0===a?void 0:a.startAt)||null,[x,p]=(0,l.useState)(null),[g,j]=(0,l.useState)([c]),{items:f,isLoading:b}=l9({selectedEventIds:g,endDate:x}),[y,N]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{p(null),u(i),j([c])},[m,i,c]),(0,r.jsxs)("div",{className:"dashboard-tickets-purchases",children:[(0,r.jsx)("h2",{children:"Dashboard de Bilheteria"}),(0,r.jsx)(lE,{selectedEventIds:g,onSelectedEventIds:j,endDate:x,onEndDateChange:p,currentEventEndAt:(0,rX.Z)(m),currentEventStartAt:(0,rX.Z)(h),currentEventId:c}),(0,r.jsxs)("div",{className:"dashboard-tickets-purchases-button-container",children:[(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"view-toggle",children:[(0,r.jsx)(v.Z,{className:"toggle-button ".concat(y?"":"active"),onClick:()=>N(!1),children:"Tabela"}),(0,r.jsx)(v.Z,{className:"toggle-button ".concat(y?"active":""),onClick:()=>N(!0),children:"Gr\xe1fico"})]})}),(0,r.jsx)(lR,{})]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"Flash Bilheteria",content:(0,r.jsx)("div",{className:"flash-bilheteria-content",children:(0,r.jsx)(l2,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})},{id:1,label:"Share On Off",content:(0,r.jsx)("div",{className:"share-on-off-content",children:(0,r.jsx)(l4,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})},{id:2,label:"Share Pagamento",content:(0,r.jsx)("div",{className:"share-payment-method-content",children:(0,r.jsx)(oi,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})},{id:3,label:"Dia da Semana X Hor\xe1rio",content:(0,r.jsx)("div",{className:"breakdown-dia-da-semana-content",children:(0,r.jsx)(ox,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})},{id:4,label:"Perfis de Usu\xe1rios",content:(0,r.jsx)("div",{className:"breakdown-visitor-profile-content",children:(0,r.jsx)(oy,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})},{id:5,label:"Modalidade X Tipo de Ingresso",content:(0,r.jsx)("div",{className:"breakdown-ticket-type-content",children:(0,r.jsx)(oE,{items:f,isLoading:b,selectedEventIds:g,currentEventId:c,endDate:x,showChart:y})})}]})]})},oI=["Janeiro","Fevereiro","Mar\xe7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],oA=e=>{let{onConfirm:t,defaultStartDate:a,defaultEndDate:n,minDate:s,maxDate:i,appliedStartDate:o,appliedEndDate:d}=e,{t:c}=(0,p.$)("admin"),[u,m]=l.useState(),[h,x]=l.useState(o||a||new Date),[g,j]=l.useState(d||n||new Date),f=l.useRef(!1);l.useEffect(()=>{o?(x(o),f.current=!0):!f.current&&a&&x(a)},[o,a]),l.useEffect(()=>{d?(j(d),f.current=!0):!f.current&&n&&j(n)},[d,n]);let b=(e,t)=>{t&&m(t),"today"===t&&(x(new Date),j(new Date))},y=l.useCallback(()=>{let e=(0,tD.Z)(h),a=(0,tP.Z)(g);"today"===u?(e=(0,tD.Z)(new Date),a=(0,tP.Z)(new Date)):"day"===u?a=e:"week"===u?(e=(0,tI.Z)(e),a=(0,tA.Z)(e)):"month"===u?(e=(0,sa.Z)(e),a=(0,sn.Z)(e)):"year"===u&&(e=(0,tT.Z)(e),a=(0,tR.Z)(e)),f.current=!0,t({dateRange:u,startDate:e,endDate:a,isSameDay:(0,tC.Z)(h,g),todayDate:new Date})},[u,h,g,t]);return l.useMemo(()=>"day"===u||"today"===u?"".concat(h.getDate()," de ").concat((0,ej.p6)(h,"MMMM yyyy")):"week"===u?"De ".concat((0,tI.Z)(h).getDate()," \xe0 ").concat((0,tA.Z)(h).getDate()," de ").concat((0,ej.p6)(h,"MMMM yyyy")):"month"===u?"".concat(oI[h.getMonth()]):"year"===u?"Ano ".concat((0,ej.p6)(h,"yyyy")):"future"===u?"A Receber":void 0,[u,h]),(0,r.jsxs)("div",{className:"date-range-select",children:[(0,r.jsxs)(ty.Z,{color:"primary",size:"small",value:u,exclusive:!0,onChange:b,className:"range-selector",children:[(0,r.jsx)(tN.Z,{value:"custom",children:"Anteriores"}),(0,r.jsx)(tN.Z,{value:"future",children:"A Receber"})]}),"custom"===u?(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsx)(tM.Z,{label:c("start"),className:"input",value:h||null,onChange:e=>x(e),disableFuture:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(tM.Z,{label:c("end"),className:"input",value:g||null,onChange:e=>j(e),disableFuture:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:y,children:"filtrar"})]}):"future"===u?(0,r.jsxs)("div",{className:"date-range",children:[(0,r.jsx)(tM.Z,{label:c("start"),className:"input",value:h||null,onChange:e=>x(e),disablePast:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(tM.Z,{label:c("end"),className:"input",value:g||null,onChange:e=>j(e),disablePast:!0,renderInput:e=>(0,r.jsx)(es.Z,{...e,size:"small"})}),(0,r.jsx)(v.Z,{variant:"contained",onClick:y,children:"filtrar"})]}):null]})},oT=e=>{var t,a,n,s,i,l,o;let{eventId:d,data:c,balance:u,isLoading:m}=e;if(m)return(0,r.jsxs)("div",{className:"gateway-payment-pagarme-statistics",children:[(0,r.jsx)("div",{className:"placeholder placeholder-section-title",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"60px"})}),(0,r.jsx)("div",{className:"placeholder placeholder-recipient-name",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"20px"})}),(0,r.jsx)("div",{className:"totals",children:[1,2,3,4].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))}),(0,r.jsx)("div",{className:"totals",children:[6,7,8,9].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))})]});if(!c||c.eventId!==d)return null;let h=null!==(a=c.totalValueOfEntries)&&void 0!==a?a:0,v=null!==(n=c.totalValueOfDepartures)&&void 0!==n?n:0,x=null!==(s=c.totalValueOfFees)&&void 0!==s?s:0,p=null!==(i=c.totalValueOfEntriesCasacor)&&void 0!==i?i:0,g=null!==(l=c.totalValueOfDeparturesCasacor)&&void 0!==l?l:0,j=null!==(o=c.totalValueOfFeesCasacor)&&void 0!==o?o:0;return(0,r.jsxs)("div",{className:"gateway-payment-pagarme-statistics",children:[(0,r.jsx)("div",{className:"section-title",children:"RECEBEDOR ".concat((null==u?void 0:null===(t=u.recipient)||void 0===t?void 0:t.name)||"")}),c&&(0!==h||0!==v||0!==x)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"totals",children:[(0,r.jsxs)("div",{className:"card total-value total-success",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE ENTRADAS"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(h)]})]}),(0,r.jsxs)("div",{className:"card total-value total-danger",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE SAIDAS"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(v)]})]}),(0,r.jsxs)("div",{className:"card total-value total-danger",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TAXAS PAGARME"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total: "}),(0,sL.n)(x)]})]}),(0,r.jsxs)("div",{className:"card total-value total-info",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE L\xcdQUIDO"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(h-v-x)]})]})]}),(0,r.jsx)("h4",{children:"Recebedor Casacor"}),(0,r.jsxs)("div",{className:"totals",children:[(0,r.jsxs)("div",{className:"card total-value total-success",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE ENTRADAS"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(p)]})]}),(0,r.jsxs)("div",{className:"card total-value total-danger",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE SAIDAS"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(g)]})]}),(0,r.jsxs)("div",{className:"card total-value total-danger",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TAXAS PAGARME"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total: "}),(0,sL.n)(j)]})]}),(0,r.jsxs)("div",{className:"card total-value total-info",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"TOTAL DE L\xcdQUIDO"})}),(0,r.jsxs)("div",{className:"value",children:[(0,r.jsx)("span",{children:"Valor total"}),(0,sL.n)(p-g-j)]})]})]})]}):(0,r.jsx)("div",{className:"no-data",children:(0,r.jsx)("h3",{children:"N\xe3o h\xe1 dados para exibir"})})]})},oR=e=>{var t,a;let{t:n}=(0,p.$)("admin"),{eventId:s,onBalance:i}=e,l=new URLSearchParams({eventId:s}),{data:o,isLoading:d}=(0,eh.Z)("/gateway-payment-pagarme/balance?"+l),{balance:c}=o||{};return o?("function"==typeof i&&i(c),d)?(0,r.jsxs)("div",{className:"gateway-payment-pagarme-balance",children:[(0,r.jsx)("div",{className:"placeholder placeholder-section-title",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"60px"})}),(0,r.jsx)("div",{className:"totals",children:[1,2].map(e=>(0,r.jsx)("div",{className:"placeholder",children:(0,r.jsx)(sl.Z,{variant:"rectangular",height:"100%"})},e))})]}):(null==c?void 0:c.recipient)?(0,r.jsxs)("div",{className:"gateway-payment-pagarme-balance",children:[(0,r.jsx)("div",{className:"section-title",children:"Conta ".concat(null==c?void 0:null===(t=c.recipient)||void 0===t?void 0:t.name," - ").concat(null==c?void 0:null===(a=c.recipient)||void 0===a?void 0:a.description)}),(0,r.jsxs)("div",{className:"totals",children:[(0,r.jsxs)("div",{className:"card total-value total-success",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"SALDO ATUAL"})}),(0,r.jsx)("div",{className:"balance-value",children:(0,sL.n)(null==c?void 0:c.available_amount)})]}),(0,r.jsxs)("div",{className:"card total-value total-info",children:[(0,r.jsx)("div",{className:"title",children:(0,r.jsx)("b",{children:"A RECEBER"})}),(0,r.jsx)("div",{className:"balance-value",children:(0,sL.n)(null==c?void 0:c.waiting_funds_amount)})]})]})]}):(0,r.jsx)("div",{className:"gateway-payment-pagarme-balance",children:(0,r.jsx)("div",{className:"section-title",children:"Inform\xe7\xf5es de Saldo indispon\xedvel no momento"})}):null},oL="gateway-payment-pagarme",oq=()=>{let{storedState:e}=(0,o.oR)(),{currentSelectedEvent:t}=e||{},[a,n]=l.useState(),[s,i]=(0,l.useState)({}),[d,c]=(0,l.useState)(null),[u,m]=(0,l.useState)(!1),h=null==t?void 0:t._id,{id:v,status:x,setTaskId:p,dataResult:g,description:j,title:f,progress:b,starting:y}=n5({screen:oL}),N=(0,l.useCallback)(async()=>
1{if(!h){c(null);return}m(!0);try{let{data:e}=await J.ZP.get("/task/gateway-payment-pagarme-by-event-id?eventId=".concat(h));c(e)}catch(e){console.log("\uD83D\uDE80 ~ loadInitialData ~ error:",e),et.Am.error(e.message),c(null)}finally{m(!1)}},[h]);(0,l.useEffect)(()=>{N()},[N]);let k=d&&d.dataResult?d.dataResult:g,w=l.useCallback(e=>{n(e);let{startDate:t,endDate:a}=e;(async()=>{try{var n;let s=t&&a?" de ".concat((0,ej.p6)(t,"P")," \xe0 ").concat((0,ej.p6)(a,"P")):t&&!a?" a partir de ".concat((0,ej.p6)(t,"P")):!t&&a?" at\xe9 ".concat((0,ej.p6)(a,"P")):"",{data:i}=await J.ZP.post("/task",{title:"Dashboard de Pagamentos com Pagar Me - ".concat(s),screen:oL,description:"Preparando para gerar relat\xf3rio"}),r=localStorage.getItem(o.rR),l=r?JSON.parse(r):[];console.log("\uD83D\uDE80 ~ start ~ storedTaskData:",l);let d=[...l.filter(e=>e.screen!==i.screen),i];console.log("\uD83D\uDE80 ~ start ~ taskDatas:",d),localStorage.setItem(o.rR,JSON.stringify(d));let c=new URLSearchParams({eventId:h,startDate:e.startDate.toString(),endDate:null==e?void 0:null===(n=e.endDate)||void 0===n?void 0:n.toString(),taskId:i.id});p(i.id),await J.ZP.get("/gateway-payment-pagarme/statistics?"+c)}catch(e){console.log("\uD83D\uDE80 ~ useEffect ~ error:",e),et.Am.error(e.message)}})()},[h]);return(0,r.jsxs)("div",{className:"gateway-payment-pagarme",children:[(0,r.jsx)("h1",{children:"Dashboard de Pagamentos com Pagar Me"}),(0,r.jsx)(oR,{eventId:h,onBalance:i}),(0,r.jsx)("h2",{children:"Filtro por per\xedodo"}),(0,r.jsx)(oA,{onConfirm:w,defaultStartDate:(null==t?void 0:t.startAt)?new Date(t.startAt):void 0,defaultEndDate:(null==t?void 0:t.endAt)?new Date(t.endAt):void 0,appliedStartDate:null==a?void 0:a.startDate,appliedEndDate:null==a?void 0:a.endDate}),((null==k?void 0:k.eventId)===h||!(null==k?void 0:k.eventId))&&(j||(null==d?void 0:d.description))&&(0,r.jsx)("h4",{children:"".concat(f||(null==d?void 0:d.title)||""," - ").concat(j||(null==d?void 0:d.description)||"")}),("in_progress"===x||u&&(null==d?void 0:d.progress))&&(0,r.jsx)(lZ,{label:"".concat(b||(null==d?void 0:d.progress)||0,"%"),value:b||(null==d?void 0:d.progress)||0}),(0,r.jsx)(oT,{eventId:h,startDate:null==a?void 0:a.startDate,endDate:null==a?void 0:a.endDate,data:k,balance:s,isLoading:u||y||"in_progress"===x})]})},oM=()=>{var e;let{storedState:t}=(0,o.oR)(),a=null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id,[n,s]=l.useState(null),[i,r]=l.useState(""),d=(0,ev.Nr)(i,300),[c,u]=l.useState(""),m=l.useRef(),{data:h,isLoading:v,refresh:x}=(0,eh.Z)("/ticket/list?admin=true&event_id=".concat(a,"&limit=100&search=").concat(d,"&year=").concat(c));function p(){s(null)}async function g(e){e.preventDefault();let t=e.target.closest(".draggable");t.style.transform="initial";let a=null==t?void 0:t.dataset.index;if(m.current&&m.current!==a){let e=[...null==h?void 0:h.tickets],[t]=e.splice(m.current,1);e.splice(a,0,t);let n=e.map(e=>e.id);try{let e=await J.ZP.put("/ticket/update-order",n);if(e.data.error)throw Error(e.data.error.message);et.Am.success("Ingressos reordenados com sucesso!")}catch(e){et.Am.error(e.message)}x()}}async function j(e){let t=h.tickets.find(t=>t.id===e);s({...t,title:(null==t?void 0:t.title)+"_COPY",id:""})}return{ticketsData:h,refresh:x,isLoading:v,filters:{search:i,year:c},onChangeFilters:function(e){"search"in e?r(e.search):"year"in e&&u(e.year)},selectedTicket:n,openTicketForm:function(e){s(e)},closeTicketForm:p,onTicketRemove:()=>{x(),p()},onDragStart:function(e){let t=e.target.closest(".draggable");m.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2},onDragEnd:function(e){e.target.style.opacity=1},onDragOver:function(e){e.preventDefault();let t=e.target.closest(".draggable");m.current!==(null==t?void 0:t.dataset.index)?t.style.transform="scale(0.9)":t.style.transform="initial"},onDragLeave:function(e){let t=e.target.closest(".draggable");t.style.transform="initial"},onDrop:g,duplicateTicket:j}},oO=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),n=null==a?void 0:a.currentSelectedEvent,{ticketsData:s,filters:i,onChangeFilters:l,openTicketForm:d,selectedTicket:u,closeTicketForm:m,refresh:h,isLoading:x,onTicketRemove:g,onDragStart:j,onDragEnd:f,onDragOver:b,onDragLeave:y,onDrop:N,duplicateTicket:k}=oM(),{verifyIsExpiredTicket:w}=(0,ic.Z)(),{tickets:Z=[],distinctYears:C=[],numberOfTickets:S}=s||{};return(0,r.jsxs)("div",{className:"tickets-container",children:[(0,r.jsx)("h3",{children:"Ingressos"}),(0,r.jsxs)("div",{className:"row filters",children:[(0,r.jsx)(es.Z,{className:"search",placeholder:e("search.tickets"),value:i.search,onChange:e=>l({search:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})})}}),(0,r.jsx)(am.Z,{options:C,value:i.year,label:"Ano",onChange:e=>l({year:e})}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>d({}),disabled:!(null==n?void 0:n.status)||(null==n?void 0:n.status)==="ended",children:"".concat(e("ticket.create"))}),(0,r.jsx)(K.ZP,{showAt:!!u,onClose:m,children:(0,r.jsx)(id.Z,{data:u,onClose:m,onCh
1ange:h,onRemove:g})})]}),(null==n?void 0:n.status)&&x?(0,r.jsx)("div",{className:"data-info",children:(0,r.jsx)(ee.aN,{inline:!0})}):(null==Z?void 0:Z.length)?(0,r.jsxs)("div",{className:"data-info",children:["Ingressos encontrados: ",S]}):(0,r.jsx)("div",{className:"data-info",children:"Nenhum ingresso cadastrado para este evento!"}),(0,r.jsx)("div",{className:"tickets flex1",children:(null==n?void 0:n.status)&&!x&&(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:95,rowCount:(null==Z?void 0:Z.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,{id:s,coverImageUrl:i,title:l,slug:o,visible:u,type:m,sellChannels:h,sellEndDate:v,hours:x}=Z[t],p=id._.find(e=>e.id===m),g=w(v,x),C=null==h?void 0:h.map(e=>"web"===e?"Website":"card-machine"===e?"Maquininha":"").join(", ");return(0,r.jsx)("div",{style:n,className:"list-item-card draggable",onClick:()=>d(Z[t]),draggable:!0,"data-index":t,"data-id":s,onDragStart:j,onDragEnd:f,onDragOver:b,onDragLeave:y,onDrop:N,children:(0,r.jsxs)("div",{className:"card-content "+(u?"active":"inactive"),children:[(0,r.jsxs)("div",{className:"cover",children:[(0,r.jsx)(eP.Z,{src:i,layout:"fill"}),!u&&(0,r.jsx)(aJ.Z,{className:"hidden-icon"})]}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",t+1]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("div",{className:"icon",children:null==p?void 0:p.icon}),(0,r.jsxs)("div",{className:"title",children:[" ",l," "]}),g&&(0,r.jsx)("span",{className:"expired-label",children:" Expirado!"})]}),(0,r.jsxs)("div",{children:["Canais de venda: ",C]})]}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(X.Z,{onClick:e=>{e.stopPropagation(),k(s)},children:(0,r.jsx)(c.TI,{})})}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})})]})},oF=()=>{var e;let{storedState:t}=(0,o.oR)(),a=null==t?void 0:null===(e=t.currentSelectedEvent)||void 0===e?void 0:e._id,[n,s]=l.useState(null),[i,r]=l.useState(""),d=(0,ev.Nr)(i,300),{data:c,isLoading:u,refresh:m}=(0,eh.Z)("/ticket-promotions/list-admin?admin=true&event_id=".concat(a,"&limit=100&search=").concat(d));function h(){s(null)}return{ticketsData:c,refresh:m,isLoading:u,filters:{search:i},onChangeFilters:function(e){"search"in e&&r(e.search)},onTicketPromotionRemove:()=>{m(),h()},selectedTicketPromotion:n,openTicketPromotionForm:function(e){s(e)},closeTicketPromotionForm:h}};var oB=a(78966),oU=a(55855);let oz={"ticket-free-to-email":{label:"Promo\xe7\xe3o de enviar mais um ingresso gr\xe1tis para email",description:"<p>Na compra de um ingresso a pessoa receber\xe1 no email escolhido mais um ingresso gr\xe1tis.</p>"},"giftcard-to-email":{label:"Promo\xe7\xe3o de enviar Gift Card no mesmo valor da compra para email",description:"<p>Na compra de um ingresso a pessoa receber\xe1 no email escolhido um cart\xe3o presente no mesmo valor da compra.</p>"}},oV=(e,t,a)=>{let{storedState:n}=(0,o.oR)(),s=null==n?void 0:n.currentSelectedEvent,i=null==s?void 0:s._id,[r,d]=l.useState({eventId:i,status:"active",type:"ticket-free-to-email",description:(null==e?void 0:e.description)||oz["ticket-free-to-email"].description,startDate:s.startAt,endDate:s.endAt,...e}),[c,u]=l.useState({}),{toggleLoader:m}=(0,ee.U2)(),[h,v]=l.useState(!1),[x,p]=l.useState(!1),[g,j]=l.useState([]),[f,b]=l.useState(null),y=l.useMemo(()=>["ticket-free-to-email","giftcard-to-email"],[]),N=l.useCallback(e=>{d(t=>(v(!0),{...t,...e}))},[r]);l.useEffect(()=>{async function e(){await (0,J.a8)({url:"/ticket/list?"+new URLSearchParams({event_id:i||"",visible:"true",limit:"100",admin:"true"}),onProcessing:p,onSuccess:e=>{j(null==e?void 0:e.tickets),r.ticketId&&b((null==e?void 0:e.tickets.find(e=>e.id===r.ticketId))||null)},onError:e=>{et.Am.error(e.message)}})}i&&e()},[i]);let k=l.useCallback(async()=>{try{let e;let a={...r,userTimezoneOffset:(0,ej.Y5)()},n={};u(n),a.name||(n.name=!0),a.description||(n.description=!0),a.startDate||(n.startDate=!0),a.endDate||(n.endDate=!0),a.promotionChannels.length||(n.promotionChannels=!0);let i=(null==a?void 0:a.endDate)?new Date(a.endDate):void 0,l=(null==a?void 0:a.startDate)?new Date(a.startDate):void 0,o=new Date(s.endAt),c=i?new Date((0,lq.Z)(i),(0,oB.Z)(i),(0,oU.Z)(i),12,0,0):void 0,h=l?new Date((0,lq.Z)(l),(0,oB.Z)(l),(0,oU.Z)(l),12,0,0):void 0,x=new Date((0,lq.Z)(o),(0,oB.Z)(o),(0,oU.Z)(o),12,0,0);if(c&&(0,i_.Z)(c,x)&&(et.Am.error("Data fim das promo\xe7\xf5es n\xe3o deve ser maior que o a Data do fim do evento!"),n.endDate=!0),Object.keys(n).length)return console.log("\uD83D\uDE80 ~ saveTicketPromotion ~ errors:",n),u(n),et.Am.error("Formul\xe1rio incompleto!");if(h&&c&&(a.startDate=h,a.endDate=c),m(!0,"Salvando promo\xe7\xe3o"),f&&(a.ticketId=f.id),console.log("\uD83D\uDE80 ~ saveTicketPromotion ~ _ticketPromotion:",a),(e=r.id?await J.ZP.put("/ticket-promotions/".concat(r.id),(0,eD.GZ)({...a}),{headers:{"Content-Type":"multipart/form-data"}}):await J.ZP.post("/ticket-promotions",(0,eD.GZ)({...a}),{headers:{"Content-Type":"multipart/form-data"}})).data.error)throw u(e.data.error.message),Error(e.data.error.message);d(e.data),t(e.data),m(),v(!1),et.Am.success("Promo\xe7\xe3o salva com sucesso!"),u({})}
1catch(e){console.log(JSON.stringify(e,null,2)),m(),et.Am.error(e.message)}},[r,f,t,a,m,ej.Y5]),w=l.useCallback(async()=>{(0,em.Z)({text:"Deseja realmente remover esta promo\xe7\xe3o?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{m(!0,"Removendo promo\xe7\xe3o");let e=await J.ZP.delete("/ticket-promotions/".concat(r.id));if(m(),e.data.error)return et.Am.error(e.data.error.message);et.Am.success("Promo\xe7\xe3o removida com sucesso!"),a(r.id)},onError:()=>{m()}})},[r]);return{ticketPromotion:r,setTicketPromotionParam:N,errors:c,setErrors:u,changesMade:h,saveTicketPromotion:k,removeTicketPromotion:w,event:s,fetchingTickets:x,tickets:g,ticket:f,setTicket:b,promotionTypes:y}},oG=e=>{let{t,i18n:a}=(0,p.$)("admin"),{data:n,onClose:s,onChange:i,onRemove:l}=e,{ticketPromotion:o,setTicketPromotionParam:d,errors:c,changesMade:u,saveTicketPromotion:m,removeTicketPromotion:h,event:x,tickets:g,fetchingTickets:j,ticket:f,setTicket:b}=oV(n,i,l),{id:y,type:N,name:k,description:w,startDate:Z,endDate:C,promotionChannels:S,banner2:_,banner1:D,banner3:E,updatedAt:P,lastUpdatedBy:I,status:A}=o,T=!y;return(0,r.jsx)("div",{className:"ticket-promotion-form forms",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsx)(ei.Z,{title:T?t("ticket_promotion.create"):t("ticket_promotion.edit"),onGoBack:()=>{u?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:s}):s()},data:{id:y,updatedAt:P,lastUpdatedBy:I}}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"Dados da Promo\xe7\xe3o",content:(0,r.jsxs)("div",{className:"form-content",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"image",children:[(0,r.jsx)(eE.Z,{refId:"ticket-cover-image",onChange:e=>d({banner2:e}),aspectRatio:16/9,renderBtn:(0,r.jsx)("label",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:_,layout:"fill"})})}),(0,r.jsx)("span",{children:"Banner 2 (768x768)"})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)("div",{style:{display:"flex"},children:(0,r.jsx)(lx.Z,{label:t("ticket_promotion.active"),checked:"active"===A,onChange:e=>d({status:e?"active":"inactive"})})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(es.Z,{className:"textfield",label:t("ticket_promotion.name")+"*",value:k||"",onChange:e=>d({name:e.target.value}),error:null==c?void 0:c.name})}),(0,r.jsx)("div",{className:"ticket-select-container",children:(0,r.jsx)(e_.Z,{id:"ticket",options:g,includeInputInList:!0,getOptionLabel:e=>"string"==typeof e?e:e.title,disablePortal:!0,loading:j,loadingText:"Carregando...",value:f,onChange:(e,t)=>
1{b(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"".concat(t("ticket_distribution.select_ticket")," (Opcional)"),error:!!(null==c?void 0:c.ticket),helperText:!!(null==c?void 0:c.ticket)&&t("required_field"),inputProps:e.inputProps}),renderOption:(e,t)=>(0,r.jsxs)("li",{...e,className:"options",children:[(0,r.jsx)("span",{className:"opt-ticket",children:(0,r.jsx)(eP.Z,{src:t.coverImageUrl,width:85,height:55})}),(0,r.jsx)("span",{className:"opt-label",children:t.title})]})})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(am.Z,{label:t("ticket_promotion.type")+"*",options:Object.keys(oz).map(e=>({label:oz[e].label,value:e})),value:N,onChange:e=>d({type:e,description:oz[e].description}),error:null==c?void 0:c.type})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)(am.Z,{label:t("ticket_promotion.promotion_channels")+"*",options:[{label:"Website",value:"web"},{label:"Maquininha",value:"card-machine"},{label:"Aplicativo",value:"app"}],multiple:!0,value:S,onChange:e=>d({promotionChannels:e}),className:"channels",error:null==c?void 0:c.promotionChannels})})]})]}),(0,r.jsxs)("div",{className:"hours",children:[(0,r.jsx)("h3",{children:t("ticket.available_days")}),(0,r.jsx)("label",{children:"Selecione as datas de in\xedcio e fim que a promo\xe7\xe3o estar\xe1 dispon\xedvel."}),(0,r.jsxs)("div",{className:"row dates",children:[(0,r.jsx)(tM.Z,{label:"Data In\xedcio",className:"input",value:Z||null,minDate:null==x?void 0:x.startDate,onChange:e=>d({startDate:e}),renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:c.startDate,error:!!c.startDate})}),(0,r.jsx)(tM.Z,{label:"Data Fim",className:"input",value:C||null,minDate:null==x?void 0:x.endDate,onChange:e=>d({endDate:e}),renderInput:e=>(0,r.jsx)(es.Z,{...e,helperText:c.endDate,error:!!c.endDate})})]})]}),(0,r.jsxs)("div",{className:"markdown-container",children:[(0,r.jsx)("h3",{children:"Descri\xe7\xe3o:"}),(0,r.jsx)(aw.Z,{initValue:w||"",onChange:e=>d({description:e})})]}),(0,r.jsxs)("div",{className:"actions",children:[!T&&(0,r.jsx)(v.Z,{variant:"outlined",color:"error",onClick:h,className:"remove-btn",children:t("remove")}),(0,r.jsx)(v.Z,{variant:"outlined",onClick:()=>{u?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:s}):s()},children:t("close")}),(0,r.jsx)(v.Z,{variant:"contained",onClick:m,children:t("save")})]})]})},{id:1,label:"Banners",content:(0,r.jsxs)("div",{className:"form-content-banner",children:[(0,r.jsxs)("div",{className:"header-card",children:[(0,r.jsx)("span",{children:"Banner 1 (1280x200)"}),(0,r.jsx)(eE.Z,{refId:"ticket-promotion-banner1",onChange:e=>d({banner1:e}),renderBtn:(0,r.jsx)("label",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:D,layout:"fill"})})})]}),(0,r.jsxs)("div",{className:"banners-row",children:[(0,r.jsxs)("div",{className:"banner2-card",children:[(0,r.jsx)("span",{children:"Banner 2 (768x768)"}),(0,r.jsx)(eE.Z,{refId:"ticket-promotion-banner2",onChange:e=>d({banner2:e}),renderBtn:(0,r.jsx)("label",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:_,layout:"fill"})})})]}),(0,r.jsxs)("div",{className:"banner3-card",children:[(0,r.jsx)("span",{children:"Banner 3 (768x768)"}),(0,r.jsx)(eE.Z,{refId:"ticket-promotion-banner3",onChange:e=>d({banner3:e}),renderBtn:(0,r.jsx)("label",{className:"cover-image",children:(0,r.jsx)(eP.Z,{src:E,layout:"fill"})})})]})]})]})}]})]})})};var oW=l.memo(oG);let o$=()=>{let{t:e,i18n:t}=(0,p.$)("admin"),{storedState:a}=(0,o.oR)(),n=null==a?void 0:a.currentSelectedEvent,{ticketsData:s,filters:i,onChangeFilters:l,onTicketPromotionRemove:d,openTicketPromotionForm:c,selectedTicketPromotion:u,closeTicketPromotionForm:m,refresh:h,isLoading:x}=oF(),{ticketPromotions:g=[],numberOfItems:j}=s||{};return(0,r.jsxs)("div",{className:"tickets-promotions-container",children:[(0,r.jsx)("h3",{children:"Promo\xe7\xf5es"}),(0,r.jsxs)("div",{className:"row filters",children:[(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>c({}),disabled:!(null==n?void 0:n.status)||(null==n?void 0:n.status)==="ended",children:"".concat(e("ticket_promotion.create"))}),(0,r.jsx)(K.ZP,{showAt:!!u,onClose:m,children:(0,r.jsx)(oW,{data:u,onClose:m,onCh
1ange:h,onRemove:d})})]}),(null==n?void 0:n.status)&&x?(0,r.jsx)("div",{className:"data-info",children:(0,r.jsx)(ee.aN,{inline:!0})}):(null==g?void 0:g.length)?(0,r.jsxs)("div",{className:"data-info",children:["Promo\xe7\xf5es encontradas: ",j]}):(0,r.jsx)("div",{className:"data-info",children:"Nenhuma promo\xe7\xe3o cadastrada para este evento!"}),(0,r.jsx)("div",{className:"tickets flex1",children:(null==n?void 0:n.status)&&!x&&(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:95,rowCount:(null==g?void 0:g.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,{id:s,status:i,banner2:l,name:o,promotionChannels:d}=g[t],u=null==d?void 0:d.map(e=>"web"===e?"Website":"card-machine"===e?"Maquininha":"app"===e?"App":"").join(", ");return(0,r.jsx)("div",{style:n,className:"list-item-card draggable",onClick:()=>c(g[t]),draggable:!0,"data-index":t,"data-id":s,children:(0,r.jsxs)("div",{className:"card-content "+("active"===i?"active":"inactive"),children:[(0,r.jsxs)("div",{className:"cover",children:[(0,r.jsx)(eP.Z,{src:l,layout:"fill"}),!i&&(0,r.jsx)(aJ.Z,{className:"hidden-icon"})]}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"title",children:[" ",o," "]})}),(0,r.jsxs)("div",{children:["Canais de promo\xe7\xf5es: ",u]})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})})]})},oH=e=>{let{oldProductTag:t,onUpdateProductTag:a}=e,[n,s]=l.useState(!1),{toggleLoader:i}=(0,ee.U2)(),r=l.useCallback(e=>{(async()=>{try{s(!0),i(!0,"Atualizando tag de produto..."),await J.ZP.put("/product/update-category-tag",{oldCategory:t,newCategory:e}),"function"==typeof a&&a({oldProductTag:t,newProductTag:e}),i(),s(!1)}catch(e){s(!1),et.Am.error(e.message)}})()},[t]);return{loading:n,onGoBack:function(){(0,K.Mr)()},submitProductTag:r}},oJ=e=>{let{productTag:t,onUpdateProductTag:a}=e,{t:n}=(0,p.$)("admin"),[s,i]=l.useState(t),{loading:o,onGoBack:d,submitProductTag:c}=oH({oldProductTag:t,onUpdateProductTag:a});return o?(0,r.jsx)("div",{className:"product-tag-form",children:(0,r.jsx)(ee.aN,{message:"Carregando "})}):(0,r.jsxs)("div",{className:"product-tag-form",children:[(0,r.jsx)(ei.Z,{title:n("product_tag.edit"),onGoBack:d}),(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-productTag",children:[(0,r.jsx)("div",{className:"form",children:(0,r.jsx)("div",{className:"fields",children:(0,r.jsx)(es.Z,{className:"textfield",label:"* "+n("product_tag.name_product_tag"),value:s||"",onChange:e=>i(e.target.value)})})}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>c(s),size:"large",className:"submit-product-tag",children:String(n("product_tag.update"))})})]})})]})},oQ=()=>{let[e,t]=l.useState(!0),[a,n]=l.useState([]),[s,i]=l.useState([]),r=l.useCallback(()=>{(async()=>{try{var e;t(!0);let a=await J.ZP.get("/product-catalogation/classification-tags");t(!1);let s=null===(e=a.data)||void 0===e?void 0:e.error;if(s)throw Error(s);n(a.data),i(a.data)}catch(e){t(!1),et.Am.error(e.message)}})()},[]),o=l.useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";i(a.filter(t=>(0,eD.Jo)(t).toLowerCase().includes((0,eD.Jo)(e).toLowerCase())))},[a]);return l.useEffect(()=>{r()},[]),{loading:e,productTags:s,setFilteredProductTags:i,setProductTags:n,filterProductTags:o}},oY=()=>{let{t:e}=(0,p.$)("admin"),[t,a]=l.useState(""),{loading:n,productTags:s,setProductTags:i,setFilteredProductTags:o,filterProductTags:d}=oQ();return(0,r.jsxs)("div",{className:"product-tag",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Tags de produtos"}),(0,r.jsx)("div",{className:"head",children:(0,r.jsx)(es.Z,{className:"search",placeholder:e("product_tag.search"),value:t||"",onChange:e=>{a(e.target.value),d(e.target.value)},InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==t?void 0:t.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>{a(""),d("")},children:(0,r.jsx)(ec.Z,{})})})}})}),!n||(null==s?void 0:s.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:60,rowCount:(null==s?void 0:s.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,l=s[t];return(0,r.jsx)("div",{"data-index":t,"data-id":"".concat(l,"-").concat(t),className:"list-item-card product-tag",style:n,draggable:!0,onClick:()=>(0,K.K4)((0,r.jsx)(oJ,{productTag:l,onUpdateProductTag:e=>{let{oldProductTag:t,newProductTag:a}=e;o(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[e.find(e=>e===a)?"":a,...e.filter(e=>e!==t)].filter(e=>e)}),i(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.filter(e=>e!==t)})}})),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"info",children:(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"title",children:[" ",l," "]})})}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},oK=e=>{let{oldBrandTag:t,onUpdateBrandTag:a}=e,[n,s]=l.useState(!1),{toggleLoader:i}=(0,ee.U2)(),r=l.useCallback(e=>{(async()=>{try{s(!0),i(!0,"Atualizando tag de produto..."),await J.ZP.put("/product/update-brand-tag",{oldBrand:t,newBrand:e}),"function"==typeof a&&a({oldBrandTag:t,newBrandTag:e}),i(),s(!1)}catch(e){s(!1),et.Am.error(e.message)}})()},[t]);return{loading:n,onGoBack:function(){(0,K.Mr)()},submitBrandTag:r}},oX=e=>{let{brandTag:t,onUpdateBrandTag:a}=e,{t:n}=(0,p.$)("admin"),[s,i]=l.useState(t),{loading:o,onGoBack:d,submitBrandTag:c}=oK({oldBrandTag:t,onUpdateBrandTag:a});return o?(0,r.jsx)("div",{className:"brand-tag-form",children:(0,r.jsx)(ee.aN,{message:"Carregando "})}):(0,r.jsxs)("div",{className:"brand-tag-form",children:[(0,r.jsx)(ei.Z,{title:n("brand_tag.edit"),onGoBack:d}),(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-brandTag",children:[(0,r.jsx)("div",{className:"form",children:(0,r.jsx)("div",{className:"fields",children:(0,r.jsx)(es.Z,{className:"textfield",label:"* "+n("brand_tag.name_brand_tag"),value:s||"",onChange:e=>i(e.target.value)})})}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>c(s),size:"large",className:"submit-brand-tag",children:String(n("brand_tag.update"))})})]})})]})},o0=()=>{let[e,t]=l.useState(!0),[a,n]=l.useState([]),[s,i]=l.useState([]),r=l.useCallback(()=>{(async()=>{try{var e;t(!0);let a=await J.ZP.get("/product-catalogation/brand-tags");t(!1);let s=null===(e=a.data)||void 0===e?void 0:e.error;if(s)throw Error(s);n(a.data),i(a.data)}catch(e){t(!1),et.Am.error(e.message)}})()},[]),o=l.useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";i(a.filter(t=>(0,eD.Jo)(t).toLowerCase().includes((0,eD.Jo)(e).toLowerCase())))},[a]);return l.useEffect(()=>{r()},[]),{loading:e,brandTags:s,setFilteredBrandTags:i,setBrandTags:n,filterBrandTags:o}},o1=()=>{let{t:e}=(0,p.$)("admin"),[t,a]=l.useState(""),{loading:n,brandTags:s,setBrandTags:i,setFilteredBrandTags:o,filterBrandTags:d}=o0();return(0,r.jsxs)("div",{className:"brand-tag",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"}
1,children:"Tags de Marcas"}),(0,r.jsx)("div",{className:"head",children:(0,r.jsx)(es.Z,{className:"search",placeholder:e("brand_tag.search"),value:t||"",onChange:e=>{a(e.target.value),d(e.target.value)},InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==t?void 0:t.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>{a(""),d("")},children:(0,r.jsx)(ec.Z,{})})})}})}),!n||(null==s?void 0:s.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:60,rowCount:(null==s?void 0:s.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,l=s[t];return(0,r.jsx)("div",{"data-index":t,"data-id":"".concat(l,"-").concat(t),className:"list-item-card brand-tag",style:n,draggable:!0,onClick:()=>(0,K.K4)((0,r.jsx)(oX,{brandTag:l,onUpdateBrandTag:e=>{let{oldBrandTag:t,newBrandTag:a}=e;o(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[e.find(e=>e===a)?"":a,...e.filter(e=>e!==t)].filter(e=>e)}),i(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.filter(e=>e!==t)})}})),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"info",children:(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"title",children:[" ",l," "]})})}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},o2={name:"",color:"#000000",cta:"",footerText:""};function o3(e){let t="".concat(e||"").trim();return t?(t.startsWith("#")||(t="#".concat(t)),t.toUpperCase()):""}let o6=(e,t,a)=>{let[n,s]=l.useState(!!e),[i,r]=l.useState(o2),[o,d]=l.useState({}),{toggleLoader:c}=(0,ee.U2)(),[u,m]=l.useState(!1),h=l.useRef(!1);async function v(){try{var t;let a=await ay.get("/advertising-brand/".concat(e));s(!1);let n=null===(t=a.data)||void 0===t?void 0:t.error;if(n)throw Error(n.message||n);r(a.data.brand)}catch(e){s(!1),et.Am.error(e.message)}}function x(){let e={},{name:t,color:a,cta:n,footerText:s}=i;return(null==t?void 0:t.trim())||(e.name_required=!0),(null==a?void 0:a.trim())||(e.color_required=!0),(null==n?void 0:n.trim())||(e.cta_required=!0),(null==s?void 0:s.trim())||(e.footerText_required=!0),d(e),!Object.keys(e).length||(et.Am.error("Formul\xe1rio incompleto!"),!1)}async function p(){try{var e;if(!x())return;c(!0,"Criando marca publicidade");let a=await ay.post("/advertising-brand",{...i,color:o3(i.color)});if(c(),null===(e=a.data)||void 0===e?void 0:e.error)throw Error(a.data.error.message||a.data.error);r(a.data.brand),setTimeout(()=>m(!1),1e3),et.Am.success("Marca publicidade criada com sucesso!"),d({}),t()}catch(e){c(),et.Am.error(e.message)}}async function g(){try{var a;if(!x())return;c(!0,"Atualizando marca publicidade");let n=await ay.put("/advertising-brand/".concat(e),{...i,color:o3(i.color)});if(c(),null===(a=n.data)||void 0===a?void 0:a.error)throw Error(n.data.error.message||n.data.error);r({...i,...n.data.brand}),setTimeout(()=>m(!1),1e3),et.Am.success("Marca publicidade atualizada com sucesso!"),d({}),t()}catch(e){c(),et.Am.error(e.message)}}return l.useEffect(()=>{e?v():s(!1)},[e]),(0,ev.gt)(u,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),{loading:n,brand:i,changeBrandData:function(e){r(t=>({...t,...e})),h.current&&m(!0)},onGoBack:function(){u?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitBrand:(null==i?void 0:i.id)?g:p,errors:o,removeBrand:function(){(0,em.Z)({text:"Deseja realmente remover esta marca publicidade?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{try{var e;c(!0,"Removendo marca publicidade");let t=await ay.delete("/advertising-brand/".concat(i.id));if(c(),null===(e=t.data)||void 0===e?void 0:e.error)throw Error(t.data.error.message||t.data.error);"function"==typeof a&&a(),et.Am.success("Marca publicidade removida com sucesso!"),(0,K.Mr)()}catch(e){c(),et.Am.error(e.message)}}})}}},o5=e=>{let{brandId:t,onChange:a,onDelete:n}=e,{loading:s,brand:i,changeBrandData:l,onGoBack:o,submitBrand:d,errors:c,removeBrand:u}
1=o6(t,a,n),{id:m,name:h,color:x,cta:p,footerText:g}=i;return s?(0,r.jsx)("div",{className:"advertising-brand-form loader",children:(0,r.jsx)(ee.aN,{})}):(0,r.jsxs)("div",{className:"advertising-brand-form",children:[(0,r.jsx)(ei.Z,{title:m?"Editar marca publicidade":"Nova marca publicidade",onGoBack:o}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("div",{className:"form",children:(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* Nome da marca",value:h||"",onChange:e=>l({name:e.target.value}),error:null==c?void 0:c.name_required}),(0,r.jsxs)("div",{className:"row color-row",children:[(0,r.jsx)(es.Z,{type:"color",className:"textfield color-picker",label:"* Cor da marca",value:x||"#000000",onChange:e=>l({color:e.target.value}),error:null==c?void 0:c.color_required}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Hex",value:x||"",onChange:e=>{let t;(t=e.target.value.trim())&&!t.startsWith("#")&&(t="#".concat(t)),l({color:t})},error:null==c?void 0:c.color_required})]}),(0,r.jsx)(es.Z,{className:"textfield",label:"* CTA (texto do bot\xe3o)",value:p||"",onChange:e=>l({cta:e.target.value}),error:null==c?void 0:c.cta_required}),(0,r.jsx)(es.Z,{className:"textfield",label:"* Texto footer",value:g||"",onChange:e=>l({footerText:e.target.value}),multiline:!0,rows:3,error:null==c?void 0:c.footerText_required})]})}),(0,r.jsxs)("div",{className:"actions",children:[!!m&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:u,className:"remove-btn",children:"Remover"}),(0,r.jsx)(v.Z,{variant:"contained",onClick:d,size:"large",children:m?"Atualizar":"Criar"})]})]})]})},o8=()=>{let[e,t]=l.useState(""),a=(0,ev.Nr)(e,300),{data:n,isLoading:s,refresh:i}=ad("/advertising-brand/list-admin?search=".concat(a||"")),o=(null==n?void 0:n.brands)||[];return(0,r.jsxs)("div",{className:"advertising-brands",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Marcas Publicidade"}),(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(es.Z,{className:"search",placeholder:"Buscar marca publicidade",value:e||"",onChange:e=>t(e.target.value),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==e?void 0:e.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>t(""),children:(0,r.jsx)(ec.Z,{})})})}}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>(0,K.K4)((0,r.jsx)(o5,{onChange:i})),children:"Criar marca"})]}),!s||(null==o?void 0:o.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:90,rowCount:(null==o?void 0:o.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,s=o[t];return(0,r.jsx)("div",{"data-index":t,"data-id":s.id,className:"list-item-card advertising-brand",style:n,onClick:()=>(0,K.K4)((0,r.jsx)(o5,{brandId:s.id,onChange:i,onDelete:i})),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"color-preview",style:{backgroundColor:s.color}}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("div",{className:"title",children:s.name})}),(0,r.jsxs)("p",{className:"subtitle",children:["CTA: ",s.cta]}),(0,r.jsx)("p",{className:"subtitle",children:s.color})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})}):(0,r.jsx)("div",{className:"loader",children:(0,r.jsx)(ee.aN,{})})]})},o7=e=>{let{oldEnvironmentTag:t,onUpdateEnvironmentTag:a}=e,[n,s]=l.useState(!1),{toggleLoader:i}=(0,ee.U2)(),r=l.useCallback(e=>{(async()=>{try{s(!0),i(!0,"Atualizando tag de ambiente..."),await ay.put("/environment/update-environment-tag",{oldEnvironmentTag:t,newEnvironmentTag:e}),"function"==typeof a&&a({oldEnvironmentTag:t,newEnvironmentTag:e}),i(),s(!1)}catch(e){s(!1),et.Am.error(e.message)}})()},[t]);return{loading:n,onGoBack:function(){(0,K.Mr)()},submitEnvironmentTag:r}},o4=e=>{let{environmentTag:t,onUpdateEnvironmentTag:a}=e,{t:n}=(0,p.$)("admin"),[s,i]=l.useState(t),{loading:o,onGoBack:d,submitEnvironmentTag:c}=o7({oldEnvironmentTag:t,onUpdateEnvironmentTag:a});return o?(0,r.jsx)("div",{className:"environment-tag-form",children:(0,r.jsx)(ee.aN,{message:"Carregando "})}):(0,r.jsxs)("div",{className:"environment-tag-form",children:[(0,r.jsx)(ei.Z,{title:n("environment_tag.edit"),onGoBack:d}),(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-environmentTag",children:[(0,r.jsx)("div",{className:"form",children:(0,r.jsx)("div",{className:"fields",children:(0,r.jsx)(es.Z,{className:"textfield",label:"* "+n("environment_tag.name_environment_tag"),value:s||"",onChange:e=>i(e.target.value)})})}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)(v.Z,{variant:"contained",onClick:()=>c(s),size:"large",className:"submit-environment-tag",children:String(n("environment_tag.update"))})})]})})]})},o9=()=>{let[e,t]=l.useState(!0),[a,n]=l.useState([]),[s,i]=l.useState([]),r=l.useCallback(()=>{(async()=>{try{var e;t(!0);let a=await ay.get("/environment/tags/environments");t(!1);let s=null===(e=a.data)||void 0===e?void 0:e.error;if(s)throw Error(s);n(a.data),i(a.data)}catch(e){t(!1),et.Am.error(e.message)}})()},[]),o=l.useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";i(a.filter(t=>(0,eD.Jo)(t).toLowerCase().includes((0,eD.Jo)(e).toLowerCase())))},[a]);return l.useEffect(()=>{r()},[]),{loading:e,environmentTags:s,setFilteredEnvironmentTags:i,setEnvironmentTags:n,filterEnvironmentTags:o}},de=()=>{let{t:e}=(0,p.$)("admin"),[t,a]=l.useState(""),{loading:n,environmentTags:s,setEnvironmentTags:i,setFilteredEnvironmentTags:o,filterEnvironmentTags:d}=o9();return(0,r.jsxs)("div",{className:"environment-tag",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Tags de Ambientes"}),(0,r.jsx)("div",{className:"head",children:(0,r.jsx)(es.Z,{className:"search",placeholder:e("environment_tag.search"),value:t||"",onChange:e=>{a(e.target.value),d(e.target.value)},InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==t?void 0:t.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>{a(""),d("")},children:(0,r.jsx)(ec.Z,{})})})}})}),!n||(null==s?void 0:s.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:t,height:a}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:a,width:t+10,rowHeight:60,rowCount:(null==s?void 0:s.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:t,key:a,style:n}=e,l=s[t];return(0,r.jsx)("div",{"data-index":t,"data-id":"".concat(l,"-").concat(t),className:"list-item-card environment-tag",style:n,draggable:!0,onClick:()=>(0,K.K4)((0,r.jsx)(o4,{environmentTag:l,onUpdateEnvironmentTag:e=>{let{oldEnvironmentTag:t,newEnvironmentTag:a}=e;o(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[e.find(e=>e===a)?"":a,...e.filter(e=>e!==t)].filter(e=>e)}),i(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.filter(e=>e!==t)})}})),children:(0,r.jsxs)("div",{className:"card-content",children:[(0,r.jsx)("div",{className:"info",children:(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"title",children:[" ",l," "]})})}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},a)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},dt=(e,t,a)=>{let[n,s]=l.useState(!0),[i,r]=l.useState({}),[o,d]=l.useState({}),{toggleLoader:c}=(0,ee.U2)(),[u,m]=l.useState(!1),[h,v]=l.useState(!1),x=l.useRef(!1),[p,g]=l.useState(!1),[j,f]=l.useState(""),[b,y]=l.useState([]),N=(0,ev.Nr)(j,300),[k,w]=l.useState({});async function Z(){try{var t;let a=await J.ZP.get("/youtube/list-admin?id=".concat(e));s(!1);let n=null===(t=a.data)||void 0===t?void 0:t.error;if(n)throw Error(n);r(a.data),w(a.data.professional||{})}catch(e){s(!1),et.Am.error(e.message)}}function C(){let e={};d(e);let{title:t,subTitle:a,url:n}=i;return t||(e.title_required=!0),a||(e.subTitle_required=!0),n||(e.url_required=!0),!Object.keys(e).length||(d(e),et.Am.error("Formul\xe1rio incompleto!"),window.scrollTo(0,0),!1)}async function S(){try{if(!C())return;c(!0,"Criando video");let e=await J.ZP.post("/youtube",{...i,professionalId:null==k?void 0:k.id});if(e.data.error)throw d(e.data.error.message),Error(e.data.error.message);r(e.data),c(),setTimeout(()=>v(!1),1e3),et.Am.success("Video criado com sucesso!"),d({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}async function _(){try{if(!C())return;c(!0,"Atualizando video");let a=await J.ZP.put("/youtube/".concat(e),{...i,professionalId:null==k?void 0:k.id});if(c(),a.data.error)throw d(a.data.error.message),Error(a.data.error.message);r({...i,...a.data}),setTimeout(()=>v(!1),1e3),et.Am.success("Video atualizada com sucesso!"),d({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}async function D(){try{c(!0,"Publicando video");let e=await J.ZP.put("/youtube/".concat(i.id,"/publish"));if(e.data.error)throw Error(e.data.error.message);r(e=>({...e,status:"active"})),et.Am.success("Video publicada com sucesso!"),d({}),t(),c()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}return(0,ev.ss)(()=>{N&&(async()=>{try{var e,t;g(!0);let a=await (0,J.ZP)("/professional/list?search=".concat(encodeURIComponent(N),"&limit=20"));if(g(!1),console.log(a.data),null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.error)return;let n=((null==a?void 0:null===(t=a.data)||void 0===t?void 0:t.professionals)||[]).map(e=>({...e,id:e.professionalId||e.id}));y(n)}catch(e){g(!1),et.Am.error(e.message)}})()},[N]),l.useEffect(()=>{e?Z():s(!1)},[e]),(0,ev.gt)(h,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{i&&r(i)},[i]),{loading:n,video:i,changeVideoData:function(e){r(t=>({...t,...e})),x.current&&v(!0)},onGoBack:function(){h?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitVideo:(null==i?void 0:i.id)?_:S,errors:o,removeVideo:function(){try{(0,em.Z)({text:"Deseja realmente remover este video?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{c(!0,"Removendo video");let e=await J.ZP.delete("/youtube/".concat(i.id));if(c(),e.data.error)throw d(e.data.error.message),Error("Erro ao remover video! \n\n"+e.data.error.message);"function"==typeof a&&a(),et.Am.success("video removida com sucesso!"),(0,K.Mr)()}})}catch(e){c(),et.Am.error(e.message)}},publishVideo:D,setShowAddressForm:m,showAddressForm:u,refreshData:Z,searchProfessional:j,setSearchProfessional:f,professionalOptions:b,setProfessional:w,professional:k,fetchingProfessionals:p}},da=e=>{let{t}=(0,p.$)("admin"),{loading:a,video:n,changeVideoData:s,onGoBack:i,submitVideo:o,errors:d,removeVideo:c,publishVideo:u,professionalOptions:m,fetchingProfessionals:h,setSearchProfessional:x,professional:g,setProfessional:j}=dt(e.videoId,e.onChange,e.onDelete),{id:f,status:b,title:y,subTitle:N,description:k,url:w,lastUpdatedBy:Z,createdBy:C,updatedAt:S}=n;return a?(0,r.jsx)("div",{className:"video-form",children:(0,r.jsx)(ee.aN,{message:"Carregando Videos"})}):(0,r.jsxs)("div",{className:"video-form",children:[(0,r.jsx)(ei.Z,{title:t(f?"video.edit":"video.create"),onGoBack:i,data:{id:f,lastUpdatedBy:{name:(null==Z?void 0:Z.name)||(null==C?void 0:C.name)||""},updatedAt:S&&(0,ej.p6)(S,"Pp")||""}}),(0,r.jsx)("div",{className:"content",children:(0,r.jsxs)("div",{className:"container-video",children:[(0,r.jsxs)("div",{className:"form",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"logo",children:"Thumbnail do Video"}),(0,r.jsx)("div",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)((0,eD.Mq)(w)),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* "+t("video.title"),value:y||"",onChange:e=>s({title:e.target.value}),error:null==d?void 0:d.title_required}),(0,r.jsx)(es.Z,{className:"textfield",label:"* "+t("video.subtitle"),value:N||"",onChange:e=>s({subTitle:e.target.value}),error:null==d?void 0:d.subTitle_required}),(0,r.jsx)(es.Z,{className:"textfield",label:"* "+t("video.link"),value:w||"",onChange:e=>s({url:e.target.value}),error:null==d?void 0:d.url_required}),(0,r.jsx)("div",{className:"professional-select-container",children:(0,r.jsx)("div",{style:{display:"flex"},children:(0,r.jsx)(e_.Z,{id:"prof",className:"prof-select",options:m,includeInputInList:!0,freeSolo:!0,getOptionLabel:e=>"string"==typeof e?e:e.name,multiple:!1,filterSelectedOptions:!0,loading:h,loadingText:"Carregando...",value:(null==g?void 0:g.id)?g:"",onChange:(e,t)=>
1{j(t)},onInputChange:(e,t)=>{x(t)},renderInput:e=>(0,r.jsx)(es.Z,{...e,className:"input",label:"".concat(t("environment.select_profession")),error:!!(null==d?void 0:d.professional_required),inputProps:e.inputProps}),renderTags:(e,t)=>e.map(e=>(0,r.jsxs)("li",{...t,className:"prof-selected",children:[(0,r.jsx)("span",{children:e.name}),(0,r.jsx)(X.Z,{size:"small",onClick:()=>j({}),children:(0,r.jsx)(ec.Z,{fontSize:"small"})})]},e.id)),renderOption:(e,t)=>{let{name:a,avatar:n}=t;return a&&(0,l.createElement)("li",{...e,key:t.id,className:"prof-list-opt",children:[(0,r.jsx)("span",{className:"opt-avatar",children:(0,r.jsx)(eP.Z,{src:n,width:80,height:80,placeholder:"blur",blurDataURL:eD.LG,objectFit:"contain",alt:""})}),(0,r.jsx)("span",{children:a})]})}})})})]})]}),(null==g?void 0:g.id)&&(0,r.jsxs)("div",{className:"selected-professional",children:[(0,r.jsx)(eP.Z,{src:(0,eD.e6)(g.avatar),width:200,height:150,placeholder:"blur",blurDataURL:eD.LG,objectFit:"contain",alt:""}),(0,r.jsx)("div",{className:"name",children:g.name})]}),(0,r.jsx)("h2",{children:String(t("video.description"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aw.Z,{initValue:k,onChange:e=>s({description:e})})}),(0,r.jsxs)("div",{className:"actions",children:[!!f&&(0,r.jsx)(v.Z,{variant:"text",color:"error",onClick:c,className:"remove-btn",children:String(t("video.remove"))}),(0,r.jsxs)("div",{children:["active"!==b&&(0,r.jsx)(v.Z,{variant:"contained",onClick:u,size:"large",className:"submit-video",children:String(t("video.publish"))}),(0,r.jsx)(v.Z,{variant:"contained",onClick:o,size:"large",className:"submit-video",children:String(t(f?"video.update":"video.create"))})]})]})]})})]})},dn=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(0,ev.Nr)(null==n?void 0:n.videoSearch,300),{data:d=[],isLoading:c,refresh:u}=(0,eh.Z)("/youtube/list-admin?&search=".concat(i)),[m,h]=l.useState([]),x=l.useRef();function g(e){let t=e.target.closest(".list-item-card");x.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function j(e){e.target.style.opacity=1}function f(e){e.preventDefault();let t=e.target.closest(".list-item-card");x.current!==(null==t?void 0:t.dataset.index)?t.style.left="40px":t.style.left="0px"}function b(e){let t=e.target.closest(".list-item-card");t.style.left="0px"}function y(e){e.preventDefault();let t=e.target.closest(".list-item-card");t.style.left="0px";let a=null==t?void 0:t.dataset.index;if(x.current&&x.current!==a){let e=[...m],[t]=e.splice(x.current,1);e.splice(a,0,t),h(e),N(e.map(e=>e.id))}}async function N(e){try{let t=await J.ZP.put("/youtube/reorder",{order:e});if(t.data.error)throw Error(t.data.error.message);et.Am.success("Videos reordenados com sucesso!")}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{Array.isArray(d)&&h(d)},[d]),(0,r.jsxs)("div",{className:"video",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Videos dispon\xedveis"}),(0,r.jsxs)("div",{className:"head",children:[(0,r.jsx)(es.Z,{className:"search",placeholder:t("video.search"),value:(null==n?void 0:n.videoSearch)||"",onChange:e=>s({videoSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==n?void 0:null===(e=n.videoSearch)||void 0===e?void 0:e.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>s({videoSearch:""}),children:(0,r.jsx)(ec.Z,{})})})}}),(0,r.jsx)(v.Z,{className:"btn-create",variant:"contained",onClick:()=>(0,K.K4)((0,r.jsx)(da,{onChange:u})),children:"".concat(t("video.create"))})]}),!c||(null==m?void 0:m.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:130,rowCount:(null==m?void 0:m.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=m[a];return(0,r.jsx)("div",{"data-index":a,"data-id":i.id,className:"list-item-card video",style:s,draggable:!0,onDragStart:g,onDragEnd:j,onDragOver:f,onDragLeave:b,onDrop:y,onClick:()=>(0,K.K4)((0,r.jsx)(da,{videoId:i.id,onChange:u,onDelete:u})),children:(0,r.jsxs)("div",{className:"card-content "+("active"===i.status?"active":"inactive"),children:[(0,r.jsx)("div",{style:{borderRadius:"10px",minWidth:"100px",width:"200px"},className:"cover",children:(0,r.jsx)(eP.Z,{src:(0,eD.e6)((0,eD.Mq)(i.url)),layout:"fill",objectFit:"cover"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"title",children:[" ",i.title," "]}),(0,r.jsxs)("span",{className:"status",children:[" ","".concat(t("video.".concat(i.status)))]})]}),(0,r.jsx)("div",{children:(0,r.jsx)("p",{className:"subtitle",children:i.subTitle})})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},ds=(e,t,a)=>{let[n,s]=l.useState(!0),[i,r]=l.useState({}),[o,d]=l.useState({}),{toggleLoader:c}=(0,ee.U2)(),[u,m]=l.useState(!1),[h,v]=l.useState(!1);l.useRef();let x=l.useRef(!1);async function p(){try{var t;let a=await J.ZP.get("/newsletter/list-admin/slug/".concat(e,"?isFromAdminPainel=true"));s(!1);let n=null===(t=a.data)||void 0===t?void 0:t.error;if(n)throw Error(n);r(a.data)}catch(e){s(!1),et.Am.error(e.message)}}async function g(){try{c(!0,"Publicando newsletter");let e=await J.ZP.put("/newsletter/".concat(i.id,"/publish"));if(e.data.error)throw Error(e.data.error.message);r(e=>({...e,status:"published"})),et.Am.success("Newsletter publicada com sucesso!"),d({}),t(),c()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}}return l.useEffect(()=>{e?p():s(!1)},[e]),(0,ev.gt)(h,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),l.useEffect(()=>{i&&r(i)},[i]),{loading:n,newsletter:i,changeNewsletterData:function(e){r(t=>({...t,...e})),x.current&&v(!0)},onGoBack:function(){h?(0,em.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:K.Mr}):(0,K.Mr)()},submitNewsletter:async function(){try{if(!function(){let e={};d(e);let{title:t,excerpt:a,content:n,coverImage:s}=i;return t||(e.title_required=!0),a||(e.subTitle_required=!0),n||(e.description_required=!0),s||(e.coverImage_required=!0),!Object.keys(e).length||(d(e),et.Am.error("Formul\xe1rio incompleto!"),window.scrollTo(0,0),!1)}())return;c(!0,"Atualizando newsletter");let a=await J.ZP.put("/newsletter/".concat(e),(0,eD.GZ)(i),{headers:{"Content-Type":"multipart/form-data"}});if(c(),a.data.error)throw d(a.data.error.message),Error(a.data.error.message);setTimeout(()=>v(!1),1e3),et.Am.success("Newsletter atualizada com sucesso!"),d({}),t()}catch(e){console.log(JSON.stringify(e,null,2)),c(),et.Am.error(e.message)}},errors:o,removeNewsletter:function(){try{(0,em.Z)({text:"Deseja realmente remover este newsletter?",confirmButtonText:"Sim, desejo remover",onConfirm:async()=>{c(!0,"Removendo newsletter");let e=await J.ZP.delete("/newsletter/".concat(i.id));if(c(),e.data.error)throw d(e.data.error.message),Error("Erro ao remover newsletter! \n\n"+e.data.error.message);
1"function"==typeof a&&a(),et.Am.success("newsletter removida com sucesso!"),(0,K.Mr)()}})}catch(e){c(),et.Am.error(e.message)}},publishNewsletter:g,setShowAddressForm:m,showAddressForm:u,refreshData:p}},di=e=>{let{t}=(0,p.$)("admin"),{translate:a,loading:n,translatingField:s,translations:i}=aO({targets:["en","es"]}),{loading:o,newsletter:d,changeNewsletterData:c,onGoBack:u,submitNewsletter:m,errors:h,removeNewsletter:x,publishNewsletter:g}=ds(e.newsletterSlug,e.onChange,e.onDelete),{_id:j,status:f,title:b,titleEn:y,titleEs:N,excerpt:k,excerptEn:w,excerptEs:Z,slug:C,content:S,contentEn:_,contentEs:D,updatedAt:E,createdAt:P,lastUpdatedBy:I,coverImage:A,coverImageInfos:T={title:"",excerpt:""},coverImageInfosEn:R={title:"",excerpt:""},coverImageInfosEs:L={title:"",excerpt:""},images:q=[],imagesEn:M=[],imagesEs:O=[],galleries:F={},galleriesEn:B={},galleriesEs:U={},seeMore:z=[],seeMoreEn:V=[],seeMoreEs:G=[]}=d;return((0,l.useEffect)(()=>{var e,t,a,r,l,o,d,u,m,h,v,x,p,g,j,f;if(!n&&s&&(console.log("\uD83D\uDE80 ~ useEffect ~ translatingField:",s,"translateLoading:",n,"translations:",i),0!==Object.keys(i).length)){if((null==i?void 0:i.coverImageInfosTitle)&&"coverImageInfosTitle"===s||(null==i?void 0:i.coverImageInfosExcerpt)&&"coverImageInfosExcerpt"===s){c({coverImageInfosEn:{...R,excerpt:null==i?void 0:null===(e=i.coverImageInfosExcerpt)||void 0===e?void 0:e.en,title:null==i?void 0:null===(t=i.coverImageInfosTitle)||void 0===t?void 0:t.en},coverImageInfosEs:{...L,excerpt:null==i?void 0:null===(a=i.coverImageInfosExcerpt)||void 0===a?void 0:a.es,title:null==i?void 0:null===(r=i.coverImageInfosTitle)||void 0===r?void 0:r.es}});return}if((null==i?void 0:i.title)&&"title"===s)return c({titleEn:i.title.en,titleEs:i.title.es});if((null==i?void 0:i.excerpt)&&"excerpt"===s)return c({excerptEn:i.excerpt.en,excerptEs:i.excerpt.es});if((null==i?void 0:i.content)&&"content"===s)return c({contentEn:i.content.en,contentEs:i.content.es});if(s.startsWith("imageContentImageAlt")){let e=Number(s.split("-")[1]);return c({imagesEn:M.map((t,a)=>{var n;return a===e?{...t,imageAlt:null===(n=i["imageContentImageAlt-".concat(a)])||void 0===n?void 0:n.en}:t}),imagesEs:O.map((t,a)=>{var n;return a===e?{...t,imageAlt:null===(n=i["imageContentImageAlt-".concat(a)])||void 0===n?void 0:n.es}:t})})}if(s.startsWith("seeMoreTitle")){let e=Number(s.split("-")[1]);return c({seeMoreEn:V.map((t,a)=>{var n;return a===e?{...t,title:null===(n=i["seeMoreTitle-".concat(a)])||void 0===n?void 0:n.en}:t}),seeMoreEs:G.map((t,a)=>{var n;return a===e?{...t,title:null===(n=i["seeMoreTitle-".concat(a)])||void 0===n?void 0:n.es}:t})})}if(s.startsWith("galleryCaption")){let[,e,t]=s.split("-");return c({galleriesEn:{...B,[e]:null===(l=B[e])||void 0===l?void 0:null===(o=l.map)||void 0===o?void 0:o.call(l,(a,n)=>{var s,r,l;return n===Number(t)?{...a,caption:null===(s=i["galleryCaption-".concat(e,"-").concat(t)])||void 0===s?void 0:s.en,title:(null===(r=i["galleryTitle-".concat(e,"-").concat(t)])||void 0===r?void 0:r.en)||a.title,excerpt:(null===(l=i["galleryExcerpt-".concat(e,"-").concat(t)])||void 0===l?void 0:l.en)||a.excerpt}:a})},galleriesEs:{...U,[e]:null===(d=U[e])||void 0===d?void 0:null===(u=d.map)||void 0===u?void 0:u.call(d,(a,n)=>{var s,r,l;return n===Number(t)?{...a,caption:null===(s=i["galleryCaption-".concat(e,"-").concat(t)])||void 0===s?void 0:s.es,title:(null===(r=i["galleryTitle-".concat(e,"-").concat(t)])||void 0===r?void 0:r.es)||a.title,excerpt:(null===(l=i["galleryExcerpt-".concat(e,"-").concat(t)])||void 0===l?void 0:l.es)||a.excerpt}:a})}})}if(s.startsWith("galleryTitle")){let[,e,t]=s.split("-");return c({galleriesEn:{...B,[e]:null===(m=B[e])||void 0===m?void 0:null===(h=m.map)||void 0===h?void 0:h.call(m,(a,n)=>{var s;return n===Number(t)?{...a,caption:i["galleryCaption-".concat(e,"-").concat(t)].en||a.caption,title:i["galleryTitle-".concat(e,"-").concat(t)].en,excerpt:(null===(s=i["galleryExcerpt-".concat(e,"-").concat(t)])||void 0===s?void 0:s.en)||a.excerpt}:a})},galleriesEs:{...U,[e]:null===(v=U[e])||void 0===v?void 0:null===(x=v.map)||void 0===x?void 0:x.call(v,(a,n)=>{var s;return n===Number(t)?{...a,caption:i["galleryCaption-".concat(e,"-").concat(t)].es||a.caption,title:i["galleryTitle-".concat(e,"-").concat(t)].es,excerpt:(null===(s=i["galleryExcerpt-".concat(e,"-").concat(t)])||void 0===s?void 0:s.es)||a.excerpt}:a})}})}if(s.startsWith("galleryExcerpt")){let[,e,t]=s.split("-");return c({galleriesEn:{...B,[e]:null===(p=B[e])||void 0===p?void 0:null===(g=p.map)||void 0===g?void 0:g.call(p,(a,n)=>{var s;return n===Number(t)?{...a,caption:i["galleryCaption-".concat(e,"-").concat(t)].en||a.caption,title:(null===(s=i["galleryTitle-".concat(e,"-").concat(t)])||void 0===s?void 0:s.en)||a.title,excerpt:i["galleryExcerpt-".concat(e,"-").concat(t)].en}:a})},galleriesEs:{...U,[e]:null===(j=U[e])||void 0===j?void 0:null===(f=j.map)||void 0===f?void 0:f.call(j,(a,n)=>{var s;return n===Number(t)?{...a,caption:i["galleryCaption-".concat(e,"-").concat(t)].es||a.caption,title:(null===(s=i["galleryTitle-".concat(e,"-").concat(t)])||void 0===s?void 0:s.es)||a.title,excerpt:i["galleryExcerpt-".concat(e,"-").concat(t)].es}:a})}})}}},[i,s,n]),o)?(0,r.jsx)("div",{className:"newsletter-form",children:(0,r.jsx)(ee.aN,{message:"Carregando Newsletters"})}):(0,r.jsxs)("div",{className:"newsletter-form",children:[(0,r.jsx)(ei.Z,{title:t(j?"newsletter.edit":"newsletter.create"),onGoBack:u,data:{id:j,lastUpdatedBy:{name:(null==I?void 0:I.name)||""},updatedAt:E}}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"Cabe\xe7alho",content:(0,r.jsx)("div",{className:"container-newsletter",children:(0,r.jsxs)("div",{className:"form",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"logo",children:"Imagem de Capa da Not\xedcia"}),(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(A),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})}),(0,r.jsx)("div",{className:"fields",style:{paddingLeft:0},children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)("div",{className:"meta-data-cover-image-container",children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_alt")," - pt-BR"),value:T.excerpt||"",onChange:e=>c({coverImageInfos:{...T,excerpt:"".concat(e.target.value)}}),disabled:n}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_title")," - pt-BR"),value:T.title||"",onChange:e=>c({coverImageInfos:{...T,title:"".concat(e.target.value)}}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{a({field:"coverImageInfosExcerpt",text:T.excerpt}),a({field:"coverImageInfosTitle",text:T.title})},disabled:n,children:n&&("coverImageInfosExcerpt"===s||"coverImageInfosTitle"===s)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_alt")," - en-US"),value:R.excerpt||"",onChange:e=>c({coverImageInfosEn:{...R,excerpt:"".concat(e.target.value)}}),disabled:n}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_title")," - en-US"),value:R.title||"",onChange:e=>c({coverImageInfosEn:{...R,title:"".concat(e.target.value)}}),disabled:n})]})},{id:2,label:"es-ES",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_alt")," - es-ES"),value:L.excerpt||"",onChange:e=>c({coverImageInfosEs:{...L,excerpt:"".concat(e.target.value)}}),disabled:n}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("event.meta_data_cover_image_title")," - es-ES"),value:L.title||"",onChange:e=>c({coverImageInfosEs:{...L,title:"".concat(e.target.value).substring(0,50)}}),disabled:n})]})}]})})]}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.title")," - pt-BR"),value:b||"",onChange:e=>c({title:e.target.value}),error:null==h?void 0:h.title_required,disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"title",text:b}),disabled:n,children:n&&"title"===s?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.title")," - en-US"),value:y||"",onChange:e=>c({titleEn:e.target.value})})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.title")," - es-ES"),value:N||"",onChange:e=>c({titleEs:e.target.value})})}]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.subt
1itle")," - pt-BR"),value:k||"",onChange:e=>c({excerpt:e.target.value}),error:null==h?void 0:h.subTitle_required}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"excerpt",text:k}),disabled:n,children:n&&"excerpt"===s?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.subtitle")," - en-US"),value:w||"",onChange:e=>c({excerptEn:e.target.value})})},{id:2,label:"es-ES",content:(0,r.jsx)(es.Z,{className:"textfield",label:"* ".concat(t("newsletter.subtitle")," - es-ES"),value:Z||"",onChange:e=>c({excerptEs:e.target.value})})}]}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.slug")),value:C||""})]})]})})},{id:1,label:"Conte\xfado",content:(0,r.jsxs)("div",{className:"container-newsletter",children:[(0,r.jsx)("h2",{children:String(t("newsletter.content"))}),(0,r.jsx)("div",{className:"markdown-container",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aw.Z,{initValue:S||"",onChange:e=>c({content:e}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>{a({field:"content",text:S})},disabled:n,children:n&&"content"===s?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(aw.Z,{initValue:_||"",onChange:e=>c({contentEn:e}),disabled:n})},{id:2,label:"es-ES",content:(0,r.jsx)(aw.Z,{initValue:D||"",onChange:e=>c({contentEs:e}),disabled:n})}]})})]})},{id:2,label:"Imagens do Conte\xfado",content:(0,r.jsxs)("div",{className:"container-newsletter",children:[(0,r.jsx)("h2",{children:String(t("newsletter.images"))}),(0,r.jsx)("div",{children:q.filter(e=>e.id!=="".concat(null==T?void 0:T.thumbnailId)).map((e,i)=>{var l,o;return(0,r.jsxs)("div",{className:"form image-content",children:[(0,r.jsx)("div",{children:(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(e.url),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsx)("div",{className:"fields",children:(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.image.image_alt")," - pt-BR"),value:e.imageAlt||"",onChange:e=>c({images:q.map((t,a)=>i===a?{...t,imageAlt:e.target.value}:t)}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"imageContentImageAlt-".concat(i),text:e.imageAlt}),disabled:n,children:n&&s==="imageContentImageAlt-".concat(i)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.image.image_alt")," - en-US"),value:(null===(l=M[i])||void 0===l?void 0:l.imageAlt)||"",onChange:e=>c({imagesEn:M.map((t,a)=>i===a?{...t,imageAlt:e.target.value}:t)}),disabled:n})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.image.image_alt")," - es-ES"),value:(null===(o=O[i])||void 0===o?void 0:o.imageAlt)||"",onChange:e=>c({imagesEs:O.map((t,a)=>i===a?{...t,imageAlt:e.target.value}:t)}),disabled:n})})}]})})]},"".concat(e.id,"-").concat(i))})})]})},{id:3,label:"Galeria de Imagens",content:(0,r.jsxs)("div",{className:"container-newsletter",children:[(0,r.jsx)("h2",{children:String(t("newsletter.galleries"))}),(0,r.jsx)("div",{children:Object.keys(F).map((e,i)=>(0,r.jsxs)("div",{className:"gallery-images",children:[(0,r.jsx)("h3",{children:"Galeria ".concat(i+1," ID: ").concat(e)}),F[e].map((i,l)=>{var o,d,u,m,h,x,p,g,j,f,b,y;return(0,r.jsxs)("div",{className:"form image-content",children:[(0,r.jsx)("div",{children:(0,r.jsx)("label",{className:"image",children:(0,r.jsx)(au(),{src:(0,eD.e6)(i.image),className:"placeholder",placeholder:"blur",layout:"fill",blurDataURL:eD.LG,objectFit:"contain",alt:""})})}),(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.caption")," - pt-BR"),value:i.caption||"",onChange:t=>c({galleries:{...F,[e]:F[e].map((e,a)=>a===l?{...e,caption:t.target.value}:e)}}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"galleryCaption-".concat(e,"-").concat(l),text:i.caption}),disabled:n,children:n&&s==="galleryCaption-".concat(e,"-").concat(l)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.caption")," - en-US"),value:(null==B?void 0:null===(o=B[e])||void 0===o?void 0:null===(d=o[l])||void 0===d?void 0:d.caption)||"",onChange:t=>c({galleriesEn:{...B,[e]:B[e].map((e,a)=>a===l?{...e,caption:t.target.value}:e)}}),disabled:n})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.caption")," - es-ES"),value:(null==U?void 0:null===(u=U[e])||void 0===u?void 0:null===(m=u[l])||void 0===m?void 0:m.caption)||"",onChange:t=>c({galleriesEs:{...U,[e]:U[e].map((e,a)=>a===l?{...e,caption:t.target.value}:e)}}),disabled:n})})}]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.title")," - pt-BR"),value:i.title||"",onChange:t=>c({galleries:{...F,[e]:F[e].map((e,a)=>a===l?{...e,title:t.target.value}:e)}}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"galleryTitle-".concat(e,"-").concat(l),text:i.title}),disabled:n,children:n&&s==="galleryTitle-".concat(e,"-").concat(l)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.title")," - en-US"),value:(null==B?void 0:null===(h=B[e])||void 0===h?void 0:null===(x=h[l])||void 0===x?void 0:x.title)||"",onChange:t=>c({galleriesEn:{...B,[e]:B[e].map((e,a)=>a===l?{...e,title:t.target.value}:e)}}),disabled:n})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.title")," - es-ES"),value:(null==U?void 0:null===(p=U[e])||void 0===p?void 0:null===(g=p[l])||void 0===g?void 0:g.title)||"",onChange:t=>c({galleriesEs:{...U,[e]:U[e].map((e,a)=>a===l?{...e,title:t.target.value}:e)}}),disabled:n})})}]}),(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.excerpt")," - pt-BR"),value:i.excerpt||"",onChange:t=>c({galleries:{...F,[e]:F[e].map((e,a)=>a===l?{...e,excerpt:t.target.value}:e)}}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"galleryExcerpt-".concat(e,"-").concat(l),text:i.excerpt}),disabled:n,children:n&&s==="galleryExcerpt-".concat(e,"-").concat(l)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.excerpt")," - en-US"),value:(null==B?void 0:null===(j=B[e])||void 0===j?void 0:null===(f=j[l])||void 0===f?void 0:f.excerpt)||"",onChange:t=>c({galleriesEn:{...B,[e]:B[e].map((e,a)=>a===l?{...e,excerpt:t.target.value}:e)}}),disabled:n})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.gallery.excerpt")," - es-ES"),value:(null==U?void 0:null===(b=U[e])||void 0===b?void 0:null===(y=b[l])||void 0===y?void 0:y.excerpt)||"",onChange:t=>c({galleriesEs:{...U,[e]:U[e].map((e,a)=>a===l?{...e,excerpt:t.target.value}:e)}}),disabled:n})})}]})]})]},"".concat(i.id,"-").concat(l))})]},"".concat(e,"-").concat(i)))})]})},{id:4,label:"Veja Tamb\xe9m",content:(0,r.jsxs)("div",{className:"container-newsletter",children:[(0,r.jsx)("h2",{children:String(t("newsletter.see_more.label"))}),(0,r.jsx)("div",{children:z.map((e,i)=>{var l,o;return(0,r.jsx)("div",{className:"form see-more",children:(0,r.jsxs)("div",{className:"fields",children:[(0,r.jsx)(aP.Z,{tabs:[{id:0,label:"pt-BR",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.see_more.title")," - pt-BR"),value:e.title||"",onChange:e=>c({seeMore:z.map((t,a)=>a===i?{...t,title:e.target.value}:t)}),disabled:n}),(0,r.jsx)(v.Z,{variant:"outlined",className:"translate-button",onClick:()=>a({field:"seeMoreTitle-".concat(i),text:e.title}),disabled:n,children:n&&s==="seeMoreTitle-".concat(i)?"".concat(t("translating")):"".concat(t("translate_to_other_languages"))})]})},{id:1,label:"en-US",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.see_more.title")," - en-US"),value:(null===(l=V[i])||void 0===l?void 0:l.title)||"",onChange:e=>c({seeMoreEn:V.map((t,a)=>a===i?{...t,titleEn:e.target.value}:t)}),disabled:n})})},{id:2,label:"es-ES",content:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.see_more.title")," - es-ES"),value:(null===(o=G[i])||void 0===o?void 0:o.title)||"",onChange:e=>c({seeMoreEs:G.map((t,a)=>a===i?{...t,titleEs:e.target.value}:t)}),disabled:n})})}]}),(0,r.jsx)(es.Z,{className:"textfield",label:"".concat(t("newsletter.see_more.slug")),value:e.slug||"",disabled:n})]})},"".concat(e.slug,"-").concat(i))})})]})}]}),(0,r.jsx)("div",{className:"actions",children:(0,r.jsx)("div",{children:(0,r.jsx)(v.Z,{variant:"contained",onClick:m,size:"large",className:"submit-newsletter",children:String(t("newsletter.update"))})})})]})]})},dr=()=>{var e;let{t,i18n:a}=(0,p.$)("admin"),{storedState:n,setStoredState:s}=(0,o.oR)(),i=(0,ev.Nr)(null==n?void 0:n.newsletterSearch,300),{data:d=[],isLoading:c,refresh:u}=(0,eh.Z)("/newsletter/list-admin?&search=".concat(i)),[m,h]=l.useState([]),v=l.useRef();function x(e){let t=e.target.closest(".list-item-card");v.current=null==t?void 0:t.dataset.index,e.target.style.opacity=.2}function g(e){e.target.style.opacity=1}function j(e){e.preventDefault();let t=e.target.closest(".list-item-card");v.current!==(null==t?void 0:t.dataset.index)?t.style.left="40px":t.style.left="0px"}function f(e){let t=e.target.closest(".list-item-card");t.style.left="0px"}function b(e){e.preventDefault();let t=e.target.closest(".list-item-card");t.style.left="0px";let a=null==t?void 0:t.dataset.index;if(v.current&&v.current!==a){let e=[...m],[t]=e.splice(v.current,1);e.splice(a,0,t),h(e),y(e.map(e=>e.id))}}async function y(e){try{let t=await J.ZP.put("/newsletter/reorder",{order:e});if(t.data.error)throw Error(t.data.error.message);
1et.Am.success("Newsletters reordenados com sucesso!")}catch(e){et.Am.error(e.message)}}return l.useEffect(()=>{Array.isArray(d.newsletters)&&h(d.newsletters)},[d]),(0,r.jsxs)("div",{className:"newsletter",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,r.jsx)("h3",{style:{padding:"0 10px"},children:"Not\xedcias"}),(0,r.jsx)("div",{className:"head",children:(0,r.jsx)(es.Z,{className:"search",placeholder:t("newsletter.search"),value:(null==n?void 0:n.newsletterSearch)||"",onChange:e=>s({newsletterSearch:e.target.value}),InputProps:{startAdornment:(0,r.jsx)(eo.Z,{position:"start",children:(0,r.jsx)(ed.Z,{})}),endAdornment:!!(null==n?void 0:null===(e=n.newsletterSearch)||void 0===e?void 0:e.length)&&(0,r.jsx)(eo.Z,{position:"end",children:(0,r.jsx)(X.Z,{onClick:()=>s({newsletterSearch:""}),children:(0,r.jsx)(ec.Z,{})})})}})}),!c||(null==m?void 0:m.length)?(0,r.jsx)("div",{className:"flex1",children:(0,r.jsx)(af.ZP,{children:e=>{let{width:a,height:n}=e;return(0,r.jsx)(aj.ZP,{className:"list",height:n,width:a+10,rowHeight:130,rowCount:(null==m?void 0:m.length)||0,overscanRowCount:8,rowRenderer:e=>{let{index:a,key:n,style:s}=e,i=m[a];return(0,r.jsx)("div",{"data-index":a,"data-id":"".concat(i.id,"-").concat(i._id,"-").concat(i.slug),className:"list-item-card newsletter",style:s,draggable:!1,onDragStart:x,onDragEnd:g,onDragOver:j,onDragLeave:f,onDrop:b,onClick:()=>(0,K.K4)((0,r.jsx)(di,{newsletterSlug:i.slug,onChange:u,onDelete:u})),children:(0,r.jsxs)("div",{className:"card-content "+("publish"===i.status?"active":"inactive"),children:[(0,r.jsx)("div",{style:{borderRadius:"10px",width:"100%",maxWidth:"200px"},className:"cover",children:(0,r.jsx)(eP.Z,{src:i.coverImage,layout:"fill",objectFit:"cover"})}),(0,r.jsxs)("div",{className:"info",children:[(0,r.jsxs)("span",{className:"order",children:["Ordem: ",a+1]}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsxs)("div",{className:"title",children:[" ",i.title," "]}),(0,r.jsxs)("span",{className:"status",children:[" ","".concat(t("newsletter.status.".concat(i.status)))]})]}),(0,r.jsx)("div",{children:(0,r.jsx)("p",{className:"subtitle",children:i.excerpt})})]}),(0,r.jsx)("div",{className:"arrow",children:(0,r.jsx)(tw.Z,{className:"icon"})})]})},n)}})}})}):(0,r.jsxs)("div",{className:"loader",children:[" ",(0,r.jsx)(ee.aN,{})]})]})},dl="usersListFilters",dd=()=>{let{toggleLoader:e}=(0,ee.U2)(),{storedState:t,setStoredState:a}=(0,o.oR)(),n=(null==t?void 0:t[dl])||{},[s,i]=l.useState(n.search||""),r=(0,ev.Nr)(s,300),d=n.itemsLimit||20,c=n.itemsPage||0,u=n.role||"",m=new URLSearchParams;r&&m.set("search",r),u&&m.set("role",u),m.set("page",String(c)),m.set("limit",String(d));let{data:h,isLoading:v,refresh:x}=(0,eh.Z)("/user/list-with-profile?".concat(m.toString())),p=h||{},g=p.users||[],j=p.total||0;l.useEffect(()=>{a({[dl]:{...n,search:r,itemsPage:0}})},[r]);let f=l.useCallback(e=>{a({[dl]:{...n,...e}})},[n]),b=l.useCallback(t=>{(0,em.Z)({title:"Excluir usu\xe1rio",text:'Deseja realmente excluir o usu\xe1rio "'.concat(t.name||t.email,'"?<br/>Esta a\xe7\xe3o registra um log de auditoria e o usu\xe1rio ser\xe1 marcado como removido.'),icon:"warning",confirmButtonText:"Sim, excluir usu\xe1rio",cancelButtonText:"Cancelar",onConfirm:async()=>{var a;e(!0,"Excluindo usu\xe1rio");let n=await J.ZP.delete("/user/admin-remove/".concat(t.id));if(e(),null===(a=n.data)||void 0===a?void 0:a.error)return et.Am.error(n.data.error.message||"Erro ao excluir usu\xe1rio");et.Am.success("Usu\xe1rio exclu\xeddo com sucesso!"),x()}})},[x,e]);return{loadingData:v,items:g,numberOfItems:j,itemsLimit:d,itemsPage:c,role:u,setFilters:f,search:s,setSearch:i,removeUser:b,refreshData:x}},dc=[{value:"",label:"Todos os perfis"},{value:"super-admin",label:"Super Admin"},{value:"admin",label:"Admin"},{value:"professional",label:"Profissional"},{value:"supplier",label:"Cotista"},{value:"user",label:"Usu\xe1rio"}],du=()=>{let{loadingData:e,items:t,numberOfItems:a,itemsLimit:n,itemsPage:s,role:i,setFilters:l,search:o,setSearch:d,removeUser:c}=dd();return(0,r.jsxs)("div",{className:"users-list",children:[(0,r.jsx)("h3",{children:"Lista de Usu\xe1rios"}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)(eu,{value:o,onChange:e=>{var t;return d((null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.value)||"")},className:"search",placeholder:"Pesquisar por nome ou email"}),(0,r.jsxs)(tt.Z,{className:"role-select",children:[(0,r.jsx)(ta.Z,{children:"Perfil"}),(0,r.jsx)(tn.Z,{label:"Perfil",value:i,onChange:e=>l({role:e.target.value,itemsPage:0}),children:dc.map(e=>(0,r.jsx)(ts.Z,{value:e.value,children:e.label},e.value||"all"))})]})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Nome"}),(0,r.jsx)("th",{children:"Email"}),(0,r.jsx)("th",{children:"Perfil profissional"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),!e||(null==t?void 0:t.length)?(0,r.jsxs)("tbody",{children:[null==t?void 0:t.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.name||"-"}),(0,r.jsx)("td",{children:e.email||"-"}),(0,r.jsx)("td",{children:e.perfil?(0,r.jsx)("span",{className:"badge badge-on",children:e.perfil}):(0,r.jsx)("span",{className:"badge badge-off",children:"Sem perfil"})}),(0,r.jsx)("td",{className:"actions",children:(0,r.jsx)(X.Z,{title:"Excluir usu\xe1rio",onClick:()=>c(e),children:(0,r.jsx)(eg.Z,{})})})]},e.id)),!e&&!(null==t?void 0:t.length)&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:4,className:"empty",children:"Nenhum usu\xe1rio encontrado"})})]}):(0,r.jsx)(ee.aN,{inline:!0})]}),(0,r.jsx)(eZ,{numberOfItems:a,rowsPerPage:n,page:s,onPageChange:e=>l({itemsPage:e}),onRowsPerPageChange:e=>l({itemsPage:0,itemsLimit:e})})]})}
1,dm=[{value:"coupon-details",label:"Cupons — relat\xf3rio de uso",source:"Bilheteria > Cupons > detalhes (CouponDetails)"},{value:"download-pdf-tickets-multi-files",label:"Pedidos — PDF de ingressos (m\xfaltiplos arquivos)",source:"API order (download em lote)"},{value:"download-csv-banner-clicks",label:"Cliques em banner — CSV",source:"Bilheteria > Cliques em banner"},{value:"list-table-order",label:"Pedidos — carregar tabela",source:"Bilheteria > Pedidos"},{value:"gateway-payment-pagarme",label:"Dashboard Pagar.me",source:"Bilheteria > Dashboard Pagar.me"},{value:"ticket-purchase-statistics",label:"Relat\xf3rios — estat\xedsticas de vendas",source:"Bilheteria > Relat\xf3rios"},{value:"download-csv-ticket-purchase",label:"Ingressos — exportar CSV",source:"API ticket-purchase (download tabela)"},{value:"download-csv-order",label:"Pedidos — exportar CSV",source:"API order (download tabela)"},{value:"list-table-ticket-purchase",label:"Ingressos — carregar tabela",source:"Bilheteria > Dashboard / Busca simples de ingressos"},{value:"ticket-invitation",label:"Convites — envio em massa",source:"Bilheteria > Convites / \xc1rea profissional"}],dh=dm.reduce((e,t)=>(e[t.value]=t.label,e),{});dm.map(e=>e.value);let dv="tasksListFilters",dx={in_progress:"Em progresso",completed:"Conclu\xeddo",waiting_download:"Aguardando download",error:"Erro"},dp=[{value:"active",label:"Ativas"},{value:"in_progress",label:"Em progresso"},{value:"waiting_download",label:"Aguardando download"},{value:"completed",label:"Conclu\xeddas"},{value:"error",label:"Com erro"},{value:"all",label:"Todas"}],dg=()=>{let{user:e}=(0,d.aC)(),{toggleLoader:t}=(0,ee.U2)(),{storedState:a,setStoredState:n}=(0,o.oR)(),s=(null==a?void 0:a[dv])||{},i=s.statusFilter||"active",r=Boolean(s.seeAllTasks),c=s.itemsLimit||20,u=s.itemsPage||0,m=s.screenFilter||"",h=(null==e?void 0:e.role)==="super-admin"||"super-admin"===Y.userRole,v=new URLSearchParams,x="active"===i?"in_progress,waiting_download":"all"!==i?i:void 0;x&&v.set("status",x),m&&v.set("screen",m),r&&h&&v.set("all","true"),v.set("page",String(u)),v.set("limit",String(c));let{data:p,isLoading:g,refresh:j}=(0,eh.Z)("/task?".concat(v.toString())),f=p||{},[b,y]=l.useState([]),[N,k]=l.useState(!1);l.useEffect(()=>{y(f.tasks||[])},[f.tasks,p]);let w=l.useCallback(t=>null!=t&&!!t.id&&(!!h&&!!r||(!t.createdBy||null==e||!e.id||t.createdBy===e.id)&&(!m||t.screen===m)&&("all"===i||("active"===i?"in_progress"===t.status||"waiting_download"===t.status:t.status===i))),[h,r,null==e?void 0:e.id,i,m]),Z=l.useCallback(e=>{if(!w(e)){y(t=>t.filter(t=>t.id!==e.id));return}y(t=>{let a=t.findIndex(t=>t.id===e.id);if(a>=0){let n=[...t];return n[a]={...n[a],...e},n}return[e,...t]})},[w]),{connected:C}=function(e){let{enabled:t=!0,onUpdate:a,onDeleted:n,onConnectError:s}=e,i=l.useRef({onUpdate:a,onDeleted:n,onConnectError:s});i.current={onUpdate:a,onDeleted:n,onConnectError:s};let[r,o]=l.useState(!1);return l.useEffect(()=>{if(!t)return;let e=(0,as.parseCookies)()[d.Y5];if(!e)return;let a=n3(e),n=e=>{var t,a;return null===(a=(t=i.current).onUpdate)||void 0===a?void 0:a.call(t,e)},s=e=>{var t,a;return null===(a=(t=i.current).onDeleted)||void 0===a?void 0:a.call(t,e)},r=()=>{var e,t;o(!0),null===(t=(e=i.current).onConnectError)||void 0===t||t.call(e,Error("Falha na conex\xe3o em tempo real"))};return a.on("task:update",n),a.on("task:deleted",s),a.on("connect_error",r),()=>{a.off("task:update",n),a.off("task:deleted",s),a.off("connect_error",r),n6()}},[t]),{connected:Boolean(null==n1?void 0:n1.connected),socketFailed:r}}({enabled:!0,onUpdate:Z,onDeleted:e=>{let{id:t}=e;return y(e=>e.filter(e=>e.id!==t))},onConnectError:()=>k(!0)}),S=b.some(e=>"in_progress"===e.status);l.useEffect(()=>{if(!N||!S)return;let e=setInterval(()=>j(),5e3);return()=>clearInterval(e)},[N,S,j]);let _=l.useCallback(e=>{let t=(null==a?void 0:a[dv])||{};n({[dv]:{...t,...e}})},[a,n]),D=async(e,a)=>{t(!0);try{var n;let t=await J.ZP.get("/task/".concat(e,"/download"),{responseType:"blob"}),s=null===(n=t.headers)||void 0===n?void 0:n["content-disposition"],i=a||"download";if(s){let e=s.match(/filename['"]?=(?:['"]?)([^'";\n]+)(?:['"]?)/i);(null==e?void 0:e[1])&&(i=e[1].trim())}let r=window.URL.createObjectURL(t.data),l=document.createElement("a");l.href=r,l.download=i,l.click(),window.URL.revokeObjectURL(r),j()}catch(e){et.Am.error("Erro ao baixar arquivo")}finally{t(!1)}},E=async e=>{let a=await (0,em.Z)({title:"Excluir tarefa",text:"Deseja remover esta tarefa?"});if(a){t(!0);try{await J.ZP.delete("/task/".concat(e)),y(t=>t.filter(t=>t.id!==e)),et.Am.success("Tarefa removida")}catch(e){et.Am.error("Erro ao remover tarefa")}finally{t(!1)}}};return{loadingData:g,tasks:b,numberOfItems:f.total||b.length,itemsLimit:c,itemsPage:u,statusFilter:i,seeAllTasks:r,isSuperAdmin:h,screenFilter:m,setFilters:_,statusFilterOptions:dp,screenFilterOptions:dm,downloadTask:D,removeTask:E,socketConnected:C,socketFailed:N}},dj=()=>{var e;let{loadingData:t,tasks:a,numberOfItems:n,itemsLimit:s,itemsPage:i,statusFilter:l,seeAllTasks:o,isSuperAdmin:d,screenFilter:c,setFilters:u,statusFilterOptions:m,screenFilterOptions:h,downloadTask:v,removeTask:x,socketConnected:p,socketFailed:g}=dg();return(0,r.jsxs)("div",{className:"admin-tasks",children:[(0,r.jsx)("h3",{children:"Tarefas"}),g&&(0,r.jsx)("p",{className:"socket-fallback-hint",children:"Conex\xe3o em tempo real indispon\xedvel; a lista ser\xe1 atualizada periodicamente."}),p&&!g&&(0,r.jsx)("p",{className:"socket-status-hint",children:"Atualiza\xe7\xe3o em tempo real ativa"}),(0,r.jsxs)("div",{className:"row filters",children:[(0,r.jsxs)(tt.Z,{className:"screen-select",children:[(0,r.jsx)(ta.Z,{children:"Tela"}),(0,r.jsxs)(tn.Z,{label:"Tela",value:c,onChange:e=>u({screenFilter:e.target.value,itemsPage:0}),children:[(0,r.jsx)(ts.Z,{value:"",children:"Todas as telas"}),h.map(e=>(0,r.jsx)(ts.Z,{value:e.value,children:e.label},e.value))]})]}),(0,r.jsxs)(tt.Z,{className:"status-select",children:[(0,r.jsx)(ta.Z,{children:"Status"}
1),(0,r.jsx)(tn.Z,{label:"Status",value:l,onChange:e=>u({statusFilter:e.target.value,itemsPage:0}),children:m.map(e=>(0,r.jsx)(ts.Z,{value:e.value,children:e.label},e.value))})]}),d&&(0,r.jsx)(ea.Z,{control:(0,r.jsx)(tr.Z,{checked:o,onChange:e=>u({seeAllTasks:e.target.checked,itemsPage:0})}),label:"Ver todas as tarefas"})]}),(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"T\xedtulo"}),(0,r.jsx)("th",{children:"Tela"}),(0,r.jsx)("th",{children:"Progresso"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Atualizado"}),(0,r.jsx)("th",{children:"A\xe7\xf5es"})]})}),!t||(null==a?void 0:a.length)?(0,r.jsxs)("tbody",{children:[null==a?void 0:a.map(t=>{var a;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:t.title}),(0,r.jsx)("td",{title:t.screen,children:(a=t.screen)?dh[a]||a:"—"}),(0,r.jsxs)("td",{className:"progress-cell",children:[(0,r.jsx)(a5.Z,{variant:"determinate",value:t.progress||0}),(0,r.jsxs)("span",{children:[null!==(e=t.progress)&&void 0!==e?e:0,"%"]}),(0,r.jsx)("small",{children:t.description})]}),(0,r.jsx)("td",{children:dx[t.status]||t.status}),(0,r.jsx)("td",{children:t.updatedAt?(0,ix.Z)(new Date(t.updatedAt),"dd/MM/yyyy HH:mm"):"—"}),(0,r.jsx)("td",{children:"waiting_download"===t.status&&(0,r.jsx)(X.Z,{size:"small",title:"Download",onClick:()=>v(t.id,t.fileName),children:(0,r.jsx)(nC.Z,{})})})]},t.id)}),!(null==a?void 0:a.length)&&!t&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,children:"Nenhuma tarefa encontrada"})})]}):(0,r.jsx)(ee.aN,{inline:!0})]}),(0,r.jsx)(eZ,{count:n,page:i,rowsPerPage:s,onPageChange:(e,t)=>
1u({itemsPage:t}),onRowsPerPageChange:e=>u({itemsLimit:parseInt(e.target.value,10),itemsPage:0})})]})};var df=a(82989),db=a(23508);function dy(e){var t,a,n,s,i,l;let{entry:o}=e,{summary:d}=o;return(0,r.jsxs)("div",{className:"cache-key-card",children:[(0,r.jsxs)("div",{className:"cache-key-header",children:[(0,r.jsxs)("div",{className:"cache-key-chips",children:[(0,r.jsx)(rK.Z,{size:"small",label:{"ticket-list":"Lista de ingressos","ticket-banner":"Banner","ticket-config-info":"Config info","ticket-config-image":"Config imagem","event-list":"Detalhe do evento","event-list-listing":"Listagem de eventos","event-list-home":"Home bilheteria"}[l=o.type]||l}),o.env?(0,r.jsx)(rK.Z,{size:"small",color:"production"===o.env?"error":"default",label:o.env}):null]}),(0,r.jsxs)("span",{className:"ttl",children:["TTL: ",function(e){if(e<0)return"sem expira\xe7\xe3o";if(e<60)return"".concat(e,"s");let t=Math.floor(e/60),a=e%60;return a?"".concat(t,"m ").concat(a,"s"):"".concat(t,"m")}(o.ttl)]})]}),(0,r.jsx)("code",{className:"cache-key",children:o.fullKey||o.key}),(null===(t=d.tickets)||void 0===t?void 0:t.length)?(0,r.jsxs)("table",{className:"cache-tickets-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Ingresso"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Canais"}),(0,r.jsx)("th",{children:"Pre\xe7o (cache)"})]})}),(0,r.jsx)("tbody",{children:d.tickets.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:e.title}),(0,r.jsx)("td",{children:e.status}),(0,r.jsx)("td",{children:(e.sellChannels||[]).join(", ")||"—"}),(0,r.jsx)("td",{children:(t=e.priceRange)?t.min===t.max?t.min.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}):"".concat(t.min.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})," – ").concat(t.max.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})):"—"})]},e.id)})})]}):null,!d.eventTitle||(null===(a=d.tickets)||void 0===a?void 0:a.length)?null:(0,r.jsxs)("p",{className:"cache-meta",children:["Evento: ",(0,r.jsx)("strong",{children:d.eventTitle}),d.eventSlug?" (".concat(d.eventSlug,")"):"",d.eventStatus?" \xb7 ".concat(d.eventStatus):""]}),(null===(n=d.events)||void 0===n?void 0:n.length)?(0,r.jsxs)("ul",{className:"cache-events-list",children:[d.events.map(e=>(0,r.jsxs)("li",{children:[e.title||e.slug,e.status?" \xb7 ".concat(e.status):""]},e.id||e.slug)),(d.eventsCount||0)>((null===(s=d.events)||void 0===s?void 0:s.length)||0)?(0,r.jsxs)("li",{children:["… e mais ",(d.eventsCount||0)-((null===(i=d.events)||void 0===i?void 0:i.length)||0)]}):null]}):null]})}let dN=()=>{var e,t,a,n,s,i,o,d,c;let{loading:u,invalidating:p,data:g,refresh:j,invalidate:f}=function(){let{toggleLoader:e}=(0,ee.U2)(),[t,a]=l.useState(!0),[n,s]=l.useState(!1),[i,r]=l.useState(null),o=l.useCallback(async()=>{a(!0);try{var e;let t=await J.ZP.get("/redis-cache/bilheteria");if(null===(e=t.data)||void 0===e?void 0:e.error){et.Am.error(t.data.error.message||"Erro ao carregar cache"),r(null);return}r(t.data)}catch(e){et.Am.error((null==e?void 0:e.message)||"Erro ao carregar cache"),r(null)}finally{a(!1)}},[]);l.useEffect(()=>{o()},[o]);let d=l.useCallback(async()=>{let t=window.confirm("Invalidar todo o cache p\xfablico da bilheteria (eventos, ingressos, banners e configs)?\n\nAs pr\xf3ximas leituras no site e na maquininha v\xe3o ao banco e recriam o cache.");if(t){s(!0),e(!0,"Invalidando cache da bilheteria");try{var a,n,i,r;let e=await J.ZP.post("/redis-cache/bilheteria/invalidate");if(null===(a=e.data)||void 0===a?void 0:a.error){et.Am.error(e.data.error.message||"Erro ao invalidar cache");return}et.Am.success((null===(n=e.data)||void 0===n?void 0:n.message)||"Cache invalidado (".concat(null!==(r=null===(i=e.data)||void 0===i?void 0:i.totalDeleted)&&void 0!==r?r:0," chave(s) removida(s))")),await o()}catch(e){et.Am.error((null==e?void 0:e.message)||"Erro ao invalidar cache")}finally{s(!1),e()}}},[o,e]);return{loading:t,invalidating:n,data:i,refresh:o,invalidate:d}}();return u&&!g?(0,r.jsxs)("div",{className:"admin-redis-cache",children:[(0,r.jsx)("h3",{children:"Cache Redis — Bilheteria"}),(0,r.jsx)(ee.aN,{})]}):(0,r.jsxs)("div",{className:"admin-redis-cache",children:[(0,r.jsxs)("div",{className:"header-row",children:[(0,r.jsx)("h3",{children:"Cache Redis — Bilheteria"}),(0,r.jsxs)("div",{className:"actions",children:[(0,r.jsx)(v.Z,{variant:"outlined",startIcon:(0,r.jsx)(iq.Z,{}),onClick:j,disabled:u||p,children:"Atualizar"}),(0,r.jsx)(v.Z,{variant:"contained",color:"warning",startIcon:(0,r.jsx)(D.Z,{}),onClick:f,disabled:u||p,children:"Invalidar cache geral"})]})]}),(0,r.jsxs)("div",{className:"ops-alert",children:[(0,r.jsx)(df.Z,{}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:"Ponto de aten\xe7\xe3o operacional"}),(0,r.jsxs)("p",{children:["Editar ingresso no admin e vender na maquininha em seguida: com invalida\xe7\xe3o ok, a lista atualiza na hora. Se a invali
1da\xe7\xe3o falhar, o operador pode ver pre\xe7o/canal antigo por at\xe9"," ",Math.round(((null==g?void 0:null===(e=g.ttlDefaults)||void 0===e?void 0:e.ticketStatic)||600)/60)," minutos — mas n\xe3o vagas erradas, porque isso vem de ",(0,r.jsx)("code",{children:"get-hours"})," (sempre no banco)."]}),(0,r.jsxs)("p",{children:["Use o bot\xe3o ",(0,r.jsx)("strong",{children:"Invalidar cache geral"})," para for\xe7ar a limpeza imediata de eventos, ingressos, banners e configs p\xfablicas."]})]})]}),(0,r.jsxs)("div",{className:"cache-status",children:[(0,r.jsx)(rK.Z,{size:"small",color:(null==g?void 0:g.cacheEnabled)?"success":"default",label:(null==g?void 0:g.cacheEnabled)?"Cache de leitura ligado":"Cache de leitura desligado"}),(0,r.jsxs)("span",{children:["API admin: ",(0,r.jsx)("code",{children:null==g?void 0:g.nodeEnv})]}),(0,r.jsxs)("span",{children:["Prefixos no Redis:"," ",(0,r.jsx)("strong",{children:(null==g?void 0:null===(t=g.envsFound)||void 0===t?void 0:t.length)?g.envsFound.join(", "):"nenhum"})]}),(0,r.jsxs)("span",{children:["Chaves em cache: ",(0,r.jsx)("strong",{children:null!==(o=null==g?void 0:g.totalKeys)&&void 0!==o?o:0})]}),(0,r.jsxs)("span",{children:["TTL padr\xe3o: eventos ",null!==(d=null==g?void 0:null===(a=g.ttlDefaults)||void 0===a?void 0:a.eventList)&&void 0!==d?d:600,"s \xb7 tickets"," ",null!==(c=null==g?void 0:null===(n=g.ttlDefaults)||void 0===n?void 0:n.ticketStatic)&&void 0!==c?c:600,"s"]})]}),(null==g?void 0:g.totalKeys)?null:(0,r.jsx)("p",{className:"empty-state",children:"Nenhuma chave de cache da bilheteria no Redis neste momento. Elas s\xe3o criadas nas primeiras leituras p\xfablicas (site / maquininha)."}),null==g?void 0:null===(s=g.events)||void 0===s?void 0:s.map(e=>(0,r.jsxs)(m.Z,{defaultExpanded:!0,className:"event-cache-accordion",children:[(0,r.jsx)(h.Z,{expandIcon:(0,r.jsx)(db.Z,{}),children:(0,r.jsxs)("div",{className:"event-summary",children:[(0,r.jsx)("strong",{children:e.title||e.identifier}),(0,r.jsx)("span",{className:"event-slug",children:e.slug||e.identifier}),(0,r.jsx)(rK.Z,{size:"small",label:"".concat(e.keys.length," chave(s)")})]})}),(0,r.jsx)(x.Z,{children:(0,r.jsx)("div",{className:"keys-grid",children:e.keys.map(e=>(0,r.jsx)(dy,{entry:e},e.key))})})]},e.identifier)),(null==g?void 0:null===(i=g.globalKeys)||void 0===i?void 0:i.length)?(0,r.jsxs)(m.Z,{className:"event-cache-accordion",children:[(0,r.jsx)(h.Z,{expandIcon:(0,r.jsx)(db.Z,{}),children:(0,r.jsxs)("div",{className:"event-summary",children:[(0,r.jsx)("strong",{children:"Home / listagens / outras chaves"}),(0,r.jsx)(rK.Z,{size:"small",label:"".concat(g.globalKeys.length," chave(s)")})]})}),(0,r.jsx)(x.Z,{children:(0,r.jsx)("div",{className:"keys-grid",children:g.globalKeys.map(e=>(0,r.jsx)(dy,{entry:e},e.key))})})]}):null]})},dk=[{id:"dashboard",label:"Dashboard",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(an,{})},{id:"events",label:"events",icon:(0,r.jsx)(j.Z,{}),content:(0,r.jsx)(nx,{type:"default"})},{id:"related_events",label:"related_events",icon:(0,r.jsx)(j.Z,{}),content:(0,r.jsx)(nx,{type:"related"})},{id:"environment_favorites",label:"Ambientes curtidos",icon:(0,r.jsx)(f.Z,{}),content:(0,r.jsx)(sc,{})},{id:"professionals",label:"professionals",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(st,{})},{id:"users_list",label:"users_list",icon:(0,r.jsx)(y.Z,{}),content:(0,r.jsx)(du,{})},{id:"tasks",label:"tasks",icon:(0,r.jsx)(N.Z,{}),content:(0,r.jsx)(dj,{})},{id:"sponsors",label:"sponsors",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(s_,{})},{id:"suppliers",label:"suppliers",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(sP,{})},{id:"advertising-brands",label:"Marcas Publicidade",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(o8,{})},{id:"environments-tag",label:"Tags de ambientes",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(de,{})},{id:"brand-tag",label:"Tags de marcas",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(o1,{})},{id:"product-tag",label:"Tags de produtos",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(oY,{})},{id:"notifications",label:"notifications",icon:(0,r.jsx)(w.Z,{}),content:(0,r.jsx)(nf,{})},{id:"newsletters",label:"Not\xedcias",icon:(0,r.jsx)(Z.Z,{}),content:(0,r.jsx)(dr,{})},{id:"banners",label:"Banners",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(nk,{})},{id:"videos",label:"Canal CASACOR",icon:(0,r.jsx)(S.Z,{}),content:(0,r.jsx)(dn,{})},{id:"environment_photos",label:"Fotos usu\xe1rios",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(ap,{})},{id:"giftcard_givexs",label:"Giftcards Givexs",icon:(0,r.jsx)(_.Z,{}),content:(0,r.jsx)(sM,{})},{id:"redis_cache",label:"redis_cache",icon:(0,r.jsx)(D.Z,{}),content:(0,r.jsx)(dN,{})},{id:"tickets",label:"tickets",icon:(0,r.jsx)(E.Z,{}),subRoutes:[{id:"tickets-types",label:"Ingressos",icon:(0,r.jsx)(P.Z,{}),content:(0,r.jsx)(oO,{})},{id:"tickets-waiting-payment",label:"Aguardando Pagamento",icon:(0,r.jsx)(I.Z,{}),content:(0,r.jsx)(lt,{})},{id:"tickets-orders",label:"Transa\xe7\xf5es",icon:(0,r.jsx)(A.Z,{}),content:(0,r.jsx)(rd,{})},{id:"tickets-email-events",label:"E-mails",icon:(0,r.jsx)(T.Z,{}),content:(0,r.jsx)(r_,{})},{id:"tickets-whatsapp-events",label:"Disparos",icon:(0,r.jsx)(R.Z,{}),content:(0,r.jsx)(rQ,{})},{id:"tickets-orders-simple-search",label:"Ingressos (Pesquisa)",icon:(0,r.jsx)(L.Z,{}),content:(0,r.jsx)(ld,{})},{id:"tickets-dashboard",label:"Ingressos vendidos",icon:(0,r.jsx)(A.Z,{}),content:(0,r.jsx)(iX,{})},{id:"tickets-purchases-users",label:"Meus Ingressos",icon:(0,r.jsx)(q.Z,{}),content:(0,r.jsx)(i7,{})},{id:"tickets-dashboard_tickets_purchases",label:"Dashboard Bilheteria",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(oP,{})},{id:"tickets-dashboard_pagarme",label:"Dashboard Pagar.me",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(oq,{})},{id:"tickets-reports",label:"Relat\xf3rios",icon:(0,r.jsx)(R.Z,{}),content:(0,r.jsx)(lS,{})},{id:"tickets-config",label:"Configura\xe7\xe3o Ingressos",icon:(0,r.jsx)(M.Z,{}),content:(0,r.jsx)(it,{})},{id:"tickets-coupons",label:"Cupons",icon:(0,r.jsx)(O.Z,{}),content:(0,r.jsx)(ij,{})},{id:"tickets-giftcard",label:"Cart\xe3o Presente",icon:(0,r.jsx)(_.Z,{}),content:(0,r.jsx)(iZ,{})},{id:"tickets-compensation",label:"Compensa\xe7\xf5es",icon:(0,r.jsx)(F.Z,{}),content:(0,r.jsx)(ir,{})},{id:"tickets-promotions",label:"Promo\xe7\xf5es",icon:(0,r.jsx)(B.Z,{}),content:(0,r.jsx)(o$,{})},{id:"tickets-profs_suppliers",label:"Profissionais e Cotistas",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(lj,{})},{id:"tickets-invitations",label:"Convites",icon:(0,r.jsx)(P.Z,{}),content:(0,r.jsx)(rt,{})},{id:"tickets-crm_integration",label:"Integra\xe7\xe3o CRM",icon:(0,r.jsx)(U.Z,{}),content:(0,r.jsx)(lv,{})},{id:"tickets-banner_clicks",label:"Banners clicks",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(r6,{})}]},{id:"permissions",label:"Permiss\xf5es",icon:(0,r.jsx)(z.Z,{}),subRoutes:[{id:"permissions-access_rules",label:"Regras de Acesso",icon:(0,r.jsx)(z.Z,{}),content:(0,r.jsx)(eC,{})},{id:"permissions-users_access",label:"Acesso usu\xe1rios",icon:(0,r.jsx)(z.Z,{}),content:(0,r.jsx)(eF,{})},{id:"permissions-users_levels",label:"N\xedveis de permiss\xe3o",icon:(0,r.jsx)(y.Z,{}),content:(0,r.jsx)(eQ,{})},{id:"permissions-operators",label:"Operadores",icon:(0,r.jsx)(V.Z,{}),content:(0,r.jsx)(tu,{})},{id:"permissions-checkin-operators",label:"Operadores Check-in",icon:(0,r.jsx)(G.Z,{}),content:(0,r.jsx)(tg,{})},{id:"permissions-access_logs",label:"Logs",icon:(0,r.jsx)(W.Z,{}),content:(0,r.jsx)(e2,{})}]}],dw=[{id:"dashboard",label:"Dashboard",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(an,{})},{id:"franchises",label:"Franquias",icon:(0,r.jsx)($.Z,{}),content:(0,r.jsx)(a$,{})},{id:"events",label:"events",icon:(0,r.jsx)(j.Z,{}),content:(0,r.jsx)(nx,{type:"default"})},{id:"related_events",label:"related_events",icon:(0,r.jsx)(j.Z,{}),content:(0,r.jsx)(nx,{type:"related"})},{id:"environment_favorites",label:"Ambientes curtidos",icon:(0,r.jsx)(f.Z,{}),content:(0,r.jsx)(sc,{})},{id:"professionals",label:"professionals",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(st,{})},{id:"users_list",label:"users_list",icon:(0,r.jsx)(y.Z,{}),content:(0,r.jsx)(du,{})},{id:"tasks",label:"tasks",icon:(0,r.jsx)(N.Z,{}),content:(0,r.jsx)(dj,{})},{id:"sponsors",label:"sponsors",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(s_,{})},{id:"suppliers",label:"suppliers",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(sP,{})},{id:"advertising-brands",label:"Marcas Publicidade",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(o8,{})},{id:"environments-tag",label:"Tags de ambientes",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(de,{})},{id:"brand-tag",label:"Tags de marcas",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(o1,{})},{id:"product-tag",label:"Tags de produtos",icon:(0,r.jsx)(k.Z,{}),content:(0,r.jsx)(oY,{})},{id:"notifications",label:"notifications",icon:(0,r.jsx)(w.Z,{}),content:(0,r.jsx)(nf,{})},{id:"newsletters",label:"Not\xedcias",icon:(0,r.jsx)(Z.Z,{}),content:(0,r.jsx)(dr,{})},{id:"banners",label:"Banners",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(nk,{})},{id:"videos",label:"CANAL Casacor",icon:(0,r.jsx)(S.Z,{}),content:(0,r.jsx)(dn,{})},{id:"environment_photos",label:"Fotos usu\xe1rios",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(ap,{})},{id:"giftcard_givexs",label:"Givex - Gift Cards",icon:(0,r.jsx)(_.Z,{}),content:(0,r.jsx)(sM,{})},{id:"redis_cache",label:"redis_cache",icon:(0,r.jsx)(D.Z,{}),content:(0,r.jsx)(dN,{})},{id:"tickets",label:"tickets",icon:(0,r.jsx)(E.Z,{}),subRoutes:[{id:"tickets-types",label:"Ingressos",icon:(0,r.jsx)(P.Z,{}),content:(0,r.jsx)(oO,{})},{id:"tickets-waiting-payment",label:"Aguardando Pagamento",icon:(0,r.jsx)(I.Z,{}),content:(0,r.jsx)(lt,{})},{id:"tickets-orders",label:"Transa\xe7\xf5es",icon:(0,r.jsx)(A.Z,{}),content:(0,r.jsx)(rd,{})},{id:"tickets-email-events",label:"E-mails",icon:(0,r.jsx)(T.Z,{}),content:(0,r.jsx)(r_,{})},{id:"tickets-whatsapp-events",label:"Disparos",icon:(0,r.jsx)(R.Z,{}),content:(0,r.jsx)(rQ,{})},{id:"tickets-orders-simple-search",label:"Ingressos (Pesquisa)",icon:(0,r.jsx)(L.Z,{}),content:(0,r.jsx)(ld,{})},{id:"tickets-dashboard",label:"Ingressos vendidos",icon:(0,r.jsx)(A.Z,{}),content:(0,r.jsx)(iX,{})},{id:"tickets-purchases-users",label:"Meus Ingressos",icon:(0,r.jsx)(q.Z,{}),content:(0,r.jsx)(i7,{})},{id:"tickets-dashboard_tickets_purchases",label:"Dashboard Bilheteria",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(oP,{})},{id:"tickets-dashboard_pagarme",label:"Dashboard Pagar.me",icon:(0,r.jsx)(g.Z,{}),content:(0,r.jsx)(oq,{})},{id:"tickets-reports",label:"Relat\xf3rios",icon:(0,r.jsx)(R.Z,{}),content:(0,r.jsx)(lS,{})},{id:"tickets-config",label:"Configura\xe7\xe3o Ingressos",icon:(0,r.jsx)(M.Z,{}),content:(0,r.jsx)(it,{})},{id:"tickets-coupons",label:"Cupons",icon:(0,r.jsx)(O.Z,{}),content:(0,r.jsx)(ij,{})},{id:"tickets-giftcard",label:"Cart\xe3o Presente",icon:(0,r.jsx)(_.Z,{}),content:(0,r.jsx)(iZ,{})},{id:"tickets-compensation",label:"Compensa\xe7\xf5es",icon:(0,r.jsx)(F.Z,{}),content:(0,r.jsx)(ir,{})},{id:"tickets-promotions",label:"Promo\xe7\xf5es",icon:(0,r.jsx)(B.Z,{}),content:(0,r.jsx)(o$,{})},{id:"tickets-profs_suppliers",label:"Profissionais e Cotistas",icon:(0,r.jsx)(b.Z,{}),content:(0,r.jsx)(lj,{})},{id:"tickets-invitations",label:"Convites",icon:(0,r.jsx)(P.Z,{}),content:(0,r.jsx)(rt,{})},{id:"tickets-crm_integration",label:"Integra\xe7\xe3o CRM",icon:(0,r.jsx)(U.Z,{}),content:(0,r.jsx)(lv,{})},{id:"tickets-banner_clicks",label:"Banners clicks",icon:(0,r.jsx)(C.Z,{}),content:(0,r.jsx)(r6,{})}]},{id:"permissions",label:"Permiss\xf5es",icon:(0,r.jsx)(z.Z,{}),subRoutes:[{id:"permissions-access_rules",label:"Regras de Acesso",icon:(0,r.jsx)(z.Z,{}),content:(0,r.jsx)(eC,{})},{id:"permissions-users_access",label:"Acesso usu\xe1rios",icon:(0,r.jsx)(z.Z,{}),content:(0,r.jsx)(eF,{})},{id:"permissions-users_levels",label:"N\xedveis de permiss\xe3o",icon:(0,r.jsx)(y.Z,{}),content:(0,r.jsx)(eQ,{})},{id:"permissions-operators",label:"Operadores",icon:(0,r.jsx)(V.Z,{}),content:(0,r.jsx)(tu,{})},{id:"permissions-checkin-operators",label:"Operadores Check-in",icon:(0,r.jsx)(G.Z,{}),content:(0,r.jsx)(tg,{})},{id:"permissions-access_logs",label:"Logs",icon:(0,r.jsx)(W.Z,{}),content:(0,r.jsx)(e2,{})}]}],dZ=[{id:"dashboard",label:"dashboard",icon:(0,r.jsx)(g.Z,{}),content:null},{id:"prof_profile",label:"prof_profile",icon:(0,r.jsx)(q.Z,{}),content:null},{id:"prof_tickets",label:"tickets",icon:(0,r.jsx)(H.Z,{}),content:(0,r.jsx)(n7,{})}];function dC(e,t){let a=[],{userRole:n,accessRules:s}=Y,i=(t||"").toLowerCase();if("super-admin"===n?a=dw:"admin"===n?a=dw:"check-in-operator"===n?a=dw.filter(e=>"tickets"===e.id).map(e=>{var t;return{...e,subRoutes:null===(t=e.subRoutes)||void 0===t?void 0:t.filter(e=>"tickets-orders-simple-search"===e.id)}}):"professional"===n?a=dZ:"supplier"===n&&(a=dZ),"super-admin"!==n&&"check-in-operator"!==n){let t=[];s.filter(t=>t.eventId===e||"all"===t.eventId).map(e=>e.screens.map(e=>{t.push(e.screenId),e.screenId.includes("-")&&t.push(e.screenId.split("-")[0])})),t.includes("permissions-users_access")&&(t.push("permissions-users_levels"),t.push("permissions-operators"),t.push("permissions-checkin-operators")),t.includes("tickets-email-events")&&t.push("tickets-whatsapp-events"),"[email protected]"===i&&(t.push("permissions"),t.push("permissions-access_logs")),a=[...a].filter(e=>t.includes(e.id)).map(e=>(e.subRoutes&&(e.subRoutes=e.subRoutes.filter(e=>t.includes(e.id))),e))}return a.map(e=>"permissions"===e.id&&e.subRoutes?{...e,subRoutes:e.subRoutes.filter(e=>"permissions-access_logs"!==e.id||"[email protected]"===i)}:e)}var dS=a(13540);let d_=e=>{var t;
1let{t:a}=(0,p.$)("admin"),{route:n,currentRouteId:s,onChangeRoute:i}=e,[o,d]=s.split(">"),[c,g]=l.useState(!1);return l.useEffect(()=>{o===n.id&&g(o)},[o,n]),(0,r.jsxs)(m.Z,{expanded:c===n.id,onChange:(t=n.id,(e,a)=>{g(!!a&&t)}),className:"sub-item",children:[(0,r.jsx)(h.Z,{expandIcon:(0,r.jsx)(u.Z,{}),className:"sub-item-wrapper",children:(0,r.jsx)(v.Z,{className:"item",startIcon:n.icon,children:a(n.label).toString()},n.id)}),(0,r.jsx)(x.Z,{className:"sub-item-container",children:n.subRoutes.map(e=>{let t=d===e.id;return(0,r.jsx)(v.Z,{className:"item sub "+(t?"selected":""),onClick:()=>i(n.id+">"+e.id),startIcon:e.icon,children:a(e.label).toString()},e.id)})})]},n.id)},dD=e=>{let{currentRouteId:t,onChangeRoute:a,eventId:n,className:s}=e,{t:i}=(0,p.$)("admin"),{logout:l,user:o}=(0,d.aC)();return(0,r.jsxs)("aside",{className:"sidebar ".concat(s||""),children:[(0,r.jsx)(c.K7,{className:"logo"}),dC(n,null==o?void 0:o.email).map(e=>{let n=null==e?void 0:e.subRoutes,s=t===e.id;return n?(0,r.jsx)(d_,{route:e,currentRouteId:t,onChangeRoute:a},e.id):(0,r.jsx)(v.Z,{className:"item "+(s?"selected":""),onClick:()=>a(e.id),startIcon:e.icon,children:i(e.label).toString()},e.id)}),(0,r.jsx)(v.Z,{className:"item logout",onClick:l,startIcon:(0,r.jsx)(dS.Z,{}),children:"Sair"})]})};var dE=a(28133),dP=a(86967);let dI=()=>{var e,t;(0,dE.Z)();let{storedState:a,setStoredState:n}=(0,o.oR)(),[s,i]=l.useState((null==a?void 0:a.lastAdminTab)||"dashboard"),[c,u]=l.useState(!1),m=l.useRef(null),{user:h,fetchingUser:x,checkUserSession:p}=(0,d.aC)(),{fetchingUserAuthorization:g}=(0,d.Aj)(),j=(0,sD.useRouter)(),{fetchingPermissions:f,fetchAdminPermissions:b}=function(){let[e,t]=l.useState(!0);return{fetchingPermissions:e,fetchAdminPermissions:async function(e){if((null==e?void 0:e.role)==="super-admin")return Y={allowedEventsIds:[],accessRules:[],userRole:null==e?void 0:e.role},t(!1);if((null==e?void 0:e.role)==="check-in-operator"){let a=e.eventId||"";return Y={allowedEventsIds:a?[a]:[],accessRules:[{id:"check-in-operator",label:"Check-in",eventId:a||"all",screens:[{screenId:"tickets-orders-simple-search",view:!0,edit:!1,delete:!1}]}],userRole:null==e?void 0:e.role},t(!1)}t(!0);let a=await J.ZP.get("/admin-permission/user/".concat(null==e?void 0:e.id)),n=a.data.permissions,s=[];null==n||n.map(e=>{s=[...s,e.eventId].filter(e=>!!e)});let i=[];null==n||n.map(e=>{i=[...i,...e.accessRules]}),Y={allowedEventsIds:s,accessRules:i,userRole:null==e?void 0:e.role},(0,Q.C)("!!! adminPermissions refreshed!"),t(!1)}}}(),y=null==a?void 0:null===(e=a.currentSelectedEvent)||void 0===e?void 0:e._id;l.useEffect(()=>{p()},[]),l.useEffect(()=>{x||(h?b(h):j.replace("/auth/signin"))},[h,x]),l.useEffect(()=>{i((null==a?void 0:a.lastAdminTab)||"dashboard")},[null==a?void 0:a.lastAdminTab]),l.useEffect(()=>{(null==h?void 0:h.role)==="check-in-operator"&&(null==a?void 0:a.lastAdminTab)!=="tickets-orders-simple-search"&&(n({lastAdminTab:"tickets-orders-simple-search"}),i("tickets-orders-simple-search"))},[null==h?void 0:h.role,null==a?void 0:a.lastAdminTab,n]);let N=async()=>{localStorage.clear(),(0,as.destroyCookie)({},d.Y5);let e=null==window?void 0:window.grecaptcha;null==e||e.enterprise.ready(()=>{e.enterprise.execute("6LdtN0orAAAAAEfpIYpKcvdS-7Y08IHLfmDo6Mmm",{action:"submit"}).then(async e=>{try{J.ZP.post("/errorslog/create",{title:"Limpeza de cache solicitada pelo usu\xe1rio - APP Casacor",error:"Usu\xe1rio solicitou limpeza de cache e recarregamento da p\xe1gina",recaptchaToken:e}),window.location.href="/auth/signin"}catch(e){console.log("\uD83D\uDE80 ~ Admin ~ grecaptcha.enterprise.execute ~ err:",e),window.location.href="/auth/signin"}})})},k=e=>{i(e),n({lastAdminTab:e}),u(!1)},w=()=>{u(!c)},Z=()=>{u(!1)};return x?(0,r.jsx)(ee.aN,{message:"Verificando sess\xe3o..."}):f?(0,r.jsx)(ee.aN,{message:"Verificando permiss\xf5es..."}):g?(0,r.jsx)(ee.aN,{message:"Verificando admin autorizado..."}):h&&((null==Y?void 0:null===(t=Y.accessRules)||void 0===t?void 0:t.length)||(null==h?void 0:h.role)==="super-admin"||(null==h?void 0:h.role)==="check-in-operator")?(0,r.jsxs)("div",{className:"admin",ref:m,children:[(0,r.jsx)("div",{className:"sidebar-overlay ".concat(c?"overlay-visible":""),onClick:Z}),(0,r.jsx)(dD,{currentRouteId:s,onChangeRoute:k,eventId:y,className:c?"sidebar-open":""}),(0,r.jsxs)("div",{className:"content",children:[(0,r.jsxs)("div",{className:"nav",children:[(0,r.jsx)("button",{className:"sidebar-toggle",onClick:w,children:"☰"}),(0,r.jsx)(nn,{}),!!h&&(0,r.jsxs)("div",{className:"user",children:[(0,r.jsx)("span",{children:h.name}),(0,r.jsx)(eP.Z,{src:h.avatar,width:50,height:50,className:"avatar"}),(0,r.jsx)(v.Z,{sx:{m:2},onClick:N,children:(0,r.jsx)(iq.Z,{})})]})]}),(0,r.jsx)("div",{className:"wrapper",children:y||String(s||"").includes("permissions-users_levels")||String(s||"").includes("permissions-operators")||String(s||"").includes("permissions-checkin-operators")||String(s||"").includes("permissions-access_logs")?function(e,t,a){let[n,s]=null==e?void 0:e.split(">"),i=dC(t,a).find(e=>e.id===n),r=null==i?void 0:i.subRoutes;if(!r)return null==i?void 0:i.content;let l=r.find(e=>e.id===s);return null==l?void 0:l.content}(s,y||"",null==h?void 0:h.email):(0,r.jsx)("h3",{children:"Selecione uma franquia acima!"})})]})]}):(0,r.jsx)(dP.default,{})};var dA=!0,dT=dI},86967:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return r}});var n=a(85893),s=a(83321),i=a(11163);function r(){let e=(0,i.useRouter)();return(0,n.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",paddingTop:40,flexDirection:"column",alignItems:"center",gap:40,padding:40,marginTop:40},children:[(0,n.jsx)("h1",{children:"\xc1rea restrita para administradores!"}),(0,n.jsx)(s.Z,{variant:"contained",onClick:()=>e.replace("/"),children:"Voltar para homepage"})]})}},15364:function(e,t,a){"use strict";
1var n=a(85893),s=a(67294),i=a(50135),r=a(50480),l=a(45843),o=a(83321),d=a(11588),c=a(98456),u=a(93946),m=a(72428),h=a(19717),v=a(72132),x=a(45507),p=a(55765),g=a(21313),j=a(54007),f=a(57257),b=a(96013),y=a(37276),N=a(58467),k=a(45332),w=a(11163),Z=a(62672);function C(e){return Array.isArray(e)?e.filter(Boolean).join("; "):String(e||"")}function S(){return{name:"",contacts:{email:"",website:"",instagram:""}}}function _(e){return(e||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.trim()}).filter(Boolean).join(" + ")}async function D(e,t){var a,n;if(!e)return!1;let s=await N.ZP.get("/professional/by/".concat(encodeURIComponent(e)));return(null===(a=s.data)||void 0===a||!a.error)&&!!s.data&&(!s.data.slug||s.data.slug===e)&&!(t&&[String((null==(n=s.data)?void 0:n.professionalId)||(null==n?void 0:n.id)||""),s.data.id,s.data.professionalId].includes(t))&&Boolean(s.data.slug||s.data.id)}async function E(e,t){let a=e||"profissional";for(let e=1;e<=50;e+=1){let n=1===e?a:"".concat(a,"-").concat(e);if(!await D(n,t))return n}return"".concat(a,"-").concat(Date.now())}let P={name:"",slug:"",avatar:"",visible:!0,description:"",members:[S()]};function I(e,t){var a,n,s,i,r,l;return{professionalId:(null==t?void 0:t.professionalId)||(null==t?void 0:t.id),memberId:e.memberId,legacyUserId:e.legacyUserId,userId:e.userId,name:e.name||"",avatar:e.avatar,biography:e.biography,biographyEn:e.biographyEn,biographyEs:e.biographyEs,activityArea:e.activityArea,fromExisting:Boolean(e.memberId||e.legacyUserId||e.userId),contacts:{email:(null===(a=e.contacts)||void 0===a?void 0:a.email)||(null==t?void 0:null===(n=t.contacts)||void 0===n?void 0:n.email)||"",website:(null===(s=e.contacts)||void 0===s?void 0:s.website)||(null==t?void 0:null===(i=t.contacts)||void 0===i?void 0:i.website)||"",instagram:C((null===(r=e.contacts)||void 0===r?void 0:r.instagram)||(null==t?void 0:null===(l=t.contacts)||void 0===l?void 0:l.instagram))}}}function A(e){var t,a,n;let s=(e.members||[]).map(t=>I(t,e));return{id:e.professionalId||e.id,professionalId:e.professionalId||e.id,name:e.name||"",slug:e.slug||"",avatar:e.avatar||"",kind:e.kind,visible:!1!==e.visible,description:e.description||(null===(t=e.members)||void 0===t?void 0:null===(a=t[0])||void 0===a?void 0:null===(n=a.biography)||void 0===n?void 0:n.text)||"",members:s.length?s:[S()],updatedAt:e.updatedAt}}function T(e,t){return!!e.memberId&&!!t.memberId&&e.memberId===t.memberId||!!e.legacyUserId&&!!t.legacyUserId&&e.legacyUserId===t.legacyUserId||!!e.userId&&!!t.userId&&e.userId===t.userId||!!e.professionalId&&!!t.professionalId&&e.professionalId===t.professionalId&&e.name===t.name}let R=e=>{let{professionalId:t,inModal:a=!1,onSaved:D}=e,R=(0,w.useRouter)(),{toggleLoader:L}=(0,g.U2)(),[q,M]=s.useState(P),[O,F]=s.useState(Boolean(t)),[B,U]=s.useState(!1),[z,V]=s.useState(!1),[G,W]=s.useState(""),[$,H]=s.useState([]),[J,Q]=s.useState(!1),Y=(0,Z.Nr)(G,300),K=Boolean(t||q.id);(0,Z.gt)(B,"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!"),s.useEffect(()=>{if(!t){F(!1);return}let e=!1;return(async()=>{try{var a;F(!0);let n=await N.ZP.get("/professional/by/".concat(t));if(e)return;if(F(!1),null===(a=n.data)||void 0===a?void 0:a.error){v.Am.error(n.data.error.message||"Cadastro n\xe3o encontrado");return}V(!0),M(A(n.data))}catch(t){if(e)return;F(!1),v.Am.error(t.message||"Cadastro n\xe3o encontrado")}})(),()=>{e=!0}},[t]),s.useEffect(()=>{if(!Y||String(Y).trim().length<2){H([]);return}let e=!1;return(async()=>{try{var t,a;Q(!0);let n=await N.ZP.get("/professional/list?search=".concat(encodeURIComponent(String(Y).trim()),"&limit=20"));if(e||(Q(!1),null===(t=n.data)||void 0===t?void 0:t.error))return;H(function(e){let t=[];for(let n of e||[]){var a;let e=(null===(a=n.members)||void 0===a?void 0:a.length)?n.members:[{name:n.name,contacts:n.contacts}];for(let a of e){let e=I(a,n);t.push({...e,cadastroName:n.name,cadastroSlug:n.slug,label:e.name})}}return t}((null===(a=n.data)||void 0===a?void 0:a.professionals)||[]))}catch(t){if(e)return;Q(!1),v.Am.error(t.message)}})(),()=>{e=!0}},[Y]);let X=_(q.members),ee=q.professionalId||q.id;function et(e){return(0,k.k6)(_(e)||"")}function ea(e){U(!0),M(t=>({...t,...e}))}function en(e,t){let a=(null==t||!t.resetName)&&z;(null==t?void 0:t.resetName)&&V(!1),U(!0),M(t=>({...t,members:e,...function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:z,n=_(e),s=a?t.name:n||t.name;return{name:s,slug:et(e)||(0,k.k6)(s||"")}}(e,t,a)}))}function es(e,t){let a=[...q.members||[]];a[e]={...a[e],...t,contacts:{...a[e].contacts,...t.contacts}},en(a)}function ei(){if(a)return(0,p.Mr)();R.replace("/admin")}function er(){B?(0,x.Z)({text:"Voc\xea fez algumas altera\xe7\xf5es que n\xe3o foram salvas!",onConfirm:ei}):ei()}async function el(e,t,a){let n=a?(0,k.GZ)({...t,members:JSON.stringify(t.members)}):t;return e?N.ZP.put("/professional/".concat(e),n):N.ZP.post("/professional",n)}async function eo(){try{var e,t,n,s,i;let r=(q.members||[]).filter(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.trim()}).map(e=>{var t,a,n;return{professionalId:e.professionalId,memberId:e.memberId,legacyUserId:e.legacyUserId,userId:e.userId,name:e.name.trim(),avatar:e.avatar,biography:e.biography,bi
1ographyEn:e.biographyEn,biographyEs:e.biographyEs,activityArea:e.activityArea,contacts:{email:(null===(t=e.contacts)||void 0===t?void 0:t.email)||"",website:(null===(a=e.contacts)||void 0===a?void 0:a.website)||"",instagram:C(null===(n=e.contacts)||void 0===n?void 0:n.instagram).split(";").map(e=>e.trim()).filter(Boolean)}}});if(!r.length)throw Error("Informe pelo menos um arquiteto");r[0]={...r[0],biography:{...r[0].biography||{},text:q.description||(null===(e=r[0].biography)||void 0===e?void 0:e.text)||""}};let l=(null===(t=q.name)||void 0===t?void 0:t.trim())||_(r),o=q.professionalId||q.id,d=await E(et(r)||(0,k.k6)(l),o);a||L(!0,"Salvando cadastro");let c={name:l,slug:d,description:q.description||"",visible:!1!==q.visible,members:r},u=q.avatar,m="undefined"!=typeof Blob&&u instanceof Blob;"string"==typeof u&&u&&(c.avatar=u);let h=m?await el(K?o:void 0,{...c,avatar:u},!0):await el(K?o:void 0,c,!1);if(m&&(null===(n=h.data)||void 0===n?void 0:null===(s=n.error)||void 0===s?void 0:s.message)==="name_required"&&(h=await el(K?o:void 0,c,!1)),a||L(),null===(i=h.data)||void 0===i?void 0:i.error)throw Error(h.data.error.message||"Erro ao salvar cadastro");let x=h.data.professional||h.data;M(A(x)),U(!1),v.Am.success(K?"Cadastro atualizado":"Cadastro criado"),null==D||D(x),(a||!K)&&ei()}catch(e){a||L(),v.Am.error(e.message)}}s.useEffect(()=>{let e=(0,k.k6)(X||"");if(!e)return;let t=!1;return(async()=>{let a=await E(e,ee);t||M(e=>e.slug===a?e:{...e,slug:a})})(),()=>{t=!0}},[X,ee]);let ed=(q.members||[]).map(e=>e.memberId||e.legacyUserId||e.professionalId),ec=$.filter(e=>!ed.includes(e.memberId||e.legacyUserId||e.professionalId));return O?(0,n.jsx)("div",{className:"forms cadastro-form",children:(0,n.jsx)(g.aN,{message:"Carregando cadastro"})}):(0,n.jsx)("div",{className:"forms cadastro-form",children:(0,n.jsxs)("div",{className:"form",children:[(0,n.jsx)(j.Z,{title:K?"Edi\xe7\xe3o de cadastro":"Novo cadastro",onGoBack:er,data:q.id?{id:"".concat(q.professionalId||q.id," (cadastro-id)"),updatedAt:q.updatedAt||"",lastUpdatedBy:{name:""}}:void 0}),(0,n.jsxs)("div",{className:"form-content",children:[(0,n.jsxs)("div",{className:"avatar-block",children:[(0,n.jsx)(f.Z,{refId:"cadastro-avatar",round:!0,maxWidthOrHeight:500,onChange:e=>ea({avatar:e}),renderBtn:(0,n.jsx)("label",{className:"image",children:(0,n.jsx)(b.Z,{src:(0,k.e6)(q.avatar),layout:"fill"})})}),(0,n.jsx)("p",{className:"avatar-hint",children:"Foto \xfanica do cadastro"})]}),(0,n.jsx)(i.Z,{className:"textfield",label:"Nome do cadastro",value:q.name||"",helperText:"Montado com os nomes dos arquitetos. Voc\xea pode ajustar.",onChange:e=>{V(!0),ea({name:e.target.value})}}),(0,n.jsx)(i.Z,{className:"textfield",label:"Slug / URL",value:q.slug||"",helperText:"Gerado automaticamente pelos nomes. Se j\xe1 existir, vira nome-2, nome-3…",disabled:!0,InputProps:{readOnly:!0}}),(0,n.jsx)(r.Z,{control:(0,n.jsx)(l.Z,{checked:!1!==q.visible,onChange:(e,t)=>
1ea({visible:t})}),label:"Vis\xedvel no site"}),(0,n.jsx)("h3",{children:"Bio"}),(0,n.jsx)("div",{className:"markdown-container",children:(0,n.jsx)(y.Z,{compact:!0,initValue:q.description||"",onChange:e=>ea({description:e})},q.professionalId||"new")}),(0,n.jsxs)("div",{className:"members-head",children:[(0,n.jsx)("h3",{children:"Arquitetos neste cadastro"}),(0,n.jsx)(o.Z,{variant:"outlined",startIcon:(0,n.jsx)(m.Z,{}),onClick:()=>en([...q.members||[],S()]),children:"Novo arquiteto"})]}),(0,n.jsx)(d.Z,{className:"architect-search",options:ec,filterOptions:e=>e,inputValue:G,value:null,loading:J,noOptionsText:G.trim().length<2?"Digite para buscar um arquiteto j\xe1 cadastrado":"Nenhum arquiteto encontrado",getOptionLabel:e=>"string"==typeof e?e:e.cadastroName&&e.cadastroName!==e.name?"".concat(e.name," \xb7 ").concat(e.cadastroName):e.name,isOptionEqualToValue:(e,t)=>T(e,t),onInputChange:(e,t,a)=>{"reset"!==a&&W(t)},onChange:(e,t)=>(function(e){if(!(null==e?void 0:e.name))return;let t=q.members||[];if(t.some(t=>T(t,e))){v.Am.info("Este arquiteto j\xe1 est\xe1 no cadastro");return}let{label:a,cadastroName:n,cadastroSlug:s,...i}=e,r=[...t],l=r.findIndex(e=>{var t;return!(null===(t=e.name)||void 0===t?void 0:t.trim())&&!e.professionalId&&!e.memberId});l>=0?r[l]=i:r.push(i),en(r,{resetName:!0}),W(""),H([])})(t),componentsProps:{popper:{className:"cadastro-architect-popper"}},renderOption:(e,t)=>{var a;return(0,s.createElement)("li",{...e,key:"".concat(t.memberId||t.professionalId,"-").concat(t.name),children:[(0,n.jsx)("span",{className:"opt-avatar",children:(0,n.jsx)(b.Z,{src:t.avatar,width:40,height:40})}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:t.name}),(0,n.jsx)("small",{children:[t.cadastroSlug,null===(a=t.contacts)||void 0===a?void 0:a.email].filter(Boolean).join(" \xb7 ")})]})]})},renderInput:e=>(0,n.jsx)(i.Z,{...e,className:"textfield",label:"Incluir arquiteto j\xe1 existente",placeholder:"Busque por nome ou slug",InputProps:{...e.InputProps,endAdornment:(0,n.jsxs)(n.Fragment,{children:[J&&(0,n.jsx)(c.Z,{color:"inherit",size:18}),e.InputProps.endAdornment]})}})}),(0,n.jsx)("ul",{className:"members",children:(q.members||[]).map((e,t)=>{var a,s,r;return(0,n.jsxs)("li",{className:"member-card",children:[(0,n.jsxs)("div",{className:"member-card-head",children:[(0,n.jsxs)("strong",{children:["Arquiteto ",t+1,e.fromExisting?(0,n.jsx)("span",{className:"badge",children:"j\xe1 cadastrado"}):null]}),(q.members||[]).length>1&&(0,n.jsx)(u.Z,{size:"small",onClick:()=>en((q.members||[]).filter((e,a)=>a!==t)),children:(0,n.jsx)(h.Z,{fontSize:"small"})})]}),(0,n.jsx)(i.Z,{className:"textfield",label:"Nome",value:e.name||"",onChange:e=>es(t,{name:e.target.value})}),(0,n.jsx)(i.Z,{className:"textfield",label:"Email",value:(null===(a=e.contacts)||void 0===a?void 0:a.email)||"",onChange:e=>es(t,{contacts:{email:e.target.value}})}),(0,n.jsx)(i.Z,{className:"textfield",label:"Site",value:(null===(s=e.contacts)||void 0===s?void 0:s.website)||"",onChange:e=>es(t,{contacts:{website:e.target.value}})}),(0,n.jsx)(i.Z,{className:"textfield",label:"Instagram",value:(null===(r=e.contacts)||void 0===r?void 0:r.instagram)||"",onChange:e=>es(t,{contacts:{instagram:e.target.value}})})]},e.memberId||e.professionalId||t)})}),(0,n.jsxs)("div",{className:"actions",children:[K&&(0,n.jsx)(o.Z,{className:"remove-btn",variant:"text",color:"error",onClick:function(){if(!K)return;let e=q.professionalId||q.id;e&&(0,x.Z)({title:"Excluir profissional",text:'Esta a\xe7\xe3o \xe9 irrevers\xedvel na listagem. O cadastro "'.concat(q.name||"sem nome",'" ser\xe1 marcado como exclu\xeddo.<br/><br/>Digite <b>EXCLUIR</b> para confirmar.'),icon:"warning",confirmButtonText:"Excluir profissional",cancelButtonText:"Cancelar",confirmWord:"EXCLUIR",onConfirm:async()=>{try{var t;a||L(!0,"Excluindo profissional");let n=await N.ZP.delete("/professional/".concat(e));if(a||L(),null===(t=n.data)||void 0===t?void 0:t.error)throw Error(n.data.error.message||"Erro ao excluir profissional");v.Am.success("Profissional exclu\xeddo"),U(!1),null==D||D(n.data.professional||n.data),ei()}catch(e){a||L(),v.Am.error(e.message)}}})},children:"Excluir profissional"}),(0,n.jsx)(o.Z,{variant:"outlined",onClick:er,children:"Fechar"}),(0,n.jsx)(o.Z,{variant:"contained",onClick:eo,children:"Salvar"})]})]})]})})};t.Z=R},54007:function(e,t,a){"use strict";var n=a(85893),s=a(78298),i=a(93946);a(67294);var r=a(77058),l=a(46870);let o=e=>{var t,a,o;let{title:d,subTitle:c,onGoBack:u,...m}=e,h=(null==m?void 0:m.data)||{},{t:v,i18n:x}=(0,r.$)("admin"),p=(t=null==h?void 0:h.lastUpdatedBy)?"string"==typeof t?/^[a-f\d]{24}$/i.test(t)?"-":t.trim()||"-":(null===(a=t.name)||void 0===a?void 0:a.trim())||(null===(o=t.email)||void 0===o?void 0:o.trim())||"-":"-";return(0,n.jsxs)("div",{className:"form-header",children:[(0,n.jsx)(i.Z,{size:"large",onClick:u,children:(0,n.jsx)(s.Z,{})}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("h2",{children:[d,(null==h?void 0:h.id)&&!!(null==h?void 0:h.id)&&(0,n.jsxs)("div",{className:"id",children:["ID:"," ",(null==h?void 0:h.linkForId)?(0,n.jsx)("a",{className:"link",href:null==h?void 0:h.linkForId,target:"_blank",rel:"noreferrer",children:h.id}):h.id]})]}),c&&(0,n.jsx)("h3",{children:c})]}),!!(null==h?void 0:h.updatedAt)&&(0,n.jsxs)("div",{className:"update-info",children:[(0,n.jsxs)("div",{className:"id",children:["".concat(v("last_update")),": ",(0,l.p6)(h.updatedAt,"Pp",x.language)]}),(0,n.jsxs)("div",{className:"id",children:["".concat(v("last_update_by")),": ",p]})]})]})};t.Z=o},62126:function(e,t,a){"use strict";var n=a(67294),s=a(62286),i=a(72132),r=a(9669),l=a.n(r),o=a(8100),d=a(20483);let c=l().create({baseURL:"https://apiv2.appcasacor.com.br"});c.interceptors.request.use(async e=>{let t=(0,s.parseCookies)(),a=t[d.Y5];return a&&e.headers&&(e.headers.Authorization="Bearer ".concat(a)),e});let u=e=>c.get(e).then(e=>e);t.Z=function(e){var t,a;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{enabled:!0},[r,l]=n.useState(0),{data:d,error:c}=(0,o.ZP)(s.enabled?e+"".concat(e.includes("?")?"&":"?","refresh=")+r:null,u),m=!c&&!d&&s.enabled,h=n.useRef([]);return n.useEffect(()=>{var e;(null==d?void 0:null===(e=d.data)||void 0===e?void 0:e.error)?((null==d?void 0:d.data.error.message)&&i.Am.error(null==d?void 0:d.data.error.message,{toastId:"useSWR.error"}),i.Am.error(JSON.stringify(null==d?void 0:d.data.error),{toastId:"useSWR.error"})):(null==d?void 0:d.data)&&(h.current=d.data)},[d]),{isLoading:m,refresh:()=>l(Date.now()),data:m?h.current:(null==d?void 0:null===(t=d.data)||void 0===t?void 0:t.error)?void 0:null==d?void 0:d.data,error:(null==d?void 0:null===(a=d.data)||void 0===a?void 0:a.error)||
1c}}},46870:function(e,t,a){"use strict";a.d(t,{Au:function(){return j},GT:function(){return k},MQ:function(){return p},O:function(){return m},Rg:function(){return b},U6:function(){return w},Y5:function(){return u},YR:function(){return d},j9:function(){return Z},mX:function(){return h},mr:function(){return f},nv:function(){return v},oJ:function(){return y},p6:function(){return c},qb:function(){return C},tE:function(){return g},uP:function(){return x},y5:function(){return N}});var n=a(61436),s=a(32912),i=a(29081),r=a(95826),l=a(99490);let o={pt:i.Z,en:r.Z},d="America/Sao_Paulo";function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"PPPP",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"pt";if(!e)return;if(!(0,n.Z)(new Date(e)))return"".concat(e);let i=(0,s.Z)(new Date(e),t,{locale:o[a]});return i}function u(){return new Date().getTimezoneOffset()}function m(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return{year:NaN,month:NaN,day:NaN};if(0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds())return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()};let a=l.ou.fromJSDate(t,{zone:d});return a.isValid?{year:a.year,month:a.month,day:a.day}:{year:NaN,month:NaN,day:NaN}}function h(e){let{year:t,month:a,day:n}=m(e);return Number.isNaN(t)?"":"".concat(t,"-").concat(String(a).padStart(2,"0"),"-").concat(String(n).padStart(2,"0"))}function v(e,t){let a=h(e),n=h(t);return Boolean(a&&n&&a===n)}function x(e){let{year:t,month:a,day:n}=m(e);return Number.isNaN(t)?"NaN":new Date(Date.UTC(t,a-1,n,12)).getUTCDay().toString()}function p(e,t){let a=h(e),n=h(t);return!!a&&!!n&&a>n}function g(e){let{year:t,month:a,day:n}=m(e);return Number.isNaN(t)?new Date(NaN):new Date(t,a-1,n)}function j(){return l.ou.now().toJSDate()}function f(e,t){let{year:a,month:n,day:s}=m(e);if(Number.isNaN(a))return new Date(NaN);let[i="0",r="0"]=t.split(":");return l.ou.fromObject({year:a,month:n,day:s,hour:Number(i)||0,minute:Number(r)||0,second:0,millisecond:0},{zone:d}).toJSDate()}function b(e,t){let[a="00:00",n="23:00"]=(t||"").split("-");return{start:f(e,a),end:f(e,n)}}function y(e){let t=l.ou.fromJSDate(new Date(e));return!t.isValid||t.toMillis()<l.ou.now().toMillis()}function N(e,t){return new Date(e).getTime()>new Date(t).getTime()}function k(e,t){return new Date(e).getTime()<new Date(t).getTime()}function w(e,t){return(null==t?void 0:t.onlyToday)?g(j()):g(e)}function Z(e,t){return(null==t?void 0:t.onlyToday)?g(j()):g(e)}function C(e){return(0,n.Z)(new Date(e))}},62672:function(e,t,a){"use strict";a.d(t,{L6:function(){return c},Nr:function(){return l},gt:function(){return d},ss:function(){return o}});var n=a(67294),s=a(11163),i=a.n(s),r=a(3990);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,[a,s]=n.useState(e);return n.useEffect(()=>{let a=setTimeout(()=>{s(e)},t);return()=>{clearTimeout(a)}},[t,e]),a}function o(e,t){let a=n.useRef(!0);n.useEffect(()=>{if(a.current){a.current=!1;return}e()},t)}let d=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Are you sure want to leave this page?";(0,r.Z)(e,t),(0,n.useEffect)(()=>{let a=()=>{if(e&&!window.confirm(t))throw"Route Canceled"};return i().events.on("beforeHistoryChange",a),()=>{i().events.off("beforeHistoryChange",a)}},[e,t])},c=()=>{let[e,t]=n.useState(0);return function(){t(e=>e+1)}}},82711:function(e,t,a){"use strict";a.d(t,{$I:function(){return o},OF:function(){return l},Zc:function(){return r},eU:function(){return s},gU:function(){return i}});var n=a(46870);function s(e){return String(e||"").replace(/<[^>]*>/g," ").replace(/&nbsp;/gi," ").replace(/\s+/g," ").trim()}function i(e){return s(e).length>0}function r(e,t){if((null==e?void 0:e.length)&&t)return e.find(e=>(0,n.nv)(e.date,t))}function l(e,t){let a=r(e,t);return Boolean(a&&!1!==a.blockSale)}function o(e,t){let a=e.noticeDates;if(null==a?void 0:a.length){if("passport"===e.type)return r(a,new Date);if(t){let e=r(a,t);if(e)return e}return r(a,new Date)}}},20067:function(){},72061:function(){}},function(e){e.O(0,[9774,9809,2554,2251,2196,7847,5443,9755,3243,135,6455,1237,3034,1642,5089,246,811,6022,6273,3607,1653,8083,8323,1460,9770,9268,2888,179],function(){return e(e.s=64830)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.