INSERT INTO guides (page_key, content_json) VALUES

('fleet.tasks', $${
  "title": "Fleet Task Workflow",
  "subtitle": "How to deploy hotfixes and software to ATMs",
  "sections": [
    {
      "icon": "📤",
      "heading": "Upload Hotfix to CDN",
      "steps": [
        { "text": "Go to <strong>cdn.bcos.cloud/uploads.html</strong> and log in with your credentials." },
        { "text": "Obtain your upload code from the portal." },
        { "text": "Upload your hotfix <code>.zip</code> file using the upload code.", "note": "This CDN upload step applies to HOTFIX artifacts only." }
      ]
    },
    {
      "icon": "📦",
      "heading": "Import into Fleet Artifacts",
      "steps": [
        { "text": "Go to the <strong>Artifacts</strong> tab in Fleet Tasks." },
        { "text": "Click <strong>Import Hotfix from CDN</strong> — available hotfixes on the CDN will be listed." },
        { "text": "Click <strong>Import</strong> next to the hotfix you uploaded." },
        { "text": "Once imported, click <strong>Enable</strong> on the artifact.", "note": "An artifact must be enabled before it can be used in a task." }
      ]
    },
    {
      "icon": "🚀",
      "heading": "Create a Deployment Task",
      "steps": [
        { "text": "Click <strong>Create Task</strong> in the toolbar." },
        { "text": "Select task kind: <strong>HOTFIX</strong> to download and apply immediately, or <strong>HOTFIX_INSTALL</strong> to schedule within a patch window." },
        { "text": "Choose the imported artifact and select one or more target ATMs." },
        { "text": "Submit — the task is created with status <strong>Pending Approval</strong> and will not execute until approved." }
      ]
    },
    {
      "icon": "✅",
      "heading": "Approval",
      "steps": [
        { "text": "A user with fleet approver permission opens the <strong>Approvals</strong> tab." },
        { "text": "They can add an optional note, then click <strong>Approve</strong> or <strong>Reject</strong>." },
        { "text": "Approved tasks move to <strong>Queued</strong> and ATMs pick them up on the next check-in.", "note": "Rejected tasks are cancelled. The requester should be notified separately." }
      ]
    },
    {
      "icon": "🕐",
      "heading": "Patch Windows (HOTFIX_INSTALL)",
      "steps": [
        { "text": "Assign a <strong>Patch Window</strong> to ATMs via device settings to control when installs run." },
        { "text": "When a HOTFIX_INSTALL task is created, it auto-schedules within that window — the <strong>Scheduled</strong> tab shows the queued time." },
        { "text": "The task still requires approval before it will execute." },
        { "text": "If an ATM has no patch window assigned, the install runs immediately after approval.", "note": "Patch windows are defined in the Patch Windows tab." }
      ]
    }
  ]
}$$),

('fleet.artifacts', $${
  "title": "Artifact Import Guide",
  "subtitle": "Fleet Management",
  "sections": [
    {
      "icon": "🤖",
      "heading": "Import Agent",
      "steps": [
        { "text": "Fetches the latest HiveOps Agent release from the CDN manifest." },
        { "text": "Pulls all available packages — patch JARs and standard full installers — for each platform (Windows, Linux)." },
        { "text": "Import the patch package to create an <strong>UPDATE_AGENT</strong> fleet task that pushes agent upgrades to devices.", "note": "Use patch packages (small, agent core only) for regular upgrades." }
      ]
    },
    {
      "icon": "🔧",
      "heading": "Import Hotfix",
      "steps": [
        { "text": "Fetches hotfix packages from the CDN manifest at <code>cdn.bcos.cloud</code>." },
        { "text": "Hotfix artifacts are deployed to devices via a <strong>UPDATE_HOTFIX</strong> fleet task without requiring an agent update.", "note": "Use for urgent patches, customer-specific fixes, or OS-level updates." }
      ]
    },
    {
      "icon": "📦",
      "heading": "Import Software",
      "steps": [
        { "text": "Fetches third-party software packages from the CDN software manifest." },
        { "text": "Deploy via <strong>UPDATE_SOFTWARE</strong> fleet tasks to install or update third-party applications.", "note": "New packages are uploaded via the Browser CDN tool." }
      ]
    }
  ]
}$$),

('fleet.patch-windows', $${
  "title": "Patch Window Guide",
  "subtitle": "How to schedule and manage ATM maintenance windows",
  "sections": [
    {
      "icon": "🕐",
      "heading": "What is a Patch Window?",
      "steps": [
        { "text": "A Patch Window defines a recurring time slot when ATMs are allowed to install hotfixes." },
        { "text": "ATMs assigned to a window will only run <strong>HOTFIX_INSTALL</strong> tasks during that window — never outside of it.", "note": "HOTFIX tasks (immediate download) are not affected by patch windows — only HOTFIX_INSTALL." },
        { "text": "Windows can recur <strong>every week</strong> on selected days, or on a <strong>specific week of the month</strong> (e.g. 2nd Tuesday)." }
      ]
    },
    {
      "icon": "➕",
      "heading": "Create a Patch Window",
      "steps": [
        { "text": "Click <strong>+ New Patch Window</strong> in the toolbar." },
        { "text": "Enter a name and select the <strong>institution</strong> this window belongs to." },
        { "text": "Select one or more <strong>days of the week</strong> when the window is active." },
        { "text": "Optionally set a <strong>Week of Month</strong> to make it monthly (e.g. 1st week only). Leave blank for weekly recurrence." },
        { "text": "Set the <strong>start and end time</strong> and select the correct <strong>timezone</strong>.", "note": "The window runs from start time to end time — keep it outside business hours." }
      ]
    },
    {
      "icon": "🏧",
      "heading": "Assign ATMs to a Window",
      "steps": [
        { "text": "Click any window row in the table to open the ATM assignment panel." },
        { "text": "ATMs currently assigned to that window are listed with their location." },
        { "text": "To assign an ATM, edit the ATM record in Device Management and set its Patch Window." },
        { "text": "To remove an ATM, click <strong>Unassign</strong> next to it in the panel.", "note": "An ATM can only belong to one patch window at a time." }
      ]
    },
    {
      "icon": "🚀",
      "heading": "Using with HOTFIX_INSTALL Tasks",
      "steps": [
        { "text": "When a <strong>HOTFIX_INSTALL</strong> task is created for an ATM with a patch window, it is automatically scheduled for the next available window slot." },
        { "text": "The scheduled time appears in the <strong>Scheduled</strong> tab in Fleet Tasks." },
        { "text": "The task still requires <strong>approval</strong> before it will execute — approval can happen before the window opens." },
        { "text": "If the ATM has no patch window assigned, the install runs immediately after approval.", "note": "Always assign a patch window to ATMs in live production environments." }
      ]
    }
  ]
}$$),

('devices.list', $${
  "title": "Device List",
  "subtitle": "How to find, filter, and manage your devices",
  "sections": [
    {
      "icon": "🔍",
      "heading": "Finding Devices",
      "steps": [
        { "text": "Use the Search box to find by ATM ID or location name." },
        { "text": "Filter by Status, Model, Group, or Agent Version in the left sidebar." },
        { "text": "Active filters appear as tags above the table — click × to remove any." }
      ]
    },
    {
      "icon": "🟢",
      "heading": "Understanding Status Indicators",
      "steps": [
        { "text": "<strong>IN SERVICE</strong> (green) — device is operational." },
        { "text": "<strong>DOWN</strong> (red) — device has an active fault." },
        { "text": "<strong>MAINTENANCE</strong> (orange) — device is under scheduled service." },
        { "text": "<strong>AGENT_OFFLINE</strong> (grey dot) — agent has not checked in for more than 5 minutes." },
        { "text": "The agent version and CDN speed bars show the software state of each device." }
      ]
    },
    {
      "icon": "👆",
      "heading": "Viewing a Device",
      "steps": [
        { "text": "Click any row to open the quick-view sidebar on the right." },
        { "text": "The sidebar has three tabs: Properties, Modules, and Command Center." },
        { "text": "Click the device ID link to open the full Device Detail page." }
      ]
    },
    {
      "icon": "➕",
      "heading": "Adding a Device",
      "steps": [
        { "text": "Click <strong>+ Add Device</strong> in the toolbar." },
        { "text": "Enter the ATM ID, Location, and Model (required)." },
        { "text": "Use <strong>Lookup Coords</strong> to geocode the address automatically." },
        { "text": "Assign to an Institution if the device belongs to a specific customer." }
      ]
    }
  ]
}$$),

('devices.detail', $${
  "title": "Device Detail",
  "subtitle": "How to view and manage an individual device",
  "sections": [
    {
      "icon": "📋",
      "heading": "Navigating Tabs",
      "steps": [
        { "text": "Use the tab bar to switch between all device views." },
        { "text": "<strong>Details</strong> — core properties and location." },
        { "text": "<strong>Software</strong> — full software inventory by category (ATM, OS, Security, Patches)." },
        { "text": "<strong>Hardware</strong> — component inventory; a badge appears when unacknowledged changes exist." },
        { "text": "<strong>Cassettes</strong> — current cassette config; apply a template from here." },
        { "text": "<strong>Activity</strong> — 24/48/72-hour timeline of power, state, and network events." }
      ]
    },
    {
      "icon": "✏️",
      "heading": "Editing Properties",
      "steps": [
        { "text": "In the <strong>Details</strong> tab, click <strong>Edit</strong>." },
        { "text": "Update location, address, coordinates, or custom fields." },
        { "text": "Changing the address triggers auto-geocoding — review coordinates before saving." },
        { "text": "Click <strong>Save</strong> to confirm, or <strong>Cancel</strong> to discard." },
        { "text": "Use <strong>Rename</strong> to change the ATM ID itself (updates the agent registration)." }
      ]
    },
    {
      "icon": "🔀",
      "heading": "Moving & Reassigning",
      "steps": [
        { "text": "Click <strong>Move Institution</strong> to reassign the device to a different customer." },
        { "text": "Select the destination institution from the dropdown and confirm." },
        { "text": "The device will immediately appear under the new institution for all users." }
      ]
    },
    {
      "icon": "⚠️",
      "heading": "Resetting Device State",
      "steps": [
        { "text": "If a device is stuck in <strong>IN SUPERVISOR</strong> or an incorrect state, click <strong>Reset to In Service</strong>." },
        { "text": "This clears the supervisor flag and returns the device to normal operation." },
        { "text": "Only use this after confirming the physical ATM is no longer in supervisor mode." }
      ]
    }
  ]
}$$),

('incidents.list', $${
  "title": "Incident Management",
  "subtitle": "How to track, assign, and resolve ATM incidents",
  "sections": [
    {
      "icon": "🔍",
      "heading": "Finding Incidents",
      "steps": [
        { "text": "Use the search bar to find by Incident #, ATM name/ID, or description text." },
        { "text": "Filter by Status, Severity, Type, Technician, or ATM Group in the left sidebar." },
        { "text": "Save a filter combination as a <strong>Preset</strong> for quick reuse." },
        { "text": "Switch between the <strong>Active</strong> and <strong>Parked</strong> tabs to see parked incidents." }
      ]
    },
    {
      "icon": "🔄",
      "heading": "Incident Lifecycle",
      "steps": [
        { "text": "New incidents start as <strong>OPEN</strong> — assign to a technician to begin." },
        { "text": "<strong>ASSIGNED</strong> → click <strong>Start</strong> when work begins → <strong>IN PROGRESS</strong>." },
        { "text": "Once resolved, click <strong>Resolve</strong> → <strong>RESOLVED</strong>." },
        { "text": "Final review, then <strong>Close</strong> → <strong>CLOSED</strong>." },
        { "text": "Park an incident at any stage to temporarily hold it without closing." }
      ]
    },
    {
      "icon": "👤",
      "heading": "Assigning & Reassigning",
      "steps": [
        { "text": "Click an incident row to open the detail sidebar." },
        { "text": "Set a <strong>Helpdesk Person</strong> (remote support) and a <strong>Field Technician</strong> (on-site)." },
        { "text": "Either assignment is optional — you can advance the workflow with just one or neither." },
        { "text": "Reassign at any stage by clicking the assignment field in the sidebar." }
      ]
    },
    {
      "icon": "⚠️",
      "heading": "Special Cases",
      "steps": [
        { "text": "<strong>Possible Fraud</strong> type — requires investigation notes before the incident can be closed." },
        { "text": "<strong>Linked incidents</strong> — group related tickets from the same ATM using the Link action." },
        { "text": "<strong>Recurring incidents</strong> — if the same issue reopens within 30 minutes, the recurrence counter increments automatically." },
        { "text": "<strong>Bulk close</strong> — select multiple resolved incidents and close them in one action." }
      ]
    }
  ]
}$$),

('incidents.create', $${
  "title": "Reporting an Incident",
  "subtitle": "How to manually log a new ATM incident",
  "sections": [
    {
      "icon": "🏧",
      "heading": "Selecting the ATM",
      "steps": [
        { "text": "Use the ATM dropdown to search by ATM ID or location name." },
        { "text": "Only ATMs your institution owns will appear." }
      ]
    },
    {
      "icon": "📋",
      "heading": "Choosing the Right Type",
      "steps": [
        { "text": "Select the incident type that best describes the fault." },
        { "text": "If unsure, use <strong>General Fault</strong> — type can be reclassified later from the Incident List." },
        { "text": "<strong>Possible Fraud</strong> triggers an investigation workflow — only select if fraud is suspected." }
      ]
    },
    {
      "icon": "🎯",
      "heading": "Setting Severity",
      "steps": [
        { "text": "<strong>Low</strong> — minor impact, ATM still functional." },
        { "text": "<strong>Medium</strong> — degraded operation (e.g. one cassette low)." },
        { "text": "<strong>High</strong> — ATM partially out of service." },
        { "text": "<strong>Critical</strong> — ATM fully down or security incident." }
      ]
    },
    {
      "icon": "📝",
      "heading": "Writing a Good Description",
      "steps": [
        { "text": "Include what the customer or technician observed." },
        { "text": "Note any error codes shown on the ATM screen." },
        { "text": "Include the time the fault was first noticed." },
        { "text": "A clear description speeds up technician dispatch and resolution." }
      ]
    }
  ]
}$$);
