randmarcomps 1.480.0 → 1.481.0

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.
@@ -61105,10 +61105,10 @@ const PeopleSection = ({ appID: e, activeChatObj: t }) => {
61105
61105
  return /* @__PURE__ */ jsxs("li", { className: "rounded border px-3 py-2 text-sm", children: [
61106
61106
  /* @__PURE__ */ jsx("p", { className: "font-medium leading-tight", children: _.Name ?? "Unknown person" }),
61107
61107
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: _.Role ?? "Role unavailable" }),
61108
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
61109
- _.Active ? "Active" : "Inactive",
61110
- R ? ` · Last auth ${R}` : ""
61111
- ] })
61108
+ R ? /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
61109
+ "Last auth ",
61110
+ R
61111
+ ] }) : null
61112
61112
  ] }, E);
61113
61113
  }) })
61114
61114
  ] });
@@ -1161,7 +1161,7 @@ ${e}</tr>
1161
1161
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${escape2(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(e);if(l===null)return o;e=l;let d='<a href="'+e+'"';return t&&(d+=' title="'+escape2(t)+'"'),d+=">"+o+"</a>",d}image({href:e,title:t,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(e);if(l===null)return escape2(n);e=l;let d=`<img src="${e}" alt="${n}"`;return t&&(d+=` title="${escape2(t)}"`),d+=">",d}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:escape2(e.text)}},_TextRenderer=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},_Parser=class vr{constructor(t){en(this,"options");en(this,"renderer");en(this,"textRenderer");this.options=t||_defaults,this.options.renderer=this.options.renderer||new _Renderer,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _TextRenderer}static parse(t,n){return new vr(n).parse(t)}static parseInline(t,n){return new vr(n).parseInline(t)}parse(t,n=!0){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=g,S=this.options.extensions.renderers[_.type].call({parser:this},_);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(_.type)){o+=S||"";continue}}const b=g;switch(b.type){case"space":{o+=this.renderer.space(b);continue}case"hr":{o+=this.renderer.hr(b);continue}case"heading":{o+=this.renderer.heading(b);continue}case"code":{o+=this.renderer.code(b);continue}case"table":{o+=this.renderer.table(b);continue}case"blockquote":{o+=this.renderer.blockquote(b);continue}case"list":{o+=this.renderer.list(b);continue}case"html":{o+=this.renderer.html(b);continue}case"paragraph":{o+=this.renderer.paragraph(b);continue}case"text":{let _=b,S=this.renderer.text(_);for(;f+1<t.length&&t[f+1].type==="text";)_=t[++f],S+=`
1162
1162
  `+this.renderer.text(_);n?o+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):o+=S;continue}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}parseInline(t,n=this.renderer){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=this.options.extensions.renderers[g.type].call({parser:this},g);if(_!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(g.type)){o+=_||"";continue}}const b=g;switch(b.type){case"escape":{o+=n.text(b);break}case"html":{o+=n.html(b);break}case"link":{o+=n.link(b);break}case"image":{o+=n.image(b);break}case"strong":{o+=n.strong(b);break}case"em":{o+=n.em(b);break}case"codespan":{o+=n.codespan(b);break}case"br":{o+=n.br(b);break}case"del":{o+=n.del(b);break}case"text":{o+=n.text(b);break}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}},_Hooks=(dn=class{constructor(e){en(this,"options");en(this,"block");this.options=e||_defaults}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}},en(dn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),dn),Marked=class{constructor(...e){en(this,"defaults",_getDefaults());en(this,"options",this.setOptions);en(this,"parse",this.parseMarkdown(!0));en(this,"parseInline",this.parseMarkdown(!1));en(this,"Parser",_Parser);en(this,"Renderer",_Renderer);en(this,"TextRenderer",_TextRenderer);en(this,"Lexer",_Lexer);en(this,"Tokenizer",_Tokenizer);en(this,"Hooks",_Hooks);this.use(...e)}walkTokens(e,t){var o,l;let n=[];for(const d of e)switch(n=n.concat(t.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,t));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,t));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,t));break}default:{const f=d;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[f.type]?this.defaults.extensions.childTokens[f.type].forEach(g=>{const b=f[g].flat(1/0);n=n.concat(this.walkTokens(b,t))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const d=t.renderers[l.name];d?t.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:t.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=t[l.level];d?d.unshift(l.tokenizer):t[l.level]=[l.tokenizer],l.start&&(l.level==="block"?t.startBlock?t.startBlock.push(l.start):t.startBlock=[l.start]:l.level==="inline"&&(t.startInline?t.startInline.push(l.start):t.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(t.childTokens[l.name]=l.childTokens)}),o.extensions=t),n.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const d in n.renderer){if(!(d in l))throw new Error(`renderer '${d}' does not exist`);if(["options","parser"].includes(d))continue;const f=d,g=n.renderer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const d in n.tokenizer){if(!(d in l))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const f=d,g=n.tokenizer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new _Hooks;for(const d in n.hooks){if(!(d in l))throw new Error(`hook '${d}' does not exist`);if(["options","block"].includes(d))continue;const f=d,g=n.hooks[f],b=l[f];_Hooks.passThroughHooks.has(d)?l[f]=_=>{if(this.defaults.async)return Promise.resolve(g.call(l,_)).then(R=>b.call(l,R));const S=g.call(l,_);return b.call(l,S)}:l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,d=n.walkTokens;o.walkTokens=function(f){let g=[];return g.push(d.call(this,f)),l&&(g=g.concat(l.call(this,f))),g}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return _Lexer.lex(e,t??this.defaults)}parser(e,t){return _Parser.parse(e,t??this.defaults)}parseMarkdown(e){return(n,o)=>{const l={...o},d={...this.defaults,...l},f=this.onError(!!d.silent,!!d.async);if(this.defaults.async===!0&&l.async===!1)return f(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));d.hooks&&(d.hooks.options=d,d.hooks.block=e);const g=d.hooks?d.hooks.provideLexer():e?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():e?_Parser.parse:_Parser.parseInline;if(d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(n):n).then(_=>g(_,d)).then(_=>d.hooks?d.hooks.processAllTokens(_):_).then(_=>d.walkTokens?Promise.all(this.walkTokens(_,d.walkTokens)).then(()=>_):_).then(_=>b(_,d)).then(_=>d.hooks?d.hooks.postprocess(_):_).catch(f);try{d.hooks&&(n=d.hooks.preprocess(n));let _=g(n,d);d.hooks&&(_=d.hooks.processAllTokens(_)),d.walkTokens&&this.walkTokens(_,d.walkTokens);let S=b(_,d);return d.hooks&&(S=d.hooks.postprocess(S)),S}catch(_){return f(_)}}}onError(e,t){return n=>{if(n.message+=`
1163
1163
  Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(t){return t}),seal||(seal=function(t){return t}),apply$1||(apply$1=function(t,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return t.apply(n,l)}),construct||(construct=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new t(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(e,t,o)}}function unconstruct(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return construct(e,n)}}function addToSet(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(e,null);let o=t.length;for(;o--;){let l=t[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(t)||(t[o]=d),l=d)}e[l]=!0}return e}function cleanArray(e){for(let t=0;t<e.length;t++)objectHasOwnProperty(e,t)||(e[t]=null);return e}function clone(e){const t=create(null);for(const[n,o]of entries(e))objectHasOwnProperty(e,n)&&(Array.isArray(o)?t[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=clone(o):t[n]=o);return t}function lookupGetter(e,t){for(;e!==null;){const o=getOwnPropertyDescriptor(e,t);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}e=getPrototypeOf(e)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function e(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function e(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return t.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function e(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const t=Xt=>createDOMPurify(Xt);if(t.version="3.3.0",t.removed=[],!e||!e.document||e.document.nodeType!==NODE_TYPE.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=e,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),q=lookupGetter(A,"childNodes"),Q=lookupGetter(A,"parentNode");if(typeof f=="function"){const Xt=n.createElement("template");Xt.content&&Xt.content.ownerDocument&&(n=Xt.content.ownerDocument)}let te,F="";const{implementation:V,createNodeIterator:ne,createDocumentFragment:ae,getElementsByTagName:se}=n,{importNode:Oe}=o;let Ne=_createHooksMap();t.isSupported=typeof entries=="function"&&typeof Q=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:oe,ERB_EXPR:$e,TMPLIT_EXPR:Ae,DATA_ATTR:je,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:qe,ATTR_WHITESPACE:Ve,CUSTOM_ELEMENT:Le}=EXPRESSIONS;let{IS_ALLOWED_URI:He}=EXPRESSIONS,We=null;const ze=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Xe=null;const nt=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),st=null,et=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,ot=!0,lt=!1,Ge=!0,$t=!1,rt=!0,Rt=!1,dt=!1,It=!1,Mt=!1,Ct=!1,Ke=!1,Ye=!0,Ze=!1;const ct="user-content-";let mt=!0,ft=!1,yt={},Ht=null;const Kt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let un=null;const hn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const An=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",Rn="http://www.w3.org/2000/svg",vn="http://www.w3.org/1999/xhtml";let Pn=vn,Mn=!1,$n=null;const Vn=addToSet({},[xn,Rn,vn],stringToString);let Jt=addToSet({},["mi","mo","mn","ms","mtext"]),Zt=addToSet({},["annotation-xml"]);const Ut=addToSet({},["title","style","font","a","script"]);let tn=null;const Yt=["application/xhtml+xml","text/html"],an="text/html";let mn=null,On=null;const Fn=n.createElement("form"),Cn=function(it){return it instanceof RegExp||it instanceof Function},Bn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(On&&On===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),tn=Yt.indexOf(it.PARSER_MEDIA_TYPE)===-1?an:it.PARSER_MEDIA_TYPE,mn=tn==="application/xhtml+xml"?stringToString:stringToLowerCase,We=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,mn):ze,Xe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,mn):nt,$n=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Vn,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(An),it.ADD_URI_SAFE_ATTR,mn):An,un=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(hn),it.ADD_DATA_URI_TAGS,mn):hn,Ht=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,mn):Kt,st=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,mn):clone({}),et=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,mn):clone({}),yt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,tt=it.ALLOW_ARIA_ATTR!==!1,ot=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$t=it.SAFE_FOR_TEMPLATES||!1,rt=it.SAFE_FOR_XML!==!1,Rt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,Ct=it.RETURN_DOM_FRAGMENT||!1,Ke=it.RETURN_TRUSTED_TYPE||!1,It=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,Ze=it.SANITIZE_NAMED_PROPS||!1,mt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,He=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Pn=it.NAMESPACE||vn,Jt=it.MATHML_TEXT_INTEGRATION_POINTS||Jt,Zt=it.HTML_INTEGRATION_POINTS||Zt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$t&&(ot=!1),Ct&&(Mt=!0),yt&&(We=addToSet({},text$1),Xe=[],yt.html===!0&&(addToSet(We,html$1),addToSet(Xe,html)),yt.svg===!0&&(addToSet(We,svg$1),addToSet(Xe,svg),addToSet(Xe,xml)),yt.svgFilters===!0&&(addToSet(We,svgFilters),addToSet(Xe,svg),addToSet(Xe,xml)),yt.mathMl===!0&&(addToSet(We,mathMl$1),addToSet(Xe,mathMl),addToSet(Xe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(We===ze&&(We=clone(We)),addToSet(We,it.ADD_TAGS,mn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Xe===nt&&(Xe=clone(Xe)),addToSet(Xe,it.ADD_ATTR,mn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,mn),it.FORBID_CONTENTS&&(Ht===Kt&&(Ht=clone(Ht)),addToSet(Ht,it.FORBID_CONTENTS,mn)),mt&&(We["#text"]=!0),Rt&&addToSet(We,["html","head","body"]),We.table&&(addToSet(We,["tbody"]),delete st.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=it.TRUSTED_TYPES_POLICY,F=te.createHTML("")}else te===void 0&&(te=_createTrustedTypesPolicy(E,l)),te!==null&&typeof F=="string"&&(F=te.createHTML(""));freeze&&freeze(it),On=it}},qn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Un=addToSet({},[...mathMl$1,...mathMlDisallowed]),sr=function(it){let Dt=Q(it);(!Dt||!Dt.tagName)&&(Dt={namespaceURI:Pn,tagName:"template"});const Wt=stringToLowerCase(it.tagName),pn=stringToLowerCase(Dt.tagName);return $n[it.namespaceURI]?it.namespaceURI===Rn?Dt.namespaceURI===vn?Wt==="svg":Dt.namespaceURI===xn?Wt==="svg"&&(pn==="annotation-xml"||Jt[pn]):!!qn[Wt]:it.namespaceURI===xn?Dt.namespaceURI===vn?Wt==="math":Dt.namespaceURI===Rn?Wt==="math"&&Zt[pn]:!!Un[Wt]:it.namespaceURI===vn?Dt.namespaceURI===Rn&&!Zt[pn]||Dt.namespaceURI===xn&&!Jt[pn]?!1:!Un[Wt]&&(Ut[Wt]||!qn[Wt]):!!(tn==="application/xhtml+xml"&&$n[it.namespaceURI]):!1},wn=function(it){arrayPush(t.removed,{element:it});try{Q(it).removeChild(it)}catch{I(it)}},Dn=function(it,Dt){try{arrayPush(t.removed,{attribute:Dt.getAttributeNode(it),from:Dt})}catch{arrayPush(t.removed,{attribute:null,from:Dt})}if(Dt.removeAttribute(it),it==="is")if(Mt||Ct)try{wn(Dt)}catch{}else try{Dt.setAttribute(it,"")}catch{}},Zn=function(it){let Dt=null,Wt=null;if(It)it="<remove></remove>"+it;else{const gn=stringMatch(it,/^[\r\n\t ]+/);Wt=gn&&gn[0]}tn==="application/xhtml+xml"&&Pn===vn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const pn=te?te.createHTML(it):it;if(Pn===vn)try{Dt=new C().parseFromString(pn,tn)}catch{}if(!Dt||!Dt.documentElement){Dt=V.createDocument(Pn,"template",null);try{Dt.documentElement.innerHTML=Mn?F:pn}catch{}}const bn=Dt.body||Dt.documentElement;return it&&Wt&&bn.insertBefore(n.createTextNode(Wt),bn.childNodes[0]||null),Pn===vn?se.call(Dt,Rt?"html":"body")[0]:Rt?Dt.documentElement:bn},er=function(it){return ne.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Kn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},or=function(it){return typeof g=="function"&&it instanceof g};function kn(Xt,it,Dt){arrayForEach(Xt,Wt=>{Wt.call(t,it,Dt,On)})}const lr=function(it){let Dt=null;if(kn(Ne.beforeSanitizeElements,it,null),Kn(it))return wn(it),!0;const Wt=mn(it.nodeName);if(kn(Ne.uponSanitizeElement,it,{tagName:Wt,allowedTags:We}),rt&&it.hasChildNodes()&&!or(it.firstElementChild)&&regExpTest(/<[/\w!]/g,it.innerHTML)&&regExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||rt&&it.nodeType===NODE_TYPE.comment&&regExpTest(/<[/\w]/g,it.data))return wn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(Wt))&&(!We[Wt]||st[Wt])){if(!st[Wt]&&tr(Wt)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt)))return!1;if(mt&&!Ht[Wt]){const pn=Q(it)||it.parentNode,bn=q(it)||it.childNodes;if(bn&&pn){const gn=bn.length;for(let Sn=gn-1;Sn>=0;--Sn){const In=M(bn[Sn],!0);In.__removalCount=(it.__removalCount||0)+1,pn.insertBefore(In,j(it))}}}return wn(it),!0}return it instanceof b&&!sr(it)||(Wt==="noscript"||Wt==="noembed"||Wt==="noframes")&&regExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(wn(it),!0):($t&&it.nodeType===NODE_TYPE.text&&(Dt=it.textContent,arrayForEach([oe,$e,Ae],pn=>{Dt=stringReplace(Dt,pn," ")}),it.textContent!==Dt&&(arrayPush(t.removed,{element:it.cloneNode()}),it.textContent=Dt)),kn(Ne.afterSanitizeElements,it,null),!1)},cr=function(it,Dt,Wt){if(Ye&&(Dt==="id"||Dt==="name")&&(Wt in n||Wt in Fn))return!1;if(!(ot&&!et[Dt]&&regExpTest(je,Dt))){if(!(tt&&regExpTest(Be,Dt))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck(Dt,it))){if(!Xe[Dt]||et[Dt]){if(!(tr(it)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&&regExpTest(Je.attributeNameCheck,Dt)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(Dt,it))||Dt==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt))))return!1}else if(!qt[Dt]){if(!regExpTest(He,stringReplace(Wt,Ve,""))){if(!((Dt==="src"||Dt==="xlink:href"||Dt==="href")&&it!=="script"&&stringIndexOf(Wt,"data:")===0&&un[it])){if(!(lt&&!regExpTest(qe,stringReplace(Wt,Ve,"")))){if(Wt)return!1}}}}}}}return!0},tr=function(it){return it!=="annotation-xml"&&stringMatch(it,Le)},nr=function(it){kn(Ne.beforeSanitizeAttributes,it,null);const{attributes:Dt}=it;if(!Dt||Kn(it))return;const Wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Xe,forceKeepAttr:void 0};let pn=Dt.length;for(;pn--;){const bn=Dt[pn],{name:gn,namespaceURI:Sn,value:In}=bn,Hn=mn(gn),zt=In;let yn=gn==="value"?zt:stringTrim(zt);if(Wt.attrName=Hn,Wt.attrValue=yn,Wt.keepAttr=!0,Wt.forceKeepAttr=void 0,kn(Ne.uponSanitizeAttribute,it,Wt),yn=Wt.attrValue,Ze&&(Hn==="id"||Hn==="name")&&(Dn(gn,it),yn=ct+yn),rt&&regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,yn)){Dn(gn,it);continue}if(Hn==="attributename"&&stringMatch(yn,"href")){Dn(gn,it);continue}if(Wt.forceKeepAttr)continue;if(!Wt.keepAttr){Dn(gn,it);continue}if(!Ge&&regExpTest(/\/>/i,yn)){Dn(gn,it);continue}$t&&arrayForEach([oe,$e,Ae],dr=>{yn=stringReplace(yn,dr," ")});const En=mn(it.nodeName);if(!cr(En,Hn,yn)){Dn(gn,it);continue}if(te&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!Sn)switch(E.getAttributeType(En,Hn)){case"TrustedHTML":{yn=te.createHTML(yn);break}case"TrustedScriptURL":{yn=te.createScriptURL(yn);break}}if(yn!==zt)try{Sn?it.setAttributeNS(Sn,gn,yn):it.setAttribute(gn,yn),Kn(it)?wn(it):arrayPop(t.removed)}catch{Dn(gn,it)}}kn(Ne.afterSanitizeAttributes,it,null)},ur=function Xt(it){let Dt=null;const Wt=er(it);for(kn(Ne.beforeSanitizeShadowDOM,it,null);Dt=Wt.nextNode();)kn(Ne.uponSanitizeShadowNode,Dt,null),lr(Dt),nr(Dt),Dt.content instanceof d&&Xt(Dt.content);kn(Ne.afterSanitizeShadowDOM,it,null)};return t.sanitize=function(Xt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Dt=null,Wt=null,pn=null,bn=null;if(Mn=!Xt,Mn&&(Xt="<!-->"),typeof Xt!="string"&&!or(Xt))if(typeof Xt.toString=="function"){if(Xt=Xt.toString(),typeof Xt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!t.isSupported)return Xt;if(dt||Bn(it),t.removed=[],typeof Xt=="string"&&(ft=!1),ft){if(Xt.nodeName){const In=mn(Xt.nodeName);if(!We[In]||st[In])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Xt instanceof g)Dt=Zn("<!---->"),Wt=Dt.ownerDocument.importNode(Xt,!0),Wt.nodeType===NODE_TYPE.element&&Wt.nodeName==="BODY"||Wt.nodeName==="HTML"?Dt=Wt:Dt.appendChild(Wt);else{if(!Mt&&!$t&&!Rt&&Xt.indexOf("<")===-1)return te&&Ke?te.createHTML(Xt):Xt;if(Dt=Zn(Xt),!Dt)return Mt?null:Ke?F:""}Dt&&It&&wn(Dt.firstChild);const gn=er(ft?Xt:Dt);for(;pn=gn.nextNode();)lr(pn),nr(pn),pn.content instanceof d&&ur(pn.content);if(ft)return Xt;if(Mt){if(Ct)for(bn=ae.call(Dt.ownerDocument);Dt.firstChild;)bn.appendChild(Dt.firstChild);else bn=Dt;return(Xe.shadowroot||Xe.shadowrootmode)&&(bn=Oe.call(o,bn,!0)),bn}let Sn=Rt?Dt.outerHTML:Dt.innerHTML;return Rt&&We["!doctype"]&&Dt.ownerDocument&&Dt.ownerDocument.doctype&&Dt.ownerDocument.doctype.name&&regExpTest(DOCTYPE_NAME,Dt.ownerDocument.doctype.name)&&(Sn="<!DOCTYPE "+Dt.ownerDocument.doctype.name+`>
1164
- `+Sn),$t&&arrayForEach([oe,$e,Ae],In=>{Sn=stringReplace(Sn,In," ")}),te&&Ke?te.createHTML(Sn):Sn},t.setConfig=function(){let Xt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bn(Xt),dt=!0},t.clearConfig=function(){On=null,dt=!1},t.isValidAttribute=function(Xt,it,Dt){On||Bn({});const Wt=mn(Xt),pn=mn(it);return cr(Wt,pn,Dt)},t.addHook=function(Xt,it){typeof it=="function"&&arrayPush(Ne[Xt],it)},t.removeHook=function(Xt,it){if(it!==void 0){const Dt=arrayLastIndexOf(Ne[Xt],it);return Dt===-1?void 0:arraySplice(Ne[Xt],Dt,1)[0]}return arrayPop(Ne[Xt])},t.removeHooks=function(Xt){Ne[Xt]=[]},t.removeAllHooks=function(){Ne=_createHooksMap()},t}var purify=createDOMPurify();function markdownToSafeHTML(e){const t=marked(e,{async:!1});return purify.sanitize(t,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:e}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:e})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:e,appID:t,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of e){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[e.map(d=>{var g;const f=d.fromPartnerID===t;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),e.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),e.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:e,activeChatObj:t,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:e[0]===n?e[1]:e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:t==null?void 0:t.name})]}),t!=null&&t.pending&&t.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(t==null?void 0:t.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(t==null?void 0:t.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(t==null?void 0:t.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:t!=null&&t.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:t==null?void 0:t.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:t!=null&&t.pending?"collapse":"ml-2 h-8 w-8",disabled:t==null?void 0:t.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:e,appID:t,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=e?[e.partner1,e.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${t}/Partner/${(d==null?void 0:d[0])===t?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((e==null?void 0:e.messages)??[]).length<1,onClick:()=>n(e.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx(PartnerActions,{userId:t,partnerId:(d==null?void 0:d[0])===t?d[1]:(d==null?void 0:d[0])||"",isAdmin:!1}),jsxRuntime.jsx(PeopleSection,{appID:t,activeChatObj:e}),jsxRuntime.jsx(LinkSection,{appID:t,activeChatObj:e})]})})}const PeopleSection=({appID:e,activeChatObj:t})=>{const n=(t==null?void 0:t.conversationID)??-1,o=!t||n===-1,{data:l,isLoading:d,isError:f,refetch:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdPeopleQuery({routeApplicationId:e,conversationId:n},{skip:o}),_=l??[];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),o?jsxRuntime.jsx("p",{className:"font-light",children:"Select a chat to see participants."}):d||b?jsxRuntime.jsx("p",{children:"Loading people..."}):f?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive",children:"Could not load people."}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"sm",onClick:()=>g(),children:"Retry"})]}):_.length===0?jsxRuntime.jsx("p",{className:"font-light",children:"No participants found."}):jsxRuntime.jsx("ul",{className:"flex flex-col gap-2",children:_.map((S,R)=>{const C=S.ApplicationId??`${S.Name??"person"}-${R}`,E=S.LastAuthentication?new Date(S.LastAuthentication).toLocaleString():void 0;return jsxRuntime.jsxs("li",{className:"rounded border px-3 py-2 text-sm",children:[jsxRuntime.jsx("p",{className:"font-medium leading-tight",children:S.Name??"Unknown person"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:S.Role??"Role unavailable"}),jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.Active?"Active":"Inactive",E?` · Last auth ${E}`:""]})]},C)})})]})},LinkSection=({appID:e,activeChatObj:t})=>{const[n,o]=React.useState(!1),l=t==null?void 0:t.conversationID,d=l===void 0||l===-1,{data:f,isLoading:g}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:e,conversationId:l??-1},{skip:d}),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[_]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[g?jsxRuntime.jsx("p",{children:"Loading links..."}):(f==null?void 0:f.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,f==null?void 0:f.map(S=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:S.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:S.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>_({routeApplicationId:e,linkId:S.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},S.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:d,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:S=>{S.preventDefault();const R=document.getElementById("link-title").value,C=document.getElementById("link-url").value;l===void 0||l===-1||(b({routeApplicationId:e,conversationId:l,createLinkRequest:{Title:R,Url:C}}),o(!1))},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:d,children:"Add Link"})]})]})]})]})},UserSetupForm=e=>{const[t]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),t({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:e.appID,partnerId:"2"})}),t({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(e,t)=>e.unread>0&&t.unread===0?-1:t.unread>0&&e.unread===0?1:e.name.localeCompare(t.name);function ChatLayout({appID:e,inputRef:t,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:e}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[q]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[Q,te]=React.useState(!1);React.useEffect(()=>{l&&(oe(dt=>{const It=l.map(Mt=>{var Ke;const Ct=dt.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((Ke=Mt.Participant)==null?void 0:Ke.PublicName)??"missing public name",unread:(Ct==null?void 0:Ct.unread)??0,pending:Mt.Status!=="Approved",messages:(Ct==null?void 0:Ct.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return It.sort(sortChats),It}),g(!0),setTimeout(()=>{var dt;return(dt=Le.current)==null?void 0:dt.focus()},50))},[l,e]);const[F,V]=React.useState(void 0),[ne,ae]=React.useState(""),[se,Oe]=React.useState(null),[Ne,oe]=React.useState([]),[$e,Ae]=React.useState(null),je=React.useRef(null),Be=React.useRef(null),[qe,Ve]=React.useState([]),Le=t||Be,He=React.useRef(null),{toast:We}=useToast(),ze=()=>Ne.find(dt=>dt.partner1===(F==null?void 0:F[0])&&dt.partner2===(F==null?void 0:F[1]));function Xe(){const dt=ze();dt&&I({routeApplicationId:e,conversationId:dt.conversationID})}const nt=dt=>Ve(It=>[...It,dt]);React.useEffect(()=>{if(qe.length==0)return;console.log(qe.length,"unprocessedMessages detected");const dt=(Mt,Ct)=>Ct.partner1===Mt.toPartnerID&&Ct.partner2===Mt.fromPartnerID||Ct.partner2===Mt.toPartnerID&&Ct.partner1===Mt.fromPartnerID;let It=!1;qe.forEach(Mt=>{if(!Ne.some(Ct=>dt(Mt,Ct))){console.log("message received for unknown convo ID - need to refetch!"),It=!0;return}oe(Ct=>Ct.map(Ke=>{if(!dt(Mt,Ke))return Ke;const Ye=Ke.messages??[];if(Ye.some(mt=>mt.id===Mt.id))return Ke;let Ze=1;const ct=document.activeElement&&document.activeElement===Le.current;return(F==null?void 0:F[0])==Ke.partner1&&F[1]==Ke.partner2&&ct&&(ct&&(Ze=0,Xe()),setTimeout(()=>{var mt;return(mt=je.current)==null?void 0:mt.scrollIntoView({behavior:"smooth"})},50)),{...Ke,pending:!1,unread:Ke.unread+Ze,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",It),It&&d(),Ve([])},[qe,Ve,oe,V,F]),React.useEffect(()=>{const dt=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return dt.on("ReceiveMessage",nt),dt.start().catch(It=>console.error("Error connecting to SignalR hub:",It)),Ae(dt),()=>{dt&&dt.stop()}},[e]),React.useEffect(()=>{var It;!F||!ze()||((It=Le.current)==null||It.focus(),setTimeout(()=>{var Mt;return(Mt=je.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[F]),React.useEffect(()=>{if(!F)return;const dt=ze();dt&&dt.conversationID!==-1&&(async()=>{var It;try{const Ct=((It=(await j({routeApplicationId:e,conversationId:dt.conversationID})).data)==null?void 0:It.map(Ke=>({id:"history"+Ke.MessageId,fromPartnerID:Ke.SenderId,toPartnerID:Ke.SenderId==dt.partner1?dt.partner2:dt.partner1,senderName:Ke.SenderName??"missing name",timestamp:new Date(Ke.SentDate+"Z").getTime(),content:Ke.Content??"no content"})))??[];oe(Ke=>Ke.map(Ye=>Ye.conversationID===dt.conversationID?{...Ye,messages:Ct}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[F,j,e]),React.useEffect(()=>{if(!F)return;const dt=ze();if(!dt)return;const It=document.activeElement&&document.activeElement===Le.current;dt.unread>0&&It&&(Xe(),oe(Mt=>Mt.map(Ct=>Ct.partner1===F[0]&&Ct.partner2===F[1]?{...Ct,unread:0}:Ct)))},[F,Ne]);const{sendMessage:Je}=useChat(),st=React.useCallback(dt=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(dt,null,2)}`)},[Je]),et=React.useCallback(async()=>{if(F)try{te(!0);const dt=await R({applicationId:e}),It=F[0]===e?F[1]:F[0],Mt=await q({routeApplicationId:e,partnerId:It,withSpecification:!0}),Ct=buildPartnershipAssistantPrompt(dt.data,Mt.data);Ct?Je(Ct):We({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(dt){console.error("Error preparing partnership analysis:",dt),We({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{te(!1)}},[F,R,q,Je,We,e]);React.useEffect(()=>{o(Ne.some(dt=>dt.unread>0))},[Ne,o]);const at=(dt,It)=>{It=It.replace(/\n/g,`
1164
+ `+Sn),$t&&arrayForEach([oe,$e,Ae],In=>{Sn=stringReplace(Sn,In," ")}),te&&Ke?te.createHTML(Sn):Sn},t.setConfig=function(){let Xt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bn(Xt),dt=!0},t.clearConfig=function(){On=null,dt=!1},t.isValidAttribute=function(Xt,it,Dt){On||Bn({});const Wt=mn(Xt),pn=mn(it);return cr(Wt,pn,Dt)},t.addHook=function(Xt,it){typeof it=="function"&&arrayPush(Ne[Xt],it)},t.removeHook=function(Xt,it){if(it!==void 0){const Dt=arrayLastIndexOf(Ne[Xt],it);return Dt===-1?void 0:arraySplice(Ne[Xt],Dt,1)[0]}return arrayPop(Ne[Xt])},t.removeHooks=function(Xt){Ne[Xt]=[]},t.removeAllHooks=function(){Ne=_createHooksMap()},t}var purify=createDOMPurify();function markdownToSafeHTML(e){const t=marked(e,{async:!1});return purify.sanitize(t,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:e}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:e})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:e,appID:t,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of e){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[e.map(d=>{var g;const f=d.fromPartnerID===t;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),e.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),e.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:e,activeChatObj:t,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:e[0]===n?e[1]:e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:t==null?void 0:t.name})]}),t!=null&&t.pending&&t.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(t==null?void 0:t.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(t==null?void 0:t.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(t==null?void 0:t.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:t!=null&&t.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:t==null?void 0:t.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:t!=null&&t.pending?"collapse":"ml-2 h-8 w-8",disabled:t==null?void 0:t.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:e,appID:t,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=e?[e.partner1,e.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${t}/Partner/${(d==null?void 0:d[0])===t?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((e==null?void 0:e.messages)??[]).length<1,onClick:()=>n(e.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx(PartnerActions,{userId:t,partnerId:(d==null?void 0:d[0])===t?d[1]:(d==null?void 0:d[0])||"",isAdmin:!1}),jsxRuntime.jsx(PeopleSection,{appID:t,activeChatObj:e}),jsxRuntime.jsx(LinkSection,{appID:t,activeChatObj:e})]})})}const PeopleSection=({appID:e,activeChatObj:t})=>{const n=(t==null?void 0:t.conversationID)??-1,o=!t||n===-1,{data:l,isLoading:d,isError:f,refetch:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdPeopleQuery({routeApplicationId:e,conversationId:n},{skip:o}),_=l??[];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),o?jsxRuntime.jsx("p",{className:"font-light",children:"Select a chat to see participants."}):d||b?jsxRuntime.jsx("p",{children:"Loading people..."}):f?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive",children:"Could not load people."}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"sm",onClick:()=>g(),children:"Retry"})]}):_.length===0?jsxRuntime.jsx("p",{className:"font-light",children:"No participants found."}):jsxRuntime.jsx("ul",{className:"flex flex-col gap-2",children:_.map((S,R)=>{const C=S.ApplicationId??`${S.Name??"person"}-${R}`,E=S.LastAuthentication?new Date(S.LastAuthentication).toLocaleString():void 0;return jsxRuntime.jsxs("li",{className:"rounded border px-3 py-2 text-sm",children:[jsxRuntime.jsx("p",{className:"font-medium leading-tight",children:S.Name??"Unknown person"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:S.Role??"Role unavailable"}),E?jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last auth ",E]}):null]},C)})})]})},LinkSection=({appID:e,activeChatObj:t})=>{const[n,o]=React.useState(!1),l=t==null?void 0:t.conversationID,d=l===void 0||l===-1,{data:f,isLoading:g}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:e,conversationId:l??-1},{skip:d}),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[_]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[g?jsxRuntime.jsx("p",{children:"Loading links..."}):(f==null?void 0:f.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,f==null?void 0:f.map(S=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:S.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:S.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>_({routeApplicationId:e,linkId:S.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},S.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:d,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:S=>{S.preventDefault();const R=document.getElementById("link-title").value,C=document.getElementById("link-url").value;l===void 0||l===-1||(b({routeApplicationId:e,conversationId:l,createLinkRequest:{Title:R,Url:C}}),o(!1))},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:d,children:"Add Link"})]})]})]})]})},UserSetupForm=e=>{const[t]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),t({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:e.appID,partnerId:"2"})}),t({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(e,t)=>e.unread>0&&t.unread===0?-1:t.unread>0&&e.unread===0?1:e.name.localeCompare(t.name);function ChatLayout({appID:e,inputRef:t,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:e}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[q]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[Q,te]=React.useState(!1);React.useEffect(()=>{l&&(oe(dt=>{const It=l.map(Mt=>{var Ke;const Ct=dt.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((Ke=Mt.Participant)==null?void 0:Ke.PublicName)??"missing public name",unread:(Ct==null?void 0:Ct.unread)??0,pending:Mt.Status!=="Approved",messages:(Ct==null?void 0:Ct.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return It.sort(sortChats),It}),g(!0),setTimeout(()=>{var dt;return(dt=Le.current)==null?void 0:dt.focus()},50))},[l,e]);const[F,V]=React.useState(void 0),[ne,ae]=React.useState(""),[se,Oe]=React.useState(null),[Ne,oe]=React.useState([]),[$e,Ae]=React.useState(null),je=React.useRef(null),Be=React.useRef(null),[qe,Ve]=React.useState([]),Le=t||Be,He=React.useRef(null),{toast:We}=useToast(),ze=()=>Ne.find(dt=>dt.partner1===(F==null?void 0:F[0])&&dt.partner2===(F==null?void 0:F[1]));function Xe(){const dt=ze();dt&&I({routeApplicationId:e,conversationId:dt.conversationID})}const nt=dt=>Ve(It=>[...It,dt]);React.useEffect(()=>{if(qe.length==0)return;console.log(qe.length,"unprocessedMessages detected");const dt=(Mt,Ct)=>Ct.partner1===Mt.toPartnerID&&Ct.partner2===Mt.fromPartnerID||Ct.partner2===Mt.toPartnerID&&Ct.partner1===Mt.fromPartnerID;let It=!1;qe.forEach(Mt=>{if(!Ne.some(Ct=>dt(Mt,Ct))){console.log("message received for unknown convo ID - need to refetch!"),It=!0;return}oe(Ct=>Ct.map(Ke=>{if(!dt(Mt,Ke))return Ke;const Ye=Ke.messages??[];if(Ye.some(mt=>mt.id===Mt.id))return Ke;let Ze=1;const ct=document.activeElement&&document.activeElement===Le.current;return(F==null?void 0:F[0])==Ke.partner1&&F[1]==Ke.partner2&&ct&&(ct&&(Ze=0,Xe()),setTimeout(()=>{var mt;return(mt=je.current)==null?void 0:mt.scrollIntoView({behavior:"smooth"})},50)),{...Ke,pending:!1,unread:Ke.unread+Ze,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",It),It&&d(),Ve([])},[qe,Ve,oe,V,F]),React.useEffect(()=>{const dt=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return dt.on("ReceiveMessage",nt),dt.start().catch(It=>console.error("Error connecting to SignalR hub:",It)),Ae(dt),()=>{dt&&dt.stop()}},[e]),React.useEffect(()=>{var It;!F||!ze()||((It=Le.current)==null||It.focus(),setTimeout(()=>{var Mt;return(Mt=je.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[F]),React.useEffect(()=>{if(!F)return;const dt=ze();dt&&dt.conversationID!==-1&&(async()=>{var It;try{const Ct=((It=(await j({routeApplicationId:e,conversationId:dt.conversationID})).data)==null?void 0:It.map(Ke=>({id:"history"+Ke.MessageId,fromPartnerID:Ke.SenderId,toPartnerID:Ke.SenderId==dt.partner1?dt.partner2:dt.partner1,senderName:Ke.SenderName??"missing name",timestamp:new Date(Ke.SentDate+"Z").getTime(),content:Ke.Content??"no content"})))??[];oe(Ke=>Ke.map(Ye=>Ye.conversationID===dt.conversationID?{...Ye,messages:Ct}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[F,j,e]),React.useEffect(()=>{if(!F)return;const dt=ze();if(!dt)return;const It=document.activeElement&&document.activeElement===Le.current;dt.unread>0&&It&&(Xe(),oe(Mt=>Mt.map(Ct=>Ct.partner1===F[0]&&Ct.partner2===F[1]?{...Ct,unread:0}:Ct)))},[F,Ne]);const{sendMessage:Je}=useChat(),st=React.useCallback(dt=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(dt,null,2)}`)},[Je]),et=React.useCallback(async()=>{if(F)try{te(!0);const dt=await R({applicationId:e}),It=F[0]===e?F[1]:F[0],Mt=await q({routeApplicationId:e,partnerId:It,withSpecification:!0}),Ct=buildPartnershipAssistantPrompt(dt.data,Mt.data);Ct?Je(Ct):We({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(dt){console.error("Error preparing partnership analysis:",dt),We({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{te(!1)}},[F,R,q,Je,We,e]);React.useEffect(()=>{o(Ne.some(dt=>dt.unread>0))},[Ne,o]);const at=(dt,It)=>{It=It.replace(/\n/g,`
1165
1165
  `),console.log("doSend",It),console.log("target",dt);const Mt={id:crypto.randomUUID(),senderName:(lt==null?void 0:lt.Name)??(lt==null?void 0:lt.EmailAddress)??"User",fromPartnerID:e,toPartnerID:dt.partner1===e?dt.partner2:dt.partner1,content:It,timestamp:Date.now()};nt(Mt),$e.invoke("NewMessage",Mt).catch(Ct=>console.error("Error sending message:",Ct)),ae(""),He.current&&(He.current.value="")},tt=()=>{const dt=ne.trim();!Rt||!dt||!F||!$e||(Rt.unread>0&&(Xe(),oe(It=>It.map(Mt=>Mt.partner1===F[0]&&Mt.partner2===F[1]?{...Mt,unread:0}:Mt))),at(Rt,dt))},ot=(dt,It)=>Oe([dt,It]);React.useEffect(()=>{if(se===null)return;const dt=Ne.find(Mt=>Mt.conversationID===se[0]);if(!dt||(V([dt.partner1,dt.partner2]),!$e))return;const It=se[1];Oe(null),It&&at(dt,It)},[se,Ne,V,$e]);const{data:lt,isLoading:Ge}=useGetV4UserQuery();if(!f||Ge)return jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"});if(!(lt!=null&&lt.Name))return jsxRuntime.jsx(UserSetupForm,{appID:(lt==null?void 0:lt.ApplicationId)??""});const $t=async()=>{var dt,It,Mt,Ct,Ke;S.current&&(S.current.disabled=!0),A(!0);try{const Ye=await R({applicationId:e}),Ze=((dt=Ye.data)==null?void 0:dt.About)??"a new business venture",ct=[];(It=Ye.data)!=null&&It.IsManufacturer&&ct.push("Manufacturer"),(Mt=Ye.data)!=null&&Mt.IsReseller&&ct.push("Reseller"),(Ct=Ye.data)!=null&&Ct.IsSalesAgency&&ct.push("Sales Agency");const ft=`
1166
1166
  Your task is to draft a ready-to-send opening message from a user to the Randmar team.
1167
1167
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.480.0",
4
+ "version": "1.481.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [