| 1 |
(function(_elementor_editor_site_settings, react, _elementor_editor_v1_adapters, _elementor_ui, _wordpress_i18n, _elementor_editor_documents) { |
| 2 |
|
| 3 |
//#region \0rolldown/runtime.js |
| 4 |
var __create = Object.create; |
| 5 |
var __defProp = Object.defineProperty; |
| 6 |
var __name = (target, value) => __defProp(target, "name", { |
| 7 |
value, |
| 8 |
configurable: true |
| 9 |
}); |
| 10 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 11 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 12 |
var __getProtoOf = Object.getPrototypeOf; |
| 13 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 14 |
var __exportAll = (all, no_symbols) => { |
| 15 |
let target = {}; |
| 16 |
for (var name in all) { |
| 17 |
__defProp(target, name, { |
| 18 |
get: all[name], |
| 19 |
enumerable: true |
| 20 |
}); |
| 21 |
} |
| 22 |
if (!no_symbols) { |
| 23 |
__defProp(target, Symbol.toStringTag, { value: "Module" }); |
| 24 |
} |
| 25 |
return target; |
| 26 |
}; |
| 27 |
var __copyProps = (to, from, except, desc) => { |
| 28 |
if (from && typeof from === "object" || typeof from === "function") { |
| 29 |
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { |
| 30 |
key = keys[i]; |
| 31 |
if (!__hasOwnProp.call(to, key) && key !== except) { |
| 32 |
__defProp(to, key, { |
| 33 |
get: ((k) => from[k]).bind(null, key), |
| 34 |
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable |
| 35 |
}); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
return to; |
| 40 |
}; |
| 41 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { |
| 42 |
value: mod, |
| 43 |
enumerable: true |
| 44 |
}) : target, mod)); |
| 45 |
|
| 46 |
//#endregion |
| 47 |
react = __toESM(react); |
| 48 |
|
| 49 |
//#region packages/packages/core/editor-agents/src/llms-settings.ts |
| 50 |
var AGENTS_SETTINGS_KEY = "agents"; |
| 51 |
var LLMS_SETTINGS_KEY = "llms"; |
| 52 |
function getSiteSettingsBag() { |
| 53 |
const settings = (0, _elementor_editor_documents.getV1CurrentDocument)()?.container?.settings; |
| 54 |
return settings ? settings : null; |
| 55 |
} |
| 56 |
function readAgentsSettings(settings) { |
| 57 |
const agents = settings?.get(AGENTS_SETTINGS_KEY); |
| 58 |
return agents && typeof agents === "object" ? { ...agents } : {}; |
| 59 |
} |
| 60 |
function omitLlms(agents) { |
| 61 |
return Object.fromEntries(Object.entries(agents).filter(([key]) => key !== LLMS_SETTINGS_KEY)); |
| 62 |
} |
| 63 |
function isEmpty(agents) { |
| 64 |
return 0 === Object.keys(agents).length; |
| 65 |
} |
| 66 |
function readLlmsContent() { |
| 67 |
const llms = readAgentsSettings(getSiteSettingsBag())[LLMS_SETTINGS_KEY]; |
| 68 |
return typeof llms === "string" ? llms : ""; |
| 69 |
} |
| 70 |
function writeLlmsContent(content) { |
| 71 |
const settings = getSiteSettingsBag(); |
| 72 |
if (!settings) return false; |
| 73 |
const agents = readAgentsSettings(settings); |
| 74 |
if ("" === content) { |
| 75 |
const remainingAgents = omitLlms(agents); |
| 76 |
settings.set(AGENTS_SETTINGS_KEY, isEmpty(remainingAgents) ? void 0 : remainingAgents); |
| 77 |
} else settings.set(AGENTS_SETTINGS_KEY, { |
| 78 |
...agents, |
| 79 |
[LLMS_SETTINGS_KEY]: content |
| 80 |
}); |
| 81 |
(0, _elementor_editor_documents.setDocumentModifiedStatus)(true); |
| 82 |
return true; |
| 83 |
} |
| 84 |
|
| 85 |
//#endregion |
| 86 |
//#region packages/packages/core/editor-agents/src/components/agents-settings-tab.tsx |
| 87 |
var TAB_ID = "settings-agents"; |
| 88 |
var TAB_ROUTE = `panel/global/${TAB_ID}`; |
| 89 |
function AgentsSettingsTab() { |
| 90 |
const [value, setValue] = (0, react.useState)(readLlmsContent); |
| 91 |
const [isSettingsAvailable, setIsSettingsAvailable] = (0, react.useState)(() => null !== getSiteSettingsBag()); |
| 92 |
(0, _elementor_editor_v1_adapters.__privateUseListenTo)([(0, _elementor_editor_v1_adapters.routeOpenEvent)(TAB_ROUTE)], () => { |
| 93 |
setIsSettingsAvailable(null !== getSiteSettingsBag()); |
| 94 |
setValue(readLlmsContent()); |
| 95 |
}); |
| 96 |
const handleChange = (0, react.useCallback)((event) => { |
| 97 |
const nextValue = event.target.value; |
| 98 |
setValue(nextValue); |
| 99 |
writeLlmsContent(nextValue); |
| 100 |
}, []); |
| 101 |
return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { p: 2 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Stack, { spacing: 1.5 }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle2" }, (0, _wordpress_i18n.__)("Agents", "elementor")), /* @__PURE__ */ react.createElement(_elementor_ui.TextField, { |
| 102 |
label: (0, _wordpress_i18n.__)("llms.txt", "elementor"), |
| 103 |
value, |
| 104 |
onChange: handleChange, |
| 105 |
multiline: true, |
| 106 |
minRows: 12, |
| 107 |
fullWidth: true, |
| 108 |
disabled: !isSettingsAvailable, |
| 109 |
helperText: isSettingsAvailable ? (0, _wordpress_i18n.__)("Content served at /llms.txt when saved. Leave empty to disable.", "elementor") : (0, _wordpress_i18n.__)("Kit settings are unavailable. Reopen Site Settings and try again.", "elementor") |
| 110 |
}))); |
| 111 |
} |
| 112 |
var AGENTS_SITE_SETTINGS_TAB_ID = TAB_ID; |
| 113 |
|
| 114 |
//#endregion |
| 115 |
//#region packages/packages/core/editor-agents/src/init.ts |
| 116 |
var EXPERIMENT_NAME = "agents_llms_txt"; |
| 117 |
function isAgentsExperimentActive() { |
| 118 |
const features = window.elementorCommon?.config?.experimentalFeatures ?? {}; |
| 119 |
return Boolean(features[EXPERIMENT_NAME]); |
| 120 |
} |
| 121 |
function init() { |
| 122 |
if (!isAgentsExperimentActive()) return; |
| 123 |
(0, _elementor_editor_site_settings.injectSiteSettingsTab)({ |
| 124 |
id: AGENTS_SITE_SETTINGS_TAB_ID, |
| 125 |
component: AgentsSettingsTab |
| 126 |
}); |
| 127 |
} |
| 128 |
|
| 129 |
//#endregion |
| 130 |
//#region packages/packages/core/editor-agents/src/index.ts |
| 131 |
var src_exports = /* @__PURE__ */ __exportAll({ |
| 132 |
AGENTS_SITE_SETTINGS_TAB_ID: () => AGENTS_SITE_SETTINGS_TAB_ID, |
| 133 |
AgentsSettingsTab: () => AgentsSettingsTab, |
| 134 |
init: () => init |
| 135 |
}); |
| 136 |
|
| 137 |
//#endregion |
| 138 |
//#region \0elementor-package-library-entry |
| 139 |
(window.elementorV2 = window.elementorV2 || {}).editorAgents = src_exports; |
| 140 |
|
| 141 |
//#endregion |
| 142 |
})(elementorV2.editorSiteSettings, React, elementorV2.editorV1Adapters, elementorV2.ui, wp.i18n, elementorV2.editorDocuments); |
| 143 |
window.elementorV2.editorAgents?.init?.(); |
| 144 |
//# sourceMappingURL=editor-agents.js.map |