const require_chunk = require('./chunk-DWy1uDak.cjs');
const require_errors = require('./errors-BtJEw2Z-.cjs');
const require_define = require('./define-BfP4rFlE.cjs');
const require_api = require('./api-CZD9zwQ-.cjs');
const require_schema = require('./schema-Cv_VNAHz.cjs');
const require_issue_helpers = require('./issue-helpers-DbPTv_qC.cjs');
const require_formatting = require('./formatting-EM76FrY3.cjs');
const __sentry_core = require_chunk.__toESM(require("@sentry/core"));

//#region src/tools/update-issue.ts
var update_issue_default = require_define.defineTool({
	name: "update_issue",
	requiredScopes: ["event:write"],
	description: [
		"Update an issue's status or assignment in Sentry. This allows you to resolve, ignore, or reassign issues.",
		"",
		"Use this tool when you need to:",
		"- Resolve an issue that has been fixed",
		"- Assign an issue to a team member or team for investigation",
		"- Mark an issue as ignored to reduce noise",
		"- Reopen a resolved issue by setting status to 'unresolved'",
		"",
		"<examples>",
		"### Resolve an issue",
		"",
		"```",
		"update_issue(organizationSlug='my-organization', issueId='PROJECT-123', status='resolved')",
		"```",
		"",
		"### Assign an issue to a user (use whoami to get your user ID)",
		"",
		"```",
		"update_issue(organizationSlug='my-organization', issueId='PROJECT-123', assignedTo='user:123456')",
		"```",
		"",
		"### Assign an issue to a team",
		"",
		"```",
		"update_issue(organizationSlug='my-organization', issueId='PROJECT-123', assignedTo='team:789')",
		"```",
		"",
		"### Mark an issue as ignored",
		"",
		"```",
		"update_issue(organizationSlug='my-organization', issueId='PROJECT-123', status='ignored')",
		"```",
		"",
		"</examples>",
		"",
		"<hints>",
		"- If the user provides the `issueUrl`, you can ignore the other required parameters and extract them from the URL.",
		"- At least one of `status` or `assignedTo` must be provided to update the issue.",
		"- assignedTo format: Use 'user:ID' for users (e.g., 'user:123456') or 'team:ID' for teams (e.g., 'team:789')",
		"- To find your user ID, first use the whoami tool which returns your numeric user ID",
		"- Valid status values are: 'resolved', 'resolvedInNextRelease', 'unresolved', 'ignored'.",
		"</hints>"
	].join("\n"),
	inputSchema: {
		organizationSlug: require_schema.ParamOrganizationSlug.optional(),
		regionUrl: require_schema.ParamRegionUrl.optional(),
		issueId: require_schema.ParamIssueShortId.optional(),
		issueUrl: require_schema.ParamIssueUrl.optional(),
		status: require_schema.ParamIssueStatus.optional(),
		assignedTo: require_schema.ParamAssignedTo.optional()
	},
	annotations: {
		readOnlyHint: false,
		destructiveHint: true,
		idempotentHint: true,
		openWorldHint: true
	},
	async handler(params, context) {
		const apiService = require_api.apiServiceFromContext(context, { regionUrl: params.regionUrl });
		if (!params.issueUrl && !params.issueId) throw new require_errors.UserInputError("Either `issueId` or `issueUrl` must be provided");
		if (!params.issueUrl && !params.organizationSlug) throw new require_errors.UserInputError("`organizationSlug` is required when providing `issueId`");
		if (!params.status && !params.assignedTo) throw new require_errors.UserInputError("At least one of `status` or `assignedTo` must be provided to update the issue");
		const { organizationSlug: orgSlug, issueId: parsedIssueId } = require_issue_helpers.parseIssueParams({
			organizationSlug: params.organizationSlug,
			issueId: params.issueId,
			issueUrl: params.issueUrl
		});
		(0, __sentry_core.setTag)("organization.slug", orgSlug);
		const currentIssue = await apiService.getIssue({
			organizationSlug: orgSlug,
			issueId: parsedIssueId
		});
		const updatedIssue = await apiService.updateIssue({
			organizationSlug: orgSlug,
			issueId: parsedIssueId,
			status: params.status,
			assignedTo: params.assignedTo
		});
		let output = `# Issue ${updatedIssue.shortId} Updated in **${orgSlug}**\n\n`;
		output += `**Issue**: ${updatedIssue.title}\n`;
		output += `**URL**: ${apiService.getIssueUrl(orgSlug, updatedIssue.shortId)}\n\n`;
		output += "## Changes Made\n\n";
		if (params.status && currentIssue.status !== params.status) output += `**Status**: ${currentIssue.status} → **${params.status}**\n`;
		if (params.assignedTo) {
			const oldAssignee = require_formatting.formatAssignedTo(currentIssue.assignedTo ?? null);
			const newAssignee = params.assignedTo === "me" ? "You" : params.assignedTo;
			output += `**Assigned To**: ${oldAssignee} → **${newAssignee}**\n`;
		}
		output += "\n## Current Status\n\n";
		output += `**Status**: ${updatedIssue.status}\n`;
		const currentAssignee = require_formatting.formatAssignedTo(updatedIssue.assignedTo ?? null);
		output += `**Assigned To**: ${currentAssignee}\n`;
		output += "\n# Using this information\n\n";
		output += `- The issue has been successfully updated in Sentry\n`;
		output += `- You can view the issue details using: \`get_issue_details(organizationSlug="${orgSlug}", issueId="${updatedIssue.shortId}")\`\n`;
		if (params.status === "resolved") output += `- The issue is now marked as resolved and will no longer generate alerts\n`;
		else if (params.status === "ignored") output += `- The issue is now ignored and will not generate alerts until it escalates\n`;
		return output;
	}
});

//#endregion
Object.defineProperty(exports, 'update_issue_default', {
  enumerable: true,
  get: function () {
    return update_issue_default;
  }
});
//# sourceMappingURL=update-issue-eELBq_Uy.cjs.map