"use strict";
/**
 * Mental Capacity (Northern Ireland) Act 2016 Compliance Pack
 *
 * Statute: Mental Capacity Act (Northern Ireland) 2016 (c.18) — partly
 *   in force; the comprehensive single-statute regime fusing capacity
 *   + mental-health treatment for over-16s with impaired capacity in NI.
 *   Distinct from GB Mental Capacity Act 2005 (does NOT apply in NI)
 *   and from Adults with Incapacity (Scotland) Act 2000.
 *
 * Jurisdiction: Northern Ireland
 * Authority:
 *   - Office of Care and Protection (NI High Court) — court-appointed
 *     deputies + lasting powers of attorney register
 *   - Mental Health Review Tribunal (Northern Ireland)
 *   - DoH NI — policy
 *
 * Why this pack (separate from GB MCA / Scotland AWI):
 *   - NI uses a distinctive single-Act fused capacity-and-treatment
 *     regime, the world's first of its kind.
 *   - Five principles closely paralleling MCA + AWI but with NI-specific
 *     court structures + tribunal pathways.
 *
 * Five principles (s.1):
 *   1. Person assumed to have capacity
 *   2. Reasonable steps to maximise capacity
 *   3. Unwise decision does not equal incapacity
 *   4. Best interests when person lacks capacity
 *   5. Less restrictive option preferred
 *
 * Decision-making instruments:
 *   - Lasting Power of Attorney (LPA — NI version)
 *   - Court-appointed deputy
 *   - Public Guardian (NI Office of Care and Protection)
 *   - Approved social worker / nominated person
 *   - Trust Panel / Tribunal pathways for high-risk treatment
 *
 * @connexum/ai-governance
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.NI_MCA_PACK = exports.NI_MCA_CATEGORY_CLASSIFIERS = void 0;
exports.NI_MCA_CATEGORY_CLASSIFIERS = {
    NI_MCA_PRINCIPLE: {
        references: ['Mental Capacity (NI) Act 2016 s.1 — five principles'],
        classifier: (i) => /\b(?:ni\s+mca\s+(?:principle|s\.?\s*1)|mental\s+capacity\s+ni\s+(?:principle|act)|capacity\s+presumption\s+ni)\b/i.test(i),
    },
    NI_LPA: {
        references: ['NI Lasting Power of Attorney register'],
        classifier: (i) => /\b(?:lasting\s+power\s+of\s+attorney\s+ni|lpa\s+ni|ni\s+lpa\s+register)\b/i.test(i),
    },
    COURT_APPOINTED_DEPUTY: {
        references: ['Office of Care and Protection (NI) court-appointed deputy'],
        classifier: (i) => /\b(?:court[\s-]?appointed\s+deputy\s+ni|office\s+of\s+care\s+and\s+protection|public\s+guardian\s+ni)\b/i.test(i),
    },
    TRUST_PANEL_REVIEW: {
        references: ['NI MCA Trust Panel + Tribunal pathways'],
        classifier: (i) => /\b(?:trust\s+panel\s+ni\s+mca|mental\s+health\s+review\s+tribunal\s+ni|nominated\s+person\s+ni)\b/i.test(i),
    },
    CAPACITY_ASSESSMENT_NI: {
        references: ['Mental Capacity (NI) Act 2016 capacity-assessment evidence'],
        classifier: (i) => /\b(?:capacity\s+assessment\s+ni\s+mca|incapacity\s+evidence\s+ni|approved\s+social\s+worker\s+ni)\b/i.test(i),
    },
    CREDENTIALS: {
        references: ['Cross-pack secrets safety'],
        classifier: (i) => {
            if (/\b(?:api[_-]?key|apikey)\s*[=:]\s*["']?[A-Za-z0-9_\-\/+]{16,}["']?/i.test(i))
                return true;
            if (/\bpassword\s*[=:]\s*["']?[A-Za-z0-9!@#$%^&*_\-]{8,}["']?/i.test(i))
                return true;
            if (/-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----/.test(i))
                return true;
            return false;
        },
    },
};
exports.NI_MCA_PACK = {
    categoryClassifiers: exports.NI_MCA_CATEGORY_CLASSIFIERS,
    id: 'ni-mental-capacity',
    aliases: ['ni-mca', 'ni-mca-2016', 'mental-capacity-ni-2016', 'mental-capacity-northern-ireland-act'],
    name: 'Mental Capacity (Northern Ireland) Act 2016',
    version: '1.0.0',
    description: 'NI distinctive single-Act fused capacity-and-treatment regime, world-first of its kind. Five principles (capacity presumption / maximise capacity / unwise decision / best interests / less restrictive option). Decision-making instruments: NI Lasting Power of Attorney, court-appointed deputy via Office of Care and Protection, Public Guardian (NI), Trust Panel / Tribunal pathways. Distinct from GB Mental Capacity Act 2005 (does NOT apply in NI) and Adults with Incapacity (Scotland) Act 2000.',
    authority: 'Office of Care and Protection (NI High Court) + Mental Health Review Tribunal (NI) + DoH NI',
    industries: ['healthcare', 'social-care', 'public-sector', 'financial-services', 'legal'],
    requiredModules: [
        { name: 'governance-runtime', required: true, reason: 'Default-deny on AI actions for adults with impaired capacity unless five-principles attestation captured + proxy authority verified.', reference: 'NI MCA 2016 s.1' },
        { name: 'attestation-manager', required: true, reason: 'Five-principles attestation; LPA + deputy + Trust Panel records; capacity-assessment evidence.', reference: 'NI MCA 2016 ss.1, 5-15' },
        { name: 'approval-queue', required: true, reason: 'T2 named-clinician / approved-social-worker / deputy / attorney sign-off on NI MCA-scope decisions; Trust Panel pathway for high-risk treatment.', reference: 'NI MCA 2016 named-role decision-making' },
        { name: 'audit-integrity', required: true, reason: 'Tamper-evident audit chain for capacity assessments, principle-attestation, proxy-authority verifications, Trust Panel decisions.', reference: 'NI MCA 2016 evidentiary requirements' },
        { name: 'data-classifier', required: true, reason: 'Surface NI MCA evidence categories.', reference: 'NI MCA evidence categorisation' },
        { name: 'agent-auth', required: true, reason: 'OCP register validation for NI LPA / deputy authority before AI executes proxy-authorised actions.', reference: 'Office of Care and Protection register' },
        { name: 'transparency-injector', required: true, reason: 'Adult-facing communication adapted to capacity (s.1(3) maximise-capacity); consultation evidence surfaced.', reference: 'NI MCA 2016 s.1(3), s.7' },
        { name: 'session-persistence', required: true, reason: 'Capacity assessments + decision evidence retained alongside the medical/social-care record (long-term retention aligned with NI public-records practice).', reference: 'NI MCA 2016; HSCNI records practice' },
        { name: 'event-bus', required: true, reason: 'Office of Care and Protection notification routing; Tribunal update routing; capacity-change event detection.', reference: 'NI MCA 2016 OCP notification pathway' },
        { name: 'supply-chain', required: true, reason: 'Sub-supplier NI MCA awareness flow-down (financial / care providers).', reference: 'NI MCA 2016 sub-supplier accountability' },
    ],
    moduleConfig: {
        'governance-runtime': { niMcaFivePrinciplesGateRequired: true, proxyAuthorityVerificationRequired: true, defaultDenyOnUnverifiedProxyAuthority: true },
        'attestation-manager': { fivePrincipleAttestationRequired: true, niLpaRecordRequired: true, courtAppointedDeputyRecordRequired: true, trustPanelRecordRequired: true },
        'approval-queue': { niMcaSignOffRequired: true, trustPanelPathwayRequired: true, reviewTier: 'T2', reviewerCompetence: 'NI_MCA_NAMED_AUTHORITY' },
        'audit-integrity': { ocpEvidenceTrackingRequired: true, tribunalEvidenceTrackingRequired: true },
        'data-classifier': { enabledCategories: ['NI_MCA_PRINCIPLE', 'NI_LPA', 'COURT_APPOINTED_DEPUTY', 'TRUST_PANEL_REVIEW', 'CAPACITY_ASSESSMENT_NI', 'CREDENTIALS'], credentialsAction: 'BLOCK' },
        'agent-auth': { ocpNiRegisterValidationRequired: true, proxyAuthorityIdentityBindingRequired: true },
        'transparency-injector': { adultFacingCommunicationCapacityAdaptedRequired: true, consultationEvidenceSurfacedRequired: true },
        'session-persistence': { retentionDaysAfterAdultDeath: 2190 },
        'event-bus': { ocpNotificationRoutingRequired: true, tribunalUpdateRoutingRequired: true, capacityChangeDetectionRequired: true },
        'supply-chain': { subSupplierNiMcaAwarenessRequired: true },
    },
    providerPolicy: {
        blockedProviders: ['deepseek', 'baidu', 'alibaba'],
        requiredCapabilities: ['DATA-RESIDENCY-UK-OR-EU', 'PROCESSOR-CONTRACT'],
        blockReasons: { deepseek: 'PRC jurisdiction. NI MCA evidence chain must be UK-resident; Office of Care and Protection evidence requires it.', baidu: 'PRC jurisdiction.', alibaba: 'PRC jurisdiction.' },
    },
    dataPolicy: {
        scanCategories: ['NI_MCA_PRINCIPLE', 'NI_LPA', 'COURT_APPOINTED_DEPUTY', 'TRUST_PANEL_REVIEW', 'CAPACITY_ASSESSMENT_NI', 'CREDENTIALS'],
        categoryActions: { NI_MCA_PRINCIPLE: 'WARN', NI_LPA: 'WARN', COURT_APPOINTED_DEPUTY: 'WARN', TRUST_PANEL_REVIEW: 'WARN', CAPACITY_ASSESSMENT_NI: 'WARN', CREDENTIALS: 'BLOCK' },
        encryptionRequired: true, encryptionStandard: 'AES-256-GCM', minimumClassification: 'RESTRICTED',
    },
    retentionPolicy: { auditLogRetentionDays: 3650, sessionRetentionDays: 3650, incidentRetentionDays: 3650, reference: 'NI MCA 2016 + HSCNI records practice', forceDelete: false, requiresLegalHoldSupport: true, sovereignty: ['gb-nir', 'gb'] },
    incidentPolicy: { notificationDeadlineHours: 72, reference: 'Office of Care and Protection notification pathway; NI MCA statutory safeguarding', requiredRecipients: ['office-of-care-and-protection-ni', 'mental-health-review-tribunal-ni', 'data-protection-officer'], formalNotificationRequired: true },
    validators: [
        { id: 'ni-mca-five-principles', description: 'Five NI MCA principles attested per scope decision.', reference: 'NI MCA 2016 s.1', check: 'attestation_active', failSeverity: 'CRITICAL' },
        { id: 'ni-mca-proxy-authority', description: 'NI LPA / deputy authority validated against Office of Care and Protection register.', reference: 'OCP register', check: 'governance_active', failSeverity: 'CRITICAL' },
        { id: 'ni-mca-trust-panel-pathway', description: 'Trust Panel pathway available for high-risk treatment decisions.', reference: 'NI MCA Trust Panel + Tribunal', check: 'approval_queue_active', failSeverity: 'HIGH' },
        { id: 'ni-mca-capacity-assessment', description: 'Capacity assessment captured tamper-evidently; reviewer competence + assessment instrument recorded.', reference: 'NI MCA 2016 capacity assessment', check: 'audit_trail_exists', failSeverity: 'HIGH' },
        { id: 'ni-mca-consultation', description: 'Consultation with relevant others captured; nominated person engaged.', reference: 'NI MCA 2016 consultation duty', check: 'attestation_active', failSeverity: 'HIGH' },
        { id: 'ni-mca-supplier-flow-down', description: 'Sub-supplier NI MCA awareness recorded.', reference: 'NI MCA sub-supplier accountability', check: 'subservice_registry_active', failSeverity: 'MEDIUM' },
        { id: 'ni-mca-evidence-retention', description: 'NI MCA evidence retained alongside medical/social-care record (10 years post-record).', reference: 'HSCNI records practice', check: 'retention_policy_active', failSeverity: 'HIGH' },
        { id: 'ni-mca-encryption', description: 'NI MCA evidence chain encrypted at rest and in transit.', reference: 'UK GDPR Art. 32; NI MCA evidentiary integrity', check: 'encryption_active', failSeverity: 'MEDIUM' },
        { id: 'ni-mca-credential-block', description: 'Plaintext credentials blocked.', reference: 'NI MCA evidentiary integrity', check: 'data_classifier_active', failSeverity: 'CRITICAL' },
    ],
};
//# sourceMappingURL=ni-mental-capacity.js.map