#include "HyperTwistTraining/HyperTwistTrainingControlPlaneLibrary.h"

namespace HyperTwistTrainingControlPlaneLibraryInternal
{
	const TCHAR* ControlPlaneRepo = TEXT("PostHog/posthog");
	const TCHAR* ControlPlaneLicense = TEXT("MIT outside ee/; enterprise license inside ee/");

	FHyperTwistTrainingSourceAttribution MakeAttribution(
		const FString& TrackId,
		const FString& Notes
	)
	{
		FHyperTwistTrainingSourceAttribution Attribution;
		Attribution.SourceMode = EHyperTwistTrainingSourceMode::DirectDonor;
		Attribution.SourceRepo = ControlPlaneRepo;
		Attribution.SourceLicense = ControlPlaneLicense;
		Attribution.SourceTrackId = TrackId;
		Attribution.SourceNotes = Notes;
		return Attribution;
	}

	FHyperTwistTrainingControlPlanePackageReference MakePackageReference(
		const FString& PackageId,
		const FString& Label,
		const FString& PackagePath,
		const FString& UsagePosture,
		const FString& LicensePosture,
		const FString& Summary,
		const TArray<FString>& ApprovedWorkflowTags,
		const TArray<FString>& ExplicitExclusions,
		const FHyperTwistTrainingSourceAttribution& SourceAttribution
	)
	{
		FHyperTwistTrainingControlPlanePackageReference Reference;
		Reference.PackageId = PackageId;
		Reference.Label = Label;
		Reference.PackagePath = PackagePath;
		Reference.UsagePosture = UsagePosture;
		Reference.LicensePosture = LicensePosture;
		Reference.Summary = Summary;
		Reference.ApprovedWorkflowTags = ApprovedWorkflowTags;
		Reference.ExplicitExclusions = ExplicitExclusions;
		Reference.SourceAttribution = SourceAttribution;
		return Reference;
	}
}

FHyperTwistTrainingControlPlaneReferenceBundle
UHyperTwistTrainingControlPlaneLibrary::BuildBundledControlPlaneReferenceBundle()
{
	using namespace HyperTwistTrainingControlPlaneLibraryInternal;

	FHyperTwistTrainingControlPlaneReferenceBundle Bundle;
	Bundle.ReferenceUtc = TEXT("2026-05-13T23:59:00Z");
	Bundle.PrimaryReplayDiagnosticContractId = TEXT("posthog-replay-diagnostics-and-segmentation");
	Bundle.PrimaryFeatureGovernanceContractId = TEXT("posthog-feature-governance-and-blast-radius");
	Bundle.PrimaryScheduledChangeContractId = TEXT("posthog-feature-scheduled-change-policy");
	Bundle.PrimaryEarlyAccessRolloutContractId = TEXT("posthog-early-access-rollout-lifecycle");
	Bundle.PrimaryComplianceBoundaryId = TEXT("posthog-mit-core-and-ee-exclusion-boundary");

	Bundle.PackageReferences =
	{
		MakePackageReference(
			TEXT("package/posthog-root"),
			TEXT("PostHog root MIT core"),
			TEXT("./"),
			TEXT("bounded-control-plane-reference"),
			TEXT("MIT outside ee/; enterprise-restricted ee/ subtree excluded"),
			TEXT("Root monorepo boundary reference for telemetry, replay, and feature-governance extraction while keeping the broader product analytics shell and enterprise subtree outside HyperTwist ownership."),
			{TEXT("control-plane-boundary"), TEXT("source-routing"), TEXT("notice-retention")},
			{
				TEXT("ee/ subtree"),
				TEXT("whole-product analytics shell adoption"),
				TEXT("deployment and self-hosting inheritance")
			},
			MakeAttribution(
				TEXT("control-plane/package-root"),
				TEXT("Preserves the root MIT-versus-ee subtree split so HyperTwist can use replay and feature-governance value while keeping the enterprise boundary explicit.")
			)
		),
		MakePackageReference(
			TEXT("package/posthog-replay"),
			TEXT("Replay and session-recordings surfaces"),
			TEXT("./products/replay + ./frontend/src/scenes/session-recordings + ./common/replay-shared"),
			TEXT("bounded-replay-diagnostic-reference"),
			TEXT("MIT outside ee/"),
			TEXT("Replay diagnostic, recording-state, timeline-segmentation, warning-categorization, and capture-debug reference surfaces for HyperTwist replay troubleshooting and review workflows."),
			{TEXT("replay-diagnostics"), TEXT("timeline-analysis"), TEXT("capture-troubleshooting")},
			{
				TEXT("full analytics dashboard shell"),
				TEXT("general web session recorder product ownership")
			},
			MakeAttribution(
				TEXT("control-plane/replay"),
				TEXT("Preserves replay diagnostic signals, session-recording workflow patterns, and window-aware segmentation seams from the retained PostHog replay lane.")
			)
		),
		MakePackageReference(
			TEXT("package/posthog-feature-flags"),
			TEXT("Feature flags and rollout governance surfaces"),
			TEXT("./products/feature_flags + ./frontend/src/scenes/feature-flags"),
			TEXT("bounded-feature-governance-reference"),
			TEXT("MIT outside ee/"),
			TEXT("Feature-flag targeting, rollout percentage, multivariate variant, evaluation-runtime, blast-radius, and activity-log reference surfaces for HyperTwist control-plane governance."),
			{TEXT("feature-governance"), TEXT("blast-radius-review"), TEXT("scheduled-rollout")},
			{
				TEXT("whole feature-management product shell"),
				TEXT("general product analytics or experimentation platform ownership")
			},
			MakeAttribution(
				TEXT("control-plane/feature-flags"),
				TEXT("Preserves the retained feature-governance seams from PostHog for bounded HyperTwist rollout control, audit summaries, and blast-radius review.")
			)
		),
		MakePackageReference(
			TEXT("package/posthog-early-access"),
			TEXT("Early access feature lifecycle surfaces"),
			TEXT("./products/early_access_features"),
			TEXT("bounded-early-access-reference"),
			TEXT("MIT outside ee/"),
			TEXT("Early-access lifecycle, stage-to-flag enrollment, rollout-to-all transitions, documentation links, and internal-event posture for bounded HyperTwist gated-feature release workflows."),
			{TEXT("early-access-lifecycle"), TEXT("gated-release"), TEXT("rollout-transition")},
			{
				TEXT("whole SaaS product-preview shell"),
				TEXT("generic customer-marketing workflow ownership")
			},
			MakeAttribution(
				TEXT("control-plane/early-access"),
				TEXT("Preserves the retained early-access lifecycle and feature-enrollment patterns from PostHog for bounded HyperTwist release-governance use.")
			)
		)
	};

	FHyperTwistTrainingReplayDiagnosticContract ReplayContract;
	ReplayContract.ContractId = TEXT("posthog-replay-diagnostics-and-segmentation");
	ReplayContract.Title = TEXT("Replay diagnostics and segmentation");
	ReplayContract.Summary = TEXT("First-party HyperTwist replay diagnostic contract preserving recording-state signals, trigger states, capture-failure verdicts, warning categorization, and window-aware timeline segmentation from the retained PostHog replay lane.");
	ReplayContract.DiagnosticSignalKeys =
	{
		TEXT("$has_recording"),
		TEXT("$recording_status"),
		TEXT("$session_recording_start_reason"),
		TEXT("$sdk_debug_replay_url_trigger_status"),
		TEXT("$sdk_debug_replay_event_trigger_status"),
		TEXT("$sdk_debug_replay_linked_flag_trigger_status"),
		TEXT("$sdk_debug_replay_internal_buffer_length"),
		TEXT("$sdk_debug_replay_internal_buffer_size"),
		TEXT("$sdk_debug_replay_flushed_size"),
		TEXT("$sdk_debug_recording_script_not_loaded"),
		TEXT("$replay_sample_rate"),
		TEXT("$replay_minimum_duration"),
		TEXT("$session_recording_remote_config"),
		TEXT("$sdk_debug_replay_remote_trigger_matching_config")
	};
	ReplayContract.VerdictKeys =
	{
		TEXT("captured"),
		TEXT("ad_blocked"),
		TEXT("disabled"),
		TEXT("trigger_pending"),
		TEXT("sampled_out"),
		TEXT("buffering_empty"),
		TEXT("unknown")
	};
	ReplayContract.TimelineSemantics =
	{
		TEXT("treat missing diagnostic properties as unknown rather than false"),
		TEXT("preserve trigger-disabled, trigger-pending, and trigger-matched state distinctions"),
		TEXT("preserve buffered-versus-flushed recording diagnostics"),
		TEXT("preserve window-aware snapshot grouping and tracked-window segmentation boundaries"),
		TEXT("preserve recorder-warning categorization while ignoring known low-value missing-node noise")
	};
	ReplayContract.WarningCategoryRules =
	{
		TEXT("bucket warning categories from the first meaningful non-prefix string or error message"),
		TEXT("ignore warnings beginning with 'Could not find node with id'"),
		TEXT("surface non-ignored replay warnings into operator-facing diagnostics rather than raw console spam")
	};
	ReplayContract.SuggestedOperatorActions =
	{
		TEXT("inspect replay settings when recording status is disabled or trigger-gated"),
		TEXT("differentiate ad-blocked recorder failures from sampling and minimum-duration failures"),
		TEXT("review sample rate, minimum duration, and remote trigger configuration before declaring a replay ingestion bug"),
		TEXT("use segmentation and tracked-window posture to explain missing or fragmented replay slices")
	};
	ReplayContract.ApprovedWorkflowTags =
	{
		TEXT("replay-diagnostics"),
		TEXT("capture-troubleshooting"),
		TEXT("timeline-analysis"),
		TEXT("warning-categorization")
	};
	ReplayContract.ExplicitExclusions =
	{
		TEXT("full session-replay product shell"),
		TEXT("generic website analytics playback ownership"),
		TEXT("ee/ replay or enterprise debugging surfaces")
	};
	ReplayContract.SourceAttribution = MakeAttribution(
		TEXT("control-plane/replay-diagnostics"),
		TEXT("Preserves replay diagnostic signals, segment creation posture, and warning-categorization seams from the retained PostHog replay lane for first-party HyperTwist troubleshooting flows.")
	);
	Bundle.ReplayDiagnosticContracts = {ReplayContract};

	FHyperTwistTrainingFeatureGovernanceContract FeatureGovernance;
	FeatureGovernance.ContractId = TEXT("posthog-feature-governance-and-blast-radius");
	FeatureGovernance.Title = TEXT("Feature governance and blast radius");
	FeatureGovernance.Summary = TEXT("First-party HyperTwist feature-governance contract preserving rollout groups, evaluation runtime, blast-radius review, variant management, and activity-log summary posture from the retained PostHog feature-flags lane.");
	FeatureGovernance.SupportedConditionScopes =
	{
		TEXT("person-scoped conditions"),
		TEXT("group-scoped conditions"),
		TEXT("mixed-targeting with per-condition aggregation scope"),
		TEXT("default evaluation contexts")
	};
	FeatureGovernance.SupportedRolloutControls =
	{
		TEXT("rollout percentage per condition group"),
		TEXT("multivariate variants and variant-specific payloads"),
		TEXT("evaluation runtime labels for client, server, or both"),
		TEXT("condition ordering and drag-reorder semantics"),
		TEXT("linked-flag and trigger-aware gating posture")
	};
	FeatureGovernance.EvaluationRuntimeLabels =
	{
		TEXT("both client and server"),
		TEXT("client-side only"),
		TEXT("server-side only")
	};
	FeatureGovernance.BlastRadiusReviewRules =
	{
		TEXT("preserve affected-count and total-count review per condition set"),
		TEXT("avoid live blast-radius calls in readonly displays"),
		TEXT("reset incompatible property filters when switching aggregation scopes"),
		TEXT("treat mixed-targeting transitions as explicit control-plane events rather than silent state drift")
	};
	FeatureGovernance.AuditActivityPatterns =
	{
		TEXT("enable or disable state changes"),
		TEXT("payload changes"),
		TEXT("release-condition additions or removals"),
		TEXT("variant rollout and variant deletion changes"),
		TEXT("runtime and targeting-scope changes")
	};
	FeatureGovernance.ApprovedWorkflowTags =
	{
		TEXT("feature-governance"),
		TEXT("blast-radius-review"),
		TEXT("variant-rollout"),
		TEXT("audit-summary")
	};
	FeatureGovernance.ExplicitExclusions =
	{
		TEXT("whole feature-management product shell"),
		TEXT("general experimentation suite ownership"),
		TEXT("ee/ approvals or enterprise-only governance surfaces")
	};
	FeatureGovernance.SourceAttribution = MakeAttribution(
		TEXT("control-plane/feature-governance"),
		TEXT("Preserves rollout-group, blast-radius, evaluation-runtime, and activity-log semantics from the retained PostHog feature-governance lane for first-party HyperTwist control-plane use.")
	);
	Bundle.FeatureGovernanceContracts = {FeatureGovernance};

	FHyperTwistTrainingScheduledChangeContract ScheduledChange;
	ScheduledChange.ContractId = TEXT("posthog-feature-scheduled-change-policy");
	ScheduledChange.Title = TEXT("Scheduled change policy");
	ScheduledChange.Summary = TEXT("First-party HyperTwist scheduled-change contract preserving future activation, pause/resume-safe editing, recurrence, cron validation, and patch-only update posture from the retained PostHog feature-governance lane.");
	ScheduledChange.SupportedOperationTypes =
	{
		TEXT("update_status"),
		TEXT("future activation or deactivation"),
		TEXT("pause-safe schedule editing")
	};
	ScheduledChange.SupportedRepeatModes =
	{
		TEXT("one-time"),
		TEXT("daily"),
		TEXT("weekly"),
		TEXT("monthly"),
		TEXT("cron")
	};
	ScheduledChange.ValidationRules =
	{
		TEXT("scheduled date is required"),
		TEXT("non-recurring schedules must be in the future"),
		TEXT("support only 5-field cron expressions"),
		TEXT("cron must parse successfully before previewing next occurrence"),
		TEXT("end date must be after the scheduled start date")
	};
	ScheduledChange.PatchSemantics =
	{
		TEXT("save only changed fields rather than rewriting the entire schedule payload"),
		TEXT("recompute scheduled-at preview from cron when the expression changes"),
		TEXT("clear recurrence and end-date state when switching back to one-time schedules")
	};
	ScheduledChange.ApprovedWorkflowTags =
	{
		TEXT("scheduled-rollout"),
		TEXT("cron-validation"),
		TEXT("change-review"),
		TEXT("future-activation")
	};
	ScheduledChange.ExplicitExclusions =
	{
		TEXT("whole generic task-scheduler ownership"),
		TEXT("enterprise approval-routing surfaces"),
		TEXT("deployment-orchestration platform ownership")
	};
	ScheduledChange.SourceAttribution = MakeAttribution(
		TEXT("control-plane/scheduled-change"),
		TEXT("Preserves the bounded future-change, recurrence, cron-validation, and patch-only schedule-edit semantics from the retained PostHog feature-governance lane.")
	);
	Bundle.ScheduledChangeContracts = {ScheduledChange};

	FHyperTwistTrainingEarlyAccessRolloutContract EarlyAccess;
	EarlyAccess.ContractId = TEXT("posthog-early-access-rollout-lifecycle");
	EarlyAccess.Title = TEXT("Early access rollout lifecycle");
	EarlyAccess.Summary = TEXT("First-party HyperTwist early-access rollout contract preserving staged release lifecycle, feature-enrollment linkage, documentation handoff, and rollout-to-all transitions from the retained PostHog early-access lane.");
	EarlyAccess.LifecycleStages =
	{
		TEXT("draft"),
		TEXT("concept"),
		TEXT("alpha"),
		TEXT("beta"),
		TEXT("general-availability"),
		TEXT("archived")
	};
	EarlyAccess.ActiveStages =
	{
		TEXT("alpha"),
		TEXT("beta"),
		TEXT("general-availability")
	};
	EarlyAccess.EnrollmentRules =
	{
		TEXT("active-stage entry enables feature-flag enrollment for opted-in users"),
		TEXT("concept stage gauges interest without enabling functionality"),
		TEXT("non-active stages clear feature-enrollment super-group posture"),
		TEXT("link only to single-variant, non-group-based feature flags")
	};
	EarlyAccess.RolloutToAllRules =
	{
		TEXT("when promoting to general availability with rollout_to_all, clear enrollment gates"),
		TEXT("replace opt-in conditions with a 100 percent rollout group"),
		TEXT("preserve documentation URL and payload as first-party release metadata")
	};
	EarlyAccess.InternalEventOutputs =
	{
		TEXT("$early_access_feature_updated internal event with previous and next serialized state"),
		TEXT("stage-change event production for release-lifecycle transitions")
	};
	EarlyAccess.ApprovedWorkflowTags =
	{
		TEXT("early-access-lifecycle"),
		TEXT("opt-in-rollout"),
		TEXT("documentation-handoff"),
		TEXT("ga-transition")
	};
	EarlyAccess.ExplicitExclusions =
	{
		TEXT("whole product-preview marketing shell"),
		TEXT("generic SaaS customer portal ownership"),
		TEXT("enterprise-only product-management surfaces")
	};
	EarlyAccess.SourceAttribution = MakeAttribution(
		TEXT("control-plane/early-access-lifecycle"),
		TEXT("Preserves stage-based early-access rollout, enrollment, and GA transition semantics from the retained PostHog early-access lane for first-party HyperTwist release control.")
	);
	Bundle.EarlyAccessRolloutContracts = {EarlyAccess};

	FHyperTwistTrainingControlPlaneComplianceBoundary ComplianceBoundary;
	ComplianceBoundary.BoundaryId = TEXT("posthog-mit-core-and-ee-exclusion-boundary");
	ComplianceBoundary.Title = TEXT("PostHog MIT-core and ee-exclusion boundary");
	ComplianceBoundary.Summary = TEXT("First-party HyperTwist compliance boundary for using PostHog MIT-core replay and feature-governance patterns while keeping the enterprise-restricted ee subtree and full analytics platform shell outside the landed lane.");
	ComplianceBoundary.AllowedSourceRoots =
	{
		TEXT("./frontend/src/scenes/session-recordings"),
		TEXT("./frontend/src/scenes/feature-flags"),
		TEXT("./products/replay"),
		TEXT("./products/feature_flags"),
		TEXT("./products/early_access_features"),
		TEXT("./common/replay-shared")
	};
	ComplianceBoundary.ExcludedSourceRoots =
	{
		TEXT("./ee"),
		TEXT("./products/product_analytics"),
		TEXT("./products/web_analytics"),
		TEXT("./products/experiments"),
		TEXT("./products/data_warehouse"),
		TEXT("./products/workflows")
	};
	ComplianceBoundary.RequiredNoticeActions =
	{
		TEXT("preserve root MIT license materials for any reused core-path code or closely adapted notices"),
		TEXT("keep the ee/ exclusion explicit in packet docs, manifests, and future widening notes"),
		TEXT("do not represent the landed control-plane lane as permission to consume enterprise paths")
	};
	ComplianceBoundary.ProvenanceCaveats =
	{
		TEXT("the root MIT license does not flatten the ee/ subtree into an ordinary donor lane"),
		TEXT("the retained value is control-plane telemetry, replay diagnostics, and feature governance rather than whole-product analytics ownership"),
		TEXT("HyperTwist should preserve replay and rollout semantics in first-party contracts instead of inheriting the larger PostHog deployment model")
	};
	ComplianceBoundary.ExplicitExclusions =
	{
		TEXT("ee/ subtree use without separate rights"),
		TEXT("whole product analytics shell adoption"),
		TEXT("generic cloud telemetry platform ownership"),
		TEXT("broad self-hosting and infrastructure inheritance")
	};
	ComplianceBoundary.SourceAttribution = MakeAttribution(
		TEXT("control-plane/compliance-boundary"),
		TEXT("Preserves the PostHog MIT-core versus enterprise-subtree boundary so HyperTwist can land a bounded control-plane lane without inheriting the excluded ee/ posture.")
	);
	Bundle.ComplianceBoundaries = {ComplianceBoundary};

	return Bundle;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetPackageReferenceById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& PackageId,
	FHyperTwistTrainingControlPlanePackageReference& OutReference
)
{
	for (const FHyperTwistTrainingControlPlanePackageReference& Reference : Bundle.PackageReferences)
	{
		if (Reference.PackageId.Equals(PackageId, ESearchCase::IgnoreCase))
		{
			OutReference = Reference;
			return true;
		}
	}

	OutReference = FHyperTwistTrainingControlPlanePackageReference();
	return false;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetReplayDiagnosticContractById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& ContractId,
	FHyperTwistTrainingReplayDiagnosticContract& OutContract
)
{
	for (const FHyperTwistTrainingReplayDiagnosticContract& Contract : Bundle.ReplayDiagnosticContracts)
	{
		if (Contract.ContractId.Equals(ContractId, ESearchCase::IgnoreCase))
		{
			OutContract = Contract;
			return true;
		}
	}

	OutContract = FHyperTwistTrainingReplayDiagnosticContract();
	return false;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetFeatureGovernanceContractById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& ContractId,
	FHyperTwistTrainingFeatureGovernanceContract& OutContract
)
{
	for (const FHyperTwistTrainingFeatureGovernanceContract& Contract : Bundle.FeatureGovernanceContracts)
	{
		if (Contract.ContractId.Equals(ContractId, ESearchCase::IgnoreCase))
		{
			OutContract = Contract;
			return true;
		}
	}

	OutContract = FHyperTwistTrainingFeatureGovernanceContract();
	return false;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetScheduledChangeContractById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& ContractId,
	FHyperTwistTrainingScheduledChangeContract& OutContract
)
{
	for (const FHyperTwistTrainingScheduledChangeContract& Contract : Bundle.ScheduledChangeContracts)
	{
		if (Contract.ContractId.Equals(ContractId, ESearchCase::IgnoreCase))
		{
			OutContract = Contract;
			return true;
		}
	}

	OutContract = FHyperTwistTrainingScheduledChangeContract();
	return false;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetEarlyAccessRolloutContractById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& ContractId,
	FHyperTwistTrainingEarlyAccessRolloutContract& OutContract
)
{
	for (const FHyperTwistTrainingEarlyAccessRolloutContract& Contract : Bundle.EarlyAccessRolloutContracts)
	{
		if (Contract.ContractId.Equals(ContractId, ESearchCase::IgnoreCase))
		{
			OutContract = Contract;
			return true;
		}
	}

	OutContract = FHyperTwistTrainingEarlyAccessRolloutContract();
	return false;
}

bool UHyperTwistTrainingControlPlaneLibrary::TryGetComplianceBoundaryById(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle,
	const FString& BoundaryId,
	FHyperTwistTrainingControlPlaneComplianceBoundary& OutBoundary
)
{
	for (const FHyperTwistTrainingControlPlaneComplianceBoundary& Boundary : Bundle.ComplianceBoundaries)
	{
		if (Boundary.BoundaryId.Equals(BoundaryId, ESearchCase::IgnoreCase))
		{
			OutBoundary = Boundary;
			return true;
		}
	}

	OutBoundary = FHyperTwistTrainingControlPlaneComplianceBoundary();
	return false;
}

FString UHyperTwistTrainingControlPlaneLibrary::BuildPackageChecklistTsv(
	const FHyperTwistTrainingControlPlaneReferenceBundle& Bundle
)
{
	FString Output = TEXT("package_id\tlabel\tpackage_path\tusage_posture\tlicense_posture\tsummary\n");
	for (const FHyperTwistTrainingControlPlanePackageReference& Reference : Bundle.PackageReferences)
	{
		if (!Reference.IsStructurallyValid())
		{
			continue;
		}

		Output.Append(Reference.PackageId);
		Output.Append(TEXT("\t"));
		Output.Append(Reference.Label);
		Output.Append(TEXT("\t"));
		Output.Append(Reference.PackagePath);
		Output.Append(TEXT("\t"));
		Output.Append(Reference.UsagePosture);
		Output.Append(TEXT("\t"));
		Output.Append(Reference.LicensePosture);
		Output.Append(TEXT("\t"));
		Output.Append(Reference.Summary.Replace(TEXT("\t"), TEXT(" ")));
		Output.Append(TEXT("\n"));
	}

	return Output;
}
