Current Path : /storage/v11800/affypharma/public_html/wp-content/plugins/ai-engine/app/

Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64

Upload File :
Current File : /storage/v11800/affypharma/public_html/wp-content/plugins/ai-engine/app/chatbot.js
/*! For license information please see chatbot.js.LICENSE.txt */
(()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=React;var r=t.n(e);function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=function(t){var e=[];return function(r,o){if("object"===n(o)&&null!==o){if(-1!==e.indexOf(o)){if(!t)throw console.warn("Circular reference found.",{key:r,value:o,cache:e,cacheIndex:e.indexOf(o)}),new Error("Circular reference found. Cancelled.");return}e.push(o)}return o}};function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return JSON.stringify(t,o(r),e)}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}r().Component;var c=["active","disabled","style"],s=["if","className","disableTransition","children"];function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function f(){return f=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},f.apply(this,arguments)}function p(t,e,r){return e=function(t){var e=function(t,e){if("object"!=a(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==a(e)?e:String(e)}(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function h(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var d=wp.element,m=d.useState,y=d.useMemo,v=d.useEffect,g=d.useRef,b=function(t){var e=t.active,r=t.disabled,n=(t.style,h(t,c));return p(p(p(p(p({display:"inline-block",width:"16px"},"display","flex"),"alignItems","center"),"justifyContent","center"),"animation",e?"pulse 2s infinite":""),"WebkitAnimation",e?"pulse 2s infinite":""),React.createElement("div",f({active:e?"true":"false",disabled:r},n),React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",dangerouslySetInnerHTML:{__html:'<path d="M192 0C139 0 96 43 96 96V256c0 53 43 96 96 96s96-43 96-96V96c0-53-43-96-96-96zM64 216c0-13.3-10.7-24-24-24s-24 10.7-24 24v40c0 89.1 66.2 162.7 152 174.4V464H120c-13.3 0-24 10.7-24 24s10.7 24 24 24h72 72c13.3 0 24-10.7 24-24s-10.7-24-24-24H216V430.4c85.8-11.7 152-85.3 152-174.4V216c0-13.3-10.7-24-24-24s-24 10.7-24 24v40c0 70.7-57.3 128-128 128s-128-57.3-128-128V216z"/>'}}))},w=function(){return{modCss:y((function(){return function(t,e){return Array.isArray(t)||(t=[t]),e&&Object.entries(e).forEach((function(e){var r=u(e,2),n=r[0];r[1]&&t.push(n)})),t.join(" ")}}),[])}};function x(t){return 0===t.indexOf("http")}var E=function(t){var e=t.if,r=t.className,n=t.disableTransition,o=void 0!==n&&n,i=t.children,a=h(t,s),c=u(m(!1),2),l=c[0],p=c[1],d=u(m("mwai-transition"),2),y=d[0],g=d[1];return v((function(){o?p(e):e?(p(!0),setTimeout((function(){g("mwai-transition mwai-transition-visible")}),150)):g("mwai-transition")}),[e,o]),l?React.createElement("div",f({className:"".concat(r," ").concat(o?"":y),onTransitionEnd:function(){"mwai-transition"!==y||o||p(!1)}},a),i):null};function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function S(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,k(n.key),n)}}function k(t){var e=function(t,e){if("object"!=O(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=O(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==O(e)?e:String(e)}var j=function(){function t(){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),t.instance)return t.instance;this.chatbots=[],this.filters={},this.actions={},t.instance=this,"undefined"!=typeof window&&(window.MwaiAPI=t.instance)}var e,r;return e=t,r=[{key:"getChatbot",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t?this.chatbots.find((function(e){return e.botId===t||e.customId===t})):this.chatbots[0]}},{key:"addFilter",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;this.filters[t]||(this.filters[t]=[]),this.filters[t].push({callback:e,priority:r}),this.filters[t].sort((function(t,e){return t.priority-e.priority}))}},{key:"applyFilters",value:function(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];return this.filters[t]?this.filters[t].reduce((function(t,e){return e.callback.apply(e,[t].concat(n))}),e):e}},{key:"addAction",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;this.actions[t]||(this.actions[t]=[]),this.actions[t].push({callback:e,priority:r}),this.actions[t].sort((function(t,e){return t.priority-e.priority}))}},{key:"doAction",value:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];this.actions[t]&&this.actions[t].forEach((function(t){t.callback.apply(t,r)}))}}],r&&S(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(),C=new j,P=function(t,e,r){return C.applyFilters(t,e,r)};function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function I(){I=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),c=new R(n||[]);return o(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function b(){}var w={};u(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=v.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var s=f(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==L(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function j(e,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(L(e)+" is not iterable")}return g.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},S(k.prototype),u(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),u(O,s,"Generator"),u(O,a,(function(){return this})),u(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function T(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return R(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function N(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){N(i,n,o,a,c,"next",t)}function c(t){N(i,n,o,a,c,"throw",t)}a(void 0)}))}}var F=wp.element,M=(F.useMemo,F.useEffect),_=F.useState;function D(t,e){return B.apply(this,arguments)}function B(){return B=A(I().mark((function t(e,r){var n,o,i,a,c,s,u,l,f,p,h,d,m,y,v=arguments;return I().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=v.length>2&&void 0!==v[2]?v[2]:null,r){t.next=14;break}return t.prev=2,t.next=5,e.json();case 5:return o=t.sent,n&&console.log("[".concat(n,"] IN: "),o),t.abrupt("return",o);case 10:return t.prev=10,t.t0=t.catch(2),console.error("Could not parse the regular response.",{err:t.t0,data}),t.abrupt("return",{success:!1,message:"Could not parse the regular response."});case 14:i=e.body.getReader(),a=new TextDecoder("utf-8"),c="",s="";case 18:return t.next=21,i.read();case 21:if(u=t.sent,l=u.value,f=u.done,c+=a.decode(l,{stream:!0}),!f){t.next=27;break}return t.abrupt("break",68);case 27:p=c.split("\n"),h=0;case 29:if(!(h<p.length-1)){t.next=65;break}if(0===p[h].indexOf("data: ")){t.next=32;break}return t.abrupt("continue",62);case 32:if("live"!==(d=JSON.parse(p[h].replace("data: ",""))).type){t.next=39;break}n&&console.log("[".concat(n," STREAM] LIVE: "),d),s+=d.data,r&&r(s,d.data),t.next=62;break;case 39:if("error"!==d.type){t.next=51;break}return t.prev=40,n&&console.error("[".concat(n," STREAM] ERROR: "),d.data),t.abrupt("return",{success:!1,message:d.data});case 45:return t.prev=45,t.t1=t.catch(40),console.error("Could not parse the 'error' stream.",{err:t.t1,data:d}),t.abrupt("return",{success:!1,message:"Could not parse the 'error' stream."});case 49:t.next=62;break;case 51:if("end"!==d.type){t.next=62;break}return t.prev=52,m=JSON.parse(d.data),n&&console.log("[".concat(n," STREAM] END: "),m),t.abrupt("return",m);case 58:return t.prev=58,t.t2=t.catch(52),console.error("Could not parse the 'end' stream.",{err:t.t2,data:d}),t.abrupt("return",{success:!1,message:"Could not parse the 'end' stream."});case 62:h++,t.next=29;break;case 65:c=p[p.length-1],t.next=18;break;case 68:return t.prev=68,y=JSON.parse(c),n&&console.log("[".concat(n," STREAM] IN: "),y),t.abrupt("return",y);case 74:return t.prev=74,t.t3=t.catch(68),console.error("Could not parse the buffer.",{err:t.t3,buffer:c}),t.abrupt("return",{success:!1,message:"Could not parse the buffer."});case 78:case"end":return t.stop()}}),t,null,[[2,10],[40,45],[52,58],[68,74]])}))),B.apply(this,arguments)}function U(t,e,r,n){return H.apply(this,arguments)}function H(){return(H=A(I().mark((function t(e,r,n,o){var a;return I().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={"Content-Type":"application/json"},n&&(a["X-WP-Nonce"]=n),o&&(a.Accept="text/event-stream"),t.next=5,fetch("".concat(e),{method:"POST",headers:a,body:i(r)});case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function G(t,e,r,n){return z.apply(this,arguments)}function z(){return z=A(I().mark((function t(e,r,n,o){var i,a=arguments;return I().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.length>4&&void 0!==a[4]?a[4]:{},t.abrupt("return",new Promise((function(t,a){var c=new FormData;c.append("file",r);for(var s=0,u=Object.entries(i);s<u.length;s++){var l=T(u[s],2),f=l[0],p=l[1];c.append(f,p)}var h=new XMLHttpRequest;h.open("POST",e,!0),n&&h.setRequestHeader("X-WP-Nonce",n),h.upload.onprogress=function(t){if(t.lengthComputable&&o){var e=t.loaded/t.total*100;o(e)}},h.onload=function(){if(h.status>=200&&h.status<300)try{var e=JSON.parse(h.responseText);t(e)}catch(t){a({status:h.status,statusText:h.statusText,error:"The server response is not valid JSON"})}else{try{var r=JSON.parse(h.responseText);return void a({status:h.status,message:r.message})}catch(t){}a({status:h.status,statusText:h.statusText})}},h.onerror=function(){a({status:h.status,statusText:h.statusText})},h.send(c)})));case 2:case"end":return t.stop()}}),t)}))),z.apply(this,arguments)}function $(){return Math.random().toString(36).substring(2)}var W=function(){var t=T(_(!0),2),e=t[0],r=t[1];M((function(){var t=setTimeout((function(){var t=setInterval((function(){r((function(t){return!t}))}),500);return function(){return clearInterval(t)}}),200);return function(){return clearTimeout(t)}}),[]);var n={opacity:e?1:0,width:"1px",height:"1em",borderLeft:"8px solid",marginLeft:"2px"};return React.createElement("span",{style:n})};function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}var V=["children"];function Q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function J(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Q(Object(r),!0).forEach((function(e){var n,o,i;n=t,o=e,i=r[e],o=function(t){var e=function(t,e){if("object"!=q(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==q(e)?e:String(e)}(o),o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Y(t){return function(t){if(Array.isArray(t))return rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||et(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(){X=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function b(){}var w={};u(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=v.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var s=f(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==q(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function j(e,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(q(e)+" is not iterable")}return g.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},S(k.prototype),u(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),u(O,s,"Generator"),u(O,a,(function(){return this})),u(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function Z(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function K(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Z(i,n,o,a,c,"next",t)}function c(t){Z(i,n,o,a,c,"throw",t)}a(void 0)}))}}function tt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||et(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function et(t,e){if(t){if("string"==typeof t)return rt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rt(t,e):void 0}}function rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var nt=wp.element,ot=nt.useContext,it=nt.createContext,at=nt.useState,ct=nt.useMemo,st=nt.useEffect,ut=nt.useCallback,lt="AI: ",ft=it(),pt=function(){var t=ot(ft);if(!t)throw new Error("useChatbotContext must be used within a ChatbotContextProvider");return t},ht=function(t){var e,r,n,o,a,c=t.children,s=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,V),l=s.params,f=s.system,p=s.theme,h=s.atts,d=w().modCss,m=(null==p?void 0:p.settings)||{},y=tt(at(f.restNonce),2),v=y[0],g=y[1],b=tt(at([]),2),E=b[0],O=b[1],S=tt(at($()),2),k=S[0],j=S[1],C=tt(at(""),2),L=C[0],I=C[1],T=tt(at({localFile:null,uploadedId:null,uploadedUrl:null,uploadProgress:null}),2),R=T[0],N=T[1],A=tt(at(null),2),F=A[0],M=A[1],_=tt(at(!1),2),B=_[0],H=_[1],z=tt(at(),2),W=z[0],q=z[1],Q=f.stream||!1,Z=f.botId,et=f.customId,rt=f.userData,nt=f.sessionId,ot=f.contextId,it=f.pluginUrl,pt=f.restUrl,ht=f.debugMode,dt=null!==(e=null==f?void 0:f.typewriter)&&void 0!==e&&e,mt=null!==(r=null==f?void 0:f.speech_recognition)&&void 0!==r&&r,yt=null!==(n=null==f?void 0:f.speech_synthesis)&&void 0!==n&&n,vt=null!==(o=null===(a=l.startSentence)||void 0===a?void 0:a.trim())&&void 0!==o?o:"",gt=function(t){var e,r,n,o,i,a,c,s,u,l,f,p,h,d,m,y,v,g,b,w,x,E,O=null!==(e=null===(r=t.guestName)||void 0===r?void 0:r.trim())&&void 0!==e?e:"",S=null!==(n=null===(o=t.textSend)||void 0===o?void 0:o.trim())&&void 0!==n?n:"",k=null!==(i=null===(a=t.textClear)||void 0===a?void 0:a.trim())&&void 0!==i?i:"",j=parseInt(t.textInputMaxLength),C=null!==(c=null===(s=t.textInputPlaceholder)||void 0===s?void 0:s.trim())&&void 0!==c?c:"",P=null!==(u=null===(l=t.textCompliance)||void 0===l?void 0:l.trim())&&void 0!==u?u:"",L=Boolean(t.window),I=Boolean(t.copyButton),T=Boolean(t.fullscreen),R=null!==(f=null===(p=t.icon)||void 0===p?void 0:p.trim())&&void 0!==f?f:"",N=null!==(h=null===(d=t.iconText)||void 0===d?void 0:d.trim())&&void 0!==h?h:"",A=parseInt(t.iconTextDelay||1),F=null!==(m=null===(y=t.iconAlt)||void 0===y?void 0:y.trim())&&void 0!==m?m:"",M=null!==(v=null===(g=t.iconPosition)||void 0===g?void 0:g.trim())&&void 0!==v?v:"",_=Boolean(t.iconBubble),D=null!==(b=null===(w=t.aiName)||void 0===w?void 0:w.trim())&&void 0!==b?b:"",B=null!==(x=null===(E=t.userName)||void 0===E?void 0:E.trim())&&void 0!==x?x:"";return{textSend:S,textClear:k,textInputMaxLength:j,textInputPlaceholder:C,textCompliance:P,window:L,copyButton:I,fullscreen:T,localMemory:Boolean(t.localMemory),imageUpload:Boolean(t.imageUpload),fileSearch:Boolean(t.fileSearch),icon:R,iconText:N,iconTextDelay:A,iconAlt:F,iconPosition:M,iconBubble:_,aiName:D,userName:B,guestName:O}}(l),bt=gt.aiName,wt=gt.userName,xt=gt.textSend,Et=gt.textClear,Ot=gt.textInputMaxLength,St=gt.textInputPlaceholder,kt=gt.textCompliance,jt=gt.guestName,Ct=gt.window,Pt=gt.copyButton,Lt=gt.fullscreen,It=gt.localMemory,Tt=gt.icon,Rt=gt.iconText,Nt=gt.iconTextDelay,At=gt.iconAlt,Ft=gt.iconPosition,Mt=gt.iconBubble,_t=gt.imageUpload,Dt=gt.fileSearch,Bt=It&&(!!et||!!Z),Ut=Bt?"mwai-chat-".concat(et||Z):null,Ht=ct((function(){var t=Tt?x(Tt)?Tt:it+"/images/"+Tt:it+"/images/chat-green.svg";return{cssVariables:Object.keys(m).reduce((function(t,e){return t["--mwai-".concat(e)]=m[e],t}),{}),iconUrl:t}}),[Tt,it,m]),Gt=Ht.cssVariables,zt=Ht.iconUrl;bt=function(t,e,r,n){if(t)t=x(t)?React.createElement("div",{className:n("mwai-avatar")},React.createElement("img",{width:"32",height:"32",src:t})):React.createElement("div",{className:n("mwai-name-text")},t);else{var o=r||"".concat(e,"/images/chat-openai.svg");t=React.createElement("div",{className:n(["mwai-avatar"])},React.createElement("img",{width:"32",height:"32",src:"".concat(o)}))}return t}(bt,it,zt,d),wt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Guest: ",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;return t?x(t)?t=React.createElement("div",{className:o(["mwai-avatar"])},React.createElement("img",{width:"32",height:"32",src:t})):(t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Guest: ",r=arguments.length>2?arguments[2]:void 0;if(!r||0===Object.keys(r).length)return e;for(var n=0,o=Object.entries(r);n<o.length;n++){var i=u(o[n],2),a=i[0],c=i[1],s="{".concat(a,"}");t.includes(s)&&(t=t.replace(s,c))}return t||e||"Guest: "}(t,e,r),t=React.createElement("div",{className:o(["mwai-name-text"])},t)):t=r?React.createElement("div",{className:o(["mwai-avatar"])},React.createElement("img",{width:"32",height:"32",src:r.AVATAR_URL})):React.createElement("div",{className:o(["mwai-avatar","mwai-svg"])},React.createElement("img",{width:"32",height:"32",src:"".concat(n,"/images/avatar-user.svg")})),t}(wt,jt,rt,it,d);var $t=function(){var t=K(X().mark((function t(){var e,r;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,U("".concat(pt,"/mwai/v1/start_session"));case 2:return e=t.sent,t.next=5,e.json();case 5:r=t.sent,g(r.restNonce);case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();st((function(){v||$t()}),[v]),st((function(){Vt()}),[vt]);var Wt=function(t){Ut&&localStorage.setItem(Ut,i({chatId:k,messages:t}))},qt=function(){N({localFile:null,uploadedId:null,uploadedUrl:null,uploadProgress:null})},Vt=function(){if(qt(),vt){var t=[{id:$(),role:"assistant",content:vt,who:lt,timestamp:(new Date).getTime()}];O(t)}else O([])},Qt=ut((function(){var t=[];if(Ut&&(t=localStorage.getItem(Ut)))return t=JSON.parse(t),O(t.messages),void j(t.chatId);Vt()}),[Z]);st((function(){Qt()}),[Z]),st((function(){if(W){H(!1);var t=Y(E),e=t.length>0?t[t.length-1]:null;if(!W.success)return"assistant"===e.role&&e.isQuerying&&t.pop(),t.pop(),t.push({id:$(),role:"system",content:W.message,who:lt,timestamp:(new Date).getTime()}),O(t),void Wt(t);if("assistant"===e.role&&e.isQuerying)e.content=P("ai.reply",W.reply),W.images&&(e.images=W.images),e.timestamp=(new Date).getTime(),delete e.isQuerying;else if("assistant"===e.role&&e.isStreaming)e.content=P("ai.reply",W.reply),W.images&&(e.images=W.images),e.timestamp=(new Date).getTime(),delete e.isStreaming;else{var r={id:$(),role:"assistant",content:P("ai.reply",W.reply),who:lt,timestamp:(new Date).getTime()};W.images&&(r.images=W.images),t.push(r)}O(t),Wt(t)}}),[W]);var Jt=ut(K(X().mark((function t(){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,j($());case 2:Ut&&localStorage.removeItem(Ut),Vt(),I("");case 5:case"end":return t.stop()}}),t)}))),[Z]),Yt=function(){var t=K(X().mark((function t(e){var r,n,o,i,a,c,s,u,l,f,p,d,m,y;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!B){t.next=3;break}return console.error("AI Engine: There is already a query in progress."),t.abrupt("return");case 3:return"string"!=typeof e&&(e=L),n=R,o=null==R?void 0:R.uploadedUrl,i=null==R||null===(r=R.localFile)||void 0===r?void 0:r.type,a=!!i&&i.startsWith("image"),c=e,o&&(c=a?"![Uploaded Image](".concat(o,")\n").concat(e):"[Uploaded File](".concat(o,")\n").concat(e)),H(!0),I(""),qt(),s=[].concat(Y(E),[{id:$(),role:"user",content:c,who:"User: ",timestamp:(new Date).getTime()}]),Wt(s),u=$(),l=[].concat(Y(s),[{id:u,role:"assistant",content:null,who:lt,timestamp:null,isQuerying:!Q,isStreaming:!!Q}]),O(l),f=J({botId:Z,customId:et,session:nt,chatId:k,contextId:ot,messages:E,newMessage:e,newFileId:null==n?void 0:n.uploadedId,stream:Q},h),t.prev=19,ht&&console.log("[CHATBOT] OUT: ",f),p=Q?function(t){O((function(e){var r=Y(e),n=r.length>0?r[r.length-1]:null;return n&&n.id===u&&(n.content=t,n.timestamp=(new Date).getTime()),r}))}:null,t.next=24,U("".concat(pt,"/mwai-ui/v1/chats/submit"),f,v,Q);case 24:return d=t.sent,t.next=27,D(d,p,ht?"CHATBOT":null);case 27:if((m=t.sent).success||!m.message){t.next=37;break}return M(m.message),(y=Y(l)).pop(),y.pop(),O(y),Wt(y),H(!1),t.abrupt("return");case 37:q(m),t.next=44;break;case 40:t.prev=40,t.t0=t.catch(19),console.error("An error happened in the handling of the chatbot response.",{err:t.t0}),H(!1);case 44:case"end":return t.stop()}}),t,null,[[19,40]])})));return function(e){return t.apply(this,arguments)}}(),Xt=function(){var t=K(X().mark((function t(e){var r,n,o,i,a,c=arguments;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:"N/A",n=c.length>2&&void 0!==c[2]?c[2]:"N/A",t.prev=2,null!==e){t.next=6;break}return qt(),t.abrupt("return");case 6:return o={type:r,purpose:n},i="".concat(pt,"/mwai-ui/v1/files/upload"),t.next=10,G(i,e,v,(function(t){N({localFile:e,uploadedId:null,uploadedUrl:null,uploadProgress:t})}),o);case 10:a=t.sent,N({localFile:e,uploadedId:a.data.id,uploadedUrl:a.data.url,uploadProgress:null}),t.next=19;break;case 14:t.prev=14,t.t0=t.catch(2),console.error("onFileUpload Error",t.t0),M(t.t0.message||"An unknown error occurred"),qt();case 19:case"end":return t.stop()}}),t,null,[[2,14]])})));return function(e){return t.apply(this,arguments)}}(),Zt={setInputText:I,saveMessages:Wt,initChatbot:Qt,setMessages:O,setClientId:j,resetMessages:Vt,resetError:function(){M(null)},onClear:Jt,onSubmit:Yt,onFileUpload:Xt},Kt={botId:Z,chatId:k,customId:et,userData:rt,pluginUrl:it,inputText:L,messages:E,busy:B,error:F,setBusy:H,typewriter:dt,speechRecognition:mt,speechSynthesis:yt,modCss:d,localMemory:Bt,imageUpload:_t,uploadedFile:R,fileSearch:Dt,textSend:xt,textClear:Et,textInputMaxLength:Ot,textInputPlaceholder:St,textCompliance:kt,aiName:bt,userName:wt,guestName:jt,isWindow:Ct,copyButton:Pt,fullscreen:Lt,icon:Tt,iconText:Rt,iconTextDelay:Nt,iconAlt:At,iconPosition:Ft,iconBubble:Mt,cssVariables:Gt,iconUrl:zt};return React.createElement(ft.Provider,{value:{state:Kt,actions:Zt}},c)};function dt(){return dt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},dt.apply(this,arguments)}const mt=["children","options"];var yt,vt;!function(t){t.blockQuote="0",t.breakLine="1",t.breakThematic="2",t.codeBlock="3",t.codeFenced="4",t.codeInline="5",t.footnote="6",t.footnoteReference="7",t.gfmTask="8",t.heading="9",t.headingSetext="10",t.htmlBlock="11",t.htmlComment="12",t.htmlSelfClosing="13",t.image="14",t.link="15",t.linkAngleBraceStyleDetector="16",t.linkBareUrlDetector="17",t.linkMailtoDetector="18",t.newlineCoalescer="19",t.orderedList="20",t.paragraph="21",t.ref="22",t.refImage="23",t.refLink="24",t.table="25",t.tableSeparator="26",t.text="27",t.textBolded="28",t.textEmphasized="29",t.textEscaped="30",t.textMarked="31",t.textStrikethroughed="32",t.unorderedList="33"}(yt||(yt={})),function(t){t[t.MAX=0]="MAX",t[t.HIGH=1]="HIGH",t[t.MED=2]="MED",t[t.LOW=3]="LOW",t[t.MIN=4]="MIN"}(vt||(vt={}));const gt=["allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","cellPadding","cellSpacing","charSet","className","classId","colSpan","contentEditable","contextMenu","crossOrigin","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hrefLang","inputMode","keyParams","keyType","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","radioGroup","readOnly","rowSpan","spellCheck","srcDoc","srcLang","srcSet","tabIndex","useMap"].reduce(((t,e)=>(t[e.toLowerCase()]=e,t)),{for:"htmlFor"}),bt={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},wt=["style","script"],xt=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,Et=/mailto:/i,Ot=/\n{2,}$/,St=/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/,kt=/^ *> ?/gm,jt=/^ {2,}\n/,Ct=/^(?:( *[-*_])){3,} *(?:\n *)+\n/,Pt=/^\s*(`{3,}|~{3,}) *(\S+)?([^\n]*?)?\n([\s\S]+?)\s*\1 *(?:\n *)*\n?/,Lt=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,It=/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,Tt=/^(?:\n *)*\n/,Rt=/\r\n?/g,Nt=/^\[\^([^\]]+)](:.*)\n/,At=/^\[\^([^\]]+)]/,Ft=/\f/g,Mt=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,_t=/^\s*?\[(x|\s)\]/,Dt=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,Bt=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,Ut=/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/,Ht=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/i,Gt=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,zt=/^<!--[\s\S]*?(?:-->)/,$t=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,Wt=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,qt=/^\{.*\}$/,Vt=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,Qt=/^<([^ >]+@[^ >]+)>/,Jt=/^<([^ >]+:\/[^ >]+)>/,Yt=/-([a-z])?/gi,Xt=/^(.*\|?.*)\n *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*)\n?/,Zt=/^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/,Kt=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,te=/^\[([^\]]*)\] ?\[([^\]]*)\]/,ee=/(\[|\])/g,re=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,ne=/\t/g,oe=/^ *\| */,ie=/(^ *\||\| *$)/g,ae=/ *$/,ce=/^ *:-+: *$/,se=/^ *:-+ *$/,ue=/^ *-+: *$/,le=/^([*_])\1((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~+.*?~+|.)*?)\1\1(?!\1)/,fe=/^([*_])((?:\[.*?\][([].*?[)\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~+.*?~+|.)*?)\1(?!\1|\w)/,pe=/^==((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)==/,he=/^~~((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)~~/,de=/^\\([^0-9A-Za-z\s])/,me=/^[\s\S]+?(?=[^0-9A-Z\s\u00c0-\uffff&#;.()'"]|\d+\.|\n\n| {2,}\n|\w+:\S|$)/i,ye=/^\n+/,ve=/^([ \t]*)/,ge=/\\([^\\])/g,be=/ *\n+$/,we=/(?:^|\n)( *)$/,xe="(?:\\d+\\.)",Ee="(?:[*+-])";function Oe(t){return"( *)("+(1===t?xe:Ee)+") +"}const Se=Oe(1),ke=Oe(2);function je(t){return new RegExp("^"+(1===t?Se:ke))}const Ce=je(1),Pe=je(2);function Le(t){return new RegExp("^"+(1===t?Se:ke)+"[^\\n]*(?:\\n(?!\\1"+(1===t?xe:Ee)+" )[^\\n]*)*(\\n|$)","gm")}const Ie=Le(1),Te=Le(2);function Re(t){const e=1===t?xe:Ee;return new RegExp("^( *)("+e+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+e+" (?!"+e+" ))\\n*|\\s*\\n*$)")}const Ne=Re(1),Ae=Re(2);function Fe(t,e){const r=1===e,n=r?Ne:Ae,o=r?Ie:Te,i=r?Ce:Pe;return{match(t,e,r){const o=we.exec(r);return o&&(e.list||!e.inline&&!e.simple)?n.exec(t=o[1]+t):null},order:1,parse(t,e,n){const a=r?+t[2]:void 0,c=t[0].replace(Ot,"\n").match(o);let s=!1;return{items:c.map((function(t,r){const o=i.exec(t)[0].length,a=new RegExp("^ {1,"+o+"}","gm"),u=t.replace(a,"").replace(i,""),l=r===c.length-1,f=-1!==u.indexOf("\n\n")||l&&s;s=f;const p=n.inline,h=n.list;let d;n.list=!0,f?(n.inline=!1,d=u.replace(be,"\n\n")):(n.inline=!0,d=u.replace(be,""));const m=e(d,n);return n.inline=p,n.list=h,m})),ordered:r,start:a}},render:(e,r,n)=>t(e.ordered?"ol":"ul",{key:n.key,start:"20"===e.type?e.start:void 0},e.items.map((function(e,o){return t("li",{key:o},r(e,n))})))}}const Me=/^\[([^\]]*)]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/,_e=/^!\[([^\]]*)]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/,De=[St,Pt,Lt,Dt,Ut,Bt,zt,Xt,Ie,Ne,Te,Ae],Be=[...De,/^[^\n]+(?:  \n|\n{2,})/,Ht,Wt];function Ue(t){return t.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function He(t){return ue.test(t)?"right":ce.test(t)?"center":se.test(t)?"left":null}function Ge(t,e,r){const n=r.inTable;r.inTable=!0;const o=e(t.trim(),r);r.inTable=n;let i=[[]];return o.forEach((function(t,e){"26"===t.type?0!==e&&e!==o.length-1&&i.push([]):("27"!==t.type||null!=o[e+1]&&"26"!==o[e+1].type||(t.text=t.text.replace(ae,"")),i[i.length-1].push(t))})),i}function ze(t,e,r){r.inline=!0;const n=Ge(t[1],e,r),o=t[2].replace(ie,"").split("|").map(He),i=function(t,e,r){return t.trim().split("\n").map((function(t){return Ge(t,e,r)}))}(t[3],e,r);return r.inline=!1,{align:o,cells:i,header:n,type:"25"}}function $e(t,e){return null==t.align[e]?{}:{textAlign:t.align[e]}}function We(t){return function(e,r){return r.inline?t.exec(e):null}}function qe(t){return function(e,r){return r.inline||r.simple?t.exec(e):null}}function Ve(t){return function(e,r){return r.inline||r.simple?null:t.exec(e)}}function Qe(t){return function(e){return t.exec(e)}}function Je(t,e,r){if(e.inline||e.simple)return null;if(r&&!r.endsWith("\n"))return null;let n="";t.split("\n").every((t=>!De.some((e=>e.test(t)))&&(n+=t+"\n",t.trim())));const o=n.trimEnd();return""==o?null:[n,o]}function Ye(t){try{if(decodeURIComponent(t).replace(/[^A-Za-z0-9/:]/g,"").match(/^\s*(javascript|vbscript|data(?!:image)):/i))return}catch(t){return null}return t}function Xe(t){return t.replace(ge,"$1")}function Ze(t,e,r){const n=r.inline||!1,o=r.simple||!1;r.inline=!0,r.simple=!0;const i=t(e,r);return r.inline=n,r.simple=o,i}function Ke(t,e,r){const n=r.inline||!1,o=r.simple||!1;r.inline=!1,r.simple=!0;const i=t(e,r);return r.inline=n,r.simple=o,i}function tr(t,e,r){return r.inline=!1,t(e,r)}const er=(t,e,r)=>({children:Ze(e,t[1],r)});function rr(){return{}}function nr(){return null}function or(...t){return t.filter(Boolean).join(" ")}function ir(t,e,r){let n=t;const o=e.split(".");for(;o.length&&(n=n[o[0]],void 0!==n);)o.shift();return n||r}function ar(t,r={}){r.overrides=r.overrides||{},r.slugify=r.slugify||Ue,r.namedCodesToUnicode=r.namedCodesToUnicode?dt({},bt,r.namedCodesToUnicode):bt;const n=r.createElement||e.createElement;function o(t,e,...o){const i=ir(r.overrides,`${t}.props`,{});return n(function(t,e){const r=ir(e,t);return r?"function"==typeof r||"object"==typeof r&&"render"in r?r:ir(e,`${t}.component`,t):t}(t,r.overrides),dt({},e,i,{className:or(null==e?void 0:e.className,i.className)||void 0}),...o)}function i(t){t=t.replace(Mt,"");let n=!1;r.forceInline?n=!0:r.forceBlock||(n=!1===re.test(t));const i=f(l(n?t:`${t.trimEnd().replace(ye,"")}\n\n`,{inline:n}));for(;"string"==typeof i[i.length-1]&&!i[i.length-1].trim();)i.pop();if(null===r.wrapper)return i;const a=r.wrapper||(n?"span":"div");let c;if(i.length>1||r.forceWrapper)c=i;else{if(1===i.length)return c=i[0],"string"==typeof c?o("span",{key:"outer"},c):c;c=null}return e.createElement(a,{key:"outer"},c)}function a(t){const r=t.match(xt);return r?r.reduce((function(t,r,n){const o=r.indexOf("=");if(-1!==o){const a=function(t){return-1!==t.indexOf("-")&&null===t.match($t)&&(t=t.replace(Yt,(function(t,e){return e.toUpperCase()}))),t}(r.slice(0,o)).trim(),c=function(t){const e=t[0];return('"'===e||"'"===e)&&t.length>=2&&t[t.length-1]===e?t.slice(1,-1):t}(r.slice(o+1).trim()),s=gt[a]||a,u=t[s]=function(t,e){return"style"===t?e.split(/;\s?/).reduce((function(t,e){const r=e.slice(0,e.indexOf(":"));return t[r.replace(/(-[a-z])/g,(t=>t[1].toUpperCase()))]=e.slice(r.length+1).trim(),t}),{}):"href"===t||"src"===t?Ye(e):(e.match(qt)&&(e=e.slice(1,e.length-1)),"true"===e||"false"!==e&&e)}(a,c);"string"==typeof u&&(Ht.test(u)||Wt.test(u))&&(t[s]=e.cloneElement(i(u.trim()),{key:n}))}else"style"!==r&&(t[gt[r]||r]=!0);return t}),{}):null}const c=[],s={},u={0:{match:Ve(St),order:1,parse:(t,e,r)=>({children:e(t[0].replace(kt,""),r)}),render:(t,e,r)=>o("blockquote",{key:r.key},e(t.children,r))},1:{match:Qe(jt),order:1,parse:rr,render:(t,e,r)=>o("br",{key:r.key})},2:{match:Ve(Ct),order:1,parse:rr,render:(t,e,r)=>o("hr",{key:r.key})},3:{match:Ve(Lt),order:0,parse:t=>({lang:void 0,text:t[0].replace(/^ {4}/gm,"").replace(/\n+$/,"")}),render:(t,e,r)=>o("pre",{key:r.key},o("code",dt({},t.attrs,{className:t.lang?`lang-${t.lang}`:""}),t.text))},4:{match:Ve(Pt),order:0,parse:t=>({attrs:a(t[3]||""),lang:t[2]||void 0,text:t[4],type:"3"})},5:{match:qe(It),order:3,parse:t=>({text:t[2]}),render:(t,e,r)=>o("code",{key:r.key},t.text)},6:{match:Ve(Nt),order:0,parse:t=>(c.push({footnote:t[2],identifier:t[1]}),{}),render:nr},7:{match:We(At),order:1,parse:t=>({target:`#${r.slugify(t[1])}`,text:t[1]}),render:(t,e,r)=>o("a",{key:r.key,href:Ye(t.target)},o("sup",{key:r.key},t.text))},8:{match:We(_t),order:1,parse:t=>({completed:"x"===t[1].toLowerCase()}),render:(t,e,r)=>o("input",{checked:t.completed,key:r.key,readOnly:!0,type:"checkbox"})},9:{match:Ve(r.enforceAtxHeadings?Bt:Dt),order:1,parse:(t,e,n)=>({children:Ze(e,t[2],n),id:r.slugify(t[2]),level:t[1].length}),render:(t,e,r)=>o(`h${t.level}`,{id:t.id,key:r.key},e(t.children,r))},10:{match:Ve(Ut),order:0,parse:(t,e,r)=>({children:Ze(e,t[1],r),level:"="===t[2]?1:2,type:"9"})},11:{match:Qe(Ht),order:1,parse(t,e,r){const[,n]=t[3].match(ve),o=new RegExp(`^${n}`,"gm"),i=t[3].replace(o,""),c=(s=i,Be.some((t=>t.test(s)))?tr:Ze);var s;const u=t[1].toLowerCase(),l=-1!==wt.indexOf(u),f={attrs:a(t[2]),noInnerParse:l,tag:l?u:t[1]};return r.inAnchor=r.inAnchor||"a"===u,l?f.text=t[3]:f.children=c(e,i,r),r.inAnchor=!1,f},render:(t,e,r)=>o(t.tag,dt({key:r.key},t.attrs),t.text||e(t.children,r))},13:{match:Qe(Wt),order:1,parse:t=>({attrs:a(t[2]||""),tag:t[1]}),render:(t,e,r)=>o(t.tag,dt({},t.attrs,{key:r.key}))},12:{match:Qe(zt),order:1,parse:()=>({}),render:nr},14:{match:qe(_e),order:1,parse:t=>({alt:t[1],target:Xe(t[2]),title:t[3]}),render:(t,e,r)=>o("img",{key:r.key,alt:t.alt||void 0,title:t.title||void 0,src:Ye(t.target)})},15:{match:We(Me),order:3,parse:(t,e,r)=>({children:Ke(e,t[1],r),target:Xe(t[2]),title:t[3]}),render:(t,e,r)=>o("a",{key:r.key,href:Ye(t.target),title:t.title},e(t.children,r))},16:{match:We(Jt),order:0,parse:t=>({children:[{text:t[1],type:"27"}],target:t[1],type:"15"})},17:{match:(t,e)=>e.inAnchor?null:We(Vt)(t,e),order:0,parse:t=>({children:[{text:t[1],type:"27"}],target:t[1],title:void 0,type:"15"})},18:{match:We(Qt),order:0,parse(t){let e=t[1],r=t[1];return Et.test(r)||(r="mailto:"+r),{children:[{text:e.replace("mailto:",""),type:"27"}],target:r,type:"15"}}},20:Fe(o,1),33:Fe(o,2),19:{match:Ve(Tt),order:3,parse:rr,render:()=>"\n"},21:{match:Je,order:3,parse:er,render:(t,e,r)=>o("p",{key:r.key},e(t.children,r))},22:{match:We(Zt),order:0,parse:t=>(s[t[1]]={target:t[2],title:t[4]},{}),render:nr},23:{match:qe(Kt),order:0,parse:t=>({alt:t[1]||void 0,ref:t[2]}),render:(t,e,r)=>o("img",{key:r.key,alt:t.alt,src:Ye(s[t.ref].target),title:s[t.ref].title})},24:{match:We(te),order:0,parse:(t,e,r)=>({children:e(t[1],r),fallbackChildren:e(t[0].replace(ee,"\\$1"),r),ref:t[2]}),render:(t,e,r)=>s[t.ref]?o("a",{key:r.key,href:Ye(s[t.ref].target),title:s[t.ref].title},e(t.children,r)):o("span",{key:r.key},e(t.fallbackChildren,r))},25:{match:Ve(Xt),order:1,parse:ze,render:(t,e,r)=>o("table",{key:r.key},o("thead",null,o("tr",null,t.header.map((function(n,i){return o("th",{key:i,style:$e(t,i)},e(n,r))})))),o("tbody",null,t.cells.map((function(n,i){return o("tr",{key:i},n.map((function(n,i){return o("td",{key:i,style:$e(t,i)},e(n,r))})))}))))},26:{match:function(t,e){return e.inTable?(e.inline=!0,oe.exec(t)):null},order:1,parse:function(){return{type:"26"}},render:()=>" | "},27:{match:Qe(me),order:4,parse:t=>({text:t[0].replace(Gt,((t,e)=>r.namedCodesToUnicode[e]?r.namedCodesToUnicode[e]:t))}),render:t=>t.text},28:{match:qe(le),order:2,parse:(t,e,r)=>({children:e(t[2],r)}),render:(t,e,r)=>o("strong",{key:r.key},e(t.children,r))},29:{match:qe(fe),order:3,parse:(t,e,r)=>({children:e(t[2],r)}),render:(t,e,r)=>o("em",{key:r.key},e(t.children,r))},30:{match:qe(de),order:1,parse:t=>({text:t[1],type:"27"})},31:{match:qe(pe),order:3,parse:er,render:(t,e,r)=>o("mark",{key:r.key},e(t.children,r))},32:{match:qe(he),order:3,parse:er,render:(t,e,r)=>o("del",{key:r.key},e(t.children,r))}};!0===r.disableParsingRawHTML&&(delete u[11],delete u[13]);const l=function(t){let e=Object.keys(t);function r(n,o){let i=[],a="";for(;n;){let c=0;for(;c<e.length;){const s=e[c],u=t[s],l=u.match(n,o,a);if(l){const t=l[0];n=n.substring(t.length);const e=u.parse(l,r,o);null==e.type&&(e.type=s),i.push(e),a=t;break}c++}}return i}return e.sort((function(e,r){let n=t[e].order,o=t[r].order;return n!==o?n-o:1})),function(t,e){return r(function(t){return t.replace(Rt,"\n").replace(Ft,"").replace(ne,"    ")}(t),e)}}(u),f=(p=function(t,e){return function(r,n,o){const i=t[r.type].render;return e?e((()=>i(r,n,o)),r,n,o):i(r,n,o)}}(u,r.renderRule),function t(e,r={}){if(Array.isArray(e)){const n=r.key,o=[];let i=!1;for(let n=0;n<e.length;n++){r.key=n;const a=t(e[n],r),c="string"==typeof a;c&&i?o[o.length-1]+=a:null!==a&&o.push(a),i=c}return r.key=n,o}return p(e,t,r)});var p;const h=i(t);return c.length?o("div",null,h,o("footer",{key:"footer"},c.map((function(t){return o("div",{id:r.slugify(t.identifier),key:t.identifier},t.identifier,f(l(t.footnote,{inline:!0})))})))):h}const cr=t=>{let{children:r,options:n}=t,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)e.indexOf(r=i[n])>=0||(o[r]=t[r]);return o}(t,mt);return e.cloneElement(ar(r,n),o)};function sr(){return sr=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},sr.apply(this,arguments)}var ur={strings:["These are the default values...","You know what you should do?","Use your own!","Have a great day!"],stringsElement:null,typeSpeed:0,startDelay:0,backSpeed:0,smartBackspace:!0,shuffle:!1,backDelay:700,fadeOut:!1,fadeOutClass:"typed-fade-out",fadeOutDelay:500,loop:!1,loopCount:1/0,showCursor:!0,cursorChar:"|",autoInsertCss:!0,attr:null,bindInputFocusEvents:!1,contentType:"html",onBegin:function(t){},onComplete:function(t){},preStringTyped:function(t,e){},onStringTyped:function(t,e){},onLastStringBackspaced:function(t){},onTypingPaused:function(t,e){},onTypingResumed:function(t,e){},onReset:function(t){},onStop:function(t,e){},onStart:function(t,e){},onDestroy:function(t){}},lr=new(function(){function t(){}var e=t.prototype;return e.load=function(t,e,r){if(t.el="string"==typeof r?document.querySelector(r):r,t.options=sr({},ur,e),t.isInput="input"===t.el.tagName.toLowerCase(),t.attr=t.options.attr,t.bindInputFocusEvents=t.options.bindInputFocusEvents,t.showCursor=!t.isInput&&t.options.showCursor,t.cursorChar=t.options.cursorChar,t.cursorBlinking=!0,t.elContent=t.attr?t.el.getAttribute(t.attr):t.el.textContent,t.contentType=t.options.contentType,t.typeSpeed=t.options.typeSpeed,t.startDelay=t.options.startDelay,t.backSpeed=t.options.backSpeed,t.smartBackspace=t.options.smartBackspace,t.backDelay=t.options.backDelay,t.fadeOut=t.options.fadeOut,t.fadeOutClass=t.options.fadeOutClass,t.fadeOutDelay=t.options.fadeOutDelay,t.isPaused=!1,t.strings=t.options.strings.map((function(t){return t.trim()})),t.stringsElement="string"==typeof t.options.stringsElement?document.querySelector(t.options.stringsElement):t.options.stringsElement,t.stringsElement){t.strings=[],t.stringsElement.style.cssText="clip: rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px;";var n=Array.prototype.slice.apply(t.stringsElement.children),o=n.length;if(o)for(var i=0;i<o;i+=1)t.strings.push(n[i].innerHTML.trim())}for(var a in t.strPos=0,t.currentElContent=this.getCurrentElContent(t),t.currentElContent&&t.currentElContent.length>0&&(t.strPos=t.currentElContent.length-1,t.strings.unshift(t.currentElContent)),t.sequence=[],t.strings)t.sequence[a]=a;t.arrayPos=0,t.stopNum=0,t.loop=t.options.loop,t.loopCount=t.options.loopCount,t.curLoop=0,t.shuffle=t.options.shuffle,t.pause={status:!1,typewrite:!0,curString:"",curStrPos:0},t.typingComplete=!1,t.autoInsertCss=t.options.autoInsertCss,t.autoInsertCss&&(this.appendCursorAnimationCss(t),this.appendFadeOutAnimationCss(t))},e.getCurrentElContent=function(t){return t.attr?t.el.getAttribute(t.attr):t.isInput?t.el.value:"html"===t.contentType?t.el.innerHTML:t.el.textContent},e.appendCursorAnimationCss=function(t){var e="data-typed-js-cursor-css";if(t.showCursor&&!document.querySelector("["+e+"]")){var r=document.createElement("style");r.setAttribute(e,"true"),r.innerHTML="\n        .typed-cursor{\n          opacity: 1;\n        }\n        .typed-cursor.typed-cursor--blink{\n          animation: typedjsBlink 0.7s infinite;\n          -webkit-animation: typedjsBlink 0.7s infinite;\n                  animation: typedjsBlink 0.7s infinite;\n        }\n        @keyframes typedjsBlink{\n          50% { opacity: 0.0; }\n        }\n        @-webkit-keyframes typedjsBlink{\n          0% { opacity: 1; }\n          50% { opacity: 0.0; }\n          100% { opacity: 1; }\n        }\n      ",document.body.appendChild(r)}},e.appendFadeOutAnimationCss=function(t){var e="data-typed-fadeout-js-css";if(t.fadeOut&&!document.querySelector("["+e+"]")){var r=document.createElement("style");r.setAttribute(e,"true"),r.innerHTML="\n        .typed-fade-out{\n          opacity: 0;\n          transition: opacity .25s;\n        }\n        .typed-cursor.typed-cursor--blink.typed-fade-out{\n          -webkit-animation: 0;\n          animation: 0;\n        }\n      ",document.body.appendChild(r)}},t}()),fr=new(function(){function t(){}var e=t.prototype;return e.typeHtmlChars=function(t,e,r){if("html"!==r.contentType)return e;var n=t.substring(e).charAt(0);if("<"===n||"&"===n){var o;for(o="<"===n?">":";";t.substring(e+1).charAt(0)!==o&&!(1+ ++e>t.length););e++}return e},e.backSpaceHtmlChars=function(t,e,r){if("html"!==r.contentType)return e;var n=t.substring(e).charAt(0);if(">"===n||";"===n){var o;for(o=">"===n?"<":"&";t.substring(e-1).charAt(0)!==o&&!(--e<0););e--}return e},t}()),pr=function(){function t(t,e){lr.load(this,e,t),this.begin()}var e=t.prototype;return e.toggle=function(){this.pause.status?this.start():this.stop()},e.stop=function(){this.typingComplete||this.pause.status||(this.toggleBlinking(!0),this.pause.status=!0,this.options.onStop(this.arrayPos,this))},e.start=function(){this.typingComplete||this.pause.status&&(this.pause.status=!1,this.pause.typewrite?this.typewrite(this.pause.curString,this.pause.curStrPos):this.backspace(this.pause.curString,this.pause.curStrPos),this.options.onStart(this.arrayPos,this))},e.destroy=function(){this.reset(!1),this.options.onDestroy(this)},e.reset=function(t){void 0===t&&(t=!0),clearInterval(this.timeout),this.replaceText(""),this.cursor&&this.cursor.parentNode&&(this.cursor.parentNode.removeChild(this.cursor),this.cursor=null),this.strPos=0,this.arrayPos=0,this.curLoop=0,t&&(this.insertCursor(),this.options.onReset(this),this.begin())},e.begin=function(){var t=this;this.options.onBegin(this),this.typingComplete=!1,this.shuffleStringsIfNeeded(this),this.insertCursor(),this.bindInputFocusEvents&&this.bindFocusEvents(),this.timeout=setTimeout((function(){0===t.strPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],t.strPos):t.backspace(t.strings[t.sequence[t.arrayPos]],t.strPos)}),this.startDelay)},e.typewrite=function(t,e){var r=this;this.fadeOut&&this.el.classList.contains(this.fadeOutClass)&&(this.el.classList.remove(this.fadeOutClass),this.cursor&&this.cursor.classList.remove(this.fadeOutClass));var n=this.humanizer(this.typeSpeed),o=1;!0!==this.pause.status?this.timeout=setTimeout((function(){e=fr.typeHtmlChars(t,e,r);var n=0,i=t.substring(e);if("^"===i.charAt(0)&&/^\^\d+/.test(i)){var a=1;a+=(i=/\d+/.exec(i)[0]).length,n=parseInt(i),r.temporaryPause=!0,r.options.onTypingPaused(r.arrayPos,r),t=t.substring(0,e)+t.substring(e+a),r.toggleBlinking(!0)}if("`"===i.charAt(0)){for(;"`"!==t.substring(e+o).charAt(0)&&(o++,!(e+o>t.length)););var c=t.substring(0,e),s=t.substring(c.length+1,e+o),u=t.substring(e+o+1);t=c+s+u,o--}r.timeout=setTimeout((function(){r.toggleBlinking(!1),e>=t.length?r.doneTyping(t,e):r.keepTyping(t,e,o),r.temporaryPause&&(r.temporaryPause=!1,r.options.onTypingResumed(r.arrayPos,r))}),n)}),n):this.setPauseStatus(t,e,!0)},e.keepTyping=function(t,e,r){0===e&&(this.toggleBlinking(!1),this.options.preStringTyped(this.arrayPos,this));var n=t.substring(0,e+=r);this.replaceText(n),this.typewrite(t,e)},e.doneTyping=function(t,e){var r=this;this.options.onStringTyped(this.arrayPos,this),this.toggleBlinking(!0),this.arrayPos===this.strings.length-1&&(this.complete(),!1===this.loop||this.curLoop===this.loopCount)||(this.timeout=setTimeout((function(){r.backspace(t,e)}),this.backDelay))},e.backspace=function(t,e){var r=this;if(!0!==this.pause.status){if(this.fadeOut)return this.initFadeOut();this.toggleBlinking(!1);var n=this.humanizer(this.backSpeed);this.timeout=setTimeout((function(){e=fr.backSpaceHtmlChars(t,e,r);var n=t.substring(0,e);if(r.replaceText(n),r.smartBackspace){var o=r.strings[r.arrayPos+1];r.stopNum=o&&n===o.substring(0,e)?e:0}e>r.stopNum?(e--,r.backspace(t,e)):e<=r.stopNum&&(r.arrayPos++,r.arrayPos===r.strings.length?(r.arrayPos=0,r.options.onLastStringBackspaced(),r.shuffleStringsIfNeeded(),r.begin()):r.typewrite(r.strings[r.sequence[r.arrayPos]],e))}),n)}else this.setPauseStatus(t,e,!1)},e.complete=function(){this.options.onComplete(this),this.loop?this.curLoop++:this.typingComplete=!0},e.setPauseStatus=function(t,e,r){this.pause.typewrite=r,this.pause.curString=t,this.pause.curStrPos=e},e.toggleBlinking=function(t){this.cursor&&(this.pause.status||this.cursorBlinking!==t&&(this.cursorBlinking=t,t?this.cursor.classList.add("typed-cursor--blink"):this.cursor.classList.remove("typed-cursor--blink")))},e.humanizer=function(t){return Math.round(Math.random()*t/2)+t},e.shuffleStringsIfNeeded=function(){this.shuffle&&(this.sequence=this.sequence.sort((function(){return Math.random()-.5})))},e.initFadeOut=function(){var t=this;return this.el.className+=" "+this.fadeOutClass,this.cursor&&(this.cursor.className+=" "+this.fadeOutClass),setTimeout((function(){t.arrayPos++,t.replaceText(""),t.strings.length>t.arrayPos?t.typewrite(t.strings[t.sequence[t.arrayPos]],0):(t.typewrite(t.strings[0],0),t.arrayPos=0)}),this.fadeOutDelay)},e.replaceText=function(t){this.attr?this.el.setAttribute(this.attr,t):this.isInput?this.el.value=t:"html"===this.contentType?this.el.innerHTML=t:this.el.textContent=t},e.bindFocusEvents=function(){var t=this;this.isInput&&(this.el.addEventListener("focus",(function(e){t.stop()})),this.el.addEventListener("blur",(function(e){t.el.value&&0!==t.el.value.length||t.start()})))},e.insertCursor=function(){this.showCursor&&(this.cursor||(this.cursor=document.createElement("span"),this.cursor.className="typed-cursor",this.cursor.setAttribute("aria-hidden",!0),this.cursor.innerHTML=this.cursorChar,this.el.parentNode&&this.el.parentNode.insertBefore(this.cursor,this.el.nextSibling)))},t}();function hr(t){return hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hr(t)}function dr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function mr(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?dr(Object(r),!0).forEach((function(e){var n,o,i;n=t,o=e,i=r[e],o=function(t){var e=function(t,e){if("object"!=hr(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=hr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hr(e)?e:String(e)}(o),o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):dr(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var yr=function(t){var e={width:9,height:9,margin:"5px 0px 0px 5px",borderRadius:"50%",backgroundColor:"#a3a1a1",opacity:1,animation:"bouncing-loader 0.4s infinite alternate"};return React.createElement(React.Fragment,null,React.createElement("style",null,"\n          @keyframes bouncing-loader {\n            to {\n              opacity: 0.6;\n              transform: translateY(-10px);\n            }\n          }\n        "),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:26}},["0.1s","0.2s","0.3s"].map((function(t,r){return React.createElement("div",{key:r,style:mr(mr({},e),{},{animationDelay:t})})}))))};function vr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var gr=wp.element.useState;const br=function(t){var e=t.content,r=t.modCss,n=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return vr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(gr(!1),2),o=n[0],i=n[1];return React.createElement("div",{className:r("mwai-copy-button",{"mwai-animate":o}),onClick:function(){try{navigator.clipboard.writeText(e),i(!0),setTimeout((function(){i(!1)}),1e3)}catch(t){console.warn("Not allowed to copy to clipboard. Make sure your website uses HTTPS.",{content:e})}}},React.createElement("div",{className:r("mwai-copy-button-one")}),React.createElement("div",{className:r("mwai-copy-button-two")}))};var wr=["href","children"];function xr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Er(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Er(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Er(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Or=wp.element,Sr=Or.useState,kr=Or.useMemo,jr=Or.useEffect,Cr=Or.useRef,Pr=function(t){var e=t.href,r=t.children,n=(function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}}(t,wr),pt().state.modCss);if(!e)return React.createElement("span",null,r);var o=window.location.hostname,i="_self";try{i=o===new URL(e,window.location.href).hostname?"_self":"_blank"}catch(t){console.error("Invalid URL:",t),i="_blank"}if("Uploaded File"===String(r)){var a=e.split("/").pop();return React.createElement("a",{href:e,target:i,rel:"noopener noreferrer",className:n("mwai-filename")},React.createElement("span",null,"✓ ",a))}return React.createElement("a",{href:e,target:i,rel:"noopener noreferrer"},r)},Lr=function(t){var e,r=t.message,n=t.onRendered,o=void 0===n?function(){}:n,i=pt().state,a=i.copyButton,c=i.userName,s=i.aiName,u=i.modCss,l="user"===r.role,f="assistant"===r.role,p=l?c:f?s:null,h=xr(Sr(r.isQuerying||r.isStreaming),1)[0],d=r.isQuerying,m=r.isStreaming,y=null!==(e=r.content)&&void 0!==e?e:"";(y.match(/```/g)||[]).length%2!=0?y+="\n```":r.isStreaming&&(y+="<BlinkingCursor />"),jr((function(){h&&(!h||d||m)||o()}),[h,d,m]);var v=kr((function(){var t={overrides:{BlinkingCursor:{component:W},a:{component:Pr},img:{props:{onError:function(t,e){null!=t.target.src.match(/\.(jpeg|jpg|gif|png)$/)&&(t.target.src="https://placehold.co/600x200?text=Expired+Image")},className:u("mwai-image")}}}};return t}),[d,m,y]);return d||m&&!y?React.createElement(yr,null):React.createElement(React.Fragment,null,React.createElement("span",{className:u("mwai-name")},p),React.createElement("span",{className:u("mwai-text")},React.createElement("span",null,React.createElement(cr,{options:v},y))),a&&React.createElement(br,{content:r.content,modCss:u}))},Ir=function(t){var e=t.message,r=t.onRendered,n=void 0===r?function(){}:r,o=pt().state,i=o.userName,a=o.aiName,c=o.modCss,s="user"===e.role,u="assistant"===e.role,l=s?i:u?a:null,f=xr(Sr(null==e?void 0:e.images),2),p=f[0],h=f[1];return jr((function(){n()})),e.isQuerying?React.createElement(yr,null):React.createElement(React.Fragment,null,React.createElement("span",{className:c("mwai-name")},l),React.createElement("span",{className:c("mwai-text")},React.createElement("div",{className:c("mwai-gallery")},null==p?void 0:p.map((function(t,e){return React.createElement("a",{key:e,href:t,target:"_blank",rel:"noopener noreferrer"},React.createElement("img",{key:e,src:t,onError:function(){return function(t){h((function(e){return e.map((function(e,r){return r===t?"https://placehold.co/600x200?text=Expired+Image":e}))}))}(e)}}))})))))},Tr=function(t){var e=t.message,r=t.conversationRef,n=t.onRendered,o=void 0===n?function(){}:n,i=pt().state,a=i.copyButton,c=i.userName,s=i.aiName,u=i.modCss,l=Cr(null),f=xr(Sr(e.isQuerying),1)[0],p=xr(Sr(!e.isQuerying),2),h=p[0],d=p[1],m=xr(Sr(!1),2),y=m[0],b=m[1],w="user"===e.role?c:s,x=e.content;return function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=g();v((function(){n.current=e}),[e]),v((function(){if(null!==t&&r){var e=setInterval((function(){n.current()}),t);return function(){return clearInterval(e)}}}),[t,r])}(200,(function(){null!=r&&r.current&&(y||(r.current.scrollTop=r.current.scrollHeight))}),!h),jr((function(){if(null!=r&&r.current){var t=function(){var t=r.current,e=t.scrollTop,n=t.scrollHeight,o=t.clientHeight;b(n-(e+o)>20)};return r.current.addEventListener("scroll",t),function(){r.current&&r.current.removeEventListener("scroll",t)}}}),[r]),jr((function(){if(f){if(l.current){var t={strings:[x],typeSpeed:P("typewriter.speed",15),showCursor:!1,onComplete:function(t){t.cursor&&t.cursor.remove(),o(),d((function(){return!0}))}},e=new pr(l.current,t);return function(){e.destroy()}}}else o()}),[e,e.isQuerying]),React.createElement(React.Fragment,null,e.isQuerying&&React.createElement(yr,null),!e.isQuerying&&f&&React.createElement(React.Fragment,null,React.createElement("span",{className:u("mwai-name")},w),React.createElement("span",{className:u("mwai-text"),ref:l})),!e.isQuerying&&!f&&React.createElement(React.Fragment,null,React.createElement("span",{className:u("mwai-name")},w),React.createElement("span",{className:u("mwai-text")},React.createElement(cr,null,x))),h&&a&&React.createElement(br,{content:x,modCss:u}))};const Rr=function(t){var e,r=t.message,n=t.conversationRef,o=pt().state,i=o.typewriter,a=o.modCss,c=Cr(),s=a("mwai-reply",{"mwai-ai":"assistant"===r.role,"mwai-user":"user"===r.role,"mwai-system":"system"===r.role}),u=(null==r||null===(e=r.images)||void 0===e?void 0:e.length)>0,l=function(){c.current&&(r.isQuerying||c.current.classList.contains("mwai-rendered")||"undefined"!=typeof hljs&&(c.current.classList.add("mwai-rendered"),c.current.querySelectorAll("pre code").forEach((function(t){hljs.highlightElement(t)}))))};return kr((function(){return"user"===r.role?React.createElement("div",{ref:c,className:s},React.createElement(Lr,{message:r})):"assistant"===r.role?u?React.createElement("div",{ref:c,className:s},React.createElement(Ir,{message:r,conversationRef:n,onRendered:l})):i&&!r.isStreaming?React.createElement("div",{ref:c,className:s},React.createElement(Tr,{message:r,conversationRef:n,onRendered:l})):React.createElement("div",{ref:c,className:s},React.createElement(Lr,{message:r,conversationRef:n,onRendered:l})):"system"===r.role?React.createElement("div",{ref:c,className:s},React.createElement(Lr,{message:r,conversationRef:n,onRendered:l})):React.createElement("div",null,React.createElement("i",null,"Unhandled role."))}),[r,n,u,i])};function Nr(){return Nr=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Nr.apply(this,arguments)}const Ar=e.useLayoutEffect;var Fr=function(t,e){"function"!=typeof t?t.current=e:t(e)};var Mr={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},_r=function(t){Object.keys(Mr).forEach((function(e){t.style.setProperty(e,Mr[e],"important")}))},Dr=null,Br=function(t,e){var r=t.scrollHeight;return"border-box"===e.sizingStyle.boxSizing?r+e.borderSize:r-e.paddingSize},Ur=function(){},Hr=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],Gr=!!document.documentElement.currentStyle;function zr(t,r,n){var o,i,a=(o=n,i=e.useRef(o),Ar((function(){i.current=o})),i);e.useLayoutEffect((function(){var e=function(t){return a.current(t)};if(t)return t.addEventListener(r,e),function(){return t.removeEventListener(r,e)}}),[])}var $r=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],Wr=function(t,r){var n,o=t.cacheMeasurements,i=t.maxRows,a=t.minRows,c=t.onChange,s=void 0===c?Ur:c,u=t.onHeightChange,l=void 0===u?Ur:u,f=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,$r),p=void 0!==f.value,h=e.useRef(null),d=function(t,r){var n=(0,e.useRef)();return(0,e.useCallback)((function(e){t.current=e,n.current&&Fr(n.current,null),n.current=r,r&&Fr(r,e)}),[r])}(h,r),m=e.useRef(0),y=e.useRef(),v=function(){var t=h.current,e=o&&y.current?y.current:function(t){var e=window.getComputedStyle(t);if(null===e)return null;var r,n=(r=e,Hr.reduce((function(t,e){return t[e]=r[e],t}),{})),o=n.boxSizing;return""===o?null:(Gr&&"border-box"===o&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+"px"),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})}(t);if(e){y.current=e;var r=function(t,e,r,n){void 0===r&&(r=1),void 0===n&&(n=1/0),Dr||((Dr=document.createElement("textarea")).setAttribute("tabindex","-1"),Dr.setAttribute("aria-hidden","true"),_r(Dr)),null===Dr.parentNode&&document.body.appendChild(Dr);var o=t.paddingSize,i=t.borderSize,a=t.sizingStyle,c=a.boxSizing;Object.keys(a).forEach((function(t){var e=t;Dr.style[e]=a[e]})),_r(Dr),Dr.value=e;var s=Br(Dr,t);Dr.value=e,s=Br(Dr,t),Dr.value="x";var u=Dr.scrollHeight-o,l=u*r;"border-box"===c&&(l=l+o+i),s=Math.max(l,s);var f=u*n;return"border-box"===c&&(f=f+o+i),[s=Math.min(f,s),u]}(e,t.value||t.placeholder||"x",a,i),n=r[0],c=r[1];m.current!==n&&(m.current=n,t.style.setProperty("height",n+"px","important"),l(n,{rowHeight:c}))}};return e.useLayoutEffect(v),zr(window,"resize",v),n=v,zr(document.fonts,"loadingdone",n),e.createElement("textarea",Nr({},f,{onChange:function(t){p||v(),s(t)},ref:d}))},qr=e.forwardRef(Wr);function Vr(t){return Vr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vr(t)}var Qr=["onUploadFile","uploadedFile","draggedType","disabled","style","modCss"];function Jr(){return Jr=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Jr.apply(this,arguments)}function Yr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Xr(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Yr(Object(r),!0).forEach((function(e){var n,o,i;n=t,o=e,i=r[e],o=function(t){var e=function(t,e){if("object"!=Vr(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Vr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vr(e)?e:String(e)}(o),o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Zr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Kr=wp.element,tn=Kr.useState,en=Kr.useMemo,rn=Kr.useImperativeHandle,nn=Kr.useRef,on=React.forwardRef((function(t,e){var r=t.onUploadFile,n=t.uploadedFile,o=t.draggedType,i=t.disabled,a=t.style,c=t.modCss,s=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,Qr),u=nn(),l=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Zr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Zr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(tn(!1),2),f=l[0],p=l[1],h=null==n?void 0:n.uploadedId,d=function(t){return r(t)};rn(e,(function(){return{handleExternalFile:d}}));var m=n,y=en((function(){return null!=m&&m.localFile?m.localFile.type.startsWith("image/")?"image":"document":o}),[m,o]),v=en((function(){var t="idle";null!=m&&m.uploadProgress?t="up":o?t="add":f&&h?t="del":h?t="ok":f&&!h&&(t="add");var e=y?y.toLowerCase():"idle";return c(["mwai-file-upload-icon","mwai-".concat(e,"-").concat(t)])}),[y,m,o,f,h,c]),g=en((function(){return null!=m&&m.uploadProgress?m.uploadProgress>99?99:Math.round(m.uploadProgress):""}),[m]);return React.createElement("div",Jr({disabled:i,onClick:function(){null!=n&&n.localFile?r(null):i||u.current.click()},onMouseEnter:function(){return p(!0)},onMouseLeave:function(){return p(!1)},style:Xr({cursor:i?"default":"pointer"},a)},s),React.createElement("div",{className:v},React.createElement("span",{className:"mwai-file-upload-progress"},g)),React.createElement("input",{type:"file",ref:u,onChange:function(t){var e=t.target.files[0];e&&r(e)},style:{display:"none"}}))}));const an=on;function cn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return sn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sn(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var un=r().forwardRef((function(t,n){var o=t.onTypeText,i=t.onSubmitAction,a=t.onUploadFile,c=t.inputText,s=t.textInputMaxLength,u=t.textInputPlaceholder,l=t.busy,f=t.modCss,p=t.isListening,h=t.setIsListening,d=t.speechRecognitionAvailable,m=t.speechRecognition,y=t.fileSearch,v=t.imageUpload,g=t.uploadedFile,w=t.composing,x=t.setComposing,E=cn((0,e.useState)(!1),2),O=E[0],S=E[1],k=cn((0,e.useState)(!1),2),j=k[0],C=k[1],P=(0,e.useRef)(),L=(0,e.useRef)(),I=v||y;(0,e.useImperativeHandle)(n,(function(){return{focusInput:function(){var t;null===(t=P.current)||void 0===t||t.focus()},currentElement:function(){return P.current}}}));var T=function(t,e){t.preventDefault(),t.stopPropagation();var r=t.dataTransfer.items[0];e?v&&function(t){return t.type.startsWith("image/")}(r)?(S("image"),C(!1)):y&&function(t){return["text/x-c","text/x-csharp","text/x-c++","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","text/javascript","application/x-sh","application/typescript"].includes(t.type)}(r)?(S("document"),C(!1)):(S(!1),C(!0)):(S(!1),C(!1))};return r().createElement("div",{className:f("mwai-input-text",{"mwai-dragging":O,"mwai-blocked":j}),onDrop:function(t){if(t.preventDefault(),T(t,!1),!l){var e=t.dataTransfer.files[0];e&&("image"===O&&v||"document"===O&&y?L.current.handleExternalFile(e):(C(!0),setTimeout((function(){return C(!1)}),2e3)))}},onDragEnter:function(t){return T(t,!0)},onDragLeave:function(t){return T(t,!1)},onDragOver:function(t){return T(t,!0)}},I&&r().createElement(an,{className:f("mwai-file-upload",{"mwai-enabled":null==g?void 0:g.uploadedId,"mwai-busy":(null==g?void 0:g.localFile)&&!(null!=g&&g.uploadedId)}),modCss:f,draggedType:O,disabled:l,ref:L,uploadedFile:g,onUploadFile:a}),r().createElement(qr,{ref:P,disabled:l,placeholder:u,value:c,maxLength:s,onCompositionStart:function(){return x(!0)},onCompositionEnd:function(){return x(!1)},onKeyDown:function(t){w||"Enter"!==t.code||t.shiftKey||(t.preventDefault(),i())},onChange:function(t){return o(t.target.value)}}),m&&r().createElement(b,{active:p,disabled:!d||l,className:f("mwai-microphone"),onClick:function(){return h(!p)}}))}));const ln=un;function fn(t){return fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fn(t)}function pn(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function hn(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?pn(Object(r),!0).forEach((function(e){dn(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pn(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function dn(t,e,r){return e=function(t){var e=function(t,e){if("object"!=fn(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=fn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fn(e)?e:String(e)}(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mn(t){return function(t){if(Array.isArray(t))return xn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||wn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yn(){yn=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function b(){}var w={};u(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=v.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var s=f(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==fn(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function j(e,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(fn(e)+" is not iterable")}return g.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},S(k.prototype),u(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),u(O,s,"Generator"),u(O,a,(function(){return this})),u(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function vn(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function gn(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){vn(i,n,o,a,c,"next",t)}function c(t){vn(i,n,o,a,c,"throw",t)}a(void 0)}))}}function bn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||wn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wn(t,e){if(t){if("string"==typeof t)return xn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xn(t,e):void 0}}function xn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var En={overrides:{a:{props:{target:"_blank"}}}};const On=function(t){var n=t.theme,o=t.style,i=function(){var t=u(m(null),2),e=t[0],r=t[1],n=g(null);return v((function(){return function(){clearInterval(n.current)}}),[]),{timeElapsed:e,startChrono:function(){if(null===n.current){var t=Date.now();n.current=setInterval((function(){var e,n,o,i=Math.floor((Date.now()-t)/1e3);r((e=i,n=Math.floor(e/60),o=e%60,"".concat(n,":").concat(o.toString().padStart(2,"0"))))}),500)}},stopChrono:function(){clearInterval(n.current),n.current=null,r(null)}}}(),a=i.timeElapsed,c=i.startChrono,s=i.stopChrono,l=bn((0,e.useState)(!1),2),f=l[0],p=l[1],h=bn((0,e.useState)(!1),2),d=h[0],y=h[1],b=bn((0,e.useState)(!1),2),x=b[0],O=b[1],S=bn((0,e.useState)(!0),2),k=S[0],j=S[1],P=w().modCss,L=(0,e.useMemo)((function(){return"css"===(null==n?void 0:n.type)?null==n?void 0:n.style:null}),[n]),I=(0,e.useRef)(),T=(0,e.useRef)(),R=(0,e.useRef)(!1),N=document.innerWidth<=768,A=pt(),F=A.state,M=A.actions,_=F.chatId,D=F.botId,B=F.customId,U=F.messages,H=F.inputText,G=F.textInputMaxLength,z=F.textSend,$=F.textClear,W=F.textInputPlaceholder,q=F.textCompliance,V=F.isWindow,Q=F.fullscreen,J=F.iconText,Y=F.iconTextDelay,X=F.iconAlt,Z=F.iconPosition,K=F.iconBubble,tt=F.cssVariables,et=F.error,rt=F.iconUrl,nt=F.busy,ot=F.speechRecognition,it=F.imageUpload,at=F.uploadedFile,ct=F.fileSearch,st=M.onClear,ut=M.onSubmit,lt=M.setInputText,ft=M.setMessages,ht=M.setClientId,dt=M.onFileUpload,mt=M.resetError,yt=function(t){var e=u(m(!1),2),r=e[0],n=e[1],o=u(m(!1),2),i=o[0],a=o[1];return v((function(){"undefined"!=typeof window&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)&&a(!0)}),[]),v((function(){if(i){var t=new(window.SpeechRecognition||window.webkitSpeechRecognition);t.interimResults=!0,t.continuous=!0;var e=function(t){var e=Array.from(t.results).map((function(t){return t[0]})).map((function(t){return t.transcript})).join("");lt(e)};return r?(t.addEventListener("result",e),t.start()):(t.removeEventListener("result",e),t.abort()),function(){t.abort()}}}),[r,i]),{isListening:r,setIsListening:n,speechRecognitionAvailable:i}}(),vt=yt.isListening,gt=yt.setIsListening,bt=yt.speechRecognitionAvailable,wt=!(null==at||!at.uploadProgress),xt=!(null==at||!at.uploadedId),Et=!xt&&H.length<1&&(null==U?void 0:U.length)>1,Ot=(0,e.useCallback)((function(){var t=setTimeout((function(){y((function(t){return t||O(!0),t}))}),1e3*Y);return function(){return clearTimeout(t)}}),[J,Y]);(0,e.useEffect)((function(){if(J&&!Y)O(!0);else if(J&&Y)return Ot()}),[J]);var St=bn((0,e.useState)([]),2),kt=St[0],jt=St[1],Ct=(0,e.useCallback)(gn(yn().mark((function t(){var e,r,n,o,i,a;return yn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:kt.length>0&&("ask"===(e=kt[0]).action?(r=e.data,n=r.text,r.submit?ut(n):lt(n)):"toggle"===e.action?y((function(t){return!t})):"open"===e.action?y(!0):"close"===e.action?y(!1):"clear"===e.action?st():"setContext"===e.action&&(o=e.data,i=o.chatId,a=o.messages,ht(i),ft(a)),jt((function(t){return t.slice(1)})));case 1:case"end":return t.stop()}}),t)}))),[kt,st,ut,ht,lt,ft]);(0,e.useEffect)((function(){Ct()}),[Ct]),(0,e.useEffect)((function(){(B||D)&&C.chatbots.push({botId:D,chatId:_,customId:B,open:function(){jt((function(t){return[].concat(mn(t),[{action:"open"}])}))},close:function(){jt((function(t){return[].concat(mn(t),[{action:"close"}])}))},clear:function(){jt((function(t){return[].concat(mn(t),[{action:"clear"}])}))},toggle:function(){jt((function(t){return[].concat(mn(t),[{action:"toggle"}])}))},ask:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];jt((function(r){return[].concat(mn(r),[{action:"ask",data:{text:t,submit:e}}])}))},setContext:function(t){var e=t.chatId,r=t.messages;jt((function(t){return[].concat(mn(t),[{action:"setContext",data:{chatId:e,messages:r}}])}))}})}),[D,_,B]),(0,e.useEffect)((function(){nt?c():(!N&&R.current&&I.current.focusInput(),s())}),[nt,c,s,N]),(0,e.useEffect)((function(){!N&&d&&I.current.focusInput(),T.current&&(T.current.scrollTop=T.current.scrollHeight)}),[d,N]),(0,e.useLayoutEffect)((function(){T.current&&(T.current.scrollTop=T.current.scrollHeight)}),[U]);var Pt=(0,e.useCallback)((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;R.current=document.activeElement===I.current.currentElement(),t?ut(t):(xt||H.length>0)&&ut(H)}),[H,ut]),Lt=P("mwai-chatbot",dn(dn(dn(dn(dn(dn(dn(dn({},"mwai-".concat(null==n?void 0:n.themeId,"-theme"),!0),"mwai-window",V),"mwai-bubble",K),"mwai-open",d),"mwai-fullscreen",!k||!V&&Q),"mwai-bottom-left","bottom-left"===Z),"mwai-top-right","top-right"===Z),"mwai-top-left","top-left"===Z)),It=function(){var t=gn(yn().mark((function t(e){return yn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return et&&mt(),t.abrupt("return",dt(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Tt=(0,e.useMemo)((function(){return null==U?void 0:U.map((function(t){return r().createElement(Rr,{key:t.id,message:t})}))}),[U]);return r().createElement(E,{id:"mwai-chatbot-".concat(B||D),if:!0,disableTransition:!V,className:Lt,style:hn(hn({},tt),o)},L&&r().createElement("style",null,L),V&&r().createElement(r().Fragment,null,r().createElement("div",{className:P(["mwai-trigger","mwai-open-button"])},r().createElement(E,{className:"mwai-icon-text-container",if:J&&x},r().createElement("div",{className:P(["mwai-icon-text-close"]),onClick:function(){return O(!1)}},"✕"),r().createElement("div",{className:P(["mwai-icon-text"])},J)),r().createElement("div",{className:P(["mwai-icon-container"]),onClick:function(){y(!0),O(!1)}},r().createElement("img",{className:P("mwai-icon"),width:"64",height:"64",alt:X,src:rt}))),r().createElement("div",{className:P("mwai-header")},r().createElement("div",{className:P("mwai-buttons")},Q&&r().createElement("div",{className:P("mwai-resize-button"),onClick:function(){return j(!k)}}),r().createElement("div",{className:P("mwai-close-button"),onClick:function(){return y(!d)}})))),r().createElement("div",{className:P("mwai-content")},r().createElement("div",{ref:T,className:P("mwai-conversation")},Tt),et&&r().createElement("div",{className:P("mwai-error"),onClick:function(){return mt()}},r().createElement(cr,{options:En},et)),r().createElement("div",{className:P("mwai-input")},r().createElement(ln,{ref:I,onTypeText:function(t){vt&&gt(!1),et&&mt(),lt(t)},onSubmitAction:Pt,onUploadFile:It,inputText:H,textInputMaxLength:G,textInputPlaceholder:W,busy:nt,isListening:vt,setIsListening:gt,speechRecognitionAvailable:bt,speechRecognition:ot,uploadedFile:at,composing:f,setComposing:p,modCss:P,imageUpload:it,fileSearch:ct}),nt&&r().createElement("button",{disabled:!0,className:P("mwai-busy")},a&&r().createElement("div",{className:P("mwai-timer")},a)),!nt&&r().createElement("button",{disabled:wt,onClick:function(){vt&&gt(!1),Et?st():Pt()}},r().createElement("span",null,Et?$:z))),q&&r().createElement("div",{className:P("mwai-compliance"),dangerouslySetInnerHTML:{__html:q}})))},Sn=function(t){return React.createElement(ht,t,React.createElement(On,t))};function kn(t){return kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kn(t)}var jn=["children"];function Cn(){Cn=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",h="suspendedYield",d="executing",m="completed",y={};function v(){}function g(){}function b(){}var w={};u(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=v.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var s=f(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==kn(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function j(e,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(kn(e)+" is not iterable")}return g.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},S(k.prototype),u(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),u(O,s,"Generator"),u(O,a,(function(){return this})),u(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function Pn(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ln(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Pn(Object(r),!0).forEach((function(e){var n,o,i;n=t,o=e,i=r[e],o=function(t){var e=function(t,e){if("object"!=kn(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=kn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kn(e)?e:String(e)}(o),o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Pn(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function In(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function Tn(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){In(i,n,o,a,c,"next",t)}function c(t){In(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Rn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Nn(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nn(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var An=wp.element,Fn=An.useContext,Mn=An.createContext,_n=An.useState,Dn=An.useMemo,Bn=An.useEffect,Un=An.useCallback,Hn=Mn(),Gn=function(t){var e=t.children,r=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,jn),n=r.system,o=r.theme,a=w().modCss,c=(null==o?void 0:o.settings)||{},s=Rn(_n([]),2),u=s[0],l=s[1],f=Rn(_n(null),2),p=f[0],h=f[1],d=Rn(_n(!1),2),m=d[0],y=d[1],v=n.botId,g=n.customId,b=n.restNonce,x=n.pluginUrl,E=n.restUrl,O=n.debugMode,S=Dn((function(){return Object.keys(c).reduce((function(t,e){return t["--mwai-".concat(e)]=c[e],t}),{})}),[x,c]),k=Un(Tn(Cn().mark((function t(){var e,r,n,o,a,c=arguments;return Cn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=c.length>0&&void 0!==c[0]&&c[0],t.prev=1,e||y(!0),r={botId:v||g},O&&console.log("[DISCUSSIONS] OUT: ",r),t.next=7,fetch("".concat(E,"/mwai-ui/v1/discussions/list"),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":b},body:i(r)});case 7:return n=t.sent,t.next=10,n.json();case 10:if((o=t.sent).success){t.next=13;break}throw new Error("Could not retrieve the discussions: ".concat(o.message));case 13:O&&console.log("[DISCUSSIONS] IN: ",o),a=o.chats.map((function(t){var e=JSON.parse(t.messages),r=JSON.parse(t.extra);return Ln(Ln({},t),{},{messages:e,extra:r})})),l(a),t.next=21;break;case 18:t.prev=18,t.t0=t.catch(1),console.error(t.t0);case 21:return t.prev=21,e||y(!1),t.finish(21);case 24:case"end":return t.stop()}}),t,null,[[1,18,21,24]])}))),[]);Bn((function(){k();var t=setInterval((function(){k(!0)}),5e3);return function(){return clearInterval(t)}}),[]);var j=function(t){var e=MwaiAPI.getChatbot(t);if(!e)throw new Error("Chatbot not found.",{botId:t,chatbots:MwaiAPI.chatbots});return e},C=function(){var t=Tn(Cn().mark((function t(e){var r;return Cn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=u.find((function(t){return t.chatId===e}))){t.next=4;break}return console.error("Discussion not found.",{chatId:e,discussions:u}),t.abrupt("return");case 4:j(v).setContext({chatId:e,messages:r.messages}),h(r);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),P=function(){var t=Tn(Cn().mark((function t(){return Cn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:j(v).clear();case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),L={onDiscussionClick:C,onNewChatClick:P},I={botId:v,pluginUrl:x,busy:m,setBusy:y,modCss:a,cssVariables:S,discussions:u,discussion:p,theme:o};return React.createElement(Hn.Provider,{value:{state:I,actions:L}},e)};function zn(t){return zn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zn(t)}function $n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Wn(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$n(Object(r),!0).forEach((function(e){qn(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function qn(t,e,r){return e=function(t){var e=function(t,e){if("object"!=zn(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=zn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zn(e)?e:String(e)}(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Vn=wp.element,Qn=Vn.useMemo,Jn=Vn.useEffect,Yn=function(t){var e=t.discussion,r=t.onClick,n=void 0===r?function(){}:r,o=t.selected,i=void 0!==o&&o,a=t.modCss,c=e.messages,s=c[c.length-1],u=s.content.length>64?s.content.substring(0,64)+"...":s.content,l=a("mwai-discussion",{"mwai-active":i});return React.createElement("li",{className:l,onClick:n},u)};const Xn=function(t){var e=t.theme,r=t.style,n=t.params,o=w().modCss,i=Qn((function(){return"css"===(null==e?void 0:e.type)?null==e?void 0:e.style:null}),[e]),a=function(){var t=Fn(Hn);if(!t)throw new Error("useDiscussionsContext must be used within a DiscussionsContextProvider");return t}(),c=a.state,s=a.actions,u=c.botId,l=c.cssVariables,f=c.discussions,p=c.discussion,h=c.busy,d=s.onDiscussionClick,m=s.onNewChatClick,y=n.textNewChat;Jn((function(){}));var v=o("mwai-discussions",qn({},"mwai-".concat(null==e?void 0:e.themeId,"-theme"),!0));return React.createElement(React.Fragment,null,React.createElement("div",{id:"mwai-discussions-".concat(u),className:v,style:Wn(Wn({},l),r)},i&&React.createElement("style",null,i),React.createElement("div",{className:o("mwai-header")},React.createElement("button",{onClick:function(){return m()},disabled:h},React.createElement("span",null,null!=y?y:"+ New chat"))),React.createElement("ul",{className:o("mwai-content")},f.map((function(t){return React.createElement(Yn,{key:t.id,discussion:t,selected:(null==p?void 0:p.id)===t.id,modCss:o,onClick:function(){return d(t.chatId)}})})))))},Zn=function(t){return React.createElement(Gn,t,React.createElement(Xn,t))};var Kn=wp.element.render;function to(t){var e=document.createElement("textarea");return e.innerHTML=t,e.value}document.addEventListener("DOMContentLoaded",(function(){function t(t,e){t.forEach((function(t){var r=JSON.parse(to(t.getAttribute("data-params"))),n=JSON.parse(to(t.getAttribute("data-system"))),o=JSON.parse(to(t.getAttribute("data-theme")));t.removeAttribute("data-params"),t.removeAttribute("data-system"),t.removeAttribute("data-theme"),Kn(e({system:n,params:r,theme:o}),t)}))}t(document.querySelectorAll(".mwai-chatbot-container"),Sn),t(document.querySelectorAll(".mwai-discussions-container"),Zn)}))})();

Softgel-Capsule – Affy Pharma Pvt Ltd

Arrange A Callback
[]
1 Step 1
Full Name
Telephone
Departmentyour full name
Postal Address
Message
0 /
Previous
Next
Shopping Basket