PluginProbe ʕ •ᴥ•ʔ
AI Engine – The Chatbot, AI Framework & MCP for WordPress / 0.2.5
AI Engine – The Chatbot, AI Framework & MCP for WordPress v0.2.5
3.5.8 3.5.7 3.5.6 3.5.5 3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.4.9 3.4.8 3.4.7 0.2.1 1.6.91 0.2.2 1.6.92 0.2.3 1.6.93 0.2.4 1.6.94 0.2.5 1.6.95 0.2.6 1.6.96 0.2.7 1.6.97 0.2.8 1.6.98 0.2.9 1.6.99 0.3.0 1.7.0 0.3.1 1.7.1 0.3.2 1.7.2 0.3.3 1.7.3 0.3.4 1.7.4 0.3.5 1.7.5 0.3.6 1.7.6 0.4.0 1.7.7 0.4.1 1.7.8 0.4.2 1.7.9 0.4.3 1.8.0 0.4.4 1.8.1 0.4.5 1.8.2 0.4.6 1.8.3 0.4.7 1.8.4 0.4.8 1.8.5 0.4.9 1.8.6 0.5.0 1.8.7 0.5.1 1.8.8 0.5.2 1.8.9 0.5.3 1.9.0 0.5.4 1.9.1 0.5.5 1.9.2 0.5.6 1.9.3 0.5.7 1.9.4 0.5.8 1.9.5 0.5.9 1.9.6 0.6.0 1.9.7 0.6.1 1.9.8 0.6.2 1.9.81 0.6.3 1.9.82 0.6.4 1.9.83 0.6.5 1.9.84 0.6.6 1.9.85 0.6.7 1.9.86 0.6.8 1.9.87 0.6.9 1.9.88 0.7.0 1.9.89 0.7.1 1.9.90 0.7.2 1.9.91 0.7.3 1.9.92 0.7.4 1.9.93 0.7.5 1.9.94 0.7.6 1.9.95 0.7.7 1.9.96 0.7.8 1.9.97 0.7.9 1.9.98 0.8.0 1.9.99 0.8.1 2.0.0 0.8.2 2.0.1 0.8.3 2.0.2 0.8.4 2.0.3 0.8.5 2.0.4 0.8.6 2.0.5 0.8.7 2.0.6 0.8.8 2.0.7 0.8.9 2.0.8 0.9.0 2.0.9 0.9.2 2.1.0 0.9.3 2.1.1 0.9.4 2.1.2 0.9.5 2.1.3 0.9.6 2.1.4 0.9.7 2.1.5 0.9.8 2.1.6 0.9.81 2.1.7 0.9.82 2.1.8 0.9.83 2.1.9 0.9.84 2.2.0 0.9.85 2.2.1 0.9.86 2.2.2 0.9.87 2.2.3 0.9.88 2.2.4 0.9.89 2.2.5 0.9.9 2.2.51 0.9.91 2.2.52 0.9.92 2.2.53 0.9.93 2.2.54 0.9.94 2.2.56 0.9.95 2.2.57 0.9.96 2.2.6 0.9.97 2.2.60 0.9.98 2.2.61 0.9.99 2.2.62 1.0.0 2.2.63 1.0.01 2.2.70 1.0.1 2.2.80 1.0.2 2.2.81 1.0.3 2.2.90 1.0.4 2.2.91 1.0.5 2.2.92 1.0.6 2.2.93 1.0.7 2.2.94 1.0.8 2.2.95 1.0.9 2.3.0 1.1.0 2.3.1 1.1.1 2.3.2 1.1.2 2.3.3 1.1.3 2.3.4 1.1.4 2.3.5 1.1.5 2.3.6 1.1.6 2.3.7 1.1.7 2.3.8 1.1.8 2.3.9 1.1.9 2.4.0 1.2.0 2.4.1 1.2.1 2.4.2 1.2.2 2.4.3 1.2.21 2.4.4 1.2.3 2.4.5 1.2.30 2.4.6 1.3.0 2.4.7 1.3.1 2.4.8 1.3.2 2.4.9 1.3.3 2.5.0 1.3.31 2.5.1 1.3.32 2.5.2 1.3.33 2.5.3 1.3.34 2.5.4 1.3.35 2.5.5 1.3.36 2.5.6 1.3.37 2.5.7 1.3.38 2.5.8 1.3.39 2.5.9 1.3.40 2.6.0 1.3.41 2.6.1 1.3.42 2.6.2 1.3.43 2.6.3 1.3.44 2.6.5 1.3.45 2.6.6 1.3.46 2.6.7 1.3.47 2.6.8 1.3.48 2.6.9 1.3.49 2.7.0 1.3.50 2.7.1 1.3.51 2.7.2 1.3.52 2.7.3 1.3.53 2.7.4 1.3.54 2.7.5 1.3.56 2.7.6 1.3.57 2.7.7 1.3.58 2.7.8 1.3.59 2.7.9 1.3.60 2.8.0 1.3.61 2.8.1 1.3.62 2.8.2 1.3.63 2.8.3 1.3.64 2.8.4 1.3.65 2.8.5 1.3.66 2.8.6 1.3.67 2.8.7 1.3.68 2.8.8 1.3.69 2.8.9 1.3.70 2.9.0 1.3.71 2.9.1 1.3.72 2.9.2 1.3.73 2.9.3 1.3.74 2.9.4 1.3.75 2.9.5 1.3.76 2.9.6 1.3.77 2.9.7 1.3.78 2.9.8 1.3.79 2.9.9 1.3.80 3.0.0 1.3.81 3.0.1 1.3.82 3.0.2 1.3.83 3.0.3 1.3.84 3.0.4 1.3.85 3.0.5 1.3.86 3.0.6 1.3.87 3.0.7 1.3.88 3.0.8 1.3.89 3.0.9 1.3.90 3.1.0 1.3.91 3.1.1 1.3.92 3.1.2 1.3.93 3.1.3 1.3.94 3.1.4 1.3.95 3.1.5 1.3.96 3.1.6 1.3.97 3.1.7 1.3.98 3.1.8 1.3.99 3.1.9 1.4.0 3.2.0 1.4.1 3.2.1 1.4.2 3.2.2 1.4.3 3.2.3 1.4.4 3.2.4 1.4.5 3.2.5 1.4.6 3.2.6 1.4.7 3.2.7 1.4.8 3.2.8 1.4.9 3.2.9 1.5.0 3.3.0 1.5.1 3.3.1 1.5.2 3.3.2 1.5.3 3.3.3 1.5.4 3.3.4 1.5.5 3.3.5 1.5.6 3.3.6 1.5.7 3.3.7 1.5.8 3.3.8 1.5.9 3.3.9 1.6.0 3.4.0 1.6.1 3.4.1 1.6.2 3.4.2 1.6.3 3.4.3 1.6.5 3.4.4 1.6.51 3.4.5 1.6.52 3.4.6 1.6.53 1.6.54 1.6.55 1.6.56 1.6.57 1.6.58 1.6.59 1.6.60 1.6.61 1.6.62 1.6.63 1.6.64 1.6.65 1.6.66 1.6.67 1.6.68 trunk 1.6.69 0.0.1 1.6.70 0.0.2 1.6.71 0.0.3 1.6.72 0.0.4 1.6.73 0.0.5 1.6.74 0.0.6 1.6.75 0.0.7 1.6.76 0.0.8 1.6.77 0.0.9 1.6.78 0.1.0 1.6.79 0.1.1 1.6.81 0.1.2 1.6.82 0.1.3 1.6.83 0.1.4 1.6.84 0.1.5 1.6.85 0.1.6 1.6.86 0.1.7 1.6.87 0.1.8 1.6.88 0.1.9 1.6.89 0.2.0 1.6.90
ai-engine / app / index.js
ai-engine / app Last commit date
index.js 3 years ago index.js.LICENSE.txt 3 years ago vendor.js 3 years ago vendor.js.LICENSE.txt 3 years ago
index.js
8 lines
1 /*! For license information please see index.js.LICENSE.txt */
2 (()=>{"use strict";var e,t={5834:(e,t,n)=>{var r,a,o,i,c,l=n(6488),u=n(5945),s=n(3757),f=n(6160),h=n(749),p=n(1630),m=n(4694),d=n(1254),y=n(8168),v=n(5979),g=n(1488),b=n(7818),w=n(537),E=n(8694),R=(mwai_meow_plugin.prefix,mwai_meow_plugin.domain,mwai_meow_plugin.rest_url.replace(/\/+$/,"")),x=mwai_meow_plugin.api_url.replace(/\/+$/,""),k=mwai_meow_plugin.plugin_url.replace(/\/+$/,""),_=("1"===mwai_meow_plugin.is_pro&&mwai_meow_plugin.is_registered,mwai_meow_plugin.rest_nonce),O=mwai_meow_plugin.options,L=n(8406),S=n(2788);function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var P=S.ZP.div(r||(r=j(["\n color: white;\n padding: 15px;\n margin-bottom: -15px;\n\n a {\n color: #7dedff;\n text-decoration: none;\n }\n\n p {\n font-size: 15px;\n }\n"]))),C=(0,S.ZP)(w.v)(a||(a=j(["\n\n .nui-block-title {\n display: none;\n }\n\n .plugin-desc {\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-left: 20px;\n\n }\n\n .nui-block-content {\n display: flex;\n padding: 10px;\n item-align: center;\n\n h2 {\n color: #055082;\n font-size: 18px;\n margin: 0;\n\n a {\n text-decoration: none;\n }\n }\n\n p {\n margin: 0px;\n font-size: 15px;\n }\n }\n"]))),T=S.ZP.img(o||(o=j(["\n width: 85px;\n height: 85px;\n padding-right: 10px;\n"]))),A=S.ZP.div(i||(i=j(["\n\n margin: 15px;\n\n .center {\n background: white;\n border-radius: 10px;\n padding: 10px;\n max-width: 100%\n overflow: none;\n\n h2 {\n font-size: 26px;\n }\n\n table {\n width: 100%;\n\n tr td:first-child {\n width: 220px;\n font-weight: bold;\n color: #1e7cba;\n }\n\n * {\n overflow-wrap: anywhere;\n }\n }\n }\n\n hr {\n border-color: #1e7cba;\n }\n"]))),I=S.ZP.ul(c||(c=j(["\n margin-top: 10px;\n background: rgb(0, 72, 88);\n padding: 10px;\n color: rgb(58, 212, 58);\n max-height: 600px;\n min-height: 200px;\n display: block;\n font-family: monospace;\n font-size: 12px;\n white-space: pre;\n overflow-x: auto;\n width: calc(100vw - 276px);\n\n .log-date {\n color: white;\n margin-left: 8px;\n }\n\n .log-type {\n background: #0000004d;\n padding: 2px 5px;\n border-radius: 8px;\n text-transform: uppercase;\n }\n\n .log-content {\n display: block;\n }\n\n .log-warning .log-type {\n background: #ccb028;\n color: white;\n }\n\n .log-fatal .log-type {\n background: #cc2828;\n color: white;\n }\n"])));function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}function F(){F=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==N(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function z(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function G(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){z(o,r,a,i,c,"next",e)}function c(e){z(o,r,a,i,c,"throw",e)}i(void 0)}))}}function M(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||B(e,t)||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 B(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(e,t):void 0}}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Z=wp.element,q=Z.useState,Y=Z.useEffect,H="".concat(R,"/meow-common/v1"),W=function(e){var t=e.request,n=e.title,r=e.max,a=M(q(!1),2),o=a[0],i=a[1],c=M(q([]),2),l=c[0],u=c[1],s=l.length>0?l.reduce((function(e,t){return e+t})):0,h=l.length>0?Math.ceil(s/l.length):0,p=!l.length&&o;return Y((function(){o&&setTimeout(G(F().mark((function e(){var n,r,a;return F().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(new Date).getTime(),e.next=3,(0,E.ZL)("".concat(H,"/").concat(t),{nonce:_});case 3:r=(new Date).getTime(),a=r-n,u((function(e){return[].concat(function(e){if(Array.isArray(e))return D(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||B(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.")}(),[a]);var t}));case 6:case"end":return e.stop()}}),e)}))),1e3)}),[l]),React.createElement(P,{style:{width:200,textAlign:"center"}},React.createElement(f.O,{h2:!0,style:{color:"white"}},n),React.createElement(L._,{size:200,value:p?r:h,max:r},React.createElement("span",{style:{fontSize:20}},p?"START":h+" ms"),React.createElement("span",{style:{fontSize:12}},p?"YOUR ENGINE":l.length+" requests")),React.createElement(b._,{style:{width:"100%",marginTop:10},color:o?"#cc3627":"#ccb027",onClick:function(){o||u([]),i(!o)}},o?"Stop":"Start"))};function U(e){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(e)}function J(){J=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==U(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function $(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$(Object(n),!0).forEach((function(t){K(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function K(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==U(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==U(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===U(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function X(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Q(o,r,a,i,c,"next",e)}function c(e){Q(o,r,a,i,c,"throw",e)}i(void 0)}))}}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return te(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?te(e,t):void 0}}(e,t)||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 te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ne=wp.element,re=ne.useState,ae=ne.useEffect;x&&R&&k||console.error("[@common/dashboard] apiUrl, restUrl and pluginUrl are mandatory.");var oe="".concat(R,"/meow-common/v1"),ie=React.createElement(P,null,React.createElement(f.O,{p:!0},"Meow Apps is a suite of plugins for photography, imaging, optimization, and SEO, run by ",React.createElement("a",{target:"_blank",href:"https://offbeatjapan.org"},"Jordy Meow"),", a photographer and developer in Japan. The goal is to improve and speed up your website. Learn more at ",React.createElement("a",{href:"http://meowapps.com",target:"_blank"},"Meow Apps"),".")),ce=React.createElement(P,null,React.createElement(f.O,{p:!0},"⭐️ The ",React.createElement("b",null,"Empty Request Time")," helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins then start this again to see how it modifies the results. Keep it absolutely under 2,000 ms! That said, I recommend it to keep it below 500ms."),React.createElement(f.O,{p:!0},"⭐️ ",React.createElement("b",null,"File Operation Time")," creates a temporary size of 10MB every time."),React.createElement(f.O,{p:!0},"⭐️ ",React.createElement("b",null,"SQL Request Time")," counts the number of posts. Those two should be very fast, and almost the same as the ",React.createElement("b",null,"Empty Request Time"),".")),le=React.createElement(P,null,React.createElement(f.O,{p:!0},"Keep your WordPress install simple and efficient by using only necessary plugins and a reliable hosting service. Avoid trying to self-host unless you have professional experience. Follow best practices and stay up-to-date with the latest recommendations on the Meow Apps website.",React.createElement("ul",null,React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-improve-seo-wordpress/",target:"_blank"},"SEO Checklist & Optimization")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-faster-wordpress-optimize/",target:"_blank"},"Optimize your WordPress Speed")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-optimize-images-wordpress/",target:"_blank"},"Optimize Images (CDN, and so on)")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-hosting-service-wordpress/",target:"_blank"},"The Best Hosting Services for WordPress"))))),ue=["".concat(oe,"/all_settings/"),{headers:{"X-WP-Nonce":_}}],se=function(){var e=ee(re(!1),2),t=e[0],n=e[1],r=(0,s.ZP)(ue,E.SG),a=r.data,o=r.mutate,i=r.error,c=null==a?void 0:a.data,l=null==c?void 0:c.meowapps_hide_meowapps,u=null==c?void 0:c.force_sslverify,R=ee(re(!1),2),x=R[0],O=R[1],L=ee(re([]),2),S=L[0],j=L[1],N=ee(re(""),2),F=N[0],z=N[1];ae((function(){i&&!t&&(n(!0),console.error("Error from UseSWR",i.message))}),[i]),ae((function(){var e=document.getElementById("meow-common-phpinfo");z(e.innerHTML)}),[]);var G=function(){var e=X(J().mark((function e(t,n){var r,i;return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=V({},a.data))[n]=t,o(V(V({},a),{},{data:r}),!1),O(!0),e.next=6,(0,E.ZL)("".concat(oe,"/update_option"),{json:{name:n,value:t},nonce:_});case 6:i=e.sent,O(!1),i.success||alert(i.message),o();case 10:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),M=function(){var e=X(J().mark((function e(){var t,n;return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return O(!0),e.next=3,(0,E.ZL)("".concat(oe,"/error_logs"),{nonce:_});case 3:t=e.sent,n=t&&t.data?t.data:[],j(n.reverse()),O(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),B=React.createElement(h.r,{title:"Main Menu"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"meowapps_hide_meowapps",label:"Hide (Not Recommended)",description:React.createElement(f.O,{p:!0},"This will hide the Meow Apps Menu (on the left side) and everything it contains. You can re-enable it through though an option that will be added in Settings → General."),value:"1",disabled:x,checked:l,onChange:G}))),D=React.createElement(h.r,{title:"SSL Verify"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"force_sslverify",label:"Force (Not Recommended)",description:React.createElement(f.O,{p:!0},"This will enforce the usage of SSL when checking the license or updating the plugin."),value:"1",disabled:x,checked:u,onChange:G})));return React.createElement(d.s,{showRestError:t},React.createElement(y.B,{title:"The Dashboard"}),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(g.c,null,React.createElement(g.P,{title:"Meow Apps"},ie,React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(C,{title:"Media Cleaner",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/media-cleaner.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-cleaner/"},"Media Cleaner")),React.createElement("p",null,"Remove the useless media entries and files."))),React.createElement(C,{title:"Database Cleaner",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/database-cleaner.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/database-cleaner/"},"Database Cleaner")),React.createElement("p",null,"Clean your database and make it faster."))),React.createElement(C,{title:"Media File Renamer",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/media-file-renamer.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-file-renamer/"},"Media File Renamer")),React.createElement("p",null,"Rename your filenames for a better SEO."))),React.createElement(C,{title:"Social Engine",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/social-engine.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/social-engine/"},"Social Engine")),React.createElement("p",null,"Share your articles and photos on the SNS."))),React.createElement(C,{title:"Meow Analytics",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/meow-analytics.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-analytics/"},"Meow Analytics")),React.createElement("p",null,"Google Analytics for your website.")))),React.createElement(v.z,{minimal:!0},React.createElement(C,{title:"Photo Engine",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/wplr-sync.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wplr-sync/"},"Photo Engine")),React.createElement("p",null,"Organize your photos in folders and collections.",React.createElement("br",null),"Synchronize with Lightroom."))),React.createElement(C,{title:"Meow Gallery",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/meow-gallery.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-gallery/"},"Meow Gallery")),React.createElement("p",null,"Fast and beautiful gallery with many layouts."))),React.createElement(C,{title:"Meow Lightbox",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/meow-lightbox.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-lightbox/"},"Meow Lightbox")),React.createElement("p",null,"Sleek and performant lightbox with EXIF support."))),React.createElement(C,{title:"Perfect Images (Retina)",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/wp-retina-2x.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wp-retina-2x/"},"Perfect Images")),React.createElement("p",null,"Optimize your thumbnails, retina, replace images, etc."))),React.createElement(C,{title:"Contact Form Block",className:"primary"},React.createElement(T,{src:"".concat(k,"/common/img/contact-form-block.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/contact-form-block/"},"Contact Form Block")),React.createElement("p",null,"Simple and straightforward contact form, in one block.")))))),React.createElement(g.P,{title:"Performance"},ce,React.createElement("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:25}},React.createElement(W,{title:"Empty Request Time",request:"empty_request",max:2500}),React.createElement(W,{title:"File Operation Time",request:"file_operation",max:2600}),React.createElement(W,{title:"SQL Request Time",request:"sql_request",max:2800})),le),React.createElement(g.P,{title:"PHP Info"},React.createElement(A,{dangerouslySetInnerHTML:{__html:F}})),React.createElement(g.P,{title:"PHP Error Logs"},React.createElement(P,null,React.createElement(b._,{style:{marginBottom:10},color:"#ccb027",onClick:M},"Load PHP Error Logs"),React.createElement(I,null,S.map((function(e){return React.createElement("li",{class:"log-".concat(e.type)},React.createElement("span",{class:"log-type"},e.type),React.createElement("span",{class:"log-date"},e.date),React.createElement("span",{class:"log-content"},e.content))}))),React.createElement(f.O,{p:!0},"If nothing appears after loading, it might be that your hosting service does not allow you to access the PHP error logs directly from here. Please contact them directly."))),React.createElement(g.P,{title:"Settings"},React.createElement(w.v,{title:"Settings",className:"primary"},B,D))))))},fe=n(1492),he=n(9137),pe=[{id:"text-davinci-003",name:"text-davinci-003",short:"davinci",description:"Most capable GPT-3 model. Can do any task the other models can do, often with higher quality, longer output and better instruction-following. Also supports inserting completions within text.",strength:"Complex intent, cause and effect, summarization for audience"},{id:"text-curie-001",name:"text-curie-001",short:"curie",description:"Very capable, but faster and lower cost than Davinci.",strength:"Language translation, complex classification, text sentiment, summarization"},{id:"text-babbage-001",name:"text-babbage-001",short:"babbage",description:"Capable of straightforward tasks, very fast, and lower cost.",strength:"Moderate classification, semantic search classification"},{id:"text-ada-001",name:"text-ada-001",short:"ada",description:"Capable of very simple tasks, usually the fastest model in the GPT-3 series, and lowest cost.",strength:"Parsing text, simple classification, address correction, keywords"},{id:"code-davinci-002",name:"code-davinci-002",short:"davinci",description:"Most capable Codex model. Particularly good at translating natural language to code. In addition to completing code, also supports inserting completions within code."}],me=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"ru",label:"Russian"},{value:"ja",label:"Japanese"},{value:"zh",label:"Chinese"}],de=[{model:"davinci",price:.02},{model:"curie",price:.002},{model:"babbage",price:5e-4},{model:"ada",price:4e-4},{model:"dall-e",price:.02}],ye=[{value:"informative",label:"Informative"},{value:"descriptive",label:"Descriptive"},{value:"creative",label:"Creative"},{value:"narrative",label:"Narrative"},{value:"persuasive",label:"Persuasive"},{value:"reflective",label:"Reflective"},{value:"argumentative",label:"Argumentative"},{value:"analytical",label:"Analytical"},{value:"evaluative",label:"Evaluative"},{value:"journalistic",label:"Journalistic"},{value:"technical",label:"Technical"}],ve=[{value:"neutral",label:"Neutral"},{value:"formal",label:"Formal"},{value:"assertive",label:"Assertive"},{value:"cheerful",label:"Cheerful"},{value:"humorous",label:"Humorous"},{value:"informal",label:"Informal"},{value:"inspirational",label:"Inspirational"},{value:"professional",label:"Professional"},{value:"confvalueent",label:"Confvalueent"},{value:"emotional",label:"Emotional"},{value:"persuasive",label:"Persuasive"},{value:"supportive",label:"Supportive"},{value:"sarcastic",label:"Sarcastic"},{value:"condescending",label:"Condescending"},{value:"skeptical",label:"Skeptical"},{value:"narrative",label:"Narrative"},{value:"journalistic",label:"Journalistic"}],ge=n(3506);function be(e){return function(e){if(Array.isArray(e))return Ee(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||we(e)||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 we(e,t){if(e){if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ee(e,t):void 0}}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Re=wp.element,xe=Re.useMemo,ke=Re.useEffect,_e=Re.useState,Oe=function(e){var t=e.options.openai_apikey;return t&&t.length>0?null:React.createElement(v.z,null,React.createElement(ge.G,null,"To use the features of AI Engine, you need to have an OpenAI account and create an API Key. Visit the ",React.createElement("a",{href:"https://beta.openai.com/account/api-keys",target:"_blank"},"OpenAI")," website."))};function Le(e){return e.split("\n").map((function(e){return(e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e})).join("\n")}var Se,je,Pe,Ce,Te=function(e){var t,n,r=(t=_e(pe[0].value),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(t,n)||we(t,n)||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.")}()),a=r[0],o=r[1],i=xe((function(){var t,n=pe,r="string"==typeof(null==e?void 0:e.extra_models)?null==e?void 0:e.extra_models:"",a=null!=e&&e.openai_finetunes&&(null==e?void 0:e.openai_finetunes.length)>0?null==e?void 0:e.openai_finetunes.filter((function(e){return e.enabled})):[];return a.length&&(n=[].concat(be(n),be(a.map((function(e){return{id:e.model,name:e.suffix,description:"Fine-tuned"}}))))),(r=null===(t=r)||void 0===t?void 0:t.split(",").filter((function(e){return e}))).length&&(n=[].concat(be(n),be(r.map((function(e){return{id:e,name:e,description:"Extra"}}))))),n}),[e]);return ke((function(){var e=i.find((function(e){return e.name.includes("davinci")}));e&&o(e.name)}),[i]),{model:a,models:i,setModel:o}},Ae=n(3895);function Ie(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Ne=function(e){var t=e.title,n=void 0===t?"Settings":t;return React.createElement(y.B,{title:"AI Engine | ".concat(n),subtitle:"By Jordy Meow"},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_content_generator"}},"Build Content"),React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_image_generator"}},"Build Images"),React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="tools.php?page=mwai_dashboard"}},"Playground"),React.createElement(b._,{className:"header",icon:"tools",onClick:function(){return location.href="admin.php?page=mwai_settings"}},"Settings")))},Fe=((0,S.ZP)(b._)(Se||(Se=Ie(["\n"]))),S.ZP.div(je||(je=Ie(["\n display: flex;\n justify-content: unset;\n align-items: center;\n justify-content: space-between;\n padding: 0 0 2px 0;\n\n h2 {\n margin: 7px 0 0 0;\n padding: 0;\n }\n"])))),ze=S.ZP.div(Pe||(Pe=Ie(["\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(30%, 1fr));\n grid-gap: 10px;\n margin-top: 20px;\n\n img {\n width: 100%;\n height: 305px;\n }\n\n .empty-image {\n width: 100%;\n height: 305px;\n background-color: #f5f5f5;\n }\n"]))),Ge=(0,S.ZP)(Ae.l)(Ce||(Ce=Ie(["\n\n .neko-textarea {\n height: 76px;\n border: 1px solid #eaeaea !important;\n background: #fbfbfb !important;\n font-size: 15px !important;\n }\n"]))),Me=n(477),Be=n(7460),De=n.n(Be),Ze=n(9995),qe=n(8178),Ye=n(9378),He=n(3103),We=n(2625),Ue=n(3676),Je=n(776),$e=n(9746),Ve=n(1203),Ke=n(3565);function Qe(e){return Qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qe(e)}function Xe(e){return function(e){if(Array.isArray(e))return ot(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||at(e)||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 et(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?et(Object(n),!0).forEach((function(t){nt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):et(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function nt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Qe(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Qe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Qe(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||at(e,t)||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 at(e,t){if(e){if("string"==typeof e)return ot(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ot(e,t):void 0}}function ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function it(){it=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Qe(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function ct(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function lt(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ct(o,r,a,i,c,"next",e)}function c(e){ct(o,r,a,i,c,"throw",e)}i(void 0)}))}}var ut=wp.element,st=ut.useState,ft=ut.useMemo,ht=ut.useRef,pt=ut.useEffect,mt=[{accessor:"row",title:"#",width:15,verticalAlign:"top"},{accessor:"validPrompt",title:"",width:15,verticalAlign:"top"},{accessor:"prompt",title:"Prompt",width:"42%",verticalAlign:"top"},{accessor:"validCompletion",title:"",width:15,verticalAlign:"top"},{accessor:"completion",title:"Completion",width:"42%",verticalAlign:"top"},{accessor:"actions",title:"",width:55,align:"center"}],dt=[{accessor:"status",title:"Status",sortable:!0},{accessor:"id",title:"ID"},{accessor:"filename",title:"File"},{accessor:"purpose",title:"Purpose"},{accessor:"filesize",title:"Size",sortable:!0},{accessor:"createdOn",title:"Date",sortable:!0},{accessor:"actions",title:""}],yt=[{accessor:"status",title:"Status",sortable:!0},{accessor:"id",title:"ID"},{accessor:"suffix",title:"Suffix"},{accessor:"model",title:"Model"},{accessor:"base_model",title:"Based On"},{accessor:"createdOn",title:"Date",sortable:!0},{accessor:"actions",title:""}],vt="\n\n###\n\n",gt="\n\n",bt=function(e){var t=e.status,n=e.includeText,r=void 0!==n&&n,a=Ze.ZP.orange,o=Ze.ZP.green,i=Ze.ZP.red,c=null;switch(t){case"pending":case"running":c=React.createElement(qe.J,{title:t,icon:"replay",spinning:!0,width:24,color:a});break;case"succeeded":case"processed":c=React.createElement(qe.J,{title:t,icon:"check-circle",width:24,color:o});break;case"failed":c=React.createElement(qe.J,{title:t,icon:"close",width:24,color:i});break;case"cancelled":c=React.createElement(qe.J,{title:t,icon:"close",width:24,color:a});break;default:c=React.createElement(qe.J,{title:t,icon:"alert",width:24,color:a})}return r?React.createElement("div",{style:{display:"flex",alignItems:"center"}},c,React.createElement("span",{style:{textTransform:"uppercase",fontSize:10,marginLeft:5}},t)):c},wt=function(){var e=lt(it().mark((function e(){var t,n;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(x,"/openai_files"),{nonce:_});case 2:return n=e.sent,e.abrupt("return",null==n||null===(t=n.files)||void 0===t?void 0:t.data);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Et=function(){var e=lt(it().mark((function e(){var t,n;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(x,"/openai_finetunes"),{nonce:_});case 2:return n=e.sent,e.abrupt("return",null==n||null===(t=n.finetunes)||void 0===t?void 0:t.data);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Rt=function(e){var t=e.children,n=e.data,r=e.onChange,a=void 0===r?function(){}:r,o=rt(st(!1),2),i=o[0],c=o[1],l=function(e){c(!1),e!==n&&a(e)};return i?React.createElement("div",{onKeyUp:function(e){"Escape"===e.key&&l(n)},style:{height:"100%",display:"flex",flexDirection:"column"}},React.createElement(Ae.l,{onBlurForce:!0,autoFocus:!0,fullHeight:!0,rows:3,style:{height:"100%"},onEnter:l,onBlur:l,value:n}),React.createElement(b._,{onClick:l,fullWidth:!0,style:{marginTop:5,height:35}},"Save")):React.createElement("pre",{style:{width:"100%",height:"100%",whiteSpace:"break-spaces",margin:0,padding:0,fontSize:13,fontFamily:"inherit"},onClick:function(){return c(!0)}},t)};const xt=function(e){var t,n,r=e.options,a=e.updateOption,o=(0,u.NL)(),i=rt(st(),2),c=i[0],l=i[1],s=rt(st(!1),2),f=s[0],h=s[1],p=rt(st("finetunes"),2),m=p[0],d=p[1],y=rt(st(!0),2),v=y[0],g=y[1],w=Te(r),R=w.models,k=w.model,O=w.setModel,L=rt(st("meow"),2),S=L[0],j=L[1],P=(0,Me.a)({queryKey:["datasets"],queryFn:wt}),C=P.isLoading,T=(P.error,P.data),A=(0,Me.a)({queryKey:["finetunes"],queryFn:Et}),I=(A.isLoading,A.error,A.data),N=(null==r?void 0:r.openai_finetunes_deleted)||[],F=10,z=rt(st(!0),2),G=z[0],M=z[1],B=rt(st(1),2),D=B[0],Z=B[1],q=rt(st([]),2),Y=q[0],H=q[1],W=rt(st(""),2),U=W[0],J=W[1],$=ft((function(){return Y.length}),[Y]),V=function(){var e=lt(it().mark((function e(){return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.invalidateQueries("datasets");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=function(){var e=lt(it().mark((function e(){return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.next=3,V();case 3:h(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=lt(it().mark((function e(){var t,n,r,a;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c,n=S,r=R.find((function(e){return e.name===k})),h(!0),e.next=6,(0,E.PV)("".concat(x,"/openai_files_finetune"),{method:"POST",nonce:_,json:{fileId:t,model:r.short,suffix:n}});case 6:if(!(a=e.sent).success){e.next=15;break}return e.next=10,X();case 10:alert("Fine-tuning started! Check its progress in the 'Models' section. Depending on your dataset size, it may take a while (from a few minutes to days)."),d("finetunes"),l(),e.next=16;break;case 15:alert(a.message);case 16:h(!1);case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=function(){var e=lt(it().mark((function e(){return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.invalidateQueries("finetunes");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=lt(it().mark((function e(){return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.next=3,X();case 3:h(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),te=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];e&&!confirm("This will delete all the rows in the builder. Are you sure?")||(H([]),re([]))},ne=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=Y.map((function(r,a){return a===e-1?tt(tt({},r),{},n?{completion:t}:{prompt:t}):r}));H(r)};pt((function(){if(!Y||0===Y.length){var e=localStorage.getItem("mwai_builder_data");e&&H(JSON.parse(e))}}),[]);var re=function(e){var t,n;t=new Date,n=(n=t.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"})).replace(/\//g,"."),n+="-"+t.getHours().toString().padStart(2,"0")+"."+t.getMinutes().toString().padStart(2,"0"),J("MEOW-".concat(n,".jsonl"));try{e?localStorage.setItem("mwai_builder_data",JSON.stringify(e)):localStorage.removeItem("mwai_builder_data"),M(!0)}catch(e){localStorage.removeItem("mwai_builder_data"),M(!1)}};pt((function(){Y&&Y.length>0&&re(Y)}),[Y]);var ae=ft((function(){var e=(D-1)*F,t=null==Y?void 0:Y.slice((D-1)*F,(D-1)*F+F);return null==t?void 0:t.map((function(t){var n,r,a=++e,o=null===(n=t.prompt)||void 0===n?void 0:n.endsWith(vt),i=null===(r=t.completion)||void 0===r?void 0:r.endsWith(gt);return{row:a,validPrompt:o?"�
3 ":"❌",prompt:React.createElement(Rt,{data:t.prompt,onChange:function(e){return ne(a,e)}},o?t.prompt.substring(0,t.prompt.length-vt.length):t.prompt),validCompletion:i?"�
4 ":"❌",completion:React.createElement(Rt,{data:t.completion,onChange:function(e){return ne(a,e,!0)}},i?t.completion.substring(0,t.completion.length-gt.length):t.completion),actions:React.createElement(b._,{rounded:!0,icon:"trash",onClick:function(){return function(e){var t=Y.filter((function(t,n){return n!==e-1}));H(t),0===t.length&&re([])}(a)}})}}))}),[Y,D,F]),oe=function(){var e=lt(it().mark((function e(t){var n;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.prev=1,e.next=4,(0,E.PV)("".concat(x,"/openai_files"),{method:"DELETE",nonce:_,json:{fileId:t}});case 4:if(!(n=e.sent).success){e.next=10;break}return e.next=8,V();case 8:e.next=11;break;case 10:alert(n.message);case 11:e.next=17;break;case 13:e.prev=13,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 17:h(!1);case 18:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}(),ie=function(){var e=lt(it().mark((function e(t){var n;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm("You are going to delete this fine-tune. Are you sure?\n\nPlease note that it will take a while before it is actually deleted. This might be a temporary issue of OpenAI.")){e.next=2;break}return e.abrupt("return");case 2:return h(!0),e.prev=3,e.next=6,(0,E.PV)("".concat(x,"/openai_finetunes"),{method:"DELETE",nonce:_,json:{modelId:t}});case 6:if(!(n=e.sent).success){e.next=14;break}return e.next=10,a([].concat(Xe(N),[t]),"openai_finetunes_deleted");case 10:return e.next=12,X();case 12:e.next=23;break;case 14:if(!(n.message.indexOf("does not exist")>-1)){e.next=22;break}return alert("This fine-tune was already deleted. It will be removed from the list."),e.next=18,a([].concat(Xe(N),[t]),"openai_finetunes_deleted");case 18:return e.next=20,X();case 20:e.next=23;break;case 22:alert(n.message);case 23:e.next=29;break;case 25:e.prev=25,e.t0=e.catch(3),console.log(e.t0),alert("Error! Check your console.");case 29:h(!1);case 30:case"end":return e.stop()}}),e,null,[[3,25]])})));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=lt(it().mark((function e(t,n){var r,a,o,i;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.prev=1,console.log({fileId:t,filename:n}),e.next=5,(0,E.PV)("".concat(x,"/openai_files_download"),{method:"POST",nonce:_,json:{fileId:t}});case 5:(r=e.sent).success?(console.log(r),a=new Blob([r.data],{type:"text/plain"}),o=window.URL.createObjectURL(a),(i=document.createElement("a")).setAttribute("href",o),i.setAttribute("download","".concat(n)),document.body.appendChild(i),i.click(),i.remove()):alert(r.message),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 13:h(!1);case 14:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,n){return e.apply(this,arguments)}}(),le=ft((function(){return null==T?void 0:T.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=e.id,n=e.filename,r=new Date(1e3*e.created_at),a="fine-tune"===e.purpose;return{status:React.createElement(bt,{status:e.status,includeText:!0}),id:t,filename:n,purpose:e.purpose,filesize:(0,E.td)(e.bytes),createdOn:r.toLocaleDateString()+" "+r.toLocaleTimeString(),actions:React.createElement(React.Fragment,null,React.createElement(b._,{disabled:!a,rounded:!0,icon:"wand",onClick:function(){return l(t)}}),React.createElement(b._,{rounded:!0,icon:"arrow-down",onClick:function(){return ce(t,n)}}),React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return oe(t)}}))}}))}),[T]),ue=ft((function(){return I?I.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=e.fine_tuned_model,n=new Date(1e3*e.created_at);return{status:React.createElement(bt,{status:e.status,includeText:!0}),id:e.id,suffix:e.suffix,model:e.fine_tuned_model,base_model:e.model,createdOn:n.toLocaleDateString()+" "+n.toLocaleTimeString(),actions:React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return ie(t)}})}})):[]}),[I]),se=C||f,pe=function(){var e=lt(it().mark((function e(){var t,n;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h(!0),e.prev=1,t=Y.map((function(e){return JSON.stringify(e)})).join("\n"),console.log(t),e.next=6,(0,E.PV)("".concat(x,"/openai_files"),{method:"POST",nonce:_,json:{filename:U,data:t}});case 6:return n=e.sent,e.next=9,V();case 9:n.success?(te(!1),alert("Uploaded successfully! You can now train a model based on this dataset."),d("files"),g(!0)):alert(n.message),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 16:h(!1);case 17:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(){return e.apply(this,arguments)}}(),me=ft((function(){var e=new Date,t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate(),a=e.getHours(),o=e.getMinutes(),i=e.getSeconds(),c=R.find((function(e){return e.name===k}));return"".concat(null==c?void 0:c.short,":ft-your-org:").concat(S,"-").concat(t,"-").concat(n<10?"0"+n:n,"-").concat(r<10?"0"+r:r,"-").concat(a<10?"0"+a:a,"-").concat(o<10?"0"+o:o,"-").concat(i<10?"0"+i:i)}),[S,k]),de=function(){var e=lt(it().mark((function e(t){var n,r;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=it().mark((function e(){var n,a,o,i,c;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[r],a=new FileReader,o=n.name.endsWith(".json"),i=n.name.endsWith(".jsonl"),c=n.name.endsWith(".csv"),o||i||c){e.next=9;break}return alert("This only supports JSON, JSONL, and CSV files."),console.log(n),e.abrupt("return","continue");case 9:a.onload=function(){var e=lt(it().mark((function e(t){var n,r,a,l,u,s,f;return it().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.target.result,r=[],o?r=JSON.parse(n):i?(a=n.split("\n"),r=a.map((function(e){e=e.trim();try{return JSON.parse(e)}catch(t){return console.log(t,e),null}}))):c&&(console.log("YO"),l=De().parse(n,{header:!0,skipEmptyLines:!0}),r=l.data,console.log("The CSV was loaded.",r)),u=r.map((function(e){var t=Object.keys(e).reduce((function(t,n){return t[n.toLowerCase()]=e[n],t}),{}),n=["prompt","question","q"].find((function(e){return t[e]})),r=["completion","answer","a"].find((function(e){return t[e]}));return{prompt:t[n],completion:t[r]}})),s=u.filter((function(e){return e.prompt&&e.completion})),u.length!==s.length&&(alert("Some are were empty. Make sure the CSV has a header row and that the columns are named 'prompt' and 'completion'. For debugging, an empty line was logged to the console."),f=u.find((function(e){return!e.prompt||!e.completion})),console.log("Empty line: ",f)),H(s);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a.readAsText(n);case 11:case"end":return e.stop()}}),e)})),r=0;case 2:if(!(r<t.length)){e.next=10;break}return e.delegateYield(n(),"t0",4);case 4:if("continue"!==e.t0){e.next=7;break}return e.abrupt("continue",7);case 7:r++,e.next=2;break;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ye=ht(null);return React.createElement(he.H,{style:{margin:10}},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("div",{style:{marginRight:15}},React.createElement(Ye.Q,{onLabel:"Model Finetune",offLabel:"Dataset Builder",width:145,onBackgroundColor:Ze.ZP.purple,offBackgroundColor:Ze.ZP.green,onChange:g,checked:v})),v&&React.createElement(He.h,{value:m,busy:se,onChange:function(e){d(e)}},React.createElement(He.S,{title:"Models",value:"finetunes",count:null!==(t=null==ue?void 0:ue.length)&&void 0!==t?t:null}),React.createElement(He.S,{title:"Datasets",value:"files",count:null!==(n=null==le?void 0:le.length)&&void 0!==n?n:null})),v&&"finetunes"===m&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:f,onClick:ee,className:"primary"},"Refresh Models")),v&&"files"===m&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:f,onClick:K,className:"primary"},"Refresh Datasets")),!v&&React.createElement("div",{style:{display:"flex",alignItems:"center",width:"100%"}},React.createElement("div",{style:{display:"flex",alignItems:"center",background:"#ecf3ff",padding:"3px 3px 3px 8px",borderRadius:5,border:"1px solid #cce1ee"}},React.createElement("label",{style:{marginRight:10}},"Filename:"),React.createElement(fe.A,{disabled:!$||f,value:$?U:"",onChange:J,style:{width:210,marginRight:5}}),React.createElement(b._,{disabled:!$||f,icon:"upload",onClick:pe,className:"primary"},"Upload")),React.createElement("div",{style:{flex:"auto"}}),React.createElement(We.b,{ref:ye,onSelectFiles:de,accept:""},React.createElement(b._,{style:{marginLeft:5},onClick:function(){return ye.current.click()}},"Import File")))),v&&"finetunes"===m&&React.createElement(React.Fragment,null,React.createElement("p",null,"The AI models you have fine-tuned. To create more, visit ",React.createElement("b",null,"Datasets"),"."),React.createElement(Ue.a,{alternateRowColor:!0,busy:se,data:ue,columns:yt,emptyMessage:React.createElement(React.Fragment,null,"You do not have any fine-tuned jobs yet.")})),v&&"files"===m&&React.createElement(React.Fragment,null,React.createElement("p",null,"The datasets you have uploaded to OpenAI. To create a new dataset, switch from ",React.createElement("b",null,"Model Finetuner")," to ",React.createElement("b",null,"Dataset Builder"),". To train a new model, click on the ",React.createElement("i",null,"magic wand"),"."),React.createElement(Ue.a,{alternateRowColor:!0,busy:se,data:le,columns:dt,emptyMessage:React.createElement(React.Fragment,null,"You do not have any dataset files yet.")})),!v&&React.createElement(React.Fragment,null,React.createElement("p",null,"You can create your dataset by importing a file (two columns, in the CSV, JSON or JSONL format) or manually by clicking ",React.createElement("b",null,"Add Entry"),". To avoid losing your work, this data is kept in your browser's local storage. ",React.createElement("b",null,"This is actually complex, so learn how to write datasets by studying ",React.createElement("a",{href:"https://beta.openai.com/docs/guides/fine-tuning/conditional-generation",target:"_blank"},"case studies"),".")," Is your dataset ready? Modify the filename to your liking and click ",React.createElement("b",null,"Upload"),"! 😎"),!G&&React.createElement("p",{style:{color:Ze.ZP.red}},"Caution: The data is too large to be saved in your browser's local storage."),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{icon:"plus",onClick:function(){H([].concat(Xe(Y),[{prompt:"Text...\n\n###\n\n",completion:"Text...\n\n"}]))},style:{paddingLeft:10,paddingRight:10}},"Add Entry"),React.createElement(b._,{icon:"wand",disabled:!0,onClick:function(){return alert("Coming soon! ✌️")}},"Generate Entries"),React.createElement(b._,{disabled:!$,className:"secondary",onClick:function(){var e=Y.map((function(e){var t=e.prompt,n=e.completion;return t.endsWith(vt)||(t+=vt),n.endsWith(gt)||(n+=gt),{prompt:t,completion:n}}));H(e)}},"Format with Defaults"),React.createElement(b._,{disabled:!$,className:"secondary",style:{marginLeft:5},onClick:function(){var e=De().unparse(Y),t=new Blob([e],{type:"text/csv"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n;var a=new Date,o="".concat(a.getFullYear(),"-").concat(a.getMonth()+1,"-").concat(a.getDate(),"-WP.csv");r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r)}},"Export as CSV"),React.createElement(b._,{disabled:!$,onClick:te,className:"danger"},"Reset Entries"),React.createElement("div",{style:{flex:"auto"}}),React.createElement(Je.Q,{currentPage:D,limit:F,total:$,onCurrentPageChanged:Z,onClick:Z})),React.createElement($e.i,{height:20}),React.createElement(Ue.a,{alternateRowColor:!0,busy:f,data:ae,columns:mt,emptyMessage:React.createElement(React.Fragment,null,"You can import a file, or create manually each entry by clicking ",React.createElement("b",null,"Add Entry"),".")}),React.createElement($e.i,{height:20}),React.createElement("div",{style:{display:"flex",justifyContent:"end"}},React.createElement(Je.Q,{currentPage:D,limit:F,total:$,onCurrentPageChanged:Z,onClick:Z})),React.createElement($e.i,{height:40,line:!0,style:{marginBottom:0}}),React.createElement("p",null,React.createElement("b",null,"Notes:")),React.createElement("p",null,"• The prompt and the completion should both end with their own special ending. For now, they are set by default: ",React.createElement("b",null,"\\n\\n===\\n\\n")," for the prompt, and ",React.createElement("b",null,"\\n\\n")," for the completion. The icon �
5 will be shown next to the prompt and/or completion when this format has been validated, and the ending will be hidden for clarity."),React.createElement("p",null,"• ",React.createElement("b",null,"\\n")," is a line break. You can add line breaks by using ",React.createElement("b",null,"SHIFT+ENTER")," while editing."),React.createElement("p",null,"• The ",React.createElement("b",null,"Format with Defaults")," button will add the default endings to the prompt and completion, if they are missing.")),React.createElement(Ve.L,{isOpen:c,title:"Train a new model",onOkClick:Q,onRequestClose:function(){return l()},onCancelClick:function(){return l()},ok:"Start",disabled:f,content:React.createElement(React.Fragment,null,React.createElement("p",null,"Exciting! 🎵 You are about to create your own new model, based on your dataset. You simply need to select a base model, and optionally, to modify the ",React.createElement("a",{href:"https://beta.openai.com/docs/guides/fine-tuning/hyperparameters",target:"_blank"},"hyperparameters"),". Before starting the process, make sure that:"),React.createElement("ul",null,React.createElement("li",null,"�
6 The dataset is well-defined."),React.createElement("li",null,"�
7 You understand ",React.createElement("a",{href:"https://openai.com/api/pricing/#faq-fine-tuning-pricing-calculation",target:"_blank"},"OpenAI pricing")," about fine-tuning.")),React.createElement("label",null,"Base model:"),React.createElement($e.i,{height:5}),React.createElement(Ke.N,{id:"models",value:k,scrolldown:!0,onChange:O},R.map((function(e){return React.createElement(Ke.Z,{value:e.id,label:e.short?e.short:e.name})}))),React.createElement($e.i,{height:5}),React.createElement("small",null,"For now, the hyperparameters can't be modified - they are set automatically by OpenAI."),React.createElement($e.i,{height:10}),React.createElement("label",null,"Suffix (for new model name):"),React.createElement($e.i,{height:5}),React.createElement(fe.A,{value:S,onChange:j}),React.createElement($e.i,{height:5}),React.createElement("small",null,"The name of the new model name will be decided by OpenAI. You can customize it a bit with this ",React.createElement("a",{href:"https://beta.openai.com/docs/api-reference/fine-tunes/list#fine-tunes/create-suffix",target:"_blank"},"prefix"),". Preview: ",React.createElement("b",null,me),"."))}))};function kt(e){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kt(e)}function _t(){_t=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==kt(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Lt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ot(Object(n),!0).forEach((function(t){St(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ot(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==kt(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==kt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===kt(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jt(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Pt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ct(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ct(e,t):void 0}}(e,t)||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 Ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Tt=wp.element.useState,At=function(e){return"dall-e"===e};const It=function(){var e=Pt(Tt(O),2),t=e[0],n=e[1],r=Pt(Tt(!1),2),a=r[0],o=r[1],i=a,c=null==t?void 0:t.module_titles,l=null==t?void 0:t.module_excerpts,u=null==t?void 0:t.module_blocks,s=null==t?void 0:t.shortcode_chat,y=null==t?void 0:t.shortcode_chat_style,b=null==t?void 0:t.shortcode_chat_formatting,R=null==t?void 0:t.shortcode_imagesbot,k=null!=t&&t.openai_apikey?null==t?void 0:t.openai_apikey:"",L=null==t?void 0:t.openai_usage,S=null==t?void 0:t.extra_models,j=(null==t||t.openai_finetunes,function(){var e,r=(e=_t().mark((function e(r,a){var i,c;return _t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=Lt(Lt({},t),{},St({},a,r)),o(!0),e.prev=2,e.next=5,(0,E.ZL)("".concat(x,"/update_option"),{json:{options:i},nonce:_});case 5:(c=e.sent).success&&n(c.options),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),e.t0.message&&alert(e.t0.message);case 12:return e.prev=12,o(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[2,9,12,15]])})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){jt(o,r,a,i,c,"next",e)}function c(e){jt(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(e,t){return r.apply(this,arguments)}}()),P=React.createElement(h.r,{title:"Assistants"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"module_titles",label:"Titles",value:"1",checked:c,description:"Create a choice of titles based on your content.",onChange:j}),React.createElement(m.P,{id:"module_excerpts",label:"Excerpt",value:"1",checked:l,description:"Create a choice of excerpts based on your content.",onChange:j}))),C=React.createElement(h.r,{title:"Blocks"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"module_blocks",label:"Enable (Coming soon)",disabled:!0,value:"1",checked:u,description:"Add Gutenberg AI Blocks in the editor. They will allow you to easily create content with AI.",onChange:j}))),T=React.createElement(h.r,{title:"Shortcodes"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"shortcode_chat",label:"ChatBot",value:"1",checked:s,description:React.createElement(React.Fragment,null,"Create a chatbot similar to ChatGPT with a shortcode:",React.createElement("br",null),React.createElement("br",null),'[mwai_chat context="Converse as if you were Michael Jackson, talking from the afterlife." ai_name="Michael: " user_name="You: " start_sentence="Hi, my friend."]',React.createElement("br",null),React.createElement("br",null),"You can also add temperature (between 0 and 1, default is 0.8) and a model (default is text-davinci-003, but you can try text-babbage-001 and the others)."),onChange:j})),React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"shortcode_imagesbot",label:"ImagesBot",value:"1",checked:R,description:React.createElement(React.Fragment,null,"Create a special chatbot that will take your input and generate images. It works like this:",React.createElement("br",null),React.createElement("br",null),'[mwai_imagesbot ai_name="AI: " user_name="You: " start_sentence="Hey there! Can you tell me what kind of images you need?" max_results="6"]'),onChange:j}))),A=React.createElement(h.r,{title:"Styles"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"shortcode_chat_style",label:"Enable",value:"1",checked:y,description:"The ChatBot and ImagesBot will look a bit like ChatGPT.",onChange:j}))),I=React.createElement(h.r,{title:"Formatting"},React.createElement(p.l,{max:"1"},React.createElement(m.P,{id:"shortcode_chat_formatting",label:"Enable",value:"1",checked:b,description:React.createElement(React.Fragment,null,"Convert the reply from the AI into HTML.",React.createElement("br",null),React.createElement("b",null,"Markdown is supported, so it is highly recommended to add 'Use Markdown.' in your context.")),onChange:j}))),N=React.createElement(h.r,{title:"Extra Models"},React.createElement(fe.A,{id:"extra_models",name:"extra_models",value:S,description:React.createElement(React.Fragment,null,"You can enter additional models you would like to use (separated by a comma). Note that your fine-tuned models are already available."),onBlur:j})),F=React.createElement(h.r,{title:"API Key"},React.createElement(fe.A,{id:"openai_apikey",name:"openai_apikey",value:k,description:React.createElement(React.Fragment,null,"You can get your API Keys in your ",React.createElement("a",{href:"https://beta.openai.com/account/api-keys",target:"_blank"},"OpenAI Account"),"."),onBlur:j})),z=React.createElement(h.r,{title:"Usage"},!Object.keys(L).length&&React.createElement(f.O,{p:!0},"N/A"),L&&React.createElement(React.Fragment,null,React.createElement("ul",{style:{marginTop:2}},Object.keys(L).map((function(e,t){var n=L[e];return React.createElement("li",{key:t},React.createElement("strong",null,"🗓️ ",e),React.createElement("ul",null,Object.keys(n).map((function(e,t){var r=n[e],a=null,o=de.find((function(t){return e.includes(t.model)}));return o&&(a=At(e)?(r.images*o.price).toFixed(2):(r.total_tokens/1e3*o.price).toFixed(2)),React.createElement("li",{key:t,style:{marginTop:10,marginLeft:10}},At(e)&&React.createElement(React.Fragment,null,React.createElement("strong",null,"• Model: ",e),React.createElement("ul",{style:{marginTop:5,marginLeft:5}},React.createElement("li",null,"💰 Images: ",React.createElement("b",null,r.images)," ",a&&React.createElement(React.Fragment,null," = ",React.createElement("b",null,a,"$"))))),!At(e)&&React.createElement(React.Fragment,null,React.createElement("strong",null,"• Model: ",e),React.createElement("ul",{style:{marginTop:5,marginLeft:5}},React.createElement("li",null,"💰 Tokens: ",React.createElement("b",null,r.total_tokens)," ",a&&React.createElement(React.Fragment,null," = ",React.createElement("b",null,a,"$"))))))}))))})))),React.createElement("p",{style:{fontSize:12,color:"#A0A0A0"}},"This is only given as an indication. For the exact amounts, please check your ",React.createElement("a",{href:"https://beta.openai.com/account/usage",target:"_blank"},"Usage at OpenAI"),"."));return React.createElement(d.s,null,React.createElement(Ne,null),React.createElement(v.o,null,React.createElement(Oe,{options:t}),React.createElement(v.z,{full:!0},React.createElement(he.H,null,React.createElement(f.O,{p:!0},"Boost your WordPress with AI! Currently, it only proposes titles and excerpts for your posts, and keep track of your OpenAI usage statistics. There is also a Playground which allows you to have a discussion with the AI, or ask it to complete some tasks. Little by little, and through your feedback, many tools will be added to AI Engine, and an API will be available so that other plugins can use it.")),React.createElement(g.c,{keepTabOnReload:!0},React.createElement(g.P,{title:"Settings"},React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:i,title:"Modules",className:"primary"},P,C,T,N)),React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:i,title:"Open AI",className:"primary"},F,z)))),(s||R)&&React.createElement(g.P,{title:"Shortcodes"},React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:i,title:"Chatbot",className:"primary"},I)),React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:i,title:"UI",className:"primary"},A)))),React.createElement(g.P,{title:"Fine Tuning: Train your AI"},React.createElement(xt,{options:t,updateOption:j}))))))};function Nt(e){return Nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Nt(e)}var Ft,zt,Gt;function Mt(){Mt=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Nt(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Bt(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Dt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Zt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zt(e,t):void 0}}(e,t)||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 Zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function qt(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Yt=wp.element,Ht=Yt.useState,Wt=Yt.useEffect,Ut=Yt.useMemo,Jt=[{id:"none",name:"None",mode:"query",description:""},{id:"custom_model",name:"Custom Model Prompt",mode:"query",description:"Hello! What's your name?\n\n###\n\n"},{id:"wp_assistant",name:"WordPress Assistant",mode:"chat",description:"Converse as a WordPress expert. Be helpful, friendly, concise, avoid external URLs and commercial solutions.\n\n AI: Hi! How can I help you with WP today?"},{id:"article_translator",name:"Article Translator",mode:"query",description:"Translate this article into French:\n\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n\n"},{id:"article_writer",name:"Article Writer",mode:"query",description:"Write an article about what to do in Paris, in summer, with a few recommendations of restaurants and cafes.\n\n"},{id:"bulk_articles_writer",name:"Bulk Articles Writer",mode:"query",description:"Write titles (TITLE: ) and very short paragraphs (CONTENT: ) for each following topic. Keywords for each topic will be added between parenthesis.\n\n - When to travel to France (seasons, food, ambiance, celebrations)\n - Why one should visit the French countryside (beach, forest, mountain, food, people)\n - Story of a night at Mont Saint-Michel (hotel, ambiance, sea, light)\n - Differences between South West and South East of France (people, food, beach, ambiance)\n"},{id:"article_corrector",name:"Article Corrector",mode:"query",description:"Fix the grammar and spelling mistakes in this text:\n\nI wake up at eleben yesderday, I will go bed eary tonigt.\n"},{id:"seo_assistant",name:"SEO Assistant",mode:"query",description:"For the following article, write a SEO-friendly and short title, keywords for Google, and a short excerpt to introduce it. Use this format:\n\n Title: \n Keywords: \n Excerpt: \n \n Uchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n "}],$t=S.ZP.textarea(Ft||(Ft=qt(["\n display: block;\n height: 460px;\n width: 100%;\n margin-bottom: 10px;\n background: #333d4e;\n border-radius: 5px;\n border: none;\n color: #d1d5dc;\n font-size: 14px;\n font-family: monospace;\n padding: 20px;\n"]))),Vt=S.ZP.div(zt||(zt=qt(["\n background: white;\n padding: 15px;\n border-radius: 5px;\n\n h3:first-child {\n margin-top: 0;\n }\n\n label {\n display: block;\n margin-bottom: 5px;\n }\n\n label {\n margin-top: 10px;\n }\n\n li {\n margin-bottom: 10px;\n border: 1px solid #e5e5e5;\n padding: 10px;\n background: #f5f5f5;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.2s ease-in-out;\n }\n\n li.active {\n background: #037cba;\n color: white;\n border-color: #037cba;\n }\n"]))),Kt=(0,S.ZP)(fe.A)(Gt||(Gt=qt(["\n flex: auto !important;\n\n input {\n height: 50px !important;\n font-size: 14px !important;\n font-family: monospace !important;\n padding: 20px 20px 20px 45px !important;\n border-color: #333d4e !important;\n background: #333d4e !important;\n color: white !important;\n }\n"])));const Qt=function(){var e=Dt(Ht(),2),t=e[0],n=e[1],r=Dt(Ht(),2),a=r[0],o=r[1],i=Dt(Ht("chat"),2),c=i[0],l=i[1],u=Dt(Ht(""),2),s=u[0],h=u[1],p=Te(O),m=p.models,y=p.model,g=p.setModel,w=Dt(Ht(1),2),R=w[0],k=w[1],L=Dt(Ht(!1),2),S=L[0],j=L[1],P=Dt(Ht({prompt_tokens:0,completion_tokens:0,total_tokens:0}),2),C=P[0],T=P[1],A=Dt(Ht({prompt_tokens:0,completion_tokens:0,total_tokens:0}),2),I=A[0],N=A[1],F=Dt(Ht(Jt[2]),2),z=F[0],G=F[1],M=Dt(Ht("\\n\\n"),2),B=M[0],D=M[1];Wt((function(){var e=z.description.split("\n").map((function(e){return e.trim()}));e=e.join("\n"),o(e),l(z.mode)}),[z]);var Z=function(){var e,t=(e=Mt().mark((function e(){var t,r,i,c,l=arguments;return Mt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]?l[0]:a,j(!0),r=B.replace(/\\n/g,"\n"),e.next=5,(0,E.ZL)("".concat(x,"/make_completions"),{json:{prompt:t,temperature:R,model:y,stop:r},nonce:_});case 5:i=e.sent,console.log("Completions",{prompt:t,result:i}),i.success?(o(t+"\n"+i.data),N(i.usage),c={prompt_tokens:C.prompt_tokens+i.usage.prompt_tokens,completion_tokens:C.completion_tokens+i.usage.completion_tokens,total_tokens:C.total_tokens+i.usage.total_tokens},T(c)):n(i.message),j(!1);case 9:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Bt(o,r,a,i,c,"next",e)}function c(e){Bt(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}(),q=Ut((function(){var e=0,t=0,n=de.find((function(e){return y&&y.includes(e.model)}));return n&&(e=(C.total_tokens/1e3*n.price).toFixed(4),t=(I.total_tokens/1e3*n.price).toFixed(4)),{sessionPrice:e,lastRequestPrice:t}}),[C,I]),Y=q.sessionPrice,H=q.lastRequestPrice;return React.createElement(d.s,{nekoErrors:[]},React.createElement(Ne,{title:"Playground"}),React.createElement(v.o,null,React.createElement(Oe,{options:O}),React.createElement(v.z,{full:!0},React.createElement(he.H,{style:{marginBottom:0}},React.createElement(f.O,{p:!0},"Welcome to the AI Playground! Here, you can play with different AI models and ask the UI to perform various tasks for you. You can ask it to write, rewrite, or translate an article, categorize words or elements into groups, write an email, etc. ",React.createElement("b",null,"Let me know if there are any new features you would like to see!")," Have fun 🥳"))),React.createElement(v.z,null,React.createElement(Vt,null,React.createElement("h3",{style:{marginTop:0}},"Templates"),React.createElement("ul",null,Jt.map((function(e){return React.createElement("li",{className:z.id===e.id?"active":"",onClick:function(){G(e)}},e.name)}))),React.createElement("h3",{style:{marginTop:0}},"Mode"),React.createElement(Ke.N,{scrolldown:!0,id:"mode",name:"mode",disabled:!0,value:c,description:"",onChange:l},React.createElement(Ke.Z,{key:"chat",id:"chat",value:"chat",label:"Chat"}),React.createElement(Ke.Z,{key:"query",id:"query",value:"query",label:"Query"})))),React.createElement(v.z,{style:{flex:3}},React.createElement($t,{onChange:function(e){o(e.target.value)},value:a}),"chat"===c&&React.createElement("div",{style:{display:"flex"}},React.createElement("span",{class:"dashicons dashicons-format-chat",style:{position:"absolute",color:"white",zIndex:200,fontSize:28,marginTop:12,marginLeft:10}}),React.createElement(Kt,{id:"entry",value:s,onChange:h,onEnter:function(){var e=a+"\nHuman: "+s;o(e),h(""),Z(e)},disabled:S})),"chat"!==c&&React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{onClick:function(){o(z.description)},disabled:S,style:{height:50,fontSize:14,flex:1}},"Reset"),React.createElement(b._,{onClick:function(){Z()},disabled:S,style:{height:50,fontSize:14,flex:4}},"Submit"))),React.createElement(v.z,null,React.createElement(Vt,null,React.createElement("h3",null,"Settings"),React.createElement("label",null,"Model:"),React.createElement(Ke.N,{id:"models",value:y,scrolldown:!0,onChange:g},m.map((function(e){return React.createElement(Ke.Z,{value:e.id,label:e.name})}))),React.createElement("label",null,"Temperature:"),React.createElement(fe.A,{id:"temperature",name:"temperature",value:R,type:"number",onChange:k,onBlur:k,description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:R>=0&&R<=1?"inherit":"red"}},"Between 0 and 1. Higher values means the model will take more risks."))}),React.createElement("label",null,"Stop Sequence:"),React.createElement(fe.A,{id:"stopSequence",name:"stopSequence",value:B,type:"text",onChange:D,onBlur:D,description:React.createElement(React.Fragment,null,React.createElement("span",null,"The sequence of tokens that will cause the model to stop generating text. You absolutely need this with your own models."))})),React.createElement(Vt,{style:{marginTop:20}},React.createElement("h3",null,"Usage"),React.createElement("p",null,"Keeps track of the current usage of the AI."),React.createElement("h4",null,"Session"),React.createElement("div",null,"Tokens: ",C.total_tokens),React.createElement("div",null,"Price: $",Y),React.createElement("h4",null,"Last Request"),React.createElement("div",null,"Tokens: ",I.total_tokens),React.createElement("div",null,"Price: $",H),React.createElement(b._,{style:{marginTop:10,width:"100%"},onClick:function(){T({prompt_tokens:0,completion_tokens:0,total_tokens:0}),N({prompt_tokens:0,completion_tokens:0,total_tokens:0})}},"Reset Usage")))),React.createElement(Ve.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};var Xt,en,tn=n(5307);function nn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var rn=S.ZP.div(Xt||(Xt=nn(["\n margin-bottom: 5px;\n"]))),an=S.ZP.div(en||(en=nn(["\n margin-top: 15px;\n padding: 15px;\n font-size: 14px;\n cursor: pointer;\n border-radius: 15px;\n background: #dbf2ff;\n line-height: 120%;\n\n &:hover {\n background: #037cba;\n color: white;\n }\n"])));function on(e){return on="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(e)}function cn(){cn=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==on(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function ln(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function un(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ln(o,r,a,i,c,"next",e)}function c(e){ln(o,r,a,i,c,"throw",e)}i(void 0)}))}}function sn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fn(e,t):void 0}}(e,t)||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 fn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var hn=wp.element,pn=hn.useState,mn=hn.useEffect,dn=hn.useMemo;const yn=function(e){var t=e.post,n=e.onTitleClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=sn(pn([]),2),c=i[0],l=i[1],u=sn(pn(!1),2),s=u[0],f=u[1],h=sn(pn(!1),2),p=h[0],m=h[1];mn((function(){t&&d(t)}),[t]);var d=function(){var e=un(cn().mark((function e(t){var n,r;return cn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,t.postTitle,f(!0),e.next=4,(0,E.ZL)("".concat(x,"/make_titles"),{json:{postId:n},nonce:_});case 4:(r=e.sent).success&&l(r.data),f(!1);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=un(cn().mark((function e(t){return cn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:g(),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),m(e.t0.message);case 10:f(!1);case 11:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}(),g=function(){var e=un(cn().mark((function e(){return cn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o(),l([]),m(),f(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b=dn((function(){return s?React.createElement(tn.S,{type:"circle",size:"10%"}):p?React.createElement(React.Fragment,null,"Error: ",p):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(rn,null,c.map((function(e){return React.createElement(an,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,p]);return React.createElement(v.o,null,React.createElement(Ve.L,{isOpen:t,onRequestClose:g,title:'New title for "'.concat(null==t?void 0:t.postTitle,'"'),content:b,ok:"Close",onOkClick:g}))};function vn(e){return vn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vn(e)}function gn(){gn=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==vn(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function bn(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function wn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var En=wp.element,Rn=En.useState,xn=En.useEffect;En.useMemo;const kn=function(){var e,t,n=(e=Rn(),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return wn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wn(e,t):void 0}}(e,t)||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.")}()),r=n[0],a=n[1];xn((function(){document.querySelectorAll(".mwai-link-title").forEach((function(e){var t=e.getAttribute("data-id"),n=e.getAttribute("data-title");e.addEventListener("click",(function(){a({postId:t,postTitle:n})}),!1)}))}),[]);var o=function(){var e,t=(e=gn().mark((function e(t){var n,o,i,c;return gn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.ZL)("".concat(x,"/update_post_title"),{json:{postId:r.postId,title:t},nonce:_});case 2:if((n=e.sent).success){e.next=7;break}throw new Error(n.message);case 7:a(),(o=document.querySelector('tr[id="post-'.concat(r.postId,'"]')))&&(i=o.querySelector(".row-title"))&&(i.innerHTML=t),(c=o.querySelector(".hidden .post_title"))&&(c.innerHTML=t);case 12:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){bn(o,r,a,i,c,"next",e)}function c(e){bn(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}();return React.createElement(v.o,null,React.createElement(yn,{post:r,onTitleClick:o,onClose:function(){a()}}))};function _n(e){return _n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_n(e)}var On;function Ln(){Ln=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==_n(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Sn(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function jn(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Sn(o,r,a,i,c,"next",e)}function c(e){Sn(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Pn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Cn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Cn(e,t):void 0}}(e,t)||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 Cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Tn,An,In=wp.element,Nn=In.useState,Fn=In.useEffect,zn=In.useMemo,Gn=S.ZP.div(On||(Tn=["\n background: white;\n padding: 15px;\n border-radius: 5px;\n\n h2 {\n margin-bottom: 8px;\n }\n \n h3:first-child {\n margin-top: 0;\n }\n\n label {\n display: block;\n margin-bottom: 5px;\n }\n\n label {\n margin-top: 10px;\n }\n\n li {\n margin-bottom: 10px;\n border: 1px solid #e5e5e5;\n padding: 10px;\n background: #f5f5f5;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.2s ease-in-out;\n }\n\n li.active {\n background: #037cba;\n color: white;\n border-color: #037cba;\n }\n\n .information {\n color: #a3a3a3;\n margin-top: 5px;\n font-size: 12px;\n line-height: 100%;\n }\n"],An||(An=Tn.slice(0)),On=Object.freeze(Object.defineProperties(Tn,{raw:{value:Object.freeze(An)}}))));const Mn=function(){var e=Pn(Nn(),2),t=e[0],n=e[1],r=Pn(Nn(""),2),a=r[0],o=r[1],i=Pn(Nn(""),2),c=i[0],l=i[1],u=Pn(Nn(4),2),s=u[0],h=u[1],p=Pn(Nn(""),2),m=p[0],y=p[1],g=Pn(Nn(2),2),w=g[0],R=g[1],k=Pn(Nn(""),2),L=k[0],S=k[1],j=Te(O),P=j.models,C=j.model,T=j.setModel,A=Pn(Nn(""),2),I=A[0],N=A[1],F=Pn(Nn("en"),2),z=F[0],G=F[1],M=Pn(Nn("informative"),2),B=M[0],D=M[1],Z=Pn(Nn("neutral"),2),q=Z[0],Y=Z[1],H=Pn(Nn(),2),W=H[0],U=H[1],J=Pn(Nn(),2),$=J[0],V=J[1],K=Pn(Nn(),2),Q=K[0],X=K[1],ee=Pn(Nn(1),2),te=ee[0],ne=ee[1],re=Pn(Nn(!1),2),ae=re[0],oe=re[1],ie=Pn(Nn(!1),2),ce=ie[0],le=ie[1],ue=Pn(Nn(!1),2),se=ue[0],pe=ue[1],de=Pn(Nn(),2),ge=de[0],be=de[1],we=zn((function(){return function(e){var t=e.split(" ").length,n=e.length,r=[];if(n)return t<3?r.push("The title is too short. It should be at least 3 words."):t>8?r.push("The title is too long. It should be no more than 8 words."):n<40?r.push("The title is too short. It should be at least 40 characters."):n>70&&r.push("The title is too long. It should be no more than 70 characters."),r.join(" ")}(a)}),[a]);Fn((function(){if(a){var e=me.find((function(e){return e.value===z})).label;U("Generate ".concat(s,' short blog headings about "').concat(a,'", in ').concat(e,". Style: ").concat(B,". Tone: ").concat(q,"."))}}),[a,s,B,q,z]),Fn((function(){if(a&&m){var e=me.find((function(e){return e.value===z})).label,t=m.split("\n").filter((function(e){return e})).length;V('Write an article about "'.concat(a,'" in ').concat(e,". With an introduction, and conclusion. The article has ").concat(w*t+2," paragraphs, organized by the following headings:\n\n").concat(m,"\n\nStyle: ").concat(B,". Tone: ").concat(q,". Use Markdown formatting."))}}),[a,m,q,B,z,w]),Fn((function(){a&&X('Write a short, SEO-friendly excerpt for en article about "'.concat(a,'"'))}),[a]);var Ee=function(){var e=jn(Ln().mark((function e(){var t,r,a=arguments;return Ln().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:prompt,e.next=3,(0,E.ZL)("".concat(x,"/make_completions"),{json:{prompt:t,temperature:te,model:C},nonce:_});case 3:if(r=e.sent,console.log("Completions",{prompt:t,result:r}),!r.success){e.next=7;break}return e.abrupt("return",r.data);case 7:return n(r.message),e.abrupt("return",null);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Re=function(){var e=jn(Ln().mark((function e(){var t;return Ln().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe(!0),y(""),e.next=4,Ee(W);case 4:(t=e.sent)&&y(Le(t)),oe(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xe=function(){var e=jn(Ln().mark((function e(){var t;return Ln().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe(!0),S(""),e.next=4,Ee($);case 4:(t=e.sent)&&S(t),oe(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ke=function(){var e=jn(Ln().mark((function e(){var t;return Ln().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe(!0),N(""),e.next=4,Ee(Q);case 4:(t=e.sent)&&N(t),oe(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_e=function(){var e=jn(Ln().mark((function e(){var t;return Ln().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe(!0),e.next=3,(0,E.ZL)("".concat(x,"/create_post"),{json:{title:a,headings:m,content:L,excerpt:I,language:z},nonce:_});case 3:t=e.sent,oe(!1),t.success?be(t.postId):n(t.message);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Se=function(){o(""),y(""),S(""),N(""),be()};return React.createElement(d.s,{nekoErrors:[]},React.createElement(Ne,{title:"Content Generator"}),React.createElement(v.o,null,React.createElement(he.H,{style:{borderRadius:0,marginBottom:0}},React.createElement(f.O,{p:!0,style:{marginBottom:0}},React.createElement("b",null,"Using the Post Generator is simple; write a Title, click on Generate Headings, then Generate Content, then (optionally) on Generate Excerpt, and Create Post.")," That's it!"),React.createElement(f.O,{p:!0,style:{marginBottom:0}},"As you go, you can also modify the prompts (they represent exactly what will be sent to the AI). If you find a prompt that gives you really good result, or have any other remark, idea, or request, please come and chat with me on the ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/support/plugin/ai-engine/"},"Support Forum"),". Let's make this better together 💕")),React.createElement(Oe,{options:O}),React.createElement(v.z,{style:{flex:1}},React.createElement(Gn,{style:{marginBottom:25,paddingBottom:20}},React.createElement("h2",{style:{marginTop:0}},"Topic"),React.createElement(fe.A,{disabled:!0,value:c,onChange:l}),React.createElement(b._,{style:{marginTop:5,marginBottom:15},disabled:!0,fullWidth:!0},"One-Click Generate"),React.createElement("div",{className:"information"},"The Topic feature is coming soon! Add a topic followed by some keywords, and it will all be generated in one-click. Let me know if that interests you!")),React.createElement(Gn,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Content Params"),React.createElement("label",null,"Language:"),React.createElement(Ke.N,{scrolldown:!0,id:"language",name:"language",disabled:ae,value:z,description:"",onChange:G},me.map((function(e){return React.createElement(Ke.Z,{key:e.value,id:e.value,value:e.value,label:e.label})}))),React.createElement("label",null,"Writing style:"),React.createElement(Ke.N,{scrolldown:!0,id:"writingStyle",name:"writingStyle",disabled:ae,value:B,description:"",onChange:D},ye.map((function(e){return React.createElement(Ke.Z,{key:e.value,id:e.value,value:e.value,label:e.label})}))),React.createElement("label",null,"Writing tone:"),React.createElement(Ke.N,{scrolldown:!0,id:"writingTone",name:"writingTone",disabled:ae,value:q,description:"",onChange:Y},ve.map((function(e){return React.createElement(Ke.Z,{key:e.value,id:e.value,value:e.value,label:e.label})}))))),React.createElement(v.z,{style:{flex:3}},React.createElement(Gn,{style:{marginBottom:25,paddingBottom:20}},React.createElement("h2",{style:{marginTop:0}},"Title"),React.createElement(fe.A,{value:a,onChange:o}),we&&React.createElement("div",{className:"information"},"Advice: ",we),React.createElement($e.i,{height:5}),React.createElement(Fe,null,React.createElement("h2",null,"Sections"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Sections: "),React.createElement(Ke.N,{scrolldown:!0,id:"headingsCount",disabled:!a||ae,style:{marginRight:10},value:s,description:"",onChange:h},React.createElement(Ke.Z,{key:3,id:3,value:3,label:3}),React.createElement(Ke.Z,{key:4,id:4,value:4,label:4}),React.createElement(Ke.Z,{key:5,id:5,value:5,label:5}),React.createElement(Ke.Z,{key:8,id:8,value:8,label:8}),React.createElement(Ke.Z,{key:12,id:12,value:12,label:12})),React.createElement(b._,{disabled:!a,isBusy:ae,onClick:Re},"Generate Sections"))),React.createElement($e.i,{height:5}),React.createElement(Ae.l,{rows:4,value:m,onBlur:y}),React.createElement("div",{className:"information"},'You can modify the content before using "Generate Content". Add, rewrite, remove, or reorganize the headings as you wish before going further.'),React.createElement($e.i,{height:5}),React.createElement(Fe,null,React.createElement("h2",null,"Content"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Paragraphs per Heading: "),React.createElement(Ke.N,{scrolldown:!0,id:"paragraphsCount",disabled:!a||ae,style:{marginRight:10},value:w,description:"",onChange:R},React.createElement(Ke.Z,{key:1,id:1,value:1,label:1}),React.createElement(Ke.Z,{key:2,id:2,value:2,label:2}),React.createElement(Ke.Z,{key:3,id:3,value:3,label:3}),React.createElement(Ke.Z,{key:4,id:4,value:4,label:4}),React.createElement(Ke.Z,{key:6,id:6,value:6,label:6}),React.createElement(Ke.Z,{key:8,id:8,value:8,label:8}),React.createElement(Ke.Z,{key:10,id:10,value:10,label:10})),React.createElement(b._,{disabled:!a,isBusy:ae,onClick:xe},"Generate Content"))),React.createElement($e.i,{height:5}),React.createElement(Ae.l,{rows:18,value:L,onBlur:S}),React.createElement("div",{className:"information"},'You can modify the content before using "Create Post". Markdown is supported, and will be converted to HTML when the post is created.'),React.createElement(Fe,null,React.createElement("h2",null,"Excerpt"),React.createElement(b._,{disabled:!a,isBusy:ae,onClick:ke},"Generate Excerpt")),React.createElement(Ae.l,{value:I,onBlur:N,rows:3}),React.createElement($e.i,{height:10}),React.createElement(b._,{fullWidth:!0,onClick:_e,isBusy:ae,disabled:!L},"Create Post"))),React.createElement(v.z,null,React.createElement(Gn,{style:{marginBottom:25}},React.createElement(Fe,null,React.createElement("h2",null,"Model Params"),React.createElement(b._,{onClick:function(){return le(!ce)}},ce?"Hide":"Show")),ce&&React.createElement(React.Fragment,null,React.createElement("label",null,"Temperature:"),React.createElement(fe.A,{id:"temperature",name:"temperature",value:te,type:"number",onChange:ne,onBlur:ne,description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:te>=0&&te<=1?"inherit":"red"}},"Between 0 and 1.")," Higher values means the model will take more risks.")}),React.createElement("label",null,"Model:"),React.createElement(Ke.N,{id:"models",value:C,scrolldown:!0,onChange:T},P.map((function(e){return React.createElement(Ke.Z,{value:e.id,label:e.name})}))),React.createElement("p",{style:{marginBottom:0}},"More parameters will be added here later! 😇"))),React.createElement(Gn,null,React.createElement(Fe,null,React.createElement("h2",null,"Prompts"),React.createElement(b._,{onClick:function(){return pe(!se)}},se?"Hide":"Show")),se&&React.createElement(React.Fragment,null,React.createElement("p",null,"The prompts are automatically generated for you, but you can fine-tune them once everything is set."),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Generate Sections")),React.createElement(Ae.l,{disabled:ae,value:W,onChange:U}),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Generate Content")),React.createElement(Ae.l,{disabled:ae,value:$,onChange:V}),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Generate Excerpt")),React.createElement(Ae.l,{disabled:!L||ae,value:Q,onChange:X}))))),React.createElement(Ve.L,{isOpen:ge,onRequestClose:function(){return be()},onOkClick:function(){window.open("/wp-admin/post.php?post=".concat(ge,"&action=edit"),"_blank"),Se()},ok:"Edit the Post",cancel:"Close",onCancelClick:Se,title:"Post Created!",content:React.createElement("p",null,"The post was created as draft.")}),React.createElement(Ve.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};function Bn(e){return Bn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bn(e)}var Dn;function Zn(){Zn=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Bn(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function qn(e){return function(e){if(Array.isArray(e))return Jn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Un(e)||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(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Hn(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Yn(o,r,a,i,c,"next",e)}function c(e){Yn(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Wn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||Un(e,t)||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 Un(e,t){if(e){if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jn(e,t):void 0}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $n=wp.element,Vn=$n.useState,Kn=$n.useEffect,Qn=$n.useMemo,Xn=[3,6,9],er=S.ZP.div(Dn||(Dn=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n margin-bottom: 5px;\n\n label {\n margin-bottom: 5px;\n display: block;\n }\n"])));const tr=function(){var e=Wn(Vn(),2),t=e[0],n=e[1],r=Wn(Vn("japan, tokyo, trees, izakaya, anime oil painting, high resolution, ghibli inspired, 4k"),2),a=r[0],o=r[1],i=Wn(Vn(!1),2),c=i[0],l=i[1],u=Wn(Vn(3),2),s=u[0],h=u[1],p=Wn(Vn([]),2),y=p[0],g=p[1],w=Wn(Vn(),2),R=w[0],k=w[1],L=Wn(Vn(""),2),S=L[0],j=L[1],P=Wn(Vn(""),2),C=P[0],T=P[1],A=Wn(Vn(""),2),I=A[0],N=A[1],F=Wn(Vn(""),2),z=F[0],G=F[1],M=Wn(Vn(""),2),B=M[0],D=M[1],Z=Wn(Vn(!1),2),q=Z[0],Y=Z[1],H=Wn(Vn([]),2),W=H[0],U=H[1],J=Qn((function(){return y.indexOf(R)}),[R,y]);Kn((function(){if(R){var e=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:42,n=e.replace(/[\s|,]+/g,"-"),r=(n=n.replace(/--+/g,"-")).split("-"),a=r[0],o=1;a.length+r[o].length<t&&o<r.length;)a+="-"+r[o],o++;return a.length>t+1&&(a=a.slice(0,t+2)),a}(a)+".png";D(e),j(a),T(a),N(a),G(a)}}),[R]);var $=function(){var e=Hn(Zn().mark((function e(){var t;return Zn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Y(!0),e.next=3,(0,E.ZL)("".concat(x,"/make_images"),{json:{prompt:a,maxResults:s},nonce:_});case 3:return t=e.sent,Y(!1),t.success&&g(c?[].concat(qn(y),qn(t.data)):t.data),n(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),V=function(){var e=Hn(Zn().mark((function e(){var t;return Zn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Y(!0),e.next=3,(0,E.ZL)("".concat(x,"/create_image"),{json:{url:R,title:S,description:C,caption:I,alt:z,filename:B},nonce:_});case 3:return t=e.sent,Y(!1),t.success&&U([].concat(qn(W),[{id:t.attachmentId,url:R}])),n(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=Qn((function(){var e=W.find((function(e){return e.url===R}));return e?e.id:null}),[R,W]);return console.log({createdMediaIds:W,currentCreatedMediaId:K}),React.createElement(d.s,{nekoErrors:[]},React.createElement(Ne,{title:"Image Generator"}),React.createElement(v.o,null,React.createElement(he.H,{style:{borderRadius:0,marginBottom:0}},React.createElement(f.O,{p:!0,style:{marginBottom:0}},React.createElement("b",null,"This is extremely beta!")," The idea is that I want this to be very convenient to use, and this UI will be found later in the Post Editor directly, via a modal, and you'll be able to add new generated images easily anywhere. If you have any remark, idea, or request, please come and chat with me on the ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/support/plugin/ai-engine/"},"Support Forum"),". Let's make this better together 💕")),React.createElement(Oe,{options:O}),React.createElement(v.z,{style:{flex:3}},R&&React.createElement(React.Fragment,null,React.createElement(he.H,null,React.createElement(Fe,{style:{paddingBottom:10}},React.createElement("h2",null,"Images Generator"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(b._,{disabled:J<1||q,onClick:function(){J>0&&k(y[J-1])}},"<"),React.createElement(b._,{disabled:q,onClick:function(){return k()}},"Back to results"),React.createElement(b._,{disabled:J>=y.length-1||q,onClick:function(){J<y.length-1&&k(y[J+1])}},">"))),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:2}},React.createElement("img",{src:R,style:{width:"100%"}})),React.createElement("div",{style:{flex:1,marginLeft:10,display:"flex",flexDirection:"column"}},React.createElement(er,null,React.createElement("label",null,"Title:"),React.createElement(Ge,{value:S,onBlur:j})),React.createElement(er,null,React.createElement("label",null,"Caption:"),React.createElement(Ge,{value:I,onBlur:N})),React.createElement(er,null,React.createElement("label",null,"Description:"),React.createElement(Ge,{value:C,onBlur:T})),React.createElement(er,null,React.createElement("label",null,"Alternative Text:"),React.createElement(Ge,{value:z,onBlur:G})),React.createElement(er,null,React.createElement("label",null,"Filename:"),React.createElement(fe.A,{value:B,onChange:D})),React.createElement(b._,{fullWidth:!0,style:{marginTop:7},isBusy:q,onClick:function(){return V()}},"Add to Media Library"),React.createElement(b._,{fullWidth:!0,style:{marginLeft:0,marginTop:7},isBusy:q,onClick:function(){return(e=document.createElement("a")).href=R,e.target="_blank",e.download=B,void e.click();var e}},"Download"),K&&React.createElement(ge.C,{style:{fontSize:13,padding:"10px 5px"}},"The media has been created! You can edit it here: ",React.createElement("a",{href:"/wp-admin/post.php?post=".concat(K,"&action=edit"),target:"_blank"},"Edit Media #",K),"."))))),!R&&React.createElement(React.Fragment,null,React.createElement(he.H,null,React.createElement(Fe,null,React.createElement("h2",null,"Generated Images"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Images: "),React.createElement(Ke.N,{scrolldown:!0,id:"maxResults",name:"maxResults",disabled:q,style:{marginRight:10},value:s,description:"",onChange:h},Xn.map((function(e){return React.createElement(Ke.Z,{key:e,id:e,value:e,label:e})}))),React.createElement(b._,{disabled:!a,isBusy:q,onClick:$},"Generate Images"))),React.createElement(Ge,{value:a,onBlur:o,style:{marginTop:20}}),y.length>0&&React.createElement(ze,null,y.map((function(e){return React.createElement("img",{src:e,onClick:function(){return k(e)}})}))),!y.length&&React.createElement(ze,null,React.createElement("div",{class:"empty-image"}),React.createElement("div",{class:"empty-image"}),React.createElement("div",{class:"empty-image"}))))),React.createElement(v.z,null,React.createElement(he.H,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Settings"),React.createElement(m.P,{id:"continuous_mode ",label:"Continuous",value:"1",checked:c,description:"New images will be added to the already generated images.",onChange:l})))),React.createElement(Ve.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};function nr(e){return nr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nr(e)}function rr(){rr=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==nr(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function ar(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function or(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ar(o,r,a,i,c,"next",e)}function c(e){ar(o,r,a,i,c,"throw",e)}i(void 0)}))}}function ir(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return cr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cr(e,t):void 0}}(e,t)||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 cr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var lr=wp.element,ur=lr.useState,sr=lr.useEffect,fr=lr.useMemo;const hr=function(e){var t=e.post,n=e.onExcerptClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=ir(ur([]),2),c=i[0],l=i[1],u=ir(ur(!1),2),s=u[0],f=u[1],h=ir(ur(!1),2),p=h[0],m=h[1];sr((function(){t&&d(t)}),[t]);var d=function(){var e=or(rr().mark((function e(t){var n,r;return rr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,f(!0),e.next=4,(0,E.ZL)("".concat(x,"/make_excerpts"),{json:{postId:n},nonce:_});case 4:(r=e.sent).success&&l(r.data),f(!1);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=or(rr().mark((function e(t){return rr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:g(),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),m(e.t0.message);case 10:f(!1);case 11:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}(),g=function(){var e=or(rr().mark((function e(){return rr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o(),l([]),m(),f(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b=fr((function(){return s?React.createElement(tn.S,{type:"circle",size:"10%"}):p?React.createElement(React.Fragment,null,"Error: ",p):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(rn,null,c.map((function(e){return React.createElement(an,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,p]);return React.createElement(v.o,null,React.createElement(Ve.L,{isOpen:t,onRequestClose:g,title:'New excerpt for "'.concat(null==t?void 0:t.postTitle,'"'),content:b,ok:"Close",onOkClick:g}))};function pr(e){return pr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pr(e)}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function dr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mr(Object(n),!0).forEach((function(t){yr(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function yr(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==pr(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==pr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===pr(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var vr=wp.element,gr=(vr.useState,vr.useEffect,vr.useMemo),br=React.createElement("g",null,React.createElement("g",null,React.createElement("path",{d:"m391 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m331 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m271 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m211 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m151 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m91 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m406 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m346 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m286 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("g",{fill:"#5f55af"},React.createElement("path",{d:"m226 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m166 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m106 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 121h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 181h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 241h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 301h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 361h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 421h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"})),React.createElement("path",{d:"m431 91v30h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15z",fill:"#39326c"}),React.createElement("path",{d:"m431 181h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 241h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 301h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 361h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 421h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"})),React.createElement("g",null,React.createElement("path",{d:"m446 51h-380c-8.284 0-15 6.716-15 15v380c0 8.284 6.716 15 15 15h380c8.284 0 15-6.716 15-15v-380c0-8.284-6.716-15-15-15z",fill:"#aed0ff"}),React.createElement("g",null,React.createElement("path",{d:"m461 446v-380c0-8.284-6.716-15-15-15h-190v410h190c8.284 0 15-6.716 15-15z",fill:"#7c84e8"})),React.createElement("path",{d:"m386 111h-260c-8.284 0-15 6.716-15 15v260c0 8.284 6.716 15 15 15h260c8.284 0 15-6.716 15-15v-260c0-8.284-6.716-15-15-15z",fill:"#5f55af"}),React.createElement("g",null,React.createElement("path",{d:"m401 386v-260c0-8.284-6.716-15-15-15h-130v290h130c8.284 0 15-6.716 15-15z",fill:"#39326c"}))),React.createElement("g",null,React.createElement("path",{d:"m247.626 192.389c-.052-.138-.106-.274-.162-.411-2.744-6.671-9.175-10.978-16.387-10.978-.006 0-.012 0-.018 0-7.219.007-13.65 4.329-16.383 11.01-.046.113-.091.227-.134.341l-45.06 118.31c-2.949 7.742.937 16.408 8.679 19.356 7.742 2.95 16.408-.937 19.356-8.679l7.543-19.804h51.691l7.458 19.762c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33zm-31.14 79.146 14.538-38.171 14.406 38.171z",fill:"#f9f9f9"}),React.createElement("g",{fill:"#e2dff4"},React.createElement("path",{d:"m264.209 321.296c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33l-36.276-96.126v86.956h.751z"}),React.createElement("path",{d:"m328.5 181c-8.284 0-15 6.716-15 15v120c0 8.284 6.716 15 15 15s15-6.716 15-15v-120c0-8.284-6.716-15-15-15z"})))),wr=React.createElement("g",null,React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06-17.32-17.32-16.37-45.67 2.06-61.8l156.08-139.26s13.46-2.54 29.46 13.46 13.46 29.46 13.46 29.46z",fill:"#0052be"}),React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06l187.6-187.6c16 16 13.46 29.46 13.46 29.46z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46c-14.997-14.997-27.922-27.922-42.92-42.92l101.46-90.54z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46-21.46-21.46 96-96z",fill:"#00337a"}),React.createElement("path",{d:"m400 279.001h-64.4l-42.47 57.87c-7.88 10.735-24.824 6.606-26.91-6.52l-11.56-73.01-73.01-11.56c-13.139-2.087-17.244-19.042-6.52-26.91l57.87-42.47v-64.4c0-12.176 13.797-19.289 23.72-12.21l50.15 35.83 70.92-19.9c11.25-3.168 21.656 7.245 18.49 18.49l-19.9 70.92 35.83 50.15c7.071 9.913-.02 23.72-12.21 23.72z",fill:"#ffdd54"}),React.createElement("path",{d:"m412.21 255.281c7.071 9.913-.02 23.72-12.21 23.72h-64.4l-42.47 57.87c-7.875 10.728-24.823 6.616-26.91-6.52l-11.56-73.01 137.79-137.79c3.83 3.84 5.3 9.44 3.83 14.66l-19.9 70.92z",fill:"#ffb454"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9h-9c-8.28 0-15-6.72-15-15s6.72-15 15-15h9v-9c0-8.28 6.72-15 15-15s15 6.72 15 15v9h9c8.28 0 15 6.719 15 15z",fill:"#bee75e"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9l30-30h9c8.28 0 15 6.719 15 15z",fill:"#00cb75"}),React.createElement("path",{d:"m336 41.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#f6f9f9"}),React.createElement("path",{d:"m441 224.001c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9z",fill:"#e2dff4"}),React.createElement("path",{d:"m497 329.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff4a4a"}),React.createElement("path",{d:"m192 24.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff8659"}),React.createElement("path",{d:"m159.442 122.977-56-32c-7.191-4.109-16.355-1.611-20.466 5.581-4.11 7.193-1.611 16.355 5.581 20.466l56 32c7.16 4.093 16.337 1.644 20.466-5.581 4.111-7.193 1.612-16.355-5.581-20.466z",fill:"#f6f9f9"}),React.createElement("path",{d:"m118.14 169.117-64 8c-8.221 1.027-14.052 8.524-13.023 16.744 1.027 8.218 8.523 14.054 16.744 13.023l64-8c8.221-1.027 14.052-8.524 13.023-16.744-1.028-8.22-8.527-14.062-16.744-13.023z",fill:"#acceff"}),React.createElement("path",{d:"m389.023 352.558c-4.111-7.193-13.274-9.693-20.466-5.581-7.192 4.11-9.691 13.272-5.581 20.466l32 56c2.769 4.845 7.83 7.561 13.037 7.561 11.319 0 18.784-12.341 13.01-22.445z",fill:"#e2dff4"}),React.createElement("path",{d:"m329.86 377.117c-8.222-1.031-15.717 4.804-16.744 13.023l-8 64c-1.117 8.925 5.834 16.862 14.902 16.862 7.455 0 13.917-5.553 14.865-13.142l8-64c1.029-8.219-4.802-15.716-13.023-16.743z",fill:"#6ba7ff"}));const Er=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.icon,n=void 0===t?"ai":t,r=e.style,a=void 0===r?{}:r,o=gr((function(){switch(n){case"ai":default:return br;case"wand":return wr}}),[n]);return React.createElement("svg",{style:dr({width:20,height:20,marginRight:5},a),"enable-background":"new 0 0 512 512",height:"512",viewBox:"0 0 512 512",width:"512",xmlns:"http://www.w3.org/2000/svg"},o)};function Rr(e){return Rr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Rr(e)}function xr(){xr=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=m.prototype=h.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Rr(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=m,r(g,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:O(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function kr(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function _r(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){kr(o,r,a,i,c,"next",e)}function c(e){kr(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Or(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Lr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Lr(e,t):void 0}}(e,t)||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 Lr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Sr=wp.element,jr=Sr.useState,Pr=(Sr.useEffect,Sr.useMemo,wp.i18n.__),Cr=wp.plugins.registerPlugin,Tr=wp.components.Button,Ar=wp.editPost,Ir=Ar.PluginDocumentSettingPanel,Nr=Ar.PluginBlockSettingsMenuItem,Fr=function(){alert("Coming soon! Let me know your feedback and ideas, I will make this awesome for you.")};Cr("ai-engine-menu-paragraph-generate",{render:function(){return React.createElement(React.Fragment,null,React.createElement(Nr,{allowedBlocks:["core/paragraph"],icon:React.createElement(Er,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",Pr("Enhance text")),onClick:Fr}),React.createElement(Nr,{allowedBlocks:["core/paragraph"],icon:React.createElement(Er,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",Pr("Translate text")),onClick:Fr}))}});var zr=function(){var e=Or(jr(),2),t=e[0],n=e[1],r=Or(jr(),2),a=r[0],o=r[1],i=function(){var e=_r(xr().mark((function e(t){return xr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:wp.data.dispatch("core/editor").editPost({title:t});case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(){var e=_r(xr().mark((function e(t){return xr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:wp.data.dispatch("core/editor").editPost({excerpt:t});case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return React.createElement(Ir,{name:"mwai-document-settings",title:React.createElement(React.Fragment,null,React.createElement(Er,null)," AI Engine"),className:"mwai-document-settings"},React.createElement("p",null,"Generate:"),React.createElement("div",{style:{display:"flex"}},React.createElement(Tr,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,r=e.title;e.excerpt,n({postId:t,postTitle:r})},style:{flex:1,marginRight:10}},React.createElement(Er,{icon:"wand",style:{marginRight:8}})," Titles"),React.createElement(Tr,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,n=e.title;e.excerpt,o({postId:t,postTitle:n})},style:{flex:1}},React.createElement(Er,{icon:"wand",style:{marginRight:8}})," Excerpts")),React.createElement(v.o,null,React.createElement(yn,{post:t,onTitleClick:i,onClose:n}),React.createElement(hr,{post:a,onExcerptClick:c,onClose:o})))};var Gr=wp.element.render,Mr=new l.S({defaultOptions:{queries:{refetchOnWindowFocus:!1}}});document.addEventListener("DOMContentLoaded",(function(e){Cr("ai-engine-document-settings",{render:zr});var t=document.getElementById("mwai-admin-settings");t&&Gr(React.createElement(u.aH,{client:Mr},React.createElement(It,null)),t);var n=document.getElementById("mwai-content-generator");n&&Gr(React.createElement(Mn,null),n);var r=document.getElementById("mwai-image-generator");r&&Gr(React.createElement(tr,null),r);var a=document.getElementById("mwai-playground");a&&Gr(React.createElement(Qt,null),a);var o=document.getElementById("mwai-admin-postsList");o&&Gr(React.createElement(kn,null),o);var i=document.getElementById("meow-common-dashboard");i&&Gr(React.createElement(se,null),i)}))},7363:e=>{e.exports=React},1533:e=>{e.exports=ReactDOM}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}};return t[e].call(o.exports,o,o.exports,r),o.exports}r.m=t,r.amdO={},e=[],r.O=(t,n,a,o)=>{if(!n){var i=1/0;for(s=0;s<e.length;s++){n=e[s][0],a=e[s][1],o=e[s][2];for(var c=!0,l=0;l<n.length;l++)(!1&o||i>=o)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(c=!1,o<i&&(i=o));if(c){e.splice(s--,1);var u=a();void 0!==u&&(t=u)}}return t}o=o||0;for(var s=e.length;s>0&&e[s-1][2]>o;s--)e[s]=e[s-1];e[s]=[n,a,o]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={826:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,i=n[0],c=n[1],l=n[2],u=0;if(i.some((t=>0!==e[t]))){for(a in c)r.o(c,a)&&(r.m[a]=c[a]);if(l)var s=l(r)}for(t&&t(n);u<i.length;u++)o=i[u],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(s)},n=self.wpJsonMwai=self.wpJsonMwai||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.nc=void 0;var a=r.O(void 0,[736],(()=>r(5834)));a=r.O(a)})();
8 //# sourceMappingURL=index.js.map