Changeset 3448047
- Timestamp:
- 01/27/2026 04:31:26 PM (2 months ago)
- Location:
- websamurai/trunk
- Files:
-
- 12 edited
-
build/admin.asset.php (modified) (1 diff)
-
build/admin.css (modified) (1 diff)
-
build/admin.js (modified) (1 diff)
-
build/frontend.asset.php (modified) (1 diff)
-
build/frontend.css (modified) (1 diff)
-
build/frontend.js (modified) (1 diff)
-
inc/ajax-handler.php (modified) (3 diffs)
-
inc/oauth-handler.php (modified) (1 diff)
-
inc/samurai-site.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
src/frontend/App.jsx (modified) (9 diffs)
-
websamurai.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
websamurai/trunk/build/admin.asset.php
r3439610 r3448047 1 <?php return array('dependencies' => array('jquery', 'react', 'react-dom'), 'version' => ' c157e9863b8a163902e6');1 <?php return array('dependencies' => array('jquery', 'react', 'react-dom'), 'version' => '3a362d81851ad0274853'); -
websamurai/trunk/build/admin.css
r3439610 r3448047 1 /*!****************************************************************************************************************!*\2 !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/less-loader/dist/cjs.js!./src/admin/styles.less ***!3 \****************************************************************************************************************/4 1 /** 5 2 * Admin Styles -
websamurai/trunk/build/admin.js
r3439610 r3448047 1 /* 2 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). 3 * This devtool is neither made for production nor for readable output files. 4 * It uses "eval()" calls to create a separate source file in the browser devtools. 5 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) 6 * or disable the default devtool with "devtool: false". 7 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). 8 */ 9 /******/ (() => { // webpackBootstrap 10 /******/ "use strict"; 11 /******/ var __webpack_modules__ = ({ 12 13 /***/ "./node_modules/react-dom/client.js": 14 /*!******************************************!*\ 15 !*** ./node_modules/react-dom/client.js ***! 16 \******************************************/ 17 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 18 19 eval("{\n\nvar m = __webpack_require__(/*! react-dom */ \"react-dom\");\nif (false) // removed by dead control flow\n{} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react-dom/client.js?\n}"); 20 21 /***/ }), 22 23 /***/ "./node_modules/react/cjs/react-jsx-runtime.development.js": 24 /*!*****************************************************************!*\ 25 !*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***! 26 \*****************************************************************/ 27 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 28 29 eval("{/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n\nif (true) {\n (function() {\n'use strict';\n\nvar React = __webpack_require__(/*! react */ \"react\");\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"<anonymous>\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('<anonymous>')) {\n _frame = _frame.replace('<anonymous>', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie. <div {...props} key=\"Hi\" />\n // or <div key=\"Hi\" {...props} /> ). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n // <div {...props} key=\"Hi\" />, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nvar didWarnAboutKeySpread = {};\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n {\n if (hasOwnProperty.call(props, 'key')) {\n var componentName = getComponentNameFromType(type);\n var keys = Object.keys(props).filter(function (k) {\n return k !== 'key';\n });\n var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';\n\n if (!didWarnAboutKeySpread[componentName + beforeExample]) {\n var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';\n\n error('A props object containing a \"key\" prop is being spread into JSX:\\n' + ' let props = %s;\\n' + ' <%s {...props} />\\n' + 'React keys must be passed directly to JSX without using spread:\\n' + ' let props = %s;\\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);\n\n didWarnAboutKeySpread[componentName + beforeExample] = true;\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react/cjs/react-jsx-runtime.development.js?\n}"); 30 31 /***/ }), 32 33 /***/ "./node_modules/react/jsx-runtime.js": 34 /*!*******************************************!*\ 35 !*** ./node_modules/react/jsx-runtime.js ***! 36 \*******************************************/ 37 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 38 39 eval("{\n\nif (false) // removed by dead control flow\n{} else {\n module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ \"./node_modules/react/cjs/react-jsx-runtime.development.js\");\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react/jsx-runtime.js?\n}"); 40 41 /***/ }), 42 43 /***/ "./src/admin/App.jsx": 44 /*!***************************!*\ 45 !*** ./src/admin/App.jsx ***! 46 \***************************/ 47 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 48 49 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _components_ApiKeyManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/ApiKeyManager */ \"./src/admin/components/ApiKeyManager.jsx\");\n/* harmony import */ var _components_OAuthConnect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/OAuthConnect */ \"./src/admin/components/OAuthConnect.jsx\");\n/* harmony import */ var _components_PromptInstructions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/PromptInstructions */ \"./src/admin/components/PromptInstructions.jsx\");\n/* harmony import */ var _components_MediaGenerate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/MediaGenerate */ \"./src/admin/components/MediaGenerate.jsx\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * Admin App Component\n */\n\n\n\n\n\n\nvar App = function App() {\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('oauth'),\n _useState2 = _slicedToArray(_useState, 2),\n activeTab = _useState2[0],\n setActiveTab = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState4 = _slicedToArray(_useState3, 2),\n isConnected = _useState4[0],\n setIsConnected = _useState4[1];\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n checkConnectionStatus();\n }, []);\n var checkConnectionStatus = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var response, data, _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n _context.p = 0;\n _context.n = 1;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/oauth/status\"), {\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce\n }\n });\n case 1:\n response = _context.v;\n _context.n = 2;\n return response.json();\n case 2:\n data = _context.v;\n setIsConnected(data.connected || false);\n _context.n = 4;\n break;\n case 3:\n _context.p = 3;\n _t = _context.v;\n console.error('Error checking OAuth status:', _t);\n case 4:\n return _context.a(2);\n }\n }, _callee, null, [[0, 3]]);\n }));\n return function checkConnectionStatus() {\n return _ref.apply(this, arguments);\n };\n }();\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"websamurai-admin\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"websamurai-admin-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"h2\", {\n children: \"Samur AI Settings\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"p\", {\n children: \"Configure authentication and manage API keys\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"websamurai-tabs\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"tab-navigation\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"button\", {\n className: \"tab-button \".concat(activeTab === 'oauth' ? 'active' : ''),\n onClick: function onClick() {\n return setActiveTab('oauth');\n },\n children: \"OAuth Connection\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"button\", {\n className: \"tab-button \".concat(activeTab === 'api-keys' ? 'active' : ''),\n onClick: function onClick() {\n return setActiveTab('api-keys');\n },\n children: \"API Keys\"\n }), isConnected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"button\", {\n className: \"tab-button \".concat(activeTab === 'prompt-instructions' ? 'active' : ''),\n onClick: function onClick() {\n return setActiveTab('prompt-instructions');\n },\n children: \"Extra Prompt Instructions\"\n }), isConnected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(\"button\", {\n className: \"tab-button \".concat(activeTab === 'media-generate' ? 'active' : ''),\n onClick: function onClick() {\n return setActiveTab('media-generate');\n },\n children: \"Generate AI Image\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(\"div\", {\n className: \"tab-content\",\n children: [activeTab === 'oauth' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_OAuthConnect__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n onConnectionChange: checkConnectionStatus\n }), activeTab === 'api-keys' && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_ApiKeyManager__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {}), activeTab === 'prompt-instructions' && isConnected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_PromptInstructions__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {}), activeTab === 'media-generate' && isConnected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_MediaGenerate__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {})]\n })]\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://websamurai/./src/admin/App.jsx?\n}"); 50 51 /***/ }), 52 53 /***/ "./src/admin/components/ApiKeyManager.jsx": 54 /*!************************************************!*\ 55 !*** ./src/admin/components/ApiKeyManager.jsx ***! 56 \************************************************/ 57 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 58 59 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * API Key Manager Component\n */\n\n\nvar ApiKeyManager = function ApiKeyManager() {\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),\n _useState2 = _slicedToArray(_useState, 2),\n keys = _useState2[0],\n setKeys = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true),\n _useState4 = _slicedToArray(_useState3, 2),\n loading = _useState4[0],\n setLoading = _useState4[1];\n var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState6 = _slicedToArray(_useState5, 2),\n error = _useState6[0],\n setError = _useState6[1];\n var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState8 = _slicedToArray(_useState7, 2),\n newKeyName = _useState8[0],\n setNewKeyName = _useState8[1];\n var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState0 = _slicedToArray(_useState9, 2),\n generatedKey = _useState0[0],\n setGeneratedKey = _useState0[1];\n var _useState1 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState10 = _slicedToArray(_useState1, 2),\n generating = _useState10[0],\n setGenerating = _useState10[1];\n var _ref = window.samurAiAdmin || {},\n ajaxUrl = _ref.ajaxUrl,\n nonce = _ref.nonce,\n apiUrl = _ref.apiUrl;\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n fetchKeys();\n }, []);\n var fetchKeys = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var response, data, _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n _context.p = 0;\n setLoading(true);\n _context.n = 1;\n return fetch(\"\".concat(apiUrl, \"/api-keys\"), {\n headers: {\n 'X-WP-Nonce': nonce\n }\n });\n case 1:\n response = _context.v;\n if (response.ok) {\n _context.n = 2;\n break;\n }\n throw new Error('Failed to fetch API keys');\n case 2:\n _context.n = 3;\n return response.json();\n case 3:\n data = _context.v;\n setKeys(data);\n setError(null);\n _context.n = 5;\n break;\n case 4:\n _context.p = 4;\n _t = _context.v;\n setError(_t.message);\n case 5:\n _context.p = 5;\n setLoading(false);\n return _context.f(5);\n case 6:\n return _context.a(2);\n }\n }, _callee, null, [[0, 4, 5, 6]]);\n }));\n return function fetchKeys() {\n return _ref2.apply(this, arguments);\n };\n }();\n var generateKey = /*#__PURE__*/function () {\n var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {\n var response, data, _t2;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.p = _context2.n) {\n case 0:\n e.preventDefault();\n if (newKeyName.trim()) {\n _context2.n = 1;\n break;\n }\n setError('Please enter a name for the API key');\n return _context2.a(2);\n case 1:\n _context2.p = 1;\n setGenerating(true);\n setError(null);\n _context2.n = 2;\n return fetch(\"\".concat(apiUrl, \"/api-keys\"), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-WP-Nonce': nonce\n },\n body: JSON.stringify({\n name: newKeyName\n })\n });\n case 2:\n response = _context2.v;\n if (response.ok) {\n _context2.n = 3;\n break;\n }\n throw new Error('Failed to generate API key');\n case 3:\n _context2.n = 4;\n return response.json();\n case 4:\n data = _context2.v;\n setGeneratedKey(data);\n setNewKeyName('');\n _context2.n = 5;\n return fetchKeys();\n case 5:\n _context2.n = 7;\n break;\n case 6:\n _context2.p = 6;\n _t2 = _context2.v;\n setError(_t2.message);\n case 7:\n _context2.p = 7;\n setGenerating(false);\n return _context2.f(7);\n case 8:\n return _context2.a(2);\n }\n }, _callee2, null, [[1, 6, 7, 8]]);\n }));\n return function generateKey(_x) {\n return _ref3.apply(this, arguments);\n };\n }();\n var deleteKey = /*#__PURE__*/function () {\n var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(id) {\n var response, _t3;\n return _regenerator().w(function (_context3) {\n while (1) switch (_context3.p = _context3.n) {\n case 0:\n if (confirm('Are you sure you want to delete this API key?')) {\n _context3.n = 1;\n break;\n }\n return _context3.a(2);\n case 1:\n _context3.p = 1;\n _context3.n = 2;\n return fetch(\"\".concat(apiUrl, \"/api-keys/\").concat(id), {\n method: 'DELETE',\n headers: {\n 'X-WP-Nonce': nonce\n }\n });\n case 2:\n response = _context3.v;\n if (response.ok) {\n _context3.n = 3;\n break;\n }\n throw new Error('Failed to delete API key');\n case 3:\n _context3.n = 4;\n return fetchKeys();\n case 4:\n _context3.n = 6;\n break;\n case 5:\n _context3.p = 5;\n _t3 = _context3.v;\n setError(_t3.message);\n case 6:\n return _context3.a(2);\n }\n }, _callee3, null, [[1, 5]]);\n }));\n return function deleteKey(_x2) {\n return _ref4.apply(this, arguments);\n };\n }();\n var copyToClipboard = function copyToClipboard(text) {\n navigator.clipboard.writeText(text);\n alert('API key copied to clipboard!');\n };\n var closeGeneratedKey = function closeGeneratedKey() {\n setGeneratedKey(null);\n };\n if (loading && keys.length === 0) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"loading\",\n children: \"Loading API keys...\"\n });\n }\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"api-key-manager\",\n children: [error && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"notice notice-error\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: error\n })\n }), generatedKey && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"generated-key-modal\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"generated-key-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"API Key Generated Successfully!\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n className: \"warning-text\",\n children: \"Make sure to copy your API key now. You won't be able to see it again!\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"key-display\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"code\", {\n children: generatedKey.key\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-primary\",\n onClick: function onClick() {\n return copyToClipboard(generatedKey.key);\n },\n children: \"Copy Key\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"key-info\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"p\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Name:\"\n }), \" \", generatedKey.name]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"p\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Created:\"\n }), \" \", generatedKey.created]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button\",\n onClick: closeGeneratedKey,\n children: \"Close\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"generate-key-form\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Generate New API Key\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"form\", {\n onSubmit: generateKey,\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"form-group\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"label\", {\n htmlFor: \"key-name\",\n children: \"Key Name\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"input\", {\n type: \"text\",\n id: \"key-name\",\n className: \"regular-text\",\n value: newKeyName,\n onChange: function onChange(e) {\n return setNewKeyName(e.target.value);\n },\n placeholder: \"e.g., Production Server, Development\",\n disabled: generating\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n type: \"submit\",\n className: \"button button-primary\",\n disabled: generating,\n children: generating ? 'Generating...' : 'Generate API Key'\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"api-keys-list\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Existing API Keys\"\n }), keys.length === 0 ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"No API keys found. Generate one to get started.\"\n }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"table\", {\n className: \"wp-list-table widefat fixed striped\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"thead\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"th\", {\n children: \"Name\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"th\", {\n children: \"Key\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"th\", {\n children: \"Created\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"th\", {\n children: \"Last Used\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"th\", {\n children: \"Actions\"\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"tbody\", {\n children: keys.map(function (key) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"tr\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"td\", {\n children: key.name\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"td\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"code\", {\n children: key.key_prefix\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"td\", {\n children: key.created\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"td\", {\n children: key.last_used || 'Never'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"td\", {\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-small button-link-delete\",\n onClick: function onClick() {\n return deleteKey(key.id);\n },\n children: \"Delete\"\n })\n })]\n }, key.id);\n })\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"mcp-server-info\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"MCP Server Information\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"p\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Endpoint:\"\n }), \" \", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"code\", {\n children: [apiUrl, \"/mcp\"]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"To use this MCP server, include your API key in requests using either:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"ul\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"li\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"code\", {\n children: \"X-API-Key\"\n }), \" header\"]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"li\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"code\", {\n children: \"Authorization: Bearer YOUR_KEY\"\n }), \" header\"]\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"mcp-setup-help\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Help Setting Up\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"p\", {\n children: [\"To connect this MCP server to your AI chatbot (Claude Desktop, Cline, or other MCP-compatible clients), you'll need to configure the server endpoint and authentication. Generate an API key above, then follow the step-by-step instructions in our comprehensive setup guide.\", ' ', /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"a\", {\n href: \"https://websamurai.io/chatbot_setup/\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n className: \"setup-guide-link\",\n children: \"View Complete Setup Guide \\u2192\"\n })]\n })]\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ApiKeyManager);\n\n//# sourceURL=webpack://websamurai/./src/admin/components/ApiKeyManager.jsx?\n}"); 60 61 /***/ }), 62 63 /***/ "./src/admin/components/MediaGenerate.jsx": 64 /*!************************************************!*\ 65 !*** ./src/admin/components/MediaGenerate.jsx ***! 66 \************************************************/ 67 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 68 69 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jquery */ \"jquery\");\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * Media AI Image Generation Component\n */\n\n\n\nvar $ = (jquery__WEBPACK_IMPORTED_MODULE_1___default());\nvar MediaGenerate = function MediaGenerate() {\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState2 = _slicedToArray(_useState, 2),\n description = _useState2[0],\n setDescription = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState4 = _slicedToArray(_useState3, 2),\n statusMessage = _useState4[0],\n setStatusMessage = _useState4[1];\n var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState6 = _slicedToArray(_useState5, 2),\n imagePreview = _useState6[0],\n setImagePreview = _useState6[1];\n var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState8 = _slicedToArray(_useState7, 2),\n isGenerating = _useState8[0],\n setIsGenerating = _useState8[1];\n var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState0 = _slicedToArray(_useState9, 2),\n showAddButton = _useState0[0],\n setShowAddButton = _useState0[1];\n var _useState1 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState10 = _slicedToArray(_useState1, 2),\n showTryAgain = _useState10[0],\n setShowTryAgain = _useState10[1];\n var pollingIntervalRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n var conversationIdRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n return function () {\n // Cleanup polling on unmount\n if (pollingIntervalRef.current) {\n clearInterval(pollingIntervalRef.current);\n }\n };\n }, []);\n var showStatus = function showStatus(message) {\n var isError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n setStatusMessage(message);\n };\n var startPolling = function startPolling(conversationId) {\n var pollCount = 0;\n var maxPolls = 60; // Poll for up to 5 minutes (60 * 5 seconds)\n\n pollingIntervalRef.current = setInterval(function () {\n pollCount++;\n if (pollCount > maxPolls) {\n clearInterval(pollingIntervalRef.current);\n pollingIntervalRef.current = null;\n showStatus('Image generation timed out. Please try again.', true);\n setIsGenerating(false);\n setShowTryAgain(true);\n return;\n }\n\n // Make AJAX request to check status\n $.ajax({\n url: window.samurAiAdmin.ajaxUrl,\n type: 'POST',\n data: {\n action: 'websamurai_poll_image',\n nonce: window.samurAiAdmin.nonce,\n conversation_id: conversationId\n },\n success: function success(response) {\n if (response.success && response.data.conversation) {\n var conversation = response.data.conversation;\n\n // Check if DoneResponse is true\n if (conversation.DoneResponse === true || conversation.DoneResponse === 'true') {\n // Stop polling\n clearInterval(pollingIntervalRef.current);\n pollingIntervalRef.current = null;\n\n // Extract image URL from Prompt.prompts array\n var imageUrl = null;\n if (conversation.Prompt && conversation.Prompt.prompts && Array.isArray(conversation.Prompt.prompts)) {\n // Look for assistant role with content object containing image URL\n for (var i = 0; i < conversation.Prompt.prompts.length; i++) {\n var prompt = conversation.Prompt.prompts[i];\n if (prompt.role === 'assistant' && prompt.content && _typeof(prompt.content) === 'object') {\n if (prompt.content.url) {\n // Found the relative URL, prepend the base URL\n var relativeUrl = prompt.content.url;\n imageUrl = window.samurAiAdmin.oauthBaseUrl + relativeUrl;\n break;\n }\n }\n }\n }\n if (imageUrl) {\n showStatus('Image generated successfully!');\n setImagePreview(imageUrl);\n setIsGenerating(false);\n setShowAddButton(true);\n setShowTryAgain(true);\n } else {\n showStatus('Image generation completed but no image URL was returned.', true);\n setIsGenerating(false);\n setShowTryAgain(true);\n }\n } else {\n // Update status message\n showStatus('Generating image... (' + pollCount + ')');\n }\n }\n },\n error: function error() {\n // Continue polling even if there's an error\n }\n });\n }, 5000); // Poll every 5 seconds\n };\n var handleGenerate = function handleGenerate() {\n if (description.trim() === '') {\n alert('Please enter a description for the image.');\n return;\n }\n setIsGenerating(true);\n setShowAddButton(false);\n setShowTryAgain(false);\n setImagePreview('');\n showStatus('Starting image generation...');\n\n // Make AJAX request to generate image\n $.ajax({\n url: window.samurAiAdmin.ajaxUrl,\n type: 'POST',\n data: {\n action: 'websamurai_generate_image',\n nonce: window.samurAiAdmin.nonce,\n description: description\n },\n success: function success(response) {\n if (response.success && response.data.conversation) {\n conversationIdRef.current = response.data.conversation.id;\n showStatus('Image generation started. Please wait...');\n\n // Start polling for completion\n startPolling(response.data.conversation.id);\n } else {\n showStatus(response.data.message || 'Failed to start image generation.', true);\n setIsGenerating(false);\n setShowTryAgain(true);\n }\n },\n error: function error(xhr, status, _error) {\n showStatus('Error: ' + _error, true);\n setIsGenerating(false);\n setShowTryAgain(true);\n }\n });\n };\n var handleAddToLibrary = function handleAddToLibrary() {\n if (!imagePreview) {\n alert('No image to add.');\n return;\n }\n showStatus('Adding image to media library...');\n setShowAddButton(false);\n setShowTryAgain(false);\n\n // Make AJAX request to add image to library\n $.ajax({\n url: window.samurAiAdmin.ajaxUrl,\n type: 'POST',\n data: {\n action: 'websamurai_add_image_to_media',\n nonce: window.samurAiAdmin.nonce,\n image_url: imagePreview,\n description: description\n },\n success: function success(response) {\n if (response.success) {\n showStatus('Image added to media library successfully!');\n\n // Reset after 2 seconds\n setTimeout(function () {\n handleReset();\n }, 2000);\n } else {\n showStatus(response.data.message || 'Failed to add image to library.', true);\n setShowAddButton(true);\n setShowTryAgain(true);\n }\n },\n error: function error(xhr, status, _error2) {\n showStatus('Error: ' + _error2, true);\n setShowAddButton(true);\n setShowTryAgain(true);\n }\n });\n };\n var handleReset = function handleReset() {\n setDescription('');\n setStatusMessage('');\n setImagePreview('');\n setIsGenerating(false);\n setShowAddButton(false);\n setShowTryAgain(false);\n if (pollingIntervalRef.current) {\n clearInterval(pollingIntervalRef.current);\n pollingIntervalRef.current = null;\n }\n conversationIdRef.current = null;\n };\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(\"div\", {\n className: \"websamurai-generate-container\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(\"div\", {\n className: \"websamurai-generate-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"h2\", {\n children: \"Generate Image with AI\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"p\", {\n children: \"Describe the image you want to create and our AI will generate it for you.\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(\"div\", {\n className: \"websamurai-generate-body\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(\"div\", {\n className: \"websamurai-input-group\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"label\", {\n htmlFor: \"websamurai-description\",\n children: \"Image Description:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"textarea\", {\n id: \"websamurai-description\",\n className: \"websamurai-textarea\",\n placeholder: \"e.g., A serene landscape with mountains and a lake at sunset\",\n rows: \"4\",\n value: description,\n onChange: function onChange(e) {\n return setDescription(e.target.value);\n },\n disabled: isGenerating\n })]\n }), statusMessage && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"div\", {\n className: \"websamurai-status\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"p\", {\n children: statusMessage\n })\n }), imagePreview && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"div\", {\n className: \"websamurai-preview\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"img\", {\n src: imagePreview,\n alt: \"Generated\"\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(\"div\", {\n className: \"websamurai-actions\",\n children: [!isGenerating && !showAddButton && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"button\", {\n type: \"button\",\n className: \"button button-primary button-large websamurai-generate-btn\",\n onClick: handleGenerate,\n children: \"Generate Image\"\n }), isGenerating && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"button\", {\n type: \"button\",\n className: \"button button-primary button-large websamurai-generate-btn\",\n disabled: true,\n children: \"Generating...\"\n }), showAddButton && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"button\", {\n type: \"button\",\n className: \"button button-primary button-large websamurai-add-btn\",\n onClick: handleAddToLibrary,\n children: \"Add to Library\"\n }), showTryAgain && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(\"button\", {\n type: \"button\",\n className: \"button button-large websamurai-retry-btn\",\n onClick: handleReset,\n children: \"Try Again\"\n })]\n })]\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MediaGenerate);\n\n//# sourceURL=webpack://websamurai/./src/admin/components/MediaGenerate.jsx?\n}"); 70 71 /***/ }), 72 73 /***/ "./src/admin/components/OAuthConnect.jsx": 74 /*!***********************************************!*\ 75 !*** ./src/admin/components/OAuthConnect.jsx ***! 76 \***********************************************/ 77 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 78 79 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * OAuth Connect Component\n */\n\n\nvar OAuthConnect = function OAuthConnect(_ref) {\n var onConnectionChange = _ref.onConnectionChange;\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState2 = _slicedToArray(_useState, 2),\n isConnected = _useState2[0],\n setIsConnected = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true),\n _useState4 = _slicedToArray(_useState3, 2),\n isLoading = _useState4[0],\n setIsLoading = _useState4[1];\n var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState6 = _slicedToArray(_useState5, 2),\n connectionStatus = _useState6[0],\n setConnectionStatus = _useState6[1];\n var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState8 = _slicedToArray(_useState7, 2),\n error = _useState8[0],\n setError = _useState8[1];\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n checkConnectionStatus();\n }, []);\n var checkConnectionStatus = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var response, data, _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n setIsLoading(true);\n setError(null);\n _context.p = 1;\n _context.n = 2;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/oauth/status\"), {\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce\n }\n });\n case 2:\n response = _context.v;\n _context.n = 3;\n return response.json();\n case 3:\n data = _context.v;\n if (data.connected) {\n setIsConnected(true);\n setConnectionStatus(data);\n }\n\n // Notify parent of connection change\n if (onConnectionChange) {\n onConnectionChange();\n }\n _context.n = 5;\n break;\n case 4:\n _context.p = 4;\n _t = _context.v;\n console.error('Error checking OAuth status:', _t);\n case 5:\n _context.p = 5;\n setIsLoading(false);\n return _context.f(5);\n case 6:\n return _context.a(2);\n }\n }, _callee, null, [[1, 4, 5, 6]]);\n }));\n return function checkConnectionStatus() {\n return _ref2.apply(this, arguments);\n };\n }();\n var handleConnect = function handleConnect() {\n setError(null);\n\n // Build OAuth URL using localized base URL\n var callbackUrl = \"\".concat(window.location.origin, \"/samuraiauth/?nonce=\").concat(window.samurAiAdmin.nonce);\n var oauthBaseUrl = window.samurAiAdmin.oauthBaseUrl || 'https://cp.websamurai.io';\n var oauthUrl = \"\".concat(oauthBaseUrl, \"/oauth/auth/?callback=\").concat(encodeURIComponent(callbackUrl));\n\n // Redirect to OAuth provider\n window.location.href = oauthUrl;\n };\n var handleRefresh = /*#__PURE__*/function () {\n var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {\n var response, data, _t2;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.p = _context2.n) {\n case 0:\n setIsLoading(true);\n setError(null);\n _context2.p = 1;\n _context2.n = 2;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/oauth/refresh\"), {\n method: 'POST',\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce,\n 'Content-Type': 'application/json'\n }\n });\n case 2:\n response = _context2.v;\n _context2.n = 3;\n return response.json();\n case 3:\n data = _context2.v;\n if (!data.success) {\n _context2.n = 5;\n break;\n }\n _context2.n = 4;\n return checkConnectionStatus();\n case 4:\n _context2.n = 6;\n break;\n case 5:\n setError(data.message || 'Failed to refresh user data');\n case 6:\n _context2.n = 8;\n break;\n case 7:\n _context2.p = 7;\n _t2 = _context2.v;\n setError('An error occurred while refreshing user data');\n console.error('Error refreshing:', _t2);\n case 8:\n _context2.p = 8;\n setIsLoading(false);\n return _context2.f(8);\n case 9:\n return _context2.a(2);\n }\n }, _callee2, null, [[1, 7, 8, 9]]);\n }));\n return function handleRefresh() {\n return _ref3.apply(this, arguments);\n };\n }();\n var handleDisconnect = /*#__PURE__*/function () {\n var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {\n var response, data, _t3;\n return _regenerator().w(function (_context3) {\n while (1) switch (_context3.p = _context3.n) {\n case 0:\n if (confirm('Are you sure you want to disconnect from cp.websamurai.io?')) {\n _context3.n = 1;\n break;\n }\n return _context3.a(2);\n case 1:\n setIsLoading(true);\n setError(null);\n _context3.p = 2;\n _context3.n = 3;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/oauth/disconnect\"), {\n method: 'POST',\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce,\n 'Content-Type': 'application/json'\n }\n });\n case 3:\n response = _context3.v;\n _context3.n = 4;\n return response.json();\n case 4:\n data = _context3.v;\n if (data.success) {\n setIsConnected(false);\n setConnectionStatus(null);\n\n // Notify parent of connection change\n if (onConnectionChange) {\n onConnectionChange();\n }\n } else {\n setError(data.message || 'Failed to disconnect');\n }\n _context3.n = 6;\n break;\n case 5:\n _context3.p = 5;\n _t3 = _context3.v;\n setError('An error occurred while disconnecting');\n console.error('Error disconnecting:', _t3);\n case 6:\n _context3.p = 6;\n setIsLoading(false);\n return _context3.f(6);\n case 7:\n return _context3.a(2);\n }\n }, _callee3, null, [[2, 5, 6, 7]]);\n }));\n return function handleDisconnect() {\n return _ref4.apply(this, arguments);\n };\n }();\n if (isLoading) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"oauth-connect\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"loading\",\n children: \"Loading connection status...\"\n })\n });\n }\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-connect\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Connect to Service\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"Authenticate with your SamuraiWP Control Panel account to enable advanced AI features and synchronization.\"\n })]\n }), error && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-error\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Error:\"\n }), \" \", error]\n }), isConnected ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-connected\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"status-badge connected\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"status-icon\",\n children: \"\\u2713\"\n }), \"Connected\"]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"connection-info\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"connection-info-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h4\", {\n children: \"Connection Details\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-small oauth-refresh\",\n onClick: handleRefresh,\n disabled: isLoading,\n title: \"Refresh user data from server\",\n children: \"\\u21BB Refresh\"\n })]\n }), connectionStatus && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"dl\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"Connected:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.connected_at ? new Date(connectionStatus.connected_at).toLocaleString() : 'N/A'\n }), connectionStatus.user_data && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.Fragment, {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"User ID:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.user_data.id || 'N/A'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"Name:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"dd\", {\n children: [connectionStatus.user_data.FirstName, ' ', connectionStatus.user_data.LastName]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"Login ID:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.user_data.LoginID || 'N/A'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"User Email:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.user_data.Email || 'N/A'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"Role:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.user_data.RoleList || 'N/A'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dt\", {\n children: \"Last Refreshed:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"dd\", {\n children: connectionStatus.refreshed_at ? new Date(connectionStatus.refreshed_at).toLocaleString() : 'Never'\n })]\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-secondary oauth-disconnect\",\n onClick: handleDisconnect,\n disabled: isLoading,\n children: \"Disconnect\"\n })]\n }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-disconnected\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"status-badge disconnected\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"status-icon\",\n children: \"\\u25CB\"\n }), \"Not Connected\"]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"oauth-benefits\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h4\", {\n children: \"Benefits of Connecting:\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"ul\", {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"li\", {\n children: \"Access advanced AI models and features\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"li\", {\n children: \"Sync your settings across multiple sites\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"li\", {\n children: \"Automatic updates and improvements\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"li\", {\n children: \"Priority support and assistance\"\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-primary oauth-connect-btn\",\n onClick: handleConnect,\n disabled: isLoading,\n children: \"Connect to Service\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n className: \"oauth-privacy\",\n children: \"Your authentication is secure and encrypted. We only access the information necessary to provide our services.\"\n })]\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (OAuthConnect);\n\n//# sourceURL=webpack://websamurai/./src/admin/components/OAuthConnect.jsx?\n}"); 80 81 /***/ }), 82 83 /***/ "./src/admin/components/PromptInstructions.jsx": 84 /*!*****************************************************!*\ 85 !*** ./src/admin/components/PromptInstructions.jsx ***! 86 \*****************************************************/ 87 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 88 89 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * Prompt Instructions Component\n */\n\n\nvar PromptInstructions = function PromptInstructions() {\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true),\n _useState2 = _slicedToArray(_useState, 2),\n isLoading = _useState2[0],\n setIsLoading = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState4 = _slicedToArray(_useState3, 2),\n isSaving = _useState4[0],\n setIsSaving = _useState4[1];\n var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState6 = _slicedToArray(_useState5, 2),\n error = _useState6[0],\n setError = _useState6[1];\n var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState8 = _slicedToArray(_useState7, 2),\n success = _useState8[0],\n setSuccess = _useState8[1];\n var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState0 = _slicedToArray(_useState9, 2),\n promptInstructions = _useState0[0],\n setPromptInstructions = _useState0[1];\n var _useState1 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState10 = _slicedToArray(_useState1, 2),\n promptInstructionsImage = _useState10[0],\n setPromptInstructionsImage = _useState10[1];\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n loadPromptInstructions();\n }, []);\n var loadPromptInstructions = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var response, data, _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n setIsLoading(true);\n setError(null);\n _context.p = 1;\n _context.n = 2;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/prompt-instructions\"), {\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce\n }\n });\n case 2:\n response = _context.v;\n _context.n = 3;\n return response.json();\n case 3:\n data = _context.v;\n if (data.success) {\n setPromptInstructions(data.data.PromptInstructions || '');\n setPromptInstructionsImage(data.data.PromptInstructionsImage || '');\n } else {\n setError(data.message || 'Failed to load prompt instructions');\n }\n _context.n = 5;\n break;\n case 4:\n _context.p = 4;\n _t = _context.v;\n setError('An error occurred while loading prompt instructions');\n console.error('Error loading prompt instructions:', _t);\n case 5:\n _context.p = 5;\n setIsLoading(false);\n return _context.f(5);\n case 6:\n return _context.a(2);\n }\n }, _callee, null, [[1, 4, 5, 6]]);\n }));\n return function loadPromptInstructions() {\n return _ref.apply(this, arguments);\n };\n }();\n var handleSave = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {\n var response, data, _t2;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.p = _context2.n) {\n case 0:\n setIsSaving(true);\n setError(null);\n setSuccess(null);\n _context2.p = 1;\n _context2.n = 2;\n return fetch(\"\".concat(window.samurAiAdmin.apiUrl, \"/prompt-instructions\"), {\n method: 'POST',\n headers: {\n 'X-WP-Nonce': window.samurAiAdmin.nonce,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n promptInstructions: promptInstructions,\n promptInstructionsImage: promptInstructionsImage\n })\n });\n case 2:\n response = _context2.v;\n _context2.n = 3;\n return response.json();\n case 3:\n data = _context2.v;\n if (data.success) {\n setSuccess('Prompt instructions saved successfully!');\n setTimeout(function () {\n return setSuccess(null);\n }, 3000);\n } else {\n setError(data.message || 'Failed to save prompt instructions');\n }\n _context2.n = 5;\n break;\n case 4:\n _context2.p = 4;\n _t2 = _context2.v;\n setError('An error occurred while saving prompt instructions');\n console.error('Error saving prompt instructions:', _t2);\n case 5:\n _context2.p = 5;\n setIsSaving(false);\n return _context2.f(5);\n case 6:\n return _context2.a(2);\n }\n }, _callee2, null, [[1, 4, 5, 6]]);\n }));\n return function handleSave() {\n return _ref2.apply(this, arguments);\n };\n }();\n if (isLoading) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"prompt-instructions\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"loading\",\n children: \"Loading prompt instructions...\"\n })\n });\n }\n\n // If there was an error loading, only show the error message\n if (error && !success) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Extra Prompt Instructions\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"Configure additional instructions that will be sent with AI prompts for text and image generation.\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions-error\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Error:\"\n }), \" \", error]\n })]\n });\n }\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Extra Prompt Instructions\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"Configure additional instructions that will be sent with AI prompts for text and image generation.\"\n })]\n }), success && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions-success\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Success:\"\n }), \" \", success]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"prompt-instructions-fields\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"field-group\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"label\", {\n htmlFor: \"prompt-instructions\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Prompt Instructions\"\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n className: \"field-description\",\n children: \"Additional instructions for general AI text generation prompts.\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"textarea\", {\n id: \"prompt-instructions\",\n className: \"large-text\",\n rows: \"8\",\n value: promptInstructions,\n onChange: function onChange(e) {\n return setPromptInstructions(e.target.value);\n },\n placeholder: \"Enter additional prompt instructions for text generation...\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"field-group\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"label\", {\n htmlFor: \"prompt-instructions-image\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"strong\", {\n children: \"Prompt Instructions (Image)\"\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n className: \"field-description\",\n children: \"Additional instructions for AI image generation prompts.\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"textarea\", {\n id: \"prompt-instructions-image\",\n className: \"large-text\",\n rows: \"8\",\n value: promptInstructionsImage,\n onChange: function onChange(e) {\n return setPromptInstructionsImage(e.target.value);\n },\n placeholder: \"Enter additional prompt instructions for image generation...\"\n })]\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"prompt-instructions-actions\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"button button-primary\",\n onClick: handleSave,\n disabled: isSaving,\n children: isSaving ? 'Saving...' : 'Save Prompt Instructions'\n })\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PromptInstructions);\n\n//# sourceURL=webpack://websamurai/./src/admin/components/PromptInstructions.jsx?\n}"); 90 91 /***/ }), 92 93 /***/ "./src/admin/index.js": 94 /*!****************************!*\ 95 !*** ./src/admin/index.js ***! 96 \****************************/ 97 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 98 99 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom/client */ \"./node_modules/react-dom/client.js\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./App */ \"./src/admin/App.jsx\");\n/* harmony import */ var _components_MediaGenerate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/MediaGenerate */ \"./src/admin/components/MediaGenerate.jsx\");\n/* harmony import */ var _styles_less__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./styles.less */ \"./src/admin/styles.less\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/**\n * Admin entry point\n */\n\n\n\n\n\n// Initialize the app when DOM is ready\n\ndocument.addEventListener('DOMContentLoaded', function () {\n var container = document.getElementById('websamurai-admin-root');\n if (container) {\n var root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_0__.createRoot)(container);\n root.render(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_App__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {}));\n }\n var mediaGrid = document.querySelector(\".wp-admin.wp-core-ui.upload-php #wp-media-grid\");\n if (mediaGrid) {\n console.log(\"Adding Generate AI Image button to Media Library toolbar\");\n var button = document.createElement(\"button\");\n button.className = \"websamurai-generate-image-btn\";\n button.innerText = \"Generate AI Image\";\n button.onclick = function (e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('stop');\n var modal = document.querySelector('#websamurai-ai-image-modal-trigger');\n if (!modal) {\n modal = document.createElement('div');\n modal.id = 'websamurai-ai-image-modal-trigger';\n modal.onclick = function (e) {\n if (e.target.id === 'websamurai-ai-image-modal-trigger') {\n modal.remove();\n }\n };\n document.body.appendChild(modal);\n }\n var root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_0__.createRoot)(modal);\n root.render(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_components_MediaGenerate__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {}));\n };\n if (mediaGrid) {\n mediaGrid.childNodes[1].after(button);\n }\n }\n});\n\n//# sourceURL=webpack://websamurai/./src/admin/index.js?\n}"); 100 101 /***/ }), 102 103 /***/ "./src/admin/styles.less": 104 /*!*******************************!*\ 105 !*** ./src/admin/styles.less ***! 106 \*******************************/ 107 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 108 109 eval("{__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://websamurai/./src/admin/styles.less?\n}"); 110 111 /***/ }), 112 113 /***/ "jquery": 114 /*!*************************!*\ 115 !*** external "jQuery" ***! 116 \*************************/ 117 /***/ ((module) => { 118 119 module.exports = window["jQuery"]; 120 121 /***/ }), 122 123 /***/ "react": 124 /*!************************!*\ 125 !*** external "React" ***! 126 \************************/ 127 /***/ ((module) => { 128 129 module.exports = window["React"]; 130 131 /***/ }), 132 133 /***/ "react-dom": 134 /*!***************************!*\ 135 !*** external "ReactDOM" ***! 136 \***************************/ 137 /***/ ((module) => { 138 139 module.exports = window["ReactDOM"]; 140 141 /***/ }) 142 143 /******/ }); 144 /************************************************************************/ 145 /******/ // The module cache 146 /******/ var __webpack_module_cache__ = {}; 147 /******/ 148 /******/ // The require function 149 /******/ function __webpack_require__(moduleId) { 150 /******/ // Check if module is in cache 151 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 152 /******/ if (cachedModule !== undefined) { 153 /******/ return cachedModule.exports; 154 /******/ } 155 /******/ // Create a new module (and put it into the cache) 156 /******/ var module = __webpack_module_cache__[moduleId] = { 157 /******/ // no module.id needed 158 /******/ // no module.loaded needed 159 /******/ exports: {} 160 /******/ }; 161 /******/ 162 /******/ // Execute the module function 163 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 164 /******/ 165 /******/ // Return the exports of the module 166 /******/ return module.exports; 167 /******/ } 168 /******/ 169 /************************************************************************/ 170 /******/ /* webpack/runtime/compat get default export */ 171 /******/ (() => { 172 /******/ // getDefaultExport function for compatibility with non-harmony modules 173 /******/ __webpack_require__.n = (module) => { 174 /******/ var getter = module && module.__esModule ? 175 /******/ () => (module['default']) : 176 /******/ () => (module); 177 /******/ __webpack_require__.d(getter, { a: getter }); 178 /******/ return getter; 179 /******/ }; 180 /******/ })(); 181 /******/ 182 /******/ /* webpack/runtime/define property getters */ 183 /******/ (() => { 184 /******/ // define getter functions for harmony exports 185 /******/ __webpack_require__.d = (exports, definition) => { 186 /******/ for(var key in definition) { 187 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 188 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 189 /******/ } 190 /******/ } 191 /******/ }; 192 /******/ })(); 193 /******/ 194 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 195 /******/ (() => { 196 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 197 /******/ })(); 198 /******/ 199 /******/ /* webpack/runtime/make namespace object */ 200 /******/ (() => { 201 /******/ // define __esModule on exports 202 /******/ __webpack_require__.r = (exports) => { 203 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 204 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 205 /******/ } 206 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 207 /******/ }; 208 /******/ })(); 209 /******/ 210 /************************************************************************/ 211 /******/ 212 /******/ // startup 213 /******/ // Load entry module and return exports 214 /******/ // This entry module can't be inlined because the eval devtool is used. 215 /******/ var __webpack_exports__ = __webpack_require__("./src/admin/index.js"); 216 /******/ 217 /******/ })() 218 ; 1 /*! For license information please see admin.js.LICENSE.txt */ 2 (()=>{"use strict";var e={20:(e,t,n)=>{var r=n(609),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,n){var r,a={},u=null,l=null;for(r in void 0!==n&&(u=""+n),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)i.call(t,r)&&!s.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:o,type:e,key:u,ref:l,props:a,_owner:c.current}}t.Fragment=a,t.jsx=u,t.jsxs=u},338:(e,t,n)=>{var r=n(795);t.H=r.createRoot,r.hydrateRoot},609:e=>{e.exports=window.React},795:e=>{e.exports=window.ReactDOM},848:(e,t,n)=>{e.exports=n(20)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=n(338),o=n(609),a=n(848);function i(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var i=r&&r.prototype instanceof u?r:u,l=Object.create(i.prototype);return c(l,"_invoke",function(n,r,o){var a,i,c,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,i=0,c=e,f.n=n,s}};function p(n,r){for(i=n,c=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(c=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(i=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,i=0))}if(o||n>1)return s;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),i=l,c=m;(t=i<2?e:c)||!d;){a||(i?i<3?(i>1&&(f.n=-1),p(i,c)):f.n=c:f.v=c);try{if(u=2,a){if(i||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,i<2&&(i=0)}else 1===i&&(t=a.return)&&t.call(a),i<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==s)break}catch(t){a=e,i=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),l}var s={};function u(){}function l(){}function d(){}t=Object.getPrototypeOf;var f=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return l.prototype=d,c(p,"constructor",d),c(d,"constructor",l),l.displayName="GeneratorFunction",c(d,o,"GeneratorFunction"),c(p),c(p,o,"Generator"),c(p,r,function(){return this}),c(p,"toString",function(){return"[object Generator]"}),(i=function(){return{w:a,m}})()}function c(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,n,r){function a(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},c(e,t,n,r)}function s(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,c,"next",e)}function c(e){s(a,r,o,i,c,"throw",e)}i(void 0)})}}function l(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,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n={}.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}}(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 d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const f=function(){var e=l((0,o.useState)([]),2),t=e[0],n=e[1],r=l((0,o.useState)(!0),2),c=r[0],s=r[1],d=l((0,o.useState)(null),2),f=d[0],p=d[1],m=l((0,o.useState)(""),2),h=m[0],v=m[1],y=l((0,o.useState)(null),2),b=y[0],j=y[1],g=l((0,o.useState)(!1),2),x=g[0],w=g[1],A=window.samurAiAdmin||{},N=(A.ajaxUrl,A.nonce),S=A.apiUrl;(0,o.useEffect)(function(){k()},[]);var k=function(){var e=u(i().m(function e(){var t,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,s(!0),e.n=1,fetch("".concat(S,"/api-keys"),{headers:{"X-WP-Nonce":N}});case 1:if((t=e.v).ok){e.n=2;break}throw new Error("Failed to fetch API keys");case 2:return e.n=3,t.json();case 3:r=e.v,n(r),p(null),e.n=5;break;case 4:e.p=4,o=e.v,p(o.message);case 5:return e.p=5,s(!1),e.f(5);case 6:return e.a(2)}},e,null,[[0,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),P=function(){var e=u(i().m(function e(t){var n,r,o;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),h.trim()){e.n=1;break}return p("Please enter a name for the API key"),e.a(2);case 1:return e.p=1,w(!0),p(null),e.n=2,fetch("".concat(S,"/api-keys"),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":N},body:JSON.stringify({name:h})});case 2:if((n=e.v).ok){e.n=3;break}throw new Error("Failed to generate API key");case 3:return e.n=4,n.json();case 4:return r=e.v,j(r),v(""),e.n=5,k();case 5:e.n=7;break;case 6:e.p=6,o=e.v,p(o.message);case 7:return e.p=7,w(!1),e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}));return function(t){return e.apply(this,arguments)}}(),I=function(){var e=u(i().m(function e(t){var n;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to delete this API key?")){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,fetch("".concat(S,"/api-keys/").concat(t),{method:"DELETE",headers:{"X-WP-Nonce":N}});case 2:if(e.v.ok){e.n=3;break}throw new Error("Failed to delete API key");case 3:return e.n=4,k();case 4:e.n=6;break;case 5:e.p=5,n=e.v,p(n.message);case 6:return e.a(2)}},e,null,[[1,5]])}));return function(t){return e.apply(this,arguments)}}();return c&&0===t.length?(0,a.jsx)("div",{className:"loading",children:"Loading API keys..."}):(0,a.jsxs)("div",{className:"api-key-manager",children:[f&&(0,a.jsx)("div",{className:"notice notice-error",children:(0,a.jsx)("p",{children:f})}),b&&(0,a.jsx)("div",{className:"generated-key-modal",children:(0,a.jsxs)("div",{className:"generated-key-content",children:[(0,a.jsx)("h3",{children:"API Key Generated Successfully!"}),(0,a.jsx)("p",{className:"warning-text",children:"Make sure to copy your API key now. You won't be able to see it again!"}),(0,a.jsxs)("div",{className:"key-display",children:[(0,a.jsx)("code",{children:b.key}),(0,a.jsx)("button",{className:"button button-primary",onClick:function(){return e=b.key,navigator.clipboard.writeText(e),void alert("API key copied to clipboard!");var e},children:"Copy Key"})]}),(0,a.jsxs)("div",{className:"key-info",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Name:"})," ",b.name]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Created:"})," ",b.created]})]}),(0,a.jsx)("button",{className:"button",onClick:function(){j(null)},children:"Close"})]})}),(0,a.jsxs)("div",{className:"generate-key-form",children:[(0,a.jsx)("h3",{children:"Generate New API Key"}),(0,a.jsxs)("form",{onSubmit:P,children:[(0,a.jsxs)("div",{className:"form-group",children:[(0,a.jsx)("label",{htmlFor:"key-name",children:"Key Name"}),(0,a.jsx)("input",{type:"text",id:"key-name",className:"regular-text",value:h,onChange:function(e){return v(e.target.value)},placeholder:"e.g., Production Server, Development",disabled:x})]}),(0,a.jsx)("button",{type:"submit",className:"button button-primary",disabled:x,children:x?"Generating...":"Generate API Key"})]})]}),(0,a.jsxs)("div",{className:"api-keys-list",children:[(0,a.jsx)("h3",{children:"Existing API Keys"}),0===t.length?(0,a.jsx)("p",{children:"No API keys found. Generate one to get started."}):(0,a.jsxs)("table",{className:"wp-list-table widefat fixed striped",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Key"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Last Used"}),(0,a.jsx)("th",{children:"Actions"})]})}),(0,a.jsx)("tbody",{children:t.map(function(e){return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:e.name}),(0,a.jsx)("td",{children:(0,a.jsx)("code",{children:e.key_prefix})}),(0,a.jsx)("td",{children:e.created}),(0,a.jsx)("td",{children:e.last_used||"Never"}),(0,a.jsx)("td",{children:(0,a.jsx)("button",{className:"button button-small button-link-delete",onClick:function(){return I(e.id)},children:"Delete"})})]},e.id)})})]})]}),(0,a.jsxs)("div",{className:"mcp-server-info",children:[(0,a.jsx)("h3",{children:"MCP Server Information"}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Endpoint:"})," ",(0,a.jsxs)("code",{children:[S,"/mcp"]})]}),(0,a.jsx)("p",{children:"To use this MCP server, include your API key in requests using either:"}),(0,a.jsxs)("ul",{children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"X-API-Key"})," header"]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:"Authorization: Bearer YOUR_KEY"})," header"]})]})]}),(0,a.jsxs)("div",{className:"mcp-setup-help",children:[(0,a.jsx)("h3",{children:"Help Setting Up"}),(0,a.jsxs)("p",{children:["To connect this MCP server to your AI chatbot (Claude Desktop, Cline, or other MCP-compatible clients), you'll need to configure the server endpoint and authentication. Generate an API key above, then follow the step-by-step instructions in our comprehensive setup guide."," ",(0,a.jsx)("a",{href:"https://websamurai.io/chatbot_setup/",target:"_blank",rel:"noopener noreferrer",className:"setup-guide-link",children:"View Complete Setup Guide →"})]})]})]})};function p(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return m(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(m(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,m(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,m(d,"constructor",u),m(u,"constructor",s),s.displayName="GeneratorFunction",m(u,o,"GeneratorFunction"),m(d),m(d,o,"Generator"),m(d,r,function(){return this}),m(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:a,m:f}})()}function m(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}m=function(e,t,n,r){function a(t,n){m(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},m(e,t,n,r)}function h(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){h(a,r,o,i,c,"next",e)}function c(e){h(a,r,o,i,c,"throw",e)}i(void 0)})}}function y(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,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.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)?b(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 b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const j=function(e){var t=e.onConnectionChange,n=y((0,o.useState)(!1),2),r=n[0],i=n[1],c=y((0,o.useState)(!0),2),s=c[0],u=c[1],l=y((0,o.useState)(null),2),d=l[0],f=l[1],m=y((0,o.useState)(null),2),h=m[0],b=m[1];(0,o.useEffect)(function(){j()},[]);var j=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return n=e.v,e.n=3,n.json();case 3:(r=e.v).connected&&(i(!0),f(r)),t&&t(),e.n=5;break;case 4:e.p=4,o=e.v,console.error("Error checking OAuth status:",o);case 5:return e.p=5,u(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),g=function(){var e=v(p().m(function e(){var t,n,r;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return u(!0),b(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/refresh"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 2:return t=e.v,e.n=3,t.json();case 3:if(!(n=e.v).success){e.n=5;break}return e.n=4,j();case 4:e.n=6;break;case 5:b(n.message||"Failed to refresh user data");case 6:e.n=8;break;case 7:e.p=7,r=e.v,b("An error occurred while refreshing user data"),console.error("Error refreshing:",r);case 8:return e.p=8,u(!1),e.f(8);case 9:return e.a(2)}},e,null,[[1,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),x=function(){var e=v(p().m(function e(){var n,r,o;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("Are you sure you want to disconnect from cp.websamurai.io?")){e.n=1;break}return e.a(2);case 1:return u(!0),b(null),e.p=2,e.n=3,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/disconnect"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"}});case 3:return n=e.v,e.n=4,n.json();case 4:(r=e.v).success?(i(!1),f(null),t&&t()):b(r.message||"Failed to disconnect"),e.n=6;break;case 5:e.p=5,o=e.v,b("An error occurred while disconnecting"),console.error("Error disconnecting:",o);case 6:return e.p=6,u(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}();return s?(0,a.jsx)("div",{className:"oauth-connect",children:(0,a.jsx)("div",{className:"loading",children:"Loading connection status..."})}):(0,a.jsxs)("div",{className:"oauth-connect",children:[(0,a.jsxs)("div",{className:"oauth-header",children:[(0,a.jsx)("h3",{children:"Connect to Service"}),(0,a.jsx)("p",{children:"Authenticate with your SamuraiWP Control Panel account to enable advanced AI features and synchronization."})]}),h&&(0,a.jsxs)("div",{className:"oauth-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",h]}),r?(0,a.jsxs)("div",{className:"oauth-connected",children:[(0,a.jsxs)("div",{className:"status-badge connected",children:[(0,a.jsx)("span",{className:"status-icon",children:"✓"}),"Connected"]}),(0,a.jsxs)("div",{className:"connection-info",children:[(0,a.jsxs)("div",{className:"connection-info-header",children:[(0,a.jsx)("h4",{children:"Connection Details"}),(0,a.jsx)("button",{className:"button button-small oauth-refresh",onClick:g,disabled:s,title:"Refresh user data from server",children:"↻ Refresh"})]}),d&&(0,a.jsxs)("dl",{children:[(0,a.jsx)("dt",{children:"Connected:"}),(0,a.jsx)("dd",{children:d.connected_at?new Date(d.connected_at).toLocaleString():"N/A"}),d.user_data&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:"User ID:"}),(0,a.jsx)("dd",{children:d.user_data.id||"N/A"}),(0,a.jsx)("dt",{children:"Name:"}),(0,a.jsxs)("dd",{children:[d.user_data.FirstName," ",d.user_data.LastName]}),(0,a.jsx)("dt",{children:"Login ID:"}),(0,a.jsx)("dd",{children:d.user_data.LoginID||"N/A"}),(0,a.jsx)("dt",{children:"User Email:"}),(0,a.jsx)("dd",{children:d.user_data.Email||"N/A"}),(0,a.jsx)("dt",{children:"Role:"}),(0,a.jsx)("dd",{children:d.user_data.RoleList||"N/A"}),(0,a.jsx)("dt",{children:"Last Refreshed:"}),(0,a.jsx)("dd",{children:d.refreshed_at?new Date(d.refreshed_at).toLocaleString():"Never"})]})]})]}),(0,a.jsx)("button",{className:"button button-secondary oauth-disconnect",onClick:x,disabled:s,children:"Disconnect"})]}):(0,a.jsxs)("div",{className:"oauth-disconnected",children:[(0,a.jsxs)("div",{className:"status-badge disconnected",children:[(0,a.jsx)("span",{className:"status-icon",children:"○"}),"Not Connected"]}),(0,a.jsxs)("div",{className:"oauth-benefits",children:[(0,a.jsx)("h4",{children:"Benefits of Connecting:"}),(0,a.jsxs)("ul",{children:[(0,a.jsx)("li",{children:"Access advanced AI models and features"}),(0,a.jsx)("li",{children:"Sync your settings across multiple sites"}),(0,a.jsx)("li",{children:"Automatic updates and improvements"}),(0,a.jsx)("li",{children:"Priority support and assistance"})]})]}),(0,a.jsx)("button",{className:"button button-primary oauth-connect-btn",onClick:function(){b(null);var e="".concat(window.location.origin,"/samuraiauth/?nonce=").concat(window.samurAiAdmin.nonce),t=window.samurAiAdmin.oauthBaseUrl||"https://cp.websamurai.io",n="".concat(t,"/oauth/auth/?callback=").concat(encodeURIComponent(e));window.location.href=n},disabled:s,children:"Connect to Service"}),(0,a.jsx)("p",{className:"oauth-privacy",children:"Your authentication is secure and encrypted. We only access the information necessary to provide our services."})]})]})};function g(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return x(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(x(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,x(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,x(d,"constructor",u),x(u,"constructor",s),s.displayName="GeneratorFunction",x(u,o,"GeneratorFunction"),x(d),x(d,o,"Generator"),x(d,r,function(){return this}),x(d,"toString",function(){return"[object Generator]"}),(g=function(){return{w:a,m:f}})()}function x(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}x=function(e,t,n,r){function a(t,n){x(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},x(e,t,n,r)}function w(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function A(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,c,"next",e)}function c(e){w(a,r,o,i,c,"throw",e)}i(void 0)})}}function N(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,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n={}.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)?S(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 S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const k=function(){var e=N((0,o.useState)(!0),2),t=e[0],n=e[1],r=N((0,o.useState)(!1),2),i=r[0],c=r[1],s=N((0,o.useState)(null),2),u=s[0],l=s[1],d=N((0,o.useState)(null),2),f=d[0],p=d[1],m=N((0,o.useState)(""),2),h=m[0],v=m[1],y=N((0,o.useState)(""),2),b=y[0],j=y[1];(0,o.useEffect)(function(){x()},[]);var x=function(){var e=A(g().m(function e(){var t,r,o;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return n(!0),l(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 2:return t=e.v,e.n=3,t.json();case 3:(r=e.v).success?(v(r.data.PromptInstructions||""),j(r.data.PromptInstructionsImage||"")):l(r.message||"Failed to load prompt instructions"),e.n=5;break;case 4:e.p=4,o=e.v,l("An error occurred while loading prompt instructions"),console.error("Error loading prompt instructions:",o);case 5:return e.p=5,n(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}(),w=function(){var e=A(g().m(function e(){var t,n,r;return g().w(function(e){for(;;)switch(e.p=e.n){case 0:return c(!0),l(null),p(null),e.p=1,e.n=2,fetch("".concat(window.samurAiAdmin.apiUrl,"/prompt-instructions"),{method:"POST",headers:{"X-WP-Nonce":window.samurAiAdmin.nonce,"Content-Type":"application/json"},body:JSON.stringify({promptInstructions:h,promptInstructionsImage:b})});case 2:return t=e.v,e.n=3,t.json();case 3:(n=e.v).success?(p("Prompt instructions saved successfully!"),setTimeout(function(){return p(null)},3e3)):l(n.message||"Failed to save prompt instructions"),e.n=5;break;case 4:e.p=4,r=e.v,l("An error occurred while saving prompt instructions"),console.error("Error saving prompt instructions:",r);case 5:return e.p=5,c(!1),e.f(5);case 6:return e.a(2)}},e,null,[[1,4,5,6]])}));return function(){return e.apply(this,arguments)}}();return t?(0,a.jsx)("div",{className:"prompt-instructions",children:(0,a.jsx)("div",{className:"loading",children:"Loading prompt instructions..."})}):u&&!f?(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),(0,a.jsxs)("div",{className:"prompt-instructions-error",children:[(0,a.jsx)("strong",{children:"Error:"})," ",u]})]}):(0,a.jsxs)("div",{className:"prompt-instructions",children:[(0,a.jsxs)("div",{className:"prompt-instructions-header",children:[(0,a.jsx)("h3",{children:"Extra Prompt Instructions"}),(0,a.jsx)("p",{children:"Configure additional instructions that will be sent with AI prompts for text and image generation."})]}),f&&(0,a.jsxs)("div",{className:"prompt-instructions-success",children:[(0,a.jsx)("strong",{children:"Success:"})," ",f]}),(0,a.jsxs)("div",{className:"prompt-instructions-fields",children:[(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions",children:(0,a.jsx)("strong",{children:"Prompt Instructions"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for general AI text generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions",className:"large-text",rows:"8",value:h,onChange:function(e){return v(e.target.value)},placeholder:"Enter additional prompt instructions for text generation..."})]}),(0,a.jsxs)("div",{className:"field-group",children:[(0,a.jsx)("label",{htmlFor:"prompt-instructions-image",children:(0,a.jsx)("strong",{children:"Prompt Instructions (Image)"})}),(0,a.jsx)("p",{className:"field-description",children:"Additional instructions for AI image generation prompts."}),(0,a.jsx)("textarea",{id:"prompt-instructions-image",className:"large-text",rows:"8",value:b,onChange:function(e){return j(e.target.value)},placeholder:"Enter additional prompt instructions for image generation..."})]})]}),(0,a.jsx)("div",{className:"prompt-instructions-actions",children:(0,a.jsx)("button",{className:"button button-primary",onClick:w,disabled:i,children:i?"Saving...":"Save Prompt Instructions"})})]})},P=window.jQuery;function I(e){return I="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},I(e)}function O(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,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _(e,t);var n={}.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)?_(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 _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var C=n.n(P)();const E=function(){var e=O((0,o.useState)(""),2),t=e[0],n=e[1],r=O((0,o.useState)(""),2),i=r[0],c=r[1],s=O((0,o.useState)(""),2),u=s[0],l=s[1],d=O((0,o.useState)(!1),2),f=d[0],p=d[1],m=O((0,o.useState)(!1),2),h=m[0],v=m[1],y=O((0,o.useState)(!1),2),b=y[0],j=y[1],g=(0,o.useRef)(null),x=(0,o.useRef)(null);(0,o.useEffect)(function(){return function(){g.current&&clearInterval(g.current)}},[]);var w=function(e){c(e)},A=function(){n(""),c(""),l(""),p(!1),v(!1),j(!1),g.current&&(clearInterval(g.current),g.current=null),x.current=null};return(0,a.jsxs)("div",{className:"websamurai-generate-container",children:[(0,a.jsxs)("div",{className:"websamurai-generate-header",children:[(0,a.jsx)("h2",{children:"Generate Image with AI"}),(0,a.jsx)("p",{children:"Describe the image you want to create and our AI will generate it for you."})]}),(0,a.jsxs)("div",{className:"websamurai-generate-body",children:[(0,a.jsxs)("div",{className:"websamurai-input-group",children:[(0,a.jsx)("label",{htmlFor:"websamurai-description",children:"Image Description:"}),(0,a.jsx)("textarea",{id:"websamurai-description",className:"websamurai-textarea",placeholder:"e.g., A serene landscape with mountains and a lake at sunset",rows:"4",value:t,onChange:function(e){return n(e.target.value)},disabled:f})]}),i&&(0,a.jsx)("div",{className:"websamurai-status",children:(0,a.jsx)("p",{children:i})}),u&&(0,a.jsx)("div",{className:"websamurai-preview",children:(0,a.jsx)("img",{src:u,alt:"Generated"})}),(0,a.jsxs)("div",{className:"websamurai-actions",children:[!f&&!h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",onClick:function(){""!==t.trim()?(p(!0),v(!1),j(!1),l(""),w("Starting image generation..."),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_generate_image",nonce:window.samurAiAdmin.nonce,description:t},success:function(e){var t,n;e.success&&e.data.conversation?(x.current=e.data.conversation.id,w("Image generation started. Please wait..."),t=e.data.conversation.id,n=0,g.current=setInterval(function(){if(++n>60)return clearInterval(g.current),g.current=null,w("Image generation timed out. Please try again."),p(!1),void j(!0);C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_poll_image",nonce:window.samurAiAdmin.nonce,conversation_id:t},success:function(e){if(e.success&&e.data.conversation){var t=e.data.conversation;if(!0===t.DoneResponse||"true"===t.DoneResponse){clearInterval(g.current),g.current=null;var r=null;if(t.Prompt&&t.Prompt.prompts&&Array.isArray(t.Prompt.prompts))for(var o=0;o<t.Prompt.prompts.length;o++){var a=t.Prompt.prompts[o];if("assistant"===a.role&&a.content&&"object"===I(a.content)&&a.content.url){var i=a.content.url;r=window.samurAiAdmin.oauthBaseUrl+i;break}}r?(w("Image generated successfully!"),l(r),p(!1),v(!0),j(!0)):(w("Image generation completed but no image URL was returned."),p(!1),j(!0))}else w("Generating image... ("+n+")")}},error:function(){}})},5e3)):(w(e.data.message||"Failed to start image generation."),p(!1),j(!0))},error:function(e,t,n){w("Error: "+n),p(!1),j(!0)}})):alert("Please enter a description for the image.")},children:"Generate Image"}),f&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-generate-btn",disabled:!0,children:"Generating..."}),h&&(0,a.jsx)("button",{type:"button",className:"button button-primary button-large websamurai-add-btn",onClick:function(){u?(w("Adding image to media library..."),v(!1),j(!1),C.ajax({url:window.samurAiAdmin.ajaxUrl,type:"POST",data:{action:"websamurai_add_image_to_media",nonce:window.samurAiAdmin.nonce,image_url:u,description:t},success:function(e){e.success?(w("Image added to media library successfully!"),setTimeout(function(){A()},2e3)):(w(e.data.message||"Failed to add image to library."),v(!0),j(!0))},error:function(e,t,n){w("Error: "+n),v(!0),j(!0)}})):alert("No image to add.")},children:"Add to Library"}),b&&(0,a.jsx)("button",{type:"button",className:"button button-large websamurai-retry-btn",onClick:A,children:"Try Again"})]})]})]})};function T(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var s=r&&r.prototype instanceof c?r:c,u=Object.create(s.prototype);return G(u,"_invoke",function(n,r,o){var a,c,s,u=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,c=0,s=e,f.n=n,i}};function p(n,r){for(c=n,s=r,t=0;!d&&u&&!o&&t<l.length;t++){var o,a=l[t],p=f.p,m=a[2];n>3?(o=m===r)&&(s=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,f.v=r,f.n=a[1]):p<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,c=0))}if(o||n>1)return i;throw d=!0,r}return function(o,l,m){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,m),c=l,s=m;(t=c<2?e:s)||!d;){a||(c?c<3?(c>1&&(f.n=-1),p(c,s)):f.n=s:f.v=s);try{if(u=2,a){if(c||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,c<2&&(c=0)}else 1===c&&(t=a.return)&&t.call(a),c<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((t=(d=f.n<0)?s:n.call(r,f))!==i)break}catch(t){a=e,c=1,s=t}finally{u=1}}return{value:t,done:d}}}(n,o,a),!0),u}var i={};function c(){}function s(){}function u(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(G(t={},r,function(){return this}),t),d=u.prototype=c.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,G(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=u,G(d,"constructor",u),G(u,"constructor",s),s.displayName="GeneratorFunction",G(u,o,"GeneratorFunction"),G(d),G(d,o,"Generator"),G(d,r,function(){return this}),G(d,"toString",function(){return"[object Generator]"}),(T=function(){return{w:a,m:f}})()}function G(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}G=function(e,t,n,r){function a(t,n){G(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},G(e,t,n,r)}function F(e,t,n,r,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function U(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,o,a,i,c=[],s=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n={}.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}}(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 D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const R=function(){var e=U((0,o.useState)("oauth"),2),t=e[0],n=e[1],r=U((0,o.useState)(!1),2),i=r[0],c=r[1];(0,o.useEffect)(function(){s()},[]);var s=function(){var e,t=(e=T().m(function e(){var t,n,r;return T().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,fetch("".concat(window.samurAiAdmin.apiUrl,"/oauth/status"),{headers:{"X-WP-Nonce":window.samurAiAdmin.nonce}});case 1:return t=e.v,e.n=2,t.json();case 2:n=e.v,c(n.connected||!1),e.n=4;break;case 3:e.p=3,r=e.v,console.error("Error checking OAuth status:",r);case 4:return e.a(2)}},e,null,[[0,3]])}),function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){F(a,r,o,i,c,"next",e)}function c(e){F(a,r,o,i,c,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}();return(0,a.jsxs)("div",{className:"websamurai-admin",children:[(0,a.jsxs)("div",{className:"websamurai-admin-header",children:[(0,a.jsx)("h2",{children:"Samur AI Settings"}),(0,a.jsx)("p",{children:"Configure authentication and manage API keys"})]}),(0,a.jsxs)("div",{className:"websamurai-tabs",children:[(0,a.jsxs)("div",{className:"tab-navigation",children:[(0,a.jsx)("button",{className:"tab-button ".concat("oauth"===t?"active":""),onClick:function(){return n("oauth")},children:"OAuth Connection"}),(0,a.jsx)("button",{className:"tab-button ".concat("api-keys"===t?"active":""),onClick:function(){return n("api-keys")},children:"API Keys"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("prompt-instructions"===t?"active":""),onClick:function(){return n("prompt-instructions")},children:"Extra Prompt Instructions"}),i&&(0,a.jsx)("button",{className:"tab-button ".concat("media-generate"===t?"active":""),onClick:function(){return n("media-generate")},children:"Generate AI Image"})]}),(0,a.jsxs)("div",{className:"tab-content",children:["oauth"===t&&(0,a.jsx)(j,{onConnectionChange:s}),"api-keys"===t&&(0,a.jsx)(f,{}),"prompt-instructions"===t&&i&&(0,a.jsx)(k,{}),"media-generate"===t&&i&&(0,a.jsx)(E,{})]})]})]})};document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("websamurai-admin-root");e&&(0,r.H)(e).render((0,a.jsx)(R,{}));var t=document.querySelector(".wp-admin.wp-core-ui.upload-php #wp-media-grid");if(t){console.log("Adding Generate AI Image button to Media Library toolbar");var n=document.createElement("button");n.className="websamurai-generate-image-btn",n.innerText="Generate AI Image",n.onclick=function(e){e.preventDefault(),e.stopPropagation(),console.log("stop");var t=document.querySelector("#websamurai-ai-image-modal-trigger");t||((t=document.createElement("div")).id="websamurai-ai-image-modal-trigger",t.onclick=function(e){"websamurai-ai-image-modal-trigger"===e.target.id&&t.remove()},document.body.appendChild(t)),(0,r.H)(t).render((0,a.jsx)(E,{}))},t&&t.childNodes[1].after(n)}})})(); -
websamurai/trunk/build/frontend.asset.php
r3439610 r3448047 1 <?php return array('dependencies' => array('react', 'react-dom'), 'version' => ' 2db1e8f3c54cadac7f1e');1 <?php return array('dependencies' => array('react', 'react-dom'), 'version' => '7bc79196a7c2ef851e7e'); -
websamurai/trunk/build/frontend.css
r3439610 r3448047 1 /*!*******************************************************************************************************************!*\2 !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/less-loader/dist/cjs.js!./src/frontend/styles.less ***!3 \*******************************************************************************************************************/4 1 /** 5 2 * Frontend Styles -
websamurai/trunk/build/frontend.js
r3439610 r3448047 1 /* 2 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). 3 * This devtool is neither made for production nor for readable output files. 4 * It uses "eval()" calls to create a separate source file in the browser devtools. 5 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) 6 * or disable the default devtool with "devtool: false". 7 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). 8 */ 9 /******/ (() => { // webpackBootstrap 10 /******/ "use strict"; 11 /******/ var __webpack_modules__ = ({ 12 13 /***/ "./node_modules/react-dom/client.js": 14 /*!******************************************!*\ 15 !*** ./node_modules/react-dom/client.js ***! 16 \******************************************/ 17 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 18 19 eval("{\n\nvar m = __webpack_require__(/*! react-dom */ \"react-dom\");\nif (false) // removed by dead control flow\n{} else {\n var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n exports.createRoot = function(c, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.createRoot(c, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n exports.hydrateRoot = function(c, h, o) {\n i.usingClientEntryPoint = true;\n try {\n return m.hydrateRoot(c, h, o);\n } finally {\n i.usingClientEntryPoint = false;\n }\n };\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react-dom/client.js?\n}"); 20 21 /***/ }), 22 23 /***/ "./node_modules/react/cjs/react-jsx-runtime.development.js": 24 /*!*****************************************************************!*\ 25 !*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***! 26 \*****************************************************************/ 27 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 28 29 eval("{/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n\nif (true) {\n (function() {\n'use strict';\n\nvar React = __webpack_require__(/*! react */ \"react\");\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"<anonymous>\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('<anonymous>')) {\n _frame = _frame.replace('<anonymous>', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie. <div {...props} key=\"Hi\" />\n // or <div key=\"Hi\" {...props} /> ). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n // <div {...props} key=\"Hi\" />, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nvar didWarnAboutKeySpread = {};\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n {\n if (hasOwnProperty.call(props, 'key')) {\n var componentName = getComponentNameFromType(type);\n var keys = Object.keys(props).filter(function (k) {\n return k !== 'key';\n });\n var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';\n\n if (!didWarnAboutKeySpread[componentName + beforeExample]) {\n var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';\n\n error('A props object containing a \"key\" prop is being spread into JSX:\\n' + ' let props = %s;\\n' + ' <%s {...props} />\\n' + 'React keys must be passed directly to JSX without using spread:\\n' + ' let props = %s;\\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);\n\n didWarnAboutKeySpread[componentName + beforeExample] = true;\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react/cjs/react-jsx-runtime.development.js?\n}"); 30 31 /***/ }), 32 33 /***/ "./node_modules/react/jsx-runtime.js": 34 /*!*******************************************!*\ 35 !*** ./node_modules/react/jsx-runtime.js ***! 36 \*******************************************/ 37 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 38 39 eval("{\n\nif (false) // removed by dead control flow\n{} else {\n module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ \"./node_modules/react/cjs/react-jsx-runtime.development.js\");\n}\n\n\n//# sourceURL=webpack://websamurai/./node_modules/react/jsx-runtime.js?\n}"); 40 41 /***/ }), 42 43 /***/ "./src/frontend/App.jsx": 44 /*!******************************!*\ 45 !*** ./src/frontend/App.jsx ***! 46 \******************************/ 47 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 48 49 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\n/**\n * Frontend App Component\n */\n\n\nvar App = function App() {\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState2 = _slicedToArray(_useState, 2),\n isOpen = _useState2[0],\n setIsOpen = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),\n _useState4 = _slicedToArray(_useState3, 2),\n content = _useState4[0],\n setContent = _useState4[1];\n var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),\n _useState6 = _slicedToArray(_useState5, 2),\n isProcessing = _useState6[0],\n setIsProcessing = _useState6[1];\n var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),\n _useState8 = _slicedToArray(_useState7, 2),\n responses = _useState8[0],\n setResponses = _useState8[1];\n var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(function () {\n // Load conversation ID from localStorage on mount\n return localStorage.getItem('websamurai_conversation_id') || null;\n }),\n _useState0 = _slicedToArray(_useState9, 2),\n conversationId = _useState0[0],\n setConversationId = _useState0[1];\n var _useState1 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null),\n _useState10 = _slicedToArray(_useState1, 2),\n pollingTimeout = _useState10[0],\n setPollingTimeout = _useState10[1];\n var responsesEndRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);\n var scrollToBottom = function scrollToBottom() {\n var _responsesEndRef$curr;\n (_responsesEndRef$curr = responsesEndRef.current) === null || _responsesEndRef$curr === void 0 || _responsesEndRef$curr.scrollIntoView({\n behavior: 'smooth'\n });\n };\n\n // Load conversation from GraphQL on mount if we have an ID\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n if (conversationId) {\n // Check if conversation is older than 1 hour\n var storedUpdatedDate = localStorage.getItem('websamurai_conversation_updated_date');\n if (storedUpdatedDate) {\n var updatedDateMs = parseInt(storedUpdatedDate, 10);\n var currentTimeMs = Date.now();\n var ageInSeconds = (currentTimeMs - updatedDateMs) / 1000;\n\n // If conversation is older than 1 hour (3600 seconds), clear it\n if (ageInSeconds > 3600) {\n // Clear stale conversation\n setConversationId(null);\n setResponses([]);\n localStorage.removeItem('websamurai_conversation_id');\n localStorage.removeItem('websamurai_conversation_updated_date');\n return;\n }\n }\n _pollConversation(conversationId);\n startPolling(conversationId);\n }\n }, []);\n\n // Scroll to bottom when responses change\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n scrollToBottom();\n }, [responses]);\n\n // Save conversation ID to localStorage whenever it changes\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n if (conversationId) {\n localStorage.setItem('websamurai_conversation_id', conversationId);\n } else {\n localStorage.removeItem('websamurai_conversation_id');\n }\n }, [conversationId]);\n\n // Cleanup polling timeout on unmount\n (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {\n return function () {\n if (pollingTimeout) {\n clearTimeout(pollingTimeout);\n }\n };\n }, [pollingTimeout]);\n var createConversation = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(userMessage) {\n var context, formData, response, data, conversation, _data$data, _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n _context.p = 0;\n context = {\n currentType: window.samurAiFrontend.currentType,\n currentID: window.samurAiFrontend.currentID,\n slug: window.samurAiFrontend.slug,\n locationType: window.samurAiFrontend.locationType\n };\n formData = new FormData();\n formData.append('action', 'websamurai_create_conversation');\n formData.append('nonce', window.samurAiFrontend.nonce);\n formData.append('subject', userMessage.substring(0, 50));\n formData.append('type', 'WebSamurai');\n formData.append('prompt', userMessage);\n formData.append('context', JSON.stringify(context));\n _context.n = 1;\n return fetch(window.samurAiFrontend.ajaxUrl, {\n method: 'POST',\n body: formData\n });\n case 1:\n response = _context.v;\n _context.n = 2;\n return response.json();\n case 2:\n data = _context.v;\n if (!data.success) {\n _context.n = 3;\n break;\n }\n conversation = data.data.conversation;\n setConversationId(conversation.id);\n startPolling(conversation.id);\n return _context.a(2, conversation);\n case 3:\n console.error('Error creating conversation:', (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.message);\n return _context.a(2, null);\n case 4:\n _context.n = 6;\n break;\n case 5:\n _context.p = 5;\n _t = _context.v;\n console.error('Error creating conversation:', _t);\n return _context.a(2, null);\n case 6:\n return _context.a(2);\n }\n }, _callee, null, [[0, 5]]);\n }));\n return function createConversation(_x) {\n return _ref.apply(this, arguments);\n };\n }();\n var updateConversation = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(convId, userMessage) {\n var formData, response, data, conversation, _data$data2, _t2;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.p = _context2.n) {\n case 0:\n _context2.p = 0;\n formData = new FormData();\n formData.append('action', 'websamurai_update_conversation');\n formData.append('nonce', window.samurAiFrontend.nonce);\n formData.append('conversation_id', convId);\n formData.append('message', userMessage);\n _context2.n = 1;\n return fetch(window.samurAiFrontend.ajaxUrl, {\n method: 'POST',\n body: formData\n });\n case 1:\n response = _context2.v;\n _context2.n = 2;\n return response.json();\n case 2:\n data = _context2.v;\n if (!data.success) {\n _context2.n = 3;\n break;\n }\n conversation = data.data.conversation; // Continue polling for the updated conversation\n startPolling(conversation.id);\n return _context2.a(2, conversation);\n case 3:\n console.error('Error updating conversation:', (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.message);\n return _context2.a(2, null);\n case 4:\n _context2.n = 6;\n break;\n case 5:\n _context2.p = 5;\n _t2 = _context2.v;\n console.error('Error updating conversation:', _t2);\n return _context2.a(2, null);\n case 6:\n return _context2.a(2);\n }\n }, _callee2, null, [[0, 5]]);\n }));\n return function updateConversation(_x2, _x3) {\n return _ref2.apply(this, arguments);\n };\n }();\n var _pollConversation = /*#__PURE__*/function () {\n var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(convId) {\n var formData, response, data, conversation, newResponses, timeout, _data$data3, _t3;\n return _regenerator().w(function (_context3) {\n while (1) switch (_context3.p = _context3.n) {\n case 0:\n _context3.p = 0;\n formData = new FormData();\n formData.append('action', 'websamurai_get_conversation');\n formData.append('nonce', window.samurAiFrontend.nonce);\n formData.append('conversation_id', convId);\n _context3.n = 1;\n return fetch(window.samurAiFrontend.ajaxUrl, {\n method: 'POST',\n body: formData\n });\n case 1:\n response = _context3.v;\n _context3.n = 2;\n return response.json();\n case 2:\n data = _context3.v;\n if (!data.success) {\n _context3.n = 3;\n break;\n }\n conversation = data.data.conversation; // Store UpdatedDate in localStorage to track conversation age\n if (conversation.UpdatedDate) {\n localStorage.setItem('websamurai_conversation_updated_date', conversation.UpdatedDate);\n }\n\n // Update responses from the Prompt field\n if (conversation.Prompt && conversation.Prompt.prompts) {\n newResponses = [];\n conversation.Prompt.prompts.forEach(function (prompt) {\n newResponses.push({\n type: prompt.role === 'user' ? 'user' : 'ai',\n text: prompt.content,\n timestamp: new Date().toLocaleTimeString()\n });\n });\n setResponses(newResponses);\n }\n\n // If DoneResponse is true, stop polling\n if (conversation.DoneResponse) {\n if (pollingTimeout) {\n clearTimeout(pollingTimeout);\n setPollingTimeout(null);\n }\n setIsProcessing(false);\n } else {\n // Schedule next poll after 2 seconds\n timeout = setTimeout(function () {\n _pollConversation(convId);\n }, 2000);\n setPollingTimeout(timeout);\n }\n return _context3.a(2, conversation);\n case 3:\n console.error('Error polling conversation:', (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.message);\n return _context3.a(2, null);\n case 4:\n _context3.n = 6;\n break;\n case 5:\n _context3.p = 5;\n _t3 = _context3.v;\n console.error('Error polling conversation:', _t3);\n return _context3.a(2, null);\n case 6:\n return _context3.a(2);\n }\n }, _callee3, null, [[0, 5]]);\n }));\n return function pollConversation(_x4) {\n return _ref3.apply(this, arguments);\n };\n }();\n var startPolling = function startPolling(convId) {\n // Clear existing timeout if any\n if (pollingTimeout) {\n clearTimeout(pollingTimeout);\n }\n\n // Start polling immediately\n _pollConversation(convId);\n };\n var handleToggle = function handleToggle() {\n setIsOpen(!isOpen);\n };\n var handleSubmit = /*#__PURE__*/function () {\n var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {\n var userMessage, messageContent, errorMessage, _t4;\n return _regenerator().w(function (_context4) {\n while (1) switch (_context4.p = _context4.n) {\n case 0:\n if (content.trim()) {\n _context4.n = 1;\n break;\n }\n alert('Please enter some text to send to AI');\n return _context4.a(2);\n case 1:\n setIsProcessing(true);\n\n // Add user message to responses\n userMessage = {\n type: 'user',\n text: content,\n timestamp: new Date().toLocaleTimeString()\n };\n setResponses(function (prev) {\n return [].concat(_toConsumableArray(prev), [userMessage]);\n });\n messageContent = content;\n setContent('');\n _context4.p = 2;\n if (conversationId) {\n _context4.n = 4;\n break;\n }\n _context4.n = 3;\n return createConversation(messageContent);\n case 3:\n _context4.n = 5;\n break;\n case 4:\n _context4.n = 5;\n return updateConversation(conversationId, messageContent);\n case 5:\n _context4.n = 7;\n break;\n case 6:\n _context4.p = 6;\n _t4 = _context4.v;\n console.error('Error:', _t4);\n errorMessage = {\n type: 'error',\n text: 'Failed to communicate with server',\n timestamp: new Date().toLocaleTimeString()\n };\n setResponses(function (prev) {\n return [].concat(_toConsumableArray(prev), [errorMessage]);\n });\n setIsProcessing(false);\n case 7:\n return _context4.a(2);\n }\n }, _callee4, null, [[2, 6]]);\n }));\n return function handleSubmit() {\n return _ref4.apply(this, arguments);\n };\n }();\n var handleKeyPress = function handleKeyPress(e) {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n };\n var handleClose = function handleClose() {\n setIsOpen(false);\n };\n var handleClear = function handleClear() {\n // Stop polling if active\n if (pollingTimeout) {\n clearTimeout(pollingTimeout);\n setPollingTimeout(null);\n }\n\n // Reset conversation state\n setResponses([]);\n setConversationId(null);\n setIsProcessing(false);\n\n // Remove UpdatedDate from localStorage\n localStorage.removeItem('websamurai_conversation_updated_date');\n };\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.Fragment, {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"websamurai-edit-tab \".concat(isOpen ? 'open' : ''),\n onClick: handleToggle,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"tab-text\",\n children: \"Edit with AI\"\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"websamurai-edit-panel \".concat(isOpen ? 'open' : ''),\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"panel-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"h3\", {\n children: \"Edit with AI\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"close-button\",\n onClick: handleClose,\n \"aria-label\": \"Close\",\n children: \"\\xD7\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"panel-content\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"responses-area\",\n children: responses.length === 0 ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"empty-state\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"p\", {\n children: \"Ask the AI to help you edit or create content...\"\n })\n }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.Fragment, {\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"responses-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"span\", {\n className: \"responses-count\",\n children: [responses.length, \" message\", responses.length !== 1 ? 's' : '']\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"clear-button\",\n onClick: handleClear,\n children: \"Clear\"\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"responses-list\",\n children: [responses.map(function (response, index) {\n var resptext = response.text;\n if (!resptext && response.content) {\n resptext = response.content;\n }\n if (typeof resptext === 'string') {\n resptext = resptext.split('\\n').map(function (line, i) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"span\", {\n children: [line, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"br\", {})]\n }, i);\n });\n } else if (_typeof(resptext) === 'object') {\n if (resptext.errors) {\n resptext = resptext.errors.map(function (err, i) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"span\", {\n className: \"error\",\n children: [err, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"br\", {})]\n }, i);\n });\n } else if (Array.isArray(resptext)) {\n resptext = resptext.map(function (txt) {\n if (!txt || txt.type === 'mcp_tool_use' || txt.type === 'mcp_tool_result') {\n return null;\n }\n var out = txt.text;\n if (!out && txt.content) {\n out = txt.content;\n }\n if (!out) {\n return null;\n }\n if (Array.isArray(out)) {\n out = out.map(function (line) {\n return line.text;\n }).join('');\n }\n if (typeof out !== 'string') {\n return '[Unsupported response format]';\n }\n return out.split('\\n').map(function (line, i) {\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"span\", {\n children: [line, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"br\", {})]\n }, i);\n });\n });\n } else {\n resptext = JSON.stringify(resptext);\n }\n } else {\n resptext = 'Unexpected response format';\n }\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"response-message \".concat(response.type),\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"message-header\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"message-label\",\n children: response.type === 'user' ? 'You' : response.type === 'ai' ? 'AI' : 'Error'\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"message-time\",\n children: response.timestamp\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"message-text\",\n children: resptext\n })]\n }, index);\n }), isProcessing && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"response-message ai thinking\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"message-header\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"message-label\",\n children: \"AI\"\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"message-text\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"thinking-animation\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"dot\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"dot\"\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"span\", {\n className: \"dot\"\n })]\n })\n })]\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n ref: responsesEndRef\n })]\n })]\n })\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(\"div\", {\n className: \"input-area\",\n children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"textarea\", {\n id: \"ai-input\",\n className: \"ai-textarea\",\n value: content,\n onChange: function onChange(e) {\n return setContent(e.target.value);\n },\n onKeyPress: handleKeyPress,\n placeholder: \"Type your message... (Press Enter to send, Shift+Enter for new line)\",\n rows: 3,\n disabled: isProcessing\n }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"panel-actions\",\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"button\", {\n className: \"submit-button\",\n onClick: handleSubmit,\n disabled: isProcessing || !content.trim(),\n children: isProcessing ? 'Sending...' : 'Send'\n })\n })]\n })]\n })]\n }), isOpen && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(\"div\", {\n className: \"websamurai-overlay\",\n onClick: handleClose\n })]\n });\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App);\n\n//# sourceURL=webpack://websamurai/./src/frontend/App.jsx?\n}"); 50 51 /***/ }), 52 53 /***/ "./src/frontend/index.js": 54 /*!*******************************!*\ 55 !*** ./src/frontend/index.js ***! 56 \*******************************/ 57 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 58 59 eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom/client */ \"./node_modules/react-dom/client.js\");\n/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./App */ \"./src/frontend/App.jsx\");\n/* harmony import */ var _styles_less__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./styles.less */ \"./src/frontend/styles.less\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/**\n * Frontend entry point\n */\n\n\n\n\n// Initialize the app when DOM is ready\n\ndocument.addEventListener('DOMContentLoaded', function () {\n // Create a container div and append to body\n var container = document.createElement('div');\n container.id = 'websamurai-frontend-root';\n document.body.appendChild(container);\n\n // Render the app\n var root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_0__.createRoot)(container);\n root.render(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_App__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {}));\n});\n\n//# sourceURL=webpack://websamurai/./src/frontend/index.js?\n}"); 60 61 /***/ }), 62 63 /***/ "./src/frontend/styles.less": 64 /*!**********************************!*\ 65 !*** ./src/frontend/styles.less ***! 66 \**********************************/ 67 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 68 69 eval("{__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://websamurai/./src/frontend/styles.less?\n}"); 70 71 /***/ }), 72 73 /***/ "react": 74 /*!************************!*\ 75 !*** external "React" ***! 76 \************************/ 77 /***/ ((module) => { 78 79 module.exports = window["React"]; 80 81 /***/ }), 82 83 /***/ "react-dom": 84 /*!***************************!*\ 85 !*** external "ReactDOM" ***! 86 \***************************/ 87 /***/ ((module) => { 88 89 module.exports = window["ReactDOM"]; 90 91 /***/ }) 92 93 /******/ }); 94 /************************************************************************/ 95 /******/ // The module cache 96 /******/ var __webpack_module_cache__ = {}; 97 /******/ 98 /******/ // The require function 99 /******/ function __webpack_require__(moduleId) { 100 /******/ // Check if module is in cache 101 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 102 /******/ if (cachedModule !== undefined) { 103 /******/ return cachedModule.exports; 104 /******/ } 105 /******/ // Create a new module (and put it into the cache) 106 /******/ var module = __webpack_module_cache__[moduleId] = { 107 /******/ // no module.id needed 108 /******/ // no module.loaded needed 109 /******/ exports: {} 110 /******/ }; 111 /******/ 112 /******/ // Execute the module function 113 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 114 /******/ 115 /******/ // Return the exports of the module 116 /******/ return module.exports; 117 /******/ } 118 /******/ 119 /************************************************************************/ 120 /******/ /* webpack/runtime/compat get default export */ 121 /******/ (() => { 122 /******/ // getDefaultExport function for compatibility with non-harmony modules 123 /******/ __webpack_require__.n = (module) => { 124 /******/ var getter = module && module.__esModule ? 125 /******/ () => (module['default']) : 126 /******/ () => (module); 127 /******/ __webpack_require__.d(getter, { a: getter }); 128 /******/ return getter; 129 /******/ }; 130 /******/ })(); 131 /******/ 132 /******/ /* webpack/runtime/define property getters */ 133 /******/ (() => { 134 /******/ // define getter functions for harmony exports 135 /******/ __webpack_require__.d = (exports, definition) => { 136 /******/ for(var key in definition) { 137 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 138 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 139 /******/ } 140 /******/ } 141 /******/ }; 142 /******/ })(); 143 /******/ 144 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 145 /******/ (() => { 146 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 147 /******/ })(); 148 /******/ 149 /******/ /* webpack/runtime/make namespace object */ 150 /******/ (() => { 151 /******/ // define __esModule on exports 152 /******/ __webpack_require__.r = (exports) => { 153 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 154 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 155 /******/ } 156 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 157 /******/ }; 158 /******/ })(); 159 /******/ 160 /************************************************************************/ 161 /******/ 162 /******/ // startup 163 /******/ // Load entry module and return exports 164 /******/ // This entry module can't be inlined because the eval devtool is used. 165 /******/ var __webpack_exports__ = __webpack_require__("./src/frontend/index.js"); 166 /******/ 167 /******/ })() 168 ; 1 /*! For license information please see frontend.js.LICENSE.txt */ 2 (()=>{"use strict";var e={20:(e,n,r)=>{var t=r(609),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(e,n,r){var t,o={},u=null,l=null;for(t in void 0!==r&&(u=""+r),void 0!==n.key&&(u=""+n.key),void 0!==n.ref&&(l=n.ref),n)s.call(n,t)&&!c.hasOwnProperty(t)&&(o[t]=n[t]);if(e&&e.defaultProps)for(t in n=e.defaultProps)void 0===o[t]&&(o[t]=n[t]);return{$$typeof:a,type:e,key:u,ref:l,props:o,_owner:i.current}}n.Fragment=o,n.jsx=u,n.jsxs=u},338:(e,n,r)=>{var t=r(795);n.H=t.createRoot,t.hydrateRoot},609:e=>{e.exports=window.React},795:e=>{e.exports=window.ReactDOM},848:(e,n,r)=>{e.exports=r(20)}},n={};function r(t){var a=n[t];if(void 0!==a)return a.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}var t=r(338),a=r(609),o=r(848);function s(e){return s="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},s(e)}function i(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(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 c(){var e,n,r="function"==typeof Symbol?Symbol:{},t=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function o(r,t,a,o){var c=t&&t.prototype instanceof i?t:i,l=Object.create(c.prototype);return u(l,"_invoke",function(r,t,a){var o,i,c,u=0,l=a||[],d=!1,p={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(n,r){return o=n,i=0,c=e,p.n=r,s}};function m(r,t){for(i=r,c=t,n=0;!d&&u&&!a&&n<l.length;n++){var a,o=l[n],m=p.p,f=o[2];r>3?(a=f===t)&&(c=o[(i=o[4])?5:(i=3,3)],o[4]=o[5]=e):o[0]<=m&&((a=r<2&&m<o[1])?(i=0,p.v=t,p.n=o[1]):m<f&&(a=r<3||o[0]>t||t>f)&&(o[4]=r,o[5]=t,p.n=f,i=0))}if(a||r>1)return s;throw d=!0,t}return function(a,l,f){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&m(l,f),i=l,c=f;(n=i<2?e:c)||!d;){o||(i?i<3?(i>1&&(p.n=-1),m(i,c)):p.n=c:p.v=c);try{if(u=2,o){if(i||(a="next"),n=o[a]){if(!(n=n.call(o,c)))throw TypeError("iterator result is not an object");if(!n.done)return n;c=n.value,i<2&&(i=0)}else 1===i&&(n=o.return)&&n.call(o),i<2&&(c=TypeError("The iterator does not provide a '"+a+"' method"),i=1);o=e}else if((n=(d=p.n<0)?c:r.call(t,p))!==s)break}catch(n){o=e,i=1,c=n}finally{u=1}}return{value:n,done:d}}}(r,a,o),!0),l}var s={};function i(){}function l(){}function d(){}n=Object.getPrototypeOf;var p=[][t]?n(n([][t]())):(u(n={},t,function(){return this}),n),m=d.prototype=i.prototype=Object.create(p);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e}return l.prototype=d,u(m,"constructor",d),u(d,"constructor",l),l.displayName="GeneratorFunction",u(d,a,"GeneratorFunction"),u(m),u(m,a,"Generator"),u(m,t,function(){return this}),u(m,"toString",function(){return"[object Generator]"}),(c=function(){return{w:o,m:f}})()}function u(e,n,r,t){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}u=function(e,n,r,t){function o(n,r){u(e,n,function(e){return this._invoke(n,r,e)})}n?a?a(e,n,{value:r,enumerable:!t,configurable:!t,writable:!t}):e[n]=r:(o("next",0),o("throw",1),o("return",2))},u(e,n,r,t)}function l(e,n,r,t,a,o,s){try{var i=e[o](s),c=i.value}catch(e){return void r(e)}i.done?n(c):Promise.resolve(c).then(t,a)}function d(e){return function(){var n=this,r=arguments;return new Promise(function(t,a){var o=e.apply(n,r);function s(e){l(o,t,a,s,i,"next",e)}function i(e){l(o,t,a,s,i,"throw",e)}s(void 0)})}}function p(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,a,o,s,i=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;c=!1}else for(;!(c=(t=o.call(r)).done)&&(i.push(t.value),i.length!==n);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return i}}(e,n)||m(e,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.")}()}function m(e,n){if(e){if("string"==typeof e)return f(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,n):void 0}}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}const v=function(){var e=p((0,a.useState)(!1),2),n=e[0],r=e[1],t=p((0,a.useState)(""),2),u=t[0],l=t[1],m=p((0,a.useState)(!1),2),f=m[0],v=m[1],y=p((0,a.useState)([]),2),h=y[0],b=y[1],g=p((0,a.useState)(null),2),w=g[0],x=g[1],j=p((0,a.useState)(function(){return localStorage.getItem("websamurai_conversation_id")||null}),2),_=j[0],S=j[1],N=p((0,a.useState)(null),2),E=N[0],A=N[1],O=(0,a.useRef)(null);(0,a.useEffect)(function(){if(_){var e=localStorage.getItem("websamurai_conversation_updated_date");if(e){var n=parseInt(e,10);if((Date.now()-n)/1e3>3600)return S(null),b([]),localStorage.removeItem("websamurai_conversation_id"),void localStorage.removeItem("websamurai_conversation_updated_date")}I(_),F(_)}},[]),(0,a.useEffect)(function(){var e;null===(e=O.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[h]),(0,a.useEffect)(function(){_?localStorage.setItem("websamurai_conversation_id",_):localStorage.removeItem("websamurai_conversation_id")},[_]),(0,a.useEffect)(function(){return function(){E&&clearTimeout(E)}},[E]);var T=function(){var e=d(c().m(function e(n){var r,t,a,o,s,i,u,l;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,x(null),r={currentType:window.samurAiFrontend.currentType,currentID:window.samurAiFrontend.currentID,slug:window.samurAiFrontend.slug,locationType:window.samurAiFrontend.locationType},(t=new FormData).append("action","websamurai_create_conversation"),t.append("nonce",window.samurAiFrontend.nonce),t.append("subject",n.substring(0,50)),t.append("type","WebSamurai"),t.append("prompt",n),t.append("context",JSON.stringify(r)),e.n=1,fetch(window.samurAiFrontend.ajaxUrl,{method:"POST",body:t});case 1:return a=e.v,e.n=2,a.json();case 2:if(!(o=e.v).success){e.n=3;break}return s=o.data.conversation,S(s.id),F(s.id),e.a(2,s);case 3:return console.error("Error creating conversation:",null===(i=o.data)||void 0===i?void 0:i.message),x((null===(u=o.data)||void 0===u?void 0:u.message)||"Error creating conversation"),e.a(2,null);case 4:e.n=6;break;case 5:return e.p=5,l=e.v,console.error("Error creating conversation:",l),e.a(2,null);case 6:return e.a(2)}},e,null,[[0,5]])}));return function(n){return e.apply(this,arguments)}}(),k=function(){var e=d(c().m(function e(n,r){var t,a,o,s,i,u,l;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,x(null),(t=new FormData).append("action","websamurai_update_conversation"),t.append("nonce",window.samurAiFrontend.nonce),t.append("conversation_id",n),t.append("message",r),e.n=1,fetch(window.samurAiFrontend.ajaxUrl,{method:"POST",body:t});case 1:return a=e.v,e.n=2,a.json();case 2:if(!(o=e.v).success){e.n=3;break}return s=o.data.conversation,F(s.id),e.a(2,s);case 3:return console.error("Error updating conversation:",null===(i=o.data)||void 0===i?void 0:i.message),x((null===(u=o.data)||void 0===u?void 0:u.message)||"Error updating conversation"),e.a(2,null);case 4:e.n=6;break;case 5:return e.p=5,l=e.v,console.error("Error updating conversation:",l),e.a(2,null);case 6:return e.a(2)}},e,null,[[0,5]])}));return function(n,r){return e.apply(this,arguments)}}(),I=function(){var e=d(c().m(function e(n){var r,t,a,o,s,i,u,l;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,(r=new FormData).append("action","websamurai_get_conversation"),r.append("nonce",window.samurAiFrontend.nonce),r.append("conversation_id",n),e.n=1,fetch(window.samurAiFrontend.ajaxUrl,{method:"POST",body:r});case 1:return t=e.v,e.n=2,t.json();case 2:if(!(a=e.v).success){e.n=3;break}return(o=a.data.conversation).UpdatedDate&&localStorage.setItem("websamurai_conversation_updated_date",o.UpdatedDate),o.Prompt&&o.Prompt.prompts&&(s=[],o.Prompt.prompts.forEach(function(e){s.push({type:"user"===e.role?"user":"ai",text:e.content,timestamp:(new Date).toLocaleTimeString()})}),b(s)),o.DoneResponse?(E&&(clearTimeout(E),A(null)),v(!1)):(i=setTimeout(function(){I(n)},2e3),A(i)),e.a(2,o);case 3:return console.error("Error polling conversation:",null===(u=a.data)||void 0===u?void 0:u.message),e.a(2,null);case 4:e.n=6;break;case 5:return e.p=5,l=e.v,console.error("Error polling conversation:",l),e.a(2,null);case 6:return e.a(2)}},e,null,[[0,5]])}));return function(n){return e.apply(this,arguments)}}(),F=function(e){E&&clearTimeout(E),I(e)},P=function(){var e=d(c().m(function e(){var n,r,t,a,o;return c().w(function(e){for(;;)switch(e.p=e.n){case 0:if(u.trim()){e.n=1;break}return alert("Please enter some text to send to AI"),e.a(2);case 1:if(v(!0),n={type:"user",text:u,timestamp:(new Date).toLocaleTimeString()},b(function(e){return[].concat(i(e),[n])}),r=u,l(""),e.p=2,t=null,_){e.n=4;break}return e.n=3,T(r);case 3:t=e.v,e.n=6;break;case 4:return e.n=5,k(_,r);case 5:t=e.v;case 6:t||v(!1),e.n=8;break;case 7:e.p=7,o=e.v,console.error("Error:",o),a={type:"error",text:"Failed to communicate with server",timestamp:(new Date).toLocaleTimeString()},b(function(e){return[].concat(i(e),[a])}),v(!1);case 8:return e.a(2)}},e,null,[[2,7]])}));return function(){return e.apply(this,arguments)}}(),D=function(){r(!1)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"websamurai-edit-tab ".concat(n?"open":""),onClick:function(){r(!n)},children:(0,o.jsx)("span",{className:"tab-text",children:"Edit with AI"})}),(0,o.jsxs)("div",{className:"websamurai-edit-panel ".concat(n?"open":""),children:[(0,o.jsxs)("div",{className:"panel-header",children:[(0,o.jsx)("h3",{children:"Edit with AI"}),(0,o.jsx)("button",{className:"close-button",onClick:D,"aria-label":"Close",children:"×"})]}),(0,o.jsxs)("div",{className:"panel-content",children:[(0,o.jsx)("div",{className:"responses-area",children:0===h.length?(0,o.jsx)("div",{className:"empty-state",children:(0,o.jsx)("p",{children:"Ask the AI to help you edit or create content..."})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"responses-header",children:[(0,o.jsxs)("span",{className:"responses-count",children:[h.length," message",1!==h.length?"s":""]}),(0,o.jsx)("button",{className:"clear-button",onClick:function(){E&&(clearTimeout(E),A(null)),b([]),S(null),v(!1),x(null),localStorage.removeItem("websamurai_conversation_updated_date")},children:"Clear"})]}),(0,o.jsxs)("div",{className:"responses-list",children:[h.map(function(e,n){var r=e.text;return!r&&e.content&&(r=e.content),r="string"==typeof r?r.split("\n").map(function(e,n){return(0,o.jsxs)("span",{children:[e,(0,o.jsx)("br",{})]},n)}):"object"===s(r)?r.errors?r.errors.map(function(e,n){return(0,o.jsxs)("span",{className:"error",children:[e,(0,o.jsx)("br",{})]},n)}):Array.isArray(r)?r.map(function(e){if(!e||"mcp_tool_use"===e.type||"mcp_tool_result"===e.type)return null;var n=e.text;return!n&&e.content&&(n=e.content),n?(Array.isArray(n)&&(n=n.map(function(e){return e.text}).join("")),"string"!=typeof n?"[Unsupported response format]":n.split("\n").map(function(e,n){return(0,o.jsxs)("span",{children:[e,(0,o.jsx)("br",{})]},n)})):null}):JSON.stringify(r):"Unexpected response format",(0,o.jsxs)("div",{className:"response-message ".concat(e.type),children:[(0,o.jsxs)("div",{className:"message-header",children:[(0,o.jsx)("span",{className:"message-label",children:"user"===e.type?"You":"ai"===e.type?"AI":"Error"}),(0,o.jsx)("span",{className:"message-time",children:e.timestamp})]}),(0,o.jsx)("div",{className:"message-text",children:r})]},n)}),f&&(0,o.jsxs)("div",{className:"response-message ai thinking",children:[(0,o.jsx)("div",{className:"message-header",children:(0,o.jsx)("span",{className:"message-label",children:"AI"})}),(0,o.jsx)("div",{className:"message-text",children:(0,o.jsxs)("div",{className:"thinking-animation",children:[(0,o.jsx)("span",{className:"dot"}),(0,o.jsx)("span",{className:"dot"}),(0,o.jsx)("span",{className:"dot"})]})})]}),w&&(0,o.jsxs)("div",{className:"response-message error",children:[(0,o.jsx)("div",{className:"message-header",children:(0,o.jsx)("span",{className:"message-label",children:"Error"})}),(0,o.jsx)("div",{className:"message-text",children:w})]}),(0,o.jsx)("div",{ref:O})]})]})}),(0,o.jsxs)("div",{className:"input-area",children:[(0,o.jsx)("textarea",{id:"ai-input",className:"ai-textarea",value:u,onChange:function(e){return l(e.target.value)},onKeyPress:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),P())},placeholder:"Type your message... (Press Enter to send, Shift+Enter for new line)",rows:3,disabled:f}),(0,o.jsx)("div",{className:"panel-actions",children:(0,o.jsx)("button",{className:"submit-button",onClick:P,disabled:f||!u.trim(),children:f?"Sending...":"Send"})})]})]})]}),n&&(0,o.jsx)("div",{className:"websamurai-overlay",onClick:D})]})};document.addEventListener("DOMContentLoaded",function(){var e=document.createElement("div");e.id="websamurai-frontend-root",document.body.appendChild(e),(0,t.H)(e).render((0,o.jsx)(v,{}))})})(); -
websamurai/trunk/inc/ajax-handler.php
r3439610 r3448047 199 199 // Check for GraphQL errors. 200 200 if ( isset( $data['errors'] ) && ! empty( $data['errors'] ) ) { 201 wp_send_json_error( 202 array( 203 'message' => __( 'GraphQL query error', 'websamurai' ), 201 $errs = array_map( function( $error ) { 202 return isset( $error['message'] ) ? $error['message'] : 'Unknown error'; 203 }, $data['errors'] ); 204 wp_send_json_error( 205 array( 206 'message' => __( 'Error: ' . implode( '\n', $errs ), 'websamurai' ), 204 207 'errors' => $data['errors'], 205 208 ) … … 451 454 $get_data = json_decode( $get_body, true ); 452 455 453 if ( 200 !== $get_status || isset( $get_data['errors'] ) ) { 454 wp_send_json_error( 455 array( 456 'message' => __( 'Failed to retrieve existing conversation', 'websamurai' ), 456 457 if ( 200 !== $get_status || isset( $get_data['data']['errors'] ) ) { 458 if( isset( $get_data['data']['errors'] ) ) { 459 $errors = $get_data['data']['errors']; 460 } else { 461 $errors = array(); 462 } 463 wp_send_json_error( 464 array( 465 'message' => __( 'Failed to retrieve existing conversation: ' . implode( '\n', $errors ), 'websamurai' ), 457 466 ) 458 467 ); … … 537 546 // Check for GraphQL errors. 538 547 if ( isset( $update_data['errors'] ) && ! empty( $update_data['errors'] ) ) { 539 wp_send_json_error( 540 array( 541 'message' => __( 'GraphQL mutation error', 'websamurai' ), 548 $errs = array_map( function( $error ) { 549 return isset( $error['message'] ) ? $error['message'] : 'Unknown error'; 550 }, $update_data['errors'] ); 551 wp_send_json_error( 552 array( 553 'message' => __( 'Error: ' . implode( '\n', $errs ), 'websamurai' ), 542 554 'errors' => $update_data['errors'], 543 555 ) -
websamurai/trunk/inc/oauth-handler.php
r3439610 r3448047 72 72 // If sync failed and we disconnected, redirect to show error. 73 73 if ( empty( get_option( 'websamurai_cp_auth_key' ) ) ) { 74 wp_die( 'OAuth Error: Failed to register site with SamuraiWP Control Panel. Please try again. ');74 wp_die( 'OAuth Error: Failed to register site with SamuraiWP Control Panel. Please try again.<br>' . $site_result->get_error_message() ); 75 75 } 76 76 } -
websamurai/trunk/inc/samurai-site.php
r3439610 r3448047 66 66 // Check for GraphQL errors. 67 67 if ( isset( $data['errors'] ) && ! empty( $data['errors'] ) ) { 68 return new WP_Error( 'graphql_error', 'GraphQL query error', $data['errors'] ); 68 $err = array_map( function( $error ) { 69 return isset( $error['message'] ) ? $error['message'] : 'Unknown error'; 70 }, $data['errors'] ); 71 return new WP_Error( 'graphql_error', 'Error:' . implode( '\n', $err ) ); 69 72 } 70 73 … … 107 110 return new WP_Error( 'no_data', 'No SamuraiSite data received from server' ); 108 111 } 112 if( $site_data['Deleted'] ) { 113 return new WP_Error( 'not_found', 'SamuraiSite not found (deleted)' ); 114 } 109 115 110 116 return $site_data; -
websamurai/trunk/readme.txt
r3439610 r3448047 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 06 Stable tag: 1.0.1 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 142 142 == Changelog == 143 143 144 = 1.0.1 145 * Fix error messaging on front end 146 * Fix recreate site if site config has been deleted 147 * Fix assets images so the show properly 148 * Add plugin thumbnail 149 144 150 = 1.0.0 = 145 151 * Initial release -
websamurai/trunk/src/frontend/App.jsx
r3439610 r3448047 9 9 const [isProcessing, setIsProcessing] = useState(false); 10 10 const [responses, setResponses] = useState([]); 11 const [ error, setError ] = useState( null ); 11 12 const [conversationId, setConversationId] = useState(() => { 12 13 // Load conversation ID from localStorage on mount … … 72 73 const createConversation = async (userMessage) => { 73 74 try { 75 setError( null ); 74 76 let context = { 75 77 currentType: window.samurAiFrontend.currentType, … … 101 103 } else { 102 104 console.error('Error creating conversation:', data.data?.message); 105 setError( data.data?.message || 'Error creating conversation' ); 103 106 return null; 104 107 } … … 111 114 const updateConversation = async (convId, userMessage) => { 112 115 try { 116 setError( null ); 113 117 const formData = new FormData(); 114 118 formData.append('action', 'websamurai_update_conversation'); … … 123 127 124 128 const data = await response.json(); 125 126 if (data.success) { 129 if ( data.success ) { 127 130 const conversation = data.data.conversation; 128 131 // Continue polling for the updated conversation … … 131 134 } else { 132 135 console.error('Error updating conversation:', data.data?.message); 136 setError( data.data?.message || 'Error updating conversation' ); 133 137 return null; 134 138 } … … 235 239 try { 236 240 // If this is the first message, create a new conversation 241 let ret = null; 237 242 if (!conversationId) { 238 await createConversation(messageContent);243 ret = await createConversation(messageContent); 239 244 } else { 240 245 // Update existing conversation with new message 241 await updateConversation(conversationId, messageContent); 246 ret = await updateConversation(conversationId, messageContent); 247 } 248 if( ! ret ) { 249 setIsProcessing(false); 242 250 } 243 251 } catch (error) { … … 275 283 setConversationId(null); 276 284 setIsProcessing(false); 285 setError( null ); 277 286 278 287 // Remove UpdatedDate from localStorage … … 400 409 </div> 401 410 )} 411 { error && ( 412 <div className="response-message error"> 413 <div className="message-header"> 414 <span className="message-label">Error</span> 415 </div> 416 <div className="message-text"> 417 { error } 418 </div> 419 </div> 420 ) } 402 421 403 422 <div ref={responsesEndRef} /> -
websamurai/trunk/websamurai.php
r3439610 r3448047 4 4 * Plugin URI: https://websamurai.io 5 5 * Description: AI-powered features for WordPress 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Kiera Howe, Wiley Solutions 8 8 * Author URI: https://wileysol.com
Note: See TracChangeset
for help on using the changeset viewer.