import { r as __exportAll } from "./chunk-BSw8zbkd.mjs";
import { A as any, B as generateId, I as object, L as string, N as lazy, P as literal, a as BaseDocumentHeaderSchema, b as isDocumentAction, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, j as array, l as baseLoadFromInput, o as BaseDocumentStateSchema, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState } from "./dist-RakiOObV.mjs";
//#region document-models/research-claim/v1/gen/schema/zod.ts
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
const definedNonNullAnySchema = any().refine((v) => isDefinedNonNullAny(v));
function AddResearchConnectionInputSchema() {
	return object({
		contextPhrase: string(),
		id: string(),
		targetRef: string()
	});
}
function CreateClaimInputSchema() {
	return object({
		content: string(),
		description: string(),
		kind: string(),
		methodology: array(string()),
		sources: array(string()),
		title: string(),
		topics: array(string())
	});
}
function RemoveResearchConnectionInputSchema() {
	return object({ id: string() });
}
function ResearchClaimStateSchema() {
	return object({
		__typename: literal("ResearchClaimState").optional(),
		connections: array(lazy(() => ResearchConnectionSchema())),
		content: string().nullish(),
		description: string().nullish(),
		kind: string().nullish(),
		methodology: array(string()),
		sources: array(string()),
		title: string().nullish(),
		topics: array(string())
	});
}
function ResearchConnectionSchema() {
	return object({
		__typename: literal("ResearchConnection").optional(),
		contextPhrase: string(),
		id: string(),
		targetRef: string()
	});
}
function UpdateClaimContentInputSchema() {
	return object({ content: string() });
}
//#endregion
//#region document-models/research-claim/v1/gen/claim-management/creators.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
var creators_exports = /* @__PURE__ */ __exportAll({
	addResearchConnection: () => addResearchConnection,
	createClaim: () => createClaim,
	removeResearchConnection: () => removeResearchConnection,
	updateClaimContent: () => updateClaimContent
});
const createClaim = (input) => createAction("CREATE_CLAIM", { ...input }, void 0, CreateClaimInputSchema, "global");
const addResearchConnection = (input) => createAction("ADD_RESEARCH_CONNECTION", { ...input }, void 0, AddResearchConnectionInputSchema, "global");
const removeResearchConnection = (input) => createAction("REMOVE_RESEARCH_CONNECTION", { ...input }, void 0, RemoveResearchConnectionInputSchema, "global");
const updateClaimContent = (input) => createAction("UPDATE_CLAIM_CONTENT", { ...input }, void 0, UpdateClaimContentInputSchema, "global");
//#endregion
//#region document-models/research-claim/v1/actions.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
/** Actions for the ResearchClaim document model */
const actions = {
	...baseActions,
	...creators_exports
};
//#endregion
//#region document-models/research-claim/v1/gen/document-model.ts
const documentModel = {
	author: {
		name: "BAI",
		website: "https://bai.powerhouse.io/"
	},
	description: "Bundled research claim — one of 249 interconnected claims about tools for thought, knowledge management, and agent-native cognitive architecture. Read-heavy, populated by maintainers",
	extension: "",
	id: "bai/research-claim",
	name: "ResearchClaim",
	specifications: [{
		changeLog: [],
		modules: [{
			description: "Research claim content management",
			id: "claim-management",
			name: "claim-management",
			operations: [
				{
					description: "Create a research claim",
					errors: [],
					examples: [],
					id: "create-claim",
					name: "CREATE_CLAIM",
					reducer: "state.title = action.input.title;\nstate.description = action.input.description;\nstate.content = action.input.content;\nstate.kind = action.input.kind;\nstate.methodology = action.input.methodology;\nstate.sources = action.input.sources;\nstate.topics = action.input.topics;",
					schema: "input CreateClaimInput {\n    title: String!\n    description: String!\n    content: String!\n    kind: String!\n    methodology: [String!]!\n    sources: [String!]!\n    topics: [String!]!\n}",
					template: "Create a research claim",
					scope: "global"
				},
				{
					description: "Add a connection to another research claim",
					errors: [],
					examples: [],
					id: "add-research-connection",
					name: "ADD_RESEARCH_CONNECTION",
					reducer: "state.connections.push({\n    id: action.input.id,\n    targetRef: action.input.targetRef,\n    contextPhrase: action.input.contextPhrase,\n});",
					schema: "input AddResearchConnectionInput {\n    id: OID!\n    targetRef: String!\n    contextPhrase: String!\n}",
					template: "Add a connection to another research claim",
					scope: "global"
				},
				{
					description: "Remove a connection",
					errors: [],
					examples: [],
					id: "remove-research-connection",
					name: "REMOVE_RESEARCH_CONNECTION",
					reducer: "state.connections = state.connections.filter(c => c.id !== action.input.id);",
					schema: "input RemoveResearchConnectionInput {\n    id: OID!\n}",
					template: "Remove a connection",
					scope: "global"
				},
				{
					description: "Update claim content",
					errors: [],
					examples: [],
					id: "update-claim-content",
					name: "UPDATE_CLAIM_CONTENT",
					reducer: "state.content = action.input.content;",
					schema: "input UpdateClaimContentInput {\n    content: String!\n}",
					template: "Update claim content",
					scope: "global"
				}
			]
		}],
		state: {
			global: {
				examples: [],
				initialValue: "{\n    \"title\": null,\n    \"description\": null,\n    \"content\": null,\n    \"kind\": null,\n    \"methodology\": [],\n    \"sources\": [],\n    \"topics\": [],\n    \"connections\": []\n}",
				schema: "type ResearchConnection {\n    id: OID!\n    targetRef: String!\n    contextPhrase: String!\n}\n\ntype ResearchClaimState {\n    title: String\n    description: String\n    content: String\n    kind: String\n    methodology: [String!]!\n    sources: [String!]!\n    topics: [String!]!\n    connections: [ResearchConnection!]!\n}"
			},
			local: {
				examples: [],
				initialValue: "",
				schema: ""
			}
		},
		version: 1
	}]
};
//#endregion
//#region document-models/research-claim/v1/src/reducers/claim-management.ts
const researchClaimClaimManagementOperations = {
	createClaimOperation(state, action) {
		state.title = action.input.title;
		state.description = action.input.description;
		state.content = action.input.content;
		state.kind = action.input.kind;
		state.methodology = action.input.methodology;
		state.sources = action.input.sources;
		state.topics = action.input.topics;
	},
	addResearchConnectionOperation(state, action) {
		state.connections.push({
			id: action.input.id,
			targetRef: action.input.targetRef,
			contextPhrase: action.input.contextPhrase
		});
	},
	removeResearchConnectionOperation(state, action) {
		state.connections = state.connections.filter((c) => c.id !== action.input.id);
	},
	updateClaimContentOperation(state, action) {
		state.content = action.input.content;
	}
};
//#endregion
//#region document-models/research-claim/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "CREATE_CLAIM":
			CreateClaimInputSchema().parse(action.input);
			researchClaimClaimManagementOperations.createClaimOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_RESEARCH_CONNECTION":
			AddResearchConnectionInputSchema().parse(action.input);
			researchClaimClaimManagementOperations.addResearchConnectionOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_RESEARCH_CONNECTION":
			RemoveResearchConnectionInputSchema().parse(action.input);
			researchClaimClaimManagementOperations.removeResearchConnectionOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_CLAIM_CONTENT":
			UpdateClaimContentInputSchema().parse(action.input);
			researchClaimClaimManagementOperations.updateClaimContentOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/research-claim/v1/gen/document-type.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
const researchClaimDocumentType = "bai/research-claim";
//#endregion
//#region document-models/research-claim/v1/gen/document-schema.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
/** Schema for validating the header object of a ResearchClaim document */
const ResearchClaimDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: literal(researchClaimDocumentType) });
/** Schema for validating the state object of a ResearchClaim document */
const ResearchClaimPHStateSchema = BaseDocumentStateSchema.extend({ global: ResearchClaimStateSchema() });
const ResearchClaimDocumentSchema = object({
	header: ResearchClaimDocumentHeaderSchema,
	state: ResearchClaimPHStateSchema,
	initialState: ResearchClaimPHStateSchema
});
/** Simple helper function to check if a state object is a ResearchClaim document state object */
function isResearchClaimState(state) {
	return ResearchClaimPHStateSchema.safeParse(state).success;
}
/** Simple helper function to assert that a document state object is a ResearchClaim document state object */
function assertIsResearchClaimState(state) {
	ResearchClaimPHStateSchema.parse(state);
}
/** Simple helper function to check if a document is a ResearchClaim document */
function isResearchClaimDocument(document) {
	return ResearchClaimDocumentSchema.safeParse(document).success;
}
/** Simple helper function to assert that a document is a ResearchClaim document */
function assertIsResearchClaimDocument(document) {
	ResearchClaimDocumentSchema.parse(document);
}
//#endregion
//#region document-models/research-claim/v1/gen/utils.ts
const initialGlobalState = {
	title: null,
	description: null,
	content: null,
	kind: null,
	methodology: [],
	sources: [],
	topics: [],
	connections: []
};
const initialLocalState = {};
const utils$1 = {
	fileExtension: "",
	createState(state) {
		return {
			...defaultBaseState(),
			global: {
				...initialGlobalState,
				...state?.global
			},
			local: {
				...initialLocalState,
				...state?.local
			}
		};
	},
	createDocument(state) {
		const document = baseCreateDocument(utils$1.createState, state);
		document.header.documentType = researchClaimDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isResearchClaimState(state);
	},
	assertIsStateOfType(state) {
		return assertIsResearchClaimState(state);
	},
	isDocumentOfType(document) {
		return isResearchClaimDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsResearchClaimDocument(document);
	}
};
//#endregion
//#region document-models/research-claim/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/research-claim/v1/utils.ts
/** Utils for the ResearchClaim document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/research-claim/v1/module.ts
/** Document model module for the ResearchClaim document type */
const ResearchClaim = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { CreateClaimInputSchema as C, UpdateClaimContentInputSchema as D, ResearchConnectionSchema as E, definedNonNullAnySchema as O, AddResearchConnectionInputSchema as S, ResearchClaimStateSchema as T, addResearchConnection as _, utils$1 as a, removeResearchConnection as b, ResearchClaimPHStateSchema as c, isResearchClaimDocument as d, isResearchClaimState as f, actions as g, documentModel as h, initialLocalState as i, isDefinedNonNullAny as k, assertIsResearchClaimDocument as l, reducer as m, utils as n, ResearchClaimDocumentHeaderSchema as o, researchClaimDocumentType as p, initialGlobalState as r, ResearchClaimDocumentSchema as s, ResearchClaim as t, assertIsResearchClaimState as u, createClaim as v, RemoveResearchConnectionInputSchema as w, updateClaimContent as x, creators_exports as y };

//# sourceMappingURL=module-kuJQZaES.mjs.map