import { b as generateId } from "./dist-CdWSQzOH.js";
import { m as actions } from "./module-Cpz1JYVM.js";
import "./upgrade-manifest-JiCdpWbf.js";
import "./document-drive-DwMcPeeu.js";
import "./chunk-VBDAOXYI-DxYKDIjC.js";
import "./dist-B2aX2Fsh.js";
import { i as useSelectedProjectDocument } from "./project-gM6yUiQB.js";
import "./load-design-tokens-DI8M2VZx.js";
import { t as DocumentToolbar } from "./connect-9ej7S5NE-Db2m-K1a.js";
import { useCallback, useState } from "react";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
//#region editors/project-editor/components/ProjectHeader.tsx
function ProjectHeader({ state }) {
	return /* @__PURE__ */ jsxs("header", {
		className: "rfp-header",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "rfp-header-row",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "rfp-col",
				style: { gap: 4 },
				children: [
					/* @__PURE__ */ jsx("span", {
						className: "rfp-meta",
						children: "Project · DAOIP-5"
					}),
					/* @__PURE__ */ jsx("h1", {
						className: "rfp-h1",
						children: state.name || "Untitled project"
					}),
					state.ownerDid ? /* @__PURE__ */ jsxs("p", {
						className: "rfp-hint",
						children: ["Owner: ", state.ownerDid]
					}) : null
				]
			}), /* @__PURE__ */ jsx("span", {
				className: `rfp-status-badge ${state.ownerDid ? "rfp-status-approved" : "rfp-status-draft"}`,
				children: state.ownerDid ? "Identified" : "Draft"
			})]
		}), state.description ? /* @__PURE__ */ jsx("p", {
			className: "rfp-body",
			style: { maxWidth: 680 },
			children: state.description
		}) : null]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectProfile.tsx
function ProjectProfile({ state, on }) {
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [
			/* @__PURE__ */ jsx("h2", {
				className: "rfp-section-subtitle",
				children: "Project profile"
			}),
			/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }),
			/* @__PURE__ */ jsxs("label", {
				className: "rfp-field",
				children: [/* @__PURE__ */ jsx("span", {
					className: "rfp-label",
					children: "Name"
				}), /* @__PURE__ */ jsx("input", {
					className: "rfp-input",
					defaultValue: state.name ?? "",
					placeholder: "Your project name",
					onBlur: (e) => on.setName(e.target.value.trim())
				})]
			}),
			/* @__PURE__ */ jsxs("label", {
				className: "rfp-field",
				children: [/* @__PURE__ */ jsx("span", {
					className: "rfp-label",
					children: "Description"
				}), /* @__PURE__ */ jsx("textarea", {
					className: "rfp-textarea",
					defaultValue: state.description ?? "",
					placeholder: "What the project does, who it serves, what it needs.",
					onBlur: (e) => on.setDesc(e.target.value.trim())
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-grid-2",
				children: [/* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Pitch / content URL"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						defaultValue: state.contentURI ?? "",
						placeholder: "https://…",
						onBlur: (e) => on.setContent(e.target.value.trim())
					})]
				}), /* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Contact email"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						type: "email",
						defaultValue: state.email ?? "",
						placeholder: "hello@project.xyz",
						onBlur: (e) => on.setEmail(e.target.value.trim())
					})]
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-grid-2",
				children: [/* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Logo URL"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						defaultValue: state.image ?? "",
						placeholder: "https://…",
						onBlur: (e) => on.setImage(e.target.value.trim())
					})]
				}), /* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Cover image URL"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						defaultValue: state.coverImage ?? "",
						placeholder: "https://…",
						onBlur: (e) => on.setCoverImage(e.target.value.trim())
					})]
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-grid-2",
				children: [/* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "License URL"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						defaultValue: state.licenseURI ?? "",
						placeholder: "https://opensource.org/…",
						onBlur: (e) => on.setLicenseUri(e.target.value.trim())
					})]
				}), /* @__PURE__ */ jsxs("label", {
					className: "rfp-field",
					children: [/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Short code"
					}), /* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						defaultValue: state.code ?? "",
						placeholder: "Short reference",
						onBlur: (e) => on.setCode(e.target.value.trim())
					})]
				})]
			})
		]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectAttestations.tsx
function ProjectAttestations({ state, on }) {
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [
			/* @__PURE__ */ jsx("h2", {
				className: "rfp-section-subtitle",
				children: "Members & attestations"
			}),
			/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }),
			/* @__PURE__ */ jsx("p", {
				className: "rfp-hint",
				children: "URLs pointing to member profiles and trusted attestation issuers (DAOIP-3). Funders read these during application review."
			}),
			/* @__PURE__ */ jsxs("label", {
				className: "rfp-field",
				children: [/* @__PURE__ */ jsx("span", {
					className: "rfp-label",
					children: "Members URI"
				}), /* @__PURE__ */ jsx("input", {
					className: "rfp-input",
					defaultValue: state.membersURI ?? "",
					placeholder: "https://…",
					onBlur: (e) => on.setMembersUri(e.target.value.trim())
				})]
			}),
			/* @__PURE__ */ jsxs("label", {
				className: "rfp-field",
				children: [/* @__PURE__ */ jsx("span", {
					className: "rfp-label",
					children: "Attestation issuers URI"
				}), /* @__PURE__ */ jsx("input", {
					className: "rfp-input",
					defaultValue: state.attestationIssuersURI ?? "",
					placeholder: "https://…",
					onBlur: (e) => on.setAttestationIssuersUri(e.target.value.trim())
				})]
			})
		]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectRelevantPools.tsx
function ProjectRelevantPools({ state, on }) {
	const [poolId, setPoolId] = useState("");
	const [poolName, setPoolName] = useState("");
	const add = () => {
		if (!poolId.trim() || !poolName.trim()) return;
		on.addRelevantPool(poolId.trim(), poolName.trim());
		setPoolId("");
		setPoolName("");
	};
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [
			/* @__PURE__ */ jsx("h2", {
				className: "rfp-section-subtitle",
				children: "Relevant grant pools"
			}),
			/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }),
			/* @__PURE__ */ jsx("p", {
				className: "rfp-hint",
				children: "Pools this project is interested in — acts as a soft signal until a formal application is submitted."
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-row",
				children: [
					/* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						style: { flex: 1 },
						value: poolId,
						onChange: (e) => setPoolId(e.target.value),
						placeholder: "Pool PHID"
					}),
					/* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						style: { flex: 1 },
						value: poolName,
						onChange: (e) => setPoolName(e.target.value),
						placeholder: "Pool name (cached)"
					}),
					/* @__PURE__ */ jsx("button", {
						className: "rfp-btn-secondary",
						onClick: add,
						disabled: !poolId.trim() || !poolName.trim(),
						children: "Add"
					})
				]
			}),
			state.relevantTo.length === 0 ? /* @__PURE__ */ jsx("div", {
				className: "rfp-empty",
				children: "No relevant pools yet."
			}) : /* @__PURE__ */ jsx("ul", {
				className: "rfp-list",
				children: state.relevantTo.map((r) => /* @__PURE__ */ jsxs("li", {
					className: "rfp-list-item",
					children: [/* @__PURE__ */ jsxs("div", {
						className: "rfp-col",
						style: {
							gap: 2,
							flex: 1
						},
						children: [/* @__PURE__ */ jsx("strong", { children: r.poolName }), /* @__PURE__ */ jsx("span", {
							className: "rfp-hint",
							children: r.poolId
						})]
					}), /* @__PURE__ */ jsx("button", {
						className: "rfp-btn-ghost",
						onClick: () => on.removeRelevantPool(r.id),
						children: "Remove"
					})]
				}, r.id))
			})
		]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectIdentity.tsx
function ProjectIdentity({ state, on }) {
	const [sameAsDraft, setSameAsDraft] = useState("");
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [
			/* @__PURE__ */ jsx("h2", {
				className: "rfp-section-subtitle",
				children: "Identity"
			}),
			/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }),
			/* @__PURE__ */ jsxs("label", {
				className: "rfp-field",
				children: [/* @__PURE__ */ jsx("span", {
					className: "rfp-label",
					children: "Owner DID"
				}), /* @__PURE__ */ jsx("input", {
					className: "rfp-input",
					defaultValue: state.ownerDid ?? "",
					placeholder: "did:pkh:eip155:1:0x…",
					onBlur: (e) => {
						const v = e.target.value.trim();
						if (v) on.setOwnerDid(v);
					}
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-col",
				children: [
					/* @__PURE__ */ jsx("span", {
						className: "rfp-label",
						children: "Canonical identity (sameAs)"
					}),
					/* @__PURE__ */ jsxs("div", {
						className: "rfp-row",
						children: [/* @__PURE__ */ jsx("input", {
							className: "rfp-input",
							style: { flex: 1 },
							value: sameAsDraft,
							onChange: (e) => setSameAsDraft(e.target.value),
							placeholder: "https://…",
							onKeyDown: (e) => {
								if (e.key === "Enter" && sameAsDraft.trim()) {
									e.preventDefault();
									on.addSameAs(sameAsDraft.trim());
									setSameAsDraft("");
								}
							}
						}), /* @__PURE__ */ jsx("button", {
							type: "button",
							className: "rfp-btn-secondary",
							disabled: !sameAsDraft.trim(),
							onClick: () => {
								if (sameAsDraft.trim()) {
									on.addSameAs(sameAsDraft.trim());
									setSameAsDraft("");
								}
							},
							children: "Add"
						})]
					}),
					state.sameAs.length === 0 ? /* @__PURE__ */ jsx("div", {
						className: "rfp-empty",
						children: "No identity links yet."
					}) : /* @__PURE__ */ jsx("ul", {
						className: "rfp-list",
						children: state.sameAs.map((url) => /* @__PURE__ */ jsxs("li", {
							className: "rfp-list-item",
							children: [/* @__PURE__ */ jsx("span", { children: url }), /* @__PURE__ */ jsx("button", {
								type: "button",
								className: "rfp-btn-ghost",
								onClick: () => on.removeSameAs(url),
								children: "Remove"
							})]
						}, url))
					})
				]
			})
		]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectSocials.tsx
function ProjectSocials({ state, on }) {
	const [socialName, setSocialName] = useState("");
	const [socialValue, setSocialValue] = useState("");
	const canAdd = !!socialName.trim() && !!socialValue.trim();
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [
			/* @__PURE__ */ jsx("h2", {
				className: "rfp-section-subtitle",
				children: "Socials"
			}),
			/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }),
			/* @__PURE__ */ jsxs("div", {
				className: "rfp-row",
				children: [
					/* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						style: { maxWidth: 180 },
						value: socialName,
						onChange: (e) => setSocialName(e.target.value),
						placeholder: "Platform (Twitter…)"
					}),
					/* @__PURE__ */ jsx("input", {
						className: "rfp-input",
						style: { flex: 1 },
						value: socialValue,
						onChange: (e) => setSocialValue(e.target.value),
						placeholder: "https://…"
					}),
					/* @__PURE__ */ jsx("button", {
						type: "button",
						className: "rfp-btn-secondary",
						disabled: !canAdd,
						onClick: () => {
							if (canAdd) {
								on.addSocial(socialName.trim(), socialValue.trim());
								setSocialName("");
								setSocialValue("");
							}
						},
						children: "Add"
					})
				]
			}),
			state.socials.length === 0 ? /* @__PURE__ */ jsx("div", {
				className: "rfp-empty",
				children: "No socials yet."
			}) : /* @__PURE__ */ jsx("ul", {
				className: "rfp-list",
				children: state.socials.map((s) => /* @__PURE__ */ jsxs("li", {
					className: "rfp-list-item",
					children: [/* @__PURE__ */ jsxs("div", {
						className: "rfp-row",
						style: { gap: 12 },
						children: [/* @__PURE__ */ jsx("span", {
							className: "rfp-chip",
							children: s.name
						}), /* @__PURE__ */ jsx("span", { children: s.value })]
					}), /* @__PURE__ */ jsx("button", {
						type: "button",
						className: "rfp-btn-ghost",
						onClick: () => on.removeSocial(s.id),
						children: "Remove"
					})]
				}, s.id))
			})
		]
	});
}
//#endregion
//#region editors/project-editor/components/ProjectExtensions.tsx
function ProjectExtensions({ state, on }) {
	const [expanded, setExpanded] = useState(false);
	return /* @__PURE__ */ jsxs("section", {
		className: "rfp-card rfp-section",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "rfp-row",
			style: { justifyContent: "space-between" },
			children: [/* @__PURE__ */ jsxs("h2", {
				className: "rfp-section-subtitle",
				children: ["DAOIP-5 extensions ", state.extensions ? "· set" : "· empty"]
			}), /* @__PURE__ */ jsx("button", {
				className: "rfp-btn-ghost",
				onClick: () => setExpanded((v) => !v),
				children: expanded ? "Hide" : "Show"
			})]
		}), expanded ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("hr", { className: "rfp-divider" }), /* @__PURE__ */ jsxs("label", {
			className: "rfp-field",
			children: [/* @__PURE__ */ jsx("span", {
				className: "rfp-label",
				children: "Extensions (JSON)"
			}), /* @__PURE__ */ jsx("textarea", {
				className: "rfp-textarea",
				defaultValue: state.extensions ?? "",
				placeholder: "{\"vendorKey\": \"value\"}",
				onBlur: (e) => on.setExtensions(e.target.value),
				style: {
					fontFamily: "monospace",
					minHeight: 120
				}
			})]
		})] }) : null]
	});
}
//#endregion
//#region editors/project-editor/editor.tsx
function Editor() {
	const [document, dispatch] = useSelectedProjectDocument();
	const setName = useCallback((name) => dispatch(actions.setProjectName({ name })), [dispatch]);
	const setDesc = useCallback((description) => dispatch(actions.setProjectDescription({ description })), [dispatch]);
	const setContent = useCallback((contentURI) => dispatch(actions.setContentUri({ contentURI })), [dispatch]);
	const setEmail = useCallback((email) => dispatch(actions.setProjectEmail({ email })), [dispatch]);
	const setImage = useCallback((image) => dispatch(actions.setProjectImage({ image })), [dispatch]);
	const setCoverImage = useCallback((coverImage) => dispatch(actions.setProjectCoverImage({ coverImage })), [dispatch]);
	const setLicenseUri = useCallback((licenseURI) => dispatch(actions.setLicenseUri({ licenseURI })), [dispatch]);
	const setCode = useCallback((code) => dispatch(actions.setProjectCode({ code })), [dispatch]);
	const setOwnerDid = useCallback((ownerDid) => dispatch(actions.setOwnerDid({ ownerDid })), [dispatch]);
	const setMembersUri = useCallback((membersURI) => dispatch(actions.setMembersUri({ membersURI })), [dispatch]);
	const setAttestationIssuersUri = useCallback((attestationIssuersURI) => dispatch(actions.setProjectAttestationIssuersUri({ attestationIssuersURI })), [dispatch]);
	const addRelevantPool = useCallback((poolId, poolName) => dispatch(actions.addRelevantPool({
		id: generateId(),
		poolId,
		poolName
	})), [dispatch]);
	const removeRelevantPool = useCallback((id) => dispatch(actions.removeRelevantPool({ id })), [dispatch]);
	const addSameAs = useCallback((url) => dispatch(actions.addProjectSameAs({ url })), [dispatch]);
	const removeSameAs = useCallback((url) => dispatch(actions.removeProjectSameAs({ url })), [dispatch]);
	const addSocial = useCallback((name, value) => dispatch(actions.addProjectSocial({
		id: generateId(),
		name,
		value
	})), [dispatch]);
	const removeSocial = useCallback((id) => dispatch(actions.removeProjectSocial({ id })), [dispatch]);
	const setExtensions = useCallback((extensions) => dispatch(actions.setProjectExtensions({ extensions })), [dispatch]);
	if (!document) return null;
	const state = document.state.global;
	return /* @__PURE__ */ jsxs("div", {
		className: "rfp-scope",
		children: [/* @__PURE__ */ jsx(DocumentToolbar, {}), /* @__PURE__ */ jsx("div", {
			className: "rfp-page",
			children: /* @__PURE__ */ jsxs("div", {
				className: "rfp-page-inner",
				children: [
					/* @__PURE__ */ jsx(ProjectHeader, { state }),
					/* @__PURE__ */ jsx(ProjectProfile, {
						state,
						on: {
							setName,
							setDesc,
							setContent,
							setEmail,
							setImage,
							setCoverImage,
							setLicenseUri,
							setCode
						}
					}),
					/* @__PURE__ */ jsx(ProjectAttestations, {
						state,
						on: {
							setMembersUri,
							setAttestationIssuersUri
						}
					}),
					/* @__PURE__ */ jsx(ProjectRelevantPools, {
						state,
						on: {
							addRelevantPool,
							removeRelevantPool
						}
					}),
					/* @__PURE__ */ jsx(ProjectIdentity, {
						state,
						on: {
							setOwnerDid,
							addSameAs,
							removeSameAs
						}
					}),
					/* @__PURE__ */ jsx(ProjectSocials, {
						state,
						on: {
							addSocial,
							removeSocial
						}
					}),
					/* @__PURE__ */ jsx(ProjectExtensions, {
						state,
						on: { setExtensions }
					})
				]
			})
		})]
	});
}
//#endregion
export { Editor as default };

//# sourceMappingURL=editor-DT07a2u3.js.map