1import{aP as hr,j as i,aY as mr,aD as vt,a9 as Ue,ao as Ve,T as Y,ab as Ne,H as gr,a7 as pe,I as yr,at as vr,n as xt,ar as bt,ac as wt,ae as xr,a6 as br,z as wr,N as Sr}from"./mui-CRsYZxVY.js";import{b as J,r as Q}from"./vendor-Dwao9eNC.js";import{dt as jr,aM as Mt,aw as Cr,bT as $r,bo as Te,w as z,cW as Ir,u as zt,t as Er,l as _r,b1 as kr,ch as Dr,b0 as Ar,bp as Rr,b as Pr,J as Nr,bc as Tr,C as Or,cF as Mr,T as zr,eC as Lr,dU as Br,dO as qr,j0 as Fr}from"./index-TALscxEc.js";import{b as ge,a as R}from"./tslib.es6-DPrcv4p0.js";import{u as Lt}from"./useProduct-BltDnkHr.js";import{p as Wr}from"./parseMessage-BE7jpFco.js";import{a as Qr,az as St}from"./icons-D8aatgQ4.js";import{a as ve,u as Yr,b as ze}from"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./lab-DSem1Osk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5444fb74-bc4f-4bcb-a823-3260863aae88",e._sentryDebugIdIdentifier="sentry-dbid-5444fb74-bc4f-4bcb-a823-3260863aae88")})()}catch{}var ut={},Gr=hr;Object.defineProperty(ut,"__esModule",{value:!0});var Bt=ut.default=void 0,Hr=Gr(jr()),Kr=i;Bt=ut.default=(0,Hr.default)((0,Kr.jsx)("path",{d:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"}),"Send");var j="-ms-",me="-moz-",x="-webkit-",qt="comm",Le="rule",dt="decl",Ur="@import",Ft="@keyframes",Vr="@layer",Wt=Math.abs,ft=String.fromCharCode,tt=Object.assign;function Jr(e,t){return k(e,0)^45?(((t<<2^k(e,0))<<2^k(e,1))<<2^k(e,2))<<2^k(e,3):0}function Qt(e){return e.trim()}function B(e,t){return(e=t.exec(e))?e[0]:e}function l(e,t,r){return e.replace(t,r)}function ke(e,t,r){return e.indexOf(t,r)}function k(e,t){return e.charCodeAt(t)|0}function ne(e,t,r){return e.slice(t,r)}function M(e){return e.length}function Yt(e){return e.length}function he(e,t){return t.push(e),e}function Zr(e,t){return e.map(t).join("")}function jt(e,t){return e.filter(function(r){return!B(r,t)})}var Be=1,se=1,Gt=0,P=0,_=0,ce="";function qe(e,t,r,n,s,o,a,c){return{value:e,root:t,parent:r,type:n,props:s,children:o,line:Be,column:se,length:a,return:"",siblings:c}}function W(e,t){return tt(qe("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function te(e){for(;e.root;)e=W(e.root,{children:[e]});he(e,e.siblings)}function Xr(){return _}function en(){return _=P>0?k(ce,--P):0,se--,_===10&&(se=1,Be--),_}function T(){return _=P<Gt?k(ce,P++):0,se++,_===10&&(se=1,Be++),_}function U(){return k(ce,P)}function De(){return P}function Fe(e,t){return ne(ce,e,t)}function rt(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function tn(e){return Be=se=1,Gt=M(ce=e),P=0,[]}function rn(e){return ce="",e}function Je(e){return Qt(Fe(P-1,nt(e===91?e+2:e===40?e+1:e)))}function nn(e){for(;(_=U())&&_<33;)T();return rt(e)>2||rt(_)>3?"":" "}function sn(e,t){for(;--t&&T()&&!(_<48||_>102||_>57&&_<65||_>70&&_<97););return Fe(e,De()+(t<6&&U()==32&&T()==32))}function nt(e){for(;T();)switch(_){case e:return P;case 34:case 39:e!==34&&e!==39&&nt(_);break;case 40:e===41&&nt(e);break;case 92:T();break}return P}function on(e,t){for(;T()&&e+_!==57;)if(e+_===84&&U()===47)break;return"/*"+Fe(t,P-1)+"*"+ft(e===47?e:T())}function an(e){for(;!rt(U());)T();return Fe(e,P)}function cn(e){return rn(Ae("",null,null,null,[""],e=tn(e),0,[0],e))}function Ae(e,t,r,n,s,o,a,c,u){for(var d=0,h=0,m=a,y=0,g=0,w=0,C=1,D=1,$=1,S=0,f="",b=s,E=o,v=n,p=f;D;)switch(w=S,S=T()){case 40:if(w!=108&&k(p,m-1)==58){ke(p+=l(Je(S),"&","&\f"),"&\f",Wt(d?c[d-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:p+=Je(S);break;case 9:case 10:case 13:case 32:p+=nn(w);break;case 92:p+=sn(De()-1,7);continue;case 47:switch(U()){case 42:case 47:he(un(on(T(),De()),t,r,u),u);break;default:p+="/"}break;case 123*C:c[d++]=M(p)*$;case 125*C:case 59:case 0:switch(S){case 0:case 125:D=0;case 59+h:$==-1&&(p=l(p,/\f/g,"")),g>0&&M(p)-m&&he(g>32?$t(p+";",n,r,m-1,u):$t(l(p," ","")+";",n,r,m-2,u),u);break;case 59:p+=";";default:if(he(v=Ct(p,t,r,d,h,s,c,f,b=[],E=[],m,o),o),S===123)if(h===0)Ae(p,t,v,v,b,o,m,c,E);else switch(y===99&&k(p,3)===110?100:y){case 100:case 108:case 109:case 115:Ae(e,v,v,n&&he(Ct(e,v,v,0,0,s,c,f,s,b=[],m,E),E),s,E,m,c,n?b:E);break;default:Ae(p,v,v,v,[""],E,0,c,E)}}d=h=g=0,C=$=1,f=p="",m=a;break;case 58:m=1+M(p),g=w;default:if(C<1){if(S==123)--C;else if(S==125&&C++==0&&en()==125)continue}switch(p+=ft(S),S*C){case 38:$=h>0?1:(p+="\f",-1);break;
1case 44:c[d++]=(M(p)-1)*$,$=1;break;case 64:U()===45&&(p+=Je(T())),y=U(),h=m=M(f=p+=an(De())),S++;break;case 45:w===45&&M(p)==2&&(C=0)}}return o}function Ct(e,t,r,n,s,o,a,c,u,d,h,m){for(var y=s-1,g=s===0?o:[""],w=Yt(g),C=0,D=0,$=0;C<n;++C)for(var S=0,f=ne(e,y+1,y=Wt(D=a[C])),b=e;S<w;++S)(b=Qt(D>0?g[S]+" "+f:l(f,/&\f/g,g[S])))&&(u[$++]=b);return qe(e,t,r,s===0?Le:c,u,d,h,m)}function un(e,t,r,n){return qe(e,t,r,qt,ft(Xr()),ne(e,2,-2),0,n)}function $t(e,t,r,n,s){return qe(e,t,r,dt,ne(e,0,n),ne(e,n+1,-1),n,s)}function Ht(e,t,r){switch(Jr(e,t)){case 5103:return x+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return x+e+e;case 4789:return me+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return x+e+me+e+j+e+e;case 5936:switch(k(e,t+11)){case 114:return x+e+j+l(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return x+e+j+l(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return x+e+j+l(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return x+e+j+e+e;case 6165:return x+e+j+"flex-"+e+e;case 5187:return x+e+l(e,/(\w+).+(:[^]+)/,x+"box-$1$2"+j+"flex-$1$2")+e;case 5443:return x+e+j+"flex-item-"+l(e,/flex-|-self/g,"")+(B(e,/flex-|baseline/)?"":j+"grid-row-"+l(e,/flex-|-self/g,""))+e;case 4675:return x+e+j+"flex-line-pack"+l(e,/align-content|flex-|-self/g,"")+e;case 5548:return x+e+j+l(e,"shrink","negative")+e;case 5292:return x+e+j+l(e,"basis","preferred-size")+e;case 6060:return x+"box-"+l(e,"-grow","")+x+e+j+l(e,"grow","positive")+e;case 4554:return x+l(e,/([^-])(transform)/g,"$1"+x+"$2")+e;case 6187:return l(l(l(e,/(zoom-|grab)/,x+"$1"),/(image-set)/,x+"$1"),e,"")+e;case 5495:case 3959:return l(e,/(image-set\([^]*)/,x+"$1$`$1");case 4968:return l(l(e,/(.+:)(flex-)?(.*)/,x+"box-pack:$3"+j+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+x+e+e;case 4200:if(!B(e,/flex-|baseline/))return j+"grid-column-align"+ne(e,t)+e;break;case 2592:case 3360:return j+l(e,"template-","")+e;case 4384:case 3616:return r&&r.some(function(n,s){return t=s,B(n.props,/grid-\w+-end/)})?~ke(e+(r=r[t].value),"span",0)?e:j+l(e,"-start","")+e+j+"grid-row-span:"+(~ke(r,"span",0)?B(r,/\d+/):+B(r,/\d+/)-+B(e,/\d+/))+";":j+l(e,"-start","")+e;case 4896:case 4128:return r&&r.some(function(n){return B(n.props,/grid-\w+-start/)})?e:j+l(l(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return l(e,/(.+)-inline(.+)/,x+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(M(e)-1-t>6)switch(k(e,t+1)){case 109:if(k(e,t+4)!==45)break;case 102:return l(e,/(.+:)(.+)-([^]+)/,"$1"+x+"$2-$3$1"+me+(k(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~ke(e,"stretch",0)?Ht(l(e,"stretch","fill-available"),t,r)+e:e}break;case 5152:case 5920:return l(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,o,a,c,u,d){return j+s+":"+o+d+(a?j+s+"-span:"+(c?u:+u-+o)+d:"")+e});case 4949:if(k(e,t+6)===121)return l(e,":",":"+x)+e;break;case 6444:switch(k(e,k(e,14)===45?18:11)){case 120:return l(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+x+(k(e,14)===45?"inline-":"")+"box$3$1"+x+"$2$3$1"+j+"$2box$3")+e;case 100:return l(e,":",":"+j)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return l(e,"scroll-","scroll-snap-")+e}return e}function Oe(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function dn(e,t,r,n){switch(e.type){case Vr:if(e.children.length)break;case Ur:case dt:return e.return=e.return||e.value;case qt:return"";case Ft:return e.return=e.value+"{"+Oe(e.children,n)+"}";case Le:if(!M(e.value=e.props.join(",")))return""}return M(r=Oe(e.children,n))?e.return=e.value+"{"+r+"}":""}function fn(e){var t=Yt(e);return function(r,n,s,o){for(var a="",c=0;c<t;c++)a+=e[c](r,n,s,o)||"";return a}}function ln(e){return function(t){t.root||(t=t.return)&&e(t)}}function pn(e,t,r,n){if(e.length>-1&&!e.return)switch(e.type){case dt:e.return=Ht(e.value,e.length,r);return;case Ft:return Oe([W(e,{value:l(e.value,"@","@"+x)})],n);case Le:if(e.length)return Zr(r=e.props,function(s){switch(B(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":te(W(e,{props:[l(s,/:(read-\w+)/,":"+me+"$1")]}
1)),te(W(e,{props:[s]})),tt(e,{props:jt(r,n)});break;case"::placeholder":te(W(e,{props:[l(s,/:(plac\w+)/,":"+x+"input-$1")]})),te(W(e,{props:[l(s,/:(plac\w+)/,":"+me+"$1")]})),te(W(e,{props:[l(s,/:(plac\w+)/,j+"input-$1")]})),te(W(e,{props:[s]})),tt(e,{props:jt(r,n)});break}return""})}}var A={},oe=typeof process<"u"&&A!==void 0&&(A.REACT_APP_SC_ATTR||A.SC_ATTR)||"data-styled",Kt="active",Ut="data-styled-version",We="6.1.11",lt=`/*!sc*/ 2`,pt=typeof window<"u"&&"HTMLElement"in window,hn=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&A!==void 0&&A.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&A.REACT_APP_SC_DISABLE_SPEEDY!==""?A.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&A.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&A!==void 0&&A.SC_DISABLE_SPEEDY!==void 0&&A.SC_DISABLE_SPEEDY!==""&&A.SC_DISABLE_SPEEDY!=="false"&&A.SC_DISABLE_SPEEDY),Qe=Object.freeze([]),ae=Object.freeze({});function mn(e,t,r){return r===void 0&&(r=ae),e.theme!==r.theme&&e.theme||t||r.theme}var Vt=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),gn=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,yn=/(^-|-$)/g;function It(e){return e.replace(gn,"-").replace(yn,"")}var vn=/(a)(d)/gi,Ee=52,Et=function(e){return String.fromCharCode(e+(e>25?39:97))};function st(e){var t,r="";for(t=Math.abs(e);t>Ee;t=t/Ee|0)r=Et(t%Ee)+r;return(Et(t%Ee)+r).replace(vn,"$1-$2")}var Ze,Jt=5381,re=function(e,t){for(var r=t.length;r;)e=33*e^t.charCodeAt(--r);return e},Zt=function(e){return re(Jt,e)};function Xt(e){return st(Zt(e)>>>0)}function xn(e){return e.displayName||e.name||"Component"}function Xe(e){return typeof e=="string"&&!0}var er=typeof Symbol=="function"&&Symbol.for,tr=er?Symbol.for("react.memo"):60115,bn=er?Symbol.for("react.forward_ref"):60112,wn={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Sn={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},rr={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},jn=((Ze={})[bn]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Ze[tr]=rr,Ze);function _t(e){return("type"in(t=e)&&t.type.$$typeof)===tr?rr:"$$typeof"in e?jn[e.$$typeof]:wn;var t}var Cn=Object.defineProperty,$n=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,In=Object.getOwnPropertyDescriptor,En=Object.getPrototypeOf,Dt=Object.prototype;function nr(e,t,r){if(typeof t!="string"){if(Dt){var n=En(t);n&&n!==Dt&&nr(e,n,r)}var s=$n(t);kt&&(s=s.concat(kt(t)));for(var o=_t(e),a=_t(t),c=0;c<s.length;++c){var u=s[c];if(!(u in Sn||r&&r[u]||a&&u in a||o&&u in o)){var d=In(t,u);try{Cn(e,u,d)}catch{}}}}return e}function ie(e){return typeof e=="function"}function ht(e){return typeof e=="object"&&"styledComponentId"in e}function K(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function ot(e,t){if(e.length===0)return"";for(var r=e[0],n=1;n<e.length;n++)r+=t?t+e[n]:e[n];return r}function ye(e){return e!==null&&typeof e=="object"&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function at(e,t,r){if(r===void 0&&(r=!1),!r&&!ye(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var n=0;n<t.length;n++)e[n]=at(e[n],t[n]);else if(ye(t))for(var n in t)e[n]=at(e[n],t[n]);return e}function mt(e,t){Object.defineProperty(e,"toString",{value:t})}function xe(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):""))}var _n=function(){function e(t){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=t}return e.prototype.indexOfGroup=function(t){for(var r=0,n=0;n<t;n++)r+=this.groupSizes[n];return r},e.prototype.insertRules=function(t,r){if(t>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,o=s;t>=o;)if((o<<=1)<0)throw xe(16,"".concat(t));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var a=s;a<o;a++)this.groupSizes[a]=0}for(var c=this.indexOfGroup(t+1),u=(a=0,r.length);a<u;a++)this.tag.insertRule(c,r[a])&&(this.groupSizes[t]++,c++)},e.prototype.clearGroup=function(t){if(t<this.length){var r=this.groupSizes[t],n=this.indexOfGroup(t),s=n+r;this.groupSizes[t]=0;for(var o=n;o<s;o++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(t){var r="";if(t>=this.length||this.groupSizes[t]===0)return r;for(var n=this.groupSizes[t],s=this.indexOfGroup(t),o=s+n,a=s;a<o;a++)r+="".concat(this.tag.getRule(a)).concat(lt);return r},e}(),Re=new Map,Me=new Map,Pe=1,_e=function(e){if(Re.has(e))return Re.get(e);for(;Me.has(Pe);)Pe++;var t=Pe++;return Re.set(e,t),Me.set(t,e),t},kn=function(e,t){Pe=t+1,Re.set(e,t),Me.set(t,e)},Dn="style[".concat(oe,"][").concat(Ut,'="').concat(We,'"]'),An=new RegExp("^".concat(oe,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Rn=function(e,t,r){for(var n,s=r.split(","),o=0,a=s.length;o<a;o++)(n=s[o])&&e.registerName(t,n)},Pn=function(e,t){for(var r,n=((r=t.textContent)!==null&&r!==void 0?r:"").split(lt),s=[],o=0,a=n.length;o<a;o++){var c=n[o].trim();if(c){var u=c.match(An);if(u){var d=0|parseInt(u[1],10),h=u[2];d!==0&&(kn(h,d),Rn(e,h,u[3]),e.getTag().insertRules(d,s)),s.length=0}else s.push(c)}}};function Nn(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var sr=function(e){var t=document.head,r=e||t,n=document.createElement("style"),s=function(c){var u=Array.from(c.querySelectorAll("style[".concat(oe,"]")));return u[u.length-1]}(r),o=s!==void 0?s.nextSibling:null;n.setAttribute(oe,Kt),n.setAttribute(Ut,We);var a=Nn();return a&&n.setAttribute("nonce",a),r.insertBefore(n,o),n},Tn=function(){function e(t){this.element=sr(t),this.element.appendChild(document.createTextNode("")),this.sheet=function(r){if(r.sheet)return r.sheet;for(var n=document.styleSheets,s=0,o=n.length;s<o;s++){var a=n[s];if(a.ownerNode===r)return a}throw xe(17)}(this.element),this.length=0}return e.prototype.insertRule=function(t,r){try{return this.sheet.insertRule(r,t),this.length++,!0}catch{return!1}},e.prototype.deleteRule=function(t){this.sheet.deleteRule(t),this.length--},e.prototype.getRule=function(t){var r=this.sheet.cssRules[t];return r&&r.cssText?r.cssText:""},e}(),On=function(){function e(t){this.element=sr(t),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(t,r){if(t<=this.length&&t>=0){var n=document.createTextNode(r);return this.element.insertBefore(n,this.nodes[t]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(t){this.element.removeChild(this.nodes[t]),this.length--},e.prototype.getRule=function(t){return t<this.length?this.nodes[t].textContent:""},e}(),Mn=function(){function e(t){this.rules=[],this.length=0}return e.prototype.insertRule=function(t,r){return t<=this.length&&(this.rules.splice(t,0,r),this.length++,!0)},e.prototype.deleteRule=function(t){this.rules.splice(t,1),this.length--},e.prototype.getRule=function(t){return t<this.length?this.rules[t]:""},e}(),At=pt,zn={isServer:!pt,useCSSOMInjection:!hn},or=function(){function e(t,r,n){t===void 0&&(t=ae),r===void 0&&(r={});var s=this;this.options=R(R({},zn),t),this.gs=r,this.names=new Map(n),this.server=!!t.isServer,!this.server&&pt&&At&&(At=!1,function(o){for(var a=document.querySelectorAll(Dn),c=0,u=a.length;c<u;c++){var d=a[c];d&&d.getAttribute(oe)!==Kt&&(Pn(o,d),d.parentNode&&d.parentNode.removeChild(d))}}(this)),mt(this,function(){return function(o){for(var a=o.getTag(),c=a.length,u="",d=function(m){var y=function($){return Me.get($)}(m);if(y===void 0)return"continue";var g=o.names.get(y),w=a.getGroup(m);if(g===void 0||w.length===0)return"continue";var C="".concat(oe,".g").concat(m,'[id="').concat(y,'"]'),D="";g!==void 0&&g.forEach(function($){$.length>0&&(D+="".concat($,","))}
2),u+="".concat(w).concat(C,'{content:"').concat(D,'"}').concat(lt)},h=0;h<c;h++)d(h);return u}(s)})}return e.registerId=function(t){return _e(t)},e.prototype.reconstructWithOptions=function(t,r){return r===void 0&&(r=!0),new e(R(R({},this.options),t),this.gs,r&&this.names||void 0)},e.prototype.allocateGSInstance=function(t){return this.gs[t]=(this.gs[t]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(t=function(r){var n=r.useCSSOMInjection,s=r.target;return r.isServer?new Mn(s):n?new Tn(s):new On(s)}(this.options),new _n(t)));var t},e.prototype.hasNameForId=function(t,r){return this.names.has(t)&&this.names.get(t).has(r)},e.prototype.registerName=function(t,r){if(_e(t),this.names.has(t))this.names.get(t).add(r);else{var n=new Set;n.add(r),this.names.set(t,n)}},e.prototype.insertRules=function(t,r,n){this.registerName(t,r),this.getTag().insertRules(_e(t),n)},e.prototype.clearNames=function(t){this.names.has(t)&&this.names.get(t).clear()},e.prototype.clearRules=function(t){this.getTag().clearGroup(_e(t)),this.clearNames(t)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Ln=/&/g,Bn=/^\s*\/\/.*$/gm;function ar(e,t){return e.map(function(r){return r.type==="rule"&&(r.value="".concat(t," ").concat(r.value),r.value=r.value.replaceAll(",",",".concat(t," ")),r.props=r.props.map(function(n){return"".concat(t," ").concat(n)})),Array.isArray(r.children)&&r.type!=="@keyframes"&&(r.children=ar(r.children,t)),r})}function qn(e){var t,r,n,s=e===void 0?ae:e,o=s.options,a=o===void 0?ae:o,c=s.plugins,u=c===void 0?Qe:c,d=function(y,g,w){return w.startsWith(r)&&w.endsWith(r)&&w.replaceAll(r,"").length>0?".".concat(t):y},h=u.slice();h.push(function(y){y.type===Le&&y.value.includes("&")&&(y.props[0]=y.props[0].replace(Ln,r).replace(n,d))}),a.prefix&&h.push(pn),h.push(dn);var m=function(y,g,w,C){g===void 0&&(g=""),w===void 0&&(w=""),C===void 0&&(C="&"),t=C,r=g,n=new RegExp("\\".concat(r,"\\b"),"g");var D=y.replace(Bn,""),$=cn(w||g?"".concat(w," ").concat(g," { ").concat(D," }"):D);a.namespace&&($=ar($,a.namespace));var S=[];return Oe($,fn(h.concat(ln(function(f){return S.push(f)})))),S};return m.hash=u.length?u.reduce(function(y,g){return g.name||xe(15),re(y,g.name)},Jt).toString():"",m}var Fn=new or,it=qn(),ir=J.createContext({shouldForwardProp:void 0,styleSheet:Fn,stylis:it});ir.Consumer;J.createContext(void 0);function Rt(){return Q.useContext(ir)}var cr=function(){function e(t,r){var n=this;this.inject=function(s,o){o===void 0&&(o=it);var a=n.name+o.hash;s.hasNameForId(n.id,a)||s.insertRules(n.id,a,o(n.rules,a,"@keyframes"))},this.name=t,this.id="sc-keyframes-".concat(t),this.rules=r,mt(this,function(){throw xe(12,String(n.name))})}return e.prototype.getName=function(t){return t===void 0&&(t=it),this.name+t.hash},e}(),Wn=function(e){return e>="A"&&e<="Z"};function Pt(e){for(var t="",r=0;r<e.length;r++){var n=e[r];if(r===1&&n==="-"&&e[0]==="-")return e;Wn(n)?t+="-"+n.toLowerCase():t+=n}return t.startsWith("ms-")?"-"+t:t}var ur=function(e){return e==null||e===!1||e===""},dr=function(e){var t,r,n=[];for(var s in e){var o=e[s];e.hasOwnProperty(s)&&!ur(o)&&(Array.isArray(o)&&o.isCss||ie(o)?n.push("".concat(Pt(s),":"),o,";"):ye(o)?n.push.apply(n,ge(ge(["".concat(s," {")],dr(o),!1),["}"],!1)):n.push("".concat(Pt(s),": ").concat((t=s,(r=o)==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||t in mr||t.startsWith("--")?String(r).trim():"".concat(r,"px")),";")))}return n};function V(e,t,r,n){if(ur(e))return[];if(ht(e))return[".".concat(e.styledComponentId)];if(ie(e)){if(!ie(o=e)||o.prototype&&o.prototype.isReactComponent||!t)return[e];var s=e(t);return V(s,t,r,n)}var o;return e instanceof cr?r?(e.inject(r,n),[e.getName(n)]):[e]:ye(e)?dr(e):Array.isArray(e)?Array.prototype.concat.apply(Qe,e.map(function(a){return V(a,t,r,n)})):[e.toString()]}function Qn(e){for(var t=0;t<e.length;t+=1){var r=e[t];if(ie(r)&&!ht(r))return!1}return!0}var Yn=Zt(We),Gn=function(){function e(t,r,n){this.rules=t,this.staticRulesId="",this.isStatic=(n===void 0||n.isStatic)&&Qn(t),this.componentId=r,this.baseHash=re(Yn,r),this.baseStyle=n,or.registerId(r)}return e.prototype.generateAndInjectStyles=function(t,r,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(t,r,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&r.hasNameForId(this.componentId,this.staticRulesId))s=K(s,this.staticRulesId);else{var o=ot(V(this.rules,t,r,n)),a=st(re(this.baseHash,o)>>>0);if(!r.hasNameForId(this.componentId,a)){var c=n(o,".".concat(a),void 0,this.componentId);r.insertRules(this.componentId,a,c)}s=K(s,a),this.staticRulesId=a}else{for(var u=re(this.baseHash,n.hash),d="",h=0;h<this.rules.length;h++){var m=this.rules[h];if(typeof m=="string")d+=m;else if(m){var y=ot(V(m,t,r,n));u=re(u,y+h),d+=y}}if(d){var g=st(u>>>0);r.hasNameForId(this.componentId,g)||r.insertRules(this.componentId,g,n(d,".".concat(g),void 0,this.componentId)),s=K(s,g)}}return s},e}(),fr=J.createContext(void 0);fr.Consumer;var et={};function Hn(e,t,r){var n=ht(e),s=e,o=!Xe(e),a=t.attrs,c=a===void 0?Qe:a,u=t.componentId,d=u===void 0?function(b,E){var v=typeof b!="string"?"sc":It(b);et[v]=(et[v]||0)+1;var p="".concat(v,"-").concat(Xt(We+v+et[v]));return E?"".concat(E,"-").concat(p):p}(t.displayName,t.parentComponentId):u,h=t.displayName,m=h===void 0?function(b){return Xe(b)?"styled.".concat(b):"Styled(".concat(xn(b),")")}(e):h,y=t.displayName&&t.componentId?"".concat(It(t.displayName),"-").concat(t.componentId):t.componentId||d,g=n&&s.attrs?s.attrs.concat(c).filter(
2Boolean):c,w=t.shouldForwardProp;if(n&&s.shouldForwardProp){var C=s.shouldForwardProp;if(t.shouldForwardProp){var D=t.shouldForwardProp;w=function(b,E){return C(b,E)&&D(b,E)}}else w=C}var $=new Gn(r,y,n?s.componentStyle:void 0);function S(b,E){return function(v,p,G){var X=v.attrs,ue=v.componentStyle,Ye=v.defaultProps,Ge=v.foldedComponentIds,be=v.styledComponentId,we=v.target,I=J.useContext(fr),O=Rt(),ee=v.shouldForwardProp||O.shouldForwardProp,Se=mn(p,I,Ye)||ae,L=function(Ce,fe,$e){for(var le,H=R(R({},fe),{className:void 0,theme:$e}),Ke=0;Ke<Ce.length;Ke+=1){var Ie=ie(le=Ce[Ke])?le(H):le;for(var F in Ie)H[F]=F==="className"?K(H[F],Ie[F]):F==="style"?R(R({},H[F]),Ie[F]):Ie[F]}return fe.className&&(H.className=K(H.className,fe.className)),H}(X,p,Se),je=L.as||we,de={};for(var q in L)L[q]===void 0||q[0]==="$"||q==="as"||q==="theme"&&L.theme===Se||(q==="forwardedAs"?de.as=L.forwardedAs:ee&&!ee(q,je)||(de[q]=L[q]));var yt=function(Ce,fe){var $e=Rt(),le=Ce.generateAndInjectStyles(fe,$e.styleSheet,$e.stylis);return le}(ue,L),He=K(Ge,be);return yt&&(He+=" "+yt),L.className&&(He+=" "+L.className),de[Xe(je)&&!Vt.has(je)?"class":"className"]=He,de.ref=G,Q.createElement(je,de)}(f,b,E)}S.displayName=m;var f=J.forwardRef(S);return f.attrs=g,f.componentStyle=$,f.displayName=m,f.shouldForwardProp=w,f.foldedComponentIds=n?K(s.foldedComponentIds,s.styledComponentId):"",f.styledComponentId=y,f.target=n?s.target:e,Object.defineProperty(f,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(b){this._foldedDefaultProps=n?function(E){for(var v=[],p=1;p<arguments.length;p++)v[p-1]=arguments[p];for(var G=0,X=v;G<X.length;G++)at(E,X[G],!0);return E}({},s.defaultProps,b):b}}),mt(f,function(){return".".concat(f.styledComponentId)}),o&&nr(f,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),f}function Nt(e,t){for(var r=[e[0]],n=0,s=t.length;n<s;n+=1)r.push(t[n],e[n+1]);return r}var Tt=function(e){return Object.assign(e,{isCss:!0})};function lr(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(ie(e)||ye(e))return Tt(V(Nt(Qe,ge([e],t,!0))));var n=e;return t.length===0&&n.length===1&&typeof n[0]=="string"?V(n):Tt(V(Nt(n,t)))}function ct(e,t,r){if(r===void 0&&(r=ae),!t)throw xe(1,t);var n=function(s){for(var o=[],a=1;a<arguments.length;a++)o[a-1]=arguments[a];return e(t,r,lr.apply(void 0,ge([s],o,!1)))};return n.attrs=function(s){return ct(e,t,R(R({},r),{attrs:Array.prototype.concat(r.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return ct(e,t,R(R({},r),s))},n}var pr=function(e){return ct(Hn,e)},Z=pr;Vt.forEach(function(e){Z[e]=pr(e)});function gt(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=ot(lr.apply(void 0,ge([e],t,!1))),s=Xt(n);return new cr(s,n)}const Kn="#4fa94d",Un={"aria-busy":!0,role:"progressbar"},Vn=Z.div` 3 display: ${e=>e.$visible?"flex":"none"}; 4`,Jn="http://www.w3.org/2000/svg",N=242.776657104492,Zn=1.6,Xn=gt` 512.5% { 6 stroke-dasharray: ${N*.14}px, ${N}px; 7 stroke-dashoffset: -${N*.11}px; 8} 943.75% { 10 stroke-dasharray: ${N*.35}px, ${N}px; 11 stroke-dashoffset: -${N*.35}px; 12} 13100% { 14 stroke-dasharray: ${N*.01}px, ${N}px; 15 stroke-dashoffset: -${N*.99}px; 16} 17`;Z.path` 18 stroke-dasharray: ${N*.01}px, ${N}; 19 stroke-dashoffset: 0; 20 animation: ${Xn} ${Zn}s linear infinite; 21`;const es=gt` 22to { 23 transform: rotate(360deg); 24 } 25`;Z.svg` 26 animation: ${es} 0.75s steps(12, end) infinite; 27 animation-duration: 0.75s; 28`;Z.polyline` 29 stroke-width: ${e=>e.width}px; 30 stroke-linecap: round; 31 32 &:nth-child(12n + 0) { 33 stroke-opacity: 0.08; 34 } 35 36 &:nth-child(12n + 1) { 37 stroke-opacity: 0.17; 38 } 39 40 &:nth-child(12n + 2) { 41 stroke-opacity: 0.25; 42 } 43 44 &:nth-child(12n + 3) { 45 stroke-opacity: 0.33; 46 } 47 48 &:nth-child(12n + 4) { 49 stroke-opacity: 0.42; 50 } 51 52 &:nth-child(12n + 5) { 53 stroke-opacity: 0.5; 54 } 55 56 &:nth-child(12n + 6) { 57 stroke-opacity: 0.58; 58 } 59 60 &:nth-child(12n + 7) { 61 stroke-opacity: 0.66; 62 } 63 64 &:nth-child(12n + 8) { 65 stroke-opacity: 0.75; 66 } 67 68 &:nth-child(12n + 9) { 69 stroke-opacity: 0.83; 70 } 71 72 &:nth-child(12n + 11) { 73 stroke-opacity: 0.92; 74 } 75`;const ts=({height:e=80,width:t=80,radius:r=9,color:n=Kn,ariaLabel:s="three-dots-loading",wrapperStyle:o,wrapperClass:a,visible:c=!0})=>i.jsx(Vn,{style:o,$visible:c,className:a,"data-testid":"three-dots-loading","aria-label":s,...Un,children:i.jsxs("svg",{width:t,height:e,viewBox:"0 0 120 30",xmlns:Jn,fill:n,"data-testid":"three-dots-svg",children:[i.jsxs("circle",{cx:"15",cy:"15",r:Number(r)+6,children:[i.jsx("animate",{attributeName:"r",from:"15",to:"15",begin:"0s",dur:"0.8s",values:"15;9;
7515",calcMode:"linear",repeatCount:"indefinite"}),i.jsx("animate",{attributeName:"fill-opacity",from:"1",to:"1",begin:"0s",dur:"0.8s",values:"1;.5;1",calcMode:"linear",repeatCount:"indefinite"})]}),i.jsxs("circle",{cx:"60",cy:"15",r,attributeName:"fill-opacity",from:"1",to:"0.3",children:[i.jsx("animate",{attributeName:"r",from:"9",to:"9",begin:"0s",dur:"0.8s",values:"9;15;9",calcMode:"linear",repeatCount:"indefinite"}),i.jsx("animate",{attributeName:"fill-opacity",from:"0.5",to:"0.5",begin:"0s",dur:"0.8s",values:".5;1;.5",calcMode:"linear",repeatCount:"indefinite"})]}),i.jsxs("circle",{cx:"105",cy:"15",r:Number(r)+6,children:[i.jsx("animate",{attributeName:"r",from:"15",to:"15",begin:"0s",dur:"0.8s",values:"15;9;15",calcMode:"linear",repeatCount:"indefinite"}),i.jsx("animate",{attributeName:"fill-opacity",from:"1",to:"1",begin:"0s",dur:"0.8s",values:"1;.5;1",calcMode:"linear",repeatCount:"indefinite"})]})]})}),rs=gt` 76to { 77 stroke-dashoffset: 136; 78 } 79`;Z.polygon` 80 stroke-dasharray: 17; 81 animation: ${rs} 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite; 82`;Z.svg` 83 transform-origin: 50% 65%; 84`;const ns=({id:e})=>{const{data:t,error:r}=Lt(e);return r||!t?i.jsx(vt,{children:`Produto #${e}`}):i.jsx(vt,{component:Mt,to:`/products/${t.id}`,children:`${t.nome}`})},ss=({id:e})=>{const{data:t,isLoading:r,error:n}=Lt(e);return r?i.jsxs(Ue,{elevation:2,sx:{textDecoration:"none",padding:1,height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",backgroundColor:"white"},children:[i.jsx(Ve,{variant:"rectangular",height:100}),i.jsx(Ve,{variant:"text",width:"80%"}),i.jsx(Ve,{variant:"text",width:"20%"})]}):n||!t?i.jsx(Ue,{elevation:2,sx:{textDecoration:"none",padding:2,height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",backgroundColor:"white"},children:i.jsxs(Y,{children:["Produto ",e]})}):i.jsxs(Ue,{component:Mt,to:`/products/${t.id}`,elevation:2,sx:{backgroundColor:"white",textDecoration:"none",padding:1,height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsx("img",{src:Cr(t.image_url[0],{width:400,height:400}),onError:s=>{s.currentTarget.src="/placeholder.svg"},alt:t.nome,height:100,width:"100%",style:{objectFit:"contain",minHeight:90,maxHeight:90,color:"transparent"}}),i.jsx(Ne,{alignItems:"center",justifyContent:"space-between",height:"100%",children:i.jsxs(Ne,{paddingTop:1,width:"100%",children:[i.jsx(Y,{gutterBottom:!0,variant:"body1",fontSize:"small",fontWeight:500,component:"div",sx:$r(3),children:t.nome}),i.jsx(Y,{variant:"h6",fontSize:"small",color:"text.secondary",fontWeight:500,children:t.preco.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})})]})})]})},os=({message:e,timestamp:t,direction:r,grouped:n,type:s,status:o,typing:a})=>{if(s!=="text")return null;const c=r==="sent"?"sent":"received";try{e=JSON.parse(e).text}catch{e="Error: Invalid message"}const u=Wr(e);return i.jsxs(gr,{sx:{marginTop:n?"2px":"14px",maxWidth:"80%",padding:"6px 7px 8px 9px",marginLeft:c==="sent"?"auto":"10px",marginRight:c==="sent"?"10px":"auto",backgroundColor:c==="sent"?"#e7e0ff":"white",color:"black",borderRadius:"7.5px",position:"relative",wordWrap:"break-word",whiteSpace:"pre-line",overflow:"hidden",boxShadow:"rgba(11, 20, 26, 0.13) 0px 1px 0.5px 0px",overscrollBehavior:"contain",flexShrink:0},children:[i.jsxs(Y,{variant:"body1",sx:{color:"inherit",fontSize:"14px"},children:[a?i.jsx(ts,{color:"#667781",height:15,width:36,visible:!0}):u.map((d,h)=>{if(d.type==="text")return i.jsx("span",{children:d.content},h);if(d.type==="inlineProducts")return i.jsx("span",{children:d.content.map((m,y,g)=>i.jsxs(J.Fragment,{children:[i.jsx(ns,{id:m}),y<g.length-1&&", "]},m))},h);if(d.type==="blockProducts")return i.jsx(pe,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(100px, 1fr))",gap:1},children:d.content.map(m=>i.jsx(ss,{id:m},m))},h)}),!a&&i.jsxs("span",{style:{fontSize:"11px",visibility:"hidden",marginLeft:"5px",marginRight:"5px"},children:[Te(new Date(t),"HH:mm"),c==="sent"&&i.jsx(Ot,{status:"read"})]})]}),!a&&i.jsxs(Y,{variant:"caption",sx:{position:"absolute",bottom:"3px",right:"9px",fontSize:"11px",color:"#667781",display:"flex",alignItems:"center"},children:[Te(new Date(t),"HH:mm"),c==="sent"&&i.jsx(Ot,{status:o})]})]})},Ot=({status:e})=>i.jsx(i.Fragment,{children:e==="sent"?i.jsx(Qr,{sx:{color:"#667781",fontSize:"14px",display:"inline",marginLeft:"3px"}}):e==="delivered"?i.jsx(St,{sx:{color:"#667781",fontSize:"14px",display:"inline",marginLeft:"3px"}}):i.jsx(St,{sx:{minWidth:"14px",color:"#52bfea",fontSize:"14px",display:"inline",marginLeft:"3px"}})}),as=async e=>{const{data:t,error:r}=await z.from("conversa").select(` 85 id, 86 vendedor_id, 87 customer_user_id, 88 ia_habilitado 89 `).eq("customer_user_id",e);if(r)throw console.log(r),new Error(r.message);if(!t||t.length===0)return null;const n=t.map(d=>d.id),{data:s,error:o}=await z.from("mensagem").select(` 90 timestamp, 91 conteudo, 92 tipo, 93 direcao, 94 status, 95 id, 96 digitando 97 `).in("conversa_id",n).order("timestamp",{ascending:!0});if(o)throw console.log(o),new Error(o.message);const{data:a,error:c}=await z.from("cliente").select(` 98 id, 99 nome, 100 profile_url 101 `).eq("customer_user_id",e).is("deletado_em",null).maybeSingle();if(c)throw console.log(c),new Error(c.message);const u=t.sort((d,h)=>h.id-d.id)[0];return{id:u.id,vendedor_id:u.vendedor_id,ia_habilitado:u.ia_habilitado,cliente:a?{id:a.id,nome:a.nome,profile_url:a.profile_url}:void 0,mensagens:s,conversationIds:n}},is=e=>{var n;const t=ve(),r=Yr({queryKey:["conversation",e],queryFn:()=>as(e),enabled:!!e});return Q.useEffect(()=>{var a;if(!((a=r.data)!=null&&a.id))return;const s=r.data.id,o=z.channel(`conversa-changes-${s}`).on("postgres_changes",{event:"*",schema:"public",table:"mensagem",filter:`conversa_id=eq.${s}`},()=>{t.invalidateQueries({queryKey:["conversation",e]}
101)}).subscribe();return()=>{z.removeChannel(o)}},[(n=r.data)==null?void 0:n.id,e,t]),r},cs=async e=>{const{data:t,error:r}=await z.from("mensagem").insert({conversa_id:e.conversa_id,direcao:"sent",tipo:"text",conteudo:JSON.stringify({text:e.conteudo}),status:"delivered"}).single();if(r)throw new Error(r.message);return t},us=e=>{const t=ve();return ze({mutationFn:cs,onMutate:async r=>{await t.cancelQueries({queryKey:["conversation",e]});const n=t.getQueryData(["conversation",e]),s={id:Ir(),conversa_id:r.conversa_id,direcao:"sent",tipo:"text",conteudo:JSON.stringify({text:r.conteudo}),status:"sent",timestamp:new Date().toISOString(),digitando:!1};return n&&t.setQueryData(["conversation",e],{...n,mensagens:[...n.mensagens,s]}),{previousConversation:n}},onError:(r,n,s)=>{console.error(r),s!=null&&s.previousConversation&&t.setQueryData(["conversation",e],s.previousConversation)},onSettled:()=>{t.invalidateQueries({queryKey:["conversation",e]})}})},ds=async({conversationId:e,ia_habilitado:t,nao_lidas:r})=>{const n={};typeof t<"u"&&(n.ia_habilitado=t),typeof r<"u"&&(n.nao_lidas=r);const{error:s}=await z.from("conversa").update(n).eq("id",e);if(s)throw new Error(s.message)},fs=()=>{const e=ve();return ze({mutationFn:ds,onMutate:async t=>{await e.cancelQueries({queryKey:["conversation",t.conversationId]});const r=e.getQueryData(["conversation",t.conversationId]);return e.setQueryData(["conversation",t.conversationId],n=>n&&{...n,...t}),{previousConversation:r}},onError:(t,r,n)=>{n!=null&&n.previousConversation&&e.setQueryData(["conversation",r.conversationId],n.previousConversation)},onSettled:()=>{e.invalidateQueries({queryKey:["conversation"]})}})},ls=()=>{const e=ve(),{user:t}=zt(),r=t==null?void 0:t.id;return ze({mutationFn:async n=>{const{customer_user_id:s}=n;if(!r)throw new Error("User must be logged in to delete conversations.");const{data:o,error:a}=await z.from("conversa").select("id").eq("customer_user_id",s).eq("vendedor_id",r);if(a)throw new Error(a.message);if(!o||o.length===0)return;const c=o.map(d=>d.id),{error:u}=await z.from("conversa").update({deletado_em:new Date().toISOString()}).in("id",c);if(u)throw new Error(u.message)},onSuccess:(n,s)=>{Er(_r.DELETE.CONVERSATION,{customerUserId:s.customer_user_id}),e.invalidateQueries({queryKey:["conversation",s.customer_user_id]})},onError:n=>{console.error("Error deleting conversations:",n.message)},retry:0})},ps=e=>{const t=new Date(e),r=new Date;return kr(t)?"hoje":Dr(t)?"ontem":Ar(r,t)<=6?Te(t,"eeee",{locale:Rr}):Te(t,"dd/MM/yyyy")};function hs(e){const t={};e.forEach(s=>{const o=ps(s.timestamp);t[o]||(t[o]=[]),t[o].push(s)}),Object.keys(t).forEach(s=>{t[s].sort((o,a)=>o.timestamp.getTime()-a.timestamp.getTime())});const r=Object.keys(t).sort((s,o)=>{const a=t[s][0].timestamp,c=t[o][0].timestamp;return a.getTime()-c.getTime()}),n={};return r.forEach(s=>{n[s]=t[s]}),n}const ms=e=>{const t=ve(),{user:r}=zt(),n=r==null?void 0:r.id;return ze({mutationFn:async()=>{if(!n)throw new Error("User must be logged in to reset unread count.");const{data:s,error:o}=await z.from("conversa").update({nao_lidas:0}).eq("customer_user_id",e).eq("vendedor_id",n);if(o)throw new Error(o.message);return s||[]},onSuccess:()=>{t.invalidateQueries({queryKey:["conversations"]})},onError:s=>{console.error("Error resetting unread count:",s.message)},retry:3})},Es=()=>{var be,we;const e=Pr(),{chatId:t}=Nr(),r=t||"",{appBarWidth:n,appBarMarginLeft:s}=Tr(),{mutate:o}=ms(r),{mutate:a}=us(r),{mutate:c,isPending:u}=fs(),{mutate:d,isPending:h}=ls(),{register:m,handleSubmit:y,setValue:g,watch:w}=Or({defaultValues:{message:""}}),C=w("message"),D=Q.useRef(null),[$,S]=Q.useState(null);Q.useEffect(()=>{r&&o()},[r,o]);const{data:f,isLoading:b}=is(r),E=Q.useMemo(()=>(f==null?void 0:f.mensagens)||[],[f]),v=hs(E.map(I=>({...I,timestamp:Mr(I.timestamp)}))),p=y(I=>{I.message.trim()===""||!(f!=null&&f.id)||(a({conversa_id:f.id,conteudo:I.message}),g("message",""))}),G=()=>{f&&c({conversationId:f.id,ia_habilitado:!f.ia_habilitado})},X=I=>{S(I.currentTarget)},ue=()=>{S(null)},Ye=()=>{d({customer_user_id:r},{onSuccess:()=>{ue(),e(-1)}})},Ge=()=>{var I;(I=f==null?void 0:f.cliente)!=null&&I.id&&e(`/customers/${f.cliente.id}`),ue()};return Q.useEffect(()=>{D.current&&D.current.scrollIntoView()},[E]),i.jsxs(pe,{sx:{pb:7,pt:1},children:[i.jsxs(zr,{title:b?" ":((be=f==null?void 0:f.cliente)==null?void 0:be.nome)||"De
101sconhecido",navigateBack:!0,children:[i.jsx(Y,{variant:"h6",component:"div",sx:{flexGrow:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}),i.jsx(yr,{color:"inherit","aria-label":"menu",onClick:X,children:i.jsx(Lr,{})}),i.jsxs(vr,{id:"chat-menu",anchorEl:$,open:!!$,onClose:ue,children:[((we=f==null?void 0:f.cliente)==null?void 0:we.id)&&i.jsxs(xt,{onClick:Ge,children:[i.jsx(bt,{children:i.jsx(Br,{})}),i.jsx(wt,{primary:"Dados do cliente"})]}),i.jsxs(xt,{onClick:Ye,disabled:h,children:[i.jsx(bt,{children:i.jsx(qr,{})}),i.jsx(wt,{primary:"Apagar conversa"})]})]})]}),i.jsxs(Ne,{spacing:2,position:"fixed",zIndex:I=>I.zIndex.appBar,bgcolor:"white",top:"calc(var(--safe-area-inset-top) + 56px)",left:0,right:0,width:n,marginLeft:s,direction:"row",alignItems:"center",justifyContent:"space-between",px:1,borderBottom:"1px solid",borderColor:"divider",children:[i.jsx(Y,{variant:"body1",fontWeight:"bold",sx:{px:2},children:"Atendimento IA"}),i.jsx(xr,{checked:(f==null?void 0:f.ia_habilitado)??!0,onChange:G,disabled:b||u})]}),i.jsxs(pe,{sx:{px:2,py:4,display:"flex",flexDirection:"column",mt:4},children:[b?i.jsx(pe,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",py:4},children:i.jsx(br,{})}):Object.keys(v).map(I=>i.jsxs(J.Fragment,{children:[i.jsx(gs,{date:I}),v[I].map((O,ee)=>{const Se=ee>0&&v[I][ee-1].direcao===O.direcao;return i.jsx(os,{message:O.conteudo,timestamp:O.timestamp,direction:O.direcao,grouped:Se,type:O.tipo,status:O.status,typing:O.digitando},O.id)})]},I)),i.jsx("div",{ref:D})]}),i.jsx(pe,{sx:{position:"fixed",bottom:0,left:0,right:0,width:n,marginLeft:s,p:1,paddingBottom:"calc(var(--safe-area-inset-bottom) + 8px)",bgcolor:"white"},children:i.jsxs(Ne,{direction:"row",spacing:2,alignItems:"center",children:[i.jsx(wr,{...m("message"),sx:{borderRadius:"200px",backgroundColor:"#ffffff","& .MuiOutlinedInput-root":{borderRadius:"200px"},"& .MuiOutlinedInput-input":{borderRadius:"200px",padding:"10px 16px"}},fullWidth:!0,placeholder:"Digite uma mensagem...",variant:"outlined",size:"small",onKeyPress:I=>{I.key==="Enter"&&p()}}),C&&i.jsx(Sr,{variant:"contained",color:"primary",onClick:p,tabIndex:-1,sx:{borderRadius:"50%",minWidth:"36px",minHeight:"36px",width:"36px",height:"36px",padding:0},onMouseDown:I=>I.preventDefault(),children:i.jsx(Bt,{fontSize:"small"})})]})})]})},gs=({date:e})=>i.jsx(Y,{variant:"caption",sx:{mt:2,mb:1,mx:"auto",fontSize:"12.5px",color:Fr.palette.text.secondary,backgroundColor:"#ffffff",borderRadius:"7.5px",pt:"5px",pb:"6px",px:"12px",lineHeight:"21px"},children:e});export{Es as default};
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.