profoundjs 7.22.0 → 7.23.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.
Files changed (38) hide show
  1. package/htdocs/profoundui/proddata/css/profoundai.css +39 -9
  2. package/htdocs/profoundui/proddata/css/profoundui.css +20 -1
  3. package/htdocs/profoundui/proddata/js/atrium.js +500 -509
  4. package/htdocs/profoundui/proddata/js/atrium_api.js +6 -6
  5. package/htdocs/profoundui/proddata/js/designer.js +4937 -5056
  6. package/htdocs/profoundui/proddata/js/genie.js +3142 -3225
  7. package/htdocs/profoundui/proddata/js/profoundai.js +34 -31
  8. package/htdocs/profoundui/proddata/js/runtime.js +1867 -1898
  9. package/htdocs/profoundui/proddata/js/signon.js +102 -107
  10. package/index.js +1 -0
  11. package/package.json +2 -2
  12. package/profound.jse +1 -1
  13. package/setup/call.js +2 -0
  14. package/setup/completeInstall.js +3 -1
  15. package/setup/convertStartJS.js +2 -2
  16. package/setup/pjsdist.savf +0 -0
  17. package/setup/plugins/mathoperation.js +75 -79
  18. package/setup/start.js +3 -2
  19. package/setup/store_credentials.js +2 -0
  20. package/setup/store_options.js +2 -0
  21. package/htdocs/profoundui/proddata/css/plogic.css +0 -4976
  22. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-700.eot +0 -0
  23. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-700.svg +0 -276
  24. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-700.ttf +0 -0
  25. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-700.woff +0 -0
  26. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-700.woff2 +0 -0
  27. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-italic.eot +0 -0
  28. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-italic.svg +0 -301
  29. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-italic.ttf +0 -0
  30. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-italic.woff +0 -0
  31. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-italic.woff2 +0 -0
  32. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-regular.eot +0 -0
  33. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-regular.svg +0 -281
  34. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-regular.ttf +0 -0
  35. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-regular.woff +0 -0
  36. package/htdocs/profoundui/proddata/fonts/gudea-v10-latin-regular.woff2 +0 -0
  37. package/htdocs/profoundui/proddata/fonts/material_icons.woff2 +0 -0
  38. package/htdocs/profoundui/proddata/js/plogic.grids.js +0 -326
@@ -1,31 +1,34 @@
1
- if(!window.profound)window.profound={};window.profound.ai||(window.profound.ai={});if(!window.pui)window.pui={};
2
- profound.ai.Chat=function(){function h(){if(window.pui&&window.pui.ide&&window.pui.ide.designerId)return true;return false}function p(){var a=Ext.c("centerPanel").f(),d={};if(a.isAIAgent&&a.aiAgent)d.aiAgent=a.aiAgent;if(a.isAIAgent&&a.dataAccess)d.dataAccess=a.dataAccess;Object.assign(d,Object.fromEntries(Object.entries(a.pjsModule).filter(function(c){return typeof c[1]!=="function"})));return d}function l(){function a(){var c=k.lastChild.querySelectorAll(".pai-chart");if(c.length!==0)if(profound.ai.a){for(var e=
3
- 0;e<c.length;e++){var f=c[e],m=JSON.parse(f.getAttribute("data-config"));f.removeAttribute("data-config");f.chart=new window.Chart(f.querySelector("canvas"),m);f=f.querySelector("span");f.parentNode.removeChild(f)}k.scrollTop=k.scrollHeight}else{d++;d<20&&setTimeout(a,1E3)}}var d=0;a()}function n(a){function d(){a.read().then(function(m){var j=m.value;if(m.done){b.hideLoader();l()}else{m=c.decode(j).split("\n");for(j=0;j<m.length-1;j++){var g=m[j];if(g){g=JSON.parse(g);if(g.threadId)x=g.threadId;
4
- if(g.status==="error"){b.hideLoader();b.add({message:"Error: "+g.message,type:"error"});return}if(g.status==="calling"){var r=k.lastChild;g=r.innerHTML.replace(y,"")+'<p>Calling <span class="pai-function-name">'+g["function"]+"</span>.</p>";b.add({message:g+y,type:"agent-response",replace:true})}else if(g.status==="calls completed"){r=k.lastChild;var u="<p>";u+=g.count===1?"Call completed.":g.count+" calls completed.";u+="</p>";u=r.innerHTML.replace(y,"")+u;b.add({message:u+y,type:"agent-response",
5
- replace:true})}else{if(g.status==="file")e=e.replace(g.placeholderUrl,g.fileUrl);e+=g.text;if(g.charts){if(!profound.ai.a){var S=window.define;window.define=undefined;profound.ai.b(M,function(){window.define=S;profound.ai.a=true})}f=g.charts}if(f)for(var N in f)e=e.replace(N,'<div class="pai-chart" data-config="'+JSON.stringify(f[N]).replace(/"/g,"&quot;")+'"><span>Loading chart...</span><canvas></canvas></div>');r=e&&typeof window.marked==="function"?window.marked(e+y):e+y;g.status==="citation"&&
6
- H.push(g);for(g=0;g<H.length;g++){u=H[g];r=r.replace(u.citationPlaceholder,u.citationContent)}b.add({message:r,type:"agent-response",replace:true})}}}d()}})}var c=new TextDecoder("utf-8"),e="",f;d()}function C(a){var d=a.status;if(a.threadId)x=a.threadId;if(a.runId)I=a.runId;if(a.modelKey)K=a.modelKey;if(a.message){var c=a.message,e="agent-response";if(a.status==="error"){c="Error: "+c;e="error"}if(a.status==="failed"){c="Failed: "+c;e="error"}if(a.status==="cancelled"){c="Cancelled";e="error"}if(a.status===
7
- "expired"){c="Chat Expired";e="error"}if(a.charts){if(!profound.ai.a){var f=window.define;window.define=undefined;profound.ai.b(M,function(){window.define=f;profound.ai.a=true})}var m=a.charts;for(var j in m)c=c.replace(j,'<div class="pai-chart" data-config="'+JSON.stringify(m[j]).replace(/"/g,"&quot;")+'"><span>Loading chart...</span><canvas></canvas></div>')}b.add({message:c,type:e});a.charts&&l()}d==="queued"||d==="in_progress"?setTimeout(function(){b.poll()},O):b.hideLoader()}function v(){i.value===
8
- ""||b.isLoading()?s.classList.remove("pai-send-button-active"):s.classList.add("pai-send-button-active");var a="webkitSpeechRecognition"in window||"SpeechRecognition"in window;if(h()){var d=Ext.c("aiAgentModel").getValue();if(pui.modelVoiceSettings)z=pui.modelVoiceSettings[d];z||(z={})}if(a&&z.enabled===false)a=false;if(a){i.classList.add("pai-with-voice");o.classList.remove("pai-hidden")}else{i.classList.remove("pai-with-voice");o.classList.add("pai-hidden")}}function F(){i.style.height="1px";var a=
9
- i.scrollHeight==0?21:i.scrollHeight;if(a<21)a=21;if(a>100)a=100;k.style.height="calc(100% - "+(a+54+(b.heading?74:0))+"px)";i.style.height=a+"px"}function T(a,d){if(typeof a!=="string")return a;if(a.length!==7)return a;if(a.substring(0,1)!=="#")return a;var c=parseInt(a.substring(1,3),16),e=parseInt(a.substring(3,5),16),f=parseInt(a.substring(5,7),16);c=parseInt(c*(100+d)/100);e=parseInt(e*(100+d)/100);f=parseInt(f*(100+d)/100);c=c<255?c:255;e=e<255?e:255;f=f<255?f:255;return"#"+(c.toString(16).length==
10
- 1?"0"+c.toString(16):c.toString(16))+(e.toString(16).length==1?"0"+e.toString(16):e.toString(16))+(f.toString(16).length==1?"0"+f.toString(16):f.toString(16))}var b=this,t=null,k=null,D=null,i=null,s=null,o=null,x=null,I=null,K=null,O=1E3,A=null,J=null,P="Thinking",E="",G="light",B=null,w=false,z={},y='<span class="pai-loader-dot pai-inline-loader"></span>',M="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",L=null,H=[],Q,q,R=false;this.init=function(a){a||(a={});b.e=a;if(!a.container)a.container=
11
- document.body;if(a.closeButton===undefined)a.closeButton=true;a.closeTitle||(a.closeTitle="Close this conversation");a.sendTitle||(a.sendTitle="Send this message");a.voiceTitle||(a.voiceTitle="Use voice");a.promptPlaceholder||(a.promptPlaceholder="Send a message...");if(a.heading)b.heading=a.heading;if(a.greeting)b.greeting=a.greeting;if(a.agent)b.agent=a.agent;if(a.pollInterval)O=a.pollInterval;if(a.loaderMessage){P=a.loaderMessage;R=true}if(a.server)E=a.server;if(a.data)b.data=a.data;if(a.stream)w=
12
- a.stream;if(typeof a.voice==="object")z=a.voice;if(a.jwt)L=a.jwt;b.dom=document.createElement("div");b.dom.classList.add("pai-chat");b.dom.classList.add("pai-hidden");a.container.appendChild(b.dom);if(a.closeButton){t=document.createElement("div");t.classList.add("pai-close-button");t.title=a.closeTitle;t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';
13
- t.addEventListener("click",function(){b.onClose&&b.onClose();h()?b.clear():b.hide()});b.dom.appendChild(t)}k=document.createElement("div");k.classList.add("pai-messages");b.dom.appendChild(k);D=document.createElement("div");D.classList.add("pai-prompt-area");i=document.createElement("textarea");i.classList.add("pai-prompt-box");i.setAttribute("placeholder",a.promptPlaceholder);i.addEventListener("keydown",function(e){if(e.key==="Enter"){e.shiftKey||e.preventDefault();e.stopPropagation();e.shiftKey||
14
- b.send()}v()});i.addEventListener("input",function(){F();v()});D.appendChild(i);o=document.createElement("div");o.classList.add("pai-voice-button");o.title=a.voiceTitle;o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm4.5-3c0 2.5-2 4.5-4.5 4.5S7.5 13.5 7.5 11H6c0 3.07 2.13 5.64 5 6.32V21h2v-3.68c2.87-.68 5-3.25 5-6.32h-1.5z"/></svg>';
15
- D.appendChild(o);if("webkitSpeechRecognition"in window||"SpeechRecognition"in window){Q=window.SpeechRecognition||window.webkitSpeechRecognition;q=new Q;q.continuous=true;q.interimResults=true;o.addEventListener("click",function(){q.lang=z.lang?z.lang:"en-US";o.classList.contains("pai-recording")?q.stop():q.start();o.classList.toggle("pai-recording")});q.onresult=function(e){if(o.classList.contains("pai-recording")){for(var f=[],m=0;m<e.results.length;m++)f.push(e.results[m][0].transcript);i.value=
16
- f.join("");F();i.scrollTop=i.scrollHeight;i.focus();v()}};q.onend=function(){o.classList.remove("pai-recording");i.select();v()};q.onerror=function(e){b.add({message:"Speech recognition error: "+e.error,type:"error"})}}s=document.createElement("div");s.classList.add("pai-send-button");s.title=a.sendTitle;s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>';
17
- s.addEventListener("click",function(){b.send()});D.appendChild(s);b.dom.appendChild(D);A=document.createElement("div");A.classList.add("pai-loader");J=document.createElement("span");J.classList.add("pai-loader-message");A.appendChild(J);for(var d=1;d<=3;d++){var c=document.createElement("div");c.classList.add("pai-loader-dot");A.appendChild(c)}b.clear();a.theme&&b.setTheme(a.theme);a.brandColor&&b.setBrandColor(a.brandColor);v()};this.show=function(){b.dom.classList.remove("pai-hidden");i.focus()};
18
- this.hide=function(){b.dom.classList.add("pai-hidden")};this.add=function(a){var d=a.message,c=document.createElement("div");c.classList.add("pai-message");var e=a.type;e||(e="user-message");c.classList.add("pai-"+e);if(e==="agent-response"){c.classList.add("markdown-body");if(E){d=d.replace(/<img src="\/profound-ai\/image\?file=/g,'<img src="'+E+"/profound-ai/image?file=");d=d.replace(/="\/profound-ai\/file\?file=/g,'="'+E+"/profound-ai/file?file=")}c.innerHTML=d;c.querySelectorAll("a").forEach(function(f){f.addEventListener("click",
19
- function(){pui.skipConfirm=true;setTimeout(function(){pui.skipConfirm=false},250)})});c.querySelectorAll("span.pai-citation").forEach(function(f){function m(){if(j&&!j.matches(":hover")){f.removeChild(j);j=null}}var j,g;f.addEventListener("mouseenter",function(){if(!j)if(f.getAttribute("data-citation")){j=document.createElement("div");j.classList.add("pai-tooltip-content");j.innerHTML=f.getAttribute("data-citation");f.appendChild(j);var r=f.getBoundingClientRect();j.style.left=r.left+"px";j.style.top=
20
- r.top-j.offsetHeight-5+"px";j.addEventListener("mouseenter",function(){clearTimeout(g)});j.addEventListener("mouseleave",function(){m()})}});f.addEventListener("mouseleave",function(){g=setTimeout(m,100)})});if(a.replace)(a=k.lastChild)&&a.classList.contains("pai-agent-response")&&a.parentNode.removeChild(a)}else c.innerText=d;k.appendChild(c);k.scrollTop=k.scrollHeight};this.clear=function(){o.classList.contains("pai-recording")&&q.stop();i.value="";k.innerHTML="";b.greeting&&b.add({message:b.greeting,
21
- type:"greeting"});b.setHeading(b.heading);b.setBrandColor(B);v();I=x=null};this.setTheme=function(a){G=a;G=typeof G!=="string"?"light":G.toLowerCase();G==="dark"?b.dom.classList.add("pai-dark"):b.dom.classList.remove("pai-dark")};this.setBrandColor=function(a){B=a;if(a=b.dom.querySelector(".pai-heading")){a.style.backgroundColor=null;a.style.backgroundImage=null;a.classList.remove("pai-branded")}t&&t.classList.remove("pai-branded");s.style.backgroundColor=null;if(B){var d=T(B,-30);if(a){a.style.backgroundColor=
22
- B;a.style.backgroundImage="linear-gradient(to right, "+B+", "+d+")";a.classList.add("pai-branded")}t&&a&&t.classList.add("pai-branded");s.style.backgroundColor=B}};this.setHeading=function(a){var d=b.dom.querySelector(".pai-heading");if(a){if(d===null){d=document.createElement("div");d.classList.add("pai-heading");b.dom.prepend(d);F()}d.innerText=a}else if(d!==null){d.remove();F()}};this.send=function(){if(i.value!=="")if(!b.isLoading()){if(o.classList.contains("pai-recording")){q.stop();o.classList.toggle("pai-recording")}b.onSend&&
23
- b.onSend(i.value);b.add({message:i.value});H=[];var a={};a.message=i.value;if(x)a.threadId=x;var d="/profound-ai/chat";if(h()){a.agentData=p();a.agentFile=Ext.c("centerPanel").f().title.replace(/\*/g,"").trim();w=pui.streamingModelList.includes(a.agentData.aiAgent.model);d="/ide/profound-ai/chat"}else a.agent=b.agent;var c=b.data;if(typeof c==="function")c=c();if(b.data)a.data=c;i.value="";F();i.focus();b.showLoader();c={"Content-Type":"application/json"};if(w){c.Connection="keep-alive";c["Response-Type"]=
24
- "stream"}if(pui.appJob&&pui.appJob.authToken)c.Authorization="Bearer "+pui.appJob.authToken;else if(L){var e=L;if(typeof e==="function")e=e();c.Authorization="Bearer "+e}fetch(E+d,{method:"POST",headers:c,body:JSON.stringify(a)}).then(function(f){return w?f.body.getReader():f.json()}).then(function(f){w?n(f):C(f)})["catch"](function(f){b.hideLoader();b.add({message:"Error: "+f.message,type:"error"})})}};this.poll=function(){if(!(!x||!I||!K)){var a={};a.threadId=x;a.runId=I;a.modelKey=K;var d="/profound-ai/poll";
25
- if(h())d="/ide/profound-ai/poll";fetch(E+d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(function(c){return c.json()}).then(function(c){C(c)})["catch"](function(c){b.hideLoader();b.add({message:"Error: "+c.message,type:"error"})})}};this.showLoader=function(a){a||(a=b.e.loaderMessage||P);J.innerText=a;if(!b.isLoading()){w?b.add({message:R?a:y,type:"agent-response"}):k.appendChild(A);v();k.scrollTop=k.scrollHeight}};this.hideLoader=function(){if(b.isLoading()){if(w)for(var a=
26
- k.querySelectorAll(".pai-inline-loader"),d=a.length-1;d>=0;d--)a[d].parentNode.removeChild(a[d]);else k.removeChild(A);v()}};this.isLoading=function(){if(w)return k.querySelectorAll(".pai-inline-loader").length>0;return A.parentNode===k};this.destroy=function(){if(b.dom){b.dom.parentNode.removeChild(b.dom);b.dom=null}};this.removeEmbedIcon=function(){profound.ai.removeEmbedIcon()}};
27
- profound.ai.d=function(h){if(!document.querySelector('link[href="'+h+'"]')){var p=document.createElement("link");p.rel="stylesheet";p.href=h;document.head.appendChild(p)}};profound.ai.b=function(h,p){if(document.querySelector('script[src="'+h+'"]'))typeof p==="function"&&p();else{var l=document.createElement("script");l.type="text/javascript";l.src=h;l.onload=function(){typeof p==="function"&&p()};document.head.appendChild(l)}};
28
- profound.ai.startAgent=function(h,p){h||(h={});var l="";if(h.server)l=h.server;if(!p&&h.agent)fetch(l+"/profound-ai/attributes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:h.agent})}).then(function(n){return n.json()}).then(function(n){if(n.status==="error")throw Error(n.message);n=n.attributes;for(var C in n)if(h[C]===undefined)h[C]=n[C];profound.ai.startAgent(h,true)})["catch"](function(n){throw Error("Unable to start AI Agent: "+n.message);});else{if(!h.container)h.container=
29
- document.body;h.stream&&profound.ai.b(l+"/marked/marked.min.js");profound.ai.d(l+"/profoundui/proddata/css/markdown.css");profound.ai.d(l+"/profoundui/proddata/css/profoundai.css");profound.ai.agent&&profound.ai.agent.destroy();if(h.embed){if(!profound.ai.embedIcon){profound.ai.embedIcon=document.createElement("div");profound.ai.embedIcon.classList.add("pai-embed-icon");profound.ai.embedIcon.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"/></svg>';
30
- h.container.appendChild(profound.ai.embedIcon)}profound.ai.embedIcon.title=h.embedIconTitle||"Ask AI Agent";l=profound.ai.embedIcon.cloneNode(true);l.addEventListener("click",function(){var n=Object.assign({},h);delete n.embed;profound.ai.startAgent(n)});profound.ai.embedIcon.parentNode.replaceChild(l,profound.ai.embedIcon);profound.ai.embedIcon=l}else{profound.ai.agent=new profound.ai.Chat;profound.ai.agent.init(h);profound.ai.agent.show();return profound.ai.agent}}};
31
- profound.ai.removeEmbedIcon=function(){if(profound.ai.embedIcon){profound.ai.embedIcon.parentNode.removeChild(profound.ai.embedIcon);profound.ai.embedIcon=null}};
1
+ window.profound||(window.profound={});window.profound.ai||(window.profound.ai={});window.pui||(window.pui={});
2
+ profound.ai.Chat=function(){function h(){return window.pui&&window.pui.ide&&window.pui.ide.designerId?!0:!1}function n(){clearTimeout(P);A=H=null;b.hideLoader();t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>';t.title=b.config.m||"Send this message";b.abortController=null}function v(){var a=Ext.i("centerPanel").l(),
3
+ c={};a.isAIAgent&&a.aiAgent&&(c.aiAgent=a.aiAgent);a.isAIAgent&&a.dataAccess&&(c.dataAccess=a.dataAccess);Object.assign(c,Object.fromEntries(Object.entries(a.pjsModule).filter(function(d){return"function"!==typeof d[1]})));return c}function q(){function a(){var d=m.lastChild.querySelectorAll(".pai-chart");if(0!==d.length)if(profound.ai.g){for(var e=0;e<d.length;e++){var g=d[e],p=JSON.parse(g.getAttribute("data-config"));g.removeAttribute("data-config");g.chart=new window.Chart(g.querySelector("canvas"),
4
+ p);g=g.querySelector("span");g.parentNode.removeChild(g)}m.scrollTop=m.scrollHeight}else c++,20>c&&setTimeout(a,1E3)}var c=0;a()}function I(a){function c(){a.read().then(function(p){var l=p.value;if(p.done)n(),q();else{p=d.decode(l).split("\n");for(l=0;l<p.length-1;l++){var k=p[l];if(k){k=JSON.parse(k);k.threadId&&(A=k.threadId);if("error"===k.status){b.hideLoader();b.add({message:"Error: "+k.message,type:"error"});return}if("calling"===k.status){var x=m.lastChild;k=x.innerHTML.replace('<span class="pai-loader-dot pai-inline-loader"></span>',
5
+ "")+'<p>Calling <span class="pai-function-name">'+k["function"]+"</span>.</p>";b.add({message:k+'<span class="pai-loader-dot pai-inline-loader"></span>',type:"agent-response",replace:!0})}else if("calls completed"===k.status){x=m.lastChild;var y="<p>";y=1===k.count?y+"Call completed.":y+(k.count+" calls completed.");y+="</p>";y=x.innerHTML.replace('<span class="pai-loader-dot pai-inline-loader"></span>',"")+y;b.add({message:y+'<span class="pai-loader-dot pai-inline-loader"></span>',type:"agent-response",
6
+ replace:!0})}else{"file"===k.status&&(e=e.replace(k.placeholderUrl,k.fileUrl));e+=k.text;if(k.charts){if(!profound.ai.g){var W=window.define;window.define=void 0;profound.ai.h("https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",function(){window.define=W;profound.ai.g=!0})}g=k.charts}if(g)for(var Q in g)e=e.replace(Q,'<div class="pai-chart" data-config="'+JSON.stringify(g[Q]).replace(/"/g,"&quot;")+'"><span>Loading chart...</span><canvas></canvas></div>');x=e&&"function"===typeof window.marked?
7
+ window.marked(e+'<span class="pai-loader-dot pai-inline-loader"></span>'):e+'<span class="pai-loader-dot pai-inline-loader"></span>';"citation"===k.status&&L.push(k);for(k=0;k<L.length;k++)y=L[k],x=x.replace(y.citationPlaceholder,y.citationContent);b.add({message:x,type:"agent-response",replace:!0})}}}c()}})["catch"](function(p){"AbortError"===p.name?n():(b.hideLoader(),b.add({message:"Error: "+p.message,type:"error"}))})}var d=new TextDecoder("utf-8"),e="",g;c()}function R(a){var c=a.status;a.threadId&&
8
+ (A=a.threadId);a.runId&&(H=a.runId);a.modelKey&&(N=a.modelKey);if(a.message){var d=a.message,e="agent-response";"error"===a.status&&(d="Error: "+d,e="error");"failed"===a.status&&(d="Failed: "+d,e="error");"cancelled"===a.status&&(d="Cancelled",e="error");"expired"===a.status&&(d="Chat Expired",e="error");if(a.charts){if(!profound.ai.g){var g=window.define;window.define=void 0;profound.ai.h("https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",function(){window.define=g;profound.ai.g=!0})}var p=
9
+ a.charts,l;for(l in p)d=d.replace(l,'<div class="pai-chart" data-config="'+JSON.stringify(p[l]).replace(/"/g,"&quot;")+'"><span>Loading chart...</span><canvas></canvas></div>')}b.add({message:d,type:e});a.charts&&q()}"queued"===c||"in_progress"===c?P=setTimeout(function(){b.poll()},S):n()}function B(){""===f.value||b.isLoading()?t.classList.remove("pai-send-button-active"):t.classList.add("pai-send-button-active");var a="webkitSpeechRecognition"in window||"SpeechRecognition"in window;if(h()){var c=
10
+ Ext.i("aiAgentModel").getValue();pui.modelVoiceSettings&&(E=pui.modelVoiceSettings[c]);E||={}}a&&!1===E.enabled&&(a=!1);a?(f.classList.add("pai-with-voice"),r.classList.remove("pai-hidden")):(f.classList.remove("pai-with-voice"),r.classList.add("pai-hidden"))}function J(){f.style.height="1px";var a=0==f.scrollHeight?21:f.scrollHeight;21>a&&(a=21);100<a&&(a=100);m.style.height="calc(100% - "+(a+54+(b.heading?74:0))+"px)";f.style.height=a+"px"}var b=this,z=b.abortController=null,m=null,F=null,f=null,
11
+ t=null,r=null,A=null,H=null,N=null,S=1E3,D=null,M=null,T="Thinking",G="",K="light",u=null,C=!1,E={},O=null,L=[],U,w,V=!1,P=null;this.init=function(a){a||={};b.config=a;a.container||(a.container=document.body);void 0===a.closeButton&&(a.closeButton=!0);a.closeTitle||(a.closeTitle="Close this conversation");a.sendTitle||(a.sendTitle="Send this message");a.voiceTitle||(a.voiceTitle="Use voice");a.promptPlaceholder||(a.promptPlaceholder="Send a message...");a.heading&&(b.heading=a.heading);a.greeting&&
12
+ (b.greeting=a.greeting);a.agent&&(b.agent=a.agent);a.pollInterval&&(S=a.pollInterval);a.loaderMessage&&(T=a.loaderMessage,V=!0);a.server&&(G=a.server);a.data&&(b.data=a.data);a.stream&&(C=a.stream);"object"===typeof a.voice&&(E=a.voice);a.jwt&&(O=a.jwt);b.dom=document.createElement("div");b.dom.classList.add("pai-chat");b.dom.classList.add("pai-hidden");a.container.appendChild(b.dom);a.closeButton&&(z=document.createElement("div"),z.classList.add("pai-close-button"),z.title=a.closeTitle,z.innerHTML=
13
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',z.addEventListener("click",function(){if(b.onClose)b.onClose();h()?b.clear():b.hide()}),b.dom.appendChild(z));m=document.createElement("div");m.classList.add("pai-messages");b.dom.appendChild(m);F=document.createElement("div");F.classList.add("pai-prompt-area");
14
+ f=document.createElement("textarea");f.classList.add("pai-prompt-box");f.setAttribute("placeholder",a.promptPlaceholder);f.addEventListener("keydown",function(e){"Enter"===e.key&&(e.shiftKey||e.preventDefault(),e.stopPropagation(),e.shiftKey||b.send());B()});f.addEventListener("input",function(){J();B()});F.appendChild(f);r=document.createElement("div");r.classList.add("pai-voice-button");r.title=a.voiceTitle;r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm4.5-3c0 2.5-2 4.5-4.5 4.5S7.5 13.5 7.5 11H6c0 3.07 2.13 5.64 5 6.32V21h2v-3.68c2.87-.68 5-3.25 5-6.32h-1.5z"/></svg>';
15
+ F.appendChild(r);if("webkitSpeechRecognition"in window||"SpeechRecognition"in window)U=window.SpeechRecognition||window.webkitSpeechRecognition,w=new U,w.continuous=!0,w.interimResults=!0,r.addEventListener("click",function(){w.lang=E.lang?E.lang:"en-US";r.classList.contains("pai-recording")?w.stop():w.start();r.classList.toggle("pai-recording")}),w.onresult=function(e){if(r.classList.contains("pai-recording")){for(var g=[],p=0;p<e.results.length;p++)g.push(e.results[p][0].transcript);f.value=g.join("");
16
+ J();f.scrollTop=f.scrollHeight;f.focus();B()}},w.onend=function(){r.classList.remove("pai-recording");f.select();B()},w.onerror=function(e){b.add({message:"Speech recognition error: "+e.error,type:"error"})};t=document.createElement("div");t.classList.add("pai-send-button");t.title=a.sendTitle;t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>';
17
+ t.addEventListener("click",function(){b.isLoading()&&b.abortController?b.abortController.abort():b.send()});F.appendChild(t);b.dom.appendChild(F);D=document.createElement("div");D.classList.add("pai-loader");M=document.createElement("span");M.classList.add("pai-loader-message");D.appendChild(M);for(var c=1;3>=c;c++){var d=document.createElement("div");d.classList.add("pai-loader-dot");D.appendChild(d)}b.clear();a.theme&&b.setTheme(a.theme);a.brandColor&&b.setBrandColor(a.brandColor);B()};this.setElementInlineProps=
18
+ function(a){a?f&&(f.style.padding="0",f.style.lineHeight="0px",f.style.fontSize="0px",f.style.minHeight="0",f.style.height="0px",f.style.boxSizing="content-box",f.style.border="none"):f&&(f.style.removeProperty("padding"),f.style.removeProperty("line-height"),f.style.removeProperty("min-height"),f.style.removeProperty("box-sizing"),f.style.removeProperty("border"),f.style.removeProperty("font-size"))};this.show=function(){b.dom.classList.remove("pai-hidden");h()||b.setElementInlineProps();setTimeout(function(){f.focus()},
19
+ 1E3)};this.hide=function(){b.dom.classList.add("pai-hidden")};this.add=function(a){var c=a.message,d=document.createElement("div");d.classList.add("pai-message");var e=a.type;e||="user-message";d.classList.add("pai-"+e);"agent-response"===e?(d.classList.add("markdown-body"),G&&(c=c.replace(/<img src="\/profound-ai\/image\?file=/g,'<img src="'+G+"/profound-ai/image?file="),c=c.replace(/="\/profound-ai\/file\?file=/g,'="'+G+"/profound-ai/file?file=")),d.innerHTML=c,d.querySelectorAll("a").forEach(function(g){g.addEventListener("click",
20
+ function(){pui.skipConfirm=!0;setTimeout(function(){pui.skipConfirm=!1},250)})}),d.querySelectorAll("span.pai-citation").forEach(function(g){function p(){l&&!l.matches(":hover")&&(g.removeChild(l),l=null)}var l,k;g.addEventListener("mouseenter",function(){if(!l&&g.getAttribute("data-citation")){l=document.createElement("div");l.classList.add("pai-tooltip-content");l.innerHTML=g.getAttribute("data-citation");g.appendChild(l);var x=g.getBoundingClientRect();l.style.left=x.left+"px";l.style.top=x.top-
21
+ l.offsetHeight-5+"px";l.addEventListener("mouseenter",function(){clearTimeout(k)});l.addEventListener("mouseleave",function(){p()})}});g.addEventListener("mouseleave",function(){k=setTimeout(p,100)})}),a.replace&&(a=m.lastChild)&&a.classList.contains("pai-agent-response")&&a.parentNode.removeChild(a)):d.innerText=c;m.appendChild(d);m.scrollTop=m.scrollHeight};this.clear=function(){r.classList.contains("pai-recording")&&w.stop();f.value="";m.innerHTML="";b.greeting&&b.add({message:b.greeting,type:"greeting"});
22
+ b.setHeading(b.heading);b.setBrandColor(u);B();H=A=null};this.setTheme=function(a){K=a;K="string"!==typeof K?"light":K.toLowerCase();"dark"===K?b.dom.classList.add("pai-dark"):b.dom.classList.remove("pai-dark")};this.setBrandColor=function(a){u=a;if(a=b.dom.querySelector(".pai-heading"))a.style.backgroundColor=null,a.style.backgroundImage=null,a.classList.remove("pai-branded");z&&z.classList.remove("pai-branded");t.style.backgroundColor=null;if(u){if("string"!==typeof u||7!==u.length||"#"!==u.substring(0,
23
+ 1))var c=u;else{var d=parseInt(u.substring(1,3),16),e=parseInt(u.substring(3,5),16);c=parseInt(u.substring(5,7),16);d=parseInt(70*d/100);e=parseInt(70*e/100);c=parseInt(70*c/100);d=255>d?d:255;e=255>e?e:255;c=255>c?c:255;d=1==d.toString(16).length?"0"+d.toString(16):d.toString(16);e=1==e.toString(16).length?"0"+e.toString(16):e.toString(16);c=1==c.toString(16).length?"0"+c.toString(16):c.toString(16);c="#"+d+e+c}a&&(a.style.backgroundColor=u,a.style.backgroundImage="linear-gradient(to right, "+u+
24
+ ", "+c+")",a.classList.add("pai-branded"));z&&a&&z.classList.add("pai-branded");t.style.backgroundColor=u}};this.setHeading=function(a){var c=b.dom.querySelector(".pai-heading");a?(h()||b.setElementInlineProps(!0),null===c&&(c=document.createElement("div"),c.classList.add("pai-heading"),b.dom.prepend(c),J()),c.innerText=a):null!==c&&(c.remove(),J())};this.send=function(){if(""!==f.value&&!b.isLoading()){r.classList.contains("pai-recording")&&(w.stop(),r.classList.toggle("pai-recording"));if(b.onSend)b.onSend(f.value);
25
+ b.add({message:f.value});L=[];var a={};a.message=f.value;A&&(a.threadId=A);var c="/profound-ai/chat";h()?(a.agentData=v(),a.agentFile=Ext.i("centerPanel").l().title.replace(/\*/g,"").trim(),C=pui.streamingModelList.includes(a.agentData.aiAgent.model),c="/ide/profound-ai/chat"):a.agent=b.agent;var d=b.data;"function"===typeof d&&(d=d());b.data&&(a.data=d);f.value="";J();f.focus();b.abortController=new AbortController;t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M6 6h12v12H6z"/></svg>';
26
+ t.title="Stop";b.showLoader();d={"Content-Type":"application/json"};C&&(d.Connection="keep-alive",d["Response-Type"]="stream");if(pui.appJob&&pui.appJob.authToken)d.Authorization="Bearer "+pui.appJob.authToken;else if(O){var e=O;"function"===typeof e&&(e=e());d.Authorization="Bearer "+e}fetch(G+c,{method:"POST",headers:d,body:JSON.stringify(a),signal:b.abortController.signal}).then(function(g){return C?g.body.getReader():g.json()}).then(function(g){C?I(g):R(g)})["catch"](function(g){"AbortError"===
27
+ g.name?n():(b.hideLoader(),b.add({message:"Error: "+g.message,type:"error"}))})}};this.poll=function(){if(A&&H&&N){var a={};a.threadId=A;a.runId=H;a.modelKey=N;var c="/profound-ai/poll";h()&&(c="/ide/profound-ai/poll");fetch(G+c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:b.abortController.signal}).then(function(d){return d.json()}).then(function(d){R(d)})["catch"](function(d){"AbortError"===d.name?n():(b.hideLoader(),b.add({message:"Error: "+d.message,
28
+ type:"error"}))})}};this.showLoader=function(a){a||=b.config.loaderMessage||T;M.innerText=a;b.isLoading()||(C?b.add({message:V?a:'<span class="pai-loader-dot pai-inline-loader"></span>',type:"agent-response"}):m.appendChild(D),B(),m.scrollTop=m.scrollHeight)};this.hideLoader=function(){if(b.isLoading()){if(C)for(var a=m.querySelectorAll(".pai-inline-loader"),c=a.length-1;0<=c;c--)a[c].parentNode.removeChild(a[c]);else m.removeChild(D);B()}};this.isLoading=function(){return C?0<m.querySelectorAll(".pai-inline-loader").length:
29
+ D.parentNode===m};this.destroy=function(){b.dom&&(b.dom.parentNode.removeChild(b.dom),b.dom=null)};this.removeEmbedIcon=function(){profound.ai.removeEmbedIcon()}};profound.ai.j=function(h){if(!document.querySelector('link[href="'+h+'"]')){var n=document.createElement("link");n.rel="stylesheet";n.href=h;document.head.appendChild(n)}};
30
+ profound.ai.h=function(h,n){if(document.querySelector('script[src="'+h+'"]'))"function"===typeof n&&n();else{var v=document.createElement("script");v.type="text/javascript";v.src=h;v.onload=function(){"function"===typeof n&&n()};document.head.appendChild(v)}};
31
+ profound.ai.startAgent=function(h,n){h||={};var v="";h.server&&(v=h.server);if(!n&&h.agent)profound.ai.j(v+"/profoundui/proddata/css/markdown.css"),profound.ai.j(v+"/profoundui/proddata/css/profoundai.css"),fetch(v+"/profound-ai/attributes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:h.agent})}).then(function(q){return q.json()}).then(function(q){if("error"===q.status)throw Error(q.message);q=q.attributes;for(var I in q)void 0===h[I]&&(h[I]=q[I]);profound.ai.startAgent(h,
32
+ !0)})["catch"](function(q){throw Error("Unable to start AI Agent: "+q.message);});else if(h.container||(h.container=document.body),h.stream&&profound.ai.h(v+"/marked/marked.min.js"),profound.ai.agent&&profound.ai.agent.destroy(),h.embed)profound.ai.embedIcon||(profound.ai.embedIcon=document.createElement("div"),profound.ai.embedIcon.classList.add("pai-embed-icon"),profound.ai.embedIcon.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"/></svg>',
33
+ h.container.appendChild(profound.ai.embedIcon)),profound.ai.embedIcon.title=h.embedIconTitle||"Ask AI Agent",n=profound.ai.embedIcon.cloneNode(!0),n.addEventListener("click",function(){var q=Object.assign({},h);delete q.embed;profound.ai.startAgent(q)}),profound.ai.embedIcon.parentNode.replaceChild(n,profound.ai.embedIcon),profound.ai.embedIcon=n;else return profound.ai.agent=new profound.ai.Chat,profound.ai.agent.init(h),profound.ai.agent.show(),profound.ai.agent};
34
+ profound.ai.removeEmbedIcon=function(){profound.ai.embedIcon&&(profound.ai.embedIcon.parentNode.removeChild(profound.ai.embedIcon),profound.ai.embedIcon=null)};