@epam/statgpt-conversation-list 0.5.0-rc.36 → 0.5.0-rc.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +122 -121
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),O=require("classnames"),p=require("react"),le=require("lodash"),w=require("@epam/statgpt-ui-components"),K=require("@tabler/icons-react"),je=require("jszip"),F=require("@epam/statgpt-shared-toolkit"),Y=require("@epam/statgpt-dial-toolkit");var L=(s=>(s.DELETE="delete",s.EXPORT="export",s.SHARE="share",s.RENAME="rename",s))(L||{}),B=(s=>(s.SHARED="shared",s.TODAY="today",s.YESTERDAY="yesterday",s.WEEK="week",s.EARLIER="earlier",s))(B||{});const ee=(s,o)=>s?.resources?.filter(r=>r?.parentPath===o)?.map(r=>{const i=`${r?.bucket}/${o}`,d=r?.url?.split("/")?.slice(1)?.join("/");return{...r,folderId:i,id:d,isShared:!0}})||[],he=s=>({[B.SHARED]:s}),Te={[B.TODAY]:[],[B.YESTERDAY]:[],[B.WEEK]:[],[B.EARLIER]:[]},pe=(s,o)=>s.toDateString()===o.toDateString(),De=(s,o)=>{const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()-1);return pe(o,r)},Oe=(s,o)=>{const r=s.getTime()-o.getTime();return Math.floor(r/(1e3*60*60*24))},ue=s=>s.updatedAt||Number(s.id?.split("-").pop()),ke=s=>{const o=new Date,r=le.cloneDeep(Te);for(const i of s)if(i.updatedAt){const d=new Date(i.updatedAt);let u;pe(o,d)?u=r[B.TODAY]:De(o,d)?u=r[B.YESTERDAY]:Oe(o,d)<=7?u=r[B.WEEK]:u=r[B.EARLIER],u?.some(f=>f.id===i.id)||u.push(i)}return r},me=s=>s?.sort((o,r)=>(ue(r)||0)-(ue(o)||0)),Le=(s,o)=>s===B.SHARED?o?.shared||"Shared":s===B.TODAY?o?.today||"Today":s===B.YESTERDAY?o?.yesterday||"Yesterday":s===B.WEEK?o?.lastWeek||"Last week":o?.earlier||"Earlier",Be=({onCloseModal:s,disableModalDividers:o,deleteConversation:r,isSmallButton:i,titles:d,locale:u})=>c.jsxs(w.Popup,{heading:d?.deleteTitle??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:w.PopUpSize.SM,dividers:!o,onClose:s,closeButtonTitle:d?.close??"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:u,children:d?.deleteMessage??"Are you sure you want to delete this conversation? This action cannot be undone."}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:d?.cancel??"Cancel",isSmallButton:i,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary text-button-primary-error",title:d?.delete??"Delete",isSmallButton:i,onClick:f=>{f.stopPropagation(),r()}})]})]}),Ue=s=>{const o=$e(F.getConversationAttachments(s)).map(r=>({...r,relativePath:"",contentLength:0}));return le.uniqBy(o,r=>Z(r.relativePath,r.name))},Fe=s=>s.endsWith("/"),ze=s=>{const o=s.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(r=>o.startsWith(r))},_e=s=>{const o=Z(...s.split("/").map(i=>decodeURIComponent(i))),r=o.lastIndexOf("/");return{absolutePath:o.slice(0,r),name:o.slice(r+1)}},$e=s=>s?s.map(o=>{if(!o.url||ze(o.url)||Fe(o.url))return null;const{absolutePath:r,name:i}=_e(o.url);return{id:o.url,name:i,contentType:o.type,folderId:r,absolutePath:r}}).filter(Boolean):[];async function He(s,o){const r=Ue(s),i=new je;r.forEach(g=>{const e=encodeURI(Z(g.absolutePath,g.name)),n=o(`${e}`.replace("files/","")),t=Ye(g.folderId),a=Z("res",t,g.name);i.file(a,n)});const d={version:5,history:[s].map(Qe)||[],folders:[]},u=JSON.stringify(d,null,2);return i.file("conversations/conversations_history.json",u),await i.generateAsync({type:"base64"})}const Ye=s=>{const o=s.split("/");return o.length>2?Z(...o.slice(2)):void 0},Qe=s=>le.omit(s,["publicationInfo"]),Z=(...s)=>s.filter(Boolean).join("/");function Ge(s,o){const r=document.createElement("a");r.download=o,r.href=s,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s)}var We=Object.defineProperty,te=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,de=(s,o,r)=>o in s?We(s,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[o]=r,ae=(s,o)=>{for(var r in o||(o={}))fe.call(o,r)&&de(s,r,o[r]);if(te)for(var r of te(o))ge.call(o,r)&&de(s,r,o[r]);return s},ie=(s,o)=>{var r={};for(var i in s)fe.call(s,i)&&o.indexOf(i)<0&&(r[i]=s[i]);if(s!=null&&te)for(var i of te(s))o.indexOf(i)<0&&ge.call(s,i)&&(r[i]=s[i]);return r};var W;(s=>{const o=class v{constructor(e,n,t,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version value out of range");if(a<-1||a>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let l=[];for(let h=0;h<this.size;h++)l.push(!1);for(let h=0;h<this.size;h++)this.modules.push(l.slice()),this.isFunction.push(l.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(t);if(this.drawCodewords(m),a==-1){let h=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const C=this.getPenaltyScore();C<h&&(a=x,h=C),this.applyMask(x)}}d(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(e,n){const t=s.QrSegment.makeSegments(e);return v.encodeSegments(t,n)}static encodeBinary(e,n){const t=s.QrSegment.makeBytes(e);return v.encodeSegments([t],n)}static encodeSegments(e,n,t=1,a=40,l=-1,m=!0){if(!(v.MIN_VERSION<=t&&t<=a&&a<=v.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let h,x;for(h=t;;h++){const E=v.getNumDataCodewords(h,n)*8,R=f.getTotalBits(e,h);if(R<=E){x=R;break}if(h>=a)throw new RangeError("Data too long")}for(const E of[v.Ecc.MEDIUM,v.Ecc.QUARTILE,v.Ecc.HIGH])m&&x<=v.getNumDataCodewords(h,E)*8&&(n=E);let C=[];for(const E of e){r(E.mode.modeBits,4,C),r(E.numChars,E.mode.numCharCountBits(h),C);for(const R of E.getData())C.push(R)}d(C.length==x);const b=v.getNumDataCodewords(h,n)*8;d(C.length<=b),r(0,Math.min(4,b-C.length),C),r(0,(8-C.length%8)%8,C),d(C.length%8==0);for(let E=236;C.length<b;E^=253)r(E,8,C);let N=[];for(;N.length*8<C.length;)N.push(0);return C.forEach((E,R)=>N[R>>>3]|=E<<7-(R&7)),new v(h,n,N,l)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let t=0;t<n;t++)for(let a=0;a<n;a++)t==0&&a==0||t==0&&a==n-1||t==n-1&&a==0||this.drawAlignmentPattern(e[t],e[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let t=n;for(let l=0;l<10;l++)t=t<<1^(t>>>9)*1335;const a=(n<<10|t)^21522;d(a>>>15==0);for(let l=0;l<=5;l++)this.setFunctionModule(8,l,i(a,l));this.setFunctionModule(8,7,i(a,6)),this.setFunctionModule(8,8,i(a,7)),this.setFunctionModule(7,8,i(a,8));for(let l=9;l<15;l++)this.setFunctionModule(14-l,8,i(a,l));for(let l=0;l<8;l++)this.setFunctionModule(this.size-1-l,8,i(a,l));for(let l=8;l<15;l++)this.setFunctionModule(8,this.size-15+l,i(a,l));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;d(n>>>18==0);for(let t=0;t<18;t++){const a=i(n,t),l=this.size-11+t%3,m=Math.floor(t/3);this.setFunctionModule(l,m,a),this.setFunctionModule(m,l,a)}}drawFinderPattern(e,n){for(let t=-4;t<=4;t++)for(let a=-4;a<=4;a++){const l=Math.max(Math.abs(a),Math.abs(t)),m=e+a,h=n+t;0<=m&&m<this.size&&0<=h&&h<this.size&&this.setFunctionModule(m,h,l!=2&&l!=4)}}drawAlignmentPattern(e,n){for(let t=-2;t<=2;t++)for(let a=-2;a<=2;a++)this.setFunctionModule(e+a,n+t,Math.max(Math.abs(a),Math.abs(t))!=1)}setFunctionModule(e,n,t){this.modules[n][e]=t,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,t=this.errorCorrectionLevel;if(e.length!=v.getNumDataCodewords(n,t))throw new RangeError("Invalid argument");const a=v.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n],l=v.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n],m=Math.floor(v.getNumRawDataModules(n)/8),h=a-m%a,x=Math.floor(m/a);let C=[];const b=v.reedSolomonComputeDivisor(l);for(let E=0,R=0;E<a;E++){let A=e.slice(R,R+x-l+(E<h?0:1));R+=A.length;const T=v.reedSolomonComputeRemainder(A,b);E<h&&A.push(0),C.push(A.concat(T))}let N=[];for(let E=0;E<C[0].length;E++)C.forEach((R,A)=>{(E!=x-l||A>=h)&&N.push(R[E])});return d(N.length==m),N}drawCodewords(e){if(e.length!=Math.floor(v.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let a=0;a<this.size;a++)for(let l=0;l<2;l++){const m=t-l,x=(t+1&2)==0?this.size-1-a:a;!this.isFunction[x][m]&&n<e.length*8&&(this.modules[x][m]=i(e[n>>>3],7-(n&7)),n++)}}d(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let t=0;t<this.size;t++){let a;switch(e){case 0:a=(t+n)%2==0;break;case 1:a=n%2==0;break;case 2:a=t%3==0;break;case 3:a=(t+n)%3==0;break;case 4:a=(Math.floor(t/3)+Math.floor(n/2))%2==0;break;case 5:a=t*n%2+t*n%3==0;break;case 6:a=(t*n%2+t*n%3)%2==0;break;case 7:a=((t+n)%2+t*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][t]&&a&&(this.modules[n][t]=!this.modules[n][t])}}getPenaltyScore(){let e=0;for(let l=0;l<this.size;l++){let m=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[l][C]==m?(h++,h==5?e+=v.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),m||(e+=this.finderPenaltyCountPatterns(x)*v.PENALTY_N3),m=this.modules[l][C],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,x)*v.PENALTY_N3}for(let l=0;l<this.size;l++){let m=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][l]==m?(h++,h==5?e+=v.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),m||(e+=this.finderPenaltyCountPatterns(x)*v.PENALTY_N3),m=this.modules[C][l],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,x)*v.PENALTY_N3}for(let l=0;l<this.size-1;l++)for(let m=0;m<this.size-1;m++){const h=this.modules[l][m];h==this.modules[l][m+1]&&h==this.modules[l+1][m]&&h==this.modules[l+1][m+1]&&(e+=v.PENALTY_N2)}let n=0;for(const l of this.modules)n=l.reduce((m,h)=>m+(h?1:0),n);const t=this.size*this.size,a=Math.ceil(Math.abs(n*20-t*10)/t)-1;return d(0<=a&&a<=9),e+=a*v.PENALTY_N4,d(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let a=this.size-7;t.length<e;a-=n)t.splice(1,0,a);return t}}static getNumRawDataModules(e){if(e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return d(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(v.getNumRawDataModules(e)/8)-v.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*v.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let a=0;a<e-1;a++)n.push(0);n.push(1);let t=1;for(let a=0;a<e;a++){for(let l=0;l<n.length;l++)n[l]=v.reedSolomonMultiply(n[l],t),l+1<n.length&&(n[l]^=n[l+1]);t=v.reedSolomonMultiply(t,2)}return n}static reedSolomonComputeRemainder(e,n){let t=n.map(a=>0);for(const a of e){const l=a^t.shift();t.push(0),n.forEach((m,h)=>t[h]^=v.reedSolomonMultiply(m,l))}return t}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let t=0;for(let a=7;a>=0;a--)t=t<<1^(t>>>7)*285,t^=(n>>>a&1)*e;return d(t>>>8==0),t}finderPenaltyCountPatterns(e){const n=e[1];d(n<=this.size*3);const t=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(t&&e[0]>=n*4&&e[6]>=n?1:0)+(t&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,t){return e&&(this.finderPenaltyAddHistory(n,t),n=0),n+=this.size,this.finderPenaltyAddHistory(n,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],o.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=o;function r(g,e,n){if(e<0||e>31||g>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)n.push(g>>>t&1)}function i(g,e){return(g>>>e&1)!=0}function d(g){if(!g)throw new Error("Assertion error")}const u=class y{constructor(e,n,t){if(this.mode=e,this.numChars=n,this.bitData=t,n<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new y(y.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const a=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+a),10),a*3+1,n),t+=a}return new y(y.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],t;for(t=0;t+2<=e.length;t+=2){let a=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;a+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(a,11,n)}return t<e.length&&r(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new y(y.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else if(e<1e6)r(6,3,n),r(e,21,n);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,n)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let t=0;for(const a of e){const l=a.mode.numCharCountBits(n);if(a.numChars>=1<<l)return 1/0;t+=4+l+a.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?n.push(e.charCodeAt(t)):(n.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return n}};u.NUMERIC_REGEX=/^[0-9]*$/,u.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,u.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let f=u;s.QrSegment=u})(W||(W={}));(s=>{(o=>{const r=class{constructor(d,u){this.ordinal=d,this.formatBits=u}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),o.Ecc=r})(s.QrCode||(s.QrCode={}))})(W||(W={}));(s=>{(o=>{const r=class{constructor(d,u){this.modeBits=d,this.numBitsCharCount=u}numCharCountBits(d){return this.numBitsCharCount[Math.floor((d+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),o.Mode=r})(s.QrSegment||(s.QrSegment={}))})(W||(W={}));var X=W;var Ve={L:X.QrCode.Ecc.LOW,M:X.QrCode.Ecc.MEDIUM,Q:X.QrCode.Ecc.QUARTILE,H:X.QrCode.Ecc.HIGH},Ce=128,Ee="L",xe="#FFFFFF",we="#000000",ve=!1,Ne=1,Xe=4,Ke=0,qe=.1;function Re(s,o=0){const r=[];return s.forEach(function(i,d){let u=null;i.forEach(function(f,g){if(!f&&u!==null){r.push(`M${u+o} ${d+o}h${g-u}v1H${u+o}z`),u=null;return}if(g===i.length-1){if(!f)return;u===null?r.push(`M${g+o},${d+o} h1v1H${g+o}z`):r.push(`M${u+o},${d+o} h${g+1-u}v1H${u+o}z`);return}f&&u===null&&(u=g)})}),r.join("")}function be(s,o){return s.slice().map((r,i)=>i<o.y||i>=o.y+o.h?r:r.map((d,u)=>u<o.x||u>=o.x+o.w?d:!1))}function Ze(s,o,r,i){if(i==null)return null;const d=s.length+r*2,u=Math.floor(o*qe),f=d/o,g=(i.width||u)*f,e=(i.height||u)*f,n=i.x==null?s.length/2-g/2:i.x*f,t=i.y==null?s.length/2-e/2:i.y*f,a=i.opacity==null?1:i.opacity;let l=null;if(i.excavate){let h=Math.floor(n),x=Math.floor(t),C=Math.ceil(g+n-h),b=Math.ceil(e+t-x);l={x:h,y:x,w:C,h:b}}const m=i.crossOrigin;return{x:n,y:t,h:e,w:g,excavation:l,opacity:a,crossOrigin:m}}function Je(s,o){return o!=null?Math.max(Math.floor(o),0):s?Xe:Ke}function Se({value:s,level:o,minVersion:r,includeMargin:i,marginSize:d,imageSettings:u,size:f,boostLevel:g}){let e=p.useMemo(()=>{const h=(Array.isArray(s)?s:[s]).reduce((x,C)=>(x.push(...X.QrSegment.makeSegments(C)),x),[]);return X.QrCode.encodeSegments(h,Ve[o],r,void 0,void 0,g)},[s,o,r,g]);const{cells:n,margin:t,numCells:a,calculatedImageSettings:l}=p.useMemo(()=>{let m=e.getModules();const h=Je(i,d),x=m.length+h*2,C=Ze(m,f,h,u);return{cells:m,margin:h,numCells:x,calculatedImageSettings:C}},[e,f,u,i,d]);return{qrcode:e,margin:t,cells:n,numCells:a,calculatedImageSettings:l}}var et=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),tt=p.forwardRef(function(o,r){const i=o,{value:d,size:u=Ce,level:f=Ee,bgColor:g=xe,fgColor:e=we,includeMargin:n=ve,minVersion:t=Ne,boostLevel:a,marginSize:l,imageSettings:m}=i,x=ie(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=x,b=ie(x,["style"]),N=m?.src,E=p.useRef(null),R=p.useRef(null),A=p.useCallback(_=>{E.current=_,typeof r=="function"?r(_):r&&(r.current=_)},[r]),[T,M]=p.useState(!1),{margin:D,cells:z,numCells:$,calculatedImageSettings:P}=Se({value:d,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:l,imageSettings:m,size:u});p.useEffect(()=>{if(E.current!=null){const _=E.current,S=_.getContext("2d");if(!S)return;let I=z;const j=R.current,k=P!=null&&j!==null&&j.complete&&j.naturalHeight!==0&&j.naturalWidth!==0;k&&P.excavation!=null&&(I=be(z,P.excavation));const Q=window.devicePixelRatio||1;_.height=_.width=u*Q;const V=u/$*Q;S.scale(V,V),S.fillStyle=g,S.fillRect(0,0,$,$),S.fillStyle=e,et?S.fill(new Path2D(Re(I,D))):z.forEach(function(ne,J){ne.forEach(function(se,oe){se&&S.fillRect(oe+D,J+D,1,1)})}),P&&(S.globalAlpha=P.opacity),k&&S.drawImage(j,P.x+D,P.y+D,P.w,P.h)}}),p.useEffect(()=>{M(!1)},[N]);const H=ae({height:u,width:u},C);let G=null;return N!=null&&(G=p.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{M(!0)},ref:R,crossOrigin:P?.crossOrigin})),p.createElement(p.Fragment,null,p.createElement("canvas",ae({style:H,height:u,width:u,ref:A,role:"img"},b)),G)});tt.displayName="QRCodeCanvas";var Me=p.forwardRef(function(o,r){const i=o,{value:d,size:u=Ce,level:f=Ee,bgColor:g=xe,fgColor:e=we,includeMargin:n=ve,minVersion:t=Ne,boostLevel:a,title:l,marginSize:m,imageSettings:h}=i,x=ie(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:b,numCells:N,calculatedImageSettings:E}=Se({value:d,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:m,imageSettings:h,size:u});let R=b,A=null;h!=null&&E!=null&&(E.excavation!=null&&(R=be(b,E.excavation)),A=p.createElement("image",{href:h.src,height:E.h,width:E.w,x:E.x+C,y:E.y+C,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const T=Re(R,C);return p.createElement("svg",ae({height:u,width:u,viewBox:`0 0 ${N} ${N}`,ref:r,role:"img"},x),!!l&&p.createElement("title",null,l),p.createElement("path",{fill:g,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),p.createElement("path",{fill:e,d:T,shapeRendering:"crispEdges"}),A)});Me.displayName="QRCodeSVG";const nt=(s,o)=>({invitationType:Y.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(s)}`},...o]}),st=s=>{const o=s?.invitationLink?.split("/").at(-1)||"";return`/${F.SHARE_CONVERSATION_ROUTE}/${o}`},ot=(s,o)=>o?.find(r=>{const i=s?.id?.split("/")?.pop(),d=r?.url?.split("/")?.pop()||"";return d===i||decodeURI(d)===i}),rt=s=>s?.messages?.filter(r=>!!r?.custom_content?.attachments)?.flatMap(r=>r?.custom_content?.attachments?.map(i=>({url:i?.url||""}))||[])?.filter(r=>!!r?.url)||[],at=({conversation:s,locale:o,onCloseModal:r,modalDividers:i,getConversation:d,generateConversationLink:u,chatExpiration:f,chatExpirationDays:g,close:e,chatWarning:n,shareLink:t,shareCopyLink:a,shareCopiedLink:l,shareDescription:m,shareRemoveAccessToUsers:h,chatName:x,getSharedConversations:C,revokeSharedConversations:b,baseUrl:N,id:E,clientSharedPage:R,clientSharedProp:A})=>{const[T,M]=p.useState(null),[D,z]=p.useState(),[$,P]=p.useState(!1),[H,G]=p.useState(!1),[_,S]=p.useState(),I=p.useRef(null),j=p.useRef(null),k=p.useMemo(()=>s?.id?decodeURI(s.id):E?.[0]&&E?.[1]&&o?decodeURI(`${E[0]}/${o}/${E[1]}`):null,[s?.id,E,o]),Q=p.useMemo(()=>{if(!T)return"";const U=N||window.location.origin;if(N&&N!==window.location.origin&&R&&A){const q=T.split(`/${F.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${U}/${R}?${A}=${q}`}return`${U}/${o}${T}`},[N,T,o,R,A]),V=p.useCallback(async U=>{const q=await C?.(Y.getSharedConversationsRequest(Y.ShareTarget.OTHERS));if(q)return ot({id:U},q.resources)},[C]);p.useEffect(()=>{if(!k||I.current===k)return;I.current=k,P(!1),j.current?.abort();const U=new AbortController;return j.current=U,(async()=>{try{const re=await d?.(k),Ie=nt(k,rt(re)),ce=await u?.(Ie),Pe=await V(k);if(U.signal.aborted||!ce)return;M(st(ce)),z(Pe),P(!0)}catch(re){if(U.signal.aborted)return;P(!1),console.error("Error sharing conversation",re)}})(),()=>{U.abort(),I.current=null}},[k,u,d,V]);const ne=p.useCallback(()=>{j.current?.abort(),I.current=null,r(),M(null),P(!1),G(!1)},[r]),J=p.useCallback(()=>{G(!0),navigator.clipboard.writeText(Q||"")},[Q]),se=async()=>{try{if(S(!0),D&&await b?.({resources:[D]}),k){const U=await V(k);j.current?.signal.aborted||z(U)}}catch(U){console.error("Error revoking shared conversation",U)}finally{j.current?.signal.aborted||S(!1)}},oe=p.useCallback(()=>c.jsx(w.Button,{buttonClassName:H?"text-button-secondary":"text-button-primary",iconBefore:H?c.jsx(K.IconCheck,{width:20,height:20}):c.jsx(K.IconCopy,{width:20,height:20}),title:H?l??"Copied":a??"Copy link",disabled:H,onClick:J}),[H,J,l,a]);return c.jsxs(w.Popup,{heading:t??"Share link",portalId:"share",size:w.PopUpSize.SM,dividers:i,onClose:ne,closeButtonTitle:e??"Close",children:[$?c.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[s?.name?c.jsxs("div",{className:"share-info flex w-full",children:[c.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:x??"Chat name:"}),c.jsx("h3",{className:"min-w-0 flex-1 truncate",title:s?.name,children:s?.name})]}):null,c.jsxs("div",{className:"share-info flex",children:[c.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:f??"Link expiration date:"}),c.jsxs("h3",{children:["3 ",g??"days"]})]}),c.jsx(Me,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:Q,size:200}),c.jsx("p",{className:"body-2 text-neutrals-1000",children:m??"Your name, special instructions, and any messages you add after sharing remain confidential."}),c.jsx(w.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:Q,value:Q,inputId:"conversationLink",iconAfterInput:oe()})]}):c.jsx("div",{className:"flex items-center justify-center p-6",children:c.jsx(w.Loader,{})}),$?s&&D?c.jsx("div",{className:"remove-access",children:c.jsx(w.Button,{title:h??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:_,onClick:se})}):c.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:n??"This chat has not been shared with anyone yet."}):c.jsx("div",{})]})},it=({conversation:s,onCloseModal:o,renameConversation:r,locale:i,disableModalDividers:d,titles:u,isSmallButton:f})=>{const[g,e]=p.useState(s?.name||""),n=a=>{e(a)},t=()=>{const a=`${s?.folderId}/${encodeURIComponent(F.getClearedConversationName(g))}-${new Date().getTime()}`;r(`conversations/${s.id}`,`conversations/${a}`)};return c.jsxs(w.Popup,{heading:u?.renameTitle??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:w.PopUpSize.SM,dividers:!d,onClose:o,closeButtonTitle:u?.close??"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:i,children:c.jsx(w.Input,{inputId:"rename",value:g,onChange:n,cssClass:"w-full"})}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:u?.cancel??"Cancel",isSmallButton:f,onClick:a=>{a.stopPropagation(),o()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary text-button-primary",title:u?.save??"Rename",isSmallButton:f,disabled:!g,onClick:a=>{a.stopPropagation(),t()}})]})]})},ye=({conversation:s,conversationStyles:o,shareConversationProps:r,onConversationDelete:i,getConversation:d,getFileBlob:u,renameConversation:f,triggerButton:g,locale:e,isDisabled:n})=>{const t=p.useMemo(()=>{const M=[{key:L.DELETE,title:o?.titles?.delete??"Delete",icon:o.actionsIcons?.[L.DELETE]}];return s?.model?.id?.endsWith(F.ONBOARDING_MODEL_POSTFIX)?M:[...s.isShared?[]:[{key:L.SHARE,title:o?.titles?.share??"Share",icon:o.actionsIcons?.[L.SHARE]},{key:L.RENAME,title:o?.titles?.rename??"Rename",icon:o.actionsIcons?.[L.RENAME]}],{key:L.EXPORT,title:o?.titles?.export??"Export",icon:o.actionsIcons?.[L.EXPORT]},...M]},[s.isShared,s?.model?.id,o.titles,o.actionsIcons]),[a,l]=p.useState(w.PopUpState.Closed),[m,h]=p.useState(w.PopUpState.Closed),[x,C]=p.useState(w.PopUpState.Closed),b=p.useCallback(()=>{l(w.PopUpState.Closed)},[l]),N=p.useCallback(()=>{h(w.PopUpState.Closed)},[h]),E=p.useCallback(()=>{C(w.PopUpState.Closed)},[C]),R=p.useCallback(()=>{i(s),b()},[s,i,b]),A=p.useCallback((M,D)=>{f(M,D),E()},[f,E]),T=M=>{M===L.DELETE&&l(w.PopUpState.Opened),M===L.SHARE&&h(w.PopUpState.Opened),M===L.RENAME&&C(w.PopUpState.Opened),M===L.EXPORT&&d(decodeURI(s.id)).then(D=>{He(D,u).then(z=>{Ge(`data:application/zip;base64,${z}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return c.jsxs(c.Fragment,{children:[c.jsx(w.Dropdown,{containerClassName:"ml-3 group-hover:visible invisible",triggerButton:g??c.jsx(lt,{disabled:n}),options:t,openedClassName:"action-menu-opened",onOptionSelect:T,disabled:n}),a===w.PopUpState.Opened&&c.jsx(Be,{titles:o.titles,locale:e,disableModalDividers:o.disableModalDividers,isSmallButton:o.isSmallModalButton,deleteConversation:R,onCloseModal:b}),m===w.PopUpState.Opened&&c.jsx(at,{conversation:s,locale:e,onCloseModal:N,...r}),x===w.PopUpState.Opened&&c.jsx(it,{conversation:s,locale:e,titles:o.titles,renameConversation:A,onCloseModal:E,disableModalDividers:o.disableModalDividers,isSmallButton:o.isSmallModalButton})]})},lt=({disabled:s})=>c.jsx("div",{className:O("flex items-center justify-center w-[24px]",s?"cursor-not-allowed":"cursor-pointer"),children:c.jsx(K.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),Ae=({conversation:s,selectedConversationId:o,searchQuery:r,onConversationClick:i,actions:d,locale:u,isDisabled:f,conversationStyles:g,shareConversationProps:e})=>{const n=p.useRef(null),t=F.getClearedConversationName(s?.name);return p.useEffect(()=>{if(s?.id===o&&n?.current){const a=n.current.parentElement?.parentElement?.parentElement;if(a){const l=n.current.getBoundingClientRect(),m=a.getBoundingClientRect(),h=l.height,x=m.height,b=l.top-m.top+a.scrollTop-(x/2-h/2);a.scrollTo({top:b,behavior:"smooth"})}}},[s,o]),c.jsxs("div",{ref:n,className:O("flex justify-between items-center py-2 px-3 border-transparent relative group border","conversation-item",o===s?.id&&"bg-hues-100 conversation-item-active",f?"cursor-not-allowed":"cursor-pointer hover:border-hues-600"),onClick:()=>!f&&i(s.folderId,s?.id),title:f?g?.titles?.noActionsAllowed:t,children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[g.conversationItemIcon?g.conversationItemIcon:null,c.jsx("h3",{className:O("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",o===s?.id?"conversation-item-text-active":""),title:f?g?.titles?.noActionsAllowed:t,children:r?.length?c.jsx(w.HighlightText,{text:t,highlightText:r}):t})]}),c.jsx(ye,{locale:u,conversationStyles:g,conversation:s,onConversationDelete:d.deleteConversation,getConversation:d.getConversation,getFileBlob:d.getFileBlob,renameConversation:d.renameConversation,shareConversationProps:e,isDisabled:f})]})},ct=({handleConversationClick:s,actions:o,selectedConversationId:r,groupLabel:i,conversationStyles:d,groupedConversations:u,shareConversationProps:f,locale:g,isDisabled:e})=>{const[n,t]=p.useState(!1),a=p.useCallback(()=>{t(l=>!l)},[t]);return c.jsxs("div",{children:[c.jsxs("div",{className:"conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700",onClick:a,children:[c.jsx(K.IconCaretRightFilled,{className:O("w-3 h-3 conversation-group-items-arrow",n?"rotate-[90deg]":"rotate-0")}),c.jsx("span",{className:"body-3 conversation-group-items-title-text",children:Le(i,d?.titles)})]}),!n&&c.jsx("div",{className:O("flex flex-col gap-y-3","conversation-group-items"),children:me(u).map(l=>c.jsx(Ae,{locale:g,isDisabled:e,conversationStyles:d,conversation:l,selectedConversationId:r,onConversationClick:s,actions:o,shareConversationProps:f},l.id||l.name))})]},i)},ut=({searchQuery:s,isExpandedSearch:o,titles:r,searchIcon:i,onSearchConversations:d,toggleSearchField:u})=>c.jsx(c.Fragment,{children:o?c.jsx(w.InputWithIcon,{inputId:"conversations-search",placeholder:r?.searchPlaceholder??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:s,iconAfterInput:c.jsx(w.IconButton,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:u,icon:c.jsx(K.IconX,{})}),onChange:d}):c.jsx(w.Button,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:i||c.jsx(K.IconSearch,{className:"size-5"}),onClick:u})}),dt=({conversations:s,selectedConversationId:o,searchQuery:r,conversationStyles:i,handleConversationClick:d,actions:u,locale:f,shareConversationProps:g,isDisabled:e})=>{const[n,t]=p.useState([]);return p.useEffect(()=>{t(me(s?.filter(a=>F.getClearedConversationName(a?.name)?.includes(r||""))))},[s,r]),c.jsx(c.Fragment,{children:n?.length?n.map(a=>c.jsx(Ae,{locale:f,conversationStyles:i,conversation:a,searchQuery:r,selectedConversationId:o,onConversationClick:d,actions:u,shareConversationProps:g,isDisabled:e},a.id)):c.jsx("h3",{className:"text-neutrals-800",children:i?.titles?.noConversation??"No conversations yet"})})},ht=({titles:s})=>c.jsxs("div",{className:"flex flex-col p-8 text-center",children:[c.jsx("p",{className:"text-neutrals-800",children:s?.noConversation??"No conversations yet"}),c.jsx("p",{className:"mt-2 text-sm text-neutrals-800",children:s?.clickNewChat??'Click "New Chat" to start a conversation'})]}),pt=({handleConversationClick:s,selectedConversationId:o,actions:r,children:i,isCollapsed:d,isStreaming:u,conversationStyles:f,conversations:g,locale:e,sharedConversations:n,setConversations:t,setSharedConversations:a,shareConversationProps:l,handleSelectedConversationRemove:m})=>{const[h,x]=p.useState({}),[C,b]=p.useState(!0),[N,E]=p.useState(""),[R,A]=p.useState(!1),{getConversations:T,getSharedConversations:M,deleteConversation:D,renameConversation:z}=r,$=p.useMemo(()=>!!N?.length,[N]);p.useEffect(()=>{x({...he(n),...ke(g)})},[g,n]),p.useEffect(()=>{async function S(){try{b(!0);const I=await T(e),j=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(I)),a(F.cleanConversationNames(ee(j,e)))}catch(I){console.error("Error loading conversation",I)}finally{b(!1)}}S()},[T,t,e,M,a]);const P=p.useCallback(async S=>{try{await D(S);const I=await T(e),j=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(I)),a(F.cleanConversationNames(ee(j,e))),o===S?.id&&m()}catch(I){console.error("Error deleting conversation",I)}},[D,T,e,M,t,a,o,m]),H=p.useCallback(async(S,I)=>{try{b(!0),await z(S,I);const j=await T(e),k=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(j)),a(F.cleanConversationNames(ee(k,e)))}catch(j){console.error("Error renaming conversation",j)}finally{b(!1)}},[T,e,M,t,a,z]),G=p.useCallback(S=>{E(S)},[E]),_=p.useCallback(()=>{A(S=>!S),E("")},[A]);return C?c.jsx(w.Loader,{}):c.jsxs(c.Fragment,{children:[!d&&c.jsxs("div",{className:O("flex justify-between items-center",R?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!R&&c.jsx("h3",{className:"sm:body-2 text-neutrals-700",children:f?.titles?.allChats??"All Chats"}),c.jsx(ut,{searchQuery:N,searchIcon:f.searchIcon,titles:f.titles,isExpandedSearch:R,onSearchConversations:G,toggleSearchField:_})]}),c.jsx("div",{className:O("scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",$?"gap-y-1":"gap-y-6"),children:d?null:c.jsx(c.Fragment,{children:g?.length===0&&n?.length===0?c.jsx(ht,{titles:f.titles}):$?c.jsx(dt,{locale:e,conversationStyles:f,conversations:[...n,...g],searchQuery:N,selectedConversationId:o,handleConversationClick:s,shareConversationProps:l,isDisabled:u,actions:{...r,deleteConversation:P}}):Object.entries(h).map(([S,I])=>I?.length>0&&c.jsx(ct,{locale:e,isDisabled:u,groupLabel:S,conversationStyles:f,groupedConversations:I,handleConversationClick:s,actions:{...r,deleteConversation:P,renameConversation:H},shareConversationProps:l,selectedConversationId:o},S))})}),i]})},mt=({onCloseModal:s,disableModalDividers:o,signOut:r,isSmallButton:i,locale:d,titles:u})=>c.jsxs(w.Popup,{heading:u?.popupTitle||"Log out?",portalId:"sign-out",containerClassName:"sign-out-popup",size:w.PopUpSize.SM,dividers:!o,onClose:s,closeButtonTitle:"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:d,children:u?.popupText}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:u?.popupCancel||"Cancel",isSmallButton:i,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary",title:u?.popupApply||"Sign Out",isSmallButton:i,onClick:f=>{f.stopPropagation(),r?.()}})]})]}),ft=({userInfo:s,signOutAction:o,contactSupportUrl:r,styles:i,locale:d,titles:u})=>{const f=b=>b?.split(" ")?.map((N,E)=>E<2?N[0].toUpperCase():"")?.join("")??"",g=p.useMemo(()=>s?.name?f(s?.name):s?.email?.[0].toUpperCase()??"",[s]),[e,n]=p.useState(!1),t=s?.name?.split(" "),a=t?`${t?.[0]??""} ${t?.[1]?.[0]?t?.[1]?.[0]+".":""}`:s?.email??"",l=p.useCallback(()=>{n(!0)},[]),m=p.useCallback(()=>{n(!1)},[]),h=p.useCallback(()=>{window.open(r||"#","_blank","noopener,noreferrer")},[r]),x=p.useMemo(()=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:O("cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",i?.initialStyles),children:g}),c.jsx("p",{className:O("h3 cursor-pointer overflow-hidden text-ellipsis",i?.userNameStyles),children:(i?.showShortName?a:s?.name)??s?.email??""})]}),[g,a,i,s]),C=p.useMemo(()=>c.jsxs("div",{className:O("py-1",i?.dropDownStyles),children:[i?.settingsIcon&&c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.settings,children:[c.jsx("span",{className:"shrink-0",children:i?.settingsIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.settings||"Settings"})]}),i?.contactSupportIcon&&c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.contactSupport,onClick:h,children:[c.jsx("span",{className:"shrink-0",children:i?.contactSupportIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.contactSupport||"Contact support"})]}),c.jsx("div",{className:O("h-0 border-t border-neutrals-600 my-2",i?.showSeparator?"block":"hidden")}),c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.signOut,onClick:l,children:[c.jsx("span",{className:"shrink-0",children:i?.signOutIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.signOut||"Sign out"}),e&&c.jsx(mt,{onCloseModal:m,signOut:()=>o?.(),locale:d,disableModalDividers:i?.disableModalDividers,titles:u})]})]}),[i,u,l,h,e,m,d,o]);if(s)return c.jsx(w.Dropdown,{containerClassName:O("transition-opacity group-hover:opacity-100 shrink w-full",i?.dropdownContainerClassName),triggerButton:x,content:C,openedClassName:"action-menu-opened"})};exports.ActionMenu=ye;exports.ActionMenuItem=L;exports.ConversationList=pt;exports.User=ft;exports.getSharedConversationsGroup=he;exports.transformSharedConversations=ee;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),O=require("classnames"),p=require("react"),le=require("lodash"),w=require("@epam/statgpt-ui-components"),K=require("@tabler/icons-react"),je=require("jszip"),F=require("@epam/statgpt-shared-toolkit"),Y=require("@epam/statgpt-dial-toolkit");var L=(s=>(s.DELETE="delete",s.EXPORT="export",s.SHARE="share",s.RENAME="rename",s))(L||{}),B=(s=>(s.SHARED="shared",s.TODAY="today",s.YESTERDAY="yesterday",s.WEEK="week",s.EARLIER="earlier",s))(B||{});const ee=(s,o)=>s?.resources?.filter(r=>r?.parentPath===o)?.map(r=>{const i=`${r?.bucket}/${o}`,d=r?.url?.split("/")?.slice(1)?.join("/");return{...r,folderId:i,id:d,isShared:!0}})||[],he=s=>({[B.SHARED]:s}),Te={[B.TODAY]:[],[B.YESTERDAY]:[],[B.WEEK]:[],[B.EARLIER]:[]},pe=(s,o)=>s.toDateString()===o.toDateString(),De=(s,o)=>{const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()-1);return pe(o,r)},Oe=(s,o)=>{const r=s.getTime()-o.getTime();return Math.floor(r/(1e3*60*60*24))},ue=s=>s.updatedAt||Number(s.id?.split("-").pop()),ke=s=>{const o=new Date,r=le.cloneDeep(Te);for(const i of s)if(i.updatedAt){const d=new Date(i.updatedAt);let u;pe(o,d)?u=r[B.TODAY]:De(o,d)?u=r[B.YESTERDAY]:Oe(o,d)<=7?u=r[B.WEEK]:u=r[B.EARLIER],u?.some(f=>f.id===i.id)||u.push(i)}return r},me=s=>s?.sort((o,r)=>(ue(r)||0)-(ue(o)||0)),Le=(s,o)=>s===B.SHARED?o?.shared||"Shared":s===B.TODAY?o?.today||"Today":s===B.YESTERDAY?o?.yesterday||"Yesterday":s===B.WEEK?o?.lastWeek||"Last week":o?.earlier||"Earlier",Be=({onCloseModal:s,disableModalDividers:o,deleteConversation:r,isSmallButton:i,titles:d,locale:u})=>c.jsxs(w.Popup,{heading:d?.deleteTitle??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:w.PopUpSize.SM,dividers:!o,onClose:s,closeButtonTitle:d?.close??"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:u,children:d?.deleteMessage??"Are you sure you want to delete this conversation? This action cannot be undone."}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:d?.cancel??"Cancel",isSmallButton:i,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary text-button-primary-error",title:d?.delete??"Delete",isSmallButton:i,onClick:f=>{f.stopPropagation(),r()}})]})]}),Ue=s=>{const o=$e(F.getConversationAttachments(s)).map(r=>({...r,relativePath:"",contentLength:0}));return le.uniqBy(o,r=>Z(r.relativePath,r.name))},Fe=s=>s.endsWith("/"),ze=s=>{const o=s.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(r=>o.startsWith(r))},_e=s=>{const o=Z(...s.split("/").map(i=>decodeURIComponent(i))),r=o.lastIndexOf("/");return{absolutePath:o.slice(0,r),name:o.slice(r+1)}},$e=s=>s?s.map(o=>{if(!o.url||ze(o.url)||Fe(o.url))return null;const{absolutePath:r,name:i}=_e(o.url);return{id:o.url,name:i,contentType:o.type,folderId:r,absolutePath:r}}).filter(Boolean):[];async function He(s,o){const r=Ue(s),i=new je;r.forEach(g=>{const e=encodeURI(Z(g.absolutePath,g.name)),n=o(`${e}`.replace("files/","")),t=Ye(g.folderId),a=Z("res",t,g.name);i.file(a,n)});const d={version:5,history:[s].map(Qe)||[],folders:[]},u=JSON.stringify(d,null,2);return i.file("conversations/conversations_history.json",u),await i.generateAsync({type:"base64"})}const Ye=s=>{const o=s.split("/");return o.length>2?Z(...o.slice(2)):void 0},Qe=s=>le.omit(s,["publicationInfo"]),Z=(...s)=>s.filter(Boolean).join("/");function Ge(s,o){const r=document.createElement("a");r.download=o,r.href=s,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s)}var We=Object.defineProperty,te=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,de=(s,o,r)=>o in s?We(s,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[o]=r,ae=(s,o)=>{for(var r in o||(o={}))fe.call(o,r)&&de(s,r,o[r]);if(te)for(var r of te(o))ge.call(o,r)&&de(s,r,o[r]);return s},ie=(s,o)=>{var r={};for(var i in s)fe.call(s,i)&&o.indexOf(i)<0&&(r[i]=s[i]);if(s!=null&&te)for(var i of te(s))o.indexOf(i)<0&&ge.call(s,i)&&(r[i]=s[i]);return r};var W;(s=>{const o=class v{constructor(e,n,t,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version value out of range");if(a<-1||a>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let l=[];for(let h=0;h<this.size;h++)l.push(!1);for(let h=0;h<this.size;h++)this.modules.push(l.slice()),this.isFunction.push(l.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(t);if(this.drawCodewords(m),a==-1){let h=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const C=this.getPenaltyScore();C<h&&(a=x,h=C),this.applyMask(x)}}d(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(e,n){const t=s.QrSegment.makeSegments(e);return v.encodeSegments(t,n)}static encodeBinary(e,n){const t=s.QrSegment.makeBytes(e);return v.encodeSegments([t],n)}static encodeSegments(e,n,t=1,a=40,l=-1,m=!0){if(!(v.MIN_VERSION<=t&&t<=a&&a<=v.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let h,x;for(h=t;;h++){const E=v.getNumDataCodewords(h,n)*8,R=f.getTotalBits(e,h);if(R<=E){x=R;break}if(h>=a)throw new RangeError("Data too long")}for(const E of[v.Ecc.MEDIUM,v.Ecc.QUARTILE,v.Ecc.HIGH])m&&x<=v.getNumDataCodewords(h,E)*8&&(n=E);let C=[];for(const E of e){r(E.mode.modeBits,4,C),r(E.numChars,E.mode.numCharCountBits(h),C);for(const R of E.getData())C.push(R)}d(C.length==x);const b=v.getNumDataCodewords(h,n)*8;d(C.length<=b),r(0,Math.min(4,b-C.length),C),r(0,(8-C.length%8)%8,C),d(C.length%8==0);for(let E=236;C.length<b;E^=253)r(E,8,C);let N=[];for(;N.length*8<C.length;)N.push(0);return C.forEach((E,R)=>N[R>>>3]|=E<<7-(R&7)),new v(h,n,N,l)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),n=e.length;for(let t=0;t<n;t++)for(let a=0;a<n;a++)t==0&&a==0||t==0&&a==n-1||t==n-1&&a==0||this.drawAlignmentPattern(e[t],e[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const n=this.errorCorrectionLevel.formatBits<<3|e;let t=n;for(let l=0;l<10;l++)t=t<<1^(t>>>9)*1335;const a=(n<<10|t)^21522;d(a>>>15==0);for(let l=0;l<=5;l++)this.setFunctionModule(8,l,i(a,l));this.setFunctionModule(8,7,i(a,6)),this.setFunctionModule(8,8,i(a,7)),this.setFunctionModule(7,8,i(a,8));for(let l=9;l<15;l++)this.setFunctionModule(14-l,8,i(a,l));for(let l=0;l<8;l++)this.setFunctionModule(this.size-1-l,8,i(a,l));for(let l=8;l<15;l++)this.setFunctionModule(8,this.size-15+l,i(a,l));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;d(n>>>18==0);for(let t=0;t<18;t++){const a=i(n,t),l=this.size-11+t%3,m=Math.floor(t/3);this.setFunctionModule(l,m,a),this.setFunctionModule(m,l,a)}}drawFinderPattern(e,n){for(let t=-4;t<=4;t++)for(let a=-4;a<=4;a++){const l=Math.max(Math.abs(a),Math.abs(t)),m=e+a,h=n+t;0<=m&&m<this.size&&0<=h&&h<this.size&&this.setFunctionModule(m,h,l!=2&&l!=4)}}drawAlignmentPattern(e,n){for(let t=-2;t<=2;t++)for(let a=-2;a<=2;a++)this.setFunctionModule(e+a,n+t,Math.max(Math.abs(a),Math.abs(t))!=1)}setFunctionModule(e,n,t){this.modules[n][e]=t,this.isFunction[n][e]=!0}addEccAndInterleave(e){const n=this.version,t=this.errorCorrectionLevel;if(e.length!=v.getNumDataCodewords(n,t))throw new RangeError("Invalid argument");const a=v.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n],l=v.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n],m=Math.floor(v.getNumRawDataModules(n)/8),h=a-m%a,x=Math.floor(m/a);let C=[];const b=v.reedSolomonComputeDivisor(l);for(let E=0,R=0;E<a;E++){let A=e.slice(R,R+x-l+(E<h?0:1));R+=A.length;const T=v.reedSolomonComputeRemainder(A,b);E<h&&A.push(0),C.push(A.concat(T))}let N=[];for(let E=0;E<C[0].length;E++)C.forEach((R,A)=>{(E!=x-l||A>=h)&&N.push(R[E])});return d(N.length==m),N}drawCodewords(e){if(e.length!=Math.floor(v.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let a=0;a<this.size;a++)for(let l=0;l<2;l++){const m=t-l,x=(t+1&2)==0?this.size-1-a:a;!this.isFunction[x][m]&&n<e.length*8&&(this.modules[x][m]=i(e[n>>>3],7-(n&7)),n++)}}d(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let t=0;t<this.size;t++){let a;switch(e){case 0:a=(t+n)%2==0;break;case 1:a=n%2==0;break;case 2:a=t%3==0;break;case 3:a=(t+n)%3==0;break;case 4:a=(Math.floor(t/3)+Math.floor(n/2))%2==0;break;case 5:a=t*n%2+t*n%3==0;break;case 6:a=(t*n%2+t*n%3)%2==0;break;case 7:a=((t+n)%2+t*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][t]&&a&&(this.modules[n][t]=!this.modules[n][t])}}getPenaltyScore(){let e=0;for(let l=0;l<this.size;l++){let m=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[l][C]==m?(h++,h==5?e+=v.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),m||(e+=this.finderPenaltyCountPatterns(x)*v.PENALTY_N3),m=this.modules[l][C],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,x)*v.PENALTY_N3}for(let l=0;l<this.size;l++){let m=!1,h=0,x=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][l]==m?(h++,h==5?e+=v.PENALTY_N1:h>5&&e++):(this.finderPenaltyAddHistory(h,x),m||(e+=this.finderPenaltyCountPatterns(x)*v.PENALTY_N3),m=this.modules[C][l],h=1);e+=this.finderPenaltyTerminateAndCount(m,h,x)*v.PENALTY_N3}for(let l=0;l<this.size-1;l++)for(let m=0;m<this.size-1;m++){const h=this.modules[l][m];h==this.modules[l][m+1]&&h==this.modules[l+1][m]&&h==this.modules[l+1][m+1]&&(e+=v.PENALTY_N2)}let n=0;for(const l of this.modules)n=l.reduce((m,h)=>m+(h?1:0),n);const t=this.size*this.size,a=Math.ceil(Math.abs(n*20-t*10)/t)-1;return d(0<=a&&a<=9),e+=a*v.PENALTY_N4,d(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let a=this.size-7;t.length<e;a-=n)t.splice(1,0,a);return t}}static getNumRawDataModules(e){if(e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return d(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(v.getNumRawDataModules(e)/8)-v.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*v.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let a=0;a<e-1;a++)n.push(0);n.push(1);let t=1;for(let a=0;a<e;a++){for(let l=0;l<n.length;l++)n[l]=v.reedSolomonMultiply(n[l],t),l+1<n.length&&(n[l]^=n[l+1]);t=v.reedSolomonMultiply(t,2)}return n}static reedSolomonComputeRemainder(e,n){let t=n.map(a=>0);for(const a of e){const l=a^t.shift();t.push(0),n.forEach((m,h)=>t[h]^=v.reedSolomonMultiply(m,l))}return t}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let t=0;for(let a=7;a>=0;a--)t=t<<1^(t>>>7)*285,t^=(n>>>a&1)*e;return d(t>>>8==0),t}finderPenaltyCountPatterns(e){const n=e[1];d(n<=this.size*3);const t=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(t&&e[0]>=n*4&&e[6]>=n?1:0)+(t&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,t){return e&&(this.finderPenaltyAddHistory(n,t),n=0),n+=this.size,this.finderPenaltyAddHistory(n,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],o.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=o;function r(g,e,n){if(e<0||e>31||g>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)n.push(g>>>t&1)}function i(g,e){return(g>>>e&1)!=0}function d(g){if(!g)throw new Error("Assertion error")}const u=class y{constructor(e,n,t){if(this.mode=e,this.numChars=n,this.bitData=t,n<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new y(y.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!y.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const a=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+a),10),a*3+1,n),t+=a}return new y(y.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!y.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],t;for(t=0;t+2<=e.length;t+=2){let a=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;a+=y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(a,11,n)}return t<e.length&&r(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new y(y.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:y.isNumeric(e)?[y.makeNumeric(e)]:y.isAlphanumeric(e)?[y.makeAlphanumeric(e)]:[y.makeBytes(y.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else if(e<1e6)r(6,3,n),r(e,21,n);else throw new RangeError("ECI assignment value out of range");return new y(y.Mode.ECI,0,n)}static isNumeric(e){return y.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return y.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let t=0;for(const a of e){const l=a.mode.numCharCountBits(n);if(a.numChars>=1<<l)return 1/0;t+=4+l+a.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?n.push(e.charCodeAt(t)):(n.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return n}};u.NUMERIC_REGEX=/^[0-9]*$/,u.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,u.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let f=u;s.QrSegment=u})(W||(W={}));(s=>{(o=>{const r=class{constructor(d,u){this.ordinal=d,this.formatBits=u}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),o.Ecc=r})(s.QrCode||(s.QrCode={}))})(W||(W={}));(s=>{(o=>{const r=class{constructor(d,u){this.modeBits=d,this.numBitsCharCount=u}numCharCountBits(d){return this.numBitsCharCount[Math.floor((d+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),o.Mode=r})(s.QrSegment||(s.QrSegment={}))})(W||(W={}));var X=W;var Ve={L:X.QrCode.Ecc.LOW,M:X.QrCode.Ecc.MEDIUM,Q:X.QrCode.Ecc.QUARTILE,H:X.QrCode.Ecc.HIGH},Ce=128,Ee="L",xe="#FFFFFF",we="#000000",ve=!1,Ne=1,Xe=4,Ke=0,qe=.1;function Re(s,o=0){const r=[];return s.forEach(function(i,d){let u=null;i.forEach(function(f,g){if(!f&&u!==null){r.push(`M${u+o} ${d+o}h${g-u}v1H${u+o}z`),u=null;return}if(g===i.length-1){if(!f)return;u===null?r.push(`M${g+o},${d+o} h1v1H${g+o}z`):r.push(`M${u+o},${d+o} h${g+1-u}v1H${u+o}z`);return}f&&u===null&&(u=g)})}),r.join("")}function be(s,o){return s.slice().map((r,i)=>i<o.y||i>=o.y+o.h?r:r.map((d,u)=>u<o.x||u>=o.x+o.w?d:!1))}function Ze(s,o,r,i){if(i==null)return null;const d=s.length+r*2,u=Math.floor(o*qe),f=d/o,g=(i.width||u)*f,e=(i.height||u)*f,n=i.x==null?s.length/2-g/2:i.x*f,t=i.y==null?s.length/2-e/2:i.y*f,a=i.opacity==null?1:i.opacity;let l=null;if(i.excavate){let h=Math.floor(n),x=Math.floor(t),C=Math.ceil(g+n-h),b=Math.ceil(e+t-x);l={x:h,y:x,w:C,h:b}}const m=i.crossOrigin;return{x:n,y:t,h:e,w:g,excavation:l,opacity:a,crossOrigin:m}}function Je(s,o){return o!=null?Math.max(Math.floor(o),0):s?Xe:Ke}function Se({value:s,level:o,minVersion:r,includeMargin:i,marginSize:d,imageSettings:u,size:f,boostLevel:g}){let e=p.useMemo(()=>{const h=(Array.isArray(s)?s:[s]).reduce((x,C)=>(x.push(...X.QrSegment.makeSegments(C)),x),[]);return X.QrCode.encodeSegments(h,Ve[o],r,void 0,void 0,g)},[s,o,r,g]);const{cells:n,margin:t,numCells:a,calculatedImageSettings:l}=p.useMemo(()=>{let m=e.getModules();const h=Je(i,d),x=m.length+h*2,C=Ze(m,f,h,u);return{cells:m,margin:h,numCells:x,calculatedImageSettings:C}},[e,f,u,i,d]);return{qrcode:e,margin:t,cells:n,numCells:a,calculatedImageSettings:l}}var et=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),tt=p.forwardRef(function(o,r){const i=o,{value:d,size:u=Ce,level:f=Ee,bgColor:g=xe,fgColor:e=we,includeMargin:n=ve,minVersion:t=Ne,boostLevel:a,marginSize:l,imageSettings:m}=i,x=ie(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=x,b=ie(x,["style"]),N=m?.src,E=p.useRef(null),R=p.useRef(null),A=p.useCallback(_=>{E.current=_,typeof r=="function"?r(_):r&&(r.current=_)},[r]),[T,M]=p.useState(!1),{margin:D,cells:z,numCells:H,calculatedImageSettings:P}=Se({value:d,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:l,imageSettings:m,size:u});p.useEffect(()=>{if(E.current!=null){const _=E.current,S=_.getContext("2d");if(!S)return;let I=z;const j=R.current,k=P!=null&&j!==null&&j.complete&&j.naturalHeight!==0&&j.naturalWidth!==0;k&&P.excavation!=null&&(I=be(z,P.excavation));const Q=window.devicePixelRatio||1;_.height=_.width=u*Q;const V=u/H*Q;S.scale(V,V),S.fillStyle=g,S.fillRect(0,0,H,H),S.fillStyle=e,et?S.fill(new Path2D(Re(I,D))):z.forEach(function(ne,J){ne.forEach(function(se,oe){se&&S.fillRect(oe+D,J+D,1,1)})}),P&&(S.globalAlpha=P.opacity),k&&S.drawImage(j,P.x+D,P.y+D,P.w,P.h)}}),p.useEffect(()=>{M(!1)},[N]);const $=ae({height:u,width:u},C);let G=null;return N!=null&&(G=p.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{M(!0)},ref:R,crossOrigin:P?.crossOrigin})),p.createElement(p.Fragment,null,p.createElement("canvas",ae({style:$,height:u,width:u,ref:A,role:"img"},b)),G)});tt.displayName="QRCodeCanvas";var Me=p.forwardRef(function(o,r){const i=o,{value:d,size:u=Ce,level:f=Ee,bgColor:g=xe,fgColor:e=we,includeMargin:n=ve,minVersion:t=Ne,boostLevel:a,title:l,marginSize:m,imageSettings:h}=i,x=ie(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:b,numCells:N,calculatedImageSettings:E}=Se({value:d,level:f,minVersion:t,boostLevel:a,includeMargin:n,marginSize:m,imageSettings:h,size:u});let R=b,A=null;h!=null&&E!=null&&(E.excavation!=null&&(R=be(b,E.excavation)),A=p.createElement("image",{href:h.src,height:E.h,width:E.w,x:E.x+C,y:E.y+C,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const T=Re(R,C);return p.createElement("svg",ae({height:u,width:u,viewBox:`0 0 ${N} ${N}`,ref:r,role:"img"},x),!!l&&p.createElement("title",null,l),p.createElement("path",{fill:g,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),p.createElement("path",{fill:e,d:T,shapeRendering:"crispEdges"}),A)});Me.displayName="QRCodeSVG";const nt=(s,o)=>({invitationType:Y.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(s)}`},...o]}),st=s=>{const o=s?.invitationLink?.split("/").at(-1)||"";return`/${F.SHARE_CONVERSATION_ROUTE}/${o}`},ot=(s,o)=>o?.find(r=>{const i=s?.id?.split("/")?.pop(),d=r?.url?.split("/")?.pop()||"";return d===i||decodeURI(d)===i}),rt=s=>s?.messages?.filter(r=>!!r?.custom_content?.attachments)?.flatMap(r=>r?.custom_content?.attachments?.map(i=>({url:i?.url||""}))||[])?.filter(r=>!!r?.url)||[],at=({conversation:s,locale:o,onCloseModal:r,modalDividers:i,getConversation:d,generateConversationLink:u,chatExpiration:f,chatExpirationDays:g,close:e,chatWarning:n,shareLink:t,shareCopyLink:a,shareCopiedLink:l,shareDescription:m,shareRemoveAccessToUsers:h,chatName:x,getSharedConversations:C,revokeSharedConversations:b,baseUrl:N,id:E,clientSharedPage:R,clientSharedProp:A})=>{const[T,M]=p.useState(null),[D,z]=p.useState(),[H,P]=p.useState(!1),[$,G]=p.useState(!1),[_,S]=p.useState(),I=p.useRef(null),j=p.useRef(null),k=p.useMemo(()=>s?.id?decodeURI(s.id):E?.[0]&&E?.[1]&&o?decodeURI(`${E[0]}/${o}/${E[1]}`):null,[s?.id,E,o]),Q=p.useMemo(()=>{if(!T)return"";const U=N||window.location.origin;if(N&&N!==window.location.origin&&R&&A){const q=T.split(`/${F.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${U}/${R}?${A}=${q}`}return`${U}/${o}${T}`},[N,T,o,R,A]),V=p.useCallback(async U=>{const q=await C?.(Y.getSharedConversationsRequest(Y.ShareTarget.OTHERS));if(q)return ot({id:U},q.resources)},[C]);p.useEffect(()=>{if(!k||I.current===k)return;I.current=k,P(!1),j.current?.abort();const U=new AbortController;return j.current=U,(async()=>{try{const re=await d?.(k),Ie=nt(k,rt(re)),ce=await u?.(Ie),Pe=await V(k);if(U.signal.aborted||!ce)return;M(st(ce)),z(Pe),P(!0)}catch(re){if(U.signal.aborted)return;P(!1),console.error("Error sharing conversation",re)}})(),()=>{U.abort(),I.current=null}},[k,u,d,V]);const ne=p.useCallback(()=>{j.current?.abort(),I.current=null,r(),M(null),P(!1),G(!1)},[r]),J=p.useCallback(()=>{G(!0),navigator.clipboard.writeText(Q||"")},[Q]),se=async()=>{try{if(S(!0),D&&await b?.({resources:[D]}),k){const U=await V(k);j.current?.signal.aborted||z(U)}}catch(U){console.error("Error revoking shared conversation",U)}finally{j.current?.signal.aborted||S(!1)}},oe=p.useCallback(()=>c.jsx(w.Button,{buttonClassName:$?"text-button-secondary":"text-button-primary",iconBefore:$?c.jsx(K.IconCheck,{width:20,height:20}):c.jsx(K.IconCopy,{width:20,height:20}),title:$?l??"Copied":a??"Copy link",disabled:$,onClick:J}),[$,J,l,a]);return c.jsxs(w.Popup,{heading:t??"Share link",portalId:"share",size:w.PopUpSize.SM,dividers:i,onClose:ne,closeButtonTitle:e??"Close",children:[H?c.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[s?.name?c.jsxs("div",{className:"share-info flex w-full",children:[c.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:x??"Chat name:"}),c.jsx("h3",{className:"min-w-0 flex-1 truncate",title:s?.name,children:s?.name})]}):null,c.jsxs("div",{className:"share-info flex",children:[c.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:f??"Link expiration date:"}),c.jsxs("h3",{children:["3 ",g??"days"]})]}),c.jsx(Me,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:Q,size:200}),c.jsx("p",{className:"body-2 text-neutrals-1000",children:m??"Your name, special instructions, and any messages you add after sharing remain confidential."}),c.jsx(w.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:Q,value:Q,inputId:"conversationLink",iconAfterInput:oe()})]}):c.jsx("div",{className:"flex items-center justify-center p-6",children:c.jsx(w.Loader,{})}),H?s&&D?c.jsx("div",{className:"remove-access",children:c.jsx(w.Button,{title:h??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:_,onClick:se})}):c.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:n??"This chat has not been shared with anyone yet."}):c.jsx("div",{})]})},it=({conversation:s,onCloseModal:o,renameConversation:r,locale:i,disableModalDividers:d,titles:u,isSmallButton:f})=>{const[g,e]=p.useState(s?.name||""),n=a=>{e(a)},t=()=>{const a=`${s?.folderId}/${encodeURIComponent(F.getClearedConversationName(g))}-${new Date().getTime()}`;r(`conversations/${s.id}`,`conversations/${a}`)};return c.jsxs(w.Popup,{heading:u?.renameTitle??"Rename conversation",portalId:"rename-conversation",containerClassName:"rename-conversation-popup",size:w.PopUpSize.SM,dividers:!d,onClose:o,closeButtonTitle:u?.close??"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:i,children:c.jsx(w.Input,{inputId:"rename",value:g,onChange:n,cssClass:"w-full"})}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:u?.cancel??"Cancel",isSmallButton:f,onClick:a=>{a.stopPropagation(),o()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary text-button-primary",title:u?.save??"Rename",isSmallButton:f,disabled:!g,onClick:a=>{a.stopPropagation(),t()}})]})]})},ye=({conversation:s,conversationStyles:o,shareConversationProps:r,onConversationDelete:i,getConversation:d,getFileBlob:u,renameConversation:f,triggerButton:g,locale:e,isDisabled:n})=>{const t=p.useMemo(()=>{const M=[{key:L.DELETE,title:o?.titles?.delete??"Delete",icon:o.actionsIcons?.[L.DELETE]}];return s?.model?.id?.endsWith(F.ONBOARDING_MODEL_POSTFIX)?M:[...s.isShared?[]:[{key:L.SHARE,title:o?.titles?.share??"Share",icon:o.actionsIcons?.[L.SHARE]},{key:L.RENAME,title:o?.titles?.rename??"Rename",icon:o.actionsIcons?.[L.RENAME]}],{key:L.EXPORT,title:o?.titles?.export??"Export",icon:o.actionsIcons?.[L.EXPORT]},...M]},[s.isShared,s?.model?.id,o.titles,o.actionsIcons]),[a,l]=p.useState(w.PopUpState.Closed),[m,h]=p.useState(w.PopUpState.Closed),[x,C]=p.useState(w.PopUpState.Closed),b=p.useCallback(()=>{l(w.PopUpState.Closed)},[l]),N=p.useCallback(()=>{h(w.PopUpState.Closed)},[h]),E=p.useCallback(()=>{C(w.PopUpState.Closed)},[C]),R=p.useCallback(()=>{i(s),b()},[s,i,b]),A=p.useCallback((M,D)=>{f(M,D),E()},[f,E]),T=M=>{M===L.DELETE&&l(w.PopUpState.Opened),M===L.SHARE&&h(w.PopUpState.Opened),M===L.RENAME&&C(w.PopUpState.Opened),M===L.EXPORT&&d(decodeURI(s.id)).then(D=>{He(D,u).then(z=>{Ge(`data:application/zip;base64,${z}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return c.jsxs(c.Fragment,{children:[c.jsx(w.Dropdown,{containerClassName:"ml-3 group-hover:visible invisible",triggerButton:g??c.jsx(lt,{disabled:n}),options:t,openedClassName:"action-menu-opened",onOptionSelect:T,disabled:n}),a===w.PopUpState.Opened&&c.jsx(Be,{titles:o.titles,locale:e,disableModalDividers:o.disableModalDividers,isSmallButton:o.isSmallModalButton,deleteConversation:R,onCloseModal:b}),m===w.PopUpState.Opened&&c.jsx(at,{conversation:s,locale:e,onCloseModal:N,...r}),x===w.PopUpState.Opened&&c.jsx(it,{conversation:s,locale:e,titles:o.titles,renameConversation:A,onCloseModal:E,disableModalDividers:o.disableModalDividers,isSmallButton:o.isSmallModalButton})]})},lt=({disabled:s})=>c.jsx("div",{className:O("flex items-center justify-center w-[24px]",s?"cursor-not-allowed":"cursor-pointer"),children:c.jsx(K.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),Ae=({conversation:s,selectedConversationId:o,searchQuery:r,onConversationClick:i,actions:d,locale:u,isDisabled:f,conversationStyles:g,shareConversationProps:e})=>{const n=p.useRef(null),t=F.getClearedConversationName(s?.name);return p.useEffect(()=>{if(s?.id===o&&n?.current){const a=n.current.parentElement?.parentElement?.parentElement;if(a){const l=n.current.getBoundingClientRect(),m=a.getBoundingClientRect(),h=l.height,x=m.height,b=l.top-m.top+a.scrollTop-(x/2-h/2);a.scrollTo({top:b,behavior:"smooth"})}}},[s,o]),c.jsxs("div",{ref:n,className:O("flex justify-between items-center py-2 px-3 border-transparent relative group border","conversation-item",o===s?.id&&"bg-hues-100 conversation-item-active",f?"cursor-not-allowed":"cursor-pointer hover:border-hues-600"),onClick:()=>!f&&i(s.folderId,s?.id),title:f?g?.titles?.noActionsAllowed:t,children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[g.conversationItemIcon?g.conversationItemIcon:null,c.jsx("h3",{className:O("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",o===s?.id?"conversation-item-text-active":""),title:f?g?.titles?.noActionsAllowed:t,children:r?.length?c.jsx(w.HighlightText,{text:t,highlightText:r}):t})]}),c.jsx(ye,{locale:u,conversationStyles:g,conversation:s,onConversationDelete:d.deleteConversation,getConversation:d.getConversation,getFileBlob:d.getFileBlob,renameConversation:d.renameConversation,shareConversationProps:e,isDisabled:f})]})},ct=({handleConversationClick:s,actions:o,selectedConversationId:r,groupLabel:i,conversationStyles:d,groupedConversations:u,shareConversationProps:f,locale:g,isDisabled:e})=>{const[n,t]=p.useState(!1),a=p.useCallback(()=>{t(l=>!l)},[t]);return c.jsxs("div",{children:[c.jsxs("div",{className:"conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700",onClick:a,children:[c.jsx(K.IconCaretRightFilled,{className:O("w-3 h-3 conversation-group-items-arrow",n?"rotate-[90deg]":"rotate-0")}),c.jsx("span",{className:"body-3 conversation-group-items-title-text",children:Le(i,d?.titles)})]}),!n&&c.jsx("div",{className:O("flex flex-col gap-y-3","conversation-group-items"),children:me(u).map(l=>c.jsx(Ae,{locale:g,isDisabled:e,conversationStyles:d,conversation:l,selectedConversationId:r,onConversationClick:s,actions:o,shareConversationProps:f},l.id||l.name))})]},i)},ut=({searchQuery:s,isExpandedSearch:o,titles:r,searchIcon:i,onSearchConversations:d,toggleSearchField:u})=>c.jsx(c.Fragment,{children:o?c.jsx(w.InputWithIcon,{inputId:"conversations-search",placeholder:r?.searchPlaceholder??"Search",containerClasses:"conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:s,iconAfterInput:c.jsx(w.IconButton,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:u,icon:c.jsx(K.IconX,{})}),onChange:d}):c.jsx(w.Button,{buttonClassName:"text-button-tertiary p-0 search-button",iconBefore:i||c.jsx(K.IconSearch,{className:"size-5"}),onClick:u})}),dt=({conversations:s,selectedConversationId:o,searchQuery:r,conversationStyles:i,handleConversationClick:d,actions:u,locale:f,shareConversationProps:g,isDisabled:e})=>{const[n,t]=p.useState([]);return p.useEffect(()=>{t(me(s?.filter(a=>F.getClearedConversationName(a?.name)?.includes(r||""))))},[s,r]),c.jsx(c.Fragment,{children:n?.length?n.map(a=>c.jsx(Ae,{locale:f,conversationStyles:i,conversation:a,searchQuery:r,selectedConversationId:o,onConversationClick:d,actions:u,shareConversationProps:g,isDisabled:e},a.id)):c.jsx("h3",{className:"text-neutrals-800",children:i?.titles?.noConversation??"No conversations yet"})})},ht=({titles:s})=>c.jsxs("div",{className:"flex flex-col p-8 text-center",children:[c.jsx("p",{className:"text-neutrals-800",children:s?.noConversation??"No conversations yet"}),c.jsx("p",{className:"mt-2 text-sm text-neutrals-800",children:s?.clickNewChat??'Click "New Chat" to start a conversation'})]}),pt=({handleConversationClick:s,selectedConversationId:o,actions:r,children:i,isCollapsed:d,isStreaming:u,conversationStyles:f,conversations:g,locale:e,sharedConversations:n,setConversations:t,setSharedConversations:a,shareConversationProps:l,handleSelectedConversationRemove:m})=>{const[h,x]=p.useState({}),[C,b]=p.useState(!0),[N,E]=p.useState(""),[R,A]=p.useState(!1),{getConversations:T,getSharedConversations:M,deleteConversation:D,renameConversation:z}=r,H=p.useMemo(()=>!!N?.length,[N]);p.useEffect(()=>{x({...he(n),...ke(g)})},[g,n]),p.useEffect(()=>{async function S(){try{b(!0);const I=await T(e),j=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(I)),a(F.cleanConversationNames(ee(j,e)))}catch(I){console.error("Error loading conversation",I)}finally{b(!1)}}S()},[T,t,e,M,a]);const P=p.useCallback(async S=>{try{await D(S);const I=await T(e),j=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(I)),a(F.cleanConversationNames(ee(j,e))),o===S?.id&&m()}catch(I){console.error("Error deleting conversation",I)}},[D,T,e,M,t,a,o,m]),$=p.useCallback(async(S,I)=>{try{b(!0),await z(S,I);const j=await T(e),k=await M(Y.getSharedConversationsRequest(Y.ShareTarget.ME));t(F.cleanConversationNames(j)),a(F.cleanConversationNames(ee(k,e)))}catch(j){console.error("Error renaming conversation",j)}finally{b(!1)}},[T,e,M,t,a,z]),G=p.useCallback(S=>{E(S)},[E]),_=p.useCallback(()=>{A(S=>!S),E("")},[A]);return C?c.jsx(w.Loader,{}):c.jsxs(c.Fragment,{children:[!d&&c.jsxs("div",{className:O("flex justify-between items-center",R?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!R&&c.jsx("h3",{className:"sm:body-2 text-neutrals-700",children:f?.titles?.allChats??"All Chats"}),c.jsx(ut,{searchQuery:N,searchIcon:f.searchIcon,titles:f.titles,isExpandedSearch:R,onSearchConversations:G,toggleSearchField:_})]}),c.jsx("div",{className:O("scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",H?"gap-y-1":"gap-y-6"),children:d?null:c.jsx(c.Fragment,{children:g?.length===0&&n?.length===0?c.jsx(ht,{titles:f.titles}):H?c.jsx(dt,{locale:e,conversationStyles:f,conversations:[...n,...g],searchQuery:N,selectedConversationId:o,handleConversationClick:s,shareConversationProps:l,isDisabled:u,actions:{...r,deleteConversation:P,renameConversation:$}}):Object.entries(h).map(([S,I])=>I?.length>0&&c.jsx(ct,{locale:e,isDisabled:u,groupLabel:S,conversationStyles:f,groupedConversations:I,handleConversationClick:s,actions:{...r,deleteConversation:P,renameConversation:$},shareConversationProps:l,selectedConversationId:o},S))})}),i]})},mt=({onCloseModal:s,disableModalDividers:o,signOut:r,isSmallButton:i,locale:d,titles:u})=>c.jsxs(w.Popup,{heading:u?.popupTitle||"Log out?",portalId:"sign-out",containerClassName:"sign-out-popup",size:w.PopUpSize.SM,dividers:!o,onClose:s,closeButtonTitle:"Cancel",children:[c.jsx("div",{className:"px-6 py-4 sm:px-0",lang:d,children:u?.popupText}),c.jsxs("div",{className:"delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",children:[c.jsx(w.Button,{buttonClassName:"cancel-button",title:u?.popupCancel||"Cancel",isSmallButton:i,onClick:f=>{f.stopPropagation(),s()}}),c.jsx(w.Button,{buttonClassName:"text-button-primary",title:u?.popupApply||"Sign Out",isSmallButton:i,onClick:f=>{f.stopPropagation(),r?.()}})]})]}),ft=({userInfo:s,signOutAction:o,contactSupportUrl:r,styles:i,locale:d,titles:u})=>{const f=b=>b?.split(" ")?.map((N,E)=>E<2?N[0].toUpperCase():"")?.join("")??"",g=p.useMemo(()=>s?.name?f(s?.name):s?.email?.[0].toUpperCase()??"",[s]),[e,n]=p.useState(!1),t=s?.name?.split(" "),a=t?`${t?.[0]??""} ${t?.[1]?.[0]?t?.[1]?.[0]+".":""}`:s?.email??"",l=p.useCallback(()=>{n(!0)},[]),m=p.useCallback(()=>{n(!1)},[]),h=p.useCallback(()=>{window.open(r||"#","_blank","noopener,noreferrer")},[r]),x=p.useMemo(()=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:O("cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",i?.initialStyles),children:g}),c.jsx("p",{className:O("h3 cursor-pointer overflow-hidden text-ellipsis",i?.userNameStyles),children:(i?.showShortName?a:s?.name)??s?.email??""})]}),[g,a,i,s]),C=p.useMemo(()=>c.jsxs("div",{className:O("py-1",i?.dropDownStyles),children:[i?.settingsIcon&&c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.settings,children:[c.jsx("span",{className:"shrink-0",children:i?.settingsIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.settings||"Settings"})]}),i?.contactSupportIcon&&c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.contactSupport,onClick:h,children:[c.jsx("span",{className:"shrink-0",children:i?.contactSupportIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.contactSupport||"Contact support"})]}),c.jsx("div",{className:O("h-0 border-t border-neutrals-600 my-2",i?.showSeparator?"block":"hidden")}),c.jsxs("button",{className:O("p-2 items-center flex gap-1 text-primary fill-primary",i?.dropdownButtonTypographyStyles||"body-1",i?.dropdownButtonStyles),title:u?.signOut,onClick:l,children:[c.jsx("span",{className:"shrink-0",children:i?.signOutIcon}),c.jsx("span",{className:"min-w-0 break-words",children:u?.signOut||"Sign out"}),e&&c.jsx(mt,{onCloseModal:m,signOut:()=>o?.(),locale:d,disableModalDividers:i?.disableModalDividers,titles:u})]})]}),[i,u,l,h,e,m,d,o]);if(s)return c.jsx(w.Dropdown,{containerClassName:O("transition-opacity group-hover:opacity-100 shrink w-full",i?.dropdownContainerClassName),triggerButton:x,content:C,openedClassName:"action-menu-opened"})};exports.ActionMenu=ye;exports.ActionMenuItem=L;exports.ConversationList=pt;exports.User=ft;exports.getSharedConversationsGroup=he;exports.transformSharedConversations=ee;
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as M, jsx as h, Fragment as te } from "react/jsx-runtime";
2
2
  import B from "classnames";
3
- import D, { useState as k, useRef as me, useMemo as X, useCallback as O, useEffect as ne } from "react";
3
+ import D, { useState as k, useRef as fe, useMemo as X, useCallback as O, useEffect as ne } from "react";
4
4
  import { cloneDeep as Ye, uniqBy as Qe, omit as Ge } from "lodash";
5
5
  import { Popup as le, PopUpSize as ce, Button as j, Loader as Re, InputWithIcon as ye, Input as je, PopUpState as $, Dropdown as Me, HighlightText as We, IconButton as Ve } from "@epam/statgpt-ui-components";
6
6
  import { IconCheck as Xe, IconCopy as Ke, IconDotsVertical as Ze, IconCaretRightFilled as Je, IconX as qe, IconSearch as et } from "@tabler/icons-react";
@@ -8,7 +8,7 @@ import tt from "jszip";
8
8
  import { getConversationAttachments as nt, SHARE_CONVERSATION_ROUTE as be, getClearedConversationName as Ee, ONBOARDING_MODEL_POSTFIX as ot, cleanConversationNames as J } from "@epam/statgpt-shared-toolkit";
9
9
  import { InvitationType as rt, getSharedConversationsRequest as se, ShareTarget as ie } from "@epam/statgpt-dial-toolkit";
10
10
  var _ = /* @__PURE__ */ ((o) => (o.DELETE = "delete", o.EXPORT = "export", o.SHARE = "share", o.RENAME = "rename", o))(_ || {}), U = /* @__PURE__ */ ((o) => (o.SHARED = "shared", o.TODAY = "today", o.YESTERDAY = "yesterday", o.WEEK = "week", o.EARLIER = "earlier", o))(U || {});
11
- const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) => {
11
+ const me = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) => {
12
12
  const a = `${s?.bucket}/${r}`, d = s?.url?.split("/")?.slice(1)?.join("/");
13
13
  return {
14
14
  ...s,
@@ -40,7 +40,7 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
40
40
  const d = new Date(a.updatedAt);
41
41
  let c;
42
42
  Ae(r, d) ? c = s[U.TODAY] : at(r, d) ? c = s[U.YESTERDAY] : lt(r, d) <= 7 ? c = s[U.WEEK] : c = s[U.EARLIER], c?.some(
43
- (f) => f.id === a.id
43
+ (m) => m.id === a.id
44
44
  ) || c.push(a);
45
45
  }
46
46
  return s;
@@ -72,8 +72,8 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
72
72
  buttonClassName: "cancel-button",
73
73
  title: d?.cancel ?? "Cancel",
74
74
  isSmallButton: a,
75
- onClick: (f) => {
76
- f.stopPropagation(), o();
75
+ onClick: (m) => {
76
+ m.stopPropagation(), o();
77
77
  }
78
78
  }
79
79
  ),
@@ -83,8 +83,8 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
83
83
  buttonClassName: "text-button-primary text-button-primary-error",
84
84
  title: d?.delete ?? "Delete",
85
85
  isSmallButton: a,
86
- onClick: (f) => {
87
- f.stopPropagation(), s();
86
+ onClick: (m) => {
87
+ m.stopPropagation(), s();
88
88
  }
89
89
  }
90
90
  )
@@ -103,7 +103,7 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
103
103
  r,
104
104
  (s) => oe(s.relativePath, s.name)
105
105
  );
106
- }, pt = (o) => o.endsWith("/"), ft = (o) => {
106
+ }, pt = (o) => o.endsWith("/"), mt = (o) => {
107
107
  const r = o.toLowerCase();
108
108
  return [
109
109
  "data:",
@@ -116,7 +116,7 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
116
116
  "telnet://",
117
117
  "api/files"
118
118
  ].some((s) => r.startsWith(s));
119
- }, mt = (o) => {
119
+ }, ft = (o) => {
120
120
  const r = oe(
121
121
  ...o.split("/").map((a) => decodeURIComponent(a))
122
122
  ), s = r.lastIndexOf("/");
@@ -125,9 +125,9 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
125
125
  name: r.slice(s + 1)
126
126
  };
127
127
  }, gt = (o) => o ? o.map((r) => {
128
- if (!r.url || ft(r.url) || pt(r.url))
128
+ if (!r.url || mt(r.url) || pt(r.url))
129
129
  return null;
130
- const { absolutePath: s, name: a } = mt(r.url);
130
+ const { absolutePath: s, name: a } = ft(r.url);
131
131
  return {
132
132
  id: r.url,
133
133
  name: a,
@@ -138,8 +138,8 @@ const fe = (o, r) => o?.resources?.filter((s) => s?.parentPath === r)?.map((s) =
138
138
  }).filter(Boolean) : [];
139
139
  async function Ct(o, r) {
140
140
  const s = ht(o), a = new tt();
141
- s.forEach((m) => {
142
- const e = encodeURI(oe(m.absolutePath, m.name)), n = r(`${e}`.replace("files/", "")), t = Et(m.folderId), i = oe("res", t, m.name);
141
+ s.forEach((f) => {
142
+ const e = encodeURI(oe(f.absolutePath, f.name)), n = r(`${e}`.replace("files/", "")), t = Et(f.folderId), i = oe("res", t, f.name);
143
143
  a.file(i, n);
144
144
  });
145
145
  const d = {
@@ -237,7 +237,7 @@ var K;
237
237
  throw new RangeError("Invalid value");
238
238
  let u, E;
239
239
  for (u = t; ; u++) {
240
- const C = w.getNumDataCodewords(u, n) * 8, v = f.getTotalBits(e, u);
240
+ const C = w.getNumDataCodewords(u, n) * 8, v = m.getTotalBits(e, u);
241
241
  if (v <= C) {
242
242
  E = v;
243
243
  break;
@@ -560,17 +560,17 @@ var K;
560
560
  [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
561
561
  // High
562
562
  ], o.QrCode = r;
563
- function s(m, e, n) {
564
- if (e < 0 || e > 31 || m >>> e)
563
+ function s(f, e, n) {
564
+ if (e < 0 || e > 31 || f >>> e)
565
565
  throw new RangeError("Value out of range");
566
566
  for (let t = e - 1; t >= 0; t--)
567
- n.push(m >>> t & 1);
567
+ n.push(f >>> t & 1);
568
568
  }
569
- function a(m, e) {
570
- return (m >>> e & 1) != 0;
569
+ function a(f, e) {
570
+ return (f >>> e & 1) != 0;
571
571
  }
572
- function d(m) {
573
- if (!m)
572
+ function d(f) {
573
+ if (!f)
574
574
  throw new Error("Assertion error");
575
575
  }
576
576
  const c = class A {
@@ -676,7 +676,7 @@ var K;
676
676
  }
677
677
  };
678
678
  c.NUMERIC_REGEX = /^[0-9]*$/, c.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, c.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
679
- let f = c;
679
+ let m = c;
680
680
  o.QrSegment = c;
681
681
  })(K || (K = {}));
682
682
  ((o) => {
@@ -719,22 +719,22 @@ function Be(o, r = 0) {
719
719
  const s = [];
720
720
  return o.forEach(function(a, d) {
721
721
  let c = null;
722
- a.forEach(function(f, m) {
723
- if (!f && c !== null) {
722
+ a.forEach(function(m, f) {
723
+ if (!m && c !== null) {
724
724
  s.push(
725
- `M${c + r} ${d + r}h${m - c}v1H${c + r}z`
725
+ `M${c + r} ${d + r}h${f - c}v1H${c + r}z`
726
726
  ), c = null;
727
727
  return;
728
728
  }
729
- if (m === a.length - 1) {
730
- if (!f)
729
+ if (f === a.length - 1) {
730
+ if (!m)
731
731
  return;
732
- c === null ? s.push(`M${m + r},${d + r} h1v1H${m + r}z`) : s.push(
733
- `M${c + r},${d + r} h${m + 1 - c}v1H${c + r}z`
732
+ c === null ? s.push(`M${f + r},${d + r} h1v1H${f + r}z`) : s.push(
733
+ `M${c + r},${d + r} h${f + 1 - c}v1H${c + r}z`
734
734
  );
735
735
  return;
736
736
  }
737
- f && c === null && (c = m);
737
+ m && c === null && (c = f);
738
738
  });
739
739
  }), s.join("");
740
740
  }
@@ -744,14 +744,14 @@ function Fe(o, r) {
744
744
  function At(o, r, s, a) {
745
745
  if (a == null)
746
746
  return null;
747
- const d = o.length + s * 2, c = Math.floor(r * bt), f = d / r, m = (a.width || c) * f, e = (a.height || c) * f, n = a.x == null ? o.length / 2 - m / 2 : a.x * f, t = a.y == null ? o.length / 2 - e / 2 : a.y * f, i = a.opacity == null ? 1 : a.opacity;
747
+ const d = o.length + s * 2, c = Math.floor(r * bt), m = d / r, f = (a.width || c) * m, e = (a.height || c) * m, n = a.x == null ? o.length / 2 - f / 2 : a.x * m, t = a.y == null ? o.length / 2 - e / 2 : a.y * m, i = a.opacity == null ? 1 : a.opacity;
748
748
  let l = null;
749
749
  if (a.excavate) {
750
- let u = Math.floor(n), E = Math.floor(t), g = Math.ceil(m + n - u), R = Math.ceil(e + t - E);
750
+ let u = Math.floor(n), E = Math.floor(t), g = Math.ceil(f + n - u), R = Math.ceil(e + t - E);
751
751
  l = { x: u, y: E, w: g, h: R };
752
752
  }
753
753
  const p = a.crossOrigin;
754
- return { x: n, y: t, h: e, w: m, excavation: l, opacity: i, crossOrigin: p };
754
+ return { x: n, y: t, h: e, w: f, excavation: l, opacity: i, crossOrigin: p };
755
755
  }
756
756
  function It(o, r) {
757
757
  return r != null ? Math.max(Math.floor(r), 0) : o ? yt : Mt;
@@ -763,8 +763,8 @@ function Ue({
763
763
  includeMargin: a,
764
764
  marginSize: d,
765
765
  imageSettings: c,
766
- size: f,
767
- boostLevel: m
766
+ size: m,
767
+ boostLevel: f
768
768
  }) {
769
769
  let e = D.useMemo(() => {
770
770
  const u = (Array.isArray(o) ? o : [o]).reduce((E, g) => (E.push(...q.QrSegment.makeSegments(g)), E), []);
@@ -774,14 +774,14 @@ function Ue({
774
774
  s,
775
775
  void 0,
776
776
  void 0,
777
- m
777
+ f
778
778
  );
779
- }, [o, r, s, m]);
779
+ }, [o, r, s, f]);
780
780
  const { cells: n, margin: t, numCells: i, calculatedImageSettings: l } = D.useMemo(() => {
781
781
  let p = e.getModules();
782
782
  const u = It(a, d), E = p.length + u * 2, g = At(
783
783
  p,
784
- f,
784
+ m,
785
785
  u,
786
786
  c
787
787
  );
@@ -791,7 +791,7 @@ function Ue({
791
791
  numCells: E,
792
792
  calculatedImageSettings: g
793
793
  };
794
- }, [e, f, c, a, d]);
794
+ }, [e, m, c, a, d]);
795
795
  return {
796
796
  qrcode: e,
797
797
  margin: t,
@@ -812,8 +812,8 @@ var St = (function() {
812
812
  const a = r, {
813
813
  value: d,
814
814
  size: c = Pe,
815
- level: f = De,
816
- bgColor: m = Te,
815
+ level: m = De,
816
+ bgColor: f = Te,
817
817
  fgColor: e = Oe,
818
818
  includeMargin: n = Le,
819
819
  minVersion: t = ke,
@@ -836,9 +836,9 @@ var St = (function() {
836
836
  C.current = Y, typeof s == "function" ? s(Y) : s && (s.current = Y);
837
837
  },
838
838
  [s]
839
- ), [T, b] = D.useState(!1), { margin: L, cells: H, numCells: Q, calculatedImageSettings: x } = Ue({
839
+ ), [T, b] = D.useState(!1), { margin: L, cells: H, numCells: G, calculatedImageSettings: x } = Ue({
840
840
  value: d,
841
- level: f,
841
+ level: m,
842
842
  minVersion: t,
843
843
  boostLevel: i,
844
844
  includeMargin: n,
@@ -859,8 +859,8 @@ var St = (function() {
859
859
  ));
860
860
  const W = window.devicePixelRatio || 1;
861
861
  Y.height = Y.width = c * W;
862
- const Z = c / Q * W;
863
- y.scale(Z, Z), y.fillStyle = m, y.fillRect(0, 0, Q, Q), y.fillStyle = e, St ? y.fill(new Path2D(Be(S, L))) : H.forEach(function(de, re) {
862
+ const Z = c / G * W;
863
+ y.scale(Z, Z), y.fillStyle = f, y.fillRect(0, 0, G, G), y.fillStyle = e, St ? y.fill(new Path2D(Be(S, L))) : H.forEach(function(de, re) {
864
864
  de.forEach(function(ue, he) {
865
865
  ue && y.fillRect(he + L, re + L, 1, 1);
866
866
  });
@@ -875,7 +875,7 @@ var St = (function() {
875
875
  }), D.useEffect(() => {
876
876
  b(!1);
877
877
  }, [N]);
878
- const G = ge({ height: c, width: c }, g);
878
+ const Q = ge({ height: c, width: c }, g);
879
879
  let V = null;
880
880
  return N != null && (V = /* @__PURE__ */ D.createElement(
881
881
  "img",
@@ -892,7 +892,7 @@ var St = (function() {
892
892
  )), /* @__PURE__ */ D.createElement(D.Fragment, null, /* @__PURE__ */ D.createElement(
893
893
  "canvas",
894
894
  ge({
895
- style: G,
895
+ style: Q,
896
896
  height: c,
897
897
  width: c,
898
898
  ref: I,
@@ -907,8 +907,8 @@ var ze = D.forwardRef(
907
907
  const a = r, {
908
908
  value: d,
909
909
  size: c = Pe,
910
- level: f = De,
911
- bgColor: m = Te,
910
+ level: m = De,
911
+ bgColor: f = Te,
912
912
  fgColor: e = Oe,
913
913
  includeMargin: n = Le,
914
914
  minVersion: t = ke,
@@ -930,7 +930,7 @@ var ze = D.forwardRef(
930
930
  "imageSettings"
931
931
  ]), { margin: g, cells: R, numCells: N, calculatedImageSettings: C } = Ue({
932
932
  value: d,
933
- level: f,
933
+ level: m,
934
934
  minVersion: t,
935
935
  boostLevel: i,
936
936
  includeMargin: n,
@@ -969,7 +969,7 @@ var ze = D.forwardRef(
969
969
  /* @__PURE__ */ D.createElement(
970
970
  "path",
971
971
  {
972
- fill: m,
972
+ fill: f,
973
973
  d: `M0,0 h${N}v${N}H0z`,
974
974
  shapeRendering: "crispEdges"
975
975
  }
@@ -1005,8 +1005,8 @@ const Pt = (o, r) => ({
1005
1005
  modalDividers: a,
1006
1006
  getConversation: d,
1007
1007
  generateConversationLink: c,
1008
- chatExpiration: f,
1009
- chatExpirationDays: m,
1008
+ chatExpiration: m,
1009
+ chatExpirationDays: f,
1010
1010
  close: e,
1011
1011
  chatWarning: n,
1012
1012
  shareLink: t,
@@ -1022,7 +1022,7 @@ const Pt = (o, r) => ({
1022
1022
  clientSharedPage: v,
1023
1023
  clientSharedProp: I
1024
1024
  }) => {
1025
- const [T, b] = k(null), [L, H] = k(), [Q, x] = k(!1), [G, V] = k(!1), [Y, y] = k(), S = me(null), P = me(null), F = X(() => o?.id ? decodeURI(o.id) : C?.[0] && C?.[1] && r ? decodeURI(`${C[0]}/${r}/${C[1]}`) : null, [o?.id, C, r]), W = X(() => {
1025
+ const [T, b] = k(null), [L, H] = k(), [G, x] = k(!1), [Q, V] = k(!1), [Y, y] = k(), S = fe(null), P = fe(null), F = X(() => o?.id ? decodeURI(o.id) : C?.[0] && C?.[1] && r ? decodeURI(`${C[0]}/${r}/${C[1]}`) : null, [o?.id, C, r]), W = X(() => {
1026
1026
  if (!T)
1027
1027
  return "";
1028
1028
  const z = N || window.location.origin;
@@ -1094,13 +1094,13 @@ const Pt = (o, r) => ({
1094
1094
  }, he = O(() => /* @__PURE__ */ h(
1095
1095
  j,
1096
1096
  {
1097
- buttonClassName: G ? "text-button-secondary" : "text-button-primary",
1098
- iconBefore: G ? /* @__PURE__ */ h(Xe, { width: 20, height: 20 }) : /* @__PURE__ */ h(Ke, { width: 20, height: 20 }),
1099
- title: G ? l ?? "Copied" : i ?? "Copy link",
1100
- disabled: G,
1097
+ buttonClassName: Q ? "text-button-secondary" : "text-button-primary",
1098
+ iconBefore: Q ? /* @__PURE__ */ h(Xe, { width: 20, height: 20 }) : /* @__PURE__ */ h(Ke, { width: 20, height: 20 }),
1099
+ title: Q ? l ?? "Copied" : i ?? "Copy link",
1100
+ disabled: Q,
1101
1101
  onClick: re
1102
1102
  }
1103
- ), [G, re, l, i]);
1103
+ ), [Q, re, l, i]);
1104
1104
  return /* @__PURE__ */ M(
1105
1105
  le,
1106
1106
  {
@@ -1111,7 +1111,7 @@ const Pt = (o, r) => ({
1111
1111
  onClose: de,
1112
1112
  closeButtonTitle: e ?? "Close",
1113
1113
  children: [
1114
- Q ? /* @__PURE__ */ M("div", { className: "share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0", children: [
1114
+ G ? /* @__PURE__ */ M("div", { className: "share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0", children: [
1115
1115
  o?.name ? /* @__PURE__ */ M("div", { className: "share-info flex w-full", children: [
1116
1116
  /* @__PURE__ */ h("p", { className: "share-info-title body-1 mr-1 text-neutrals-800", children: E ?? "Chat name:" }),
1117
1117
  /* @__PURE__ */ h(
@@ -1124,10 +1124,10 @@ const Pt = (o, r) => ({
1124
1124
  )
1125
1125
  ] }) : null,
1126
1126
  /* @__PURE__ */ M("div", { className: "share-info flex", children: [
1127
- /* @__PURE__ */ h("p", { className: "share-info-title body-1 mr-1 text-neutrals-800", children: f ?? "Link expiration date:" }),
1127
+ /* @__PURE__ */ h("p", { className: "share-info-title body-1 mr-1 text-neutrals-800", children: m ?? "Link expiration date:" }),
1128
1128
  /* @__PURE__ */ M("h3", { children: [
1129
1129
  "3 ",
1130
- m ?? "days"
1130
+ f ?? "days"
1131
1131
  ] })
1132
1132
  ] }),
1133
1133
  /* @__PURE__ */ h(
@@ -1152,7 +1152,7 @@ const Pt = (o, r) => ({
1152
1152
  }
1153
1153
  )
1154
1154
  ] }) : /* @__PURE__ */ h("div", { className: "flex items-center justify-center p-6", children: /* @__PURE__ */ h(Re, {}) }),
1155
- Q ? o && L ? /* @__PURE__ */ h("div", { className: "remove-access", children: /* @__PURE__ */ h(
1155
+ G ? o && L ? /* @__PURE__ */ h("div", { className: "remove-access", children: /* @__PURE__ */ h(
1156
1156
  j,
1157
1157
  {
1158
1158
  title: u ?? "Remove access to all users",
@@ -1172,12 +1172,12 @@ const Pt = (o, r) => ({
1172
1172
  locale: a,
1173
1173
  disableModalDividers: d,
1174
1174
  titles: c,
1175
- isSmallButton: f
1175
+ isSmallButton: m
1176
1176
  }) => {
1177
- const [m, e] = k(o?.name || ""), n = (i) => {
1177
+ const [f, e] = k(o?.name || ""), n = (i) => {
1178
1178
  e(i);
1179
1179
  }, t = () => {
1180
- const i = `${o?.folderId}/${encodeURIComponent(Ee(m))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1180
+ const i = `${o?.folderId}/${encodeURIComponent(Ee(f))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1181
1181
  s(
1182
1182
  `conversations/${o.id}`,
1183
1183
  `conversations/${i}`
@@ -1198,7 +1198,7 @@ const Pt = (o, r) => ({
1198
1198
  je,
1199
1199
  {
1200
1200
  inputId: "rename",
1201
- value: m,
1201
+ value: f,
1202
1202
  onChange: n,
1203
1203
  cssClass: "w-full"
1204
1204
  }
@@ -1209,7 +1209,7 @@ const Pt = (o, r) => ({
1209
1209
  {
1210
1210
  buttonClassName: "cancel-button",
1211
1211
  title: c?.cancel ?? "Cancel",
1212
- isSmallButton: f,
1212
+ isSmallButton: m,
1213
1213
  onClick: (i) => {
1214
1214
  i.stopPropagation(), r();
1215
1215
  }
@@ -1220,8 +1220,8 @@ const Pt = (o, r) => ({
1220
1220
  {
1221
1221
  buttonClassName: "text-button-primary text-button-primary",
1222
1222
  title: c?.save ?? "Rename",
1223
- isSmallButton: f,
1224
- disabled: !m,
1223
+ isSmallButton: m,
1224
+ disabled: !f,
1225
1225
  onClick: (i) => {
1226
1226
  i.stopPropagation(), t();
1227
1227
  }
@@ -1238,8 +1238,8 @@ const Pt = (o, r) => ({
1238
1238
  onConversationDelete: a,
1239
1239
  getConversation: d,
1240
1240
  getFileBlob: c,
1241
- renameConversation: f,
1242
- triggerButton: m,
1241
+ renameConversation: m,
1242
+ triggerButton: f,
1243
1243
  locale: e,
1244
1244
  isDisabled: n
1245
1245
  }) => {
@@ -1286,16 +1286,16 @@ const Pt = (o, r) => ({
1286
1286
  a(o), R();
1287
1287
  }, [o, a, R]), I = O(
1288
1288
  (b, L) => {
1289
- f(b, L), C();
1289
+ m(b, L), C();
1290
1290
  },
1291
- [f, C]
1291
+ [m, C]
1292
1292
  );
1293
1293
  return /* @__PURE__ */ M(te, { children: [
1294
1294
  /* @__PURE__ */ h(
1295
1295
  Me,
1296
1296
  {
1297
1297
  containerClassName: "ml-3 group-hover:visible invisible",
1298
- triggerButton: m ?? /* @__PURE__ */ h(Ft, { disabled: n }),
1298
+ triggerButton: f ?? /* @__PURE__ */ h(Ft, { disabled: n }),
1299
1299
  options: t,
1300
1300
  openedClassName: "action-menu-opened",
1301
1301
  onOptionSelect: (b) => {
@@ -1368,11 +1368,11 @@ const Pt = (o, r) => ({
1368
1368
  onConversationClick: a,
1369
1369
  actions: d,
1370
1370
  locale: c,
1371
- isDisabled: f,
1372
- conversationStyles: m,
1371
+ isDisabled: m,
1372
+ conversationStyles: f,
1373
1373
  shareConversationProps: e
1374
1374
  }) => {
1375
- const n = me(null), t = Ee(o?.name);
1375
+ const n = fe(null), t = Ee(o?.name);
1376
1376
  return ne(() => {
1377
1377
  if (o?.id === r && n?.current) {
1378
1378
  const i = n.current.parentElement?.parentElement?.parentElement;
@@ -1392,13 +1392,13 @@ const Pt = (o, r) => ({
1392
1392
  "flex justify-between items-center py-2 px-3 border-transparent relative group border",
1393
1393
  "conversation-item",
1394
1394
  r === o?.id && "bg-hues-100 conversation-item-active",
1395
- f ? "cursor-not-allowed" : "cursor-pointer hover:border-hues-600"
1395
+ m ? "cursor-not-allowed" : "cursor-pointer hover:border-hues-600"
1396
1396
  ),
1397
- onClick: () => !f && a(o.folderId, o?.id),
1398
- title: f ? m?.titles?.noActionsAllowed : t,
1397
+ onClick: () => !m && a(o.folderId, o?.id),
1398
+ title: m ? f?.titles?.noActionsAllowed : t,
1399
1399
  children: [
1400
1400
  /* @__PURE__ */ M("div", { className: "flex min-w-0 flex-1 items-center", children: [
1401
- m.conversationItemIcon ? m.conversationItemIcon : null,
1401
+ f.conversationItemIcon ? f.conversationItemIcon : null,
1402
1402
  /* @__PURE__ */ h(
1403
1403
  "h3",
1404
1404
  {
@@ -1407,7 +1407,7 @@ const Pt = (o, r) => ({
1407
1407
  "conversation-item-text",
1408
1408
  r === o?.id ? "conversation-item-text-active" : ""
1409
1409
  ),
1410
- title: f ? m?.titles?.noActionsAllowed : t,
1410
+ title: m ? f?.titles?.noActionsAllowed : t,
1411
1411
  children: s?.length ? /* @__PURE__ */ h(
1412
1412
  We,
1413
1413
  {
@@ -1422,14 +1422,14 @@ const Pt = (o, r) => ({
1422
1422
  Bt,
1423
1423
  {
1424
1424
  locale: c,
1425
- conversationStyles: m,
1425
+ conversationStyles: f,
1426
1426
  conversation: o,
1427
1427
  onConversationDelete: d.deleteConversation,
1428
1428
  getConversation: d.getConversation,
1429
1429
  getFileBlob: d.getFileBlob,
1430
1430
  renameConversation: d.renameConversation,
1431
1431
  shareConversationProps: e,
1432
- isDisabled: f
1432
+ isDisabled: m
1433
1433
  }
1434
1434
  )
1435
1435
  ]
@@ -1442,8 +1442,8 @@ const Pt = (o, r) => ({
1442
1442
  groupLabel: a,
1443
1443
  conversationStyles: d,
1444
1444
  groupedConversations: c,
1445
- shareConversationProps: f,
1446
- locale: m,
1445
+ shareConversationProps: m,
1446
+ locale: f,
1447
1447
  isDisabled: e
1448
1448
  }) => {
1449
1449
  const [n, t] = k(!1), i = O(() => {
@@ -1480,14 +1480,14 @@ const Pt = (o, r) => ({
1480
1480
  (l) => /* @__PURE__ */ h(
1481
1481
  _e,
1482
1482
  {
1483
- locale: m,
1483
+ locale: f,
1484
1484
  isDisabled: e,
1485
1485
  conversationStyles: d,
1486
1486
  conversation: l,
1487
1487
  selectedConversationId: s,
1488
1488
  onConversationClick: o,
1489
1489
  actions: r,
1490
- shareConversationProps: f
1490
+ shareConversationProps: m
1491
1491
  },
1492
1492
  l.id || l.name
1493
1493
  )
@@ -1534,8 +1534,8 @@ const Pt = (o, r) => ({
1534
1534
  conversationStyles: a,
1535
1535
  handleConversationClick: d,
1536
1536
  actions: c,
1537
- locale: f,
1538
- shareConversationProps: m,
1537
+ locale: m,
1538
+ shareConversationProps: f,
1539
1539
  isDisabled: e
1540
1540
  }) => {
1541
1541
  const [n, t] = k([]);
@@ -1552,14 +1552,14 @@ const Pt = (o, r) => ({
1552
1552
  }, [o, s]), /* @__PURE__ */ h(te, { children: n?.length ? n.map((i) => /* @__PURE__ */ h(
1553
1553
  _e,
1554
1554
  {
1555
- locale: f,
1555
+ locale: m,
1556
1556
  conversationStyles: a,
1557
1557
  conversation: i,
1558
1558
  searchQuery: s,
1559
1559
  selectedConversationId: r,
1560
1560
  onConversationClick: d,
1561
1561
  actions: c,
1562
- shareConversationProps: m,
1562
+ shareConversationProps: f,
1563
1563
  isDisabled: e
1564
1564
  },
1565
1565
  i.id
@@ -1574,8 +1574,8 @@ const Pt = (o, r) => ({
1574
1574
  children: a,
1575
1575
  isCollapsed: d,
1576
1576
  isStreaming: c,
1577
- conversationStyles: f,
1578
- conversations: m,
1577
+ conversationStyles: m,
1578
+ conversations: f,
1579
1579
  locale: e,
1580
1580
  sharedConversations: n,
1581
1581
  setConversations: t,
@@ -1588,13 +1588,13 @@ const Pt = (o, r) => ({
1588
1588
  getSharedConversations: b,
1589
1589
  deleteConversation: L,
1590
1590
  renameConversation: H
1591
- } = s, Q = X(() => !!N?.length, [N]);
1591
+ } = s, G = X(() => !!N?.length, [N]);
1592
1592
  ne(() => {
1593
1593
  E({
1594
1594
  ...st(n),
1595
- ...ct(m)
1595
+ ...ct(f)
1596
1596
  });
1597
- }, [m, n]), ne(() => {
1597
+ }, [f, n]), ne(() => {
1598
1598
  async function y() {
1599
1599
  try {
1600
1600
  R(!0);
@@ -1603,7 +1603,7 @@ const Pt = (o, r) => ({
1603
1603
  );
1604
1604
  t(J(S)), i(
1605
1605
  J(
1606
- fe(P, e)
1606
+ me(P, e)
1607
1607
  )
1608
1608
  );
1609
1609
  } catch (S) {
@@ -1629,7 +1629,7 @@ const Pt = (o, r) => ({
1629
1629
  );
1630
1630
  t(J(S)), i(
1631
1631
  J(
1632
- fe(P, e)
1632
+ me(P, e)
1633
1633
  )
1634
1634
  ), r === y?.id && p();
1635
1635
  } catch (S) {
@@ -1646,7 +1646,7 @@ const Pt = (o, r) => ({
1646
1646
  r,
1647
1647
  p
1648
1648
  ]
1649
- ), G = O(
1649
+ ), Q = O(
1650
1650
  async (y, S) => {
1651
1651
  try {
1652
1652
  R(!0), await H(y, S);
@@ -1655,7 +1655,7 @@ const Pt = (o, r) => ({
1655
1655
  );
1656
1656
  t(J(P)), i(
1657
1657
  J(
1658
- fe(F, e)
1658
+ me(F, e)
1659
1659
  )
1660
1660
  );
1661
1661
  } catch (P) {
@@ -1689,13 +1689,13 @@ const Pt = (o, r) => ({
1689
1689
  v ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"
1690
1690
  ),
1691
1691
  children: [
1692
- !v && /* @__PURE__ */ h("h3", { className: "sm:body-2 text-neutrals-700", children: f?.titles?.allChats ?? "All Chats" }),
1692
+ !v && /* @__PURE__ */ h("h3", { className: "sm:body-2 text-neutrals-700", children: m?.titles?.allChats ?? "All Chats" }),
1693
1693
  /* @__PURE__ */ h(
1694
1694
  zt,
1695
1695
  {
1696
1696
  searchQuery: N,
1697
- searchIcon: f.searchIcon,
1698
- titles: f.titles,
1697
+ searchIcon: m.searchIcon,
1698
+ titles: m.titles,
1699
1699
  isExpandedSearch: v,
1700
1700
  onSearchConversations: V,
1701
1701
  toggleSearchField: Y
@@ -1709,14 +1709,14 @@ const Pt = (o, r) => ({
1709
1709
  {
1710
1710
  className: B(
1711
1711
  "scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0 pr-2",
1712
- Q ? "gap-y-1" : "gap-y-6"
1712
+ G ? "gap-y-1" : "gap-y-6"
1713
1713
  ),
1714
- children: d ? null : /* @__PURE__ */ h(te, { children: m?.length === 0 && n?.length === 0 ? /* @__PURE__ */ h($t, { titles: f.titles }) : Q ? /* @__PURE__ */ h(
1714
+ children: d ? null : /* @__PURE__ */ h(te, { children: f?.length === 0 && n?.length === 0 ? /* @__PURE__ */ h($t, { titles: m.titles }) : G ? /* @__PURE__ */ h(
1715
1715
  _t,
1716
1716
  {
1717
1717
  locale: e,
1718
- conversationStyles: f,
1719
- conversations: [...n, ...m],
1718
+ conversationStyles: m,
1719
+ conversations: [...n, ...f],
1720
1720
  searchQuery: N,
1721
1721
  selectedConversationId: r,
1722
1722
  handleConversationClick: o,
@@ -1724,7 +1724,8 @@ const Pt = (o, r) => ({
1724
1724
  isDisabled: c,
1725
1725
  actions: {
1726
1726
  ...s,
1727
- deleteConversation: x
1727
+ deleteConversation: x,
1728
+ renameConversation: Q
1728
1729
  }
1729
1730
  }
1730
1731
  ) : Object.entries(u).map(
@@ -1734,13 +1735,13 @@ const Pt = (o, r) => ({
1734
1735
  locale: e,
1735
1736
  isDisabled: c,
1736
1737
  groupLabel: y,
1737
- conversationStyles: f,
1738
+ conversationStyles: m,
1738
1739
  groupedConversations: S,
1739
1740
  handleConversationClick: o,
1740
1741
  actions: {
1741
1742
  ...s,
1742
1743
  deleteConversation: x,
1743
- renameConversation: G
1744
+ renameConversation: Q
1744
1745
  },
1745
1746
  shareConversationProps: l,
1746
1747
  selectedConversationId: r
@@ -1778,8 +1779,8 @@ const Pt = (o, r) => ({
1778
1779
  buttonClassName: "cancel-button",
1779
1780
  title: c?.popupCancel || "Cancel",
1780
1781
  isSmallButton: a,
1781
- onClick: (f) => {
1782
- f.stopPropagation(), o();
1782
+ onClick: (m) => {
1783
+ m.stopPropagation(), o();
1783
1784
  }
1784
1785
  }
1785
1786
  ),
@@ -1789,8 +1790,8 @@ const Pt = (o, r) => ({
1789
1790
  buttonClassName: "text-button-primary",
1790
1791
  title: c?.popupApply || "Sign Out",
1791
1792
  isSmallButton: a,
1792
- onClick: (f) => {
1793
- f.stopPropagation(), s?.();
1793
+ onClick: (m) => {
1794
+ m.stopPropagation(), s?.();
1794
1795
  }
1795
1796
  }
1796
1797
  )
@@ -1805,8 +1806,8 @@ const Pt = (o, r) => ({
1805
1806
  locale: d,
1806
1807
  titles: c
1807
1808
  }) => {
1808
- const f = (R) => R?.split(" ")?.map((N, C) => C < 2 ? N[0].toUpperCase() : "")?.join("") ?? "", m = X(
1809
- () => o?.name ? f(o?.name) : o?.email?.[0].toUpperCase() ?? "",
1809
+ const m = (R) => R?.split(" ")?.map((N, C) => C < 2 ? N[0].toUpperCase() : "")?.join("") ?? "", f = X(
1810
+ () => o?.name ? m(o?.name) : o?.email?.[0].toUpperCase() ?? "",
1810
1811
  [o]
1811
1812
  ), [e, n] = k(!1), t = o?.name?.split(" "), i = t ? `${t?.[0] ?? ""} ${t?.[1]?.[0] ? t?.[1]?.[0] + "." : ""}` : o?.email ?? "", l = O(() => {
1812
1813
  n(!0);
@@ -1822,7 +1823,7 @@ const Pt = (o, r) => ({
1822
1823
  "cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",
1823
1824
  a?.initialStyles
1824
1825
  ),
1825
- children: m
1826
+ children: f
1826
1827
  }
1827
1828
  ),
1828
1829
  /* @__PURE__ */ h(
@@ -1835,7 +1836,7 @@ const Pt = (o, r) => ({
1835
1836
  children: (a?.showShortName ? i : o?.name) ?? o?.email ?? ""
1836
1837
  }
1837
1838
  )
1838
- ] }), [m, i, a, o]), g = X(() => /* @__PURE__ */ M("div", { className: B("py-1", a?.dropDownStyles), children: [
1839
+ ] }), [f, i, a, o]), g = X(() => /* @__PURE__ */ M("div", { className: B("py-1", a?.dropDownStyles), children: [
1839
1840
  a?.settingsIcon && /* @__PURE__ */ M(
1840
1841
  "button",
1841
1842
  {
@@ -1932,5 +1933,5 @@ export {
1932
1933
  en as ConversationList,
1933
1934
  tn as User,
1934
1935
  st as getSharedConversationsGroup,
1935
- fe as transformSharedConversations
1936
+ me as transformSharedConversations
1936
1937
  };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@epam/statgpt-conversation-list",
3
- "version": "0.5.0-rc.36",
3
+ "version": "0.5.0-rc.37",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@tabler/icons-react": "^3.34.1",
7
7
  "@epam/ai-dial-shared": "^0.43.3",
8
- "@epam/statgpt-ui-components": "0.5.0-rc.36",
8
+ "@epam/statgpt-ui-components": "0.5.0-rc.37",
9
9
  "classnames": "^2.5.1",
10
- "@epam/statgpt-shared-toolkit": "0.5.0-rc.36",
11
- "@epam/statgpt-dial-toolkit": "0.5.0-rc.36",
10
+ "@epam/statgpt-shared-toolkit": "0.5.0-rc.37",
11
+ "@epam/statgpt-dial-toolkit": "0.5.0-rc.37",
12
12
  "jszip": "3.10.1",
13
13
  "lodash": "^4.17.23"
14
14
  },