import { useEffect as e } from "react";
import t from "prop-types";
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
import { LockIcon as a, UnlockIcon as o } from "@primer/octicons-react";
import s from "lodash/identity.js";
//#region src/plugins/editor-content-read-only/actions.js
var c = "editor_update_read_only", l = "editor_update_read_write", u = () => ({ type: c }), d = () => ({ type: l }), f = {
	[c]: (e) => e.set("contentIsReadOnly", !0),
	[l]: (e) => e.set("contentIsReadOnly", !1)
}, p = (e) => e.get("contentIsReadOnly") || !1, m = (e) => !p(e), h = ({ editorSelectors: e, editorActions: t }) => {
	let n = e.selectContentIsReadWrite(), i = (e) => () => {
		e ? t.setContentReadOnly() : t.setContentReadWrite();
	};
	return n ? /* @__PURE__ */ r("div", {
		className: "swagger-editor__generic-padding-thin-top-bottom",
		children: /* @__PURE__ */ r("button", {
			type: "button",
			className: "swagger-editor__editor-pane-bar-control",
			onClick: i(!0),
			children: /* @__PURE__ */ r(o, {
				size: "small",
				"aria-label": "Unlock"
			})
		})
	}) : /* @__PURE__ */ r("div", {
		className: "swagger-editor__generic-padding-thin-top-bottom",
		children: /* @__PURE__ */ r("button", {
			type: "button",
			className: "swagger-editor__editor-pane-bar-control",
			onClick: i(!1),
			children: /* @__PURE__ */ r(a, {
				size: "small",
				"aria-label": "Lock"
			})
		})
	});
};
h.propTypes = {
	editorActions: t.shape({
		setContentReadOnly: t.func.isRequired,
		setContentReadWrite: t.func.isRequired
	}).isRequired,
	editorSelectors: t.shape({ selectContentIsReadWrite: t.func.isRequired }).isRequired
};
//#endregion
//#region src/plugins/editor-content-read-only/extensions/editor-textarea/wrap-components/EditorPaneBarTopWrapper.jsx
var g = (e, a) => {
	let o = a.getComponent("ReadOnlySelection", !0), c = ({ renderControls: t = s, ...a }) => /* @__PURE__ */ r(e, {
		...a,
		renderControls: (e) => t(/* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r(o, {}), e] }))
	});
	return c.propTypes = { renderControls: t.func }, c;
}, _ = (n, i) => {
	let a = ({ isReadOnly: t = null, ...a }) => {
		let o = i.editorSelectors.selectContentIsReadOnly(), s = t ?? o;
		return e(() => {
			typeof t == "boolean" && t !== o && (t && i.editorActions.setContentReadOnly(), t || i.editorActions.setContentReadWrite());
		}, [t, o]), /* @__PURE__ */ r(n, {
			...a,
			isReadOnly: s
		});
	};
	return a.propTypes = { isReadOnly: t.bool }, a;
}, v = () => ({
	components: { ReadOnlySelection: h },
	wrapComponents: {
		Editor: _,
		EditorPaneBarTop: g
	},
	statePlugins: { editor: {
		reducers: f,
		selectors: {
			selectContentIsReadOnly: p,
			selectContentIsReadWrite: m
		},
		actions: {
			setContentReadOnly: u,
			setContentReadWrite: d
		}
	} }
});
//#endregion
export { v as default };

//# sourceMappingURL=index.js.map