identityscope 0.28.5 → 0.28.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +106 -77
  2. package/SECURITY.md +7 -7
  3. package/dist/core/audit-readiness.js +7 -7
  4. package/dist/core/audit-readiness.js.map +1 -1
  5. package/dist/core/checks.js +13 -13
  6. package/dist/core/checks.js.map +1 -1
  7. package/dist/core/datasets.js +1 -1
  8. package/dist/core/datasets.js.map +1 -1
  9. package/dist/core/governance-trail.js +3 -3
  10. package/dist/core/governance-trail.js.map +1 -1
  11. package/dist/core/http-transport.js +1 -1
  12. package/dist/core/http-transport.js.map +1 -1
  13. package/dist/core/insights.d.ts +1 -1
  14. package/dist/core/insights.js +8 -8
  15. package/dist/core/insights.js.map +1 -1
  16. package/dist/core/joiner-evidence.js +5 -5
  17. package/dist/core/joiner-evidence.js.map +1 -1
  18. package/dist/core/lab/policy-preview.js +3 -3
  19. package/dist/core/lab/policy-preview.js.map +1 -1
  20. package/dist/core/lab/transform-impact.js +1 -1
  21. package/dist/core/lab/transform-impact.js.map +1 -1
  22. package/dist/core/lab/transform-people.js +4 -4
  23. package/dist/core/lab/transform-people.js.map +1 -1
  24. package/dist/core/lab/transforms.js +1 -1
  25. package/dist/core/lab/transforms.js.map +1 -1
  26. package/dist/core/lifecycle-gaps.js +6 -6
  27. package/dist/core/lifecycle-gaps.js.map +1 -1
  28. package/dist/core/lookup.js +1 -1
  29. package/dist/core/lookup.js.map +1 -1
  30. package/dist/core/model-insights.js +10 -10
  31. package/dist/core/model-insights.js.map +1 -1
  32. package/dist/core/operations-watch.js +7 -7
  33. package/dist/core/operations-watch.js.map +1 -1
  34. package/dist/core/preview.js +3 -3
  35. package/dist/core/preview.js.map +1 -1
  36. package/dist/core/roles.js +1 -1
  37. package/dist/core/roles.js.map +1 -1
  38. package/dist/core/threat-signals.js +9 -9
  39. package/dist/core/threat-signals.js.map +1 -1
  40. package/dist/core/threat-watch.js +3 -3
  41. package/dist/core/threat-watch.js.map +1 -1
  42. package/dist/core/transport.d.ts +4 -0
  43. package/dist/core/transport.js +23 -3
  44. package/dist/core/transport.js.map +1 -1
  45. package/dist/core/warnings.js +3 -3
  46. package/dist/core/warnings.js.map +1 -1
  47. package/dist/node/attribute-history.js +2 -2
  48. package/dist/node/attribute-history.js.map +1 -1
  49. package/dist/node/cli.js +57 -5
  50. package/dist/node/cli.js.map +1 -1
  51. package/dist/node/evidence.js +7 -7
  52. package/dist/node/evidence.js.map +1 -1
  53. package/dist/node/ui-page.d.ts +1 -1
  54. package/dist/node/ui-page.js +1 -1
  55. package/dist/node/ui-page.js.map +1 -1
  56. package/dist/node/ui-server.js +64 -51
  57. package/dist/node/ui-server.js.map +1 -1
  58. package/dist/reports/builtin.generated.js +35 -35
  59. package/dist/reports/builtin.generated.js.map +1 -1
  60. package/package.json +1 -1
  61. package/reports/access-profile-members.yaml +3 -3
  62. package/reports/access-profile-membership-counts.yaml +2 -2
  63. package/reports/accounts-by-source.yaml +2 -2
  64. package/reports/active-identities-without-manager.yaml +2 -2
  65. package/reports/aggregation-failures.yaml +1 -1
  66. package/reports/aggregation-history.yaml +1 -1
  67. package/reports/all-sources.yaml +1 -1
  68. package/reports/application-accounts.yaml +3 -3
  69. package/reports/application-entitlements.yaml +3 -3
  70. package/reports/certification-decisions.yaml +1 -1
  71. package/reports/direct-reports-per-manager.yaml +3 -3
  72. package/reports/disabled-accounts-of-active-people.yaml +3 -3
  73. package/reports/duplicate-emails.yaml +1 -1
  74. package/reports/entitlement-holders.yaml +2 -2
  75. package/reports/entitlements-held-by-inactive-identities.yaml +3 -3
  76. package/reports/identities-by-lifecycle-state.yaml +3 -3
  77. package/reports/identities-missing-key-attributes.yaml +3 -3
  78. package/reports/identities-with-processing-errors.yaml +2 -2
  79. package/reports/machine-accounts.yaml +1 -1
  80. package/reports/managers-and-direct-reports.yaml +4 -4
  81. package/reports/most-access.yaml +3 -3
  82. package/reports/new-identities.yaml +3 -3
  83. package/reports/old-passwords.yaml +3 -3
  84. package/reports/pending-reviews-by-reviewer.yaml +1 -1
  85. package/reports/person-access.yaml +4 -4
  86. package/reports/privileged-access.yaml +2 -2
  87. package/reports/provisioning-error-causes.yaml +1 -1
  88. package/reports/provisioning-failures.yaml +1 -1
  89. package/reports/recent-activity.yaml +3 -3
  90. package/reports/recent-leavers.yaml +4 -4
  91. package/reports/role-members.yaml +3 -3
  92. package/reports/role-membership-counts.yaml +2 -2
  93. package/reports/team-access.yaml +4 -4
  94. package/reports/terminated-users-with-active-accounts.yaml +4 -4
  95. package/reports/uncorrelated-accounts.yaml +1 -1
  96. package/ui/js/01-small-helpers.js +2 -2
  97. package/ui/js/04-library.js +1 -1
  98. package/ui/js/07-fields.js +1 -1
  99. package/ui/js/08-designer.js +4 -4
  100. package/ui/js/11-lookup.js +4 -4
  101. package/ui/js/16-ownership.js +3 -3
  102. package/ui/js/18-audit.js +5 -5
  103. package/ui/js/19-insights.js +6 -6
  104. package/ui/js/20-role-mining.js +5 -5
  105. package/ui/js/22-partner-overview-all-customer-tenants.js +2 -2
  106. package/ui/js/23-in-app-guidance.js +42 -42
  107. package/ui/js/24-role-tools.js +4 -4
  108. package/ui/js/27-warnings.js +29 -29
  109. package/ui/js/28-audit-readiness.js +12 -12
  110. package/ui/js/29-lifecycle.js +19 -19
  111. package/ui/js/30-labs.js +8 -8
  112. package/ui/js/31-build.js +6 -6
  113. package/ui/js/32-lab-examples.js +2 -2
  114. package/ui/js/33-finder.js +2 -2
  115. package/ui/js/34-governance.js +4 -4
  116. package/ui/js/35-watch.js +13 -13
  117. package/ui/js/36-model.js +21 -21
  118. package/ui/js/37-logs-and-watch.js +11 -11
  119. package/ui/shell.html +3 -3
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/embed-reports.mjs from ui/shell.html, ui/style.css and ui/js/*.js. Do not edit.
2
- export const UI_PAGE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>IdentityScope</title>\n<style>\n:root{\n --bg:#f3f5f9;--panel:#fff;--sunken:#f7f8fb;--text:#0f172a;--text2:#334155;--muted:#5b6577;--faint:#64748b;\n --line:#e3e8ef;--line2:#cbd5e1;--accent:#2457d6;--accent2:#1d47b3;--accent-soft:#eaf0fd;--accent-ring:rgba(36,87,214,.18);\n --danger:#b42318;--danger-soft:#fdeceb;--warn:#8a5a00;--warn-soft:#fff6e0;--ok:#067647;--ok-soft:#e6f6ec;\n --nav:#0d1b33;--nav2:#16284a;--radius:10px;--shadow:0 1px 2px rgba(15,23,42,.05),0 1px 3px rgba(15,23,42,.06);--shadow2:0 10px 30px rgba(15,23,42,.14);\n}\n*{box-sizing:border-box}\nhtml,body{height:100%}\nbody{margin:0;font:14px/1.5 \"Segoe UI Variable Text\",\"Segoe UI\",-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased}\nbutton,input,select,textarea{font:inherit;color:inherit}\na{color:var(--accent)}\ncode{font:12.5px ui-monospace,\"Cascadia Mono\",Consolas,monospace;background:var(--sunken);border:1px solid var(--line);border-radius:5px;padding:1px 5px}\nsvg.i{width:16px;height:16px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:-3px}\n.hidden{display:none!important}\n.muted{color:var(--muted)}\n.small{font-size:12.5px}\n\n/* top bar */\nheader{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:14px;height:56px;padding:0 20px;background:var(--nav);color:#fff;box-shadow:0 1px 0 rgba(255,255,255,.04)}\n.brand{display:flex;align-items:center;gap:10px;font-weight:650;font-size:16px;letter-spacing:-.01em}\n.logo{width:30px;height:30px;border-radius:8px;background:linear-gradient(135deg,#3d7bff,#1d47b3);display:grid;place-items:center;font-size:12px;font-weight:800;letter-spacing:.02em}\nnav{display:flex;gap:2px;margin-left:10px}\n.navbtn{display:flex;align-items:center;gap:7px;background:transparent;border:none;color:rgba(255,255,255,.7);padding:7px 13px;border-radius:8px;cursor:pointer}\n.navbtn:hover{color:#fff;background:rgba(255,255,255,.07)}\n.navbtn.active{background:var(--nav2);color:#fff;font-weight:600}\n@media (max-width:2500px){.navbtn{padding:7px 9px}}\n@media (max-width:2280px){.navbtn{padding:7px 6px;gap:5px}.navbtn svg.i{display:none}.tenant{max-width:260px}.tagline{display:none}.hbtn{padding:6px 9px}}\n@media (max-width:1900px){.hbtn svg.i{display:none}.calls{display:none}.tenant{max-width:200px}header{gap:10px}}\n.navbtn,.hbtn,.tenant{white-space:nowrap}\n@media (max-width:1900px){.calls{display:none}.brand{font-size:0}.brand .logo{font-size:12px}nav{margin-left:2px}}\n.spacer{flex:1}\n.tenant{display:flex;align-items:center;gap:8px;font-size:12.5px;color:rgba(255,255,255,.82);background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);border-radius:999px;padding:4px 12px 4px 10px;max-width:420px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.dot{width:8px;height:8px;border-radius:50%;background:#34d399;box-shadow:0 0 0 3px rgba(52,211,153,.18);flex-shrink:0}\n.hbtn{display:flex;align-items:center;gap:7px;background:transparent;border:1px solid rgba(255,255,255,.2);color:#fff;border-radius:8px;padding:6px 12px;cursor:pointer;font-size:13px}\n.hbtn:hover{background:rgba(255,255,255,.08)}\n\n/* buttons and inputs */\n.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid var(--line2);background:#fff;border-radius:8px;padding:7px 14px;cursor:pointer;font-weight:500;white-space:nowrap;transition:background .12s,border-color .12s,box-shadow .12s}\n.btn:hover{background:var(--sunken);border-color:#b6c2d2}\n.btn:focus-visible,.input:focus,.field input:focus,.field select:focus,select.input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}\n.btn.primary:hover{background:var(--accent2);border-color:var(--accent2)}\n.btn.ghost{border-color:transparent;background:transparent;color:var(--text2)}\n.btn.ghost:hover{background:var(--sunken)}\n.btn.link{border:none;background:none;color:var(--accent);padding:6px 4px;font-weight:600}\n.btn.link:hover{text-decoration:underline;background:none}\n.btn.sm{padding:4px 10px;font-size:13px;border-radius:7px}\n.btn.icon{padding:5px 7px}\n.btn.danger{color:var(--danger)}\n.btn:disabled{opacity:.5;cursor:default}\na.btn{text-decoration:none}\na.btn:hover{text-decoration:none}\n.input,.field input,.field select,.field textarea{display:block;width:100%;padding:8px 11px;border:1px solid var(--line2);border-radius:8px;background:#fff;color:var(--text);font-size:14px;transition:border-color .12s,box-shadow .12s}\nselect.input,.field select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#64748b 50%),linear-gradient(135deg,#64748b 50%,transparent 50%);background-position:calc(100% - 15px) 52%,calc(100% - 10px) 52%;background-size:5px 5px;background-repeat:no-repeat;padding-right:30px}\n.field{display:block;margin-bottom:14px}\n.field>span.lbl{display:block;font-size:12.5px;font-weight:600;color:var(--text2);margin-bottom:5px}\n.field .hint{display:block;font-size:12px;color:var(--muted);margin-top:4px}\n.req{color:var(--danger);margin-left:2px}\n.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px 16px}\n.grid .field{margin-bottom:0}\n.bar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}\n.check{display:inline-flex;align-items:center;gap:7px;margin-right:16px;font-size:14px;cursor:pointer}\n.check input{width:16px;height:16px;accent-color:var(--accent)}\n\n/* messages */\n.error{background:var(--danger-soft);color:var(--danger);border:1px solid #f6c9c5;border-radius:8px;padding:9px 12px;margin:10px 0;white-space:pre-wrap;font-size:13px}\n.note{background:var(--warn-soft);color:var(--warn);border:1px solid #f3dd9f;border-radius:8px;padding:8px 12px;margin:8px 0;font-size:13px}\n.success{background:var(--ok-soft);color:var(--ok);border:1px solid #b9e5c8;border-radius:8px;padding:8px 12px;margin:8px 0;font-size:13px}\n.progress{display:flex;align-items:center;gap:10px;color:var(--muted);margin:14px 0}\n.spinner{width:16px;height:16px;border:2px solid #d5dde8;border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.pill{display:inline-flex;align-items:center;gap:5px;border-radius:999px;padding:2px 9px;font-size:12px;font-weight:600;white-space:nowrap}\n.pill.on{background:var(--ok-soft);color:var(--ok)}.pill.off{background:#eef1f5;color:var(--muted)}.pill.blue{background:var(--accent-soft);color:var(--accent)}\n.tag{display:inline-block;font-size:11.5px;color:var(--muted);background:var(--sunken);border:1px solid var(--line);border-radius:999px;padding:0 8px;margin:0 4px 4px 0}\n#toast{position:fixed;bottom:22px;left:50%;transform:translateX(-50%);background:#0f172a;color:#fff;border-radius:10px;padding:10px 16px;box-shadow:var(--shadow2);font-size:13.5px;z-index:30;transition:opacity .2s}\n\n/* cards */\n.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:18px 20px;margin-bottom:16px}\n.card-h{display:flex;align-items:center;gap:10px;margin:0 0 14px}\n.card-h h3{margin:0;font-size:15px;font-weight:650;flex:1;display:flex;align-items:center;gap:9px}\n.step{width:24px;height:24px;border-radius:50%;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-size:12px;font-weight:700;flex-shrink:0}\n\n/* connect */\n#connect{max-width:980px;margin:40px auto;padding:0 20px}\n.connect-hero{text-align:center;margin-bottom:26px}\n.connect-hero h2{font-size:26px;letter-spacing:-.02em;margin:10px 0 6px}\n.connect-hero p{color:var(--muted);margin:0}\n.connect-cols{display:grid;grid-template-columns:1.1fr 1fr;gap:18px;align-items:start}\n@media (max-width:860px){.connect-cols{grid-template-columns:1fr}}\n.connect-cols .card{padding:24px}\n.connect-cols h3{margin:0 0 4px;font-size:16px;display:flex;align-items:center;gap:8px}\n.connect-cols p.lead{color:var(--muted);margin:0 0 18px;font-size:13.5px}\ndetails.help{font-size:13px;color:var(--text2);background:var(--sunken);border:1px solid var(--line);border-radius:8px;padding:10px 12px;margin-top:16px}\ndetails.help summary{cursor:pointer;font-weight:600}\ndetails.help ol{margin:8px 0 0 18px;padding:0}\ndetails.help li{margin:3px 0}\n.saved{display:flex;align-items:center;gap:12px;background:var(--accent-soft);border:1px solid #cddcfb;border-radius:var(--radius);padding:12px 16px;margin-bottom:18px}\n\n/* reports layout */\n#app{display:flex;height:calc(100vh - 56px)}\naside{width:290px;flex-shrink:0;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column}\n.aside-top{padding:14px 14px 8px;display:flex;flex-direction:column;gap:10px}\n.searchbox{position:relative}\n.searchbox svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--faint)}\n.searchbox input{padding-left:33px}\n#library{overflow-y:auto;padding:4px 10px 18px;flex:1}\n.group{margin:10px 0 4px}\n.group-h{display:flex;align-items:center;gap:8px;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:700;padding:4px 6px}\n.group-h .count{margin-left:auto;font-weight:600;letter-spacing:0}\n.entry{display:block;width:100%;text-align:left;background:none;border:none;border-radius:7px;padding:6px 10px;cursor:pointer;color:var(--text2);font-size:13.5px;line-height:1.35}\n.entry:hover{background:var(--sunken);color:var(--text)}\n.entry.active{background:var(--accent-soft);color:var(--accent);font-weight:600}\n#main{flex:1;min-width:0;overflow-y:auto}\n#content{outline:none}\n.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\nbutton:focus-visible,a:focus-visible,[tabindex]:focus-visible,.navbtn:focus-visible,.hbtn:focus-visible,.tab:focus-visible,.chk:focus-visible,.pval:focus-visible{outline:2px solid #2563eb;outline-offset:2px}\n.skip{position:absolute;left:-9999px;top:8px;z-index:20;background:#fff;color:#0f172a;padding:8px 12px;border-radius:8px}\n.skip:focus{left:12px}\n.wrap{max-width:1240px;margin:0 auto;padding:22px 28px 60px}\n\n/* home */\n.hero{background:linear-gradient(135deg,#0d1b33 0%,#1b3a75 60%,#2457d6 100%);color:#fff;border-radius:14px;padding:28px 30px;margin-bottom:20px;position:relative;overflow:hidden}\n.hero h2{font-size:24px;letter-spacing:-.02em;margin:0 0 6px}\n.hero p{margin:0 0 18px;color:rgba(255,255,255,.8);max-width:640px}\n.hero .searchbox{max-width:560px}\n.hero .searchbox input{border:none;padding-top:11px;padding-bottom:11px;font-size:15px;box-shadow:0 6px 20px rgba(0,0,0,.18)}\n.hero-stats{display:flex;gap:22px;margin-top:18px;font-size:13px;color:rgba(255,255,255,.8)}\n.hero-stats b{color:#fff;font-size:18px;display:block}\n.hero .btn{background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.35);color:#fff}\n.hero .btn:hover{background:rgba(255,255,255,.2)}\n.chips{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 16px}\n.chip{border:1px solid var(--line2);background:#fff;border-radius:999px;padding:5px 12px;cursor:pointer;font-size:13px;color:var(--text2);display:inline-flex;align-items:center;gap:6px}\n.chip:hover{border-color:#9fb0c6}\n.chip.active{background:var(--text);border-color:var(--text);color:#fff}\n.sec-h{display:flex;align-items:baseline;gap:10px;margin:22px 0 10px}\n.sec-h h3{margin:0;font-size:15px}\n.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:14px}\n.rcard{display:flex;flex-direction:column;gap:8px;text-align:left;background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px;cursor:pointer;box-shadow:var(--shadow);transition:transform .12s,box-shadow .12s,border-color .12s;min-height:142px}\n.rcard:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(15,23,42,.1);border-color:#c9d5e6}\n.rcard .top{display:flex;align-items:center;gap:10px}\n.rcard h3{margin:0;font-size:14.5px;line-height:1.3}\n.rcard p{margin:0;color:var(--muted);font-size:13px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}\n.rcard .foot{margin-top:auto;display:flex;gap:6px;align-items:center;font-size:12px;color:var(--faint)}\n.cat-ico{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;flex-shrink:0}\n.cat-ico svg.i{width:18px;height:18px}\n\n/* report view */\n.crumbs{font-size:12.5px;color:var(--muted);display:flex;align-items:center;gap:6px;margin-bottom:8px}\n.crumbs button{background:none;border:none;color:var(--accent);cursor:pointer;padding:0}\n.rhead{display:flex;align-items:flex-start;gap:14px;margin-bottom:4px}\n.rhead h2{margin:0;font-size:22px;letter-spacing:-.015em;line-height:1.25}\n.rhead .desc{color:var(--muted);margin:6px 0 0;max-width:860px}\n.tabs{display:flex;flex-wrap:wrap;gap:2px;border-bottom:1px solid var(--line);margin:18px 0 18px}\n.tab{display:flex;align-items:center;gap:6px;background:none;border:none;border-bottom:2px solid transparent;padding:8px 12px;font-size:13.5px;white-space:nowrap;cursor:pointer;color:var(--muted);font-weight:500;margin-bottom:-1px}\n.tab:hover{color:var(--text)}\n.tab.active{color:var(--accent);border-bottom-color:var(--accent);font-weight:650}\n.runbar{display:flex;gap:10px;align-items:flex-end;flex-wrap:wrap;margin-top:16px;padding-top:16px;border-top:1px solid var(--line)}\n.runbar .field{margin:0;min-width:260px}\n\n/* results */\n.stats{display:flex;align-items:center;gap:16px;flex-wrap:wrap;margin-bottom:12px}\n.stat b{font-size:22px;letter-spacing:-.02em;display:block;line-height:1.1}\n.stat span{font-size:12px;color:var(--muted)}\n.table-wrap{overflow:auto;max-height:64vh;border:1px solid var(--line);border-radius:10px;background:#fff}\ntable{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}\nth,td{padding:8px 12px;border-bottom:1px solid #eef1f5;text-align:left;vertical-align:top}\nth{position:sticky;top:0;background:#f6f8fb;white-space:nowrap;font-weight:650;font-size:12.5px;color:var(--text2);cursor:pointer;user-select:none;z-index:1;border-bottom:1px solid var(--line)}\nth:hover{color:var(--text)}\nth .arrow{color:var(--accent);margin-left:4px}\ntbody tr:nth-child(even) td{background:#fbfcfe}\ntbody tr:hover td{background:#f1f5fd}\ntd.num{text-align:right;font-variant-numeric:tabular-nums}\ntd.empty-cell{color:var(--faint)}\n.yes{color:var(--ok);font-weight:600}.no{color:var(--muted)}\n.empty{padding:44px 20px;text-align:center;color:var(--muted)}\n.empty b{display:block;color:var(--text);font-size:15px;margin-bottom:4px}\n\n/* pickers */\n.picker{position:relative}\n.picker-btn{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-height:38px;width:100%;padding:5px 30px 5px 8px;border:1px solid var(--line2);border-radius:8px;background:#fff;cursor:pointer;text-align:left;position:relative}\n.picker-btn:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.picker-btn .ph{color:var(--faint);padding:2px 4px}\n.picker-btn .chev{position:absolute;right:9px;top:50%;transform:translateY(-50%);color:var(--muted)}\n.tok{display:inline-flex;align-items:center;gap:4px;background:var(--accent-soft);color:var(--accent);border-radius:6px;padding:1px 4px 1px 8px;font-size:12.5px;font-weight:600;max-width:100%}\n.tok span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.tok button{border:none;background:none;color:inherit;cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:.7}\n.tok button:hover{opacity:1}\n.pop{position:absolute;z-index:20;top:calc(100% + 4px);left:0;right:0;min-width:300px;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow2);padding:8px}\n.pop input.input{margin-bottom:6px}\n.pop-list{max-height:280px;overflow-y:auto}\n.opt{display:flex;align-items:center;gap:9px;padding:6px 8px;border-radius:6px;cursor:pointer;font-size:13.5px}\n.opt:hover,.opt.kb{background:var(--sunken)}\n.opt input{accent-color:var(--accent);width:15px;height:15px}\n.opt .hint{margin-left:auto;font-size:11.5px;color:var(--faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:45%}\n.pop-foot{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--line);margin-top:6px;padding-top:6px;font-size:12.5px;color:var(--muted)}\n.tokinput{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:38px;padding:5px 8px;border:1px solid var(--line2);border-radius:8px;background:#fff}\n.tokinput:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.tokinput input{border:none;outline:none;flex:1;min-width:120px;padding:3px 2px}\n\n/* designer */\n.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:10px}\n.tile{display:flex;gap:10px;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:10px;padding:11px 12px;cursor:pointer;transition:border-color .12s,background .12s}\n.tile:hover{border-color:#a9bbd6}\n.tile.active{border-color:var(--accent);background:var(--accent-soft);box-shadow:0 0 0 1px var(--accent)}\n.tile b{display:block;font-size:13.5px;margin-bottom:2px}\n.tile span{font-size:12px;color:var(--muted);line-height:1.35;display:block}\n.cond{display:grid;grid-template-columns:minmax(200px,1.3fr) minmax(150px,.8fr) minmax(220px,1.4fr) auto;gap:8px;align-items:start;padding:10px;border:1px solid var(--line);border-radius:10px;background:var(--sunken);margin-bottom:8px}\n@media (max-width:1000px){.cond{grid-template-columns:1fr 1fr}}\n.cond .ask{grid-column:1/-1;display:flex;align-items:center;gap:10px;font-size:12.5px;color:var(--muted)}\n.cond .ask .input{max-width:360px;padding:5px 9px;font-size:13px}\n.joiner{display:flex;align-items:center;gap:8px;margin:0 0 10px;font-size:13.5px}\n.joiner select{width:auto}\n.colrow{display:grid;grid-template-columns:28px minmax(220px,1.3fr) minmax(160px,1fr) 150px auto;gap:8px;align-items:center;padding:6px 8px;border:1px solid var(--line);border-radius:9px;background:#fff;margin-bottom:6px}\n.colrow .n{color:var(--faint);font-size:12px;text-align:center;font-weight:600}\n.actionbar{position:sticky;bottom:0;background:rgba(243,245,249,.92);backdrop-filter:blur(6px);border-top:1px solid var(--line);padding:12px 0;margin-top:6px;display:flex;gap:10px;align-items:center;z-index:4}\ndetails.adv summary{cursor:pointer;color:var(--text2);font-weight:600;font-size:13.5px}\ntextarea.yaml{width:100%;min-height:480px;font:13px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;padding:14px;border:1px solid var(--line2);border-radius:10px;background:#0f172a;color:#e2e8f0}\ntextarea.yaml:focus{outline:none;box-shadow:0 0 0 3px var(--accent-ring)}\n\n/* modal */\n.modal{position:fixed;inset:0;background:rgba(15,23,42,.5);display:flex;align-items:center;justify-content:center;z-index:25;backdrop-filter:blur(2px)}\n.modal .box{background:#fff;border-radius:14px;width:min(880px,92vw);max-height:86vh;display:flex;flex-direction:column;box-shadow:var(--shadow2)}\n.modal .head{display:flex;align-items:center;gap:8px;padding:14px 18px;border-bottom:1px solid var(--line)}\n.modal .head h3{margin:0;font-size:16px;flex:1}\n.modal pre{margin:0;padding:16px 18px;overflow:auto;font:12.5px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;white-space:pre-wrap}\n\n/* schedules */\n.drawer-back{position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:40;display:flex;justify-content:flex-end}\n.drawer{width:min(460px,94vw);height:100%;overflow-y:auto;background:#fff;box-shadow:var(--shadow2);padding:20px 22px;font-size:14px}\n.drawer h4{margin:18px 0 6px;font-size:13px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}\n.drawer ul{margin:0;padding-left:18px}.drawer li{margin:5px 0}\n.checklist{display:flex;flex-direction:column;gap:6px}\n.cl-item{display:flex;gap:10px;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 10px;cursor:pointer;font-size:13.5px}\n.cl-item:hover{border-color:var(--accent)}\n.cl-box{width:18px;height:18px;border:1.5px solid var(--line2);border-radius:5px;display:grid;place-items:center;font-size:12px;flex-shrink:0;color:var(--muted)}\n.cl-item.done{color:var(--muted)}.cl-item.done .cl-box{background:var(--ok);border-color:var(--ok);color:#fff}\n.fix{background:#f6f9ff;border:1px solid #d9e4fb;border-radius:10px;padding:10px 14px;margin:0 0 14px;font-size:13.5px}\n.fix ol{margin:6px 0 0;padding-left:20px}.fix li{margin:3px 0}\n#schedules,#roles,#checks,#lookup,#tenant-page,#certs,#monthly,#warnings,#nerm,#logs{height:calc(100vh - 56px);overflow-y:auto}\n.tagline{font-size:10.5px;font-weight:500;color:rgba(255,255,255,.55);letter-spacing:.01em}\n.calls{font-size:12px;color:rgba(255,255,255,.65);white-space:nowrap}\npre.json{margin:0;max-height:60vh;overflow:auto;background:#0f172a;color:#e2e8f0;border-radius:10px;padding:14px;font:12.5px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;white-space:pre-wrap;word-break:break-word}\n.banner{display:flex;align-items:center;gap:14px;border-radius:12px;padding:14px 18px;margin-bottom:16px;border:1px solid var(--line);background:#fff}\n.banner b{font-size:17px}\n.banner.ok{background:var(--ok-soft);border-color:#b9e5c8;color:var(--ok)}\n.banner.warn{background:var(--warn-soft);border-color:#f3dd9f;color:var(--warn)}\n.banner.bad{background:var(--danger-soft);border-color:#f6c9c5;color:var(--danger)}\n.banner.idle,.banner.run{color:var(--text2)}\n.banner span{font-size:13px}\n.tiles-chk{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:12px}\n.chk{--c:#94a3b8;position:relative;display:flex;flex-direction:column;gap:6px;text-align:left;background:#fff;border:1px solid var(--line);border-left:4px solid var(--c);border-radius:12px;padding:12px 14px;cursor:pointer;box-shadow:var(--shadow);transition:box-shadow .12s,transform .12s}\n.chk:hover{box-shadow:0 8px 22px rgba(15,23,42,.1);transform:translateY(-1px)}\n.chk.sel{outline:2px solid var(--accent);outline-offset:1px}\n.chk.ok{--c:#15803d}.chk.warn{--c:#b45309}.chk.bad{--c:#dc2626}.chk.err{--c:#5b6577}.chk.off{--c:#64748b;background:#f8fafc;border-left-color:#cbd5e1}\n.chk.stale{background:#fbfcfe}\n.chk-top{display:flex;align-items:center;gap:8px}\n.chk-dot{width:9px;height:9px;border-radius:50%;background:var(--c);flex-shrink:0}\n.chk-label{font-weight:650;font-size:13.5px;flex:1}\n.chk-st{font-size:11.5px;font-weight:650;color:var(--c)}\n.chk-mid{display:flex;align-items:baseline;gap:6px}\n.chk-mid b{font-size:28px;letter-spacing:-.02em;line-height:1}\n.chk-mid svg.spark{color:var(--c);align-self:center}\n.chk-sum{font-size:12.5px;color:var(--muted);line-height:1.4}\n.chk .pill{align-self:flex-start}\n.chk-top3{border-top:1px solid #eef1f5;padding-top:6px;font-size:12px;display:flex;flex-direction:column;gap:2px}\n.chk-top3 div{display:flex;gap:8px;justify-content:space-between}\n.chk-top3 span{color:var(--text2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.trend{color:var(--accent);margin:4px 0 14px}\n.trend svg{width:100%;max-width:640px;height:90px}\n.matches{display:flex;flex-direction:column;gap:4px;margin-top:10px}\n.match{display:flex;flex-direction:column;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 12px;cursor:pointer}\n.match:hover,.match.sel{border-color:var(--accent);background:var(--accent-soft)}\n.match span{font-size:12.5px}\n.avatar{width:44px;height:44px;border-radius:50%;background:linear-gradient(135deg,#3d7bff,#1d47b3);color:#fff;display:grid;place-items:center;font-weight:700;flex-shrink:0}\n.flags{display:flex;flex-direction:column;gap:6px;margin-top:14px}\n.flag{border-radius:8px;padding:8px 12px;font-size:13.5px;border-left:4px solid}\n.flag.bad{background:var(--danger-soft);border-color:#dc2626;color:#7a1a12}\n.flag.warn{background:var(--warn-soft);border-color:#d97706;color:#6b4500}\n.flag.info{background:var(--sunken);border-color:#94a3b8;color:var(--text2)}\n.rolecards{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin-bottom:14px}\n.rolecard{border:1px solid var(--line);border-radius:10px;padding:14px;background:#fff}\n.rolecard h4{margin:0 0 6px;font-size:15px}\n.rolecard .crit{font:12.5px/1.5 ui-monospace,\"Cascadia Mono\",Consolas,monospace;background:var(--sunken);border-radius:7px;padding:7px 9px;margin-top:8px;color:var(--text2);word-break:break-word}\n.kv{display:flex;gap:14px;flex-wrap:wrap;font-size:12.5px;color:var(--muted)}\n.kv b{color:var(--text);font-size:14px}\n.meter{height:8px;border-radius:99px;background:#e9edf3;overflow:hidden;margin:6px 0}\n.meter span{display:block;height:100%;background:linear-gradient(90deg,#3d7bff,#2457d6)}\n.tick{color:var(--ok);font-weight:700}.dash{color:var(--faint)}\n.chg{display:inline-block;border-radius:6px;padding:1px 8px;font-size:12px;font-weight:650}\n.chg.gain{background:var(--ok-soft);color:var(--ok)}.chg.lose{background:var(--danger-soft);color:var(--danger)}.chg.keep-other,.chg.off{background:#eef1f5;color:var(--muted)}\n.bigstats{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:14px}\n.bigstat{border:1px solid var(--line);border-radius:10px;padding:12px 14px;background:#fff}\n.bigstat b{display:block;font-size:24px;letter-spacing:-.02em}\n.bigstat span{font-size:12.5px;color:var(--muted)}\n.bigstat.gain b{color:var(--ok)}.bigstat.lose b{color:var(--danger)}\n.crit-group{border:1px dashed var(--line2);border-radius:10px;padding:10px;margin:8px 0;background:#fcfdff}\n.crit-row{display:grid;grid-template-columns:170px minmax(160px,1fr) minmax(150px,1fr) 150px minmax(160px,1fr) auto;gap:8px;align-items:start;margin-bottom:8px}\n@media (max-width:1100px){.crit-row{grid-template-columns:1fr 1fr 1fr}}\n.jobs td,.jobs th{vertical-align:middle}\n.jobs th{cursor:default}\n.actions{display:flex;gap:6px;flex-wrap:wrap}\n.log{background:#0f172a;color:#e2e8f0;border-radius:8px;padding:8px 10px;font:12px/1.45 ui-monospace,Consolas,monospace;white-space:pre-wrap;max-height:180px;overflow:auto;margin-top:6px}\n.inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}\n.inline .input{width:auto}\n.inline .field .input{width:100%}\n#schedules .grid{margin-bottom:14px}\n.partner-strip{margin:0 auto 18px;max-width:980px}\n.ptable{width:100%;border-collapse:collapse;font-size:13px}\n.ptable th,.ptable td{padding:8px 10px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle}\n.ptable th{background:#f6f8fb;font-weight:600;font-size:12px;color:var(--text2)}\n.ptable th.pcol{max-width:92px;white-space:normal;line-height:1.2;text-align:center}\n.ptable td.pcell{text-align:center}\n.ptable tr.sel td{background:#f4f8ff}\n.pval{border:0;border-radius:7px;min-width:44px;padding:5px 8px;font:600 13px inherit;cursor:pointer;position:relative}\n.pval.ok{background:var(--ok-soft);color:var(--ok)}.pval.warn{background:var(--warn-soft);color:var(--warn)}.pval.bad{background:var(--danger-soft);color:var(--danger)}.pval.err{background:#eef1f5;color:var(--muted)}\n.pnew{position:absolute;top:-7px;right:-8px;background:var(--danger);color:#fff;font-size:9px;border-radius:6px;padding:1px 4px;font-weight:700}\n.pstat{display:inline-block;border-radius:999px;padding:3px 10px;font-weight:600;font-size:12px}\n.pstat.ok{background:var(--ok-soft);color:var(--ok)}.pstat.warn{background:var(--warn-soft);color:var(--warn)}.pstat.bad{background:var(--danger-soft);color:var(--danger)}.pstat.err{background:#eef1f5;color:var(--muted)}\n.pdetail{background:#fbfcfe;border:1px solid var(--line);border-radius:10px;padding:12px 14px}\n#schedules .card .bar{margin-top:6px}\n.tokchip{border:0;cursor:pointer;background:#fef3c7;color:#92400e;border-radius:999px;padding:4px 12px;font-size:12.5px;font-weight:600;white-space:nowrap}\n.tokchip{flex-shrink:0}.tokchip .tk-short{display:none}\n@media (max-width:1440px){.navbtn{padding:6px 4px;font-size:13px}header{gap:7px}.hbtn{padding:6px 8px}}\n@media (max-width:1300px){.navbtn{padding:5px 3px;font-size:12.5px}header{gap:5px}.hbtn{padding:5px 7px;font-size:12.5px}}\n@media (max-width:1900px){.tokchip .tk-long{display:none}.tokchip .tk-short{display:inline}.tokchip{padding:4px 9px}}\n.wkbars{display:inline-flex;align-items:flex-end;gap:2px;height:24px;vertical-align:middle}\n.wkbar{width:9px;background:#cbd5e1;border-radius:2px 2px 0 0;display:flex;align-items:flex-end;overflow:hidden}\n.wkfail{width:100%;background:#dc2626}\n.linkbtn{background:none;border:0;padding:0;color:var(--accent,#2563eb);cursor:pointer;font:inherit;text-align:left;text-decoration:underline;text-underline-offset:2px}\n.linkbtn:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n.evlist{margin:6px 0 0;padding-left:16px;font-size:13px}\n.evlist li{margin-bottom:4px}\ndetails > summary{cursor:pointer;color:var(--accent,#2563eb)}\n.finder-back{position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:60;display:flex;justify-content:center;align-items:flex-start;padding-top:12vh}\n.finder{background:var(--card,#fff);border-radius:12px;box-shadow:0 20px 50px rgba(0,0,0,.25);width:min(640px,92vw);overflow:hidden}\n.finder > .input{border:0;border-bottom:1px solid var(--line,#e5e7eb);border-radius:0;font-size:16px;padding:14px 16px;width:100%;max-width:none}\n.finder-list{list-style:none;margin:0;padding:6px 0;max-height:52vh;overflow:auto}\n.finder-opt{display:flex;flex-direction:column;gap:2px;padding:8px 14px;cursor:pointer}\n.finder-opt.active,.finder-opt:hover{background:var(--accent-soft,#eef2ff)}\n\n/* two-level tabs: sections, then the tabs of the open section */\n.seg{display:inline-flex;flex-wrap:wrap;gap:3px;background:#e6ebf2;border-radius:10px;padding:3px;margin:16px 0 0;max-width:100%}\n.segbtn{display:inline-flex;align-items:center;gap:7px;border:0;background:transparent;border-radius:8px;padding:6px 13px;font-weight:600;font-size:13px;color:var(--text2);cursor:pointer;white-space:nowrap}\n.segbtn:hover{color:var(--text);background:rgba(255,255,255,.55)}\n.segbtn.active{background:#fff;color:var(--accent2);box-shadow:var(--shadow)}\n.segn{font-size:11px;font-weight:650;color:var(--text2);background:rgba(15,23,42,.08);border-radius:999px;padding:0 6px;line-height:17px}\n.segbtn.active .segn{background:var(--accent-soft);color:var(--accent2)}\n.tabs.sub{margin:8px 0 18px}\n.tab svg.i{width:15px;height:15px}\n</style>\n</head>\n<body>\n<a class=\"skip\" href=\"#content\">Skip to content</a>\n<header>\n <h1 class=\"sr-only\">IdentityScope</h1>\n <div class=\"brand\"><div class=\"logo\">IS</div><div style=\"display:flex;flex-direction:column;line-height:1.1\">IdentityScope<span class=\"tagline\">for SailPoint Identity Security Cloud</span></div></div>\n <nav id=\"nav\" class=\"hidden\"><button id=\"nav-reports\" class=\"navbtn active\"></button><button id=\"nav-checks\" class=\"navbtn\"></button><button id=\"nav-warnings\" class=\"navbtn\"></button><button id=\"nav-nerm\" class=\"navbtn\"></button><button id=\"nav-logs\" class=\"navbtn\"></button><button id=\"nav-lookup\" class=\"navbtn\"></button><button id=\"nav-tenant\" class=\"navbtn\"></button><button id=\"nav-build\" class=\"navbtn\"></button><button id=\"nav-certs\" class=\"navbtn\"></button><button id=\"nav-roles\" class=\"navbtn\"></button><button id=\"nav-monthly\" class=\"navbtn\"></button><button id=\"nav-schedules\" class=\"navbtn\"></button></nav>\n <span class=\"spacer\"></span>\n <span class=\"tenant hidden\" id=\"tenant-chip\"><span class=\"dot\"></span><span id=\"tenant\"></span></span>\n <button type=\"button\" class=\"tokchip hidden\" id=\"token-chip\"></button>\n <span class=\"calls hidden\" id=\"calls-chip\" title=\"Calls this screen made to ISC since it started\"><span id=\"calls\">0</span> API calls</span>\n <button id=\"btn-partner-nav\" class=\"hbtn hidden\" title=\"The instant check of every customer tenant\"></button>\n <button id=\"btn-help\" class=\"hbtn hidden\" title=\"What this page shows and how to use it\"></button>\n <button id=\"btn-doctor\" class=\"hbtn hidden\" title=\"Check permissions and data\"></button>\n <button id=\"btn-disconnect\" class=\"hbtn hidden\" title=\"Disconnect\"></button>\n</header>\n\n<main id=\"content\" tabindex=\"-1\">\n<div id=\"connect\" class=\"hidden\">\n <div class=\"connect-hero\">\n <div class=\"logo\" style=\"width:46px;height:46px;border-radius:12px;font-size:16px;margin:0 auto;color:#fff\">IS</div>\n <h2>Connect to your tenant</h2>\n <p>Reports only read data. Nothing you enter leaves this computer except to sign in to your tenant.</p>\n </div>\n <div class=\"saved partner-strip\" style=\"background:#f0fdf4;border-color:#bbf7d0\"><span style=\"flex:1\"><b>Just looking?</b> Try every screen on a made-up tenant. No sign-in, nothing leaves this computer.</span><button class=\"btn\" id=\"btn-demo\">Try the demo tenant</button></div>\n <div class=\"saved partner-strip\"><span style=\"flex:1\"><b>More than one tenant?</b> Sandbox, QA and production, or several customers: check them all in one place.</span><button class=\"btn\" id=\"btn-partner\">Open All tenants</button></div>\n <div id=\"saved-box\" class=\"saved hidden\">\n <span class=\"dot\" style=\"background:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)\"></span>\n <span style=\"flex:1\">Saved tenant <b id=\"saved-url\"></b></span>\n <button class=\"btn primary\" id=\"btn-use-saved\">Use saved tenant</button>\n </div>\n <div class=\"connect-cols\">\n <section class=\"card\">\n <h3>Sign in with SailPoint <span class=\"pill on\">recommended</span></h3>\n <p class=\"lead\">Uses your normal ISC sign-in (SSO, MFA). You see only what your own ISC access allows.</p>\n <label class=\"field\"><span class=\"lbl\">Tenant</span><input id=\"si-base\" placeholder=\"yourtenant, or paste the ISC address from your browser\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">OAuth client ID</span><input id=\"si-client\" autocomplete=\"off\"><span class=\"hint\">Your ISC admin creates it once for everyone (see below).</span></label>\n <details class=\"adv\" style=\"margin:-4px 0 16px\"><summary>Client secret (only if your admin says so)</summary>\n <input id=\"si-secret\" class=\"input\" type=\"password\" autocomplete=\"off\" style=\"margin-top:8px\">\n </details>\n <button class=\"btn primary\" id=\"btn-signin\" style=\"width:100%;padding:10px\">Sign in with SailPoint</button>\n <div id=\"signin-wait\" class=\"hidden progress\"><span class=\"spinner\"></span><span>Finish signing in on the SailPoint tab that opened. This page continues by itself. <a id=\"signin-link\" target=\"_blank\" rel=\"noopener\">Open sign-in page</a></span></div>\n <div id=\"signin-error\" class=\"error hidden\"></div>\n <details class=\"help\"><summary>Set up once (ISC admin)</summary>\n <ol>\n <li>In ISC: <b>Admin</b> &rarr; <b>Global</b> &rarr; <b>Security Settings</b> &rarr; <b>API Management</b> &rarr; <b>New</b>.</li>\n <li>Description: <i>identityscope</i>. Grant types: <b>Authorization Code</b> and <b>Refresh Token</b>.</li>\n <li>Redirect URL: <code id=\"redirect-uri\">http://localhost:4317/callback</code></li>\n <li>Scopes: the read scopes below. Each user still only gets what their own ISC access allows.<details style=\"margin-top:6px\"><summary>The 26 read scopes</summary><code style=\"display:block;white-space:pre-wrap;word-break:break-word;margin-top:6px;font-size:12px;line-height:1.6\">sp:search:read idn:sources:read idn:accounts:read idn:entitlement:read idn:campaign:read idn:access-request-status:read idn:identity-profile:read idn:identity-profile-lifecycle-state:read idn:role-unchecked:read idn:access-profile:read idn:remote-client:read sp:workflow:read sp:workflow-execution:read idn:transform:read idn:provisioning-policy:read idn:workgroup:read idn:attr-sync-source-config:read idn:mis-account:read idn:rule-management-connector:read idn:identity-profile-attribute:read idn:sod-policy:read idn:password-policy:read sp:trigger-service-subscriptions:read sp:forms:read idn:notification-templates:read idn:segment:read</code><div class=\"muted small\" style=\"margin-top:6px\">To sign in at all: the first two. A missing scope only switches off the screen that needs it, and that screen says which. Optional extras (API credentials, Non-employees) are in the README under Permissions.</div></details></li>\n <li>Share the <b>client ID</b> with report users. Everyone uses the same client ID.</li>\n </ol>\n </details>\n </section>\n <section class=\"card\">\n <h3>Personal access token</h3>\n <p class=\"lead\">Needed for automatic (scheduled) runs. Best with a dedicated read-only reporting identity.</p>\n <label class=\"field\"><span class=\"lbl\">Tenant</span><input id=\"in-base\" placeholder=\"yourtenant, or paste the ISC address from your browser\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">Client ID</span><input id=\"in-id\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">Client secret</span><input id=\"in-secret\" type=\"password\" autocomplete=\"off\"></label>\n <button class=\"btn\" id=\"btn-connect\" style=\"width:100%;padding:10px\">Connect with token</button>\n <div id=\"connect-error\" class=\"error hidden\"></div>\n <details class=\"help\"><summary>Where do I get one, and which scopes?</summary>In ISC: your name (top right) &rarr; <b>Preferences</b> &rarr; <b>Personal Access Tokens</b> &rarr; <b>New Token</b>. The identity should have the <b>Org admin</b> user level; only read scopes are needed.<details style=\"margin-top:6px\"><summary>The 26 read scopes</summary><code style=\"display:block;white-space:pre-wrap;word-break:break-word;margin-top:6px;font-size:12px;line-height:1.6\">sp:search:read idn:sources:read idn:accounts:read idn:entitlement:read idn:campaign:read idn:access-request-status:read idn:identity-profile:read idn:identity-profile-lifecycle-state:read idn:role-unchecked:read idn:access-profile:read idn:remote-client:read sp:workflow:read sp:workflow-execution:read idn:transform:read idn:provisioning-policy:read idn:workgroup:read idn:attr-sync-source-config:read idn:mis-account:read idn:rule-management-connector:read idn:identity-profile-attribute:read idn:sod-policy:read idn:password-policy:read sp:trigger-service-subscriptions:read sp:forms:read idn:notification-templates:read idn:segment:read</code><div class=\"muted small\" style=\"margin-top:6px\">To sign in at all: the first two. A missing scope only switches off the screen that needs it, and that screen says which. Optional extras (API credentials, Non-employees) are in the README under Permissions.</div></details></details>\n </section>\n </div>\n</div>\n\n<div id=\"demo-bar\" class=\"hidden\" role=\"status\" style=\"background:#fef3c7;border-bottom:1px solid #fcd34d;color:#78350f;padding:7px 18px;font-size:13px;text-align:center\"><b>Demo tenant.</b> Every person, account and number here is made up. To use your own tenant, click Disconnect and connect to it.</div>\n<div id=\"app\" class=\"hidden\">\n <aside>\n <div class=\"aside-top\">\n <button class=\"btn primary\" id=\"btn-new\"></button>\n <div class=\"searchbox\"><span id=\"search-ico\"></span><input id=\"search\" class=\"input\" placeholder=\"Find a report\"></div>\n </div>\n <div id=\"library\"></div>\n </aside>\n <div id=\"main\"></div>\n</div>\n<div id=\"schedules\" class=\"hidden\"></div>\n<div id=\"roles\" class=\"hidden\"></div>\n<div id=\"checks\" class=\"hidden\"></div>\n<div id=\"lookup\" class=\"hidden\"></div>\n<div id=\"tenant-page\" class=\"hidden\"></div>\n<div id=\"build\" class=\"hidden\"></div>\n<div id=\"certs\" class=\"hidden\"></div>\n<div id=\"monthly\" class=\"hidden\"></div>\n<div id=\"warnings\" class=\"hidden\"></div>\n<div id=\"nerm\" class=\"hidden\"></div>\n<div id=\"logs\" class=\"hidden\"></div>\n<div id=\"partner\" class=\"hidden\"></div>\n</main>\n\n<div id=\"modal\" class=\"modal hidden\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"modal-title\">\n <div class=\"box\">\n <div class=\"head\"><h3 id=\"modal-title\"></h3><button class=\"btn sm\" id=\"modal-copy\">Copy</button><button class=\"btn sm\" id=\"modal-close\">Close</button></div>\n <pre id=\"modal-text\"></pre>\n </div>\n</div>\n<div id=\"toast\" class=\"hidden\" role=\"status\" aria-live=\"polite\"></div>\n<script>\n(function () {\n 'use strict';\n var hash = new URLSearchParams(location.hash.slice(1));\n var KEY = hash.get('k') || sessionStorage.getItem('isc-reports-key') || '';\n if (hash.get('k')) { sessionStorage.setItem('isc-reports-key', KEY); history.replaceState(null, '', location.pathname); }\n\n var state = { reports: [], catalog: null, current: null, tab: 'run', job: null, result: null, dirty: false, picks: {}, disc: {}, homeCat: '' };\n\n // ---------- small helpers ----------\n function $(id) { return document.getElementById(id); }\n function el(tag, attrs) {\n var e = document.createElement(tag);\n if (attrs) for (var k in attrs) {\n var v = attrs[k];\n if (v === undefined || v === null || v === false) continue;\n if (k === 'text') e.textContent = v;\n else if (k === 'className') e.className = v;\n else if (k.slice(0, 2) === 'on') e.addEventListener(k.slice(2), v);\n else if (k === 'value') e.value = v;\n else if (k === 'checked') e.checked = !!v;\n else e.setAttribute(k, v === true ? '' : v);\n }\n for (var i = 2; i < arguments.length; i++) add(e, arguments[i]);\n return e;\n }\n function add(e, c) {\n if (c === null || c === undefined || c === false) return;\n if (Array.isArray(c)) c.forEach(function (x) { add(e, x); });\n else e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c);\n }\n function clone(x) { return JSON.parse(JSON.stringify(x)); }\n var ICONS = {\n people: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 20c0-3.5 3.6-6 8-6s8 2.5 8 6',\n lifecycle: 'M4 12a8 8 0 0 1 14-5.3L20 9M20 4v5h-5M20 12a8 8 0 0 1-14 5.3L4 15M4 20v-5h5',\n shield: 'M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6zM8.5 12l2.5 2.5 4.5-5',\n layers: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5',\n apps: 'M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z',\n cert: 'M9 3h6v3H9zM7 4.5H5V21h14V4.5h-2M9 13.5l2 2 4-4',\n inbox: 'M4 13h4l2 3h4l2-3h4M4 13l3-8h10l3 8v6H4z',\n pulse: 'M3 12h4l3-7 4 14 3-7h4',\n file: 'M6 3h9l4 4v14H6zM14 3v5h5M9 13h7M9 17h5',\n search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM21 21l-5-5',\n download: 'M12 4v11M7 10l5 5 5-5M5 20h14',\n play: 'M7 5l12 7-12 7z',\n plus: 'M12 5v14M5 12h14',\n x: 'M6 6l12 12M18 6L6 18',\n chev: 'M6 9l6 6 6-6',\n clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2',\n up: 'M12 19V5M6 11l6-6 6 6',\n down: 'M12 5v14M6 13l6 6 6-6',\n trash: 'M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13',\n logout: 'M15 4h4v16h-4M10 8l-4 4 4 4M6 12h10',\n eye: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',\n save: 'M5 3h11l3 3v15H5zM8 3v5h7M8 14h8v7H8z',\n filter: 'M4 5h16l-6 7v6l-4 2v-8z',\n cols: 'M4 4h16v16H4zM10 4v16M16 4v16',\n sigma: 'M18 5H6l6 7-6 7h12',\n sort: 'M7 4v16M3 16l4 4 4-4M17 20V4M13 8l4-4 4 4',\n db: 'M12 8c4.4 0 8-1.3 8-3s-3.6-3-8-3-8 1.3-8 3 3.6 3 8 3zM4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3',\n grid: 'M4 4h16v16H4zM4 10h16M4 16h16M10 4v16',\n code: 'M8 8l-4 4 4 4M16 8l4 4-4 4M14 5l-4 14',\n sliders: 'M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4',\n copy: 'M8 8h12v12H8zM4 16V4h12',\n heart: 'M3 12h4l2-4 3 8 2-4h7'\n };\n function icon(name, cls) {\n var NS = 'http://www.w3.org/2000/svg';\n var s = document.createElementNS(NS, 'svg');\n s.setAttribute('viewBox', '0 0 24 24');\n s.setAttribute('class', 'i' + (cls ? ' ' + cls : ''));\n s.setAttribute('aria-hidden', 'true');\n var p = document.createElementNS(NS, 'path');\n p.setAttribute('d', ICONS[name] || ICONS.file);\n if (name === 'play') { p.setAttribute('fill', 'currentColor'); }\n s.appendChild(p);\n return s;\n }\n var CATS = {\n 'People': ['people', '#2457d6', '#eaf0fd'],\n 'Lifecycle': ['lifecycle', '#7c3aed', '#f1ebfe'],\n 'Hygiene': ['shield', '#0e7c66', '#e3f5f0'],\n 'Access model': ['layers', '#b45309', '#fdf1e2'],\n 'Application owners': ['apps', '#0369a1', '#e2f1fa'],\n 'Certifications': ['cert', '#be185d', '#fce8f1'],\n 'Requests': ['inbox', '#4d7c0f', '#eef6df'],\n 'Operations': ['pulse', '#b91c1c', '#fdeaea'],\n 'Configuration': ['sliders', '#0f766e', '#e0f4f1'],\n 'My reports': ['file', '#334155', '#eef1f5']\n };\n var CAT_ORDER = ['My reports', 'People', 'Lifecycle', 'Hygiene', 'Operations', 'Access model', 'Application owners', 'Certifications', 'Requests', 'Configuration'];\n function catOf(r) { return r.custom ? 'My reports' : (r.definition.category || 'Other'); }\n function catIcon(cat) {\n var c = CATS[cat] || ['file', '#334155', '#eef1f5'];\n return el('span', { className: 'cat-ico', style: 'color:' + c[1] + ';background:' + c[2] }, icon(c[0]));\n }\n var POPULAR = ['provisioning-errors', 'aggregation-failures', 'uncorrelated-accounts', 'terminated-users-with-active-accounts', 'person-access', 'application-accounts', 'identity-attribute-mappings', 'privileged-access', 'new-identities'];\n\n function api(path, method, body) {\n return fetch(path, {\n method: method || 'GET',\n headers: Object.assign({ 'x-isc-reports-key': KEY }, body ? { 'content-type': 'application/json' } : {}),\n body: body ? JSON.stringify(body) : undefined\n }).then(function (res) {\n var n = res.headers.get('x-isc-api-calls');\n if (n !== null && $('calls')) $('calls').textContent = Number(n).toLocaleString('en-US');\n return res.json().catch(function () { return {}; }).then(function (data) {\n if (!res.ok) {\n var err = new Error(data.error || ('Request failed (' + res.status + ')'));\n err.problems = data.problems || [];\n err.data = data;\n throw err;\n }\n return data;\n });\n });\n }\n var NOT_ANSWERING = 'IdentityScope on this computer is not answering. If its window was closed or shows an error, start it again and reload this page.';\n function errorText(e) { if (e && e.name === 'TypeError' && /fetch|network|load failed/i.test(e.message || '')) return NOT_ANSWERING; return e.message + (e.problems && e.problems.length ? '\\n- ' + e.problems.join('\\n- ') : ''); }\n var toastTimer;\n function toast(text) {\n var t = $('toast');\n t.textContent = text;\n t.classList.remove('hidden');\n clearTimeout(toastTimer);\n toastTimer = setTimeout(function () { t.classList.add('hidden'); }, 2600);\n }\n function fmtNum(n) { return Number(n).toLocaleString('en-US'); }\n\n // static icons in the page frame\n add($('nav-reports'), [icon('grid'), 'Reports']);\n add($('nav-schedules'), [icon('clock'), 'Schedules']);\n add($('nav-roles'), [icon('layers'), 'Role tools']);\n add($('nav-checks'), [icon('pulse'), 'Instant check']);\n add($('nav-warnings'), [icon('clock'), 'Warnings']);\n add($('nav-nerm'), [icon('people'), 'Non-employees']);\n add($('nav-logs'), [icon('file'), 'Logs']);\n add($('nav-lookup'), [icon('search'), 'Lookup']);\n add($('nav-tenant'), [icon('db'), 'Tenant']);\n add($('nav-build'), [icon('code'), 'Build & test']);\n add($('nav-certs'), [icon('cert'), 'Audit']);\n add($('nav-monthly'), [icon('sigma'), 'Insights']);\n add($('btn-doctor'), [icon('heart'), 'Health check']);\n add($('btn-help'), ['? Help']);\n add($('btn-partner-nav'), [icon('db'), 'All tenants']);\n $('btn-partner-nav').addEventListener('click', function () { showPartner(); });\n $('btn-partner').addEventListener('click', function () { showPartner(); });\n $('btn-help').addEventListener('click', function () { openHelp(); });\n add($('btn-disconnect'), [icon('logout'), 'Disconnect']);\n add($('btn-new'), [icon('plus'), 'New report']);\n add($('search-ico'), icon('search'));\n\n // ---------- connection ----------\n function showConnect(st) {\n $('connect').classList.remove('hidden');\n $('app').classList.add('hidden');\n $('partner').classList.add('hidden');\n $('btn-partner-nav').classList.add('hidden');\n $('demo-bar').classList.add('hidden');\n ['btn-doctor', 'btn-disconnect', 'nav', 'schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'tenant-chip', 'calls-chip', 'token-chip', 'btn-help'].forEach(function (id) { $(id).classList.add('hidden'); });\n if (st && st.signIn) {\n if (st.signIn.baseUrl && !$('si-base').value) $('si-base').value = st.signIn.baseUrl;\n if (st.signIn.clientId && !$('si-client').value) $('si-client').value = st.signIn.clientId;\n $('redirect-uri').textContent = st.signIn.redirectUri;\n }\n if (st && st.saved && st.saved.hasCredentials) {\n $('saved-box').classList.remove('hidden');\n $('saved-url').textContent = st.saved.baseUrl;\n } else $('saved-box').classList.add('hidden');\n }\n function showApp(tenant, user) {\n $('connect').classList.add('hidden');\n ['btn-doctor', 'btn-disconnect', 'nav', 'tenant-chip', 'calls-chip', 'btn-help'].forEach(function (id) { $(id).classList.remove('hidden'); });\n api('/api/state').then(function (st) { state.consoleUrl = st.consoleUrl; state.diagnostics = st.diagnostics; state.demo = !!st.demo; $('demo-bar').classList.toggle('hidden', !st.demo); });\n state.tn.data = {};\n state.ins = null; state.sd = {}; state.ch = {}; state.rc = {}; state.rq = { days: 90 }; state.mn.data = null; state.ev = { days: 365 };\n state.wn = null;\n state.ct.data = null; state.ow.data = null; state.cp.info = null; state.cp.data = null; state.mr.data = null;\n $('tenant').textContent = (tenant || '') + (user ? ' · ' + user : '');\n state.picks = {};\n state.disc = {};\n state.chk.meta = null; state.chk.results = null; state.chk.selected = null;\n state.lk.sources = null; state.lk.person = null; state.lk.source = null; state.lk.matches = null;\n showPage('reports');\n loadLibrary();\n state.pt.data = null;\n loadPartner().catch(function () {});\n if (!state.updateNoticed) { state.updateNoticed = true; noticeNewVersion(); }\n noticeTokenExpiry();\n }\n // Warns in the header when the token this connection uses expires within 14 days.\n function noticeTokenExpiry() {\n var chip = $('token-chip');\n chip.classList.add('hidden');\n api('/api/credentials/mine').then(function (m) {\n if (m.kind !== 'token' || m.daysToExpiry === null || m.daysToExpiry > 14) return;\n var long = m.daysToExpiry < 0 ? 'Token expired' : m.daysToExpiry === 0 ? 'Token expires today' : 'Token expires in ' + m.daysToExpiry + ' day' + (m.daysToExpiry === 1 ? '' : 's');\n var short = m.daysToExpiry < 0 ? 'Token expired' : 'Token: ' + m.daysToExpiry + 'd';\n chip.textContent = '';\n chip.appendChild(el('span', { className: 'tk-long', text: long }));\n chip.appendChild(el('span', { className: 'tk-short', text: short }));\n chip.title = 'The personal access token IdentityScope uses (' + m.name + ') expires ' + (m.expires || '').slice(0, 10) + '. Create a new one in ISC and sign in again with it; scheduled reports stop working when it expires.';\n chip.onclick = function () { state.tn.tab = 'credentials'; showPage('tenant'); };\n chip.classList.remove('hidden');\n }).catch(function () {});\n }\n function showPage(name) {\n state.page = name;\n $('partner').classList.add('hidden');\n $('nav-reports').classList.toggle('active', name === 'reports');\n $('nav-schedules').classList.toggle('active', name === 'schedules');\n $('nav-roles').classList.toggle('active', name === 'roles');\n $('nav-checks').classList.toggle('active', name === 'checks');\n $('nav-lookup').classList.toggle('active', name === 'lookup');\n $('nav-tenant').classList.toggle('active', name === 'tenant');\n $('nav-build').classList.toggle('active', name === 'build');\n $('nav-certs').classList.toggle('active', name === 'certs');\n $('nav-monthly').classList.toggle('active', name === 'monthly');\n $('nav-warnings').classList.toggle('active', name === 'warnings');\n $('nav-nerm').classList.toggle('active', name === 'nerm');\n $('nav-logs').classList.toggle('active', name === 'logs');\n $('app').classList.toggle('hidden', name !== 'reports');\n ['schedules', 'roles', 'checks', 'lookup', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.toggle('hidden', name !== p); });\n if (name === 'certs') renderAudit();\n if (name === 'monthly') { state.mr.data = null; renderInsights(); }\n if (name === 'warnings') renderWarnings();\n if (name === 'nerm') renderNerm();\n if (name === 'logs') renderLogs();\n $('tenant-page').classList.toggle('hidden', name !== 'tenant');\n if (name === 'tenant') renderTenant();\n if (name === 'build') renderBuild();\n if (name === 'schedules') loadSchedules();\n if (name === 'roles') renderRoles();\n if (name === 'checks') renderChecks();\n if (name === 'lookup') renderLookup();\n }\n $('nav-checks').addEventListener('click', function () { showPage('checks'); });\n $('nav-lookup').addEventListener('click', function () { showPage('lookup'); });\n $('nav-tenant').addEventListener('click', function () { showPage('tenant'); });\n $('nav-build').addEventListener('click', function () { showPage('build'); });\n $('nav-certs').addEventListener('click', function () { showPage('certs'); });\n $('nav-monthly').addEventListener('click', function () { showPage('monthly'); });\n $('nav-warnings').addEventListener('click', function () { showPage('warnings'); });\n $('nav-nerm').addEventListener('click', function () { showPage('nerm'); });\n $('nav-logs').addEventListener('click', function () { showPage('logs'); });\n $('nav-roles').addEventListener('click', function () { showPage('roles'); });\n $('nav-reports').addEventListener('click', function () { showPage('reports'); });\n $('nav-schedules').addEventListener('click', function () { state.editing = null; showPage('schedules'); });\n function doConnect(body, button) {\n var err = $('connect-error');\n err.classList.add('hidden');\n button.disabled = true;\n var label = button.textContent;\n button.textContent = 'Connecting...';\n api('/api/connect', 'POST', body).then(function (r) {\n $('in-secret').value = '';\n state.signedIn = false;\n showApp(r.tenant);\n }).catch(function (e) {\n err.textContent = errorText(e);\n err.classList.remove('hidden');\n }).then(function () { button.disabled = false; button.textContent = label; });\n }\n $('btn-connect').addEventListener('click', function () {\n doConnect({ baseUrl: $('in-base').value, clientId: $('in-id').value, clientSecret: $('in-secret').value }, $('btn-connect'));\n });\n $('in-secret').addEventListener('keydown', function (e) { if (e.key === 'Enter') $('btn-connect').click(); });\n $('btn-signin').addEventListener('click', function () {\n var err = $('signin-error');\n err.classList.add('hidden');\n var win = window.open('about:blank', '_blank');\n api('/api/login/start', 'POST', { baseUrl: $('si-base').value, clientId: $('si-client').value, clientSecret: $('si-secret').value }).then(function (r) {\n $('si-secret').value = '';\n if (win) win.location.href = r.authorizeUrl;\n $('signin-link').href = r.authorizeUrl;\n $('signin-wait').classList.remove('hidden');\n var waitUntil = Date.now() + 10 * 60 * 1000;\n (function check() {\n api('/api/state').then(function (st) {\n if (st.connected) { $('signin-wait').classList.add('hidden'); state.signedIn = true; showApp(st.tenant, st.signedInAs); }\n else if (Date.now() < waitUntil) setTimeout(check, 1500);\n else { $('signin-wait').classList.add('hidden'); err.textContent = 'Sign-in timed out. Try again.'; err.classList.remove('hidden'); }\n });\n })();\n }).catch(function (e) {\n if (win) win.close();\n err.textContent = errorText(e);\n err.classList.remove('hidden');\n });\n });\n $('btn-use-saved').addEventListener('click', function () { doConnect({ useSaved: true }, $('btn-use-saved')); });\n $('btn-demo').addEventListener('click', function () {\n var b = $('btn-demo'), err = $('connect-error');\n err.classList.add('hidden');\n b.disabled = true; b.textContent = 'Starting the demo...';\n api('/api/demo/start', 'POST', {}).then(function (r) { state.signedIn = false; showApp(r.tenant); }, function (e) { err.textContent = errorText(e); err.classList.remove('hidden'); })\n .then(function () { b.disabled = false; b.textContent = 'Try the demo tenant'; });\n });\n $('btn-disconnect').addEventListener('click', function () {\n api('/api/disconnect', 'POST', {}).then(function () { return api('/api/state'); }).then(showConnect);\n });\n\n // ---------- health check ----------\n function modal(title, text) {\n $('modal-title').textContent = title;\n $('modal-text').textContent = text;\n $('modal').classList.remove('hidden');\n }\n $('modal-close').addEventListener('click', function () { $('modal').classList.add('hidden'); });\n $('modal').addEventListener('click', function (e) { if (e.target === $('modal')) $('modal').classList.add('hidden'); });\n $('modal-copy').addEventListener('click', function () {\n navigator.clipboard.writeText($('modal-text').textContent).then(function () { toast('Copied'); });\n });\n $('btn-doctor').addEventListener('click', function () {\n modal('Health check', 'Checking sign-in, permissions and data... (about 30 seconds)');\n api('/api/doctor', 'POST', {}).then(function (r) { modal('Health check: safe to share, no names or IDs', r.text); })\n .catch(function (e) { modal('Health check failed', errorText(e)); });\n });\n\n // ---------- library ----------\n function loadLibrary(selectId) {\n return Promise.all([api('/api/reports'), state.catalog ? Promise.resolve(state.catalog) : api('/api/catalog')]).then(function (r) {\n state.reports = r[0];\n state.catalog = r[1];\n var pick = selectId && state.reports.filter(function (x) { return x.definition.id === selectId; })[0];\n if (pick) select(pick);\n else { renderLibrary(); if (!state.current) renderHome(); }\n }).catch(function (e) { $('main').textContent = ''; $('main').appendChild(el('div', { className: 'wrap' }, el('div', { className: 'error', text: errorText(e) }))); });\n }\n function matches(r, q) {\n var d = r.definition;\n return !q || (d.name + ' ' + (d.description || '') + ' ' + d.id + ' ' + (d.tags || []).join(' ') + ' ' + (d.category || '')).toLowerCase().indexOf(q) >= 0;\n }\n function grouped(q) {\n var groups = {};\n state.reports.forEach(function (r) {\n if (!matches(r, q)) return;\n var g = catOf(r);\n (groups[g] = groups[g] || []).push(r);\n });\n var order = Object.keys(groups).sort(function (a, b) {\n var ia = CAT_ORDER.indexOf(a), ib = CAT_ORDER.indexOf(b);\n return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib) || a.localeCompare(b);\n });\n return { groups: groups, order: order };\n }\n function renderLibrary() {\n var q = $('search').value.trim().toLowerCase();\n var g = grouped(q);\n var box = $('library');\n box.textContent = '';\n box.appendChild(el('button', { className: 'entry' + (!state.current ? ' active' : ''), onclick: goHome }, icon('grid'), ' All reports'));\n g.order.forEach(function (name) {\n box.appendChild(el('div', { className: 'group' },\n el('div', { className: 'group-h' }, el('span', { text: name }), el('span', { className: 'count', text: String(g.groups[name].length) })),\n g.groups[name].map(function (r) {\n var active = state.current && state.current.source === r;\n return el('button', { className: 'entry' + (active ? ' active' : ''), title: r.definition.description || '', text: r.definition.name, onclick: function () { select(r); } });\n })));\n });\n if (!g.order.length) box.appendChild(el('div', { className: 'muted small', style: 'padding:10px', text: 'No report matches.' }));\n }\n $('search').addEventListener('input', function () { renderLibrary(); if (!state.current) renderHome(); });\n function goHome() { state.current = null; renderLibrary(); renderHome(); }\n\n function reportCard(r) {\n var d = r.definition;\n var params = Object.keys(d.params || {});\n return el('button', { className: 'rcard', onclick: function () { select(r); } },\n el('div', { className: 'top' }, catIcon(catOf(r)), el('h3', { text: d.name })),\n el('p', { text: d.description || '' }),\n el('div', { className: 'foot' }, el('span', { text: catOf(r) }), params.length ? el('span', { text: '· ' + params.length + (params.length === 1 ? ' option' : ' options') }) : null));\n }\n function renderHome() {\n var m = $('main');\n m.textContent = '';\n var w = el('div', { className: 'wrap' });\n m.appendChild(w);\n var q = $('search').value.trim().toLowerCase();\n var big = el('input', { className: 'input', placeholder: 'Search reports: orphan accounts, leavers, roles, passwords...', value: $('search').value });\n big.addEventListener('input', function () { $('search').value = big.value; renderLibrary(); drawCards(); });\n var builtins = state.reports.filter(function (r) { return !r.custom; }).length;\n var mine = state.reports.length - builtins;\n w.appendChild(el('div', { className: 'hero' },\n el('h2', { text: 'What do you want to know about your tenant?' }),\n el('p', { text: 'Pick a ready-made report, or build your own with point-and-click filters. Everything is read-only.' }),\n el('div', { className: 'searchbox' }, icon('search'), big),\n el('div', { className: 'hero-stats' },\n el('div', {}, el('b', { text: String(builtins) }), 'ready-made reports'),\n el('div', {}, el('b', { text: String(mine) }), 'my reports'),\n el('div', {}, el('b', { text: String((state.catalog.datasets || []).length) }), 'kinds of data'),\n el('button', { className: 'btn sm', style: 'align-self:center;margin-left:auto', onclick: sharePanel }, icon('copy'), 'Share reports: import / export'))));\n var chips = el('div', { className: 'chips' });\n var cards = el('div');\n var glanceBox = el('div');\n w.appendChild(glanceBox);\n glance(glanceBox);\n w.appendChild(el('div', { className: 'cards', style: 'margin-bottom:18px' },\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { showPage('checks'); } },\n el('div', { className: 'top' }, catIcon('Operations'), el('h3', { text: 'Instant check' })), el('p', { text: 'Provisioning errors, failed aggregations, sources, leavers and more: every daily check in one click.' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.lk.tab = 'person'; showPage('lookup'); } },\n el('div', { className: 'top' }, catIcon('People'), el('h3', { text: 'Look up a person or source' })), el('p', { text: 'Accounts, access, recent failures and hints on one page: \"why can\\u2019t this person log in?\"' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.roleTab = 'compare'; showPage('roles'); } },\n el('div', { className: 'top' }, catIcon('Access model'), el('h3', { text: 'Compare roles' })), el('p', { text: 'Side by side: shared and different access, overlap of members, how similar they are.' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.roleTab = 'impact'; showPage('roles'); } },\n el('div', { className: 'top' }, catIcon('Lifecycle'), el('h3', { text: 'Preview a role change' })), el('p', { text: 'Change membership criteria and see who would gain or lose the role, before you save it in ISC.' }))));\n w.appendChild(chips);\n w.appendChild(cards);\n function drawCards() {\n var qq = $('search').value.trim().toLowerCase();\n var g = grouped(qq);\n chips.textContent = '';\n chips.appendChild(el('button', { className: 'chip' + (!state.homeCat ? ' active' : ''), text: 'All', onclick: function () { state.homeCat = ''; drawCards(); } }));\n g.order.forEach(function (c) {\n chips.appendChild(el('button', { className: 'chip' + (state.homeCat === c ? ' active' : ''), onclick: function () { state.homeCat = c; drawCards(); } }, c, el('span', { className: 'muted', text: String(g.groups[c].length) })));\n });\n cards.textContent = '';\n if (!qq && !state.homeCat) {\n var pop = POPULAR.map(function (id) { return state.reports.filter(function (r) { return r.definition.id === id; })[0]; }).filter(Boolean);\n if (pop.length) {\n cards.appendChild(el('div', { className: 'sec-h' }, el('h3', { text: 'Most used' }), el('span', { className: 'muted small', text: 'what IAM teams ask for most' })));\n cards.appendChild(el('div', { className: 'cards' }, pop.map(reportCard)));\n }\n }\n g.order.filter(function (c) { return !state.homeCat || c === state.homeCat; }).forEach(function (c) {\n cards.appendChild(el('div', { className: 'sec-h' }, el('h3', { text: c }), el('span', { className: 'muted small', text: g.groups[c].length + ' reports' })));\n cards.appendChild(el('div', { className: 'cards' }, g.groups[c].map(reportCard)));\n });\n if (!g.order.length) cards.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No report matches \"' + qq + '\".' }), 'Try another word, or build it yourself with ', el('button', { className: 'btn link', text: 'New report', onclick: function () { $('btn-new').click(); } }), '.'));\n }\n drawCards();\n if (q) big.focus();\n }\n\n function select(r) {\n state.current = { source: r, def: clone(r.definition), custom: r.custom, yaml: r.yaml };\n state.result = null;\n state.job = null;\n state.dirty = false;\n state.tab = 'run';\n state.groupBy = '';\n state.runError = null;\n state.running = false;\n state.paramValues = {};\n var p = r.definition.params || {};\n Object.keys(p).forEach(function (k) {\n var d = p[k].default;\n state.paramValues[k] = d === undefined ? (p[k].type === 'list' ? [] : '') : d;\n });\n renderLibrary();\n renderMain();\n $('main').scrollTop = 0;\n }\n\n // ---------- pickers ----------\n function loadPick(kind) {\n if (!state.picks[kind]) state.picks[kind] = api('/api/pick/' + kind).then(function (r) { return r.options; }).catch(function (e) { delete state.picks[kind]; throw e; });\n return state.picks[kind];\n }\n /**\n * A drop-down with search. opts: { options: Promise<[{value,label,hint}]> | array, multiple, value, onChange, placeholder, valueKey }\n * valueKey 'label' stores the names instead of the IDs.\n */\n function picker(opts) {\n var multiple = !!opts.multiple;\n var key = opts.valueKey || 'value';\n var selected = multiple ? (Array.isArray(opts.value) ? opts.value.slice() : opts.value ? String(opts.value).split(',').map(function (s) { return s.trim(); }).filter(Boolean) : []) : (opts.value ? [String(opts.value)] : []);\n var all = null, failed = null;\n var wrap = el('div', { className: 'picker' });\n var btn = el('button', { type: 'button', className: 'picker-btn' });\n wrap.appendChild(btn);\n var pop = null;\n function labelOf(v) {\n if (!all) return v;\n var o = all.filter(function (x) { return x[key] === v; })[0];\n return o ? o.label : v;\n }\n function emit() { opts.onChange(multiple ? selected.slice() : (selected[0] || '')); }\n function drawBtn() {\n btn.textContent = '';\n if (!selected.length) btn.appendChild(el('span', { className: 'ph', text: opts.placeholder || (multiple ? 'All (pick to narrow)' : 'Choose...') }));\n selected.forEach(function (v) {\n btn.appendChild(el('span', { className: 'tok' }, el('span', { text: labelOf(v) }), el('button', { type: 'button', title: 'Remove', text: '×', onclick: function (e) {\n e.stopPropagation();\n selected = selected.filter(function (x) { return x !== v; });\n drawBtn(); emit(); if (pop) drawList();\n } })));\n });\n btn.appendChild(el('span', { className: 'chev' }, icon('chev')));\n }\n var search, list, foot;\n function drawList() {\n list.textContent = '';\n if (failed) { list.appendChild(el('div', { className: 'error', text: failed })); return; }\n if (!all) { list.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading from your tenant...')); return; }\n var q = search.value.trim().toLowerCase();\n var shown = all.filter(function (o) { return !q || (o.label + ' ' + (o.hint || '')).toLowerCase().indexOf(q) >= 0; });\n shown.slice(0, 300).forEach(function (o) {\n var on = selected.indexOf(o[key]) >= 0;\n var row = el('label', { className: 'opt' });\n if (multiple) row.appendChild(el('input', { type: 'checkbox', checked: on }));\n row.appendChild(el('span', { text: o.label, style: on && !multiple ? 'font-weight:600;color:var(--accent)' : '' }));\n if (o.hint) row.appendChild(el('span', { className: 'hint', text: o.hint }));\n row.addEventListener('click', function (e) {\n e.preventDefault();\n if (multiple) {\n if (on) selected = selected.filter(function (x) { return x !== o[key]; }); else selected.push(o[key]);\n drawList();\n } else { selected = [o[key]]; close(); }\n drawBtn(); emit();\n });\n list.appendChild(row);\n });\n if (!shown.length) list.appendChild(el('div', { className: 'muted small', style: 'padding:8px', text: 'Nothing matches.' }));\n if (shown.length > 300) list.appendChild(el('div', { className: 'muted small', style: 'padding:8px', text: 'Showing 300 of ' + shown.length + '. Type to narrow.' }));\n foot.textContent = '';\n foot.appendChild(el('span', { text: all.length + ' in your tenant' + (multiple ? ' · ' + selected.length + ' picked' : '') }));\n if (selected.length) foot.appendChild(el('button', { type: 'button', className: 'btn link', text: 'Clear', onclick: function () { selected = []; drawBtn(); emit(); drawList(); } }));\n }\n function open() {\n if (pop) return;\n search = el('input', { className: 'input', placeholder: 'Search...' });\n list = el('div', { className: 'pop-list' });\n foot = el('div', { className: 'pop-foot' });\n pop = el('div', { className: 'pop' }, search, list, foot);\n wrap.appendChild(pop);\n search.addEventListener('input', drawList);\n search.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });\n drawList();\n setTimeout(function () { search.focus(); document.addEventListener('mousedown', outside); }, 0);\n }\n function close() { if (pop) { pop.remove(); pop = null; document.removeEventListener('mousedown', outside); } }\n function outside(e) { if (!wrap.contains(e.target)) close(); }\n btn.addEventListener('click', function () { if (pop) close(); else open(); });\n Promise.resolve(opts.options).then(function (o) { all = o; drawBtn(); if (pop) drawList(); }, function (e) { failed = errorText(e); if (pop) drawList(); });\n drawBtn();\n return wrap;\n }\n /** Free-text list with suggestions: type and press Enter or comma. */\n function tokenInput(opts) {\n var values = Array.isArray(opts.value) ? opts.value.slice() : opts.value ? String(opts.value).split(',').map(function (s) { return s.trim(); }).filter(Boolean) : [];\n var id = 'dl' + Math.random().toString(36).slice(2);\n var input = el('input', { placeholder: values.length ? '' : (opts.placeholder || 'Type and press Enter'), 'aria-label': opts.label || opts.placeholder || 'Add a value (press Enter)', list: opts.suggestions && opts.suggestions.length ? id : null });\n var box = el('div', { className: 'tokinput' });\n function draw() {\n box.textContent = '';\n values.forEach(function (v) {\n box.appendChild(el('span', { className: 'tok' }, el('span', { text: v }), el('button', { type: 'button', text: '×', 'aria-label': 'Remove ' + v, onclick: function () { values = values.filter(function (x) { return x !== v; }); draw(); opts.onChange(values.slice()); } })));\n });\n input.placeholder = values.length ? '' : (opts.placeholder || 'Type and press Enter');\n box.appendChild(input);\n if (opts.suggestions && opts.suggestions.length) box.appendChild(el('datalist', { id: id }, opts.suggestions.map(function (s) { return el('option', { value: s }); })));\n }\n function commit() {\n input.value.split(',').map(function (s) { return s.trim(); }).filter(Boolean).forEach(function (v) { if (values.indexOf(v) < 0) values.push(v); });\n input.value = '';\n draw(); opts.onChange(values.slice()); input.focus();\n }\n input.addEventListener('keydown', function (e) {\n if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); commit(); }\n else if (e.key === 'Backspace' && !input.value && values.length) { values.pop(); draw(); opts.onChange(values.slice()); input.focus(); }\n });\n input.addEventListener('change', function () { if (input.value.trim()) commit(); });\n input.addEventListener('blur', function () { if (input.value.trim()) commit(); });\n box.addEventListener('click', function (e) { if (e.target === box) input.focus(); });\n draw();\n return box;\n }\n /** Values seen in the tenant for the field a parameter filters on (for suggestions). */\n function suggestionsFor(d, name) {\n if (!d || !state.catalog) return [];\n var field = null;\n (function walk(c) {\n if (!c || field) return;\n if (c.all || c.any) (c.all || c.any).forEach(walk);\n else if (c.not) walk(c.not);\n else if (c.value === '${' + name + '}') field = c.field;\n })({ all: [d.where, d.filter, d.expand && d.expand.where].filter(Boolean) });\n if (!field) return [];\n var disc = state.disc[d.from.dataset];\n if (!disc || !disc.fields) { ensureDisc(d.from.dataset); return []; }\n return fieldInfo(d, field).values || [];\n }\n /** The input for one report parameter. */\n function paramInput(p, value, onChange, suggestions) {\n if (p.pick) return picker({ options: loadPick(p.pick), multiple: p.type === 'list', value: value, onChange: onChange, placeholder: p.type === 'list' ? (p.required ? 'Pick one or more' : 'All (pick to narrow)') : 'Choose...' });\n if (p.options) {\n if (p.type === 'list') return picker({ options: p.options.map(function (o) { return { value: o, label: o }; }), multiple: true, value: value, onChange: onChange });\n var s = el('select', { className: 'input' }, el('option', { value: '', text: p.required ? 'Choose...' : '(any)' }), p.options.map(function (o) { return el('option', { value: o, text: o }); }));\n s.value = value || '';\n s.addEventListener('change', function () { onChange(s.value); });\n return s;\n }\n if (p.type === 'list') return tokenInput({ value: value, onChange: onChange, suggestions: suggestions, placeholder: suggestions && suggestions.length ? 'e.g. ' + suggestions.slice(0, 3).join(', ') : 'Type a value and press Enter' });\n if (p.type === 'boolean') {\n var b = el('select', { className: 'input' }, el('option', { value: '', text: '(default)' }), el('option', { value: 'true', text: 'Yes' }), el('option', { value: 'false', text: 'No' }));\n b.value = value === true ? 'true' : value === false ? 'false' : String(value || '');\n b.addEventListener('change', function () { onChange(b.value); });\n return b;\n }\n var dlId = suggestions && suggestions.length && p.type !== 'number' ? 'pv' + Math.random().toString(36).slice(2) : null;\n var i = el('input', { className: 'input', type: p.type === 'number' ? 'number' : 'text', value: value === undefined || value === null ? '' : String(value), list: dlId });\n i.addEventListener('input', function () { onChange(i.value); });\n if (!dlId) return i;\n return el('div', {}, i, el('datalist', { id: dlId }, suggestions.map(function (v) { return el('option', { value: v }); })));\n }\n function paramsGrid(params, values, onChange, def) {\n var names = Object.keys(params || {});\n if (!names.length) return null;\n return el('div', { className: 'grid' }, names.map(function (k) {\n var p = params[k];\n return el('label', { className: 'field', onclick: function (e) { if (e.target.tagName === 'LABEL') e.preventDefault(); } },\n el('span', { className: 'lbl' }, p.description || k, p.required ? el('span', { className: 'req', text: '*' }) : null),\n paramInput(p, values[k], function (v) { values[k] = v; if (onChange) onChange(k, v); }, def ? suggestionsFor(def, k) : null));\n }));\n }\n\n // ---------- report view ----------\n function renderMain() {\n var m = $('main');\n var keep = m.scrollTop;\n m.textContent = '';\n var c = state.current;\n if (!c) { renderHome(); return; }\n var d = c.def;\n var w = el('div', { className: 'wrap' });\n m.appendChild(w);\n var cat = c.custom ? 'My reports' : (d.category || 'Other');\n w.appendChild(el('div', { className: 'crumbs' }, el('button', { text: 'All reports', onclick: goHome }), '/', el('span', { text: cat })));\n w.appendChild(el('div', { className: 'rhead' }, catIcon(cat), el('div', { style: 'flex:1' },\n el('h2', { text: d.name || 'New report' }),\n d.description ? el('p', { className: 'desc', text: d.description }) : null,\n (d.tags && d.tags.length) ? el('div', { style: 'margin-top:8px' }, d.tags.map(function (t) { return el('span', { className: 'tag', text: t }); })) : null)));\n var tabs = el('div', { className: 'tabs' });\n [['run', 'Run', 'play'], ['design', c.custom ? 'Design' : 'Customize', 'sliders'], ['yaml', 'YAML', 'code']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.tab === t[0] ? ' active' : ''), onclick: function () { state.tab = t[0]; renderMain(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.tab === 'run') renderRun(w);\n else if (state.tab === 'design') renderDesign(w);\n else renderYaml(w);\n m.scrollTop = keep;\n }\n\n function renderRun(w) {\n var c = state.current, d = c.def;\n var card = el('section', { className: 'card' });\n var grid = paramsGrid(d.params, state.paramValues, null, d);\n if (grid) card.appendChild(el('div', { className: 'card-h' }, el('h3', {}, icon('sliders'), 'Options')));\n if (grid) card.appendChild(grid);\n var groupSel = el('select', { className: 'input' }, el('option', { value: '', text: 'Every row' }), fieldChoices(d, true).map(function (g) {\n return el('optgroup', { label: g.label }, g.fields.map(function (o) { return el('option', { value: o.value, text: 'Count by ' + o.label }); }));\n }));\n groupSel.value = state.groupBy || '';\n groupSel.addEventListener('change', function () { state.groupBy = groupSel.value; });\n card.appendChild(el('div', { className: 'runbar', style: grid ? '' : 'margin-top:0;padding-top:0;border-top:none' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Show' }), groupSel),\n el('button', { className: 'btn', title: 'Reads only the first 500 records, to check the report quickly', onclick: function () { run(500); } }, icon('eye'), 'Preview'),\n el('button', { className: 'btn primary', onclick: function () { run(); } }, icon('play'), 'Run report'),\n el('span', { className: 'spacer' }),\n c.isNew ? null : el('button', { className: 'btn ghost', title: 'Send it by email or Teams on a schedule', onclick: function () {\n state.editing = { isNew: true, report: d.id, params: clone(state.paramValues || {}) };\n showPage('schedules');\n } }, icon('clock'), 'Schedule this report')));\n w.appendChild(card);\n var out = el('div', { id: 'run-out' });\n w.appendChild(out);\n renderResult();\n }\n\n function paramsForRun() {\n var out = {};\n Object.keys(state.paramValues || {}).forEach(function (k) {\n var v = state.paramValues[k];\n if (v === '' || v === null || v === undefined || (Array.isArray(v) && !v.length)) return;\n out[k] = v;\n });\n return out;\n }\n function run(preview) {\n var c = state.current;\n var params = paramsForRun();\n Object.keys(params).forEach(function (k) { if (!c.def.params || !c.def.params[k]) delete params[k]; });\n var body = { definition: c.def, params: params, preview: preview, groupBy: state.groupBy && state.tab === 'run' ? [state.groupBy] : [] };\n state.result = null;\n state.runError = null;\n state.progress = 'Starting...';\n state.running = true;\n state.sortCol = null;\n state.quick = '';\n renderResult();\n api('/api/run', 'POST', body).then(function (r) {\n state.job = r.job;\n poll(r.job);\n }).catch(function (e) { state.running = false; state.runError = errorText(e); renderResult(); });\n }\n function poll(job) {\n state.activeJob = job;\n api('/api/jobs/' + job).then(function (s) {\n if (state.job !== job) return;\n if (s.state === 'running') {\n state.progress = s.progress + ' · ' + s.seconds + 's';\n renderResult();\n setTimeout(function () { poll(job); }, 700);\n } else {\n state.running = false;\n if (s.state === 'error') state.runError = s.error;\n else state.result = s.result;\n renderResult();\n }\n }).catch(function (e) { state.running = false; state.runError = errorText(e); renderResult(); });\n }\n function cellText(v) { return v === null || v === undefined ? '' : typeof v === 'boolean' ? (v ? 'Yes' : 'No') : typeof v === 'number' ? fmtNum(v) : String(v); }\n function renderResult() {\n var out = $('run-out');\n if (!out) return;\n out.textContent = '';\n if (state.running) {\n out.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { text: state.progress, style: 'flex:1' }), stopButton())));\n return;\n }\n if (state.runError) { out.appendChild(el('div', { className: 'error', text: state.runError })); return; }\n var r = state.result;\n if (!r) {\n out.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Ready when you are' }), 'Press Preview for a quick look at the first 500 records, or Run report for the full result.'));\n return;\n }\n var dl = function (f, label, primary) {\n return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + state.job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label);\n };\n var quick = el('input', { className: 'input', placeholder: 'Filter these rows...', value: state.quick || '', style: 'width:230px;padding:6px 10px' });\n var card = el('section', { className: 'card', style: 'padding:16px' });\n card.appendChild(el('div', { className: 'stats' },\n el('div', { className: 'stat' }, el('b', { text: fmtNum(r.total) }), el('span', { text: r.total === 1 ? 'row' : 'rows' })),\n el('div', { className: 'stat' }, el('b', { text: (r.durationMs / 1000).toFixed(1) + 's' }), el('span', { text: 'to run' })),\n el('span', { className: 'spacer', style: 'flex:1' }),\n r.total ? quick : null,\n dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML')));\n r.warnings.forEach(function (x) { card.appendChild(el('div', { className: 'note', text: x })); });\n if (r.total > r.shown) card.appendChild(el('div', { className: 'note', text: 'Showing the first ' + fmtNum(r.shown) + ' rows here. Downloads contain all ' + fmtNum(r.total) + '.' }));\n out.appendChild(card);\n if (!r.total) { card.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No rows' }), 'Nothing in the tenant matches this report. That can be good news.')); return; }\n var tableBox = el('div', { className: 'table-wrap' });\n card.appendChild(tableBox);\n function drawTable() {\n var q = (state.quick || '').toLowerCase();\n var rows = r.rows.filter(function (row) { return !q || row.some(function (v) { return cellText(v).toLowerCase().indexOf(q) >= 0; }); });\n if (state.sortCol !== null && state.sortCol !== undefined) {\n var i = state.sortCol, dir = state.sortDir;\n rows = rows.slice().sort(function (a, b) {\n var x = a[i], y = b[i];\n if (x === null || x === '') return 1; if (y === null || y === '') return -1;\n if (typeof x === 'number' && typeof y === 'number') return (x - y) * dir;\n return String(x).localeCompare(String(y), 'en', { numeric: true, sensitivity: 'base' }) * dir;\n });\n }\n tableBox.textContent = '';\n tableBox.appendChild(el('table', {},\n el('thead', {}, el('tr', {}, r.columns.map(function (col, i) {\n return el('th', { title: 'Sort', onclick: function () { state.sortDir = state.sortCol === i ? -state.sortDir : 1; state.sortCol = i; drawTable(); } },\n col.label, state.sortCol === i ? el('span', { className: 'arrow', text: state.sortDir > 0 ? '▲' : '▼' }) : null);\n }))),\n el('tbody', {}, rows.map(function (row) {\n return el('tr', {}, row.map(function (v) {\n if (typeof v === 'boolean') return el('td', {}, el('span', { className: v ? 'yes' : 'no', text: v ? 'Yes' : 'No' }));\n return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) });\n }));\n }))));\n if (!rows.length) tableBox.appendChild(el('div', { className: 'empty', text: 'No shown row contains \"' + state.quick + '\".' }));\n }\n quick.addEventListener('input', function () { state.quick = quick.value; drawTable(); });\n drawTable();\n }\n\n // ---------- fields ----------\n var ALIAS_LABEL = { profile: 'Identity profile', mapping: 'Mapping', identity: 'Person', account: 'Account', access: 'Access item', entitlement: 'Entitlement', source: 'Source', role: 'Role', accessProfile: 'Access profile', event: 'Audit event', activity: 'Account activity', campaign: 'Campaign', item: 'Review item', request: 'Access request', request2: 'Request' };\n function datasetOf(name) { return state.catalog.datasets.filter(function (d) { return d.name === name; })[0]; }\n function ensureDisc(dataset) {\n if (state.disc[dataset]) return;\n state.disc[dataset] = { loading: true };\n api('/api/discover/' + dataset).then(function (r) { state.disc[dataset] = r; }, function (e) { state.disc[dataset] = { error: errorText(e) }; })\n .then(function () {\n if (state.page === 'build' && state.bt && state.bt.tab === 'roles' && dataset === 'identities' && !state.imp.busy) { renderBuild(); return; }\n if (!$('roles').classList.contains('hidden')) { if (dataset === 'identities' && ((state.roleTab === 'impact' && !state.imp.busy) || (state.roleTab === 'mining' && !state.mn.busy))) renderRoles(); return; }\n if (state.current && !state.running && state.tab !== 'yaml' && state.current.def.from.dataset === dataset) renderMain();\n });\n }\n /** Field choices grouped by alias. Each field: { value, label, type, values, path }. */\n function fieldChoices(d, forCounting) {\n var ds = datasetOf(d.from.dataset);\n if (!ds) return [];\n var disc = state.disc[d.from.dataset];\n var discOk = disc && disc.fields;\n var groups = [];\n function addGroup(alias, label, catalog, found) {\n var byPath = {};\n (found || []).forEach(function (f) { byPath[f.path] = f; });\n var known = [], extra = [];\n (catalog || []).forEach(function (f) {\n if (f.type === 'object' || (forCounting && f.type === 'list' && !f.expandable && f.path !== 'tags')) return;\n if (f.expandable) return;\n var df = byPath[f.path];\n known.push({ value: alias + '.' + f.path, label: f.label, type: f.type, values: df ? df.values : [], path: f.path });\n });\n (found || []).forEach(function (f) {\n if (f.known || f.type === 'object') return;\n if ((catalog || []).some(function (c) { return c.path === f.path || f.path.indexOf(c.path + '.') === 0 && c.expandable; })) return;\n extra.push({ value: alias + '.' + f.path, label: f.label, type: f.type, values: f.values, path: f.path });\n });\n if (known.length) groups.push({ label: label, fields: known });\n if (extra.length) groups.push({ label: label + ': more found in your tenant', fields: extra });\n }\n var root = d.from.as || ds.alias;\n addGroup(root, ALIAS_LABEL[root] || ds.label, ds.fields, discOk ? disc.fields : null);\n if (d.expand) {\n var key = d.expand.path.split('.').slice(1).join('.');\n var items = ds.itemFields && ds.itemFields[key];\n if (items) addGroup(d.expand.as, ALIAS_LABEL[d.expand.as] || d.expand.as, items, discOk && disc.items ? disc.items[key] : null);\n }\n (d.joins || []).forEach(function (j) {\n var jd = datasetOf(j.dataset);\n if (jd) addGroup(j.as, (ALIAS_LABEL[j.as] || jd.label) + ' (looked up)', jd.fields, null);\n });\n return groups;\n }\n function flatFields(d) { return [].concat.apply([], fieldChoices(d).map(function (g) { return g.fields; })); }\n function fieldInfo(d, value) {\n var f = flatFields(d).filter(function (x) { return x.value === value; })[0];\n return f || { value: value, label: value, type: 'string', values: [] };\n }\n function fieldSelect(d, value, onChange, opts) {\n opts = opts || {};\n var s = el('select', { className: 'input' });\n if (opts.empty) s.appendChild(el('option', { value: '', text: opts.empty }));\n var found = false;\n fieldChoices(d, opts.counting).forEach(function (g) {\n s.appendChild(el('optgroup', { label: g.label }, g.fields.map(function (f) { if (f.value === value) found = true; return el('option', { value: f.value, text: f.label }); })));\n });\n if (value && !found) s.insertBefore(el('option', { value: value, text: value }), s.firstChild);\n s.value = value || '';\n s.addEventListener('change', function () { onChange(s.value); });\n return s;\n }\n function isSourceId(path) { return /(^|\\.)source\\.id$|(^|\\.)sourceId$/.test(path); }\n function isSourceName(path) { return /(^|\\.)source\\.name$|(^|\\.)sourceName$|(^|\\.)source\\.displayableName$/.test(path); }\n function formatFor(type) { return type === 'date' ? 'date' : type === 'boolean' ? 'boolean' : type === 'number' ? 'number' : type === 'list' ? 'list' : undefined; }\n\n // operators shown for each kind of field\n var OPS_BY_TYPE = {\n string: [['eq', 'is'], ['ne', 'is not'], ['in', 'is one of'], ['notIn', 'is none of'], ['contains', 'contains'], ['notContains', 'does not contain'], ['startsWith', 'starts with'], ['endsWith', 'ends with'], ['exists', 'has a value'], ['missing', 'is empty'], ['matches', 'matches pattern']],\n list: [['eq', 'includes'], ['in', 'includes one of'], ['notIn', 'includes none of'], ['contains', 'has an item containing'], ['exists', 'is not empty'], ['missing', 'is empty']],\n boolean: [['isTrue', 'is Yes'], ['isFalse', 'is No'], ['missing', 'is empty']],\n number: [['eq', '='], ['ne', '≠'], ['gt', '>'], ['gte', '≥'], ['lt', '<'], ['lte', '≤'], ['exists', 'has a value'], ['missing', 'is empty']],\n date: [['newerThanDays', 'in the last (days)'], ['olderThanDays', 'more than (days) ago'], ['exists', 'has a value'], ['missing', 'is empty']]\n };\n function opsFor(type) { return OPS_BY_TYPE[type] || OPS_BY_TYPE.string; }\n function needsValue(op) { var o = state.catalog.operators.filter(function (x) { return x.op === op; })[0]; return o ? o.needsValue : true; }\n var ASK = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\n\n // ---------- designer ----------\n var TEMPLATES = [\n { key: 'people', label: 'People', desc: 'One row per identity', icon: 'people', dataset: 'identities', cols: ['identity.displayName', 'identity.email', 'identity.attributes.department', 'identity.attributes.cloudLifecycleState', 'identity.manager.displayName'] },\n { key: 'people-accounts', label: 'People and their accounts', desc: 'One row per account of each person', icon: 'apps', dataset: 'identities', expand: 'identity.accounts', cols: ['identity.displayName', 'identity.attributes.cloudLifecycleState', 'account.source.name', 'account.name', 'account.disabled'] },\n { key: 'people-access', label: 'People and their access', desc: 'One row per role, access profile or entitlement held', icon: 'layers', dataset: 'identities', expand: 'identity.access', cols: ['identity.displayName', 'identity.email', 'access.type', 'access.displayName', 'access.source.name', 'access.privileged'] },\n { key: 'accounts', label: 'Accounts', desc: 'All accounts, linked or not', icon: 'apps', dataset: 'accounts', cols: ['account.sourceName', 'account.name', 'account.nativeIdentity', 'account.uncorrelated', 'account.disabled'] },\n { key: 'entitlements', label: 'Entitlements', desc: 'Groups, profiles, permissions', icon: 'layers', dataset: 'entitlements', cols: ['entitlement.source.name', 'entitlement.name', 'entitlement.owner.name', 'entitlement.privileged', 'entitlement.requestable'] },\n { key: 'roles', label: 'Roles', desc: 'Role catalog', icon: 'layers', dataset: 'roles', cols: ['role.name', 'role.owner.name', 'role.enabled', 'role.requestable', 'role.accessProfileCount'] },\n { key: 'accessProfiles', label: 'Access profiles', desc: 'Access profile catalog', icon: 'layers', dataset: 'accessProfiles', cols: ['accessProfile.source.name', 'accessProfile.name', 'accessProfile.owner.name', 'accessProfile.enabled', 'accessProfile.requestable'] },\n { key: 'sources', label: 'Sources', desc: 'Connected applications', icon: 'db', dataset: 'sources', cols: ['source.name', 'source.type', 'source.status', 'source.owner.name', 'source.authoritative'] },\n { key: 'events', label: 'Audit events', desc: 'What happened, when, by whom', icon: 'pulse', dataset: 'events', cols: ['event.created', 'event.name', 'event.type', 'event.status', 'event.target.name', 'event.actor.name'] },\n { key: 'accessRequests', label: 'Access requests', desc: 'Requests and where they stand', icon: 'inbox', dataset: 'accessRequests', cols: ['request.created', 'request.requestedFor.name', 'request.name', 'request.type', 'request.state'] },\n { key: 'certificationItems', label: 'Review decisions', desc: 'Certification items and decisions', icon: 'cert', dataset: 'certificationItems', cols: ['item.campaign.name', 'item.certification.reviewer.name', 'item.identitySummary.name', 'item.accessSummary.access.name', 'item.decision'] },\n { key: 'activities', label: 'Account activities', desc: 'Provisioning: creates, changes, errors', icon: 'pulse', dataset: 'accountActivities', cols: ['activity.created', 'activity.action', 'activity.recipient.name', 'activity.sources', 'activity.status', 'activity.errors'] },\n { key: 'mappings', label: 'Identity mappings', desc: 'Where each identity attribute comes from', icon: 'db', dataset: 'identityProfiles', expand: 'profile.mappings', cols: ['profile.name', 'mapping.attribute', 'mapping.kind', 'mapping.source', 'mapping.sourceAttribute', 'mapping.transform'] },\n { key: 'campaigns', label: 'Campaigns', desc: 'Certification campaigns', icon: 'cert', dataset: 'campaigns', cols: ['campaign.name', 'campaign.status', 'campaign.deadline', 'campaign.totalCertifications', 'campaign.completedCertifications'] }\n ];\n function templateFor(d) {\n return TEMPLATES.filter(function (t) { return t.dataset === d.from.dataset && (t.expand || '') === (d.expand ? d.expand.path : ''); })[0];\n }\n function applyTemplate(d, t) {\n d.from = { dataset: t.dataset };\n if (t.expand) d.expand = { path: t.expand, as: t.expand === 'identity.access' ? 'access' : t.expand === 'profile.mappings' ? 'mapping' : 'account' }; else delete d.expand;\n delete d.where; delete d.joins; delete d.filter; delete d.sort; delete d.group; delete d.limit;\n Object.keys(d.params || {}).forEach(function (k) { delete d.params[k]; });\n delete d.params;\n var ds = datasetOf(t.dataset);\n d.columns = t.cols.map(function (p) {\n var root = p.split('.')[0], rest = p.split('.').slice(1).join('.');\n var list = root === (ds.alias) ? ds.fields : (ds.itemFields && ds.itemFields[(t.expand || '').split('.').slice(1).join('.')]) || [];\n var f = list.filter(function (x) { return x.path === rest; })[0];\n return { field: p, label: f ? f.label : undefined, format: f ? formatFor(f.type) : undefined };\n });\n }\n function newReport() {\n var def = { id: 'my-report-' + Date.now().toString(36), name: 'New report', category: 'My reports', from: { dataset: 'identities' } };\n applyTemplate(def, TEMPLATES[0]);\n state.current = { source: null, def: def, custom: true, isNew: true };\n state.tab = 'design';\n state.result = null;\n state.groupBy = '';\n state.runError = null;\n state.paramValues = {};\n state.dirty = true;\n renderLibrary();\n renderMain();\n }\n $('btn-new').addEventListener('click', newReport);\n\n function changed() { state.dirty = true; state.current.yaml = null; }\n function card(stepNo, iconName, title, hint) {\n return el('section', { className: 'card' }, el('div', { className: 'card-h' },\n el('h3', {}, stepNo ? el('span', { className: 'step', text: String(stepNo) }) : icon(iconName), title),\n hint ? el('span', { className: 'muted small', text: hint }) : null));\n }\n\n function renderDesign(w) {\n var c = state.current, d = c.def, ds = datasetOf(d.from.dataset);\n ensureDisc(d.from.dataset);\n var disc = state.disc[d.from.dataset] || {};\n\n // about\n var nameIn = el('input', { className: 'input', value: d.name });\n nameIn.addEventListener('input', function () { d.name = nameIn.value; changed(); });\n var descIn = el('input', { className: 'input', value: d.description || '', placeholder: 'What this report shows and who it is for' });\n descIn.addEventListener('input', function () { d.description = descIn.value || undefined; changed(); });\n var about = card(0, 'file', 'About this report');\n about.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:1fr 2fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Name' }), nameIn),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Description' }), descIn)));\n if (!c.custom) about.appendChild(el('div', { className: 'note', text: 'This is a ready-made report. Your changes are saved as your own copy under \"My reports\".' }));\n w.appendChild(about);\n\n // 1. data\n var tpl = templateFor(d);\n var data = card(1, null, 'What do you want a row to be?', disc.loading ? 'reading a sample of your tenant...' : disc.sampled !== undefined ? 'fields checked against ' + disc.sampled + ' records of your tenant' : '');\n data.appendChild(el('div', { className: 'tiles' }, TEMPLATES.map(function (t) {\n return el('button', { className: 'tile' + (tpl === t ? ' active' : ''), onclick: function () {\n if (tpl === t) return;\n if ((d.filter || d.where || d.group) && !confirm('Start over with \"' + t.label + '\"? Filters and columns are reset.')) return;\n applyTemplate(d, t); changed(); renderMain();\n } }, catIcon({ people: 'People', apps: 'Application owners', layers: 'Access model', db: 'Hygiene', pulse: 'Operations', inbox: 'Requests', cert: 'Certifications' }[t.icon]), el('div', {}, el('b', { text: t.label }), el('span', { text: t.desc })));\n })));\n if (!tpl) data.appendChild(el('div', { className: 'note', text: 'This report reads ' + ds.label.toLowerCase() + (d.expand ? ', one row per item of ' + d.expand.path : '') + '. Pick a tile to start over with another kind of row.' }));\n if (disc.error) data.appendChild(el('div', { className: 'note', text: 'Could not read a sample from your tenant, so only the standard fields are offered. ' + disc.error }));\n if (d.where || (d.expand && d.expand.where) || (d.joins && d.joins.length)) {\n data.appendChild(el('div', { className: 'note', text: 'This report also has built-in rules and lookups. They are kept as they are; see the YAML tab.' }));\n }\n w.appendChild(data);\n\n // 2. filters\n w.appendChild(filtersCard(d));\n\n // 3. columns or counts\n w.appendChild(columnsCard(d));\n\n // 4. sort and limit\n var sortCard = card(4, null, 'Order and size');\n var s0 = (d.sort && d.sort[0]) || '';\n var dir = el('select', { className: 'input' }, el('option', { value: '', text: 'A → Z, smallest, oldest first' }), el('option', { value: '-', text: 'Z → A, largest, newest first' }));\n dir.value = s0.charAt(0) === '-' ? '-' : '';\n var sortField = s0.replace(/^[-+]/, '');\n var writeSort = function () { if (sortField) d.sort = [dir.value + sortField]; else delete d.sort; changed(); };\n dir.addEventListener('change', writeSort);\n var lim = el('input', { className: 'input', type: 'number', min: '1', placeholder: 'all rows', value: d.limit || '' });\n lim.addEventListener('input', function () { var n = Number(lim.value); if (lim.value && n > 0) d.limit = Math.floor(n); else delete d.limit; changed(); });\n sortCard.appendChild(el('div', { className: 'grid' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Sort by' }), fieldSelect(d, sortField, function (v) { sortField = v; writeSort(); }, { empty: 'Report order' })),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Direction' }), dir),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Only the first' }), lim)));\n w.appendChild(sortCard);\n\n // advanced\n var search = ds.kind === 'search';\n var qv = search ? d.from.query : d.from.filter;\n var qIn = el('input', { className: 'input', value: Array.isArray(qv) ? qv.join(search ? ' AND ' : ' and ') : (qv || ''), placeholder: ds.hint || '' });\n qIn.addEventListener('input', function () {\n var key = search ? 'query' : 'filter';\n if (qIn.value.trim()) d.from[key] = qIn.value; else delete d.from[key];\n changed();\n });\n w.appendChild(el('section', { className: 'card' }, el('details', { className: 'adv' }, el('summary', { text: 'Advanced: make big reports faster' }),\n el('p', { className: 'muted small', text: search ? 'An ISC search query narrows what is read from the tenant before your filters run. Your filters above still decide the result.' : 'An ISC API filter narrows what is read from the tenant before your filters run.' }),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: search ? 'Search query' : 'API filter' }), qIn))));\n\n // values to try the asked filters with\n if (d.params && Object.keys(d.params).length) {\n state.paramValues = state.paramValues || {};\n var tc = card(0, 'sliders', 'Try it with', 'these are asked each time the report runs');\n tc.appendChild(paramsGrid(d.params, state.paramValues, null, d));\n w.appendChild(tc);\n }\n\n // actions\n var msg = el('span', { className: 'muted small' });\n w.appendChild(el('div', { className: 'actionbar' },\n el('button', { className: 'btn', onclick: function () { run(500); setTimeout(function () { var o = $('run-out'); if (o) o.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 50); } }, icon('eye'), 'Preview'),\n el('button', { className: 'btn primary', onclick: function () { save(msg); } }, icon('save'), c.custom ? 'Save' : 'Save as my report'),\n c.custom && !c.isNew ? el('button', { className: 'btn ghost danger', onclick: function () {\n if (!confirm('Delete \"' + c.def.name + '\"?')) return;\n api('/api/reports/' + c.def.id, 'DELETE').then(function () { state.current = null; toast('Report deleted'); loadLibrary(); }).catch(function (e) { msg.textContent = errorText(e); });\n } }, icon('trash'), 'Delete') : null,\n msg));\n w.appendChild(el('div', { id: 'run-out' }));\n renderResult();\n }\n\n function filtersCard(d) {\n var fc = card(2, null, 'Which rows?', 'leave empty for all');\n var f = d.filter;\n var list = !f ? [] : f.all ? f.all : f.any ? f.any : f.not ? null : [f];\n var flat = list && list.every(function (x) { return typeof x.field === 'string'; });\n if (!flat) { fc.appendChild(el('div', { className: 'muted', text: 'These filters are nested; edit them in the YAML tab.' })); return fc; }\n var mode = f && f.any ? 'any' : 'all';\n var write = function () {\n list.forEach(function (x) { if (!needsValue(x.op)) delete x.value; });\n var valid = list.filter(function (x) { return x.field; });\n if (!valid.length) delete d.filter; else if (valid.length === 1) d.filter = valid[0]; else d.filter = mode === 'any' ? { any: valid } : { all: valid };\n changed();\n };\n if (list.length > 1) {\n var modeSel = el('select', { className: 'input', style: 'width:auto' }, el('option', { value: 'all', text: 'all' }), el('option', { value: 'any', text: 'any' }));\n modeSel.value = mode;\n modeSel.addEventListener('change', function () { mode = modeSel.value; write(); });\n fc.appendChild(el('div', { className: 'joiner' }, 'Keep rows that match', modeSel, 'of these:'));\n }\n list.forEach(function (x, i) { fc.appendChild(conditionRow(d, x, function () { write(); }, function () { removeAsk(d, x); list.splice(i, 1); write(); renderMain(); })); });\n fc.appendChild(el('button', { className: 'btn', onclick: function () {\n var first = flatFields(d)[0];\n list.push({ field: first ? first.value : '', op: opsFor(first ? first.type : 'string')[0][0], value: '' });\n if (!needsValue(list[list.length - 1].op)) delete list[list.length - 1].value;\n write(); renderMain();\n } }, icon('plus'), 'Add a filter'));\n return fc;\n }\n\n function paramNameFor(d, label) {\n var base = label.replace(/[^A-Za-z0-9 ]/g, ' ').trim().split(/\\s+/).map(function (w, i) { w = w.toLowerCase(); return i ? w.charAt(0).toUpperCase() + w.slice(1) : w; }).join('') || 'value';\n if (/^[0-9]/.test(base)) base = 'p' + base;\n var n = base, k = 2;\n while (d.params && d.params[n]) n = base + k++;\n return n;\n }\n function removeAsk(d, x) {\n var m = typeof x.value === 'string' && ASK.exec(x.value);\n if (m && d.params) { delete d.params[m[1]]; if (!Object.keys(d.params).length) delete d.params; }\n }\n\n function conditionRow(d, x, write, remove) {\n var info = fieldInfo(d, x.field);\n var ops = opsFor(info.type);\n if (!ops.some(function (o) { return o[0] === x.op; })) ops = ops.concat([[x.op, (state.catalog.operators.filter(function (o) { return o.op === x.op; })[0] || { label: x.op }).label]]);\n var askM = typeof x.value === 'string' && ASK.exec(x.value);\n var fieldSel = fieldSelect(d, x.field, function (v) {\n removeAsk(d, x);\n x.field = v;\n var t = fieldInfo(d, v).type;\n x.op = opsFor(t)[0][0];\n if (needsValue(x.op)) x.value = ''; else delete x.value;\n write(); renderMain();\n });\n var opSel = el('select', { className: 'input' }, ops.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n opSel.value = x.op;\n opSel.addEventListener('change', function () {\n var wasList = x.op === 'in' || x.op === 'notIn';\n x.op = opSel.value;\n var isList = x.op === 'in' || x.op === 'notIn';\n if (!needsValue(x.op)) { removeAsk(d, x); delete x.value; }\n else if (!askM && wasList !== isList) x.value = isList ? (x.value ? [String(x.value)] : []) : (Array.isArray(x.value) ? (x.value[0] || '') : x.value || '');\n else if (askM) { var p = d.params[askM[1]]; p.type = isList ? 'list' : (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') ? 'number' : 'string'; }\n write(); renderMain();\n });\n var valueBox = el('div');\n if (askM) {\n var p = (d.params || {})[askM[1]] || {};\n var q = el('input', { className: 'input', value: p.description || '', placeholder: 'Question shown when running' });\n q.addEventListener('input', function () { p.description = q.value || undefined; changed(); });\n valueBox.appendChild(q);\n } else if (needsValue(x.op)) {\n valueBox.appendChild(valueEditor(d, x, info, write));\n }\n var askBox = el('input', { type: 'checkbox', checked: !!askM });\n askBox.addEventListener('change', function () {\n if (askBox.checked) {\n // Source names become a source drop-down: ask for the source, filter on its ID.\n var idField = isSourceName(x.field) ? x.field.replace(/source\\.name$|source\\.displayableName$/, 'source.id').replace(/sourceName$/, 'sourceId') : null;\n if (idField && flatFields(d).some(function (f) { return f.value === idField; })) { x.field = idField; x.value = Array.isArray(x.value) ? [] : ''; }\n var listOp = x.op === 'in' || x.op === 'notIn';\n var numeric = x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number';\n var name = paramNameFor(d, fieldInfo(d, x.field).label);\n d.params = d.params || {};\n var spec = { type: listOp ? 'list' : numeric ? 'number' : 'string', description: fieldInfo(d, x.field).label + (numeric && x.op !== 'eq' ? ' (days)' : '') };\n if (isSourceId(x.field)) spec.pick = 'sources';\n var cur = x.value;\n if (cur !== '' && cur !== undefined && !(Array.isArray(cur) && !cur.length) && !isSourceId(x.field)) spec['default'] = cur;\n d.params[name] = spec;\n x.value = '${' + name + '}';\n state.paramValues = state.paramValues || {};\n state.paramValues[name] = spec['default'] !== undefined ? spec['default'] : spec.type === 'list' ? [] : '';\n } else {\n var m = ASK.exec(x.value);\n var prev = m && d.params && d.params[m[1]];\n removeAsk(d, x);\n x.value = prev && prev['default'] !== undefined ? prev['default'] : (x.op === 'in' || x.op === 'notIn') ? [] : '';\n }\n write(); renderMain();\n });\n var ask = needsValue(x.op) ? el('label', { className: 'ask' }, askBox, el('span', { text: askM ? 'Asked when the report runs (and in schedules).' : 'Ask for this value each time the report runs' })) : null;\n return el('div', { className: 'cond' }, fieldSel, opSel, valueBox,\n el('button', { className: 'btn icon ghost', title: 'Remove this filter', onclick: remove }, icon('x')), ask);\n }\n\n function valueEditor(d, x, info, write) {\n var listOp = x.op === 'in' || x.op === 'notIn';\n var path = info.path || x.field;\n if (isSourceId(path) || isSourceName(path)) {\n return picker({ options: loadPick('sources'), multiple: listOp, value: x.value, valueKey: isSourceId(path) ? 'value' : 'label', onChange: function (v) { x.value = v; write(); }, placeholder: listOp ? 'Pick sources' : 'Pick a source' });\n }\n if (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') {\n var n = el('input', { className: 'input', type: 'number', value: x.value === undefined ? '' : String(x.value), placeholder: x.op === 'newerThanDays' || x.op === 'olderThanDays' ? 'days, e.g. 30' : 'number' });\n n.addEventListener('input', function () { x.value = n.value === '' ? '' : Number(n.value); write(); });\n return n;\n }\n if (listOp) {\n if (info.values && info.values.length && info.values.length <= 50) {\n return picker({ options: info.values.map(function (v) { return { value: v, label: v }; }), multiple: true, value: x.value, onChange: function (v) { x.value = v; write(); }, placeholder: 'Pick or type values' });\n }\n return tokenInput({ value: x.value, suggestions: info.values, onChange: function (v) { x.value = v; write(); } });\n }\n var id = 'sv' + Math.random().toString(36).slice(2);\n var t = el('input', { className: 'input', value: x.value === undefined ? '' : String(x.value), list: info.values && info.values.length ? id : null, placeholder: info.values && info.values.length ? 'e.g. ' + info.values.slice(0, 2).join(', ') : 'value' });\n t.addEventListener('input', function () { x.value = t.value; write(); });\n return el('div', {}, t, info.values && info.values.length ? el('datalist', { id: id }, info.values.map(function (v) { return el('option', { value: v }); })) : null);\n }\n\n function columnsCard(d) {\n var counting = !!(d.group && d.group.by && d.group.by.length);\n var cc = card(3, null, 'What to show', null);\n var modeSel = el('div', { className: 'chips', style: 'margin-bottom:14px' },\n el('button', { className: 'chip' + (!counting ? ' active' : ''), onclick: function () {\n if (!counting) return;\n d.columns = state.current.stash || d.columns; delete d.group; changed(); renderMain();\n } }, icon('cols'), 'A list of rows'),\n el('button', { className: 'chip' + (counting ? ' active' : ''), onclick: function () {\n if (counting) return;\n state.current.stash = clone(d.columns || []);\n var first = (d.columns && d.columns[0] && d.columns[0].field) || (flatFields(d)[0] || {}).value;\n d.group = { by: [first], countLabel: 'Count' };\n syncGroupColumns(d); changed(); renderMain();\n } }, icon('sigma'), 'Counts (summary)'));\n cc.appendChild(modeSel);\n if (counting) {\n cc.appendChild(el('p', { className: 'muted small', style: 'margin-top:0', text: 'One row per combination of these fields, with how many rows have it. Largest first.' }));\n d.group.by.forEach(function (b, i) {\n cc.appendChild(el('div', { className: 'colrow', style: 'grid-template-columns:28px 1fr auto' }, el('span', { className: 'n', text: String(i + 1) }),\n fieldSelect(d, b, function (v) { d.group.by[i] = v; syncGroupColumns(d); changed(); }, { counting: true }),\n el('button', { className: 'btn icon ghost', title: 'Remove', disabled: d.group.by.length === 1, onclick: function () { d.group.by.splice(i, 1); syncGroupColumns(d); changed(); renderMain(); } }, icon('x'))));\n });\n if (d.group.by.length < 4) cc.appendChild(fieldSelect(d, '', function (v) { if (!v) return; d.group.by.push(v); syncGroupColumns(d); changed(); renderMain(); }, { empty: '+ Also count by...', counting: true }));\n var cl = el('input', { className: 'input', value: d.group.countLabel || 'Count', style: 'max-width:260px' });\n cl.addEventListener('input', function () { d.group.countLabel = cl.value || undefined; changed(); });\n cc.appendChild(el('label', { className: 'field', style: 'margin:14px 0 0' }, el('span', { className: 'lbl', text: 'Heading of the count column' }), cl));\n return cc;\n }\n var formats = [['', 'Automatic'], ['text', 'Text'], ['date', 'Date'], ['datetime', 'Date and time'], ['number', 'Number'], ['boolean', 'Yes / No'], ['list', 'List'], ['count', 'How many'], ['json', 'Raw']];\n d.columns = d.columns || [];\n d.columns.forEach(function (col, i) {\n var li = el('input', { className: 'input', value: col.label || '', placeholder: fieldInfo(d, col.field).label });\n li.addEventListener('input', function () { col.label = li.value || undefined; changed(); });\n var fs = el('select', { className: 'input' }, formats.map(function (x) { return el('option', { value: x[0], text: x[1] }); }));\n fs.value = col.format || '';\n fs.addEventListener('change', function () { col.format = fs.value || undefined; changed(); });\n var move = function (delta) {\n var j = i + delta;\n if (j < 0 || j >= d.columns.length) return;\n var t = d.columns[i]; d.columns[i] = d.columns[j]; d.columns[j] = t;\n changed(); renderMain();\n };\n cc.appendChild(el('div', { className: 'colrow' }, el('span', { className: 'n', text: String(i + 1) }),\n fieldSelect(d, col.field, function (v) { col.field = v; var inf = fieldInfo(d, v); col.label = inf.label; col.format = formatFor(inf.type); changed(); renderMain(); }),\n li, fs,\n el('div', { className: 'bar', style: 'gap:2px' },\n el('button', { className: 'btn icon ghost', title: 'Move up', disabled: i === 0, onclick: function () { move(-1); } }, icon('up')),\n el('button', { className: 'btn icon ghost', title: 'Move down', disabled: i === d.columns.length - 1, onclick: function () { move(1); } }, icon('down')),\n el('button', { className: 'btn icon ghost', title: 'Remove', onclick: function () { d.columns.splice(i, 1); changed(); renderMain(); } }, icon('x')))));\n });\n if (!d.columns.length) cc.appendChild(el('div', { className: 'note', text: 'Add at least one column.' }));\n var addSel = fieldSelect(d, '', function (v) {\n if (!v) return;\n var inf = fieldInfo(d, v);\n d.columns.push({ field: v, label: inf.label, format: formatFor(inf.type) });\n changed(); renderMain();\n }, { empty: '+ Add a column...' });\n addSel.style.maxWidth = '420px';\n cc.appendChild(el('div', { style: 'margin-top:10px' }, addSel));\n return cc;\n }\n function syncGroupColumns(d) {\n d.columns = d.group.by.filter(Boolean).map(function (b) { var inf = fieldInfo(d, b); return { field: b, label: inf.label, format: inf.type === 'date' ? 'date' : undefined }; });\n }\n\n function save(msg) {\n var c = state.current;\n var def = clone(c.def);\n if (!c.custom) {\n def.id = def.id + '-copy';\n def.name = def.name + ' (my copy)';\n var n = 2;\n while (state.reports.some(function (r) { return r.definition.id === def.id; })) def.id = c.def.id + '-copy-' + n++;\n }\n def.category = c.custom ? (def.category || 'My reports') : 'My reports';\n msg.textContent = '';\n api('/api/reports', 'POST', { definition: def }).then(function (r) {\n toast('Saved \"' + def.name + '\" to My reports');\n state.dirty = false;\n state.current = null;\n return loadLibrary(r.saved);\n }).catch(function (e) { msg.textContent = ''; msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });\n }\n\n // ---------- yaml ----------\n function renderYaml(w) {\n var c = state.current;\n var ta = el('textarea', { className: 'yaml', spellcheck: 'false' });\n var problems = el('div');\n w.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'The full report definition. Copy it to share the report, or edit it directly and press Apply.' }));\n w.appendChild(ta);\n w.appendChild(problems);\n w.appendChild(el('div', { className: 'bar', style: 'margin-top:12px' },\n el('button', { className: 'btn primary', onclick: function () {\n problems.textContent = '';\n api('/api/parse', 'POST', { yaml: ta.value }).then(function (r) { c.def = r.definition; changed(); c.yaml = ta.value; state.tab = 'design'; toast('Applied'); renderMain(); })\n .catch(function (e) { problems.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, 'Apply'),\n el('button', { className: 'btn', onclick: function () { navigator.clipboard.writeText(ta.value).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')));\n if (c.yaml && !state.dirty) ta.value = c.yaml;\n else api('/api/yaml', 'POST', { definition: c.def }).then(function (r) {\n ta.value = r.yaml;\n if (r.problems.length) problems.appendChild(el('div', { className: 'error', text: 'Fix before running:\\n- ' + r.problems.join('\\n- ') }));\n });\n }\n\n // ---------- instant check ----------\n state.chk = { results: null, meta: null, selected: null, auto: 0, timer: null, busy: null };\n var STATUS = { ok: ['OK', 'ok'], warn: ['Attention', 'warn'], bad: ['Problem', 'bad'], error: ['Could not check', 'err'], off: ['Off', 'off'] };\n function ago(iso) {\n if (!iso) return '';\n var s = Math.round((Date.now() - Date.parse(iso)) / 1000);\n if (s < 60) return 'just now';\n if (s < 3600) return Math.round(s / 60) + ' min ago';\n if (s < 86400) return Math.round(s / 3600) + ' h ago';\n return Math.round(s / 86400) + ' days ago';\n }\n function when(iso) { return iso ? iso.replace('T', ' ').slice(0, 16) : '—'; }\n function sparkline(points, w, h) {\n var NS = 'http://www.w3.org/2000/svg';\n var svg = document.createElementNS(NS, 'svg');\n svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);\n svg.setAttribute('width', w); svg.setAttribute('height', h);\n svg.setAttribute('class', 'spark');\n var vals = (points || []).filter(function (p) { return p.value !== null && p.value !== undefined; }).slice(-30);\n if (vals.length < 2) return svg;\n var max = Math.max.apply(null, vals.map(function (p) { return p.value; })), min = Math.min.apply(null, vals.map(function (p) { return p.value; }));\n var span = max - min || 1;\n var pts = vals.map(function (p, i) { return (i * (w - 4) / (vals.length - 1) + 2).toFixed(1) + ',' + (h - 3 - ((p.value - min) / span) * (h - 6)).toFixed(1); });\n var line = document.createElementNS(NS, 'polyline');\n line.setAttribute('points', pts.join(' '));\n line.setAttribute('fill', 'none'); line.setAttribute('stroke', 'currentColor'); line.setAttribute('stroke-width', '1.8'); line.setAttribute('stroke-linejoin', 'round');\n svg.appendChild(line);\n var last = pts[pts.length - 1].split(',');\n var dot = document.createElementNS(NS, 'circle');\n dot.setAttribute('cx', last[0]); dot.setAttribute('cy', last[1]); dot.setAttribute('r', '2.6'); dot.setAttribute('fill', 'currentColor');\n svg.appendChild(dot);\n var t = document.createElementNS(NS, 'title');\n t.textContent = vals.length + ' checks, from ' + fmtNum(min) + ' to ' + fmtNum(max);\n svg.appendChild(t);\n return svg;\n }\n function loadCheckMeta() { return api('/api/checks').then(function (m) { state.chk.meta = m; return m; }); }\n function runAllChecks() {\n var c = state.chk;\n if (c.busy) return;\n c.busy = 'Starting the checks...'; c.error = null; renderChecks();\n api('/api/checks/run', 'POST', {}).then(function (r) {\n c.job = r.job;\n pollJob(r.job, function (m) { c.busy = m; var p = $('chk-progress'); if (p) p.textContent = m; },\n function (s) { c.busy = null; c.results = s.extra.results; c.headline = s.extra.headline; c.at = new Date().toISOString(); loadCheckMeta().then(renderChecks, renderChecks); },\n function (e) { c.busy = null; c.error = e; renderChecks(); });\n }).catch(function (e) { c.busy = null; c.error = errorText(e); renderChecks(); });\n }\n function setAuto(min) {\n var c = state.chk;\n c.auto = min;\n if (c.timer) clearInterval(c.timer);\n c.timer = min ? setInterval(function () { if (!$('checks').classList.contains('hidden')) runAllChecks(); }, min * 60000) : null;\n }\n function renderChecks() {\n var c = state.chk;\n var outer = $('checks');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n if (!c.meta) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadCheckMeta().then(renderChecks, function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }\n var autoSel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Refresh the instant check automatically' }, [[0, 'Refresh: off'], [5, 'Every 5 min'], [15, 'Every 15 min'], [30, 'Every 30 min'], [60, 'Every hour']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n autoSel.value = String(c.auto || 0);\n autoSel.addEventListener('change', function () { setAuto(Number(autoSel.value)); });\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:#b91c1c;background:#fdeaea' }, icon('pulse')),\n el('div', { style: 'flex:1' }, el('h2', { text: 'Instant check' }), el('p', { className: 'desc', text: 'Every daily check in one click: provisioning, aggregations, sources, identities, requests, leavers, campaigns. Read-only.' })),\n autoSel,\n el('button', { className: 'btn', onclick: function () { c.showLimits = !c.showLimits; renderChecks(); } }, icon('sliders'), 'Limits'),\n el('button', { className: 'btn primary', disabled: !!c.busy, onclick: runAllChecks }, icon('play'), c.results ? 'Check again' : 'Run all checks')));\n if (c.showLimits) w.appendChild(limitsCard());\n if (c.error) w.appendChild(el('div', { className: 'error', text: c.error }));\n var trends = c.meta.trends || {};\n var results = c.results;\n var bad = 0, warn = 0, err = 0;\n (results || []).forEach(function (r) { if (r.status === 'bad') bad++; else if (r.status === 'warn') warn++; else if (r.status === 'error') err++; });\n if (c.busy) w.appendChild(el('div', { className: 'banner run' }, el('span', { className: 'spinner' }), el('span', { id: 'chk-progress', text: c.busy, style: 'flex:1' }), stopButton()));\n else if (results) {\n var level = bad ? 'bad' : warn || err ? 'warn' : 'ok';\n w.appendChild(el('div', { className: 'banner ' + level },\n el('b', { text: level === 'ok' ? 'All checks OK' : c.headline.charAt(0).toUpperCase() + c.headline.slice(1) }),\n el('span', { text: 'Checked ' + ago(c.at) + (c.auto ? ' · refreshes every ' + c.auto + ' min' : '') }),\n el('span', { style: 'flex:1' }),\n c.job ? el('a', { className: 'btn sm', href: '/api/jobs/' + c.job + '/download?format=xlsx&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Summary in Excel') : null));\n } else {\n var lastAt = null;\n Object.keys(trends).forEach(function (k) { var p = trends[k].points; if (p && p.length && (!lastAt || p[p.length - 1].at > lastAt)) lastAt = p[p.length - 1].at; });\n w.appendChild(el('div', { className: 'banner idle' }, el('b', { text: lastAt ? 'Last checked ' + ago(lastAt) : 'Not checked yet' }), el('span', { text: 'Press \"Run all checks\". A full check takes from a few seconds to a few minutes on large tenants.' })));\n }\n var grid = el('div', { className: 'tiles-chk' });\n var byId = {};\n (results || []).forEach(function (r) { byId[r.id] = r; });\n c.meta.checks.forEach(function (m) {\n var r = byId[m.id];\n var tr = trends[m.id] || {};\n var off = m.optIn ? !(m.settings && m.settings.enabled === true) : (m.settings && m.settings.enabled === false);\n var st = off ? 'off' : r ? r.status : (tr.status || null);\n var stale = !r && st;\n var tile = el('button', { className: 'chk ' + (st ? STATUS[st][1] : 'none') + (c.selected === m.id ? ' sel' : '') + (stale ? ' stale' : ''), onclick: function () { c.selected = c.selected === m.id ? null : m.id; renderChecks(); } });\n tile.appendChild(el('div', { className: 'chk-top' }, el('span', { className: 'chk-dot' }), el('span', { className: 'chk-label', text: m.label }), st ? el('span', { className: 'chk-st', text: STATUS[st][0] + (stale && !off ? ' (last time)' : '') }) : null));\n var value = r ? r.value : (tr.points && tr.points.length ? tr.points[tr.points.length - 1].value : null);\n tile.appendChild(el('div', { className: 'chk-mid' }, el('b', { text: value === null || value === undefined ? '—' : fmtNum(value) }), el('span', { className: 'muted', text: value === 1 ? (m.unit === 'people' ? 'person' : m.unit.replace(/ies$/, 'y').replace(/s$/, '')) : m.unit }),\n el('span', { style: 'flex:1' }), sparkline(tr.points, 92, 30)));\n tile.appendChild(el('div', { className: 'chk-sum', text: off ? (m.optIn && !(m.settings && m.settings.enabled === false) ? 'Needs setting up: save the end-date attribute on Warnings > End dates.' : 'Switched off in Limits.') : r ? r.summary : (tr.summary || m.description) }));\n if (r && r.newCount && !m.growth) tile.appendChild(el('span', { className: 'pill blue', text: r.newCount + ' new' }));\n if (r && r.top && r.top.length) tile.appendChild(el('div', { className: 'chk-top3' }, r.top.map(function (x) { return el('div', {}, el('span', { text: x.label }), el('b', { text: fmtNum(x.count) })); })));\n grid.appendChild(tile);\n });\n w.appendChild(grid);\n if (c.selected) w.appendChild(checkDetail(c.meta.checks.filter(function (m) { return m.id === c.selected; })[0], byId[c.selected], trends[c.selected]));\n }\n function checkDetail(m, r, tr) {\n var card = el('section', { className: 'card', style: 'margin-top:16px' });\n card.appendChild(el('div', { className: 'card-h' }, el('h3', { text: m.label }),\n m.report ? el('button', { className: 'btn sm', onclick: function () {\n var rep = state.reports.filter(function (x) { return x.definition.id === m.report; })[0];\n if (!rep) return;\n showPage('reports'); select(rep);\n if (r && r.params) Object.keys(r.params).forEach(function (k) { state.paramValues[k] = r.params[k]; });\n renderMain();\n } }, icon('file'), 'Open the full report') : null));\n card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: m.description + ' Amber from ' + fmtNum((m.settings.warn || m.defaults.warn)) + ', red from ' + fmtNum((m.settings.bad || m.defaults.bad)) + (m.growth ? ' more than the previous check.' : '.') }));\n var pts = (tr && tr.points) || [];\n if (pts.length >= 2) {\n card.appendChild(el('div', { className: 'trend' }, el('div', { className: 'muted small', text: 'Trend (' + pts.length + ' checks since ' + when(pts[0].at).slice(0, 10) + ')' }), sparkline(pts, 640, 90)));\n }\n var fx = fixCard(m.id);\n if (fx && (!r || r.status !== 'ok')) card.appendChild(fx);\n if (!r) { card.appendChild(el('div', { className: 'muted', text: 'Run the checks to see the details.' })); return card; }\n if (r.newItems && r.newItems.length) card.appendChild(el('div', { className: 'note', text: 'New since the previous check: ' + r.newItems.join('; ') + (r.newCount > r.newItems.length ? ' and ' + (r.newCount - r.newItems.length) + ' more' : '') }));\n if (r.status === 'error') { card.appendChild(el('div', { className: 'error', text: r.error })); return card; }\n if (!r.rows.length) { card.appendChild(el('div', { className: 'empty', text: 'Nothing found. Good.' })); return card; }\n card.appendChild(el('div', { className: 'table-wrap', style: 'max-height:50vh' }, el('table', {},\n el('thead', {}, el('tr', {}, r.columns.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }), m.growth ? null : el('th', { style: 'cursor:default' }, el('span', { className: 'sr-only', text: 'Exception' })))),\n el('tbody', {}, r.rows.map(function (row, i) {\n var key = r.rowKeys && r.rowKeys[i];\n return el('tr', {}, row.map(function (v) { return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) }); }),\n m.growth ? null : el('td', { style: 'width:1%;white-space:nowrap' }, key ? el('button', { className: 'btn sm', title: 'Accept this item as an exception, with a reason and an end date', 'aria-label': 'Accept ' + key + ' as an exception', onclick: function () { acceptDialog(m, key, runAllChecks); } }, 'Accept…') : null));\n })))));\n if (r.value > r.rows.length) card.appendChild(el('div', { className: 'note', text: 'Showing ' + r.rows.length + ' of ' + fmtNum(r.value) + '. Open the full report for everything.' }));\n if (r.accepted) card.appendChild(el('p', { className: 'muted small' }, fmtNum(r.accepted) + ' accepted as exception' + (r.accepted === 1 ? '' : 's') + ' and left out. ', el('button', { className: 'btn link', style: 'padding:0', text: 'See exceptions', onclick: function () { state.au.tab = 'exceptions'; showPage('certs'); } })));\n return card;\n }\n function limitsCard() {\n var c = state.chk;\n var edits = {};\n var rows = c.meta.checks.map(function (m) {\n var s = m.settings || {};\n var e = edits[m.id] = { enabled: m.optIn ? s.enabled === true : s.enabled !== false, optIn: !!m.optIn, warn: s.warn, bad: s.bad, days: s.days };\n var on = el('input', { type: 'checkbox', checked: e.enabled });\n on.addEventListener('change', function () { e.enabled = on.checked; });\n var num = function (key, ph) {\n var i = el('input', { className: 'input', type: 'number', min: '1', value: e[key] === undefined ? '' : String(e[key]), placeholder: String(ph), style: 'width:110px;padding:5px 8px' });\n i.addEventListener('input', function () { e[key] = i.value === '' ? undefined : Number(i.value); });\n return i;\n };\n return el('tr', {}, el('td', {}, el('label', { className: 'check' }, on, m.label)),\n el('td', {}, num('warn', m.defaults.warn)), el('td', {}, num('bad', m.defaults.bad)),\n el('td', {}, m.defaults.days !== undefined ? num('days', m.defaults.days) : el('span', { className: 'muted', text: '—' })),\n el('td', { className: 'muted small', text: m.growth ? 'limits apply to the increase' : '' }));\n });\n var msg = el('span');\n return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Limits' }), el('span', { className: 'muted small', text: 'empty = default (shown in grey). Also used by scheduled instant checks.' })),\n el('div', { className: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ['Check', 'Amber from', 'Red from', 'Days', ''].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))), el('tbody', {}, rows))),\n el('div', { className: 'bar', style: 'margin-top:12px' }, el('button', { className: 'btn primary', onclick: function () {\n var out = {};\n Object.keys(edits).forEach(function (k) { var e = edits[k]; var o = {}; if (!e.enabled) o.enabled = false; else if (e.optIn) o.enabled = true; ['warn', 'bad', 'days'].forEach(function (x) { if (e[x] !== undefined && !isNaN(e[x])) o[x] = e[x]; }); out[k] = o; });\n msg.textContent = '';\n api('/api/checks/settings', 'PUT', { checks: out }).then(function () { toast('Limits saved'); c.showLimits = false; return loadCheckMeta(); }).then(renderChecks).catch(function (e) { msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save limits'), msg));\n }\n\n // ---------- lookup ----------\n state.lk = { tab: 'person', q: '', matches: null, person: null, sources: null, source: null, filter: '' };\n function renderLookup() {\n var L = state.lk;\n var outer = $('lookup');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#2457d6;background:#eaf0fd' }, icon('search')),\n el('div', {}, el('h2', { text: 'Lookup' }), el('p', { className: 'desc', text: 'Everything about one person or one source on one page. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['person', 'Person', 'people'], ['source', 'Source', 'db'], ['ownership', 'Ownership', 'layers']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (L.tab === t[0] ? ' active' : ''), onclick: function () { L.tab = t[0]; renderLookup(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (L.tab === 'person') renderPerson(w); else if (L.tab === 'ownership') renderOwnership(w); else renderSourceLookup(w);\n }\n var searchTimer;\n function renderPerson(w) {\n var L = state.lk;\n var input = el('input', { className: 'input', value: L.q, placeholder: 'Name, username or email (at least 2 characters)', style: 'font-size:15px;padding:11px 12px 11px 36px' });\n var list = el('div');\n input.addEventListener('input', function () {\n L.q = input.value;\n clearTimeout(searchTimer);\n searchTimer = setTimeout(function () {\n if (L.q.trim().length < 2) { L.matches = null; drawMatches(); return; }\n list.textContent = ''; list.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Searching...'));\n var asked = L.q;\n api('/api/people?q=' + encodeURIComponent(asked)).then(function (r) { if (asked === L.q) { L.matches = r.people; drawMatches(); } }).catch(function (e) { list.textContent = ''; list.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }, 300);\n });\n function drawMatches() {\n list.textContent = '';\n if (!L.matches) return;\n if (!L.matches.length) { list.appendChild(el('div', { className: 'muted', style: 'padding:10px', text: 'Nobody found.' })); return; }\n list.appendChild(el('div', { className: 'matches' }, L.matches.map(function (m) {\n return el('button', { className: 'match' + (L.person && L.person.id === m.id ? ' sel' : ''), onclick: function () { openPerson(m.id); } },\n el('b', { text: m.name }), el('span', { className: 'muted', text: [m.username, m.email, m.department, m.lifecycleState].filter(Boolean).join(' · ') }));\n })));\n }\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'searchbox' }, icon('search'), input), list));\n drawMatches();\n setTimeout(function () { input.focus(); input.setSelectionRange(input.value.length, input.value.length); }, 0);\n if (L.loading) w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading accounts, access and recent activity...'));\n else if (L.personError) w.appendChild(el('div', { className: 'error', text: L.personError }));\n else if (L.person) w.appendChild(personView(L.person));\n }\n function openPerson(id) {\n var L = state.lk;\n L.loading = true; L.personError = null; renderLookup();\n api('/api/people/' + id).then(function (p) { L.person = p; L.loading = false; L.matches = null; renderLookup(); }).catch(function (e) { L.loading = false; L.personError = errorText(e); renderLookup(); });\n }\n function section(title, count, body) {\n return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, title, count !== null && count !== undefined ? el('span', { className: 'pill off', text: String(count) }) : null)), body);\n }\n function simpleTable(headers, rows, label) {\n if (!rows.length) return el('div', { className: 'muted', text: 'None.' });\n // Focusable so a long table can be scrolled with the keyboard.\n return el('div', { className: 'table-wrap', style: 'max-height:46vh', tabindex: '0', role: 'region', 'aria-label': label || 'Table: ' + headers.filter(Boolean).join(', ') }, el('table', {},\n el('thead', {}, el('tr', {}, headers.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, rows.map(function (r) { return el('tr', {}, r.map(function (v) {\n if (v && v.nodeType) return el('td', {}, v);\n return el('td', { className: v === null || v === undefined || v === '' ? 'empty-cell' : '', text: v === null || v === undefined || v === '' ? '—' : String(v) });\n })); }))));\n }\n function yesNo(v, badWhenYes) { return el('span', { className: v ? (badWhenYes ? 'chg lose' : 'yes') : 'no', text: v ? 'Yes' : 'No' }); }\n function personView(p) {\n var box = el('div');\n var lcBad = p.inactive || /inactive|terminat|disabled|leaver/i.test(p.lifecycleState || '');\n box.appendChild(el('section', { className: 'card' },\n el('div', { className: 'bar', style: 'align-items:flex-start' }, el('div', { className: 'avatar', text: (p.name || '?').split(/\\s+/).map(function (x) { return x.charAt(0); }).slice(0, 2).join('').toUpperCase() }),\n el('div', { style: 'flex:1' }, el('h2', { style: 'margin:0;font-size:20px', text: p.name }),\n el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: p.username || '' }), el('span', { text: p.email || 'no email' }), el('span', { text: 'Manager: ' + (p.manager || 'none') }), el('span', { text: 'Profile: ' + (p.identityProfile || '?') }))),\n el('span', { className: 'pill ' + (lcBad ? 'off' : 'on'), text: p.lifecycleState || 'no lifecycle state' }), openInIsc('/ui/a/admin/identities/' + encodeURIComponent(p.id) + '/details/attributes', true)),\n el('div', { className: 'flags' }, p.flags.map(function (f) { return el('div', { className: 'flag ' + f.level, text: f.text }); }))));\n p.notes.forEach(function (n) { box.appendChild(el('div', { className: 'note', text: n })); });\n var byType = {}, srcs = {}, priv = 0, direct = 0;\n p.access.forEach(function (a) { byType[a.type] = (byType[a.type] || 0) + 1; if (a.source) srcs[a.source] = 1; if (a.privileged) priv++; if (a.type === 'ENTITLEMENT' && a.direct) direct++; });\n box.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: String(p.accounts.length) }), el('span', { text: 'accounts' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ROLE || 0) }), el('span', { text: 'roles' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ACCESS_PROFILE || 0) }), el('span', { text: 'access profiles' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ENTITLEMENT || 0) }), el('span', { text: 'entitlements (' + direct + ' assigned directly)' })),\n el('div', { className: 'bigstat' + (priv ? ' lose' : '') }, el('b', { text: String(priv) }), el('span', { text: 'privileged access items' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(Object.keys(srcs).length) }), el('span', { text: 'sources with access' }))));\n box.appendChild(section('Accounts', p.accounts.length, simpleTable(['Source', 'Account', 'Disabled', 'Locked', 'Privileged', 'Password set'],\n p.accounts.map(function (a) { return [a.source, a.name, yesNo(a.disabled, true), yesNo(a.locked, true), yesNo(a.privileged), (a.passwordLastSet || '').slice(0, 10)]; }))));\n box.appendChild(section('Recent provisioning (30 days)', p.activities.length, simpleTable(['Time', 'Action', 'Sources', 'Status', 'Errors'],\n p.activities.map(function (a) { return [when(a.created), a.action, a.sources, a.status, a.errors.join('; ')]; }))));\n box.appendChild(section('Access', p.access.length, simpleTable(['Type', 'Access', 'Source', 'Privileged', 'Assigned directly'],\n p.access.map(function (a) { return [a.type, a.name, a.source, yesNo(a.privileged), a.type === 'ENTITLEMENT' ? (a.direct ? 'Yes' : 'Through a role or access profile') : 'Yes']; }))));\n box.appendChild(timelineSection(p));\n box.appendChild(section('Access requests', p.requests.length, simpleTable(['Submitted', 'Access', 'Type', 'State'], p.requests.map(function (r) { return [when(r.created), r.name, r.type, r.state]; }))));\n box.appendChild(section('Audit events about this person (30 days)', p.events.length, simpleTable(['Time', 'Event', 'Status', 'By'], p.events.map(function (e) { return [when(e.created), e.name, e.status, e.actor]; }))));\n box.appendChild(section('Identity attributes', p.attributes.length, simpleTable(['Attribute', 'Value'], p.attributes.map(function (a) { return [a.name, a.value]; }))));\n return box;\n }\n function renderSourceLookup(w) {\n var L = state.lk;\n if (L.source || L.sourceLoading || L.sourceError) {\n w.appendChild(el('button', { className: 'btn ghost', style: 'margin-bottom:10px', onclick: function () { L.source = null; L.sourceError = null; renderLookup(); } }, '← All sources'));\n if (L.sourceLoading) w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading counts, aggregations and errors for this source...'));\n else if (L.sourceError) w.appendChild(el('div', { className: 'error', text: L.sourceError }));\n else w.appendChild(sourceView(L.source));\n return;\n }\n if (!L.sources) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading sources and their recent aggregations...'));\n api('/api/sources').then(function (r) { L.sources = r; renderLookup(); }).catch(function (e) { L.sources = { sources: [], notes: [errorText(e)] }; renderLookup(); });\n return;\n }\n var f = el('input', { className: 'input', placeholder: 'Filter sources...', value: L.filter, style: 'max-width:320px' });\n var tableBox = el('div');\n function draw() {\n var q = L.filter.toLowerCase();\n var list = L.sources.sources.filter(function (s) { return !q || (s.name + ' ' + (s.type || '') + ' ' + (s.owner || '')).toLowerCase().indexOf(q) >= 0; });\n tableBox.textContent = '';\n tableBox.appendChild(simpleTable(['Source', 'Connection', 'Last aggregation', 'Last success', 'Owner', 'Type'], list.map(function (s) {\n var agg = s.lastAggregation ? el('span', {}, el('span', { className: 'chg ' + (s.lastAggregation.status === 'PASSED' ? 'gain' : 'lose'), text: s.lastAggregation.status === 'PASSED' ? 'Passed' : 'Failed' }), ' ' + ago(s.lastAggregation.created)) : el('span', { className: 'muted', text: 'none in 7 days' });\n return [el('button', { className: 'btn link', style: 'padding:0', text: s.name, onclick: function () { openSource(s.id); } }), el('span', { className: 'chg ' + (s.healthy ? 'gain' : 'lose'), text: s.healthy ? 'OK' : (s.status || '').replace('SOURCE_STATE_', '').replace(/_/g, ' ').toLowerCase() }), agg, s.lastSuccess ? ago(s.lastSuccess) : null, s.owner || null, s.type || null];\n })));\n }\n f.addEventListener('input', function () { L.filter = f.value; draw(); });\n var bad = L.sources.sources.filter(function (s) { return !s.healthy; }).length;\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Sources' }), el('span', { className: 'muted small', text: L.sources.sources.length + ' sources, ' + bad + ' with a connection problem' }), f), tableBox));\n L.sources.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n draw();\n }\n function openSource(id) {\n var L = state.lk;\n L.sourceLoading = true; L.sourceError = null; renderLookup();\n api('/api/sources/' + id).then(function (d) { L.source = d; L.sourceLoading = false; renderLookup(); }).catch(function (e) { L.sourceLoading = false; L.sourceError = errorText(e); renderLookup(); });\n }\n function sourceView(d) {\n var s = d.source, box = el('div');\n box.appendChild(el('section', { className: 'card' },\n el('div', { className: 'bar' }, el('h2', { style: 'margin:0;font-size:20px;flex:1', text: s.name }), el('span', { className: 'pill ' + (s.healthy ? 'on' : 'off'), text: s.healthy ? 'Connection OK' : (s.status || '').replace('SOURCE_STATE_', '').replace(/_/g, ' ').toLowerCase() }), openInIsc('/ui/a/admin/connections/sources/' + encodeURIComponent(s.id) + '/menu/base_configuration')),\n el('div', { className: 'kv', style: 'margin-top:6px' }, el('span', { text: s.type || '' }), el('span', { text: 'Owner: ' + (s.owner || 'none') }), el('span', { text: s.authoritative ? 'Authoritative' : 'Not authoritative' }), s.description ? el('span', { text: s.description }) : null)));\n var cnt = d.counts;\n var stat = function (v, label, cls) { return el('div', { className: 'bigstat' + (cls ? ' ' + cls : '') }, el('b', { text: v === null ? '—' : fmtNum(v) }), el('span', { text: label })); };\n box.appendChild(el('div', { className: 'bigstats' }, stat(cnt.accounts, 'accounts'), stat(cnt.uncorrelated, 'not linked to a person', cnt.uncorrelated ? 'lose' : ''), stat(cnt.entitlements, 'entitlements'), stat(cnt.entitlementsWithoutOwner, 'entitlements without owner', cnt.entitlementsWithoutOwner ? 'lose' : ''),\n el('div', { className: 'bigstat' }, el('b', { text: s.lastSuccess ? ago(s.lastSuccess) : 'none' }), el('span', { text: 'last successful aggregation (30 days)' }))));\n var open = function (id, params) { return el('button', { className: 'btn sm', onclick: function () {\n var rep = state.reports.filter(function (x) { return x.definition.id === id; })[0];\n showPage('reports'); select(rep); Object.keys(params).forEach(function (k) { state.paramValues[k] = params[k]; }); renderMain();\n } }, icon('file'), 'Open report'); };\n box.appendChild(el('div', { className: 'bar', style: 'margin-bottom:16px' }, el('span', { className: 'muted', text: 'Reports for this source:' }),\n el('span', {}, 'Unlinked accounts ', open('uncorrelated-accounts', { sources: [s.id] })), el('span', {}, 'Everyone with an account ', open('application-accounts', { sources: [s.id] })), el('span', {}, 'Entitlements without owner ', open('entitlements-without-owner', { sources: [s.id] }))));\n d.notes.forEach(function (n) { box.appendChild(el('div', { className: 'note', text: n })); });\n if (d.usedBy) box.appendChild(section('Used by', null, el('div', {},\n d.usedBy.identityProfiles.length ? simpleTable(['Identity profile', 'How it uses this source'], d.usedBy.identityProfiles.map(function (x) { return [x.name, x.how]; })) : el('div', { className: 'muted', text: 'No identity profile reads this source.' }),\n el('div', { className: 'kv', style: 'margin-top:10px' }, el('span', {}, el('b', { text: d.usedBy.accessProfiles === null ? '\\u2014' : fmtNum(d.usedBy.accessProfiles) }), ' access profiles on this source'), el('span', {}, el('b', { text: fmtNum(d.usedBy.mappedAttributes) }), ' identity attribute mappings read it')))));\n box.appendChild(diagnosticsCard(s));\n box.appendChild(sourceConfigCard(s.id));\n box.appendChild(section('Provisioning errors by cause (7 days)', d.causes.length, simpleTable(['Cause', 'Errors'], d.causes.map(function (c) { return [c.cause, c.count]; }))));\n box.appendChild(section('Aggregations (30 days)', d.aggregations.length, simpleTable(['Time', 'Event', 'Status', 'Errors'], d.aggregations.map(function (a) { return [when(a.created), a.name, el('span', { className: 'chg ' + (a.status === 'PASSED' ? 'gain' : 'lose'), text: a.status || '?' }), a.errors]; }))));\n box.appendChild(section('Latest provisioning errors (7 days)', d.errors.length, simpleTable(['Time', 'Action', 'For', 'Error'], d.errors.map(function (e) { return [when(e.created), e.action, e.person, e.error]; }))));\n return box;\n }\n\n // ---------- tenant ----------\n state.tn = { tab: 'overview', data: {}, days: 1, filter: '' };\n function renderTenant() {\n var T = state.tn;\n var outer = $('tenant-page');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#e0f4f1' }, icon('db')),\n el('div', {}, el('h2', { text: 'Tenant' }), el('p', { className: 'desc', text: 'The size and health of the setup behind the identities: Virtual Appliances, workflows, transforms and API credentials. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['overview', 'Overview', 'grid'], ['clusters', 'Virtual Appliances', 'db'], ['workflows', 'Workflows', 'lifecycle'], ['transforms', 'Transforms', 'code'], ['credentials', 'API credentials', 'shield'], ['cmap', 'Credential map', 'eye'], ['rules', 'Rule usage', 'code'], ['compare', 'Compare tenants', 'cols']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (T.tab === t[0] ? ' active' : ''), onclick: function () { T.tab = t[0]; renderTenant(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (T.tab === 'compare') { renderCompare2(w); return; }\n if (T.tab === 'credentials') { renderCredentials(w); return; }\n // One home for each: runs and failures, where transforms are used, where credentials are used.\n if (T.tab === 'workflows') { renderWorkflowHealth(w); return; }\n if (T.tab === 'transforms') { renderImpactMap(w); return; }\n if (T.tab === 'cmap') { renderCredentialMap(w); return; }\n if (T.tab === 'rules') { renderRuleUsage(w); return; }\n var key = T.tab;\n var d = T.data[key];\n var reload = el('button', { className: 'btn sm', onclick: function () { delete T.data[key]; renderTenant(); } }, icon('lifecycle'), 'Reload');\n if (!d) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading from your tenant...'));\n T.data[key] = { loading: true };\n api('/api/tenant/' + T.tab).then(function (r) { T.data[key] = r; }, function (e) { T.data[key] = { error: errorText(e) }; }).then(function () { if (!$('tenant-page').classList.contains('hidden')) renderTenant(); });\n return;\n }\n if (d.loading) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading from your tenant...')); return; }\n if (d.error) { w.appendChild(el('div', { className: 'error', text: d.error })); w.appendChild(reload); return; }\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n if (T.tab === 'overview') {\n w.appendChild(el('div', { className: 'bigstats' }, d.counts.map(function (c) { return el('div', { className: 'bigstat' }, el('b', { text: c.count === null ? '—' : fmtNum(c.count) }), el('span', { text: c.label })); })));\n w.appendChild(el('div', { className: 'bar' }, reload, el('span', { className: 'muted small', text: 'A dash means the current sign-in or token cannot read that number.' })));\n var gl = el('div', { style: 'margin-top:18px' });\n w.appendChild(gl);\n glance(gl);\n } else if (T.tab === 'clusters') {\n var bad = d.clusters.filter(function (c) { return !c.healthy; }).length;\n w.appendChild(el('div', { className: 'banner ' + (bad ? 'bad' : 'ok') }, el('b', { text: bad ? bad + ' cluster' + (bad > 1 ? 's' : '') + ' need attention' : 'All clusters normal' }), el('span', { text: d.clusters.length + ' clusters' }), el('span', { style: 'flex:1' }), reload));\n d.clusters.forEach(function (c) {\n w.appendChild(section(c.name, c.clients.length, el('div', {},\n el('div', { className: 'kv', style: 'margin-bottom:10px' }, el('span', {}, el('span', { className: 'chg ' + (c.healthy ? 'gain' : 'lose'), text: c.status || (c.healthy ? 'NORMAL' : '?') })), c.type ? el('span', { text: 'Type: ' + c.type }) : null, c.alert ? el('span', { text: 'Alert: ' + c.alert }) : null, c.operational === false ? el('span', { text: 'Not operational' }) : null),\n simpleTable(['Appliance', 'Status', 'Last seen', 'Version', 'IP address'], c.clients.map(function (v) {\n return [v.name, el('span', { className: 'chg ' + (v.healthy ? 'gain' : 'lose'), text: v.status || '?' }), v.sinceLastSeen ? v.sinceLastSeen + ' ago' : when(v.lastSeen), v.version, v.ip];\n }), 'Appliances in ' + c.name))));\n });\n }\n }\n\n\n // ---------- API credentials ----------\n state.cr = { expiringDays: 30, unusedDays: 90, only: 'attention', q: '' };\n function credFlagClass(f) { return /^Expired|^Owner|^Expires (today|in [0-9] )/.test(f) ? 'lose' : /^Expires|^Never expires|^Not used|^Never used|^Can change|^All of/.test(f) ? 'off' : 'keep-other'; }\n function renderCredentials(w) {\n var C = state.cr;\n var exp = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Expiring within' }, [7, 14, 30, 60, 90].map(function (n) { return el('option', { value: String(n), text: 'Expiring within ' + n + ' days' }); }));\n exp.value = String(C.expiringDays);\n exp.addEventListener('change', function () { C.expiringDays = Number(exp.value); });\n var un = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Unused for' }, [30, 60, 90, 180, 365].map(function (n) { return el('option', { value: String(n), text: 'Unused for ' + n + '+ days' }); }));\n un.value = String(C.unusedDays);\n un.addEventListener('change', function () { C.unusedDays = Number(un.value); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Personal access tokens and API clients: when they expire, when they were last used, whether their owner is still here, and how much they can do. Secrets are never read.' }), exp, un,\n el('button', { className: 'btn primary', disabled: !!C.busy, onclick: function () { runJobInto(C, '/api/credentials/run', { expiringDays: C.expiringDays, unusedDays: C.unusedDays }, renderTenant); } }, icon('play'), C.data ? 'Read again' : 'Read credentials')));\n if (C.busy) { w.appendChild(busyBox(C.busy)); return; }\n if (C.error) { w.appendChild(el('div', { className: 'error', text: C.error })); return; }\n var d = C.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n if (d.thisConnection) {\n var dd = d.thisConnection.daysToExpiry;\n w.appendChild(el('div', { className: 'banner ' + (dd !== null && dd <= 14 ? 'bad' : 'ok') }, el('b', { text: 'The token IdentityScope uses (' + d.thisConnection.name + ')' }),\n el('span', { text: d.thisConnection.expires === null ? 'never expires' : dd < 0 ? 'expired ' + (-dd) + ' days ago' : 'expires ' + d.thisConnection.expires.slice(0, 10) + ' (in ' + dd + ' day' + (dd === 1 ? '' : 's') + ')' })));\n }\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.tokens) }), el('span', { text: 'personal access tokens' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.clients) }), el('span', { text: 'API clients' })),\n el('div', { className: 'bigstat' + (T.expiringSoon ? ' lose' : '') }, el('b', { text: fmtNum(T.expiringSoon) }), el('span', { text: 'expire within ' + d.expiringDays + ' days' })),\n el('div', { className: 'bigstat' + (T.ownerLeft ? ' lose' : '') }, el('b', { text: fmtNum(T.ownerLeft) }), el('span', { text: 'active, owner has left' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.neverExpire) }), el('span', { text: 'tokens that never expire' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.unused) }), el('span', { text: 'unused ' + d.unusedDays + '+ days' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.expired) }), el('span', { text: 'already expired' }))));\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['attention', 'Needing attention'], ['all', 'All'], ['tokens', 'Personal access tokens'], ['clients', 'API clients']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = C.only;\n var f = el('input', { className: 'input', placeholder: 'Filter by name or owner...', value: C.q, style: 'max-width:260px', 'aria-label': 'Filter by name or owner' });\n var box = el('div');\n var draw = function () {\n var q = C.q.toLowerCase();\n var list = d.credentials.filter(function (c) {\n if (C.only === 'attention' && !c.flags.length) return false;\n if (C.only === 'tokens' && c.kind !== 'Personal access token') return false;\n if (C.only === 'clients' && c.kind !== 'API client') return false;\n return !q || (c.name + ' ' + (c.owner || '')).toLowerCase().indexOf(q) >= 0;\n });\n box.textContent = '';\n box.appendChild(list.length ? simpleTable(['Type', 'Name', 'Owner', 'Expires', 'Last used', 'Scopes', 'Needs attention'], list.map(function (c) {\n return [c.kind === 'API client' ? 'API client' : 'Token',\n el('span', {}, c.name, c.thisConnection ? el('span', { className: 'chg gain', style: 'margin-left:6px', text: 'used by IdentityScope' }) : null, c.managed ? el('span', { className: 'chg keep-other', style: 'margin-left:6px', text: 'managed by SailPoint' }) : null),\n c.owner ? c.owner + (c.ownerStatus && c.ownerStatus !== 'active' ? ' (' + c.ownerStatus + ')' : '') : null,\n el('span', { style: 'white-space:nowrap', text: c.kind === 'API client' ? 'does not expire' : c.expires === null ? 'never' : c.expires.slice(0, 10) }),\n el('span', { style: 'white-space:nowrap', text: c.lastUsed ? c.lastUsed.slice(0, 10) : 'never' }),\n el('span', { className: 'small', text: c.scopes.length ? c.scopes.join(' ') : 'all of the owner\\u2019s rights' }),\n el('span', {}, c.flags.map(function (x) { return el('span', { className: 'chg ' + credFlagClass(x), style: 'margin:0 4px 2px 0;display:inline-block', text: x }); }))];\n })) : el('p', { className: 'muted', text: C.only === 'attention' ? 'Nothing needs attention.' : 'None.' }));\n };\n only.addEventListener('change', function () { C.only = only.value; draw(); });\n f.addEventListener('input', function () { C.q = f.value; draw(); });\n w.appendChild(section('Credentials', d.credentials.length, el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, only, f, el('span', { style: 'flex:1' }), downloads(C.job)), box)));\n draw();\n w.appendChild(el('p', { className: 'muted small', text: 'API clients have no expiry date in ISC; their secret can be rotated. \"Last used\" is updated by SailPoint about once a day. Tokens managed by SailPoint (for example for workflows) are not flagged for never expiring.' }));\n }\n // ---------- source configuration and diagnostics (used by the source page) ----------\n function openInIsc(path, unverified) {\n if (!state.consoleUrl) return null;\n return el('a', { className: 'btn sm', href: state.consoleUrl + path, target: '_blank', rel: 'noopener', title: unverified ? 'Opens the ISC admin console. If the page is not found, tell us the right address.' : 'Opens the ISC admin console' }, icon('eye'), 'Open in ISC');\n }\n function sourceConfigCard(id) {\n var pre = el('pre', { className: 'json' });\n var det = el('details', { className: 'adv' }, el('summary', { text: 'Configuration (secrets hidden)' }), el('div', { className: 'bar', style: 'margin:10px 0' },\n el('button', { className: 'btn sm', onclick: function () { navigator.clipboard.writeText(pre.textContent).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')), pre);\n det.addEventListener('toggle', function () {\n if (!det.open || pre.textContent) return;\n pre.textContent = 'Loading...';\n api('/api/sources/' + id + '/config').then(function (r) { pre.textContent = JSON.stringify(r.config, null, 2); }).catch(function (e) { pre.textContent = errorText(e); });\n });\n return el('section', { className: 'card' }, det);\n }\n function diagnosticsCard(s) {\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, icon('pulse'), 'Connector diagnostics'), el('span', { className: 'pill ' + (state.diagnostics ? 'on' : 'off'), text: state.diagnostics ? 'on' : 'off' })));\n if (!state.diagnostics) {\n card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'Test connection, ping cluster and peek change nothing in ISC or in the application, but they make the Virtual Appliance contact the application, and peek shows live data from it. They are off unless you turn them on. Every use is written to logs/diagnostics.log.' }));\n card.appendChild(el('button', { className: 'btn', onclick: function () {\n if (!confirm('Turn on connector diagnostics on this computer? Each action still asks before it runs.')) return;\n api('/api/settings/diagnostics', 'PUT', { enabled: true }).then(function (r) { state.diagnostics = r.diagnostics; renderLookup(); });\n } }, 'Turn on diagnostics'));\n return card;\n }\n var out = el('div', { style: 'margin-top:12px' });\n var run = function (action, extra) {\n var label = { test: 'Test the connection to', ping: 'Ping the VA cluster of', peek: 'Read live objects from' }[action];\n if (!confirm(label + ' \"' + s.name + '\"?')) return;\n out.textContent = '';\n out.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Waiting for the Virtual Appliance...'));\n api('/api/sources/' + s.id + '/diagnostics', 'POST', Object.assign({ action: action, confirm: true }, extra || {})).then(function (r) {\n out.textContent = '';\n var res = r.result || {};\n if (action === 'peek') {\n var objs = res.resourceObjects || [];\n out.appendChild(el('div', { className: 'muted small', text: objs.length + ' object(s) in ' + (res.elapsedMillis || '?') + ' ms. Shown here only, not saved.' }));\n objs.forEach(function (o) {\n var attrs = o.attributes || {};\n out.appendChild(el('details', { className: 'adv', style: 'margin-top:8px' }, el('summary', { text: (o.name || o.identity || '?') + (o.identity && o.identity !== o.name ? ' (' + o.identity + ')' : '') }),\n simpleTable(['Attribute', 'Value'], Object.keys(attrs).sort().map(function (k) { var v = attrs[k]; return [k, typeof v === 'object' ? JSON.stringify(v) : String(v)]; }))));\n });\n } else {\n var good = /success/i.test(res.status || '');\n out.appendChild(el('div', { className: good ? 'success' : 'error', text: (good ? 'Succeeded' : 'Result: ' + (res.status || 'unknown')) + (res.elapsedMillis ? ' in ' + res.elapsedMillis + ' ms' : '') + '.' }));\n if (res.details && Object.keys(res.details).length) out.appendChild(el('pre', { className: 'json', text: JSON.stringify(res.details, null, 2) }));\n }\n }).catch(function (e) { out.textContent = ''; out.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n };\n var objType = el('select', { className: 'input', style: 'width:auto' }, el('option', { value: 'account', text: 'accounts' }), el('option', { value: 'group', text: 'groups' }));\n var count = el('select', { className: 'input', style: 'width:auto' }, [5, 10, 25].map(function (n) { return el('option', { value: String(n), text: String(n) }); }));\n count.value = '10';\n card.appendChild(el('div', { className: 'bar' },\n el('button', { className: 'btn', onclick: function () { run('test'); } }, 'Test connection'),\n el('button', { className: 'btn', onclick: function () { run('ping'); } }, 'Ping VA cluster'),\n el('span', { className: 'muted', style: 'margin-left:10px', text: 'Peek' }), count, objType,\n el('button', { className: 'btn', onclick: function () { run('peek', { objectType: objType.value, maxCount: Number(count.value) }); } }, 'Peek live objects'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn ghost sm', onclick: function () { api('/api/settings/diagnostics', 'PUT', { enabled: false }).then(function (r) { state.diagnostics = r.diagnostics; renderLookup(); }); } }, 'Turn off')));\n card.appendChild(out);\n return card;\n }\n\n // ---------- certifications ----------\n state.ct = { days: 90, items: true };\n function runJobInto(holder, path, body, rerender) {\n holder.busy = 'Starting...'; holder.error = null; holder.data = null; rerender();\n api(path, 'POST', body || {}).then(function (r) {\n holder.job = r.job;\n pollJob(r.job, function (m) { holder.busy = m; var p = document.querySelector('[data-progress]'); if (p) p.textContent = m; },\n function (s) {\n holder.busy = null; holder.data = s.extra;\n // Anything ISC cut short is shown as a note on the result.\n if (s.warnings && s.warnings.length && holder.data && typeof holder.data === 'object') holder.data.notes = (holder.data.notes || []).concat(s.warnings);\n rerender();\n },\n function (e) { holder.busy = null; holder.error = e; rerender(); });\n }).catch(function (e) { holder.busy = null; holder.error = errorText(e); rerender(); });\n }\n function stopButton() {\n var b = el('button', { className: 'btn sm ghost', title: 'Stop this job. Nothing is changed in ISC; a partly done check is not saved.', onclick: function () {\n if (!state.activeJob) return;\n b.disabled = true; b.textContent = 'Stopping...';\n api('/api/jobs/' + state.activeJob + '/stop', 'POST', {}).catch(function (e) { toast(errorText(e)); });\n } }, icon('x'), 'Stop');\n return b;\n }\n function busyBox(text) { return el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0', role: 'status', 'aria-live': 'polite' }, el('span', { className: 'spinner' }), el('span', { 'data-progress': '1', text: text, style: 'flex:1' }), stopButton())); }\n function pageHead(w, iconName, color, bg, title, desc, right) {\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:' + color + ';background:' + bg }, icon(iconName)),\n el('div', { style: 'flex:1' }, el('h2', { text: title }), el('p', { className: 'desc', text: desc })), right || null));\n }\n function progressBar(pct, warn) {\n return el('div', { style: 'display:flex;align-items:center;gap:8px;min-width:140px' }, el('div', { className: 'meter', style: 'flex:1;margin:0' }, el('span', { style: 'width:' + Math.min(100, pct) + '%;' + (warn ? 'background:linear-gradient(90deg,#f59e0b,#d97706)' : '') })), el('span', { className: 'small', text: pct + '%' }));\n }\n function renderCerts() { renderAudit(); }\n function certsTab(w) {\n var C = state.ct;\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(C.days);\n period.addEventListener('change', function () { C.days = Number(period.value); });\n var items = el('input', { type: 'checkbox', checked: C.items });\n items.addEventListener('change', function () { C.items = items.checked; });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Campaign progress, reviewers who are behind, and reviews that look rubber-stamped.' }), period, el('label', { className: 'check', title: 'Reads every review item: slower on big campaigns' }, items, 'Approve/revoke counts'),\n el('button', { className: 'btn primary', disabled: !!C.busy, onclick: function () { runJobInto(C, '/api/certifications/run', { days: C.days, items: C.items }, renderCerts); } }, icon('play'), C.data ? 'Read again' : 'Read certifications')));\n if (C.busy) { w.appendChild(busyBox(C.busy)); return; }\n if (C.error) { w.appendChild(el('div', { className: 'error', text: C.error })); return; }\n var d = C.data;\n if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Are reviews on track?' }), 'Reads campaigns, every reviewer’s progress and their decisions. A certification admin’s token or sign-in sees all reviewers.')); return; }\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.active) }), el('span', { text: 'active campaigns' })),\n el('div', { className: 'bigstat' + (T.overdue ? ' lose' : '') }, el('b', { text: fmtNum(T.overdue) }), el('span', { text: 'past the deadline' })),\n el('div', { className: 'bigstat' + (T.atRisk ? ' lose' : '') }, el('b', { text: fmtNum(T.atRisk) }), el('span', { text: 'due within 7 days, under 80%' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.openDecisions) }), el('span', { text: 'decisions still open' })),\n el('div', { className: 'bigstat' }, el('b', { text: T.approvedInPeriod + T.revokedInPeriod ? Math.round(T.revokedInPeriod * 100 / (T.approvedInPeriod + T.revokedInPeriod)) + '%' : '—' }), el('span', { text: 'of decisions were revokes' }))));\n w.appendChild(section('Campaigns', d.campaigns.length, simpleTable(['Campaign', 'Type', 'Status', 'Deadline', 'Progress', ''], d.campaigns.map(function (c) {\n var flag = c.overdue ? el('span', { className: 'chg lose', text: 'Overdue' }) : c.atRisk ? el('span', { className: 'chg lose', text: 'At risk' }) : null;\n return [c.name, c.type, c.status, c.deadline ? c.deadline.slice(0, 10) + (c.status === 'ACTIVE' && c.daysLeft !== null ? ' (' + (c.daysLeft >= 0 ? c.daysLeft + ' days left' : -c.daysLeft + ' days late') + ')' : '') : null, progressBar(c.percent, c.overdue || c.atRisk), flag];\n }))));\n w.appendChild(section('Reviewers', d.reviewers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, el('button', { className: 'btn sm', onclick: function () { wnState().tab = 'reminders'; showPage('warnings'); } }, icon('clock'), 'Remind reviewers before the deadline'), downloads(C.job)),\n simpleTable(['Reviewer', 'Campaigns', 'Reviews', 'Decisions', 'Approved', 'Revoked', 'Approve %', 'Overdue reviews'], d.reviewers.map(function (r) {\n var pct = r.decisionsTotal ? Math.round(r.decisionsMade * 100 / r.decisionsTotal) : 0;\n return [r.name, r.campaigns.join(', '), r.certifications, r.decisionsTotal ? progressBar(pct, r.overdueOpen > 0) : null, r.approved, r.revoked, r.approveRate === null ? null : r.approveRate + '%', r.overdueOpen ? el('span', { className: 'chg lose', text: String(r.overdueOpen) }) : 0];\n })))));\n w.appendChild(section('Reviews that may be rubber-stamped', d.flags.length, d.flags.length ? el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'Everything approved and signed off very fast, or a large review with not a single revoke. A signal worth a conversation, not proof.' }),\n simpleTable(['Reviewer', 'Campaign', 'Review', 'Decisions', 'Why it stands out'], d.flags.map(function (f) { return [f.reviewer, f.campaign, f.certification, f.decisions, f.reason]; }))) : el('div', { className: 'muted', text: 'None found.' })));\n }\n\n // ---------- monthly report ----------\n state.mr = { month: '' };\n function renderMonthly() { renderInsights(); }\n function monthlyTab(w) {\n var M = state.mr;\n if (!M.data) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Building the report...'));\n api('/api/monthly' + (M.month ? '?month=' + M.month : '')).then(function (d) { M.data = d; M.month = d.month; renderMonthly(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n return;\n }\n var d = M.data;\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Month' }, (d.months.length ? d.months : [d.month]).map(function (m) { return el('option', { value: m, text: m }); }));\n sel.value = d.month;\n sel.addEventListener('change', function () { M.month = sel.value; M.data = null; renderMonthly(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { style: 'flex:1' }, el('b', { text: 'Monthly report: ' + d.monthLabel }), el('span', { className: 'muted', text: ' — from the instant checks recorded on this computer. Lower is better for every check.' })), sel, el('a', { className: 'btn primary', href: '/api/monthly/download?month=' + d.month + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download (open and print to PDF)')));\n w.appendChild(section('Highlights', null, el('ul', { style: 'margin:0;padding-left:20px' }, d.highlights.map(function (h) { return el('li', { style: 'margin:4px 0', text: h }); }))));\n w.appendChild(section('Daily checks during the month', null, simpleTable(['Check', 'First day', 'Last day', 'Change', 'Days checked', 'Days red / amber', 'Trend'], d.checks.map(function (c) {\n var ch = c.change === null ? null : el('span', { style: 'font-weight:600;color:' + (c.change < 0 ? 'var(--ok)' : c.change > 0 ? 'var(--danger)' : 'var(--text2)'), text: c.change === 0 ? 'no change' : (c.change > 0 ? '+' : '−') + fmtNum(Math.abs(c.change)) + (c.changePercent !== null ? ' (' + (c.changePercent > 0 ? '+' : '') + c.changePercent + '%)' : '') });\n var sp = el('span', { style: 'color:var(--accent)' }, sparkline(c.days.map(function (x) { return { value: x.value }; }), 140, 30));\n return [c.label, c.start === null ? null : fmtNum(c.start), c.end === null ? null : fmtNum(c.end), ch, c.daysChecked, c.daysRed + ' / ' + c.daysAmber, sp];\n }))));\n if (d.snapshot) w.appendChild(section('The tenant today', null, el('div', { className: 'bigstats', style: 'margin:0' }, d.snapshot.map(function (s) { return el('div', { className: 'bigstat' }, el('b', { text: s.count === null ? '—' : fmtNum(s.count) }), el('span', { text: s.label })); }))));\n }\n\n // ---------- ownership (a Lookup tab) ----------\n state.ow = { filter: '', owner: null };\n function renderOwnership(w) {\n var O = state.ow;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Who owns sources, roles, access profiles, entitlements, workflows and identity profiles, and what is owned by people who left. Reads every entitlement, so it takes a while on big tenants.' }),\n el('button', { className: 'btn primary', disabled: !!O.busy, onclick: function () { runJobInto(O, '/api/ownership/run', {}, renderLookup); } }, icon('play'), O.data ? 'Read again' : 'Read ownership')));\n if (O.busy) { w.appendChild(busyBox(O.busy)); return; }\n if (O.error) { w.appendChild(el('div', { className: 'error', text: O.error })); return; }\n var d = O.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var types = ['Source', 'Role', 'Access profile', 'Entitlement', 'Workflow', 'Identity profile'];\n w.appendChild(el('div', { className: 'bigstats' }, types.map(function (ty) {\n var total = d.totals[ty] || 0, un = d.unowned[ty] || 0;\n return el('div', { className: 'bigstat' + (un ? ' lose' : '') }, el('b', { text: fmtNum(un) }), el('span', { text: ty.toLowerCase() + 's without owner (of ' + fmtNum(total) + ')' }));\n })));\n var ownerWord = function (st) { return st === 'not found' ? 'no longer in ISC' : st; };\n var left = d.owners.filter(function (o) { return o.status !== 'active'; });\n w.appendChild(el('div', { className: 'banner ' + (d.orphaned.length ? 'bad' : 'ok') }, el('b', { text: d.orphaned.length ? fmtNum(d.orphaned.length) + ' objects are owned by ' + left.length + ' people who left or no longer exist' : 'Every owner is an active identity' }), el('span', { style: 'flex:1' }), downloads(O.job)));\n if (d.orphaned.length) w.appendChild(section('Owned by people who left (hand these over)', d.orphaned.length, simpleTable(['Type', 'Object', 'Source', 'Owner', 'Owner status'], d.orphaned.slice(0, 1000).map(function (x) { return [x.type, x.name, x.source, x.ownerName, el('span', { className: 'chg lose', text: ownerWord(x.ownerStatus) + (x.lifecycleState ? ' (' + x.lifecycleState + ')' : '') })]; }))));\n var f = el('input', { className: 'input', placeholder: 'Filter owners...', value: O.filter, style: 'max-width:280px' });\n var box = el('div');\n var draw = function () {\n var q = O.filter.toLowerCase();\n box.textContent = '';\n box.appendChild(simpleTable(['Owner', 'Status', 'Sources', 'Roles', 'Access profiles', 'Entitlements', 'Workflows', 'Identity profiles', 'Total'], d.owners.filter(function (o) { return !q || (o.name + ' ' + (o.email || '')).toLowerCase().indexOf(q) >= 0; }).slice(0, 500).map(function (o) {\n return [el('button', { className: 'btn link', style: 'padding:0', text: o.name, onclick: function () { O.owner = o.id; renderLookup(); } }), el('span', { className: 'chg ' + (o.status === 'active' ? 'gain' : 'lose'), text: ownerWord(o.status) }), o.counts['Source'] || 0, o.counts['Role'] || 0, o.counts['Access profile'] || 0, o.counts['Entitlement'] || 0, o.counts['Workflow'] || 0, o.counts['Identity profile'] || 0, o.total];\n })));\n };\n f.addEventListener('input', function () { O.filter = f.value; draw(); });\n w.appendChild(section('Owners', d.owners.length, el('div', {}, el('div', { style: 'margin-bottom:10px' }, f), box)));\n draw();\n if (O.owner) {\n var who = d.owners.filter(function (o) { return o.id === O.owner; })[0];\n var mine = d.objects.filter(function (x) { return x.ownerId === O.owner; });\n w.appendChild(section('Owned by ' + (who ? who.name : '?'), mine.length, simpleTable(['Type', 'Object', 'Source'], mine.slice(0, 2000).map(function (x) { return [x.type, x.name, x.source]; }))));\n }\n }\n\n // ---------- compare tenants (a Tenant tab) ----------\n state.cp = { kinds: null };\n function cmpKey(path) { return String(path).replace(/ \\(.*$/, '').replace(/\\[\\d+\\]/g, '[]'); }\n function cmpIgnore(P, kind, setting, on) {\n api('/api/compare/ignore', 'POST', { kind: kind, setting: setting, ignore: on }).then(function (r) {\n P.info.ignore = r.ignore;\n if (on && P.data) {\n // Apply now to what is on screen; the next Compare applies it to the results and the exports.\n P.data.kinds.forEach(function (k) {\n if (k.kind !== kind) return;\n var keep = [];\n k.different.forEach(function (x) { var left = x.differences.filter(function (y) { return cmpKey(y.path) !== setting; }); if (left.length) keep.push({ name: x.name, differences: left }); else k.same++; });\n k.different = keep;\n });\n }\n renderTenant();\n }, function (e) { toast(errorText(e)); });\n }\n function renderCompare2(w) {\n var P = state.cp;\n if (!P.info) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/compare').then(function (r) { P.info = r; if (!P.kinds) P.kinds = r.kinds.map(function (k) { return k.kind; }); renderTenant(); });\n return;\n }\n if (!P.info.other) {\n var base = el('input', { className: 'input', placeholder: 'production tenant, e.g. acme or https://acme.api.identitynow.com', autocomplete: 'off' });\n var cid = el('input', { className: 'input', autocomplete: 'off' });\n var sec = el('input', { className: 'input', type: 'password', autocomplete: 'off' });\n var msg = el('div');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Connect the other tenant' })),\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Compares ' + (P.info.tenant || 'this tenant') + ' with another tenant (for example sandbox with production) by object name. Read-only on both. The other tenant’s token is kept in memory only, never saved.' }),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Other tenant' }), base), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID (personal access token)' }), cid), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client secret' }), sec)),\n el('button', { className: 'btn primary', style: 'margin-top:14px', onclick: function () {\n msg.textContent = '';\n api('/api/compare/connect', 'POST', { baseUrl: base.value, clientId: cid.value, clientSecret: sec.value }).then(function (r) { sec.value = ''; P.info.other = r.tenant; renderTenant(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, 'Connect'), msg));\n return;\n }\n var boxes = el('div', { className: 'bar' }, P.info.kinds.map(function (k) {\n var c = el('input', { type: 'checkbox', checked: P.kinds.indexOf(k.kind) >= 0, 'aria-label': k.label });\n c.addEventListener('change', function () { P.kinds = P.kinds.filter(function (x) { return x !== k.kind; }); if (c.checked) P.kinds.push(k.kind); renderTenant(); });\n return el('label', { className: 'check' }, c, k.label);\n }));\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, 'Compare ', el('span', { className: 'pill blue', text: P.info.tenant }), ' with ', el('span', { className: 'pill blue', text: P.info.other })),\n el('button', { className: 'btn ghost sm', onclick: function () { api('/api/compare/disconnect', 'POST', {}).then(function () { P.info.other = null; P.data = null; renderTenant(); }); } }, 'Disconnect other tenant')),\n boxes,\n el('p', { className: 'muted small', text: '\"Where rules are used\" compares which sources, transforms, identity profiles, identity attributes and provisioning policies use each rule: a rule used in one tenant and not the other is a deployment gap. Connector rules are compared in full, code included.' }),\n (function () {\n var c = el('input', { type: 'checkbox', checked: !!P.cloudRuleCode, 'aria-describedby': 'cloud-rule-note' });\n c.addEventListener('change', function () { P.cloudRuleCode = c.checked; renderTenant(); });\n return el('div', { className: 'note', style: 'margin-top:10px' },\n el('label', { className: 'check', style: 'font-weight:600' }, c, 'Also compare cloud rule code'),\n el('div', { id: 'cloud-rule-note', className: 'small', style: 'margin-top:4px', text: 'ISC has no plain read for cloud rules. With this on, IdentityScope starts one SP-Config export job of rules in each tenant, waits for it and compares the code. The export reads configuration and changes nothing, but it is a job you will see in the tenant, and the API client needs SP-Config access (the sp:config:read or sp:config:manage scope). Off by default; not used by change history or the drift check.' }));\n })(),\n el('div', { className: 'bar', style: 'margin-top:12px' },\n el('button', { className: 'btn primary', disabled: !!P.busy || (!P.kinds.length && !P.cloudRuleCode), onclick: function () { runJobInto(P, '/api/compare/run', { kinds: P.kinds, cloudRuleCode: !!P.cloudRuleCode }, renderTenant); } }, icon('cols'), 'Compare'),\n el('button', { className: 'btn ghost sm', onclick: function () { P.kinds = P.info.kinds.map(function (k) { return k.kind; }); renderTenant(); } }, 'All'),\n el('button', { className: 'btn ghost sm', onclick: function () { P.kinds = []; renderTenant(); } }, 'None'))));\n if (P.busy) { w.appendChild(busyBox(P.busy)); return; }\n if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }\n var d = P.data;\n if (!d) return;\n w.appendChild(el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:10px' }, downloads(P.job)));\n w.appendChild(simpleTable(['Type', 'Only in ' + d.a, 'Only in ' + d.b, 'Different', 'Same'], d.kinds.map(function (k) {\n return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : k.onlyA.length, k.error ? null : k.onlyB.length, k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];\n })));\n var ignored = (P.info && P.info.ignore) || [];\n if (ignored.length) {\n w.appendChild(el('div', { className: 'note', style: 'margin:12px 0' }, el('b', { text: 'Ignored settings: ' }),\n el('span', {}, ignored.map(function (key) {\n var parts = key.split('|'), label = (P.info.kinds.filter(function (k) { return k.kind === parts[0]; })[0] || { label: parts[0] }).label;\n return el('span', { className: 'chip', style: 'display:inline-flex;gap:6px;align-items:center;margin:2px 6px 2px 0' }, label + ': ', el('code', { text: parts.slice(1).join('|') }),\n el('button', { className: 'linkbtn small', 'aria-label': 'Stop ignoring ' + parts.slice(1).join('|'), onclick: function () { cmpIgnore(P, parts[0], parts.slice(1).join('|'), false); } }, 'undo'));\n })),\n el('div', { className: 'small muted', text: 'Undo takes effect at the next Compare.' })));\n }\n d.kinds.forEach(function (k) {\n if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;\n var body = el('div');\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Only in ' + d.a + ': ' }), k.onlyA.join(', ')));\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Only in ' + d.b + ': ' }), k.onlyB.join(', ')));\n if (k.different.length > 1) {\n // Which settings differ most often: usually tenant-specific values (cluster, owner) worth ignoring.\n var counts = {};\n k.different.forEach(function (x) { var seen = {}; x.differences.forEach(function (y) { var key = cmpKey(y.path); if (!seen[key]) { seen[key] = 1; counts[key] = (counts[key] || 0) + 1; } }); });\n var top = Object.keys(counts).sort(function (a, b) { return counts[b] - counts[a]; }).slice(0, 8);\n body.appendChild(el('div', { className: 'note', style: 'margin:8px 0' }, el('b', { text: 'Most common differences: ' }),\n el('div', {}, top.map(function (key) {\n return el('div', { style: 'display:flex;gap:10px;align-items:center;margin:3px 0' }, el('code', { text: key }), el('span', { className: 'muted small', text: counts[key] + ' of ' + k.different.length }),\n el('button', { className: 'btn ghost sm', 'aria-label': 'Ignore ' + key + ' for ' + k.label, onclick: function () { cmpIgnore(P, k.kind, key, true); } }, 'Ignore'));\n })),\n el('div', { className: 'small muted', text: 'Ignore a setting that is meant to differ between tenants (for example a cluster or an owner). It is remembered on this computer for future comparisons.' })));\n }\n k.different.forEach(function (x) {\n body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' difference' + (x.differences.length > 1 ? 's' : '') + ')' }),\n simpleTable(['Setting', d.a, d.b], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));\n });\n w.appendChild(section(k.label, null, body));\n });\n }\n\n // ---------- Audit (Certifications, Separation of duties, Review coverage, Access outliers, Provisioning speed, Change history, Evidence pack) ----------\n state.au = { tab: 'certs' };\n function renderAudit() {\n var outer = $('certs');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#be185d;background:#fce8f1' }, icon('cert')),\n el('div', {}, el('h2', { text: 'Audit' }), el('p', { className: 'desc', text: 'Certifications, separation of duties, review coverage, access outliers, provisioning speed, configuration changes and a ready-made evidence pack for auditors. Read-only.' }))));\n groupedTabs(w, 'au', AU_GROUPS, AU_TABS, state.au.tab, function (id) { state.au.tab = id; renderAudit(); });\n if (state.au.tab === 'sod') renderSod(w);\n else if (state.au.tab === 'changes') renderChanges(w);\n else if (state.au.tab === 'evidence') renderEvidence(w);\n else if (state.au.tab === 'coverage') renderCoverage(w);\n else if (state.au.tab === 'outliers') renderOutliers(w);\n else if (state.au.tab === 'speed') renderSpeed(w);\n else if (state.au.tab === 'adminaccts') renderAdminAccounts(w);\n else if (state.au.tab === 'exceptions') renderExceptions(w);\n else if (state.au.tab === 'trail') renderRequestTrail(w);\n else if (state.au.tab === 'chain') renderApproverChain(w);\n else if (state.au.tab === 'leavertimes') renderLeaverTimes(w);\n else if (state.au.tab === 'attrhist') renderAttrHistory(w);\n else if (state.au.tab === 'owners') renderOwners(w);\n else if (state.au.tab === 'outmodel') renderOutsideModel(w);\n else if (state.au.tab === 'composition') renderComposition(w);\n else if (state.au.tab === 'reassigned') renderReassigned(w);\n else certsTab(w);\n }\n function moneyText(n, cur) { return n === null || n === undefined ? '—' : (cur ? cur + ' ' : '') + Number(n).toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 2 }); }\n function loadInsightSettings(then) {\n api('/api/insights/settings').then(function (s) { state.ins = s; then(); }).catch(function (e) { toast(errorText(e)); });\n }\n\n // separation of duties\n state.sd = {};\n function renderSod(w) {\n var S = state.sd;\n if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderAudit); return; }\n if (!S.rules) S.rules = clone(state.ins.sod || []);\n var msg = el('div');\n var list = el('div');\n var draw = function () {\n list.textContent = '';\n if (!S.rules.length) list.appendChild(el('div', { className: 'muted', style: 'margin-bottom:10px', text: 'No rules yet. Example: \"Create vendor\" and \"Approve payment\" should not be held by the same person.' }));\n S.rules.forEach(function (r, i) {\n var name = el('input', { className: 'input', value: r.name || '', placeholder: 'Rule name, e.g. Create and approve payments' });\n name.addEventListener('input', function () { r.name = name.value; });\n var desc = el('input', { className: 'input', value: r.description || '', placeholder: 'Why (optional), e.g. SOX control FIN-07' });\n desc.addEventListener('input', function () { r.description = desc.value; });\n list.appendChild(el('div', { className: 'card', style: 'margin-bottom:10px;padding:14px' },\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr auto;align-items:end' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Rule' }), name),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Reason' }), desc),\n el('button', { className: 'btn ghost sm', title: 'Remove rule', onclick: function () { S.rules.splice(i, 1); draw(); } }, icon('trash'))),\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr;margin-top:10px' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side A: any of' }), tokenInput({ value: r.sideA || [], placeholder: 'Access name, e.g. SF Admin (Salesforce)', onChange: function (v) { r.sideA = v; } })),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side B: any of' }), tokenInput({ value: r.sideB || [], placeholder: 'Access name, e.g. Approve Payments', onChange: function (v) { r.sideB = v; } })))));\n });\n };\n draw();\n w.appendChild(section('Rules', S.rules.length, el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'A person breaks a rule when they hold at least one item of side A and one of side B. Use the name of an entitlement, access profile or role as ISC shows it; add the source in brackets to be exact: \"Domain Admins (Active Directory)\". Matching ignores case.' }),\n list,\n el('div', { className: 'bar' },\n el('button', { className: 'btn', onclick: function () { S.rules.push({ name: '', sideA: [], sideB: [] }); draw(); } }, icon('plus'), 'Add rule'),\n el('button', { className: 'btn', onclick: function () {\n msg.textContent = '';\n api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); toast('Rules saved'); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save rules'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn primary', disabled: !!S.busy, onclick: function () {\n msg.textContent = '';\n api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); runJobInto(S, '/api/sod/run', {}, renderAudit); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('play'), S.data ? 'Check again' : 'Save and check')),\n msg)));\n if (S.busy) { w.appendChild(busyBox(S.busy)); return; }\n if (S.error) { w.appendChild(el('div', { className: 'error', text: S.error })); return; }\n var d = S.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'banner ' + (d.violations.length ? 'bad' : 'ok') }, el('b', { text: d.violations.length ? fmtNum(d.violations.length) + ' violation' + (d.violations.length > 1 ? 's' : '') : 'No violations' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' people checked' }), el('span', { style: 'flex:1' }), downloads(S.job)));\n w.appendChild(section('Per rule', null, simpleTable(['Rule', 'Reason', 'People'], d.rules.map(function (r) { return [r.name, r.description, r.violations ? el('span', { className: 'chg lose', text: String(r.violations) }) : 0]; }))));\n if (d.violations.length) w.appendChild(section('People who break a rule', d.violations.length, simpleTable(['Rule', 'Person', 'Username', 'Lifecycle state', 'Holds (side A)', 'Holds (side B)'], d.violations.slice(0, 2000).map(function (v) {\n return [v.rule, el('button', { className: 'btn link', style: 'padding:0', text: v.person, onclick: function () { openPerson(v.personId); } }), v.username, v.lifecycleState, v.heldA.join(', '), v.heldB.join(', ')];\n }))));\n }\n\n // configuration change history\n state.ch = {};\n function changeTable(d, labels) {\n var box = el('div');\n box.appendChild(simpleTable(['Type', labels[1], labels[0], 'Changed', 'Unchanged'], d.kinds.map(function (k) {\n return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : (k.onlyB.length ? el('span', { className: 'chg gain', text: String(k.onlyB.length) }) : 0), k.error ? null : (k.onlyA.length ? el('span', { className: 'chg lose', text: String(k.onlyA.length) }) : 0), k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];\n })));\n d.kinds.forEach(function (k) {\n if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;\n var body = el('div');\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: labels[1] + ': ' }), k.onlyB.join(', ')));\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: labels[0] + ': ' }), k.onlyA.join(', ')));\n k.different.forEach(function (x) {\n body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' change' + (x.differences.length > 1 ? 's' : '') + ')' }),\n simpleTable(['Setting', labels[2], labels[3]], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));\n });\n box.appendChild(section(k.label, null, body));\n });\n return box;\n }\n function renderChanges(w) {\n // What changed between two snapshots, then drift from the approved baseline (the release that went live).\n var top = el('div');\n w.appendChild(top);\n renderChangesBetween(top);\n var drift = el('div', { style: 'margin-top:26px' }, el('h3', { style: 'margin:0 0 8px', text: 'Drift from an approved baseline' }));\n w.appendChild(drift);\n renderDrift(drift);\n }\n function renderChangesBetween(w) {\n var H = state.ch;\n if (!H.days) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/changes').then(function (r) { H.days = r.days; H.from = r.days[1] || r.days[0] || ''; H.to = r.days[0] || ''; renderAudit(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n return;\n }\n var snapBtn = el('button', { className: 'btn' + (H.days.length ? '' : ' primary'), disabled: !!H.busy, onclick: function () {\n runJobInto(H, '/api/changes/snapshot', {}, function () { if (!H.busy && !H.error) { H.days = null; H.diff = null; } renderAudit(); });\n } }, icon('save'), 'Take a snapshot now');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'A snapshot keeps the settings of sources, transforms, identity profiles, roles, access profiles and workflows on this computer (secrets hidden). Scheduled instant checks save one every day by themselves. Compare two days to see what changed.' }), snapBtn));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) w.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.days.length < 2) {\n w.appendChild(el('div', { className: 'empty' }, el('b', { text: H.days.length ? 'One snapshot so far (' + H.days[0] + ')' : 'No snapshots yet' }), 'Take a snapshot now and another one later (or schedule the instant check daily); then pick two days to compare.'));\n return;\n }\n var mk = function (v, set, label) { var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, H.days.map(function (d) { return el('option', { value: d, text: d }); })); s.value = v; s.addEventListener('change', function () { set(s.value); }); return s; };\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'bar' }, el('span', { text: 'What changed from' }), mk(H.from, function (v) { H.from = v; }, 'From snapshot'), el('span', { text: 'to' }), mk(H.to, function (v) { H.to = v; }, 'To snapshot'),\n el('button', { className: 'btn primary', onclick: function () {\n H.diff = 'loading'; renderAudit();\n api('/api/changes/diff?from=' + H.from + '&to=' + H.to).then(function (r) { H.diff = r; renderAudit(); }).catch(function (e) { H.diff = null; H.error = errorText(e); renderAudit(); });\n } }, icon('cols'), 'Show changes'),\n el('span', { className: 'muted small', text: H.days.length + ' snapshots kept' }))));\n if (H.diff === 'loading') { w.appendChild(busyBox('Comparing...')); return; }\n if (H.diff) {\n var n = H.diff.kinds.reduce(function (s, k) { return s + k.onlyA.length + k.onlyB.length + k.different.length; }, 0);\n w.appendChild(el('div', { className: 'banner ' + (n ? 'warn' : 'ok') }, el('b', { text: n ? fmtNum(n) + ' change' + (n > 1 ? 's' : '') + ' from ' + H.diff.from + ' to ' + H.diff.to : 'Nothing changed from ' + H.diff.from + ' to ' + H.diff.to })));\n w.appendChild(changeTable(H.diff, ['Removed', 'Added', H.diff.from, H.diff.to]));\n }\n }\n\n // evidence pack\n state.ev = { days: 365 };\n function renderEvidence(w) {\n var E = state.ev;\n if (!E.sections) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/evidence').then(function (r) { E.sections = r.sections; E.chosen = r.sections.map(function (s) { return s.id; }); renderAudit(); });\n return;\n }\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year'], [730, 'Last 2 years']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(E.days);\n period.addEventListener('change', function () { E.days = Number(period.value); });\n w.appendChild(section('What goes into the pack', null, el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'One zip for your auditors: an Excel file per part, a README saying when, by whom and from which tenant it was produced, and SHA-256 fingerprints (SHA256SUMS.txt) so they can check nothing was changed afterwards. Nothing is sent anywhere; you download it.' }),\n el('div', { className: 'checklist' }, E.sections.map(function (s) {\n var c = el('input', { type: 'checkbox', checked: E.chosen.indexOf(s.id) >= 0 });\n c.addEventListener('change', function () { E.chosen = E.chosen.filter(function (x) { return x !== s.id; }); if (c.checked) E.chosen.push(s.id); });\n return el('label', { className: 'cl-item' }, c, el('span', {}, el('b', { text: s.label }), el('span', { className: 'muted small', text: ' — ' + s.description })));\n })),\n el('div', { className: 'bar', style: 'margin-top:12px' }, el('span', { text: 'Period for leavers and requests' }), period, el('span', { style: 'flex:1' }),\n el('button', { className: 'btn primary', disabled: !!E.busy, onclick: function () { runJobInto(E, '/api/evidence/run', { sections: E.chosen, days: E.days }, renderAudit); } }, icon('play'), 'Build the pack')))));\n if (E.busy) { w.appendChild(busyBox(E.busy)); return; }\n if (E.error) { w.appendChild(el('div', { className: 'error', text: E.error })); return; }\n var d = E.data;\n if (!d) return;\n var bad = d.files.filter(function (f) { return f.error; }).length;\n w.appendChild(el('div', { className: 'banner ' + (bad ? 'warn' : 'ok') }, el('b', { text: (d.files.length - bad) + ' of ' + d.files.length + ' parts ready' }), el('span', { className: 'muted', text: d.fileName }), el('span', { style: 'flex:1' }),\n el('a', { className: 'btn primary sm', href: '/api/evidence/' + E.job + '/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download zip')));\n w.appendChild(section('Contents', d.files.length, simpleTable(['Part', 'File', 'Rows', 'SHA-256 fingerprint'], d.files.map(function (f) {\n return [f.section, f.error ? el('span', { className: 'chg lose', text: 'not included' }) : f.name, f.rows === null ? null : fmtNum(f.rows), f.error ? f.error : el('code', { className: 'small', text: f.sha256.slice(0, 16) + '…' })];\n }))));\n }\n\n // ---------- Insights (Monthly report, License reclaim, Access requests) ----------\n state.inz = { tab: 'monthly' };\n function renderInsights() {\n var outer = $('monthly');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0e7c66;background:#e3f5f0' }, icon('sigma')),\n el('div', {}, el('h2', { text: 'Insights' }), el('p', { className: 'desc', text: 'The monthly report for management, licenses you could reclaim, and how access requests flow. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['monthly', 'Monthly report', 'file'], ['reclaim', 'License reclaim', 'down'], ['requests', 'Access requests', 'inbox']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.inz.tab === t[0] ? ' active' : ''), onclick: function () { state.inz.tab = t[0]; if (t[0] === 'monthly') state.mr.data = null; renderInsights(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.inz.tab === 'reclaim') renderReclaim(w);\n else if (state.inz.tab === 'requests') renderRequests(w);\n else monthlyTab(w);\n }\n\n // license reclaim\n state.rc = {};\n function renderReclaim(w) {\n var R = state.rc;\n if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderInsights); return; }\n var cfg = state.ins.reclaim || {};\n if (!R.form) R.form = { dormantDays: cfg.dormantDays || 90, currency: cfg.currency || '', leaverStates: (cfg.leaverStates || ['inactive', 'terminated']).slice(), sources: clone(cfg.sources || {}) };\n var F = R.form;\n var sources = R.sources;\n if (!sources) loadPick('sources').then(function (list) { R.sources = list; if (state.page === 'monthly' && state.inz.tab === 'reclaim') renderInsights(); }).catch(function (e) { toast(errorText(e)); });\n var msg = el('div');\n var days = el('input', { className: 'input', type: 'number', min: '7', value: String(F.dormantDays), style: 'width:100px', 'aria-label': 'Dormant after (days)' });\n days.addEventListener('input', function () { F.dormantDays = Number(days.value); });\n var cur = el('input', { className: 'input', value: F.currency, placeholder: 'USD', style: 'width:90px', 'aria-label': 'Currency' });\n cur.addEventListener('input', function () { F.currency = cur.value; });\n var rows = (sources || []).map(function (s) {\n var one = F.sources[s.label] || {};\n var cost = el('input', { className: 'input', type: 'number', min: '0', step: '0.01', 'aria-label': 'Cost per account per month for ' + s.label, value: one.cost === undefined ? '' : String(one.cost), placeholder: 'e.g. 12.50', style: 'width:120px' });\n cost.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].cost = cost.value === '' ? undefined : Number(cost.value); });\n var ll = el('input', { className: 'input', 'aria-label': 'Last login attribute for ' + s.label, value: one.lastLogin || '', placeholder: s.hint && /active directory/i.test(s.hint) ? 'lastLogonTimestamp' : 'attribute name', style: 'width:220px' });\n ll.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].lastLogin = ll.value; });\n return [s.label, s.hint, cost, ll];\n });\n w.appendChild(el('details', { className: 'card adv', open: !Object.keys(cfg.sources || {}).length || null }, el('summary', { style: 'font-weight:600', text: 'Settings: cost per account and sign-in dates' }),\n el('p', { className: 'muted small', text: 'Cost: what one account on the application costs per month (license or subscription), to estimate savings. Sign-in attribute: the account attribute that holds the last sign-in date, for example lastLogonTimestamp for Active Directory. It must be in the source’s account schema in ISC. Leave both empty for sources you do not pay for.' }),\n el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('span', { text: 'Dormant after' }), days, el('span', { text: 'days without sign-in. Currency' }), cur,\n el('span', { text: 'People have left when lifecycle state is' }), tokenInput({ value: F.leaverStates, onChange: function (v) { F.leaverStates = v; } })),\n sources ? simpleTable(['Source', 'Type', 'Monthly cost per account', 'Sign-in date attribute'], rows) : el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading sources...'),\n el('div', { className: 'bar', style: 'margin-top:10px' }, el('button', { className: 'btn', onclick: function () {\n msg.textContent = '';\n api('/api/reclaim/settings', 'PUT', F).then(function () { return loadInsightSettings(function () { R.form = null; toast('Settings saved'); renderInsights(); }); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save settings')), msg));\n w.appendChild(el('div', { className: 'bar', style: 'margin:14px 0' }, el('span', { className: 'muted', style: 'flex:1', text: 'Finds enabled accounts of people who left and accounts nobody signed in with for a long time, so licenses can be taken back. Disabling them is up to you in ISC.' }),\n el('button', { className: 'btn primary', disabled: !!R.busy, onclick: function () { runJobInto(R, '/api/reclaim/run', {}, renderInsights); } }, icon('play'), R.data ? 'Look again' : 'Find licenses to reclaim')));\n if (R.busy) { w.appendChild(busyBox(R.busy)); return; }\n if (R.error) { w.appendChild(el('div', { className: 'error', text: R.error })); return; }\n var d = R.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' + (T.accounts ? ' lose' : '') }, el('b', { text: fmtNum(T.accounts) }), el('span', { text: 'accounts to reclaim' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.leaver) }), el('span', { text: 'held by people who left' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.dormant) }), el('span', { text: 'no sign-in for ' + d.dormantDays + '+ days' })),\n el('div', { className: 'bigstat' + (T.monthly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.monthly, d.currency) : '—' }), el('span', { text: 'possible saving per month' })),\n el('div', { className: 'bigstat' + (T.yearly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.yearly, d.currency) : '—' }), el('span', { text: 'per year' }))));\n w.appendChild(section('By application', d.sources.length, simpleTable(['Source', 'People who left', 'Dormant', 'Cost per account', 'Per month', 'Per year'], d.sources.map(function (s) {\n return [el('button', { className: 'btn link', style: 'padding:0', text: s.source, onclick: function () { R.only = R.only === s.source ? null : s.source; renderInsights(); } }), s.leaver, s.dormant, moneyText(s.costPerAccount, d.currency), moneyText(s.monthly, d.currency), moneyText(s.yearly, d.currency)];\n }))));\n var list = d.rows.filter(function (r) { return !R.only || r.source === R.only; });\n w.appendChild(section(R.only ? 'Accounts on ' + R.only : 'Accounts', list.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, R.only ? el('button', { className: 'btn ghost sm', onclick: function () { R.only = null; renderInsights(); } }, 'Show all') : null, downloads(R.job)),\n simpleTable(['Source', 'Account', 'Person', 'Why', 'Last sign-in', 'Privileged'], list.slice(0, 2000).map(function (r) {\n return [r.source, r.account, r.person, el('span', { className: 'chg ' + (r.reason === 'Person has left' ? 'lose' : 'off'), text: r.reason + (r.lifecycleState && r.reason === 'Person has left' ? ' (' + r.lifecycleState + ')' : '') }), r.lastLogin ? r.lastLogin.slice(0, 10) + ' (' + r.daysSince + ' days)' : null, yesNo(r.privileged, true)];\n })))));\n }\n\n // access requests\n state.rq = { days: 90 };\n function renderRequests(w) {\n var Q = state.rq;\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[30, 'Last 30 days'], [90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(Q.days);\n period.addEventListener('change', function () { Q.days = Number(period.value); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'How long requests wait for approval, which approvers are slow or have requests waiting, and which access is requested and rejected most. An admin sign-in sees everyone’s requests.' }), period,\n el('button', { className: 'btn primary', disabled: !!Q.busy, onclick: function () { runJobInto(Q, '/api/requests/run', { days: Q.days }, renderInsights); } }, icon('play'), Q.data ? 'Read again' : 'Read requests')));\n if (Q.busy) { w.appendChild(busyBox(Q.busy)); return; }\n if (Q.error) { w.appendChild(el('div', { className: 'error', text: Q.error })); return; }\n var d = Q.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n var hrs = function (h) { return h === null ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; };\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.requests) }), el('span', { text: 'requests in ' + d.days + ' days' })),\n el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToApprove) }), el('span', { text: 'typical wait for an approval' })),\n el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToComplete) }), el('span', { text: 'typical time to get the access' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.rejected) }), el('span', { text: 'rejected' })),\n el('div', { className: 'bigstat' + (T.open ? ' lose' : '') }, el('b', { text: fmtNum(T.open) }), el('span', { text: 'still open' })),\n el('div', { className: 'bigstat' + (T.failed ? ' lose' : '') }, el('b', { text: fmtNum(T.failed) }), el('span', { text: 'failed' }))));\n if (d.weekly.length > 1) w.appendChild(section('Requests per week', null, el('div', { style: 'color:var(--accent)' }, sparkline(d.weekly.map(function (x) { return { value: x.requests }; }), 900, 60), el('div', { className: 'muted small', text: d.weekly[0].week + ' to ' + d.weekly[d.weekly.length - 1].week }))));\n w.appendChild(section('Approvers', d.approvers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(Q.job)),\n simpleTable(['Approver', 'Decisions', 'Approved', 'Rejected', 'Typical time to decide', 'Waiting now', 'Oldest waiting'], d.approvers.map(function (a) {\n return [a.name, a.decisions, a.approved, a.rejected, hrs(a.medianHours), a.pending ? el('span', { className: 'chg lose', text: String(a.pending) }) : 0, a.oldestPendingDays === null ? null : a.oldestPendingDays + ' days'];\n })))));\n w.appendChild(section('Most requested access', d.items.length, simpleTable(['Access', 'Type', 'Requests', 'Completed', 'Rejected', 'Reject rate'], d.items.slice(0, 100).map(function (i) {\n return [i.name, i.type, i.requests, i.completed, i.rejected, i.rejectRate === null ? null : (i.rejectRate >= 50 && i.rejected > 1 ? el('span', { className: 'chg lose', text: i.rejectRate + '%' }) : i.rejectRate + '%')];\n }))));\n }\n\n // ---------- role mining (a Role tools tab) ----------\n state.mn = { attribute: 'department', minGroup: 5, minShare: 80 };\n function renderMining(w) {\n var M = state.mn;\n var attrs = identityAttrs();\n var names = attrs.map(function (a) { return a.name; });\n if (names.indexOf(M.attribute) < 0) names.unshift(M.attribute);\n var attr = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Group people by' }, names.map(function (n) { return el('option', { value: n, text: n }); }));\n attr.value = M.attribute;\n attr.addEventListener('change', function () { M.attribute = attr.value; });\n var minG = el('input', { className: 'input', type: 'number', min: '1', value: String(M.minGroup), style: 'width:80px', 'aria-label': 'Smallest group size' });\n minG.addEventListener('input', function () { M.minGroup = Number(minG.value); });\n var share = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Held by at least' }, [60, 70, 80, 90, 100].map(function (n) { return el('option', { value: String(n), text: n + '%' }); }));\n share.value = String(M.minShare);\n share.addEventListener('change', function () { M.minShare = Number(share.value); });\n w.appendChild(el('section', { className: 'card' },\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Groups people by an identity attribute (department, job title, location...) and lists the entitlements most of each group already hold. Those are candidates for a birthright role with that attribute as membership criteria. Items an existing role already gives are marked.' }),\n el('div', { className: 'bar' }, el('span', { text: 'Group people by' }), attr, el('span', { text: 'groups of at least' }), minG, el('span', { text: 'people, access held by at least' }), share,\n el('button', { className: 'btn primary', disabled: !!M.busy, onclick: function () { runJobInto(M, '/api/mining/run', { attribute: M.attribute, minGroup: M.minGroup, minShare: M.minShare }, renderRoles); } }, icon('play'), 'Find candidate roles'))));\n if (M.busy) { w.appendChild(busyBox(M.busy)); return; }\n if (M.error) { w.appendChild(el('div', { className: 'error', text: M.error })); return; }\n var d = M.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var fresh = d.candidates.filter(function (c) { return c.newItems > 0; }).length;\n w.appendChild(el('div', { className: 'banner ' + (fresh ? 'warn' : 'ok') }, el('b', { text: fresh ? fresh + ' group' + (fresh > 1 ? 's have' : ' has') + ' common access no role gives yet' : 'No new candidate roles' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' active people in ' + fmtNum(d.groups) + ' groups' }), el('span', { style: 'flex:1' }), downloads(M.job)));\n d.candidates.slice(0, 60).forEach(function (c) {\n w.appendChild(section(d.attribute + ' = ' + c.value, fmtNum(c.members) + (c.members === 1 ? ' person' : ' people'), el('div', {},\n simpleTable(['Entitlement', 'Source', 'Held by', 'Already in a role'], c.items.map(function (i) {\n return [i.name, i.source, i.holders + ' (' + i.share + '%)', i.covered ? el('span', { className: 'chg gain', text: 'Yes' }) : el('span', { className: 'chg lose', text: 'No' })];\n })),\n c.newItems ? el('p', { className: 'muted small', text: 'Candidate role: members where ' + d.attribute + ' is \"' + c.value + '\", with the ' + c.newItems + ' item' + (c.newItems > 1 ? 's' : '') + ' marked No. Check it first with \"Preview a role change\".' }) : null)));\n });\n }\n\n // ---------- share reports (report packs) ----------\n function sharePanel() {\n var m = $('main');\n m.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:980px' });\n m.appendChild(w);\n pageHead(w, 'copy', '#334155', '#eef1f5', 'Share reports', 'Export reports to one file and import packs from colleagues or other companies. A pack holds report definitions only, never data or credentials.');\n var mine = state.reports.filter(function (r) { return r.custom; });\n var chosen = mine.map(function (r) { return r.definition.id; });\n var exportList = el('div', { className: 'checklist' }, (mine.length ? mine : state.reports.slice(0, 0)).map(function (r) {\n var c = el('input', { type: 'checkbox', checked: true });\n c.addEventListener('change', function () { chosen = chosen.filter(function (x) { return x !== r.definition.id; }); if (c.checked) chosen.push(r.definition.id); });\n return el('label', { className: 'cl-item' }, c, el('span', { text: r.definition.name + ' (' + r.definition.id + ')' }));\n }));\n w.appendChild(section('Export my reports', mine.length, mine.length ? el('div', {}, exportList, el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {\n if (!chosen.length) { toast('Choose at least one report'); return; }\n var a = el('a', { href: '/api/packs/download?ids=' + encodeURIComponent(chosen.join(',')) + '&k=' + encodeURIComponent(KEY), download: '' });\n document.body.appendChild(a); a.click(); a.remove();\n } }, icon('download'), 'Download pack')) : el('div', { className: 'muted', text: 'You have no reports of your own yet. Use New report or Customize on a ready-made report.' })));\n var box = el('div');\n var file = el('input', { type: 'file', accept: '.json,application/json' });\n file.addEventListener('change', function () {\n var f = file.files && file.files[0];\n if (!f) return;\n if (f.size > 1500000) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: 'The file is too large for a report pack.' })); return; }\n f.text().then(function (text) {\n return api('/api/packs/preview', 'POST', { text: text }).then(function (p) {\n box.textContent = '';\n var pick = p.entries.filter(function (e) { return e.status === 'new' || e.status === 'replaces yours'; }).map(function (e) { return e.id; });\n box.appendChild(simpleTable(['', 'Report', 'ID', 'What happens'], p.entries.map(function (e) {\n var ok = e.status === 'new' || e.status === 'replaces yours';\n var c = el('input', { type: 'checkbox', checked: ok, disabled: !ok });\n c.addEventListener('change', function () { pick = pick.filter(function (x) { return x !== e.id; }); if (c.checked) pick.push(e.id); });\n var what = e.status === 'new' ? el('span', { className: 'chg gain', text: 'Added' }) : e.status === 'replaces yours' ? el('span', { className: 'chg lose', text: 'Replaces your report with this ID' }) : e.status === 'built in' ? el('span', { className: 'chg off', text: 'Skipped: same ID as a ready-made report' }) : el('span', { className: 'chg lose', text: 'Skipped: ' + e.problems.join('; ') });\n return [c, e.name, e.id, what];\n })));\n box.appendChild(el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {\n api('/api/packs/import', 'POST', { text: text, ids: pick }).then(function (r) { toast(r.saved.length + ' report' + (r.saved.length === 1 ? '' : 's') + ' added'); loadLibrary(); }).catch(function (e) { box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('plus'), 'Add the chosen reports'));\n });\n }).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n });\n w.appendChild(section('Import a pack', null, el('div', {}, el('p', { className: 'muted small', style: 'margin-top:0', text: 'Choose a .json pack file. You see every report before anything is added. Ready-made reports are never replaced.' }), file, box)));\n }\n\n // ---------- partner overview: all customer tenants ----------\n state.pt = { only: false, form: null, sel: null };\n var ST_WORD = { ok: 'OK', warn: 'Attention', bad: 'Problem', error: 'Could not check', off: 'Off' };\n var ST_CLS = { ok: 'ok', warn: 'warn', bad: 'bad', error: 'err', off: 'off' };\n function showPartner() {\n state.page = 'partner';\n $('connect').classList.add('hidden');\n $('app').classList.add('hidden');\n ['schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.add('hidden'); });\n ['nav-reports', 'nav-schedules', 'nav-roles', 'nav-checks', 'nav-lookup', 'nav-tenant', 'nav-build', 'nav-certs', 'nav-monthly', 'nav-warnings', 'nav-nerm', 'nav-logs'].forEach(function (n) { $(n).classList.remove('active'); });\n $('partner').classList.remove('hidden');\n $('btn-help').classList.remove('hidden');\n renderPartner();\n }\n function hidePartner() { $('partner').classList.add('hidden'); }\n function loadPartner() {\n return api('/api/tenants').then(function (d) { state.pt.data = d; state.pt.count = d.tenants.length; $('btn-partner-nav').classList.toggle('hidden', !d.tenants.length || $('nav').classList.contains('hidden')); return d; });\n }\n function renderPartner() {\n var P = state.pt;\n var outer = $('partner');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1500px' });\n outer.appendChild(w);\n var back = $('nav').classList.contains('hidden')\n ? el('button', { className: 'btn', onclick: function () { hidePartner(); api('/api/state').then(showConnect); } }, icon('logout'), 'Back to sign-in')\n : el('button', { className: 'btn', onclick: function () { hidePartner(); showPage('reports'); } }, 'Back to ' + ($('tenant').textContent || 'the tenant'));\n pageHead(w, 'db', '#0e7c66', '#e3f5f0', 'All tenants', 'The instant check of all your tenants in one place: sandbox, QA and production of one company, or the tenants of every customer a partner looks after. Read-only: each tenant uses its own credentials, kept only on this computer.', back);\n if (!P.data) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadPartner().then(renderPartner).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }\n var d = P.data;\n var R = state.ptRun;\n var runBtn = el('button', { className: 'btn primary', disabled: !!R.busy || !d.tenants.length, onclick: function () { partnerRun({}); } }, icon('play'), d.lastRun ? 'Check all again' : 'Check all tenants');\n var only = el('input', { type: 'checkbox', checked: P.only });\n only.addEventListener('change', function () { P.only = only.checked; renderPartner(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('button', { className: 'btn', onclick: function () { P.form = { isNew: true }; renderPartner(); } }, icon('plus'), 'Add a tenant'),\n el('label', { className: 'inline small' }, only, 'Only tenants that need attention'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn', 'aria-expanded': String(!!P.pick), onclick: function () { P.pick = P.pick ? null : d.checks.map(function (c) { return c.id; }); renderPartner(); } }, icon('cols'), 'Checks (' + d.checks.length + ' of ' + (d.allChecks || d.checks).length + ')'), runBtn));\n if (P.pick) {\n var boxes = el('div', { style: 'display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:6px 18px;margin:10px 0' });\n (d.allChecks || []).forEach(function (c) {\n var cb = el('input', { type: 'checkbox', checked: P.pick.indexOf(c.id) >= 0 });\n cb.addEventListener('change', function () { P.pick = cb.checked ? P.pick.concat([c.id]) : P.pick.filter(function (x) { return x !== c.id; }); });\n boxes.appendChild(el('label', { className: 'inline small' }, cb, c.label, c.quick ? null : el('span', { className: 'muted', text: ' (reads every identity or account; slow on large tenants)' })));\n });\n var savePick = function (ids) {\n api('/api/tenants/checks', 'PUT', { ids: ids }).then(function () { P.pick = null; P.data = null; renderPartner(); }, function (e) { toast(errorText(e)); });\n };\n w.appendChild(el('div', { className: 'card', style: 'padding:14px 16px' },\n el('b', { text: 'Checks on this page' }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'The quick checks show whether each tenant is running. The others stay on each tenant\\u2019s own Instant check; tick one here only if you want it across all tenants. This also applies to the scheduled All tenants summary.' }),\n boxes,\n el('div', { className: 'bar' }, el('button', { className: 'btn primary', onclick: function () { savePick(P.pick); } }, 'Save'),\n el('button', { className: 'btn', onclick: function () { savePick((d.allChecks || []).filter(function (c) { return c.quick; }).map(function (c) { return c.id; })); } }, 'Back to the quick checks'),\n el('button', { className: 'btn', onclick: function () { P.pick = null; renderPartner(); } }, 'Cancel'))));\n }\n if (P.form) w.appendChild(partnerForm(P));\n if (R.busy) w.appendChild(busyBox(R.busy));\n if (R.error) w.appendChild(el('div', { className: 'error', text: R.error }));\n if (!d.tenants.length) {\n w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No tenants yet' }), 'Add each tenant (your sandbox, QA and production, or each customer) with a read-only personal access token or API client from that tenant. Then check all of them with one click, or schedule \"All tenants\" daily for one summary by email or Teams.'));\n return;\n }\n var run = P.data.lastRun;\n var byId = {};\n if (run) run.results.forEach(function (r) { byId[r.id] = r; });\n var known = {};\n d.lastKnown.forEach(function (k) { known[k.id] = k; });\n if (run) w.appendChild(el('div', { className: 'banner ' + (/problem/.test(run.headline) ? 'bad' : /look at/.test(run.headline) ? 'warn' : 'ok') }, el('b', { text: run.headline }), el('span', { className: 'muted', text: 'checked ' + fmtWhen(run.at) }), el('span', { style: 'flex:1' }), R.job && R.data ? downloads(R.job) : null));\n else w.appendChild(el('div', { className: 'note', text: 'Showing the last results kept on this computer. Check all tenants for fresh numbers.' }));\n var order = { error: 0, bad: 1, warn: 2, ok: 3, off: 4, none: 5 };\n var rows = d.tenants.map(function (t) {\n var r = byId[t.id];\n var k = known[t.id] || { status: {}, values: {} };\n var overall = r ? r.status : worstOf(d.checks.map(function (c) { return k.status[c.id]; }).filter(Boolean));\n return { t: t, r: r, k: k, overall: overall || 'none' };\n }).filter(function (x) { return !P.only || x.overall === 'warn' || x.overall === 'bad' || x.overall === 'error'; })\n .sort(function (a, b) { return order[a.overall] - order[b.overall] || a.t.name.localeCompare(b.t.name); });\n var table = el('table', { className: 'grid-table ptable' });\n var head = el('tr', {}, el('th', { text: 'Tenant' }), el('th', { text: 'Overall' }), d.checks.map(function (c) { return el('th', { className: 'pcol', title: c.label, text: c.label }); }), el('th', {}, el('span', { className: 'sr-only', text: 'Actions' })));\n table.appendChild(el('thead', {}, head));\n var body = el('tbody');\n rows.forEach(function (x) {\n var t = x.t;\n var tr = el('tr', { className: P.sel && P.sel.id === t.id ? 'sel' : '' });\n tr.appendChild(el('td', {}, el('b', { text: t.name }), el('div', { className: 'muted small', text: new URL(t.baseUrl).host }), t.hasSecret ? null : el('div', { className: 'error small', text: 'No secret saved' }), tokenNote(x.r)));\n tr.appendChild(el('td', {}, x.overall === 'none' ? el('span', { className: 'muted small', text: 'Not checked yet' }) : el('span', { className: 'pstat ' + ST_CLS[x.overall], text: x.r && x.r.error ? 'Could not check' : ST_WORD[x.overall] })));\n if (x.r && x.r.error) {\n tr.appendChild(el('td', { colSpan: String(d.checks.length), className: 'small' }, el('span', { className: 'error', style: 'display:inline-block;margin:0', text: x.r.error })));\n } else d.checks.forEach(function (c) {\n var res = x.r ? x.r.results.filter(function (y) { return y.id === c.id; })[0] : null;\n var st = res ? res.status : x.k.status[c.id];\n var v = res ? res.value : x.k.values[c.id];\n var cell = el('td', { className: 'pcell' });\n if (st && st !== 'off') {\n var b = el('button', { className: 'pval ' + ST_CLS[st], title: c.label + ': ' + (res ? res.summary : ST_WORD[st]), text: st === 'error' ? '!' : (v === null || v === undefined ? '—' : fmtNum(v)), onclick: function () { P.sel = { id: t.id, check: c.id }; renderPartner(); } });\n if (res && x.r.worse.indexOf(c.id) >= 0) b.appendChild(el('span', { className: 'pnew', text: 'new' }));\n cell.appendChild(b);\n } else cell.appendChild(el('span', { className: 'muted', text: st === 'off' ? 'off' : '' }));\n tr.appendChild(cell);\n });\n tr.appendChild(el('td', { style: 'white-space:nowrap' },\n el('button', { className: 'btn sm primary', title: 'Open this tenant with all pages', disabled: !t.hasSecret, onclick: function () { openTenant(t); } }, 'Open'),\n el('button', { className: 'btn sm ghost', title: 'Edit', onclick: function () { P.form = { id: t.id, name: t.name, baseUrl: t.baseUrl, clientId: t.clientId, notes: t.notes || '' }; renderPartner(); } }, icon('sliders')),\n el('button', { className: 'btn sm ghost', title: 'Check only this tenant', disabled: !!R.busy, onclick: function () { partnerRun({ ids: [t.id] }); } }, icon('play'))));\n body.appendChild(tr);\n if (P.sel && P.sel.id === t.id) {\n var res = x.r ? x.r.results.filter(function (y) { return y.id === P.sel.check; })[0] : null;\n var c = d.checks.filter(function (y) { return y.id === P.sel.check; })[0];\n var inner = el('div', { className: 'pdetail' }, el('b', { text: t.name + ' · ' + (c ? c.label : '') }));\n if (res) {\n inner.appendChild(el('div', { text: res.summary }));\n if (res.error) inner.appendChild(el('div', { className: 'error small', text: res.error }));\n if (res.top && res.top.length) inner.appendChild(el('div', { className: 'muted small', text: res.top.slice(0, 5).map(function (y) { return y.label + ' (' + y.count + ')'; }).join(' · ') }));\n if (FIX && FIX[res.id]) inner.appendChild(el('div', { className: 'small', style: 'margin-top:6px' }, el('b', { text: 'How to fix: ' }), FIX[res.id][0]));\n } else inner.appendChild(el('div', { className: 'muted', text: 'From the last check kept on this computer. Check this tenant for details.' }));\n var go = CHECK_GOTO[P.sel.check];\n inner.appendChild(el('div', { className: 'bar', style: 'margin-top:8px' },\n el('button', { className: 'btn sm primary', disabled: !t.hasSecret, title: go ? 'Opens ' + t.name + ' on ' + go[2] : 'Opens ' + t.name, onclick: function () { openTenant(t, null, P.sel.check); } }, icon('play'), go ? 'Open ' + go[2] : 'Open in this tenant'),\n el('button', { className: 'btn sm ghost', onclick: function () { P.sel = null; renderPartner(); } }, 'Close')));\n body.appendChild(el('tr', {}, el('td', { colSpan: String(d.checks.length + 3) }, inner)));\n }\n });\n table.appendChild(body);\n w.appendChild(el('div', { className: 'card', style: 'padding:0;overflow-x:auto' }, table));\n w.appendChild(el('p', { className: 'muted small', text: 'Click a number for details and a link to the report or page behind it. \"new\" means new or worse since that tenant\\'s previous check. Limits are the ones set on the Instant check page. Schedule \"All tenants\" on the Schedules page for one daily summary of every tenant.' }));\n }\n state.ptRun = {};\n function partnerRun(body) {\n runJobInto(state.ptRun, '/api/tenants/run', body, function () {\n if (state.ptRun.data && state.pt.data) state.pt.data.lastRun = state.ptRun.data;\n if (state.page === 'partner') renderPartner();\n });\n }\n function worstOf(list) {\n var rank = { error: 4, bad: 3, warn: 2, ok: 1, off: 0 };\n var best = null;\n list.forEach(function (s) { if (s && (best === null || rank[s] > rank[best])) best = s; });\n return best;\n }\n function fmtWhen(iso) { try { return new Date(iso).toLocaleString(); } catch (e) { return iso; } }\n // Where each check's details are: a report (run as soon as it opens) or a page and tab.\n var CHECK_GOTO = {\n 'provisioning-errors': ['report', 'provisioning-errors', 'the Provisioning errors report'],\n 'aggregation-failures': ['report', 'aggregation-failures', 'the Aggregation failures report'],\n 'stale-sources': ['report', 'aggregation-history', 'the Aggregations by source report'],\n 'sources-in-error': ['report', 'sources-needing-attention', 'the Sources needing attention report'],\n 'identity-errors': ['report', 'identities-with-processing-errors', 'the Identities with processing errors report'],\n 'stuck-requests': ['report', 'stuck-access-requests', 'the Stuck access requests report'],\n 'leavers-with-access': ['report', 'terminated-users-with-active-accounts', 'the Terminated users with active accounts report'],\n 'uncorrelated-growth': ['report', 'uncorrelated-accounts', 'the Uncorrelated accounts report'],\n 'campaigns-at-risk': ['report', 'campaign-progress', 'the Campaign progress report'],\n 'va-clusters': ['tenant', 'clusters', 'Tenant > Virtual Appliances'],\n 'api-credentials': ['tenant', 'credentials', 'Tenant > API credentials'],\n 'workflow-failures': ['tenant', 'workflows', 'Tenant > Workflows'],\n 'access-ending': ['warnings', 'ending', 'Warnings > Access ending'],\n 'stuck-on-leavers': ['warnings', 'stuck', 'Warnings > Waiting on leavers'],\n 'admins-left': ['warnings', 'admins', 'Warnings > ISC admins'],\n 'past-end-date': ['warnings', 'people', 'Warnings > End dates'],\n 'lifecycle-gaps': ['warnings', 'joiners', 'Warnings > Missed joiners'],\n 'slow-removals': ['certs', 'speed', 'Audit > Provisioning speed'],\n };\n function goToCheck(id) {\n var g = CHECK_GOTO[id];\n if (!g) { showPage('checks'); return; }\n if (g[0] === 'report') {\n showPage('reports');\n loadLibrary(g[1]).then(function () { if (state.current && state.current.def.id === g[1]) run(false); });\n return;\n }\n if (g[0] === 'tenant') state.tn.tab = g[1];\n if (g[0] === 'build') state.bt.tab = g[1];\n if (g[0] === 'warnings') wnState().tab = g[1];\n if (g[0] === 'certs') state.au.tab = g[1];\n showPage(g[0]);\n }\n function openTenant(t, page, check) {\n toast('Opening ' + t.name + '...');\n api('/api/tenants/' + t.id + '/open', 'POST', {}).then(function (r) {\n hidePartner();\n state.signedIn = false;\n showApp(r.tenant);\n $('tenant').textContent = t.name + ' · ' + r.tenant;\n $('tenant-chip').title = t.name + ' · ' + r.tenant;\n $('btn-partner-nav').classList.remove('hidden');\n if (check) goToCheck(check);\n else if (page) showPage(page);\n }).catch(function (e) { toast(errorText(e)); });\n }\n function partnerForm(P) {\n var F = P.form;\n var msg = el('div');\n var inp = function (key, ph, type) { var i = el('input', { className: 'input', value: F[key] || '', placeholder: ph || '', type: type || 'text', autocomplete: 'off' }); i.addEventListener('input', function () { F[key] = i.value; }); return i; };\n var save = el('button', { className: 'btn primary', onclick: function () {\n msg.textContent = '';\n save.disabled = true;\n var body = { name: F.name, baseUrl: F.baseUrl, clientId: F.clientId, clientSecret: F.clientSecret || '', notes: F.notes };\n (F.isNew ? api('/api/tenants', 'POST', body) : api('/api/tenants/' + F.id, 'PUT', body)).then(function (r) {\n P.form = null; P.data = null;\n toast((F.isNew ? 'Added ' : 'Saved ') + r.tenant.name + (r.note ? ' · ' + r.note : ''));\n renderPartner();\n }).catch(function (e) { save.disabled = false; msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), F.isNew ? 'Test and add' : 'Save');\n var remove = F.isNew ? null : el('button', { className: 'btn ghost', onclick: function () {\n remove.replaceWith(el('span', { className: 'inline' }, el('span', { text: 'Remove ' + F.name + ' and its saved secret from this computer?' }),\n el('button', { className: 'btn sm', onclick: function () { api('/api/tenants/' + F.id, 'DELETE').then(function () { P.form = null; P.data = null; P.sel = null; toast('Removed'); renderPartner(); }); } }, 'Yes, remove'),\n el('button', { className: 'btn sm ghost', onclick: function () { renderPartner(); } }, 'No')));\n } }, icon('trash'), 'Remove');\n return el('section', { className: 'card', style: 'margin-bottom:14px' },\n el('h3', { style: 'margin-top:0', text: F.isNew ? 'Add a tenant' : 'Edit ' + F.name }),\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Customer name' }), inp('name', 'e.g. Acme Corp')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Tenant' }), inp('baseUrl', 'acme, or paste the ISC address from your browser')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID' }), inp('clientId')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: F.isNew ? 'Client secret' : 'Client secret (leave empty to keep the saved one)' }), inp('clientSecret', '', 'password'))),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Notes (optional)' }), inp('notes', 'e.g. contract ends June, contact: J. Smith')),\n el('p', { className: 'muted small', text: 'Use a personal access token or API client of a read-only identity in that tenant (for a customer\\u2019s tenant, ask the customer for one). The secret is kept only in the owner-only secrets file on this computer and is never shown again. IdentityScope tests the connection before saving.' }),\n el('div', { className: 'bar' }, save, el('button', { className: 'btn ghost', onclick: function () { P.form = null; renderPartner(); } }, 'Cancel'), el('span', { style: 'flex:1' }), remove),\n msg);\n }\n\n\n function tokenNote(r) {\n var d = r && r.token ? r.token.daysToExpiry : null;\n if (d === null || d === undefined || d > 30) return null;\n return el('div', { className: 'small', style: 'margin-top:2px;white-space:nowrap;font-weight:600;color:' + (d <= 14 ? 'var(--danger)' : 'var(--warn)'), title: 'The personal access token IdentityScope uses for this tenant', text: d < 0 ? 'Token expired' : d === 0 ? 'Token expires today' : 'Token: ' + d + ' day' + (d === 1 ? '' : 's') + ' left' });\n }\n // ---------- in-app guidance ----------\n var HELP = {\n reports: { title: 'Reports', what: 'Ready-made reports and the ones you build. Pick a report, fill in its options and press Preview (first 500 records, quick) or Run report (everything).', read: ['\"Show: Count by\" turns any report into a summary: one row per value with how many.', 'Click a column heading to sort; type in \"Filter these rows\" to search what is shown.', 'Downloads (Excel, CSV, HTML) always contain every row, also when the screen shows only the first part.'], act: ['Customize makes your own copy you can change with drop-downs.', 'New report: pick what a row is (people, accounts, access...), add filters, choose columns, save.', 'Schedule this report sends it by email or Teams on a schedule.'], perms: 'Depends on the data: search needs sp:search:read; accounts, entitlements and sources need their read permissions. The Health check shows what your sign-in can read.' },\n checks: { title: 'Instant check', what: 'Every daily check in one click. Each tile is green (fine), amber (look at it) or red (act now), based on the limits you set.', read: ['\"N new\" means rows that were not there at the previous check, so you see what changed since yesterday.', 'The small line is the trend: the value of each past check, kept on this computer.', 'Grey \"(last time)\" tiles show the previous result until you run the checks again.', '\"Could not check\" usually means the sign-in or token lacks a permission for that check.'], act: ['Click a tile for the rows behind it, how to fix it and a link to the full report.', 'Limits sets when a check turns amber or red, the period it looks at, or switches it off.', 'Schedules > New schedule > \"Instant check\" with \"only when something is new or got worse\" gives a quiet daily alert.'], perms: 'Each check needs read access to its data (search, sources, VA clusters, workflows, campaigns, access requests).' },\n 'lookup-person': { title: 'Person lookup', what: 'One person on one page: lifecycle state, manager, every account, all access, the last 30 days of provisioning, access requests and audit events.', read: ['The coloured lines at the top are hints: red needs action (locked account, failed provisioning), amber is worth checking (disabled account, no manager or email).', '\"Assigned directly\" means the entitlement was given on its own, not through a role or access profile.'], act: ['Use it for \"why can’t this person log in\" and \"why does this person have this access\".', 'Open in ISC jumps to the person in the admin console.'], perms: 'Search (identities, account activities, events); access requests need an admin.' },\n 'lookup-source': { title: 'Source lookup', what: 'Every source with its connection status and last aggregation; click one for counts, aggregations, errors, configuration and what depends on it.', read: ['\"Last successful aggregation\" comes from audit events, so it only reaches back as far as ISC keeps them.', '\"Used by\" lists the identity profiles that read this source; a failing authoritative source affects every identity in that profile.', 'The configuration hides passwords, secrets, keys and encrypted values.'], act: ['Open in ISC goes to the source’s configuration (Admin > Connections > Sources).', 'Connector diagnostics (test connection, ping VA cluster, peek) are off until you turn them on, and ask before every action.'], perms: 'Sources, accounts and entitlements read; diagnostics need source admin rights.' },\n ownership: { title: 'Ownership', what: 'Who owns every source, role, access profile, entitlement, workflow and identity profile, what has no owner, and what is owned by people who left.', read: ['Owners who left or no longer exist cannot approve requests or review access, so those requests and reviews get stuck.', '\"Not found\" means the owner identity no longer exists.'], act: ['Hand over the objects listed under \"Owned by people who left\" (Excel download for the handover).', 'Click an owner to see everything they own before they change jobs.'], perms: 'Read access to sources, roles, access profiles, entitlements, workflows and identity profiles.' },\n tenant: { title: 'Tenant', what: 'The size and health of the setup: counts, Virtual Appliances, workflows, transforms, API credentials and a comparison with another tenant. To try transforms and workflows before changing them, see Build & test.', read: ['A dash in the overview means the sign-in or token cannot read that number.', 'Virtual Appliances: anything not NORMAL is listed first. A VA in error stops aggregation and provisioning for its sources.', 'Transforms \"not referenced\" are not used by an identity profile or another transform; they may still be used in provisioning policies or rules.', 'API credentials: personal access tokens show their expiry date; API clients have none in ISC. \"Owner has left\" means the owner is inactive or in a leaver lifecycle state; the token keeps working until someone deletes it.'], act: ['API credentials: renew tokens that expire soon before scripts and schedules stop, and delete tokens of people who left after checking with their team.', 'Compare tenants: connect production with a token (kept in memory only) to see what differs from sandbox before you move changes.'], perms: 'idn:remote-client:read, sp:workflow:read, sp:workflow-execution:read, idn:transform:read. API credentials: sp:all-personal-access-tokens:read (or sp:my-personal-access-tokens:read for your own) and sp:oauth-client:read.' },\n 'build-tlab': { title: 'Transform lab', what: 'Run a transform on this computer and see each step. Nothing is saved to ISC.', read: ['\"Only ISC can say\" marks custom rules, uniqueness checks and anything else the offline engine cannot know.', 'Assumptions are listed where SailPoint\\'s documentation does not say what happens.', 'Try it on real people with an attribute to compare: \"different\" shows where the result is not what ISC holds now. Check a mapping this way before trusting a result.'], act: ['Save test cases for a transform and run them after every change.'], perms: 'idn:transform:read; on people also sp:search:read, idn:accounts:read and idn:identity-profile:read.' },\n 'build-impact': { title: 'Transform impact', what: 'Where each transform is used: identity profiles, other transforms and provisioning policies, also through chains of transforms, and how many people that covers.', read: ['\"Through A → B\" means the transform is used inside A, which is used by B.', 'People counts are the identities in the identity profiles that use it.', 'Rules run code IdentityScope cannot read, so anything a rule does is not included.'], act: ['Before changing a transform, try the change in the Transform lab on people of every profile listed.', 'Transforms used by nothing are candidates for clean-up; check rules first.'], perms: 'idn:transform:read, idn:identity-profile:read, idn:sources:read, sp:search:read.' },\n 'build-policy': { title: 'Account create preview', what: 'What a source\\'s provisioning policy would produce for one person, worked out on this computer. Nothing is created.', read: ['\"Not set here\" means the field has no transform in the policy; the value comes from the source, a rule or the connector.', 'Password fields are never worked out or shown. Generators and rules are only known to ISC.', 'A required field that would be empty stops the account from being created.'], act: ['Preview a joiner before their start date to find empty required fields.'], perms: 'idn:sources:read, sp:search:read, idn:accounts:read, idn:transform:read.' },\n 'build-wlab': { title: 'Workflow lab', what: 'Walk a workflow step by step on this computer with a trigger you give it. Nothing is called, so the workflow does not need to be disabled.', read: ['Replay reads the history of real runs (kept 90 days by ISC). \"Same path\" means the simulator took the branches ISC took.', 'Secrets in steps show as \"(hidden)\".', 'Loops run their first five items.'], act: ['\"Replay with my edits\" shows which real runs would take a different path before you publish a change.'], perms: 'sp:workflow:read, sp:workflow-execution:read.' },\n 'build-health': { title: 'Workflow health', what: 'Runs and failures of each workflow per week, and the causes of failed runs grouped.', read: ['Causes come from the history of failed runs; IDs, numbers and names are taken out so the same problem groups together.', 'Runs older than 90 days have no history in ISC.', '\"Enabled, never ran\" can be normal for rare events; check the trigger if it should have run.'], act: ['A workflow that fails every run usually has an expired credential: see the Credential map.'], perms: 'sp:workflow:read, sp:workflow-execution:read.' },\n 'build-roles': { title: 'Role change preview', what: 'Who would gain or lose a role if its membership criteria changed.', read: ['\"Keeps it\" are people who hold the role another way (request or assignment).'], act: ['Try the criteria here before saving them in ISC.'], perms: 'idn:role-unchecked:read, sp:search:read; account conditions also idn:accounts:read.' },\n 'build-drift': { title: 'Drift check', what: 'Compare the configuration now with an approved baseline: what was added, removed or changed since.', read: ['The baseline is a copy of a change-history snapshot, kept on this computer, so later snapshots cannot change it.', 'IDs, timestamps and secrets are not compared.'], act: ['Approve a baseline after each release to production, and check for drift before the next one.'], perms: 'The scopes of the Tenant page plus idn:sources:read, idn:identity-profile:read, idn:role-unchecked:read and sp:search:read.' },\n 'build-cmap': { title: 'Credential map', what: 'Every client ID, user and endpoint used in workflows and source connections.', read: ['Secret values are never read; \"typed in\" only means the field is filled in.', 'HTTP Request steps before version 3 cannot use Parameter Storage.'], act: ['When a secret is rotated in an application, update each place listed (or once in Parameter Storage).'], perms: 'sp:workflow:read, idn:sources:read.' },\n partner: { title: 'All tenants (partner overview)', what: 'The instant check of every tenant you look after, side by side: sandbox, QA and production of one company, or each customer of a partner.', read: ['Each row is one tenant; each column one check. Green is OK, amber needs a look, red is a problem, grey could not be checked.', '\"new\" marks a check that is new or worse since that tenant\\'s previous check.', 'Rows with problems come first. Click a number for the cause and how to fix it; Open switches to that tenant with all pages.'], act: ['Schedule \"All tenants\" daily (Schedules page) to get one summary by email or Teams, only when something is new or worse.', 'Use a read-only token for each tenant: the overview never changes anything, but a read-only identity keeps it that way by design.'], perms: 'Per tenant: the read scopes the instant check uses (search, sources, account activities, events, clusters, workflows, campaigns, access request status).' },\n sod: { title: 'Separation of duties', what: 'Rules for access one person should not hold together, and everyone who breaks them.', read: ['A person breaks a rule when they hold any item of side A and any item of side B, however they got it (role, access profile, request).', 'Write items as ISC shows them; add the source in brackets to be exact, e.g. \"Domain Admins (Active Directory)\". Case is ignored.', 'Some ISC editions have their own SOD policies; these rules work without them and stay on this computer.'], act: ['Remove one side, or record an approved exception (mitigating control) for the auditors.', 'The Evidence pack can include the violations list.'], perms: 'Search on identities (sp:search:read).' },\n changes: { title: 'Change history', what: 'What changed in the configuration between two days: sources, transforms, identity profiles, roles, access profiles and workflows.', read: ['Drift from an approved baseline: approve the snapshot of a release, then \"Check for drift now\" lists what was added, removed or changed since. The baseline is a copy kept on this computer.', 'Added and Removed are by name; a renamed object shows as one removed and one added.', 'Snapshots hide secrets and ignore IDs and timestamps, so only real setting changes show.', 'Snapshots are kept on this computer (the \"changes\" folder), one per day, at most 400 days.'], act: ['Schedule the instant check daily: it saves a snapshot every day by itself.', 'Use it after \"something broke yesterday\": compare yesterday with today.'], perms: 'Read on sources, transforms, identity profiles, workflows; search on roles and access profiles.' },\n evidence: { title: 'Evidence pack', what: 'One zip with the reports auditors ask for, a README and SHA-256 fingerprints of every file.', read: ['README.txt says which tenant, when, by whom and with which version it was produced.', 'SHA256SUMS.txt lets an auditor check that no file was changed afterwards (sha256sum -c SHA256SUMS.txt).', 'A part the sign-in cannot read is listed as NOT INCLUDED, with the reason.'], act: ['Build it at the start of the audit and hand the zip over as is.', 'Keep a copy: rebuilding later gives today’s data, not the data of that day.'], perms: 'Whatever each part reads: search, sources, campaigns and certifications, access requests.' },\n reclaim: { title: 'License reclaim', what: 'Enabled accounts of people who left, and accounts nobody signed in with for a long time, with what they cost.', read: ['Authoritative sources (HR) and disabled accounts are skipped.', 'Dormant accounts need a sign-in date attribute per source; without one only leavers are listed.', 'Savings are an estimate: accounts times the monthly cost you entered.'], act: ['Download the list and agree with the application owners which accounts to disable or delete in ISC.', 'Check service and shared accounts before removing them.'], perms: 'Search on identities, accounts and sources read.' },\n requests: { title: 'Access requests', what: 'How fast access requests are approved and fulfilled, who approves slowly, and what is requested and rejected most.', read: ['\"Typical\" is the median: half of the requests were faster.', 'Waiting now counts approvals that are still open, per approver.', 'A high reject rate on an item often means it is requestable by the wrong people or badly described.'], act: ['Remind or replace slow approvers; add a backup approver.', 'Make often-approved items part of a role so nobody has to request them.'], perms: 'Access request status read; an admin sees everyone’s requests.' },\n mining: { title: 'Find candidate roles', what: 'Entitlements most people with the same attribute value (for example the same department) already hold: candidates for a birthright role.', read: ['\"Held by\" shows how many people of the group hold the item.', '\"Already in a role\" means an existing role gives it, directly or through an access profile.'], act: ['Try the candidate in \"Preview a role change\" with the attribute as criteria, then create the role in ISC.'], perms: 'Search on identities, roles and access profiles.' },\n certs: { title: 'Certifications', what: 'Campaign progress, every reviewer’s progress and decisions, and reviews that may be rubber-stamped.', read: ['At risk: due within 7 days and under 80% complete. Overdue: past the deadline and not complete.', 'Approve % close to 100 on large reviews, or a sign-off minutes after the review opened, are signals worth a conversation, not proof.', 'A high share of revokes is usually healthy: reviewers are actually removing access.'], act: ['Download the reviewer list and send reminders to the reviewers who are behind.', 'Reassign reviews of reviewers who are absent, or extend the deadline in ISC.'], perms: 'A certification admin’s sign-in or token sees every reviewer; others may see only their own reviews.' },\n roles: { title: 'Role tools', what: 'Compare roles side by side, and preview who would gain or lose a role before you change its membership criteria in ISC.', read: ['The preview evaluates the criteria like ISC does, ignoring upper and lower case in values.', '\"Each condition on its own\" shows how many people match each condition, how many have the attribute at all, and its most common values: the quickest way to spot a typo.', 'Only attributes that are searchable in ISC can be checked.', '\"Keeps it (other way)\" are people who hold the role by request or assignment, not by the criteria.'], act: ['Show JSON gives the criteria in the format of the ISC role API.', 'Download the list of people affected for the change approval.'], perms: 'Role read (idn:role-unchecked:read or idn:role-checked:read) and search.' },\n coverage: { title: 'Review coverage', what: 'Which sources and privileged entitlements a certification campaign reviewed in the period, and which none did.', read: ['A source counts as reviewed when at least one review item named it.', 'Privileged entitlements are matched by ID, or by name and source.'], act: ['Add the sources and privileged entitlements that were not reviewed to your next campaign.', 'Download the list as evidence that coverage was checked.'], perms: 'idn:campaign:read, idn:sources:read, sp:search:read.' },\n outliers: { title: 'Access outliers', what: 'Active people with far more access items than the median of their group (department by default).', read: ['Groups need at least 5 people; the difference must be at least 10 items.', 'Admins and long-serving staff often have more access; an outlier is a place to start, not a finding.'], act: ['Review the top outliers with their managers first.', 'Compare by job title or another attribute if department is too broad.'], perms: 'sp:search:read on identities.' },\n speed: { title: 'Provisioning speed', what: 'How long account changes take per source, and access removals (disable, delete) that took longer than your limit or are still not done.', read: ['Time runs from when ISC started the change to its last update.', 'For connectors that work through tickets or queues, waiting time is included.'], act: ['Follow up removals \"not done\" first: someone who left may still have access.', 'Use the 90% figure per source to agree a realistic target with application owners.'], perms: 'sp:search:read on account activity.' },\n 'wn-quality': { title: 'Identity data', what: 'Active people without a manager, an email or an attribute you choose, and emails used by more than one person.', read: ['People who left are not checked.', 'Shared emails often mean duplicate identities, test accounts or a mapping problem.'], act: ['Fix the data in the HR source; ISC takes it from there.', 'Missing managers first: approvals and manager certifications depend on them.'], perms: 'sp:search:read on identities.' },\n 'wn-joiners': { title: 'Missed joiners', what: 'Active people missing an account on a source that nearly everyone in their identity profile has (a birthright account), and people past their start date still in a pre-hire lifecycle state.', read: ['Birthright sources are worked out per identity profile; nothing needs setting up.', 'People created within the grace period are not flagged yet.'], act: ['Check the provisioning policy and the account activity for the person; a failed create often explains it.', 'Fix the lifecycle state or the start date for people stuck in pre-hire.'], perms: 'sp:search:read on identities.' },\n 'wn-leavers': { title: 'Missed leavers', what: 'People whose account on their own authoritative (HR) source is disabled while ISC treats them as active, and leavers who still have enabled accounts, roles or access profiles.', read: ['Accounts on the HR source and on ISC itself are not counted for leavers.', 'People active after their end date are on the End dates tab.'], act: ['For \"HR says gone\", check the lifecycle state rules: they should follow the HR status.', 'Disable or remove what leavers still have, starting with privileged accounts.'], perms: 'sp:search:read on identities.' },\n movers: { title: 'Mover leftovers', what: 'Access that almost nobody else in the person\\u2019s group (department by default) has.', read: ['Often left over from a previous job, or granted as a one-off.', 'Groups need at least 10 people.'], act: ['Ask the manager whether the person still needs it; remove what is left from a previous job.'], perms: 'sp:search:read on identities.' },\n adminaccts: { title: 'Admin accounts', what: 'Accounts named like admin, svc, test or shared that are linked to a person.', read: ['A word matches only as a separate part of the account name.', 'You can change the words.'], act: ['Give service accounts an owner instead of linking them to a person; remove test accounts; keep admin accounts separate and reviewed.'], perms: 'sp:search:read on identities.' },\n exceptions: { title: 'Exceptions', what: 'Findings someone accepted, with a reason, who accepted it and an end date.', read: ['In force: left out of the instant check until the end date.', 'Expired: shown again; decide again or fix it.'], act: ['Accept from the details of an instant check tile; end an exception here when the reason no longer holds.', 'Include the register in the evidence pack.'], perms: 'None: kept on this computer.' },\n 'wn-massch': { title: 'Mass changes', what: 'Provisioning per day, with a spike flagged when today or yesterday is far above the usual day.', read: ['Usual = the median day of the period before.', 'A spike lists the sources behind it.'], act: ['Check the last HR file, transform or role change before the next aggregation; pause the source if needed.'], perms: 'sp:search:read on account activities.' },\n 'wn-loops': { title: 'Provisioning loops', what: 'The same change for the same person and source sent many times.', read: ['Often an attribute sync whose value the connector changes back, or a request ISC keeps re-sending.'], act: ['Fix the transform or the connector mapping; remove the stale assignment.'], perms: 'sp:search:read on account activities.' },\n 'wn-outside': { title: 'Changed outside ISC', what: 'Account states that ISC did not cause: disabled without an ISC disable, or enabled again after ISC disabled them.', read: ['Account state is from the last aggregation.', 'By default every disable and enable ISC still has on record is checked, not only recent ones.', 'The last column shows the last disable or enable ISC itself sent to the account.'], act: ['Ask the application team who changed it; turn on native change detection where the source supports it.'], perms: 'Read access to accounts and account activities.' },\n 'wn-syncdrift': { title: 'Attribute sync drift', what: 'Attributes ISC syncs to a source whose value on the account differs from ISC, plus failed syncs.', read: ['Only active people and enabled accounts are compared.', 'Manager is compared by display name.'], act: ['Run an attribute sync for the person, or fix the target attribute mapping.'], perms: 'idn:attr-sync-source-config:read (ORG_ADMIN or HELPDESK) and read access to accounts.' },\n 'wn-groupappr': { title: 'Group approvals', what: 'Pending approvals assigned to a governance group, with how many members are still active.', read: ['\"Nobody can approve\" means every member has left.'], act: ['Add active members to the group or forward the approval.'], perms: 'An org admin token; idn:workgroup:read.' },\n 'wn-mgrleft': { title: 'Manager left', what: 'Active people whose manager has left or is not in ISC.', read: ['Narrow to contractors with a search query.'], act: ['Fix the manager in the HR or NERM source.'], perms: 'sp:search:read on identities.' },\n leavertimes: { title: 'Leaver removal times', what: 'Per leaver: when leaving started and how long each account took to be disabled.', read: ['Start is the lifecycle state change event when ISC has one, otherwise the first disable ISC sent.', 'Accounts on the authoritative source are left out.'], act: ['Fix slow sources first; give auditors the download.'], perms: 'sp:search:read on identities, events and account activities.' },\n attrhist: { title: 'Attribute changes', what: 'Changes of the attributes you follow, between looks by IdentityScope.', read: ['The first look records values only.', 'Kept on this computer, owner-only.'], act: ['Schedule a look every day for a running history.'], perms: 'sp:search:read on identities.' },\n owners: { title: 'Entitlement owners', what: 'Each entitlement owner with what they own and how many people hold it.', read: ['Owners who left come first.', 'Holders are counted for up to 3,000 entitlements.'], act: ['Give each owner their filtered download; replace owners who left.'], perms: 'Read access to entitlements; sp:search:read on identities.' },\n rules: { title: 'Rule usage', what: 'Every connector and cloud rule and where it is used.', read: ['Cloud rules can only be listed with the opt-in SP-Config export.', 'Rules called from other rules or workflows are not seen.'], act: ['Remove unused rules after a check; deploy missing ones before they are called.'], perms: 'Read access to sources, transforms, identity profiles and connector rules; sp:config:read for the export.' },\n 'nerm-overview': { title: 'End dates and sponsors', what: 'Active non-employees past or near their end date, and sponsor problems.', read: ['The end date comes from a date attribute with end, expiry or termination in its name, unless you name one.', 'Sponsors are owner attributes, matched to ISC by email.'], act: ['Ask sponsors to renew or end the engagement; give profiles without a sponsor a new one.'], perms: 'A NERM scope on the API token (nerm:api:read-only), plus sp:search:read in ISC.' },\n 'nerm-sync': { title: 'NERM vs ISC', what: 'Profiles whose NERM status and ISC identity state differ.', read: ['Matched through the accounts on the NERM source in ISC.', 'Only profile types marked as synced to ISC are compared.'], act: ['Aggregate the NERM source, then check the identity profile and lifecycle states.'], perms: 'nerm:api:read-only, and read access to accounts in ISC.' },\n 'nerm-sessions': { title: 'Waiting workflows', what: 'NERM workflow sessions still waiting on a step.', read: ['Age shows only when NERM returns the start date.'], act: ['Follow up with the approver or reviewer in NERM.'], perms: 'nerm:api:read-only (or workflow-operator).' },\n 'nerm-risk': { title: 'High risk', what: 'Profiles at the highest NERM risk level.', read: ['Risk levels and scores come from NERM.'], act: ['Review these first in certifications and end dates.'], perms: 'nerm:api:read-only.' },\n 'nerm-users': { title: 'Portal users who left', what: 'NERM users who can still sign in although their ISC identity has left.', read: ['Users not linked to an ISC identity are counted in a note.'], act: ['Disable the user in NERM.'], perms: 'nerm:api:read-only, plus sp:search:read in ISC.' },\n outmodel: { title: 'Outside roles', what: 'Entitlements active people hold directly instead of through a role or access profile.', read: ['Directly = by request, by an admin, or found on the source by aggregation.', '\"Never given by a role\" entitlements are not in any role or access profile that someone has.'], act: ['Put common direct access into a role or access profile; review privileged direct access first.'], perms: 'sp:search:read on identities.' },\n composition: { title: 'What is in every role', what: 'One row per role, access profile and entitlement.', read: ['Entitlements put straight into a role have no access profile.', 'Empty roles grant nothing.'], act: ['Give the download to role owners for review; remove or fill empty roles.'], perms: 'idn:role-unchecked:read and idn:access-profile:read.' },\n reassigned: { title: 'Reassigned reviews', what: 'Certifications passed on to another reviewer.', read: ['Shows who passed it on, the reason given, and whether the new reviewer is still active.'], act: ['Ask for a reason where none was given; reassign reviews that sit with someone who left.'], perms: 'A certification admin token (idn:campaign:read).' },\n 'wn-aggsafe': { title: 'Aggregation safety', what: 'Per source: the delete threshold, how many account aggregations ran and failed, and sources that did not aggregate.', read: ['A high delete threshold lets one broken read remove most accounts.', 'Sources fed by file upload aggregate only when a file is loaded.'], act: ['Lower thresholds of 50% or more; fix sources whose aggregations keep failing.'], perms: 'Read access to sources; sp:search:read on events.' },\n 'wn-svc': { title: 'Service accounts', what: 'Service and machine accounts with no owner, an owner who left, or no recent use.', read: ['Owners and last-used dates come from Machine Identity Security when the tenant has it.'], act: ['Give every enabled account an owner; disable the unused ones after checking.'], perms: 'idn:mis-account:read, or read access to accounts.' },\n 'wn-multi': { title: 'Several accounts', what: 'People with more than one account on the same source.', read: ['On the authoritative source it usually means a duplicate HR record or a rehire.'], act: ['Fix the correlation or merge the HR records.'], perms: 'sp:search:read on identities.' },\n 'wn-pwfail': { title: 'Password failures', what: 'Password changes, resets and syncs that failed.', read: ['From audit events of type password activity.'], act: ['Fix the source connection or password policy mismatch; ask the person to change the password again.'], perms: 'sp:search:read on events.' },\n 'wn-lcset': { title: 'Lifecycle settings', what: 'What each lifecycle state of each identity profile does to accounts and access.', read: ['A leaver state is one where ISC marks people inactive, or whose name says so.', 'Findings: leaver states that turn nothing off, or leave some sources on; states switched off that still hold people.'], act: ['Add the missing sources to the state’s account settings in the identity profile, or confirm a workflow handles them.'], perms: 'idn:identity-profile:read, idn:identity-profile-lifecycle-state:read and idn:sources:read.' },\n 'wn-govgroups': { title: 'Governance groups', what: 'Every governance group with its owner, members and where it is used.', read: ['A group with no active member cannot approve or review anything sent to it.'], act: ['Add active members, replace owners who left, delete groups that are not used.'], perms: 'idn:workgroup:read; sp:search:read on identities.' },\n 'logs-ccg': { title: 'Connector log (ccg.log)', what: 'Reads the connector log of a Virtual Appliance from a copy on this computer and shows the errors and warnings grouped and counted, per source, with the full error detail.', read: ['ISC has no API for this file: copy it from the appliance (/home/sailpoint/log/ccg.log) or point to a folder where it is dropped.', 'Repeats are one row with a count; IDs, numbers and names are ignored when grouping.', 'Times are as written in the log (UTC).', 'Values that look like passwords, tokens or keys are hidden.'], act: ['Open the detail of the most frequent error for the source that fails; the first line of the error detail usually names the cause (timeout, permission, certificate, bad attribute).', 'Compare the time with “What ISC recorded”.'], perms: 'None in ISC. The file must be readable on this computer.' },\n 'logs-isc': { title: 'What ISC recorded', what: 'One timeline of aggregations, source changes and provisioning errors per source, and the state of the Virtual Appliances now.', read: ['This is ISC’s summary of each error, not the full connector log.', 'Event names and statuses are shown as ISC wrote them.'], act: ['A source failing while its cluster is not NORMAL: fix the appliance first.', 'For the detail behind an error of a Virtual Appliance source, read its ccg.log in the other tab.'], perms: 'sp:search:read on events and account activities; idn:sources:read; idn:remote-client:read for the appliances.' },\n 'wn-privgain': { title: 'Privileged access gained', what: 'Privileged entitlements a person holds now and did not hold at the previous look, each checked against what ISC itself provisioned in between.', read: ['The first run only remembers who holds what; findings appear from the second run.', '“No ISC record” means the access appeared at aggregation without ISC provisioning it: granted on the application, or arrived with a new account.', 'Kept on this computer: identity and entitlement IDs, and the findings of the last 90 days.'], act: ['Ask the application owner who granted it; remove it or put it through a request so it is approved and reviewed.'], perms: 'sp:search:read on identities and account activities.' },\n 'wn-outacct': { title: 'Accounts created outside ISC', what: 'Accounts that appeared in the period and that ISC marks as aggregated, not provisioned, on sources that are not authoritative.', read: ['A source where most accounts are new was probably just connected; its accounts are listed last.', 'Accounts without an origin in ISC are left out and counted in a note.'], act: ['An account nobody owns that already has access: find who created it on the application, then correlate or remove it.'], perms: 'idn:accounts:read, idn:sources:read; sp:search:read for the owners.' },\n 'wn-sensitive': { title: 'Sensitive changes', what: 'What changed in the configuration that touches a control, compared with an earlier snapshot on this computer, plus API clients and tokens created since.', read: ['Needs two snapshots: the first run takes one; schedule a daily snapshot for a steady record.', '“Who” is the last person ISC’s audit log names for an object of the same name; it can be empty.', 'High: rules, lifecycle states, password and SOD policies, event subscriptions, anything removed, and source safety settings.'], act: ['Confirm each change was planned and approved; revert what was not.'], perms: 'The reads of Change history; sp:search:read for who; an org admin token for API credentials.' },\n 'wn-risk': { title: 'Risk by person', what: 'The signals of the threat screens added up per person.', read: ['People on more than one screen come first.', 'The score only orders the list.', 'Matched by display name: two people with the same name count as one.'], act: ['Start with the people on several screens; open the screen named in each signal for the detail.'], perms: 'Those of the threat screens; a screen this sign-in cannot read is left out and named.' },\n 'wn-upcoming': { title: 'Coming up', what: 'People whose start or end date falls in the next days, the lifecycle state they are in now, and what the states of their identity profile do.', read: ['ISC decides the state from the profile’s mapping; this page does not predict it.', '“To check” lists what could go wrong on the day: no manager, no leaver state, a leaver state that leaves accounts on.'], act: ['Fix the lifecycle state or the manager before the date; for starters, check the birthright accounts exist.'], perms: 'sp:search:read on identities; idn:identity-profile:read, idn:identity-profile-lifecycle-state:read and idn:sources:read for the states.' },\n 'wn-stuckreq': { title: 'Stuck requests', what: 'Access requests still running after the limit, the phase each is in and on whom it waits, with the sources ISC keeps re-sending the same change to.', read: ['ISC shows a request as pending until its last phase ends, even after it was approved.', 'A churning source fills the queue that requests wait in.'], act: ['Waiting for an approver: remind or reassign in ISC. Waiting in provisioning: check the source, its Virtual Appliance and Warnings > Provisioning loops.'], perms: 'An org admin token for all requests; sp:search:read on account activities.' },\n 'wn-signins': { title: 'Sign-in signals', what: 'Sign-ins to ISC that deserve a look: many failures for one person, a success right after a run of failures, sign-ins by people who have left, and one network address trying many people.', read: ['From ISC audit events of type AUTH. Sign-ins handled by a separate identity provider are recorded there, not here.', 'The address table appears only if the events carry a network address.'], act: ['Check with the person; reset the password and sign-in method if they did not do it; disable identities that left.'], perms: 'sp:search:read on events and identities.' },\n 'wn-selfappr': { title: 'Self-approvals', what: 'Access requests approved by the person who gets the access, or by whoever requested it for someone else.', read: ['Approvals by a governance group are not attributed to a member.'], act: ['Change the approval settings so the owner or manager step cannot be the requester; review what was granted.'], perms: 'An org admin token (idn:access-request-status:read).' },\n 'wn-adminact': { title: 'Admin activity', what: 'Changes to tenant settings, sources, users and access items, by who made them.', read: ['Changes ISC made itself are left out.', '\"Not a person in ISC\" is an API client, a token or a deleted identity.', 'Event names are shown as ISC wrote them.'], act: ['Confirm each change was planned; remove admin rights and tokens of people who left.'], perms: 'sp:search:read on events and identities.' },\n 'wn-spikes': { title: 'Access spikes', what: 'People who were given many access items in one day.', read: ['New joiners and role changes do this legitimately.'], act: ['Check who requested it and whether the person changed job; review what was added.'], perms: 'sp:search:read on account activities and identities.' },\n trail: { title: 'Request trail', what: 'Every access request in the period with each approval step: who decided, approved or rejected, their comment and when, and how the request ended.', read: ['\"Was\" shows the original approver when a step was forwarded or reassigned.', 'A request with no approval step was auto-approved or needed no approval.', '“How fast approvers decide” times each step from the step before it (or from submission) to the decision.', 'The download has one row per approval step.'], act: ['Give the download to auditors as approval evidence.', 'Requests that failed after approval: check the error on the request and the source.'], perms: 'An org admin token (idn:access-request-status:read); other users only see their own requests.' },\n chain: { title: 'Approver chain', what: 'For every access profile, role and requestable entitlement: who approves a request, in what order, and who approves a revoke.', read: ['Steps are in approval order; \"Manager of the person\" is the manager of whoever the access is for.', 'Problems: no approval at all, an owner step with no owner, a governance group that is empty or deleted.', 'At most 300 requestable entitlements are read (one call each).'], act: ['Add an owner, fix the governance group, or add an approval step in the access item settings in ISC.'], perms: 'Read access to access profiles, roles, entitlements, sources and governance groups.' },\n 'wn-expiry': { title: 'Accounts expiring', what: 'Accounts whose expiry attribute is within the period, and accounts that expired but ISC still shows as enabled.', read: ['Read: never (in words, 0, -1, the AD maximum), FILETIME, Unix seconds or milliseconds, LDAP time, ISO dates, MM/dd/yyyy and dd/MM/yyyy with or without a time, and month names.', 'Day-first dates are detected per source (a value like 31/12/2026 anywhere).', 'The attribute must be in the source account schema and aggregated.'], act: ['Ask the manager whether the account should be extended; for expired but enabled accounts, check the leaver process.'], perms: 'Read access to accounts on the chosen sources.' },\n 'wn-revokes': { title: 'Revokes not done', what: 'Items a reviewer revoked in a certification that the person still holds.', read: ['ISC removes revoked access only after sign-off, so unsigned certifications show \"waiting for sign-off\".', '\"Still held\" after sign-off: the removal failed, is still running, or the item also comes from a role, access profile or another assignment.'], act: ['Look at the account activity for the person (Person lookup), fix the source or connector, and remove the item again.'], perms: 'A certification admin token sees every campaign; others only see their own reviews.' },\n 'wn-ending': { title: 'Access ending', what: 'Access granted through a request with an end date. ISC removes it on that date without asking anyone.', read: ['Grouped by manager so you can tell each manager what their people will lose.', 'Comes from completed access requests that had an end date.'], act: ['If the access is still needed, the person requests it again with a later end date before it ends.'], perms: 'idn:access-request-status:read (an admin sees everyone’s requests); search on identities for managers.' },\n 'wn-stuck': { title: 'Waiting on leavers', what: 'Open certification reviews and pending access approvals assigned to someone who left or is no longer in ISC.', read: ['\"Has left\" means inactive or in a leaver lifecycle state.', 'Approvals assigned to a governance group are not listed; a group has other members.'], act: ['Reassign the reviews in the campaign and forward the approvals in ISC.', 'Hand over objects owned by people who left on Lookup > Ownership.'], perms: 'idn:campaign:read, idn:access-request-status:read, search on identities.' },\n 'wn-reminders': { title: 'Review deadlines', what: 'Open certifications due within the period you choose, grouped by reviewer.', read: ['Decisions left is decisions total minus decisions made.', 'Reviewers who left are not in the copied emails.'], act: ['Copy the emails or open an email draft with the reviewers in BCC.', 'Reassign reviews of reviewers who are away.'], perms: 'idn:campaign:read; search on identities.' },\n 'wn-people': { title: 'End dates', what: 'Active people whose end date is coming up, and people still active after their end date.', read: ['Uses the identity attribute you set as the end date; contractors often have one.', 'Saving the attribute turns on the \"Active after end date\" tile in the instant check.'], act: ['Check with HR whether the person really left, then fix the HR record or the lifecycle state.'], perms: 'sp:search:read on identities.' },\n 'wn-admins': { title: 'ISC admins', what: 'Everyone with a user level in ISC itself (Org admin, Source admin, Help desk and others), found as \"IdentityNow\" source entitlements.', read: ['\"New\" means not there at the previous look on this computer.', 'Last sign-in is not shown.'], act: ['Remove user levels of people who left first, then review whether each Org admin still needs it.', 'Download the list as evidence for your yearly admin review.'], perms: 'sp:search:read on identities.' },\n 'wn-catalog': { title: 'Access catalog', what: 'Requestable entitlements, access profiles and roles without a description or owner, or whose owner left.', read: ['The score is the share of requestable items with a description and an active owner.', 'Sources with the lowest score come first.'], act: ['Ask application owners to write one plain sentence per item, starting with the lowest-scoring sources.', 'Give every requestable item an owner so approvals have someone to go to.'], perms: 'sp:search:read on entitlements, access profiles and roles.' },\n 'wn-growth': { title: 'Identity count', what: 'How many identities you have, how many are new each month, and when you reach your licensed number.', read: ['Until four weeks of counts are kept on this computer, the pace counts new identities only, so it is an upper estimate.', 'Scheduled instant checks keep one count per day.'], act: ['Enter your licensed number and check which identities your contract counts.', 'Plan the renewal before you reach it.'], perms: 'sp:search:read on identities.' },\n monthly: { title: 'Monthly report', what: 'How every daily check moved during a month, with highlights and the tenant’s size, for management.', read: ['Each day counts once: the last check of that day.', 'Lower is better for every check; green change is an improvement.'], act: ['Download it and open it in a browser, then print to PDF to send.', 'Schedule the instant check daily so every month has data.'], perms: 'None beyond the checks themselves; built from this computer’s history.' },\n schedules: { title: 'Schedules', what: 'Send reports or the instant check by email or Teams/Slack automatically, using Windows Task Scheduler.', read: ['Email goes only to addresses of active identities in ISC (shared mailboxes can be allowed one by one).', 'Chat messages carry counts and check results only, never names.'], act: ['\"Only when something is new or got worse\" keeps alerts quiet on good days.', 'Automatic runs need \"Remember my tenant\" with a token of a read-only reporting identity, because sign-ins expire.'], perms: 'The saved token needs read access to what the scheduled reports read.' }\n };\n var FIX = {\n 'provisioning-errors': ['Fix the top cause first: the tile and the \"grouped by cause\" report collapse hundreds of errors into a few problems.', 'Duplicate or invalid usernames: check the naming attribute in the source’s create account profile.', 'Timeouts or connection errors: check the source and its Virtual Appliance (Tenant > Virtual Appliances).', 'Missing required attribute: check the create account profile and the identity attribute it reads.'],\n 'aggregation-failures': ['Open the source (Lookup > Source) to see the error ISC recorded.', 'Common causes: an expired service account password, a changed firewall rule, or the Virtual Appliance being down.', 'After fixing, run the aggregation again from the source in ISC (Admin > Connections > Sources).'],\n 'stale-sources': ['Check the source’s aggregation schedule in ISC: it may be off or failing.', 'Sources loaded by file upload are not counted here.'],\n 'va-clusters': ['Check that the Virtual Appliance machine is running and can reach SailPoint over the network.', 'The appliance status and its logs are in the ISC admin console under Virtual Appliances; contact SailPoint support if it stays in error.'],\n 'workflow-failures': ['Open the workflow’s execution history in ISC to see the step that failed.', 'Common causes: expired credentials in an HTTP step, renamed attributes, or rate limits.'],\n 'sources-in-error': ['Connection problems: see failed aggregations above and use Test connection on the source page.', 'No owner: assign one in ISC; owners approve access and review the source.'],\n 'identity-errors': ['Read the error message in the detail table: often a transform that fails or a manager that cannot be found.', 'The \"Identity attribute mappings\" report shows where each attribute comes from; fix the mapping, then refresh the identity in ISC.'],\n 'stuck-requests': ['Open the request in ISC: usually waiting for an approver who left (see Lookup > Ownership) or a provisioning error.'],\n 'leavers-with-access': ['Check the leaver lifecycle state in the identity profile: its \"disable accounts\" list must include these sources.', 'Disable the remaining accounts, and check why the lifecycle state change did not reach them.'],\n 'campaigns-at-risk': ['Send reminders to the reviewers who are behind (Certifications page), reassign reviews of absent reviewers, or extend the deadline.'],\n 'lifecycle-gaps': ['Open Warnings > Missed joiners and Missed leavers for details; a missed joiner usually means a failed or missing provisioning policy, \"HR says gone\" usually means the lifecycle state is not driven by the HR status.'],\n 'slow-removals': ['Open Audit > Provisioning speed to see which source is slow; removals \"not done\" usually wait on a ticket, a queue or a failed connector.'],\n 'access-ending': ['Tell the managers on Warnings > Access ending; if the access is still needed, it must be requested again with a later end date.'],\n 'stuck-on-leavers': ['Reassign the certification reviews in the campaign and forward the approvals in ISC (list on Warnings > Waiting on leavers).'],\n 'admins-left': ['Remove the user level in ISC under Admin > Identities > the person > User level, then check why the leaver process did not.'],\n 'past-end-date': ['Check with HR whether these people left; then fix the HR record or the lifecycle state rules (list on Warnings > End dates).'],\n 'uncorrelated-growth': ['A sudden jump usually means a correlation rule stopped matching after an attribute changed, or new service accounts arrived.', 'Check the source’s correlation settings and the \"Accounts not linked to any person\" report for that source.']\n };\n function currentHelpKey() {\n var p = state.page || 'reports';\n if (p === 'partner') return 'partner';\n if (p === 'certs') return state.au.tab === 'certs' ? 'certs' : state.au.tab;\n if (p === 'monthly') return state.inz.tab;\n if (p === 'warnings') return state.wn && state.wn.tab === 'movers' ? 'movers' : 'wn-' + (state.wn ? state.wn.tab : 'ending');\n if (p === 'tenant' && state.tn) {\n var moved = { workflows: 'build-health', transforms: 'build-impact', cmap: 'build-cmap' }[state.tn.tab];\n if (moved) return moved;\n }\n if (p === 'roles' && state.roleTab === 'mining') return 'mining';\n if (p === 'build') return 'build-' + state.bt.tab;\n if (p === 'nerm') return 'nerm-' + nmState().tab;\n if (p === 'logs') return 'logs-' + lgState().tab;\n if (p === 'tenant' && state.tn && state.tn.tab === 'rules') return 'rules';\n if (p === 'roles' && state.roleTab === 'impact') return 'build-roles';\n if (p === 'lookup') return state.lk.tab === 'ownership' ? 'ownership' : state.lk.tab === 'source' ? 'lookup-source' : 'lookup-person';\n return p;\n }\n function openHelp() {\n var h = HELP[currentHelpKey()] || HELP.reports;\n var drawer = el('aside', { className: 'drawer', 'aria-label': 'Help' });\n drawer.appendChild(el('button', { className: 'btn sm', style: 'margin-bottom:12px', onclick: function () { close(); openFinder(); } }, icon('search'), 'Find any page, tab or report (Ctrl+K)'));\n var onKey = function (e) { if (e.key === 'Escape') close(); };\n var close = function () { back.remove(); document.removeEventListener('keydown', onKey); if (!$('btn-help').classList.contains('hidden')) $('btn-help').focus(); };\n document.addEventListener('keydown', onKey);\n var back = el('div', { className: 'drawer-back', onclick: function (e) { if (e.target === back) close(); } }, drawer);\n var list = function (title, items) { return items && items.length ? el('div', {}, el('h4', { text: title }), el('ul', {}, items.map(function (x) { return el('li', { text: x }); }))) : null; };\n drawer.appendChild(el('div', { className: 'bar', style: 'margin-bottom:6px' }, el('h3', { style: 'margin:0;flex:1', text: h.title }), el('button', { className: 'btn icon ghost', title: 'Close', onclick: close }, icon('x'))));\n drawer.appendChild(el('p', { text: h.what }));\n drawer.appendChild(list('How to read it', h.read));\n drawer.appendChild(list('What you can do', h.act));\n drawer.appendChild(el('div', {}, el('h4', { text: 'Permissions' }), el('p', { className: 'muted', text: h.perms })));\n var checklist = el('div');\n drawer.appendChild(el('div', {}, el('h4', { text: 'Getting started' }), checklist));\n renderChecklist(checklist);\n drawer.appendChild(el('div', {}, el('h4', { text: 'Getting help' }),\n el('p', { className: 'small', text: 'A support file lists versions, settings, schedules, recent errors and log lines, with secrets, names, email addresses, tenant addresses and IDs removed. Read it before you send it to whoever helps you.' }),\n el('a', { className: 'btn sm', href: '/api/support/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download a support file')));\n var upd = el('div');\n drawer.appendChild(upd);\n renderUpdates(upd);\n drawer.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'IdentityScope only reads from ISC. Nothing on these pages changes your tenant (connector diagnostics excepted, which are off unless you turn them on).' }));\n document.body.appendChild(back);\n var first = drawer.querySelector('button');\n if (first) first.focus();\n }\n function renderUpdates(box, now) {\n api('/api/updates' + (now ? '?now=1' : '')).then(function (u) {\n box.textContent = '';\n if (!u.available) return;\n var on = el('input', { type: 'checkbox', checked: u.enabled });\n on.addEventListener('change', function () { api('/api/updates', 'PUT', { enabled: on.checked }).then(function () { renderUpdates(box); }); });\n var line = u.error ? el('p', { className: 'small error', text: u.error })\n : u.latest ? el('p', { className: 'small', text: u.newer ? 'Version ' + u.latest + ' is available (you have ' + u.current + ').' : 'You have the latest version (' + u.current + ').' }, u.newer && u.page ? el('a', { href: u.page, target: '_blank', rel: 'noopener', text: ' Open the release page' }) : null)\n : el('p', { className: 'small muted', text: 'You have version ' + u.current + '.' });\n box.appendChild(el('div', {}, el('h4', { text: 'New versions' }), line,\n el('div', { className: 'bar' }, el('button', { className: 'btn sm', onclick: function () { renderUpdates(box, true); } }, 'Check now'),\n el('label', { className: 'inline small' }, on, 'Check when the screen opens')),\n el('p', { className: 'muted small', text: 'Checking asks the release page for the latest version number. Nothing about you or your tenant is sent.' })));\n }).catch(function () { box.textContent = ''; });\n }\n function noticeNewVersion() {\n api('/api/updates').then(function (u) { if (u.enabled && u.newer) toast('IdentityScope ' + u.latest + ' is available. See Help for the release page.'); }).catch(function () {});\n }\n function renderChecklist(box) {\n box.textContent = '';\n box.appendChild(el('div', { className: 'muted small', text: 'Checking...' }));\n Promise.all([api('/api/checks').catch(function () { return null; }), api('/api/schedules').catch(function () { return null; })]).then(function (r) {\n var checks = r[0], sched = r[1];\n var ran = checks && Object.keys(checks.trends || {}).some(function (k) { return (checks.trends[k].points || []).length; });\n var limits = checks && checks.checks.some(function (c) { return c.settings && Object.keys(c.settings).length; });\n var daily = sched && sched.jobs.some(function (j) { return j.report === '@instant-check'; });\n var delivery = sched && (sched.email || sched.jobs.some(function (j) { return j.webhookKind; }));\n var items = [\n [true, 'Connected to your tenant', null],\n [null, 'Run the Health check (top right) once to see what your sign-in can read', function () { $('btn-doctor').click(); }],\n [ran, 'Run the instant check', function () { showPage('checks'); }],\n [limits, 'Adjust the limits to your tenant (optional)', function () { state.chk.showLimits = true; showPage('checks'); }],\n [delivery, 'Set up email or a Teams/Slack webhook', function () { showPage('schedules'); }],\n [daily, 'Schedule the instant check daily (builds trends and the monthly report)', function () { state.editing = { isNew: true, report: '@instant-check', params: {} }; showPage('schedules'); }]\n ];\n box.textContent = '';\n box.appendChild(el('div', { className: 'checklist' }, items.map(function (it) {\n return el('button', { className: 'cl-item' + (it[0] ? ' done' : ''), onclick: function () { if (it[2]) { document.querySelectorAll('.drawer-back').forEach(function (d) { d.remove(); }); it[2](); } } },\n el('span', { className: 'cl-box', text: it[0] ? '✓' : it[0] === null ? '•' : '' }), el('span', { text: it[1] }));\n })));\n });\n }\n function fixCard(id) {\n var steps = FIX[id];\n if (!steps) return null;\n return el('div', { className: 'fix' }, el('b', { text: 'How to fix' }), el('ol', {}, steps.map(function (s) { return el('li', { text: s }); })));\n }\n /** \"Today at a glance\" for the home page, from the last instant check on this computer. */\n function glance(box) {\n api('/api/checks').then(function (m) {\n var last = null, worst = { bad: 0, warn: 0 };\n Object.keys(m.trends || {}).forEach(function (k) {\n var tr = m.trends[k], p = tr.points && tr.points[tr.points.length - 1];\n if (!p) return;\n if (!last || p.at > last) last = p.at;\n if (tr.status === 'bad') worst.bad++; else if (tr.status === 'warn') worst.warn++;\n });\n box.textContent = '';\n var level = !last ? 'idle' : worst.bad ? 'bad' : worst.warn ? 'warn' : 'ok';\n box.appendChild(el('div', { className: 'banner ' + level, style: 'margin-bottom:18px' },\n el('b', { text: !last ? 'Start your day with the instant check' : worst.bad + worst.warn ? (worst.bad ? worst.bad + ' problem' + (worst.bad > 1 ? 's' : '') : '') + (worst.bad && worst.warn ? ', ' : '') + (worst.warn ? worst.warn + ' to look at' : '') : 'All checks OK' }),\n el('span', { text: last ? 'Last instant check ' + ago(last) : 'Provisioning, aggregations, VAs, workflows, leavers and more in one click.' }),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn sm', onclick: function () { showPage('checks'); } }, icon('pulse'), last ? 'Open instant check' : 'Run it now')));\n }).catch(function () { box.textContent = ''; });\n }\n\n // ---------- role tools ----------\n function pollJob(id, onProgress, onDone, onError, misses) {\n state.activeJob = id;\n api('/api/jobs/' + id).then(function (s) {\n if (s.state === 'running') { onProgress(s.progress + ' · ' + s.seconds + 's'); setTimeout(function () { pollJob(id, onProgress, onDone, onError); }, 800); }\n else if (s.state === 'error') onError(s.error);\n else onDone(s);\n }).catch(function (e) {\n // The local program may be busy for a moment: try again for about a minute before giving up.\n var n = (misses || 0) + 1;\n if (e && e.name === 'TypeError' && n <= 20) { onProgress('Waiting for IdentityScope to answer...'); setTimeout(function () { pollJob(id, onProgress, onDone, onError, n); }, 3000); }\n else onError(errorText(e));\n });\n }\n function downloads(job) {\n var dl = function (f, label, primary) { return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label); };\n return el('div', { className: 'bar' }, dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML'));\n }\n state.roleTab = state.roleTab || 'compare';\n state.cmp = { roles: [] };\n state.imp = { roleId: '', criteria: null, loaded: null };\n\n function renderRoles() {\n // The role change preview also lives on the Build & test page: redraw that page when it is open.\n if (state.page === 'build') { renderBuild(); return; }\n var outer = $('roles');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1180px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, catIcon('Access model'),\n el('div', {}, el('h2', { text: 'Role tools' }), el('p', { className: 'desc', text: 'Understand roles before you change them. Read-only: nothing is changed in ISC.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['compare', 'Compare roles', 'cols'], ['impact', 'Preview a role change', 'eye'], ['mining', 'Find candidate roles', 'search']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.roleTab === t[0] ? ' active' : ''), onclick: function () { state.roleTab = t[0]; renderRoles(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.roleTab === 'compare') renderCompare(w); else if (state.roleTab === 'mining') renderMining(w); else renderImpact(w);\n }\n\n function renderCompare(w) {\n var c = state.cmp;\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Pick two to six roles' })));\n card.appendChild(el('div', { className: 'runbar', style: 'margin-top:0;padding-top:0;border-top:none' },\n el('label', { className: 'field', style: 'flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'Roles' }), picker({ options: loadPick('roles'), multiple: true, value: c.roles, placeholder: 'Pick roles', onChange: function (v) { c.roles = v; } })),\n el('button', { className: 'btn primary', onclick: function () {\n c.error = null; c.data = null; c.busy = 'Starting...'; renderRoles();\n api('/api/roles/compare', 'POST', { roles: c.roles }).then(function (r) {\n c.job = r.job;\n pollJob(r.job, function (m) { c.busy = m; var p = $('cmp-progress'); if (p) p.textContent = m; }, function (s) { c.busy = null; c.data = s.extra; renderRoles(); }, function (e) { c.busy = null; c.error = e; renderRoles(); });\n }).catch(function (e) { c.busy = null; c.error = errorText(e); renderRoles(); });\n } }, icon('cols'), 'Compare')));\n w.appendChild(card);\n if (c.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'cmp-progress', text: c.busy, style: 'flex:1' }), stopButton()))); return; }\n if (c.error) { w.appendChild(el('div', { className: 'error', text: c.error })); return; }\n var d = c.data;\n if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Which roles overlap?' }), 'Compare roles to find duplicates to merge, or to explain how two job roles differ.')); return; }\n w.appendChild(el('div', { className: 'rolecards' }, d.roles.map(function (r) {\n return el('div', { className: 'rolecard' }, el('h4', { text: r.name }),\n el('div', { className: 'kv' }, el('span', {}, el('b', { text: fmtNum(r.members) }), ' members'), el('span', {}, el('b', { text: String(r.accessProfiles.length) }), ' access profiles'), el('span', {}, el('b', { text: String(r.effectiveEntitlements) }), ' entitlements')),\n el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: 'Owner: ' + (r.owner || 'none') }), el('span', { text: r.enabled === false ? 'Disabled' : 'Enabled' }), el('span', { text: r.requestable ? 'Requestable' : 'Not requestable' })),\n el('div', { className: 'crit', text: r.criteriaText }));\n })));\n var stats = el('section', { className: 'card' });\n if (d.similarity !== undefined && d.similarity !== null) {\n var pct = Math.round(d.similarity * 100);\n stats.appendChild(el('div', { className: 'bar', style: 'justify-content:space-between' }, el('b', { text: 'Entitlement overlap of the first two roles: ' + pct + '%' }),\n el('span', { className: 'muted small', text: pct >= 80 ? 'Very similar: candidates to merge.' : pct >= 40 ? 'Partly overlapping.' : 'Mostly different.' })));\n stats.appendChild(el('div', { className: 'meter' }, el('span', { style: 'width:' + pct + '%' })));\n }\n stats.appendChild(el('div', { className: 'kv', style: 'margin-top:6px' },\n el('span', {}, el('b', { text: fmtNum(d.members.inAll) }), ' people hold all of them'),\n d.roles.map(function (r, i) { return el('span', {}, el('b', { text: fmtNum(d.members.only[i]) }), ' only ' + r.name); })));\n w.appendChild(stats);\n var filter = c.filter || 'all';\n var chips = el('div', { className: 'chips' }, [['all', 'All access'], ['shared', 'In every role'], ['diff', 'Differences']].map(function (f) {\n return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { c.filter = f[0]; renderRoles(); } });\n }));\n var rows = d.items.filter(function (x) { var all = x.inRole.every(Boolean); return filter === 'all' || (filter === 'shared' ? all : !all); });\n var tcard = el('section', { className: 'card', style: 'padding:16px' }, el('div', { className: 'bar', style: 'justify-content:space-between;margin-bottom:12px' }, chips, downloads(c.job)));\n tcard.appendChild(el('div', { className: 'table-wrap' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Type', 'Access', 'Source'].concat(d.roles.map(function (r) { return r.name; }), ['Granted through']).map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, rows.map(function (x) {\n return el('tr', {}, el('td', { text: x.type }), el('td', { text: x.name }), el('td', { className: x.source ? '' : 'empty-cell', text: x.source || '—' }),\n x.inRole.map(function (v) { return el('td', {}, el('span', { className: v ? 'tick' : 'dash', text: v ? '✓' : '—' })); }),\n el('td', { className: 'muted', text: x.via.join(', ') }));\n })))));\n if (!rows.length) tcard.appendChild(el('div', { className: 'empty', text: 'Nothing in this view.' }));\n w.appendChild(tcard);\n }\n\n var CRIT_OPS = [['EQUALS', 'is'], ['NOT_EQUALS', 'is not'], ['CONTAINS', 'contains'], ['DOES_NOT_CONTAIN', 'does not contain'], ['STARTS_WITH', 'starts with'], ['ENDS_WITH', 'ends with'], ['GREATER_THAN', '>'], ['LESS_THAN', '<'], ['GREATER_THAN_EQUALS', '≥'], ['LESS_THAN_EQUALS', '≤']];\n function newLeaf() { return { operation: 'EQUALS', key: { type: 'IDENTITY', property: 'attribute.department', sourceId: null }, stringValue: '' }; }\n function normalizeCriteria(c) {\n if (!c) return { operation: 'AND', children: [newLeaf()] };\n c = clone(c);\n if (c.operation !== 'AND' && c.operation !== 'OR') return { operation: 'AND', children: [c] };\n return c;\n }\n function identityAttrs() {\n var disc = state.disc.identities;\n if (!disc) { ensureDisc('identities'); return []; }\n return (disc.fields || []).filter(function (f) { return f.path.indexOf('attributes.') === 0; }).map(function (f) { return { name: f.path.slice(11), values: f.values }; });\n }\n function critRow(leaf, onRemove) {\n leaf.key = leaf.key || { type: 'IDENTITY', property: '', sourceId: null };\n var attrs = identityAttrs();\n var type = el('select', { className: 'input', 'aria-label': 'Condition on' }, el('option', { value: 'IDENTITY', text: 'Identity attribute' }), el('option', { value: 'ACCOUNT', text: 'Account attribute' }), el('option', { value: 'ENTITLEMENT', text: 'Entitlement' }));\n type.value = leaf.key.type;\n type.addEventListener('change', function () {\n leaf.key.type = type.value;\n leaf.key.sourceId = type.value === 'IDENTITY' ? null : leaf.key.sourceId;\n if (type.value === 'ENTITLEMENT') leaf.key.property = 'attribute.memberOf';\n renderRoles();\n });\n var src = leaf.key.type === 'IDENTITY' ? el('div', { className: 'muted small', style: 'padding:9px 4px', text: 'any source' })\n : picker({ options: loadPick('sources'), value: leaf.key.sourceId || '', placeholder: 'Pick a source', onChange: function (v) { leaf.key.sourceId = v || null; } });\n var dl1 = 'ca' + Math.random().toString(36).slice(2), dl2 = 'cv' + Math.random().toString(36).slice(2);\n var name = (leaf.key.property || '').replace(/^attribute\\./, '');\n var prop = el('input', { className: 'input', value: name, placeholder: leaf.key.type === 'ENTITLEMENT' ? 'memberOf' : 'attribute name', list: leaf.key.type === 'IDENTITY' ? dl1 : null });\n prop.addEventListener('input', function () { leaf.key.property = 'attribute.' + prop.value.trim(); });\n prop.addEventListener('change', function () { renderRoles(); });\n var op = el('select', { className: 'input', 'aria-label': 'Comparison' }, CRIT_OPS.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n op.value = leaf.operation;\n op.addEventListener('change', function () { leaf.operation = op.value; });\n var a = attrs.filter(function (x) { return x.name === name; })[0];\n var val = el('input', { className: 'input', value: leaf.stringValue || '', placeholder: leaf.key.type === 'ENTITLEMENT' ? 'entitlement value, e.g. CN=VPN Users,...' : 'value', list: a && a.values.length ? dl2 : null });\n val.addEventListener('input', function () { leaf.stringValue = val.value; });\n return el('div', { className: 'crit-row' }, type, src, el('div', {}, prop, leaf.key.type === 'IDENTITY' ? el('datalist', { id: dl1 }, attrs.map(function (x) { return el('option', { value: x.name }); })) : null),\n op, el('div', {}, val, a && a.values.length ? el('datalist', { id: dl2 }, a.values.map(function (v) { return el('option', { value: v }); })) : null),\n el('button', { className: 'btn icon ghost', title: 'Remove', onclick: onRemove }, icon('x')));\n }\n function opSelect(node) {\n var s = el('select', { className: 'input', style: 'width:auto;display:inline-block', 'aria-label': 'All or any' }, el('option', { value: 'AND', text: 'all' }), el('option', { value: 'OR', text: 'any' }));\n s.value = node.operation;\n s.addEventListener('change', function () { node.operation = s.value; });\n return s;\n }\n function renderImpact(w) {\n var im = state.imp;\n if (!im.criteria) im.criteria = normalizeCriteria(null);\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Which role?' })));\n card.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:minmax(280px,1fr) 2fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Role (leave empty to try criteria for a new role)' }),\n picker({ options: loadPick('roles'), value: im.roleId, placeholder: 'New role', onChange: function (v) {\n im.roleId = v; im.loaded = null; im.data = null; im.error = null;\n if (!v) { im.criteria = normalizeCriteria(null); renderRoles(); return; }\n api('/api/roles/' + v).then(function (r) { im.loaded = r; im.criteria = normalizeCriteria(r.criteria); renderRoles(); }).catch(function (e) { im.error = errorText(e); renderRoles(); });\n } })),\n im.loaded ? el('div', { className: 'field' }, el('span', { className: 'lbl', text: 'Current criteria' }), el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px', text: im.loaded.criteriaText })) : el('div')));\n if (im.loaded && im.loaded.membershipType === 'IDENTITY_LIST') card.appendChild(el('div', { className: 'note', text: 'This role is given to a fixed list of identities today. You can still try criteria to see who they would cover.' }));\n w.appendChild(card);\n\n var ed = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'New criteria' }), el('span', { className: 'muted small', text: 'compared without case, like ISC' })));\n var root = im.criteria;\n ed.appendChild(el('div', { className: 'joiner' }, 'Give the role to people who match', opSelect(root), 'of:'));\n (root.children || []).forEach(function (ch, i) {\n var removeMe = function () { root.children.splice(i, 1); renderRoles(); };\n if (ch.operation === 'AND' || ch.operation === 'OR') {\n var g = el('div', { className: 'crit-group' }, el('div', { className: 'joiner', style: 'justify-content:space-between' }, el('span', {}, 'A group matching ', opSelect(ch), ' of:'), el('button', { className: 'btn icon ghost', title: 'Remove group', onclick: removeMe }, icon('x'))));\n (ch.children || []).forEach(function (leaf, j) { g.appendChild(critRow(leaf, function () { ch.children.splice(j, 1); if (!ch.children.length) root.children.splice(i, 1); renderRoles(); })); });\n g.appendChild(el('button', { className: 'btn sm', onclick: function () { ch.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Condition in this group'));\n ed.appendChild(g);\n } else ed.appendChild(critRow(ch, removeMe));\n });\n ed.appendChild(el('div', { className: 'bar', style: 'margin-top:6px' },\n el('button', { className: 'btn', onclick: function () { root.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Add condition'),\n el('button', { className: 'btn', onclick: function () { root.children.push({ operation: root.operation === 'AND' ? 'OR' : 'AND', children: [newLeaf()] }); renderRoles(); } }, icon('plus'), 'Add group'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn ghost', onclick: function () { modal('Criteria as JSON (for the ISC role API, membership.criteria)', JSON.stringify(im.criteria, null, 2)); } }, icon('code'), 'Show JSON'),\n el('button', { className: 'btn primary', onclick: function () {\n im.error = null; im.data = null; im.busy = 'Starting...'; renderRoles();\n api('/api/roles/impact', 'POST', { roleId: im.roleId || undefined, criteria: im.criteria }).then(function (r) {\n im.job = r.job;\n pollJob(r.job, function (m) { im.busy = m; var p = $('imp-progress'); if (p) p.textContent = m; }, function (s) { im.busy = null; im.data = s.extra; renderRoles(); }, function (e) { im.busy = null; im.error = e; renderRoles(); });\n }).catch(function (e) { im.busy = null; im.error = errorText(e); renderRoles(); });\n } }, icon('eye'), 'Preview who is affected')));\n w.appendChild(ed);\n if (im.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'imp-progress', text: im.busy, style: 'flex:1' }), stopButton()))); return; }\n if (im.error) { w.appendChild(el('div', { className: 'error', text: im.error })); return; }\n var d = im.data;\n if (!d) return;\n var res = el('section', { className: 'card' });\n res.appendChild(el('div', { className: 'card-h' }, el('h3', { text: 'What would change' }), downloads(im.job)));\n res.appendChild(el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px;margin-bottom:12px', text: 'New: ' + d.newCriteria }));\n res.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat gain' }, el('b', { text: '+' + fmtNum(d.gain) }), el('span', { text: 'would gain the role' })),\n el('div', { className: 'bigstat lose' }, el('b', { text: '−' + fmtNum(d.lose) }), el('span', { text: 'would lose it' })),\n d.role ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.holdersNow) }), el('span', { text: 'hold it now' })) : null,\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.matchNew) }), el('span', { text: 'match the new criteria' })),\n d.keepOther ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.keepOther) }), el('span', { text: 'keep it (given another way)' })) : null,\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.identitiesChecked) }), el('span', { text: 'identities checked' }))));\n d.warnings.forEach(function (x) { res.appendChild(el('div', { className: 'note', text: x })); });\n if (d.conditions && d.conditions.length) {\n res.appendChild(el('div', { className: 'muted small', style: 'margin:14px 0 6px;font-weight:600', text: 'Each condition on its own (of ' + fmtNum(d.identitiesChecked) + ' identities)' }));\n res.appendChild(el('div', { className: 'table-wrap', style: 'margin-bottom:14px' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Condition', 'People matching', 'People with any value', 'Most common values'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, d.conditions.map(function (c) {\n return el('tr', {}, el('td', { style: 'font-family:ui-monospace,Consolas,monospace;font-size:12.5px', text: c.text }),\n el('td', { className: 'num' }, el('span', { className: c.matches ? '' : 'chg lose', text: fmtNum(c.matches) })),\n el('td', { className: 'num', text: c.withValue === null ? '\\u2014' : fmtNum(c.withValue) }),\n el('td', { className: 'muted', text: c.topValues.map(function (v) { return v.value + ' (' + fmtNum(v.count) + ')'; }).join(', ') || '\\u2014' }));\n })))));\n }\n var filter = im.filter || 'all';\n res.appendChild(el('div', { className: 'chips' }, [['all', 'Everyone affected'], ['gain', 'Gain'], ['lose', 'Lose'], ['keep-other', 'Keep (other way)']].map(function (f) {\n return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { im.filter = f[0]; renderRoles(); } });\n })));\n var people = d.people.filter(function (p) { return filter === 'all' || p.change === filter; });\n var label = { gain: 'Gains', lose: 'Loses', 'keep-other': 'Keeps' };\n if (people.length) {\n res.appendChild(el('div', { className: 'table-wrap' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Change', 'Person', 'Email', 'Department', 'Lifecycle state', 'Manager'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, people.slice(0, 1000).map(function (p) {\n return el('tr', {}, el('td', {}, el('span', { className: 'chg ' + p.change, text: label[p.change] })), el('td', { text: p.name }), el('td', { text: p.email || '—' }), el('td', { text: p.department || '—' }), el('td', { text: p.lifecycleState || '—' }), el('td', { text: p.manager || '—' }));\n })))));\n if (people.length > 1000) res.appendChild(el('div', { className: 'note', text: 'Showing 1,000 of ' + fmtNum(people.length) + '. Downloads contain everyone.' }));\n } else res.appendChild(el('div', { className: 'empty', text: d.gain + d.lose === 0 ? 'Nobody would gain or lose the role.' : 'Nobody in this view.' }));\n w.appendChild(res);\n }\n\n // ---------- schedules ----------\n var DAYNAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\n function loadSchedules(message) {\n var box = $('schedules');\n box.textContent = '';\n box.appendChild(el('div', { className: 'wrap' }, el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Loading schedules...' }))));\n Promise.all([api('/api/schedules'), state.reports.length ? Promise.resolve(state.reports) : api('/api/reports')]).then(function (r) {\n state.sched = r[0];\n state.reports = r[1];\n renderSchedules(message);\n }).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }\n\n function renderSchedules(message) {\n var sd = state.sched, outer = $('schedules');\n outer.textContent = '';\n var box = el('div', { className: 'wrap', style: 'max-width:1120px' });\n outer.appendChild(box);\n box.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:18px' }, el('span', { className: 'cat-ico', style: 'color:#2457d6;background:#eaf0fd' }, icon('clock')),\n el('div', {}, el('h2', { text: 'Schedules' }), el('p', { className: 'desc', text: 'Send reports by email or to Teams/Slack automatically. Files are also saved in ' + sd.outputDir + '.' }))));\n if (message) box.appendChild(el('div', { className: 'success', text: message }));\n\n if (state.editing) {\n box.appendChild(jobForm(state.editing));\n if (!sd.email) {\n box.appendChild(el('div', { className: 'note', text: 'To send this report by email, fill in the email server once (below). For Teams or Slack only, you can skip it.' }));\n box.appendChild(emailCard(true));\n }\n return;\n }\n\n // tenant for automatic runs\n var remember = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Tenant for automatic runs' })));\n if (sd.remembered) {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill on', text: 'Saved on this computer' }),\n el('span', { className: 'muted', text: 'Automatic runs sign in with the saved token, even when this screen is closed.' }),\n el('button', { className: 'btn sm', text: 'Forget it', onclick: function () { api('/api/remember', 'POST', { remember: false }).then(function () { loadSchedules('Saved tenant details removed.'); }); } })));\n } else if (state.signedIn) {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill off', text: 'Not saved' }),\n el('span', { className: 'muted', text: 'You signed in with SailPoint. Sign-ins expire, so automatic runs need a personal access token: disconnect, connect with a token of a reporting identity, then click \"Remember my tenant\". \"Run now\" works with your sign-in.' })));\n } else {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill off', text: 'Not saved' }),\n el('span', { className: 'muted', text: 'Automatic runs happen when this screen is closed, so they need your tenant details saved on this computer (in your user profile, readable only by you).' }),\n el('button', { className: 'btn primary sm', text: 'Remember my tenant', onclick: function () {\n api('/api/remember', 'POST', { remember: true }).then(function () { loadSchedules('Tenant details saved for automatic runs.'); }).catch(function (e) { alert(errorText(e)); });\n } })));\n }\n box.appendChild(remember);\n\n // jobs\n var jobsCard = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'My schedules' }),\n el('button', { className: 'btn primary', text: '+ New schedule', onclick: function () { state.editing = { isNew: true }; renderSchedules(); } })));\n if (!sd.jobs.length) jobsCard.appendChild(el('div', { className: 'muted', text: 'No schedules yet. Click \"New schedule\", or open a report and click \"Schedule this report\".' }));\n else {\n var t = el('table', { className: 'jobs' }, el('thead', {}, el('tr', {}, ['Name', 'Report', 'When', 'Sends to', 'Runs automatically', ''].map(function (h) { return el('th', { text: h }); }))));\n var tb = el('tbody');\n sd.jobs.forEach(function (j) {\n var to = [];\n if (j.emailTo.length) to.push(j.emailTo.join(', '));\n if (j.webhookKind) to.push(j.webhookKind === 'teams' ? 'Teams' : j.webhookKind === 'slack' ? 'Slack' : 'Webhook');\n var status = el('div');\n var auto = j.automatic\n ? el('div', {}, el('span', { className: 'pill on', text: 'On' }), el('div', { className: 'muted', style: 'font-size:12px', text: 'Next: ' + j.automatic.next }))\n : el('span', { className: 'pill off', text: 'Off' });\n tb.appendChild(el('tr', {},\n el('td', { text: j.name }), el('td', { text: j.reportName }), el('td', { text: j.whenText }), el('td', { text: to.join(' + ') || 'files only' }), el('td', {}, auto),\n el('td', {}, el('div', { className: 'actions' },\n el('button', { className: 'btn sm', text: 'Run now', onclick: function () { runNow(j, status); } }),\n el('button', { className: 'btn sm', text: j.automatic ? 'Turn off' : 'Turn on', title: sd.windows === false ? '' : 'Uses Windows Task Scheduler', onclick: function () { toggleAuto(j); } }),\n el('button', { className: 'btn sm', text: 'Edit', onclick: function () { state.editing = j; renderSchedules(); } }),\n el('button', { className: 'btn sm', text: 'Delete', onclick: function () {\n if (!confirm('Delete the schedule \"' + j.name + '\"?')) return;\n api('/api/schedules/jobs/' + encodeURIComponent(j.name), 'DELETE').then(function () { loadSchedules('Schedule deleted.'); });\n } })))));\n tb.appendChild(el('tr', {}, el('td', { colspan: '6', style: 'border-bottom:none;padding-top:0' }, status, j.lastLog ? el('details', {}, el('summary', { className: 'muted', text: 'Last automatic runs' }), el('div', { className: 'log', text: j.lastLog })) : null)));\n });\n t.appendChild(tb);\n jobsCard.appendChild(el('div', { className: 'table-wrap', style: 'max-height:none' }, t));\n }\n box.appendChild(jobsCard);\n box.appendChild(emailCard());\n }\n\n function runNow(j, status) {\n status.textContent = '';\n status.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Running \"' + j.name + '\" now...' })));\n api('/api/schedules/jobs/' + encodeURIComponent(j.name) + '/run', 'POST', {}).then(function (r) {\n var check = function () {\n api('/api/schedules/runs/' + r.run).then(function (s) {\n if (s.state === 'running') { setTimeout(check, 1000); return; }\n var o = s.outcome;\n status.textContent = '';\n if (o.ok) {\n var parts = [(o.rows || 0).toLocaleString('en-US') + ' rows'];\n if (o.skipped) parts.push('nothing sent (no rows)');\n if (o.delivered.length) parts.push('sent: ' + o.delivered.join(', '));\n if (o.files.length) parts.push('saved ' + o.files.length + ' file(s)');\n status.appendChild(el('div', { className: 'success', text: 'Done: ' + parts.join(' · ') }));\n } else status.appendChild(el('div', { className: 'error', text: o.error || 'Failed' }));\n });\n };\n check();\n }).catch(function (e) { status.textContent = ''; status.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }\n\n function toggleAuto(j) {\n api('/api/schedules/jobs/' + encodeURIComponent(j.name) + '/automatic', 'POST', { on: !j.automatic })\n .then(function () { loadSchedules(j.automatic ? 'Automatic runs turned off for \"' + j.name + '\".' : '\"' + j.name + '\" will now run automatically (' + j.whenText + ') while this computer is on.'); })\n .catch(function (e) { alert(errorText(e)); });\n }\n\n function emailCard(inForm) {\n var e = state.sched.email || {};\n var host = el('input', { className: 'input', value: e.host || '', placeholder: 'smtp.office365.com' });\n var port = el('input', { className: 'input', value: e.port || 587, style: 'width:90px' });\n var user = el('input', { className: 'input', value: e.user || '', placeholder: 'reports@company.com' });\n var pass = el('input', { className: 'input', type: 'password', placeholder: e.passwordSaved ? 'saved (leave empty to keep)' : '' });\n var from = el('input', { className: 'input', value: e.from || '', placeholder: 'IAM Reports <reports@company.com>' });\n var testTo = el('input', { className: 'input', placeholder: 'you@company.com', style: 'width:240px' });\n var msg = el('div');\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Email server' })),\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Ask your mail team for an SMTP relay or an app password. The password is stored only on this computer.' }),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Server' }), host), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Port' }), port),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'User name' }), user), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Password' }), pass)),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'From' }), from)),\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', text: 'Save email settings', onclick: function () {\n msg.textContent = '';\n api('/api/schedules/email', 'PUT', { host: host.value, port: Number(port.value), user: user.value, password: pass.value, from: from.value })\n .then(function () {\n if (!inForm) return loadSchedules('Email settings saved.');\n return api('/api/schedules').then(function (sd) {\n state.sched = sd;\n msg.appendChild(el('div', { className: 'success', text: 'Email settings saved. Now click \"Save schedule\" above.' }));\n });\n })\n .catch(function (er) { msg.appendChild(el('div', { className: 'error', text: errorText(er) })); });\n } }),\n el('span', { className: 'muted', text: 'Send a test to' }), testTo,\n el('button', { className: 'btn', text: 'Send test email', onclick: function () {\n msg.textContent = '';\n msg.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Sending...' })));\n api('/api/schedules/email/test', 'POST', { to: testTo.value }).then(function () { msg.textContent = ''; msg.appendChild(el('div', { className: 'success', text: 'Test email sent to ' + testTo.value + '.' })); })\n .catch(function (er) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(er) })); });\n } })),\n msg);\n return card;\n }\n\n function jobForm(j) {\n var editing = !j.isNew;\n var reports = state.reports.map(function (r) { return r.definition; });\n var name = el('input', { className: 'input', value: j.name || '', placeholder: 'weekly-leavers' });\n var reportSel = el('select', { className: 'input' }, el('option', { value: '', text: 'Choose a report' }), el('option', { value: '@instant-check', text: 'Instant check (all checks, a summary)' }), el('option', { value: '@all-tenants-check', text: 'All tenants: instant check of every customer tenant (partner overview)' }), reports.map(function (d) { return el('option', { value: d.id, text: d.name }); }));\n reportSel.value = j.report || '';\n var paramsBox = el('div');\n var paramValues = Object.assign({}, j.params || {});\n function drawParams() {\n paramsBox.textContent = '';\n var d = reports.filter(function (x) { return x.id === reportSel.value; })[0];\n if (!d || !d.params) return;\n var g = paramsGrid(d.params, paramValues);\n if (g) { g.style.marginBottom = '14px'; paramsBox.appendChild(g); }\n }\n var nameFor = function (r) { return r === '@instant-check' ? 'daily-instant-check' : r === '@all-tenants-check' ? 'daily-all-tenants' : r; };\n reportSel.addEventListener('change', function () { paramValues = {}; drawParams(); if ((!name.value || name.value === '@instant-check' || name.value === '@all-tenants-check') && reportSel.value) name.value = nameFor(reportSel.value); });\n drawParams();\n if (!name.value && j.report) name.value = nameFor(j.report);\n\n var w = j.when || { every: 'week', time: '08:00', weekday: 1, day: 1 };\n var every = el('select', { className: 'input' }, el('option', { value: 'day', text: 'Every day' }), el('option', { value: 'week', text: 'Every week' }), el('option', { value: 'month', text: 'Every month' }));\n every.value = w.every;\n var time = el('input', { className: 'input', type: 'time', value: w.time || '08:00' });\n var weekday = el('select', { className: 'input' }, DAYNAMES.map(function (n, i) { return el('option', { value: String(i), text: 'on ' + n }); }));\n weekday.value = String(w.weekday === undefined ? 1 : w.weekday);\n var day = el('select', { className: 'input' }, Array.from({ length: 28 }, function (_, i) { return el('option', { value: String(i + 1), text: 'on day ' + (i + 1) }); }));\n day.value = String(w.day || 1);\n var syncWhen = function () { weekday.style.display = every.value === 'week' ? '' : 'none'; day.style.display = every.value === 'month' ? '' : 'none'; };\n every.addEventListener('change', syncWhen); syncWhen();\n\n var fmts = j.formats || ['xlsx'];\n var checks = ['xlsx', 'csv', 'html'].map(function (f) {\n var c = el('input', { type: 'checkbox' });\n c.checked = fmts.indexOf(f) >= 0;\n return { f: f, c: c };\n });\n var emailTo = el('input', { className: 'input', value: (j.emailTo || []).join(', '), placeholder: 'audit@company.com, you@company.com' });\n var allow = {};\n (j.allowUnverified || []).forEach(function (a) { allow[a.toLowerCase()] = true; });\n var recipientsBox = el('div');\n function showRecipients(list) {\n recipientsBox.textContent = '';\n list.forEach(function (r) {\n var line = el('div', { style: 'font-size:13px;margin:3px 0' });\n if (r.ok) {\n line.appendChild(el('span', { className: 'ok', text: '\\u2713 ' + r.email }));\n line.appendChild(el('span', { className: 'muted', text: r.identity ? ' (' + r.identity + ')' : r.reason ? ' (' + r.reason + ')' : '' }));\n } else {\n line.appendChild(el('span', { style: 'color:var(--danger)', text: '\\u2717 ' + r.email + ': ' + r.reason }));\n if (r.reason === 'no identity in ISC has this email') {\n var c = el('input', { type: 'checkbox' });\n c.checked = !!allow[r.email.toLowerCase()];\n c.addEventListener('change', function () { if (c.checked) allow[r.email.toLowerCase()] = true; else delete allow[r.email.toLowerCase()]; });\n line.appendChild(el('label', { className: 'check', style: 'margin-left:12px' }, c, 'It is a shared mailbox or distribution list of our company: allow it'));\n }\n }\n recipientsBox.appendChild(line);\n });\n }\n var checkBtn = el('button', { className: 'btn sm', text: 'Check recipients in ISC', onclick: function () {\n recipientsBox.textContent = 'Checking...';\n api('/api/schedules/recipients', 'POST', { emails: emailTo.value, allowUnverified: Object.keys(allow) })\n .then(function (r) { showRecipients(r.recipients); })\n .catch(function (e) { recipientsBox.textContent = ''; recipientsBox.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } });\n var kind = el('select', { className: 'input' }, el('option', { value: '', text: 'No chat message' }), el('option', { value: 'teams', text: 'Microsoft Teams' }), el('option', { value: 'slack', text: 'Slack' }));\n kind.value = j.webhookKind || '';\n var hook = el('input', { className: 'input', placeholder: j.webhookSaved ? 'saved (leave empty to keep)' : 'https://...' });\n var syncHook = function () { hook.parentNode.style.display = kind.value ? '' : 'none'; };\n var sendWhen = el('select', { className: 'input', style: 'width:auto' },\n el('option', { value: 'always', text: 'every time it runs' }),\n el('option', { value: 'rows', text: 'only when there is something (rows, or a check that is not OK)' }),\n el('option', { value: 'new', text: 'only when something is new or got worse since the last run' }));\n sendWhen.value = j.sendWhen || (j.skipWhenEmpty ? 'rows' : (j.isNew && (j.report === '@instant-check' || j.report === '@all-tenants-check') ? 'new' : 'always'));\n reportSel.addEventListener('change', function () { if ((reportSel.value === '@instant-check' || reportSel.value === '@all-tenants-check') && sendWhen.value === 'always') sendWhen.value = 'new'; });\n var msg = el('div');\n var hookLabel = el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Webhook address (Teams: channel > Workflows > \"Send webhook alerts to a channel\")' }), hook);\n var form = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: editing ? 'Edit schedule' : 'New schedule' })),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Name' }), name), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Report' }), reportSel)),\n paramsBox,\n el('div', { className: 'inline', style: 'margin-bottom:14px' }, el('span', { className: 'muted', text: 'Runs' }), every, weekday, day, el('span', { className: 'muted', text: 'at' }), time),\n el('div', { className: 'bar', style: 'margin-bottom:12px' }, el('span', { className: 'muted', text: 'Files:' }), checks.map(function (x) { return el('label', { className: 'check' }, x.c, x.f === 'xlsx' ? 'Excel' : x.f.toUpperCase()); }),\n el('span', { className: 'muted', style: 'margin-left:12px', text: 'Send' }), sendWhen),\n el('div', { className: 'inline', style: 'align-items:flex-start;margin:6px 0 16px' },\n el('label', { className: 'field', style: 'flex:1;min-width:300px;margin:0' }, el('span', { className: 'lbl', text: 'Email to' }), emailTo, el('span', { className: 'hint', text: 'Comma separated. Each address must belong to an active identity in ISC.' })),\n el('div', { style: 'padding-top:23px' }, checkBtn)),\n recipientsBox,\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Also post a summary to' }), kind), hookLabel),\n el('p', { className: 'muted', text: 'Chat messages carry only counts and check results, never names; the data goes by email or stays in the saved files.' }),\n msg,\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', text: 'Save schedule', onclick: function () {\n msg.textContent = '';\n var body = {\n previousName: editing ? j.name : undefined,\n name: name.value.trim(), report: reportSel.value, params: paramValues,\n when: { every: every.value, time: time.value, weekday: Number(weekday.value), day: Number(day.value) },\n formats: checks.filter(function (x) { return x.c.checked; }).map(function (x) { return x.f; }),\n emailTo: emailTo.value, allowUnverified: Object.keys(allow), webhookKind: kind.value || undefined, webhookUrl: hook.value, sendWhen: sendWhen.value\n };\n api('/api/schedules/jobs', 'POST', body).then(function (r) {\n state.editing = null;\n loadSchedules('Schedule \"' + r.saved + '\" saved. Click \"Run now\" to try it, and \"Turn on\" to run it automatically.');\n }).catch(function (e) {\n if (e.data && e.data.recipients) { msg.appendChild(el('div', { className: 'error', text: e.message })); showRecipients(e.data.recipients); }\n else msg.appendChild(el('div', { className: 'error', text: errorText(e) }));\n });\n } }),\n el('button', { className: 'btn', text: 'Cancel', onclick: function () { state.editing = null; renderSchedules(); } })));\n kind.addEventListener('change', syncHook);\n setTimeout(syncHook, 0);\n return form;\n }\n\n // ---------- start ----------\n api('/api/state').then(function (st) {\n if (st.connected) { state.signedIn = st.signedInAs !== undefined && st.signedInAs !== null; showApp(st.tenant, st.signedInAs); } else showConnect(st);\n }).catch(function (e) {\n document.body.textContent = '';\n document.body.appendChild(el('div', { className: 'error', style: 'margin:40px', text: errorText(e) }));\n });\n // ---------- Warnings: what breaks on a date or stalls without anyone noticing ----------\n function wnState() {\n if (!state.wn) state.wn = { tab: 'ending', ending: { days: 30 }, stuck: {}, reminders: { days: 7 }, people: { days: 30 }, admins: {}, catalog: { q: '' }, growth: {}, settings: null };\n return state.wn;\n }\n var WN_TABS = [\n ['joiners', 'Missed joiners', 'up', 'Active people missing an account that nearly everyone in their identity profile has, and people past their start date still in a pre-hire state.'],\n ['movers', 'Mover leftovers', 'people', 'Access that almost no one else in the person\\u2019s group has: often left over from a previous job (movers) or given as a one-off.'],\n ['leavers', 'Missed leavers', 'people', 'People whose HR account is disabled but who are active in ISC, and leavers who still have enabled accounts, roles or access profiles.'],\n ['expiry', 'Accounts expiring', 'clock', 'Accounts whose expiry date (Active Directory accountExpires, or any date attribute you name) is close, and expired accounts that are still enabled.'],\n ['revokes', 'Revokes not done', 'cert', 'Access a reviewer revoked in a certification that the person still has after sign-off.'],\n ['massch', 'Mass changes', 'pulse', 'Days with far more disables, deletes, new accounts or removed access than usual: a bad HR file or transform can change thousands of accounts overnight.'],\n ['loops', 'Provisioning loops', 'lifecycle', 'The same change sent to the same account again and again: an attribute sync that never sticks or a request ISC keeps re-sending.'],\n ['outside', 'Changed outside ISC', 'eye', 'Accounts disabled on the application although ISC never disabled them, and accounts enabled again after ISC disabled them.'],\n ['syncdrift', 'Attribute sync drift', 'cols', 'Synced attributes whose value on the account differs from ISC, and attribute syncs that failed.'],\n ['groupappr', 'Group approvals', 'people', 'Access approvals waiting on a governance group, with how many members can still approve.'],\n ['mgrleft', 'Manager left', 'people', 'Active people (contractors included) whose manager or sponsor has left: their approvals and reviews reach nobody.'],\n ['aggsafe', 'Aggregation safety', 'pulse', 'Per source: the delete threshold, failed aggregations, and sources that did not aggregate at all.'],\n ['svc', 'Service accounts', 'code', 'Service and machine accounts without an owner, with an owner who left, or not used for a long time, and who owns which.'],\n ['multi', 'Several accounts', 'people', 'People with more than one account on the same source; on the authoritative source this usually means a duplicate HR record or a rehire.'],\n ['pwfail', 'Password failures', 'shield', 'Password changes, resets and syncs that failed, per person and source.'],\n ['lcset', 'Lifecycle settings', 'lifecycle', 'What each lifecycle state does to accounts and access, and leaver states that leave accounts switched on.'],\n ['govgroups', 'Governance groups', 'people', 'Governance groups with no members, only members who left, an owner who left, or no use anywhere.'],\n ['signins', 'Sign-in signals', 'shield', 'Many failed sign-ins for one person, a sign-in right after a run of failures, sign-ins by people who have left, and one network address trying many people.'],\n ['selfappr', 'Self-approvals', 'eye', 'Access requests approved by the person who gets the access, or by the person who asked for it on someone’s behalf.'],\n ['adminact', 'Admin activity', 'code', 'Who changed tenant settings, sources, admins and access items, with changes made by people who have left or by something that is not a person.'],\n ['spikes', 'Access spikes', 'pulse', 'People who were given an unusual number of access items in one day.'],\n ['privgain', 'Privileged access gained', 'shield', 'Privileged entitlements people hold now and did not hold at the previous look, and whether ISC provisioned them or they appeared on the application.'],\n ['outacct', 'Accounts created outside ISC', 'eye', 'New accounts ISC found on a source and did not create itself, with the ones nobody owns or that already have access first.'],\n ['sensitive', 'Sensitive changes', 'code', 'Configuration changes that touch a control (rules, lifecycle states, sources, password and SOD policies, event subscriptions) and new API credentials, with who made them where ISC says.'],\n ['risk', 'Risk by person', 'people', 'The signals of all threat screens added up per person: someone who shows on several screens comes first.'],\n ['upcoming', 'Coming up', 'clock', 'Who starts or ends in the next days, the lifecycle state they are in now and what the states of their identity profile are set to do. Before the day, not after.'],\n ['stuckreq', 'Stuck requests', 'pulse', 'Access requests still running after a day or more: the phase each waits in and on whom, next to the sources ISC keeps re-sending the same change to.'],\n ['ending', 'Access ending', 'clock', 'Access granted with an end date. ISC removes it on that date; renew it before then if it is still needed.'],\n ['stuck', 'Waiting on leavers', 'people', 'Certification reviews and access approvals assigned to someone who left. They do not move until someone reassigns them.'],\n ['reminders', 'Review deadlines', 'cert', 'Certifications still open close to their deadline, per reviewer, so you can send reminders in time.'],\n ['people', 'End dates', 'lifecycle', 'Active people whose end date is coming up, and people still active after their end date.'],\n ['admins', 'ISC admins', 'shield', 'Who holds a user level in ISC itself, such as Org admin, and who of them has left.'],\n ['catalog', 'Access catalog', 'apps', 'Requestable access without a description or owner: people request the wrong thing and approvals stall.'],\n ['growth', 'Identity count', 'up', 'How many identities you have, how fast the number grows, and when you reach your licensed number.'],\n ['quality', 'Identity data', 'people', 'Active people without a manager, email or a key attribute, and emails used by more than one person.']\n ];\n function renderWarnings() {\n var W = wnState();\n var outer = $('warnings');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#b45309;background:#fef3c7' }, icon('clock')),\n el('div', {}, el('h2', { text: 'Warnings' }), el('p', { className: 'desc', text: 'Things that break on a date or stall quietly, found before someone notices the hard way. Read-only.' }))));\n groupedTabs(w, 'wn', WN_GROUPS, WN_TABS, W.tab, function (id) { W.tab = id; renderWarnings(); });\n var spec = WN_TABS.filter(function (t) { return t[0] === W.tab; })[0];\n if (!W.settings && (W.tab === 'people' || W.tab === 'growth')) {\n W.settings = 'loading';\n api('/api/warnings/settings').then(function (s) { W.settings = s; }, function () { W.settings = {}; }).then(function () { if (state.page === 'warnings') renderWarnings(); });\n }\n ({ ending: wnEnding, stuck: wnStuck, reminders: wnReminders, people: wnPeople, admins: wnAdmins, catalog: wnCatalog, growth: wnGrowth, quality: wnQuality, joiners: wnJoiners, leavers: wnLeavers, expiry: wnExpiry, revokes: wnRevokes, massch: wnMassChange, signins: wnSignIns, selfappr: wnSelfApprovals, adminact: wnAdminActivity, spikes: wnAccessSpikes, lcset: wnLifecycleSettings, govgroups: wnGovGroups, aggsafe: wnAggSafety, svc: wnServiceAccounts, multi: wnMultiAccounts, pwfail: wnPasswordFailures, loops: wnLoops, outside: wnOutside, syncdrift: wnSyncDrift, groupappr: wnGroupApprovals, mgrleft: wnManagerLeft, privgain: wnPrivGained, outacct: wnOutsideAccounts, sensitive: wnSensitive, risk: wnRisk, upcoming: wnUpcoming, stuckreq: wnStuckReq, movers: function (w) { renderMovers(w); } })[W.tab](w, W[W.tab] || {}, spec[3]);\n }\n function wnRunBar(w, H, path, label, desc, extras, body) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/warnings/' + path + '/run', body ? body() : {}, renderWarnings); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function daysSelect(H, options, label) {\n var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, options.map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n s.value = String(H.days);\n s.addEventListener('change', function () { H.days = Number(s.value); });\n return s;\n }\n function stat(n, label, tone) { return el('div', { className: 'bigstat' + (tone && n ? ' ' + tone : '') }, el('b', { text: n === null || n === undefined ? '—' : fmtNum(n) }), el('span', { text: label })); }\n function pill(text, tone) { return el('span', { className: 'chg ' + tone, text: text }); }\n function statusPill(s) { return !s || s === 'active' ? null : pill(s === 'left' ? 'has left' : s, 'lose'); }\n function daysText(n) { return n === 0 ? 'today' : n === 1 ? 'tomorrow' : n < 0 ? (-n) + ' days ago' : 'in ' + n + ' days'; }\n\n function wnEnding(w, H, desc) {\n var sel = daysSelect(H, [[7, 'Next 7 days'], [14, 'Next 14 days'], [30, 'Next 30 days'], [90, 'Next 90 days']], 'Period');\n if (!wnRunBar(w, H, 'access-ending', 'Find access ending', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'items end in the next ' + d.days + ' days'), stat(d.rows.filter(function (r) { return r.daysLeft <= 7; }).length, 'within 7 days', 'lose'), stat(d.byManager.length, 'managers to tell')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No access with an end date in this period.' })); return; }\n w.appendChild(section('By manager', d.byManager.length, simpleTable(['Manager', 'Items ending', 'Soonest'], d.byManager.map(function (m) { return [m.manager, m.count, daysText(m.soonest)]; }))));\n w.appendChild(section('Access ending', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Person', 'Access', 'Type', 'Ends', 'Manager', 'Requested by'], d.rows.slice(0, 2000).map(function (r) {\n return [el('span', {}, r.person, ' ', statusPill(r.personStatus)), r.access, r.type, el('span', { style: 'white-space:nowrap' }, r.removeDate.slice(0, 10) + ' ', pill(daysText(r.daysLeft), r.daysLeft <= 7 ? 'lose' : 'off')), r.manager, r.requester];\n })))));\n w.appendChild(el('p', { className: 'muted small', text: 'From completed access requests that had an end date. Access removed earlier by another route may still show here.' }));\n }\n\n function wnStuck(w, H, desc) {\n if (!wnRunBar(w, H, 'stuck', 'Find stuck items', desc)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.reviews, 'certification reviews', 'lose'), stat(d.totals.approvals, 'access approvals', 'lose')));\n if (!d.rows.length) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'Nothing is waiting on people who left' })));\n else w.appendChild(section('Waiting on people who left', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['What', 'Item', 'Waiting on', 'When'], d.rows.map(function (r) { return [r.kind, r.item, el('span', {}, r.waitingOn, ' ', statusPill(r.status)), r.detail]; })))));\n w.appendChild(el('p', { className: 'muted small' }, 'Reassign them in ISC: certification reviews from the campaign, approvals from the request. Objects owned by people who left (sources, roles, access profiles) are on ',\n el('button', { className: 'btn link', style: 'padding:0', text: 'Lookup → Ownership', onclick: function () { state.lk.tab = 'ownership'; showPage('lookup'); } }), '.'));\n }\n\n function wnReminders(w, H, desc) {\n var sel = daysSelect(H, [[3, 'Due within 3 days'], [7, 'Due within 7 days'], [14, 'Due within 14 days'], [30, 'Due within 30 days']], 'Due within');\n if (!wnRunBar(w, H, 'reminders', 'Find reviews due', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n var left = d.reviewers.reduce(function (a, r) { return a + r.decisionsLeft; }, 0);\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.reviewers.length, 'reviewers to remind'), stat(d.rows.length, 'open certifications'), stat(left, 'decisions still to make'), stat(d.rows.filter(function (r) { return r.daysLeft < 0; }).length, 'already overdue', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No open certification is due in this period.' })); return; }\n var copy = el('button', { className: 'btn sm', disabled: !d.emails.length, onclick: function () {\n try { navigator.clipboard.writeText(d.emails.join('; ')).then(function () { toast(d.emails.length + ' email addresses copied'); }, function () { toast('Could not copy; select them from the download instead'); }); } catch (e) { toast('Could not copy; select them from the download instead'); }\n } }, icon('copy'), 'Copy reviewer emails');\n var mail = d.emails.length ? el('a', { className: 'btn sm', href: 'mailto:?bcc=' + encodeURIComponent(d.emails.join(',')) + '&subject=' + encodeURIComponent('Reminder: your access review is due soon') + '&body=' + encodeURIComponent('Hello,\\n\\nYou have an access review in SailPoint that is due soon. Please open SailPoint, go to Certifications, and complete your decisions before the deadline.\\n\\nThank you.') }, icon('inbox'), 'Email draft (BCC)') : null;\n w.appendChild(section('Reviewers', d.reviewers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, copy, mail, downloads(H.job)),\n simpleTable(['Reviewer', 'Email', 'Certifications', 'Decisions left', 'Soonest deadline', 'Campaigns'], d.reviewers.map(function (r) {\n return [el('span', {}, r.reviewer, ' ', statusPill(r.status)), r.email, r.certifications, r.decisionsLeft, r.soonest === null ? null : pill(daysText(r.soonest), r.soonest <= 2 ? 'lose' : 'off'), r.campaigns.join(', ')];\n })))));\n w.appendChild(el('p', { className: 'muted small' }, 'Reviewers who left are not in the copied emails; reassign their reviews instead (see \"Waiting on leavers\"). For progress, approve rates and rubber-stamped reviews, see ',\n el('button', { className: 'btn link', style: 'padding:0', text: 'Audit > Certifications', onclick: function () { state.au.tab = 'certs'; showPage('certs'); } }), '.'));\n }\n\n function wnPeople(w, H, desc) {\n var W = wnState();\n var st = W.settings && W.settings !== 'loading' ? W.settings : null;\n var p = (st && st.people) || {};\n var attr = el('input', { className: 'input', value: p.endDateAttribute || '', placeholder: 'endDate', style: 'max-width:220px', 'aria-label': 'End-date attribute' });\n var q = el('input', { className: 'input', value: p.query || '', placeholder: 'All active identities, or e.g. attributes.employeeType:contractor', style: 'max-width:420px', 'aria-label': 'Which identities' });\n var msg = el('span');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Settings' })),\n el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Identity attribute with the end date' }), attr),\n el('label', { className: 'field', style: 'margin:0;flex:1' }, el('span', { className: 'lbl', text: 'Which identities (search query, optional)' }), q),\n el('button', { className: 'btn', style: 'align-self:flex-end', onclick: function () {\n msg.textContent = '';\n api('/api/warnings/settings', 'PUT', { people: { endDateAttribute: attr.value.trim(), query: q.value.trim() } }).then(function () { W.settings = null; toast('Saved. The instant check now includes \"Active after end date\".'); renderWarnings(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save')), msg,\n el('p', { className: 'muted small', style: 'margin:8px 0 0', text: 'Use the name of the identity attribute as in the identity profile (not the display name). Dates like 2026-12-31, 12/31/2026 or epoch numbers are understood.' })));\n var sel = daysSelect(H, [[7, 'Ending within 7 days'], [30, 'Ending within 30 days'], [90, 'Ending within 90 days']], 'Ending within');\n if (!wnRunBar(w, H, 'people', 'Check end dates', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.pastEnd.length, 'still active after end date', 'lose'), stat(d.endingSoon.length, 'ending within ' + d.days + ' days'), stat(d.withDate, 'of ' + fmtNum(d.checked) + ' have an end date')));\n var tbl = function (list, label) { return simpleTable(['Person', 'End date', 'Manager', 'Lifecycle state'], list.slice(0, 2000).map(function (r) { return [r.person, el('span', { style: 'white-space:nowrap' }, r.endDate.slice(0, 10) + ' ', pill(daysText(r.daysLeft), r.daysLeft < 0 ? 'lose' : 'off')), r.manager, r.lifecycle]; }), label); };\n if (d.pastEnd.length) w.appendChild(section('Still active after their end date', d.pastEnd.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)), tbl(d.pastEnd, 'People still active after their end date'))));\n if (d.endingSoon.length) w.appendChild(section('Ending soon', d.endingSoon.length, tbl(d.endingSoon, 'People ending soon')));\n if (!d.pastEnd.length && !d.endingSoon.length && d.withDate) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No one is past or near their end date' })));\n w.appendChild(el('p', { className: 'muted small', text: 'People past their end date usually mean the HR source still sends them as active, or the lifecycle state does not react to the end date. Check with HR before disabling anyone.' }));\n }\n\n function wnAdmins(w, H, desc) {\n if (!wnRunBar(w, H, 'admins', 'List ISC admins', desc)) return;\n var d = H.data;\n var fresh = d.rows.filter(function (r) { return r.isNew; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'people with a user level'), stat(d.totals.orgAdmins, 'Org admins'), stat(d.totals.left, 'who have left', 'lose'), stat(d.since ? fresh : null, d.since ? 'new since ' + d.since.slice(0, 10) : 'new: from the next look on', 'lose')));\n w.appendChild(el('div', { style: 'display:grid;grid-template-columns:minmax(220px,1fr) 3fr;gap:16px;align-items:start' },\n section('By user level', d.byLevel.length, simpleTable(['User level', 'People'], d.byLevel.map(function (l) { return [levelName(l.level), l.people]; }))),\n section('People', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Person', 'User levels', 'Lifecycle state', 'Status'], d.rows.map(function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.levels.map(levelName).join(', '), r.lifecycle, el('span', {}, statusPill(r.status), r.isNew ? pill('new', 'off') : null)];\n }))))));\n w.appendChild(el('p', { className: 'muted small', text: 'User levels are the \"IdentityNow\" source entitlements found by search. Last sign-in is not shown: ISC gives it per person through another API. Remove user levels in ISC under Admin > Identities > the person > User level.' }));\n }\n function levelName(l) {\n var M = { ORG_ADMIN: 'Org admin', CERT_ADMIN: 'Certification admin', HELPDESK: 'Help desk', DASHBOARD: 'Dashboard', REPORT_ADMIN: 'Report admin', ROLE_ADMIN: 'Role admin', ROLE_SUBADMIN: 'Role sub-admin', SOURCE_ADMIN: 'Source admin', SOURCE_SUBADMIN: 'Source sub-admin', SAAS_MANAGEMENT_ADMIN: 'SaaS management admin', SAAS_MANAGEMENT_READER: 'SaaS management reader' };\n return M[l] || l;\n }\n\n function wnCatalog(w, H, desc) {\n if (!wnRunBar(w, H, 'catalog', 'Check the catalog', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.score === null ? null : T.score, 'quality score (% complete)'), stat(T.items, 'requestable items'), stat(T.noDescription, 'without a description', 'lose'), stat(T.noOwner, 'without an owner', 'lose'), stat(T.ownerLeft, 'owner has left', 'lose')));\n w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'Requestable items', 'Complete', 'Score'], d.bySource.map(function (s) { return [s.source, s.items, s.complete, progressBar(s.score, s.score < 60)]; }))));\n if (d.unused) {\n w.appendChild(section('Nobody has it', d.unused.length, d.unused.length ? el('div', {},\n el('p', { className: 'muted', text: 'Roles and access profiles that no identity holds, out of ' + fmtNum(T.unusedChecked || 0) + ' checked. Candidates to retire, or roles whose membership criteria match nobody (check those with Role tools > Preview a role change).' }),\n simpleTable(['Type', 'Name', 'Source', 'Owner', 'Requestable', 'Enabled'], d.unused.slice(0, 2000).map(function (r) { return [r.type, r.name, r.source || null, r.owner || null, r.requestable ? 'yes' : 'no', r.enabled ? 'yes' : pill('disabled', 'off')]; }), 'Roles and access profiles nobody has'))\n : el('p', { className: 'muted', text: 'Every role and access profile checked (' + fmtNum(T.unusedChecked || 0) + ') is held by at least one identity.' })));\n }\n if (!d.rows.length) return;\n var f = el('input', { className: 'input', placeholder: 'Filter by name, source or owner...', value: H.q || '', style: 'max-width:300px', 'aria-label': 'Filter' });\n var box = el('div');\n var draw = function () {\n var q = (H.q || '').toLowerCase();\n var list = d.rows.filter(function (r) { return !q || (r.name + ' ' + (r.source || '') + ' ' + (r.owner || '')).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(simpleTable(['Type', 'Name', 'Source', 'Owner', 'Missing'], list.slice(0, 2000).map(function (r) { return [r.type, r.name, r.source, r.owner, el('span', {}, r.issues.map(function (x) { return el('span', { className: 'chg ' + (/left|longer/.test(x) ? 'lose' : 'off'), style: 'margin:0 4px 2px 0;display:inline-block', text: x }); }))]; })));\n if (list.length > 2000 || d.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { H.q = f.value; draw(); });\n w.appendChild(section('Items to fix', d.rows.length + (d.more || 0), el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, el('span', { style: 'flex:1' }), downloads(H.job)), box)));\n draw();\n }\n\n function wnGrowth(w, H, desc) {\n var W = wnState();\n var st = W.settings && W.settings !== 'loading' ? W.settings : {};\n var lic = el('input', { className: 'input', type: 'number', min: '1', value: st.licensed || '', placeholder: 'e.g. 10000', style: 'max-width:160px', 'aria-label': 'Licensed identities' });\n var basis = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Count' }, [['all', 'All identities'], ['active', 'Active identities only']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n basis.value = st.basis || 'all';\n var msg = el('span');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Your license' })),\n el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Licensed identities' }), lic),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Count' }), basis),\n el('button', { className: 'btn', style: 'align-self:flex-end', onclick: function () {\n msg.textContent = '';\n api('/api/warnings/settings', 'PUT', { licensed: lic.value === '' ? '' : Number(lic.value), basis: basis.value }).then(function () { W.settings = null; toast('Saved'); renderWarnings(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save')), msg));\n if (!wnRunBar(w, H, 'growth', 'Count identities', desc)) return;\n var d = H.data;\n var cur = d.basis === 'active' ? d.active : d.total;\n var pace = d.netPerMonth !== null ? d.netPerMonth : d.addedPerMonth;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.total, 'identities'), stat(d.active, 'active'), stat(pace, d.forecastFrom === 'kept counts' ? 'net change per month' : 'new per month (3-month average)'),\n d.licensed ? stat(d.licensed - cur, 'left of your ' + fmtNum(d.licensed), d.licensed - cur < 0 ? 'lose' : '') : null));\n if (d.licensed) {\n var used = cur === null ? 0 : Math.round((cur * 100) / d.licensed);\n var when = d.monthsToLicensed === null ? (pace && pace > 0 ? null : 'not growing at the current pace') : d.monthsToLicensed === 0 ? 'already reached' : 'in about ' + d.monthsToLicensed + ' months (' + new Date(Date.now() + d.monthsToLicensed * 30.4 * 86400000).toISOString().slice(0, 7) + ')';\n w.appendChild(el('div', { className: 'banner ' + (used >= 100 ? 'bad' : d.monthsToLicensed !== null && d.monthsToLicensed <= 6 ? 'warn' : 'ok') }, el('b', { text: used + '% of your license used' }), when ? el('span', { text: 'Licensed number reached ' + when }) : null));\n } else w.appendChild(el('div', { className: 'note', text: 'Enter your licensed number above to see when you reach it.' }));\n var max = Math.max.apply(null, d.monthly.map(function (m) { return m.added || 0; }).concat([1]));\n w.appendChild(section('New identities per month', d.monthly.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Month', 'New identities', 'Compared'], d.monthly.map(function (m) { return [m.month, m.added, m.added === null ? null : el('div', { className: 'meter', style: 'width:240px;margin:4px 0' }, el('span', { style: 'width:' + Math.round(((m.added || 0) * 100) / max) + '%' }))]; })))));\n if (d.history && d.history.length > 1) w.appendChild(section('Counts kept on this computer', d.history.length, simpleTable(['Date', 'Identities', 'Active'], d.history.slice(-12).reverse().map(function (p) { return [p.date, p.total, p.active]; }))));\n }\n // ---------- Audit readiness: access outliers, review coverage, provisioning speed (Audit); identity data (Warnings) ----------\n function arState() {\n if (!state.ar) state.ar = { outliers: { groupBy: 'department', factor: 3 }, coverage: { months: 12 }, speed: { days: 30, limit: 24 }, quality: { attribute: 'department' } };\n return state.ar;\n }\n function arRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/audit/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function attrInput(H, key, label, placeholder) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder, style: 'max-width:180px', 'aria-label': label });\n i.addEventListener('input', function () { H[key] = i.value.trim(); });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function numSelect(H, key, options, label) {\n var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, options.map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n s.value = String(H[key]);\n s.addEventListener('change', function () { H[key] = Number(s.value); });\n return s;\n }\n function hoursText(h) { return h < 1 ? Math.round(h * 60) + ' min' : h < 48 ? (Math.round(h * 10) / 10) + ' h' : (Math.round(h / 2.4) / 10) + ' days'; }\n\n // access outliers\n function renderOutliers(w) {\n var H = arState().outliers;\n var extras = el('div', { className: 'bar' }, attrInput(H, 'groupBy', 'Compare people by attribute', 'department'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Outlier when at least' }), numSelect(H, 'factor', [[2, '2× the group median'], [3, '3× the group median'], [5, '5× the group median']], 'Outlier factor')));\n if (!arRunBar(w, H, 'outliers', 'Find outliers', 'People with far more access than others in the same group. Groups need at least 5 people; a difference of 10 items or more counts.', extras, function () { return { groupBy: H.groupBy || 'department', factor: H.factor }; }, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'outliers', 'lose'), stat(d.groups.length, 'groups compared'), stat(d.checked, 'active people checked'), stat(d.skippedSmallGroups, 'in groups too small to compare')));\n if (d.rows.length) w.appendChild(section('Outliers', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Person', 'Group (' + d.groupBy + ')', 'Access items', 'Group median', 'Times', 'Entitlements', 'Roles'], d.rows.slice(0, 2000).map(function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.group, r.access, r.groupMedian, pill(r.times + '×', r.times >= 5 ? 'lose' : 'off'), r.entitlements, r.roles];\n }), 'Access outliers'))));\n else if (d.groups.length) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No outliers at this level' })));\n if (d.groups.length) w.appendChild(section('Groups', d.groups.length, simpleTable(['Group', 'People', 'Median access items', 'Outliers'], d.groups.slice(0, 500).map(function (g) { return [g.group, g.people, g.median, g.outliers]; }), 'Groups compared')));\n w.appendChild(el('p', { className: 'muted small', text: 'Access items are what ISC counts for each person (entitlements, roles and access profiles). An outlier is not wrong by itself: admins and long-serving staff often have more. Use it to pick whom to review first.' }));\n }\n\n // certification coverage\n function renderCoverage(w) {\n var H = arState().coverage;\n var extras = numSelect(H, 'months', [[6, 'Last 6 months'], [12, 'Last 12 months'], [24, 'Last 24 months']], 'Period');\n if (!arRunBar(w, H, 'coverage', 'Check coverage', 'Which sources and privileged entitlements a certification reviewed in the period, and which none did.', extras, function () { return { months: H.months }; }, renderAudit)) return;\n var d = H.data, P = d.privileged;\n var srcTotal = d.sources.length + d.notReviewedSources.length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns in ' + d.months + ' months'), stat(d.reviewItems, 'review items'),\n stat(d.notReviewedSources.length, 'of ' + fmtNum(srcTotal) + ' sources not reviewed', 'lose'), stat(P.notReviewed.length, 'of ' + fmtNum(P.total) + ' privileged entitlements not reviewed', 'lose')));\n w.appendChild(el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)));\n if (d.notReviewedSources.length) w.appendChild(section('Sources no certification reviewed', d.notReviewedSources.length, el('div', { style: 'display:flex;flex-wrap:wrap;gap:6px' }, d.notReviewedSources.map(function (s) { return pill(s, 'lose'); }))));\n if (P.notReviewed.length) w.appendChild(section('Privileged entitlements not reviewed', P.notReviewed.length, simpleTable(['Entitlement', 'Source'], P.notReviewed.slice(0, 2000).map(function (x) { return [x.name, x.source]; }), 'Privileged entitlements not reviewed')));\n if (d.sources.length) w.appendChild(section('Reviewed sources', d.sources.length, simpleTable(['Source', 'Items reviewed', 'Latest review', 'Campaigns'], d.sources.map(function (s) { return [s.source, s.reviewedItems, s.lastReviewed ? s.lastReviewed.slice(0, 10) : null, s.campaigns.slice(0, 3).join(', ') + (s.campaigns.length > 3 ? ' +' + (s.campaigns.length - 3) : '')]; }), 'Reviewed sources')));\n if (d.byAccessType.length) w.appendChild(el('p', { className: 'muted small', text: 'Review items by type: ' + d.byAccessType.map(function (x) { return x.type.toLowerCase().replace(/_/g, ' ') + ' ' + fmtNum(x.items); }).join(', ') + '. Roles and access profiles count for the source of their entitlements only when ISC names it in the review item. A campaign still running counts as reviewing what it contains.' }));\n }\n\n // provisioning speed\n function renderSpeed(w) {\n var H = arState().speed;\n var extras = el('div', { className: 'bar' }, numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [90, 'Last 90 days']], 'Period'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Removals should take at most' }), numSelect(H, 'limit', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '3 days']], 'Removal limit')));\n if (!arRunBar(w, H, 'speed', 'Measure', 'How long account changes take per source, and access removals (disable, delete) that were slow or are still not done.', extras, function () { return { days: H.days, removalLimitHours: H.limit }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.changes, 'account changes'), stat(T.removals, 'removals'), stat(T.openRemovals, 'removals still not done after ' + d.removalLimitHours + ' h', 'lose'), stat(T.slowRemovals, 'removals that took longer', 'lose')));\n if (d.slow.length) w.appendChild(section('Slow or open removals', d.slow.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Person', 'Source', 'Change', 'Started (UTC)', 'Took', 'State'], d.slow.slice(0, 2000).map(function (x) { return [x.person, x.source, x.op, x.started.slice(0, 16).replace('T', ' '), hoursText(x.hours), pill(x.state, x.state === 'not done' ? 'lose' : 'off')]; }), 'Slow or open removals'))));\n else if (T.removals) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'Every removal finished within ' + d.removalLimitHours + ' hours' })));\n if (d.rows.length) w.appendChild(section('By source', d.rows.length, simpleTable(['Source', 'Change', 'Count', 'Median', '90% within', 'Longest', 'Over the limit'], d.rows.map(function (r) {\n return [r.source, r.op, r.count, hoursText(r.medianHours), hoursText(r.p90Hours), hoursText(r.maxHours), r.slower ? pill(String(r.slower), 'lose') : 0];\n }), 'Provisioning speed by source')));\n }\n\n // identity data quality (Warnings tab)\n function wnQuality(w, H, desc) {\n var A = arState().quality;\n var extras = attrInput(A, 'attribute', 'Attribute everyone should have', 'department');\n if (!arRunBar(w, A, 'quality', 'Check identity data', desc, extras, function () { return { attribute: A.attribute || 'department' }; }, renderWarnings)) return;\n var d = A.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.noManager, 'without a manager', 'lose'), stat(T.noEmail, 'without an email', 'lose'), stat(T.noAttribute, 'without ' + d.attribute, 'lose'), stat(T.sharedEmail, 'sharing an email', 'lose'), stat(d.checked, 'active people checked')));\n if (d.sharedEmails.length) w.appendChild(section('Emails used by more than one person', d.sharedEmails.length, simpleTable(['Email', 'People'], d.sharedEmails.map(function (s) { return [s.email, s.people.join(', ')]; }), 'Shared emails')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No gaps found' }))); return; }\n var f = el('input', { className: 'input', placeholder: 'Filter by person or issue...', value: A.q || '', style: 'max-width:280px', 'aria-label': 'Filter' });\n var box = el('div');\n var draw = function () {\n var q = (A.q || '').toLowerCase();\n var list = d.rows.filter(function (r) { return !q || (r.person + ' ' + r.issue).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(simpleTable(['Person', 'Email', 'Lifecycle state', 'Issue'], list.slice(0, 2000).map(function (r) { return [r.person, r.email, r.lifecycle, r.issue]; }), 'Identity data issues'));\n if (list.length > 2000 || d.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { A.q = f.value; draw(); });\n w.appendChild(section('Issues', d.rows.length + (d.more || 0), el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, el('span', { style: 'flex:1' }), downloads(A.job)), box)));\n draw();\n w.appendChild(el('p', { className: 'muted small', text: 'Missing managers break approvals and manager certifications; missing emails break notifications; shared emails often mean duplicate people or test accounts. Fix them in the HR source, not in ISC.' }));\n }\n // ---------- Joiner, mover and leaver gaps; admin accounts; accepted exceptions ----------\n function lcState() {\n if (!state.lc) state.lc = { joiners: { graceDays: 3, share: 90, startDateAttribute: '' }, leavers: { kind: 'all' }, movers: { groupBy: 'department', maxShare: 5 }, accounts: { words: 'admin, adm, svc, service, test, tst, sa, root, sys, shared, generic' }, exceptions: {} };\n return state.lc;\n }\n function lcRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lifecycle/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function filteredTable(H, rows, headers, toCells, label, extraBar) {\n var f = el('input', { className: 'input', placeholder: 'Filter...', value: H.q || '', style: 'max-width:280px', 'aria-label': 'Filter ' + label });\n var box = el('div');\n var draw = function () {\n var q = (H.q || '').toLowerCase();\n var list = rows.filter(function (r) { return !q || JSON.stringify(r).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(list.length ? simpleTable(headers, list.slice(0, 2000).map(toCells), label) : el('p', { className: 'muted', text: 'Nothing matches.' }));\n if (list.length > 2000 || H.data.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { H.q = f.value; draw(); });\n draw();\n return el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, extraBar || null, el('span', { style: 'flex:1' }), downloads(H.job)), box);\n }\n\n // Warnings > Missed joiners\n function wnJoiners(w, _H, desc) {\n var H = lcState().joiners;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Birthright when held by' }), numSelect(H, 'share', [[80, '80% of the profile'], [90, '90% of the profile'], [95, '95% of the profile']], 'Birthright share')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Grace period' }), numSelect(H, 'graceDays', [[1, '1 day'], [3, '3 days'], [7, '7 days'], [14, '14 days']], 'Grace period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Also check joiners of the last' }), numSelect(H, 'recentDays', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Recent joiners')),\n attrInput(H, 'startDateAttribute', 'Start-date attribute (optional)', 'startDate'));\n if (!H.recentDays) H.recentDays = 30;\n if (!lcRunBar(w, H, 'joiners', 'Find missed joiners', desc, extras, function () { return { share: H.share, graceDays: H.graceDays, recentDays: H.recentDays, startDateAttribute: H.startDateAttribute || undefined }; }, renderWarnings)) return;\n var d = H.data, E = d.evidence;\n if (!E) {\n var started = d.rows.filter(function (r) { return !r.missing.length; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length - started, 'missing a birthright account', 'lose'), stat(started, 'past start date, still pre-hire', 'lose'), stat(d.checked, 'active people checked')));\n if (d.rows.length) w.appendChild(section('Missed joiners', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Identity profile', 'Created', 'Why', 'Missing accounts on'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.profile, r.created ? r.created.slice(0, 10) : null, r.reason, r.missing.length ? el('span', {}, r.missing.map(function (m) { return pill(m, 'lose'); })) : null];\n }, 'Missed joiners')));\n return;\n }\n var T = E.totals, bad = T['Criteria met, state not applied'] + T['Joiner ran, provisioning failed'] + T['No joiner activity recorded'] + T['Joiner ran, access not in place'];\n w.appendChild(el('div', { className: 'bigstats' },\n stat(T['Criteria met, state not applied'], 'criteria met, state not applied', 'lose'), stat(T['Joiner ran, provisioning failed'], 'joiner ran, provisioning failed', 'lose'),\n stat(T['No joiner activity recorded'] + T['Joiner ran, access not in place'], 'access missing, no create recorded', 'lose'), stat(T['Joiner ran, still in progress'], 'still in progress'),\n stat(T['Joiner complete'], 'joiner complete'), stat(T.checked, 'people checked')));\n w.appendChild(el('p', { className: 'muted', text: 'ISC has no single \"joiner triggered\" event, so each person is checked three ways: what their lifecycle state is set up to grant, whether the identity profile\\'s lifecycle mapping puts them in that state today (worked out with the Transform lab engine), and what ISC recorded (lifecycle changes, account activities, account creates passed or failed).' }));\n if (E.states.length) w.appendChild(section('What each lifecycle state grants', E.states.length, simpleTable(['Identity profile', 'Lifecycle state', 'Access profiles', 'Enables accounts on'], E.states.map(function (x) {\n return [x.profile, x.name + (x.enabled ? '' : ' (disabled)'), x.accessProfiles.map(function (a) { return a.name + (a.source ? ' (' + a.source + ')' : ''); }).join(', ') || '—', x.enableSources.map(function (a) { return a.name; }).join(', ') || '—'];\n }), 'Lifecycle state configuration')));\n if (d.birthright.length) w.appendChild(section('Accounts most of each profile has', d.birthright.length, simpleTable(['Identity profile', 'Active people', 'Sources nearly everyone has'], d.birthright.map(function (b) {\n return [b.profile, b.people, b.sources.length ? b.sources.map(function (s) { return s.source + ' (' + s.share + '%)'; }).join(', ') : '—'];\n }), 'Birthright accounts per identity profile')));\n if (!bad && !T['State does not match the criteria']) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No missed joiners: every person checked has what their lifecycle state grants, or it is in progress' })));\n var tone = function (v) { return v === 'Joiner complete' ? 'gain' : v === 'Joiner ran, still in progress' || v === 'Could not tell' ? 'keep-other' : 'lose'; };\n w.appendChild(section('People checked', E.rows.length, filteredTable(H, E.rows, ['Person', 'Lifecycle state', 'Verdict', 'Why', 'Recorded by ISC'], function (r) {\n var ev = r.evidence.length ? el('details', {}, el('summary', { text: r.evidence.length + ' record' + (r.evidence.length === 1 ? '' : 's') }),\n el('ul', { className: 'evlist' }, r.evidence.map(function (e) { return el('li', {}, el('span', { className: 'muted small', text: e.when ? e.when.slice(0, 16).replace('T', ' ') + ' ' : '' }), e.what, e.status ? ' ' : null, e.status ? pill(e.status.toLowerCase(), /fail|error/i.test(e.status) ? 'lose' : /pass|complete|commit/i.test(e.status) ? 'gain' : 'keep-other') : null, e.detail ? el('div', { className: 'small', text: e.detail }) : null); })))\n : el('span', { className: 'muted', text: 'nothing' });\n return [el('span', {}, r.person, el('div', { className: 'muted small', text: r.profile + (r.created ? ' · created ' + r.created.slice(0, 10) : '') })),\n el('span', {}, r.lifecycle || '—', r.criteria ? el('div', { className: 'small' + (r.criteria === r.lifecycle ? ' muted' : ''), text: 'criteria: ' + r.criteria }) : r.criteriaNote ? el('div', { className: 'muted small', text: r.criteriaNote }) : null),\n el('span', {}, pill(r.verdict, tone(r.verdict)), el('div', { className: 'muted small', text: r.reason })), r.why, ev];\n }, 'Joiner check')));\n w.appendChild(el('p', { className: 'muted small', text: 'Checked: people missing what their lifecycle state grants, people flagged by the birthright pattern (a source most of their identity profile has), past start dates, and everyone who joined in the period chosen. Birthright access given by roles with membership criteria is covered by the pattern, not the lifecycle state.' }));\n }\n\n // Warnings > Missed leavers\n function wnLeavers(w, _H, desc) {\n var H = lcState().leavers;\n if (!lcRunBar(w, H, 'leavers', 'Find missed leavers', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.hrDisabled, 'HR says gone, ISC says active', 'lose'), stat(T.enabledAccounts, 'enabled accounts of leavers', 'lose'), stat(T.roles, 'roles or access profiles of leavers', 'lose'), stat(T.leavers, 'leavers checked')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No missed leavers found' }))); return; }\n var kinds = [['all', 'All gaps'], ['HR account disabled, identity active', 'HR says gone, ISC says active'], ['Left, account still enabled', 'Accounts still enabled'], ['Left, still holds a role or access profile', 'Roles and access profiles']];\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Which gaps' }, kinds.map(function (k) { return el('option', { value: k[0], text: k[1] }); }));\n sel.value = H.kind;\n sel.addEventListener('change', function () { H.kind = sel.value; renderWarnings(); });\n var rows = H.kind === 'all' ? d.rows : d.rows.filter(function (r) { return r.kind === H.kind; });\n w.appendChild(section('Missed leavers', rows.length, filteredTable(H, rows, ['Person', 'Lifecycle state', 'Gap', 'Detail', 'Source'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.lifecycle, pill(r.kind, /HR/.test(r.kind) ? 'lose' : 'off'), r.detail, r.source];\n }, 'Missed leavers', sel)));\n w.appendChild(el('p', { className: 'muted small', text: '\"HR says gone\" means the account on the person’s own authoritative source is disabled while ISC still treats them as active: usually the lifecycle state does not follow the HR status. People active after their end date are on the End dates tab.' }));\n }\n\n // Warnings > Mover leftovers\n function renderMovers(w) {\n var H = lcState().movers;\n var extras = el('div', { className: 'bar' }, attrInput(H, 'groupBy', 'Compare people by attribute', 'department'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Unusual when held by under' }), numSelect(H, 'maxShare', [[2, '2% of the group'], [5, '5% of the group'], [10, '10% of the group']], 'Unusual share')));\n if (!lcRunBar(w, H, 'movers', 'Find unusual access', 'Access that almost no one else in the person’s group has: often left over from a previous job (movers) or given as a one-off.', extras, function () { return { groupBy: H.groupBy || 'department', maxShare: H.maxShare }; }, renderWarnings)) return;\n var d = H.data;\n var people = {}; d.rows.forEach(function (r) { people[r.person] = 1; });\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'unusual access items', 'lose'), stat(Object.keys(people).length, 'people'), stat(d.rows.filter(function (r) { return r.privileged; }).length, 'of them privileged', 'lose'), stat(d.groups, 'groups compared')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No unusual access found' }))); return; }\n w.appendChild(section('Unusual access', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Group (' + d.groupBy + ')', 'Access', 'Source', 'Holders in group'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.group, el('span', {}, r.access + ' ', r.privileged ? pill('privileged', 'lose') : null, el('div', { className: 'muted small', text: r.type })), r.source, r.holders + ' of ' + fmtNum(r.groupSize)];\n }, 'Unusual access')));\n w.appendChild(el('p', { className: 'muted small', text: 'Groups need at least 10 active people. Access held by at most 3 people of the group, and by fewer than the share you chose, counts as unusual. ISC user levels are left out (see Warnings > ISC admins).' }));\n }\n\n // Audit > Admin accounts\n function renderAdminAccounts(w) {\n var H = lcState().accounts;\n var inp = el('input', { className: 'input', value: H.words, style: 'min-width:340px', 'aria-label': 'Words in account names' });\n inp.addEventListener('input', function () { H.words = inp.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Words in account names' }), inp);\n if (!lcRunBar(w, H, 'accounts', 'Find accounts', 'Admin, service and test accounts that are linked to a person: often shared or privileged accounts hiding under a normal identity.', extras, function () { return { words: H.words.split(/[\\s,;]+/).filter(Boolean) }; }, renderAudit)) return;\n var d = H.data;\n var leftEnabled = d.rows.filter(function (r) { return r.left && !r.disabled; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'accounts found'), stat(leftEnabled, 'enabled, person has left', 'lose'), stat(d.rows.filter(function (r) { return r.privileged; }).length, 'privileged')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No such accounts linked to people' }))); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Source', 'Linked to', 'Matched', 'State'], function (r) {\n return [el('span', {}, r.account + ' ', r.privileged ? pill('privileged', 'lose') : null), r.source, el('span', {}, r.person, ' ', r.left ? pill('has left', 'lose') : null), r.word, r.disabled ? 'disabled' : 'enabled'];\n }, 'Admin and service accounts linked to people')));\n w.appendChild(el('p', { className: 'muted small', text: 'A word matches when it is a separate part of the name: adm.alice, svc_backup and alice-test match; \"sample\" does not match \"sa\". Decide per account whether it should belong to the person, to a service owner, or be removed.' }));\n }\n\n // Audit > Exceptions\n function renderExceptions(w) {\n var H = lcState().exceptions;\n if (!H.data && !H.busy) {\n H.busy = 'Loading...';\n api('/api/exceptions').then(function (d) { H.data = d; }, function (e) { H.error = errorText(e); }).then(function () { H.busy = null; if (state.au && state.au.tab === 'exceptions') renderAudit(); });\n }\n w.appendChild(el('p', { className: 'muted', text: 'Known findings someone accepted, with a reason and an end date. Until then they are left out of the instant check (on this computer and in scheduled checks), and they go into the evidence pack as your risk-acceptance register. Accept an item from the details of an instant check tile.' }));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n var mine = H.data.exceptions.filter(function (e) { return e.tenant === H.data.tenant; });\n var inForce = mine.filter(function (e) { return e.state === 'in force'; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(inForce, 'in force'), stat(mine.filter(function (e) { return e.state === 'expired'; }).length, 'expired: decide again', 'lose'), stat(mine.filter(function (e) { return e.state === 'ended'; }).length, 'ended')));\n if (!mine.length) { w.appendChild(el('p', { className: 'muted', text: 'No exceptions for this tenant yet.' })); return; }\n w.appendChild(section('Exceptions for this tenant', mine.length, simpleTable(['Check', 'Item', 'Reason', 'Accepted by', 'Until', 'State', 'Action'], mine.map(function (e) {\n return [e.checkLabel, e.key, e.reason, e.acceptedBy + ' (' + e.created.slice(0, 10) + ')', e.until,\n pill(e.state + (e.ended ? ' ' + e.ended.slice(0, 10) : ''), e.state === 'in force' ? 'keep-other' : e.state === 'expired' ? 'lose' : 'off'),\n e.state === 'in force' ? el('button', { className: 'btn sm', onclick: function () { endExceptionDialog(e); } }, 'End now') : null];\n }), 'Accepted exceptions')));\n }\n function endExceptionDialog(e) {\n var who = el('input', { className: 'input', placeholder: 'Your name', 'aria-label': 'Ended by' });\n var msg = el('div');\n var box = el('div', { className: 'card', role: 'dialog', 'aria-label': 'End exception', style: 'position:fixed;inset:auto 0 0 0;margin:0 auto 24px;max-width:520px;z-index:50;box-shadow:0 10px 40px rgba(0,0,0,.25)' },\n el('h3', { text: 'End this exception now?' }), el('p', { className: 'muted', text: e.checkLabel + ': ' + e.key }), who, msg,\n el('div', { className: 'bar', style: 'margin-top:10px;justify-content:flex-end' },\n el('button', { className: 'btn', onclick: function () { box.remove(); } }, 'Cancel'),\n el('button', { className: 'btn primary', onclick: function () {\n if (who.value.trim().length < 2) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: 'Say who ends it.' })); return; }\n api('/api/exceptions/' + e.id + '/end', 'POST', { by: who.value.trim() }).then(function () { box.remove(); lcState().exceptions.data = null; toast('Exception ended'); renderAudit(); }, function (err) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(err) })); });\n } }, 'End it')));\n box.addEventListener('keydown', function (ev) { if (ev.key === 'Escape') box.remove(); });\n document.body.appendChild(box);\n who.focus();\n }\n // Instant check: accept one row as an exception\n function acceptDialog(m, key, done) {\n var inYear = new Date(Date.now() + 90 * 86400000).toISOString().slice(0, 10);\n var reason = el('textarea', { className: 'input', rows: '2', placeholder: 'Why this is acceptable (e.g. vendor-managed account, reviewed by the security team)', 'aria-label': 'Reason' });\n var who = el('input', { className: 'input', placeholder: 'Name and role, e.g. Priya Shah, IAM lead', 'aria-label': 'Accepted by' });\n var until = el('input', { className: 'input', type: 'date', value: inYear, 'aria-label': 'Until', style: 'max-width:180px' });\n var msg = el('div');\n var box = el('div', { className: 'card', role: 'dialog', 'aria-label': 'Accept as exception', style: 'position:fixed;inset:auto 0 0 0;margin:0 auto 24px;max-width:560px;z-index:50;box-shadow:0 10px 40px rgba(0,0,0,.25)' },\n el('h3', { text: 'Accept as an exception' }), el('p', { className: 'muted', text: m.label + ': ' + key }),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Reason' }), reason),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Accepted by' }), who),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Until (at most two years)' }), until), msg,\n el('div', { className: 'bar', style: 'justify-content:flex-end' },\n el('button', { className: 'btn', onclick: function () { box.remove(); } }, 'Cancel'),\n el('button', { className: 'btn primary', onclick: function () {\n api('/api/exceptions', 'POST', { check: m.id, key: key, reason: reason.value, acceptedBy: who.value, until: until.value }).then(function () {\n box.remove(); lcState().exceptions.data = null; toast('Accepted until ' + until.value + '. It is left out from the next check.'); if (done) done();\n }, function (err) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(err) })); });\n } }, 'Accept')));\n box.addEventListener('keydown', function (ev) { if (ev.key === 'Escape') box.remove(); });\n document.body.appendChild(box);\n reason.focus();\n }\n // ---------- Transform lab, Workflow lab, Credential map (all read-only; evaluated on this computer) ----------\n var LAB_SAMPLE_TRANSFORM = { type: 'static', attributes: { fn: { type: 'identityAttribute', attributes: { name: 'firstname' } }, ln: { type: 'identityAttribute', attributes: { name: 'lastname' } }, value: '$fn.substring(0,1).toLowerCase()$ln.toLowerCase()' } };\n var LAB_SAMPLE_TRIGGER = { identity: { id: 'id-1', name: 'jane.doe' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }] };\n function labState() {\n if (!state.lab) state.lab = {\n t: { json: JSON.stringify(LAB_SAMPLE_TRANSFORM, null, 2), name: '', implicit: '', identity: JSON.stringify(LAB_IDENTITY, null, 2), accounts: JSON.stringify([LAB_HR_ACCOUNT], null, 2), drafts: '', result: null, cases: [], people: {}, count: 200, query: '', attribute: '' },\n w: { json: '', trigger: JSON.stringify(LAB_SAMPLE_TRIGGER, null, 2), mocks: '{}', pick: '', result: null, replay: {} },\n c: {},\n };\n return state.lab;\n }\n function labCode(value, label, rows, oninput) {\n var ta = el('textarea', { className: 'yaml', spellcheck: 'false', 'aria-label': label, style: 'min-height:' + (rows * 20 + 28) + 'px' });\n ta.value = value;\n ta.addEventListener('input', function () { oninput(ta.value); });\n return ta;\n }\n function labParse(text, what) {\n if (!String(text).trim()) return undefined;\n try { return JSON.parse(text); } catch (e) { throw new Error(what + ' is not valid JSON: ' + e.message); }\n }\n function labValue(v) {\n if (v === null || v === undefined) return el('span', { className: 'muted', text: 'null (no value)' });\n return el('code', { text: typeof v === 'string' ? v : JSON.stringify(v) });\n }\n var LAB_STATUS = { ok: ['worked offline', 'gain'], error: ['fails (ISC would fail too)', 'lose'], 'isc-only': ['only ISC can work this out', 'keep-other'], random: ['different every run', 'keep-other'] };\n function labStatus(s) { var x = LAB_STATUS[s] || [s, 'keep-other']; return pill(x[0], x[1]); }\n function labLoadTenant(H, path, rerender) {\n if (H.list || H.loading) return;\n H.loading = true;\n api(path).then(function (r) { H.list = r; }, function (e) { H.listError = errorText(e); }).then(function () { H.loading = false; rerender(); });\n }\n\n // Tenant > Transform lab\n function renderTransformLab(w) {\n var L = labState().t, rr = renderBuild;\n labLoadTenant(L, '/api/lab/transforms', rr);\n w.appendChild(el('div', { className: 'note', text: 'Runs the transform on this computer, nothing is saved to ISC. Pick one of your transforms or identity profile mappings, or paste a draft. Velocity, dates and lookups work the way SailPoint documents them; anything only ISC can know (custom rules, uniqueness) is marked.' }));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Start from' }, el('option', { value: '', text: L.listError ? 'Could not read transforms' : L.list ? 'Start from one of yours...' : 'Reading your transforms...' }));\n if (L.list) {\n var g1 = el('optgroup', { label: 'Identity profile mappings' });\n L.list.mappings.forEach(function (m, i) { g1.appendChild(el('option', { value: 'm' + i, text: m.profile + ': ' + m.attribute + ' (' + m.summary + ')' })); });\n var g2 = el('optgroup', { label: 'Transforms' });\n L.list.transforms.forEach(function (t, i) { g2.appendChild(el('option', { value: 't' + i, text: t.name + ' (' + t.type + ')' })); });\n pick.appendChild(g1); pick.appendChild(g2);\n }\n pick.addEventListener('change', function () {\n var v = pick.value; if (!v) return;\n if (v[0] === 'm') { var m = L.list.mappings[Number(v.slice(1))]; L.json = JSON.stringify(m.transformDefinition, null, 2); L.name = m.profile + ' / ' + m.attribute; L.attribute = m.attribute; }\n else { var t = L.list.transforms[Number(v.slice(1))]; L.json = JSON.stringify({ type: t.type, attributes: t.attributes || {} }, null, 2); L.name = t.name; L.attribute = ''; }\n L.help = ''; L.result = null; L.people = {}; L.cases = (L.saved && L.saved[L.name]) || [];\n rr();\n });\n if (!L.saved) api('/api/lab/tests').then(function (r) { L.saved = r; }, function () { L.saved = {}; });\n var nameIn = el('input', { className: 'input', value: L.name, placeholder: 'Name (for saved test cases)', style: 'max-width:260px', 'aria-label': 'Transform name' });\n nameIn.addEventListener('input', function () { L.name = nameIn.value; });\n var exPick = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Examples' }, el('option', { value: '', text: 'Or start from an example...' }));\n TRANSFORM_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });\n exPick.addEventListener('change', function () {\n var x = TRANSFORM_EXAMPLES[Number(exPick.value)]; if (!x) return;\n L.json = JSON.stringify(x.transform, null, 2); L.name = x.title; L.attribute = '';\n L.implicit = x.implicit || ''; L.identity = JSON.stringify(x.identity || LAB_IDENTITY, null, 2);\n L.accounts = JSON.stringify(x.accounts || [], null, 2); L.drafts = x.drafts ? JSON.stringify(x.drafts, null, 2) : '';\n L.help = x.help; L.result = null; L.people = {}; L.cases = [];\n rr();\n });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, nameIn));\n if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));\n\n var runBtn = el('button', { className: 'btn primary', onclick: function () { labRunTransform(L, rr); } }, icon('play'), 'Run');\n var left = el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Transform (JSON)' }), labCode(L.json, 'Transform JSON', 16, function (v) { L.json = v; }));\n var imp = el('input', { className: 'input', value: L.implicit, placeholder: 'e.g. 2024-03-01 or Sales', 'aria-label': 'Input value' });\n imp.addEventListener('input', function () { L.implicit = imp.value; });\n var right = el('div', { style: 'flex:1;min-width:300px' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Input value (what the identity profile mapping passes in)' }), imp),\n el('div', { className: 'lbl', text: 'Identity attributes (JSON)' }), labCode(L.identity, 'Identity attributes JSON', 4, function (v) { L.identity = v; }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Accounts (JSON list; used by accountAttribute)' }), labCode(L.accounts, 'Accounts JSON', 7, function (v) { L.accounts = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Each account: \"source\" (the source name the transform asks for), \"attributes\" (the account\\'s attributes); optional \"nativeIdentity\", \"name\" and \"created\", which accountFilter and the oldest-first rule use.' }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Other transforms (JSON list; used by reference)' }), labCode(L.drafts, 'Other transforms JSON', 4, function (v) { L.drafts = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Drafts with a \"name\", \"type\" and \"attributes\". A reference looks here first, then in your tenant\\'s saved transforms, so you can test a chain before saving any of it.' }),\n el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn));\n w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' }, left, right));\n\n if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));\n var R = L.result;\n if (R) {\n var r = R.result;\n w.appendChild(section('Result', null, el('div', {},\n el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('b', { text: 'Value: ' }), labValue(r.value), labStatus(r.status)),\n r.error ? el('div', { className: 'error', text: r.error }) : null,\n r.assumptions.length ? el('div', { className: 'note' }, el('b', { text: 'Assumed where SailPoint does not document it: ' }), r.assumptions.join(' · ')) : null,\n simpleTable(['Step', 'Transform', 'Input', 'Output', 'Note'], r.trace.map(function (s) {\n return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.type }), s.name || null, s.input === undefined ? null : labValue(s.input), s.error ? pill(s.error, 'lose') : labValue(s.output), s.note || null];\n }), 'How the value was worked out'))));\n }\n renderLabCases(w, L, rr);\n renderLabPeople(w, L, rr);\n }\n function labInput(L, implicit) {\n var input = { implicit: implicit === undefined ? (L.implicit === '' ? undefined : L.implicit) : implicit };\n var id = labParse(L.identity, 'Identity attributes'); if (id) input.identity = id;\n var ac = labParse(L.accounts, 'Accounts'); if (ac) input.accounts = ac;\n return input;\n }\n function labRunTransform(L, rr) {\n L.error = null;\n try {\n var tr = labParse(L.json, 'The transform');\n var cases = L.cases.map(function (c) { return { name: c.name, expected: c.expected, input: labInput(L, c.implicit) }; });\n api('/api/lab/transform/run', 'POST', { transform: tr, input: labInput(L), cases: cases, transforms: labParse(L.drafts, 'Other transforms') }).then(function (r) {\n L.result = r;\n (r.cases || []).forEach(function (x, i) { if (L.cases[i]) L.cases[i].last = x; });\n }, function (e) { L.error = errorText(e); }).then(rr);\n } catch (e) { L.error = e.message; rr(); }\n }\n function renderLabCases(w, L, rr) {\n var addBtn = el('button', { className: 'btn sm', onclick: function () {\n var got = L.result && L.result.result.value;\n L.cases.push({ name: 'Case ' + (L.cases.length + 1), implicit: L.implicit, expected: got === null || got === undefined ? '' : String(got) });\n rr();\n } }, icon('plus'), 'Add the current input as a case');\n var saveBtn = el('button', { className: 'btn sm', disabled: !L.name, onclick: function () {\n api('/api/lab/tests', 'POST', { transform: L.name, cases: L.cases.map(function (c) { return { name: c.name, implicit: c.implicit, expected: c.expected }; }) }).then(function (r) { L.saved = r; toast('Test cases saved on this computer'); }, function (e) { toast(errorText(e)); });\n } }, icon('save'), 'Save cases');\n var passed = L.cases.filter(function (c) { return c.last && c.last.pass; }).length, ran = L.cases.filter(function (c) { return c.last; }).length;\n var body = el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, addBtn, saveBtn, el('span', { className: 'muted small', text: L.name ? 'Saved for \"' + L.name + '\" in your IdentityScope folder.' : 'Give the transform a name to save its cases.' }), el('span', { style: 'flex:1' }), ran ? pill(passed + ' of ' + ran + ' pass', passed === ran ? 'gain' : 'lose') : null));\n if (L.cases.length) {\n body.appendChild(simpleTable(['Case', 'Input value', 'Expected', 'Got', ''], L.cases.map(function (c, i) {\n var n = el('input', { className: 'input', value: c.name, 'aria-label': 'Case name ' + (i + 1) }); n.addEventListener('input', function () { c.name = n.value; });\n var v = el('input', { className: 'input', value: c.implicit || '', 'aria-label': 'Case input ' + (i + 1) }); v.addEventListener('input', function () { c.implicit = v.value; });\n var x = el('input', { className: 'input', value: c.expected || '', 'aria-label': 'Expected value ' + (i + 1) }); x.addEventListener('input', function () { c.expected = x.value; });\n return [n, v, x, c.last ? el('span', {}, pill(c.last.pass ? 'pass' : 'fail', c.last.pass ? 'gain' : 'lose'), ' ', el('code', { text: c.last.got })) : null,\n el('button', { className: 'btn sm', 'aria-label': 'Remove case ' + (i + 1), onclick: function () { L.cases.splice(i, 1); rr(); } }, icon('trash'))];\n }), 'Test cases'));\n body.appendChild(el('p', { className: 'muted small', text: 'Cases use the identity attributes and accounts above with their own input value. Run checks every case.' }));\n }\n w.appendChild(section('Test cases', L.cases.length, body));\n }\n function renderLabPeople(w, L, rr) {\n var H = L.people;\n var count = numSelect(L, 'count', [[50, '50 people'], [200, '200 people'], [500, '500 people'], [2000, '2,000 people']], 'How many people');\n var q = attrInput(L, 'query', 'Which people (search query, optional)', 'attributes.department:Sales');\n var at = attrInput(L, 'attribute', 'Compare with identity attribute (optional)', 'email');\n var go = el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () {\n try { runJobInto(H, '/api/lab/transform/people', { transform: labParse(L.json, 'The transform'), transforms: labParse(L.drafts, 'Other transforms'), attribute: L.attribute || undefined, query: L.query || undefined, count: L.count }, rr); } catch (e) { toast(e.message); }\n } }, icon('people'), 'Run on real people');\n var body = el('div', {}, el('p', { className: 'muted', text: 'Reads real people and their accounts from ISC and works the value out for each, on this computer. With an attribute to compare, it shows where the offline result differs from what ISC holds now: use it before changing a mapping, or to check this engine against your tenant.' }),\n el('div', { className: 'bar', style: 'margin-bottom:12px;align-items:flex-end' }, q, at, el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'How many' }), count), go));\n if (H.busy) body.appendChild(busyBox(H.busy));\n if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.data) {\n var d = H.data, S = d.summary;\n (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });\n body.appendChild(el('div', { className: 'bigstats' }, d.attribute ? stat(S.same, 'same as ISC') : null, d.attribute ? stat(S.different, 'different from ISC', 'lose') : null, stat(S.empty, 'no value'), stat(S.errors, 'errors', 'lose'), stat(S.iscOnly + S.random, 'only ISC can say'), stat(d.people, 'people')));\n if (d.distinct.length) body.appendChild(el('p', { className: 'muted small', text: 'Most common results: ' + d.distinct.slice(0, 8).map(function (x) { return (x.value || '(empty)') + ' × ' + x.people; }).join(', ') }));\n var show = d.attribute ? d.rows.slice().sort(function (a, b) { return (a.same === false ? 0 : 1) - (b.same === false ? 0 : 1); }) : d.rows;\n body.appendChild(filteredTable(H, show, ['Person', d.attribute ? 'In ISC now' : 'Current', 'Offline result', 'Result'], function (r) {\n return [r.person, r.current === undefined ? null : labValue(r.current), labValue(r.result), r.status !== 'ok' ? labStatus(r.status) : d.attribute ? pill(r.same ? 'same' : 'different', r.same ? 'gain' : 'lose') : null];\n }, 'Transform results per person'));\n }\n w.appendChild(section('Try it on real people', null, body));\n }\n\n // Tenant > Workflow lab\n function renderWorkflowLab(w) {\n var L = labState().w, rr = renderBuild;\n labLoadTenant(L, '/api/lab/workflows', rr);\n w.appendChild(el('div', { className: 'note', text: 'Walks a workflow step by step on this computer with a trigger you give it: which branch each condition takes, what each variable becomes and what each action would send. Nothing is called, so the workflow does not need to be disabled. Secrets are never shown.' }));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Workflow' }, el('option', { value: '', text: L.listError ? 'Could not read workflows' : L.list ? 'Pick one of your workflows...' : 'Reading your workflows...' }));\n (L.list || []).forEach(function (x) { pick.appendChild(el('option', { value: x.id, text: x.name + (x.enabled ? '' : ' (disabled)') })); });\n pick.value = L.pick;\n pick.addEventListener('change', function () {\n L.pick = pick.value;\n var x = (L.list || []).filter(function (y) { return y.id === L.pick; })[0];\n if (x) L.json = JSON.stringify(x.definition || {}, null, 2);\n L.help = '';\n L.result = null; L.replay = {}; rr();\n });\n var exPick = el('select', { className: 'input', style: 'max-width:360px', 'aria-label': 'Workflow examples' }, el('option', { value: '', text: 'Or start from an example...' }));\n WORKFLOW_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });\n exPick.addEventListener('change', function () {\n var x = WORKFLOW_EXAMPLES[Number(exPick.value)]; if (!x) return;\n L.pick = ''; L.json = JSON.stringify(x.definition, null, 2); L.trigger = JSON.stringify(TRIGGER_SAMPLES[x.trigger].input, null, 2);\n L.mocks = JSON.stringify(x.mocks || {}, null, 2); L.help = x.help; L.result = null; L.replay = {};\n rr();\n });\n var trPick = el('select', { className: 'input', style: 'max-width:280px', 'aria-label': 'Trigger input samples' }, el('option', { value: '', text: 'Trigger input sample...' }));\n TRIGGER_SAMPLES.forEach(function (x, i) { trPick.appendChild(el('option', { value: String(i), text: x.title })); });\n trPick.addEventListener('change', function () { var x = TRIGGER_SAMPLES[Number(trPick.value)]; if (!x) return; L.trigger = JSON.stringify(x.input, null, 2); L.result = null; rr(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, trPick));\n if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));\n var runBtn = el('button', { className: 'btn primary', onclick: function () {\n L.error = null;\n try {\n api('/api/lab/workflow/simulate', 'POST', { definition: labParse(L.json, 'The definition'), trigger: labParse(L.trigger, 'The trigger') || {}, mocks: labParse(L.mocks, 'Step outputs') || {} }).then(function (r) { L.result = r; }, function (e) { L.error = errorText(e); }).then(rr);\n } catch (e) { L.error = e.message; rr(); }\n } }, icon('play'), 'Simulate');\n w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' },\n el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Definition (JSON: \"start\" and \"steps\")' }), labCode(L.json, 'Workflow definition JSON', 16, function (v) { L.json = v; })),\n el('div', { style: 'flex:1;min-width:300px' }, el('div', { className: 'lbl', text: 'Trigger input (JSON)' }), labCode(L.trigger, 'Trigger JSON', 8, function (v) { L.trigger = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'What the trigger passes in; steps read it as $.trigger. Pick a sample above for the shape SailPoint documents per trigger, or replay a real run to use its actual input.' }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Step outputs to pretend (JSON: step name → output, optional)' }), labCode(L.mocks, 'Step outputs JSON', 4, function (v) { L.mocks = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'For steps that would read ISC or call a system, e.g. {\"Get Identity\": {\"attributes\": {\"manager\": {\"email\": \"x@acme.com\"}}}}. Later steps read it as $.getIdentity (the step name in camel case).' }),\n el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn))));\n if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));\n var R = L.result;\n if (R) {\n var tone = R.outcome === 'success' ? 'ok' : 'bad';\n w.appendChild(el('div', { className: 'banner ' + tone }, el('b', { text: 'Ends in ' + R.outcome + (R.endStep ? ' at \"' + R.endStep + '\"' : '') }), el('span', { text: R.path.join(' → ') })));\n R.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'note', text: x })); });\n if (R.failure) w.appendChild(el('div', { className: 'error', text: R.failure }));\n w.appendChild(section('Steps', R.steps.length, simpleTable(['Step', 'Kind', 'What happens', 'Details', 'Next'], R.steps.map(function (s) {\n var details = s.resolved !== undefined ? s.resolved : s.output;\n return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.step }), s.kind + (s.mocked ? ' (' + s.mocked + ' output)' : ''), el('span', {}, s.note || '', s.warning ? el('div', {}, pill(s.warning, 'lose')) : null), details === undefined ? null : el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: JSON.stringify(details) }), s.next || null];\n }), 'Simulated steps')));\n }\n renderReplay(w, L, rr);\n }\n function renderReplay(w, L, rr) {\n var H = L.replay;\n if (!L.replayCount) L.replayCount = 20;\n var count = numSelect(L, 'replayCount', [[10, 'Last 10 runs'], [20, 'Last 20 runs'], [50, 'Last 50 runs'], [100, 'Last 100 runs']], 'How many runs');\n var go = function (draft) {\n return function () {\n try { runJobInto(H, '/api/lab/workflow/replay', { workflowId: L.pick, count: L.replayCount, definition: draft ? labParse(L.json, 'The definition') : undefined }, rr); } catch (e) { toast(e.message); }\n };\n };\n var body = el('div', {}, el('p', { className: 'muted', text: 'Reads the history of real runs (ISC keeps it for 90 days) and runs each one again here. \"As it ran\" checks the simulator against ISC. \"With my edits\" uses the definition above, so you can see which real runs would now take a different path before you publish.' }),\n el('div', { className: 'bar', style: 'margin-bottom:12px' }, count,\n el('button', { className: 'btn primary', disabled: !L.pick || !!H.busy, onclick: go(false) }, icon('lifecycle'), 'Replay as it ran'),\n el('button', { className: 'btn', disabled: !L.pick || !!H.busy, onclick: go(true) }, icon('play'), 'Replay with my edits'),\n L.pick ? null : el('span', { className: 'muted small', text: 'Pick one of your workflows first.' })));\n if (H.busy) body.appendChild(busyBox(H.busy));\n if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.data) {\n var d = H.data;\n (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });\n body.appendChild(el('div', { className: 'bigstats' }, stat(d.same, d.draft ? 'would take the same path' : 'same path as ISC'), stat(d.total - d.same, d.draft ? 'would take a different path' : 'different from ISC', 'lose'), stat(d.total, 'runs replayed')));\n body.appendChild(filteredTable(H, d.results, ['Started', 'Status in ISC', 'Path in ISC', d.draft ? 'Path with your edits' : 'Simulated path', 'Result'], function (x) {\n return [x.started ? x.started.slice(0, 16).replace('T', ' ') : null, x.status || null, x.realPath.join(' → '), x.simPath.join(' → '), x.same ? pill('same', 'gain') : pill(x.noTrigger ? 'no trigger recorded' : 'different at step ' + ((x.divergence && x.divergence.index + 1) || '?'), 'lose')];\n }, 'Replayed runs'));\n }\n w.appendChild(section('Replay real runs', null, body));\n }\n\n // Tenant > Credential map\n function renderCredentialMap(w) {\n var H = labState().c, rr = rerenderHost;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Every place a client ID, user or endpoint is used in workflows and source connections: a checklist for rotating a secret or promoting to production. Secret values are never read or shown; only whether one is typed in.' }),\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lab/credentials/run', {}, rr); } }, icon('search'), H.data ? 'Read again' : 'Map credentials')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.inline, 'secrets typed into a step or source', 'lose'), stat(T.otherTenant, 'calls to another ISC tenant', T.otherTenant ? 'lose' : undefined), stat(T.thisTenantByName, 'call this tenant by its name (break when promoted)', T.thisTenantByName ? 'lose' : undefined), stat(T.parameterStorage, 'use Parameter Storage'), stat(T.workflowSteps, 'workflow steps with a connection'), stat(T.sources, 'sources with a connection')));\n w.appendChild(section('By credential', d.groups.length, simpleTable(['Target', 'Client ID or user', 'Uses', 'Workflows', 'Sources', 'Secret typed in'], d.groups.map(function (g) {\n return [g.target || '—', g.clientId || g.user || '—', g.uses, g.workflows, g.sources, g.inline ? pill(String(g.inline), 'lose') : 0];\n }), 'Credentials grouped by target')));\n w.appendChild(section('Every use', d.uses.length, filteredTable(H, d.uses, ['Where', 'Name', 'Step', 'Target', 'Client ID or user', 'Secret kept as', 'Notes'], function (u) {\n return [u.where, el('span', {}, u.object, u.objectEnabled === false ? el('div', { className: 'muted small', text: 'disabled' }) : null), u.step || null, u.target || null, u.clientId || u.user || null,\n u.parameterStorage ? pill('Parameter Storage', 'gain') : u.hasSecret ? pill('typed in', 'lose') : 'none', u.flags.length ? el('span', {}, u.flags.map(function (f) { return el('div', { className: 'small', text: f }); })) : null];\n }, 'Credential uses')));\n w.appendChild(el('p', { className: 'muted small', text: 'To rotate: change the secret in the application, then update each place listed here in ISC (or once, in Parameter Storage, for steps that use it). IdentityScope stays read-only and does not change them for you.' }));\n }\n // ---------- Build & test: try changes before making them in ISC (read-only) ----------\n state.bt = { tab: 'tlab', impact: {}, pick: '', policy: { usageType: 'CREATE', person: '' }, health: { days: 30 }, drift: {} };\n // Build & test holds the tools for trying a change before making it. Where transforms and credentials\n // are used and workflow health live on the Tenant page, drift on Audit > Change history, and the role\n // change preview on Role tools: one home each.\n var BUILD_TABS = [\n ['tlab', 'Transform lab', 'sliders'], ['policy', 'Account create preview', 'plus'], ['wlab', 'Workflow lab', 'play'],\n ];\n /** Redraws whichever page the shared tools are on. */\n function rerenderHost() {\n if (state.page === 'tenant') renderTenant();\n else if (state.page === 'certs') renderAudit();\n else renderBuild();\n }\n function renderBuild() {\n var B = state.bt;\n var outer = $('build');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#6d28d9;background:#ede9fe' }, icon('code')),\n el('div', {}, el('h2', { text: 'Build & test' }), el('p', { className: 'desc', text: 'Try changes before you make them in ISC. Everything here runs on this computer or only reads ISC: nothing is created, changed or started.' }))));\n var tabs = el('div', { className: 'tabs' });\n BUILD_TABS.forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (B.tab === t[0] ? ' active' : ''), onclick: function () { B.tab = t[0]; renderBuild(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (!BUILD_TABS.some(function (t) { return t[0] === B.tab; })) B.tab = 'tlab';\n if (B.tab === 'policy') renderPolicyPreview(w);\n else if (B.tab === 'wlab') renderWorkflowLab(w);\n else renderTransformLab(w);\n w.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'Also: where each transform is used (Tenant > Transforms), workflow runs and failures (Tenant > Workflows), where credentials are used (Tenant > Credential map), drift from an approved baseline (Audit > Change history), and who a role change would affect (Role tools > Preview a role change).' }));\n }\n\n // Transform impact\n function renderImpactMap(w) {\n var B = state.bt, H = B.impact;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Before you change a transform: every identity profile, other transform and provisioning policy that uses it, also through other transforms, and how many people that covers. Also lists transforms nothing uses.' }),\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/impact/run', {}, rerenderHost); } }, icon('search'), H.data ? 'Read again' : 'Find where transforms are used')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.transforms.length, 'transforms'), stat(d.unused.length, 'used by nothing', d.unused.length ? 'lose' : undefined), stat(d.profiles.length, 'identity profiles'), stat(d.policiesRead, 'provisioning policies read')));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Transform' }, el('option', { value: '', text: 'Pick a transform to see where it is used...' }));\n d.transforms.forEach(function (t) { pick.appendChild(el('option', { value: t.name, text: t.name + ' (' + t.uses.length + ' use' + (t.uses.length === 1 ? '' : 's') + ')' })); });\n pick.value = B.pick;\n pick.addEventListener('change', function () { B.pick = pick.value; rerenderHost(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:12px' }, pick));\n var t = d.transforms.filter(function (x) { return x.name === B.pick; })[0];\n if (t) {\n var people = t.people === null ? 'an unknown number of' : fmtNum(t.people);\n w.appendChild(el('div', { className: 'banner ' + (t.uses.length ? 'bad' : 'ok') }, el('b', { text: t.uses.length ? 'Changing \"' + t.name + '\" affects ' + t.uses.length + ' place' + (t.uses.length === 1 ? '' : 's') : '\"' + t.name + '\" is not used anywhere IdentityScope can see' }),\n t.uses.length ? el('span', { text: t.people ? ' · identity attributes of ' + people + ' people' : '' }) : null));\n if (t.uses.length) w.appendChild(section('Where \"' + t.name + '\" is used', t.uses.length, simpleTable(['Used by', 'Where', 'Attribute or field', 'How'], t.uses.map(function (u) {\n return [u.kind, u.where, u.detail || null, u.via.length ? 'through ' + u.via.join(' → ') : 'directly'];\n }), 'Uses of the transform')));\n }\n if (d.unused.length) w.appendChild(section('Used by nothing', d.unused.length, el('p', { className: 'muted', text: d.unused.join(', ') + '. Check rules before deleting: a rule can use a transform in its own code.' })));\n w.appendChild(section('All transforms', d.transforms.length, filteredTable(H, d.transforms, ['Transform', 'Type', 'Used directly', 'All uses', 'People'], function (x) {\n return [el('button', { className: 'linkbtn', text: x.name, onclick: function () { B.pick = x.name; rerenderHost(); } }), x.type, x.direct, x.uses.length ? x.uses.length : pill('not used', 'lose'), x.people === null ? null : x.people];\n }, 'Transforms and their uses')));\n }\n\n // Account create preview\n function renderPolicyPreview(w) {\n var P = state.bt.policy;\n if (!P.sources && !P.loading) {\n P.loading = true;\n api('/api/build/sources').then(function (r) { P.sources = r; }, function (e) { P.sourcesError = errorText(e); }).then(function () { P.loading = false; if (state.bt.tab === 'policy') renderBuild(); });\n }\n w.appendChild(el('div', { className: 'note', text: 'What a source\\'s create policy would produce for one person, worked out on this computer with the Transform lab engine. Nothing is created. Use it to check a new or changed policy before the next joiner, or why a create failed.' }));\n var src = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Source' }, el('option', { value: '', text: P.sourcesError ? 'Could not read sources' : P.sources ? 'Pick a source...' : 'Reading sources...' }));\n (P.sources || []).forEach(function (s) { src.appendChild(el('option', { value: s.id, text: s.name })); });\n src.value = P.sourceId || '';\n src.addEventListener('change', function () { P.sourceId = src.value; });\n var use = el('select', { className: 'input', style: 'max-width:160px', 'aria-label': 'Policy' });\n ['CREATE', 'UPDATE', 'ENABLE', 'DISABLE', 'CHANGE_PASSWORD'].forEach(function (u) { use.appendChild(el('option', { value: u, text: u === 'CREATE' ? 'Create account' : u.charAt(0) + u.slice(1).toLowerCase().replace('_', ' ') })); });\n use.value = P.usageType;\n use.addEventListener('change', function () { P.usageType = use.value; });\n var who = el('input', { className: 'input', value: P.person, placeholder: 'Username, email or display name', style: 'max-width:280px', 'aria-label': 'Person' });\n who.addEventListener('input', function () { P.person = who.value; });\n who.addEventListener('keydown', function (e) { if (e.key === 'Enter') go.click(); });\n var go = el('button', { className: 'btn primary', disabled: !!P.busy, onclick: function () {\n if (!P.sourceId) { toast('Pick a source first'); return; }\n if (!P.person.trim()) { toast('Name the person first'); return; }\n runJobInto(P, '/api/build/policy/run', { sourceId: P.sourceId, usageType: P.usageType, person: P.person }, renderBuild);\n } }, icon('play'), 'Preview');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, src, use, who, go));\n if (P.busy) { w.appendChild(busyBox(P.busy)); return; }\n if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }\n if (!P.data) return;\n var d = P.data;\n d.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'banner bad' }, el('span', { text: x }))); });\n if (!d.fields.length) return;\n w.appendChild(el('p', { className: 'muted', text: d.source + ' · ' + (d.policy || d.usageType) + (d.person ? ' · for ' + d.person.name : '') }));\n w.appendChild(section('Fields', d.fields.length, simpleTable(['Field', 'Required', 'Value', 'Result', 'Note'], d.fields.map(function (f) {\n return [el('code', { text: f.field }), f.required ? 'yes' : null, f.status === 'ok' || f.status === 'random' ? labValue(f.value) : null,\n f.status === 'none' ? pill('not set here', 'keep-other') : f.status === 'hidden' ? pill('hidden', 'keep-other') : labStatus(f.status), f.error || f.note || null];\n }), 'Account fields')));\n if (d.assumptions.length) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'Assumed: ' }), d.assumptions.join(' · ')));\n }\n\n // Workflow health\n function weekBars(weeks) {\n var max = Math.max.apply(null, weeks.map(function (x) { return x.runs; }).concat([1]));\n var label = weeks.map(function (x, i) { return 'week ' + (i + 1) + ': ' + x.failed + ' failed of ' + x.runs; }).join(', ');\n var box = el('span', { className: 'wkbars', role: 'img', 'aria-label': label, title: label });\n weeks.forEach(function (x) {\n var h = x.runs ? Math.max(3, Math.round(22 * x.runs / max)) : 2;\n var bar = el('span', { className: 'wkbar', style: 'height:' + h + 'px' });\n if (x.failed) bar.appendChild(el('span', { className: 'wkfail', style: 'height:' + Math.max(2, Math.round(h * x.failed / x.runs)) + 'px' }));\n box.appendChild(bar);\n });\n return box;\n }\n function renderWorkflowHealth(w) {\n var H = state.bt.health;\n var days = numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [60, 'Last 60 days'], [90, 'Last 90 days']], 'Period');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Runs and failures of every workflow per week, and why runs failed, grouped: the same error with different IDs or names counts as one cause.' }),\n days, el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/health/run', { days: H.days }, rerenderHost); } }, icon('heart'), H.data ? 'Read again' : 'Check workflow health')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var rate = T.runs ? Math.round(1000 * T.failed / T.runs) / 10 : null;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.runs, 'runs'), stat(T.failed, 'failed', T.failed ? 'lose' : undefined), stat(rate, 'failure rate (%)'), stat(T.failingEveryRun, 'fail every run', T.failingEveryRun ? 'lose' : undefined), stat(T.worse, 'failing more this week', T.worse ? 'lose' : undefined), stat(T.quiet, 'enabled, never ran')));\n w.appendChild(section('Workflows', d.workflows.length, filteredTable(H, d.workflows, ['Workflow', 'Runs', 'Failed', 'Failure rate', 'Per week (grey: runs, red: failed)', 'Last run', 'Flags', 'Most common cause'], function (x) {\n return [el('span', {}, x.name, el('div', { className: 'muted small', text: [x.enabled ? null : 'disabled', x.trigger, x.owner ? 'owner ' + x.owner : null].filter(Boolean).join(' · ') })), x.failedOnly ? '—' : x.runs, x.failed, x.rate === null ? null : x.rate + '%', weekBars(x.weeks), x.lastRun ? x.lastRun.slice(0, 16).replace('T', ' ') + (x.lastStatus ? ' · ' + x.lastStatus : '') : null,\n x.flags.length ? el('span', {}, x.flags.map(function (f) { return el('div', {}, pill(f, /Enabled/.test(f) ? 'keep-other' : 'lose')); })) : null, x.topCause || null];\n }, 'Workflow health')));\n if (d.causes.length) w.appendChild(section('Why runs failed', d.causes.length, simpleTable(['Workflow', 'Step', 'Cause', 'Runs', 'Last'], d.causes.map(function (c) {\n return [c.workflow, c.step || null, el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: c.cause }), c.runs, c.last.slice(0, 16).replace('T', ' ')];\n }), 'Failure causes')));\n }\n\n // Drift check\n function renderDrift(w) {\n var D = state.bt.drift;\n if (!D.info && !D.loading) {\n D.loading = true;\n api('/api/build/drift').then(function (r) { D.info = r; }, function (e) { D.infoError = errorText(e); }).then(function () { D.loading = false; if (state.bt.tab === 'drift') rerenderHost(); });\n }\n w.appendChild(el('div', { className: 'note', text: 'Approve a configuration snapshot as the baseline (for example the day a release went live), then check at any time what changed since: sources, transforms, identity profiles, roles, access profiles and workflows added, removed or changed outside a release. The baseline is kept on this computer.' }));\n if (D.infoError) { w.appendChild(el('div', { className: 'error', text: D.infoError })); return; }\n if (!D.info) { w.appendChild(busyBox('Reading saved snapshots...')); return; }\n var I = D.info;\n var reload = function () { D.info = null; rerenderHost(); };\n var takeSnap = el('button', { className: 'btn', disabled: !!D.snapBusy, onclick: function () {\n D.snapBusy = 'Taking a snapshot...'; rerenderHost();\n api('/api/changes/snapshot', 'POST', {}).then(function (r) {\n pollJob(r.job, function (p) { D.snapBusy = p; rerenderHost(); }, function () { D.snapBusy = null; toast('Snapshot saved'); reload(); }, function (e) { D.snapBusy = null; toast(e); rerenderHost(); });\n }, function (e) { D.snapBusy = null; toast(errorText(e)); rerenderHost(); });\n } }, icon('save'), D.snapBusy ? D.snapBusy : 'Take a snapshot now');\n if (!I.baseline || D.changing) {\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: I.baseline ? 'Change the baseline' : 'Approve a baseline' })));\n if (!I.days.length) {\n card.appendChild(el('p', { className: 'muted', text: 'There is no configuration snapshot yet. Take one now (it reads the configuration; nothing changes in ISC), then approve it.' }));\n card.appendChild(el('div', { className: 'bar' }, takeSnap));\n } else {\n var day = el('select', { className: 'input', style: 'max-width:200px', 'aria-label': 'Snapshot day' });\n I.days.forEach(function (x) { day.appendChild(el('option', { value: x, text: x })); });\n var note = el('input', { className: 'input', placeholder: 'Note, e.g. Release 2026.12 to production', style: 'max-width:360px', 'aria-label': 'Note' });\n card.appendChild(el('div', { className: 'bar' }, day, note,\n el('button', { className: 'btn primary', onclick: function () {\n api('/api/build/drift/baseline', 'POST', { day: day.value, note: note.value }).then(function () { D.changing = false; D.data = null; toast('Baseline approved'); reload(); }, function (e) { toast(errorText(e)); });\n } }, icon('save'), 'Approve as baseline'), takeSnap,\n D.changing ? el('button', { className: 'btn', onclick: function () { D.changing = false; rerenderHost(); } }, 'Cancel') : null));\n }\n w.appendChild(card);\n return;\n }\n var b = I.baseline;\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Baseline: ' + b.day })),\n el('p', { className: 'muted', text: (b.note ? b.note + ' · ' : '') + 'approved by ' + b.by + ' on ' + b.approvedAt.slice(0, 16).replace('T', ' ') }),\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', disabled: !!D.busy, onclick: function () { runJobInto(D, '/api/build/drift/run', {}, rerenderHost); } }, icon('cols'), 'Check for drift now'),\n el('button', { className: 'btn', onclick: function () { D.changing = true; rerenderHost(); } }, 'Change baseline'),\n el('button', { className: 'btn', onclick: function () { api('/api/build/drift/baseline', 'POST', { day: '' }).then(function () { D.data = null; reload(); }); } }, icon('trash'), 'Remove'))));\n if (D.busy) { w.appendChild(busyBox(D.busy)); return; }\n if (D.error) { w.appendChild(el('div', { className: 'error', text: D.error })); return; }\n if (!D.data) return;\n var d = D.data, T = d.totals, any = T.added + T.removed + T.changed;\n w.appendChild(el('div', { className: 'banner ' + (any ? 'bad' : 'ok') }, el('b', { text: any ? any + ' change' + (any === 1 ? '' : 's') + ' since the baseline' : 'No drift: the configuration matches the baseline' })));\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.added, 'added', T.added ? 'lose' : undefined), stat(T.removed, 'removed', T.removed ? 'lose' : undefined), stat(T.changed, 'changed', T.changed ? 'lose' : undefined), stat(T.same, 'unchanged')));\n d.kinds.forEach(function (k) {\n if (k.error) { w.appendChild(el('div', { className: 'note', text: k.label + ': ' + k.error })); return; }\n var n = k.onlyA.length + k.onlyB.length + k.different.length;\n if (!n) return;\n var body = el('div', {});\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Added: ' }), k.onlyB.join(', ')));\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Removed: ' }), k.onlyA.join(', ')));\n if (k.different.length) body.appendChild(simpleTable(['Name', 'Setting', 'At the baseline', 'Now'], k.different.flatMap(function (x) {\n return x.differences.map(function (f, i) { return [i ? '' : x.name, el('code', { text: f.path || '(whole object)' }), f.a, f.b]; });\n }), k.label + ' changed since the baseline'));\n w.appendChild(section(k.label, n, body));\n });\n w.appendChild(el('div', { className: 'bar', style: 'margin-top:10px' }, downloads(D.job)));\n }\n // ---------- Worked examples for the Transform lab and the Workflow lab ----------\n // Each transform example fills every box: the transform, the input value, identity attributes,\n // accounts and, for references, the other transforms it uses. Values are made up.\n var LAB_HR_ACCOUNT = { source: 'Workday', nativeIdentity: '100234', created: '2024-03-01T09:00:00Z', attributes: { firstName: 'José', lastName: 'García Núñez', department: 'FIN', workerType: 'Employee', startDate: '2025-01-06', email: 'jose.garcia@acme.com' } };\n var LAB_AD_ACCOUNTS = [\n { source: 'Active Directory', nativeIdentity: 'CN=adm_jgarcia,OU=Admins,DC=acme,DC=com', name: 'adm_jgarcia', created: '2024-02-01T09:00:00Z', attributes: { sAMAccountName: 'adm_jgarcia', mail: 'adm_jgarcia@acme.com' } },\n { source: 'Active Directory', nativeIdentity: 'CN=jgarcia,OU=Users,DC=acme,DC=com', name: 'jgarcia', created: '2024-03-02T09:00:00Z', attributes: { sAMAccountName: 'jgarcia', mail: 'jose.garcia@acme.com' } },\n ];\n var LAB_IDENTITY = { firstname: 'José', lastname: 'García Núñez', department: 'Finance', email: 'jose.garcia@acme.com' };\n var CLEAN_NAME = { name: 'Clean Name', type: 'lower', attributes: { input: { type: 'replace', attributes: { regex: '[^A-Za-z]', replacement: '', input: { type: 'decomposeDiacriticalMarks', attributes: {} } } } } };\n var TRANSFORM_EXAMPLES = [\n {\n title: 'Account attribute from one source',\n help: 'accountAttribute reads a value from the person\\'s account on a source. Put the account in the Accounts box: \"source\" is the source name the transform asks for, \"attributes\" are the account\\'s attributes.',\n transform: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'department' } },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'Pick one of several accounts',\n help: 'With more than one account on a source, ISC takes the oldest unless you filter or sort. Here accountFilter skips the admin account. Remove the filter and run again to see the admin account picked instead.',\n transform: { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith(\"CN=adm_\"))' } },\n accounts: LAB_AD_ACCOUNTS,\n },\n {\n title: 'Use another transform (reference)',\n help: 'A reference runs another transform by name. IdentityScope looks for it first in Other transforms (your drafts), then in the tenant\\'s saved transforms, so you can test a change to \"Clean Name\" before saving it. The trace shows the referenced steps indented.',\n transform: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'lastName' } } } },\n accounts: [LAB_HR_ACCOUNT],\n drafts: [CLEAN_NAME],\n },\n {\n title: 'Chain of transforms: email from names',\n help: 'Builds an email from first and last name, each cleaned by the \"Clean Name\" transform, with the domain picked from the department by a second transform, \"Email Domain\". Change \"Clean Name\" under Other transforms and run again: every transform that uses it changes too.',\n transform: {\n type: 'static',\n attributes: {\n fn: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'firstname' } } } },\n ln: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'lastname' } } } },\n domain: { type: 'reference', attributes: { id: 'Email Domain', input: { type: 'identityAttribute', attributes: { name: 'department' } } } },\n value: '$fn.$ln@$domain',\n },\n },\n identity: LAB_IDENTITY,\n drafts: [CLEAN_NAME, { name: 'Email Domain', type: 'lookup', attributes: { table: { Finance: 'acme.com', Research: 'labs.acme.com', default: 'acme.com' } } }],\n },\n {\n title: 'Lifecycle state from HR dates',\n help: 'The classic joiner criteria: \"active\" from the start date on, \"prehire\" before. Change startDate in the account to a future date and run again. Dates are compared in GMT, as ISC does.',\n transform: {\n type: 'dateCompare',\n attributes: {\n firstDate: { type: 'dateFormat', attributes: { inputFormat: 'yyyy-MM-dd', outputFormat: 'ISO8601', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'startDate' } } } },\n secondDate: 'now',\n operator: 'LTE',\n positiveCondition: 'active',\n negativeCondition: 'prehire',\n },\n },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'Lookup table with a default',\n help: 'lookup turns a code into a name. The input value box is what the identity profile mapping passes in; try \"RND\" and then a code that is not in the table to see the default.',\n transform: { type: 'lookup', attributes: { table: { FIN: 'Finance', RND: 'Research', OPS: 'Operations', default: 'Unknown department' } } },\n implicit: 'FIN',\n },\n {\n title: 'Conditional on an account value',\n help: 'conditional compares two values with \"eq\" and returns one of two results. The variable $type is defined in the attributes from the HR account.',\n transform: { type: 'conditional', attributes: { type: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'workerType' } }, expression: '$type eq Employee', positiveCondition: 'E', negativeCondition: 'C' } },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'First value that exists',\n help: 'firstValid returns the first value that is not empty: here the AD mail, then the HR email, then a fixed text. Empty the Accounts box to see the fallback.',\n transform: { type: 'firstValid', attributes: { values: [\n { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith(\"CN=adm_\"))' } },\n { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'email' } },\n 'no-email@acme.com',\n ], ignoreErrors: true } },\n accounts: [LAB_HR_ACCOUNT].concat(LAB_AD_ACCOUNTS),\n },\n ];\n\n // Workflow examples: a definition, a trigger input in the shape SailPoint documents for that trigger,\n // and outputs to pretend for steps that would call ISC or another system.\n var TRIGGER_SAMPLES = [\n { title: 'Identity Attributes Changed', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }, { attribute: 'department', oldValue: 'Sales', newValue: 'Marketing' }] } },\n { title: 'Identity Created', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, attributes: { firstname: 'William', lastname: 'Wilson', email: 'william.wilson@acme.com', department: 'Sales', cloudLifecycleState: 'prehire' } } },\n { title: 'Access Request Submitted', input: { accessRequestId: '2c91808b6ef1d43e016efba0ce470904', requestedFor: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'William Wilson' }, requestedItems: [{ id: '2c91808b6ef1d43e016efba0ce470905', name: 'Engineering Access', description: 'Access to engineering database', type: 'ACCESS_PROFILE', operation: 'Add', comment: 'Needed for the project.' }], requestedBy: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1314', name: 'Rob Robertson' } } },\n { title: 'Account Aggregation Completed', input: { source: { type: 'SOURCE', id: '2c9180835d191a86015d28455b4b232a', name: 'HR Source' }, status: 'Error', started: '2026-11-20T22:01:50.474Z', completed: '2026-11-20T22:02:04.090Z', errors: ['Accounts unable to be aggregated.'], warnings: ['Account Skipped'], stats: { scanned: 200, unchanged: 190, changed: 6, added: 4, removed: 3 } } },\n { title: 'Scheduled or external (empty)', input: {} },\n ];\n var WORKFLOW_EXAMPLES = [\n {\n title: 'Leaver: open a ticket when someone becomes inactive',\n help: 'The comparison reads the changed lifecycle state with a JSONPath filter. Change \"newValue\" in the trigger to \"active\" and simulate again: the workflow takes the other branch and ends without the ticket.',\n trigger: 0,\n definition: { start: 'Is Leaver', steps: {\n 'Is Leaver': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.changes[?(@.attribute == \"cloudLifecycleState\")].newValue', variableB: 'inactive', nextStep: 'Get Identity' }], defaultStep: 'End - Not a leaver' },\n 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Open Ticket', type: 'action', versionNumber: 2 },\n 'Open Ticket': { actionId: 'sp:http', attributes: { method: 'post', url: 'https://acme.service-now.com/api/now/table/incident', authenticationType: 'OAuth', jsonRequestBody: { short_description: 'Leaver: {{$.getIdentity.attributes.displayName}}', manager: '{{$.getIdentity.attributes.manager.name}}' } }, nextStep: 'End - Ticket opened', type: 'action', versionNumber: 3 },\n 'End - Ticket opened': { type: 'success' },\n 'End - Not a leaver': { type: 'success' },\n } },\n mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson' } } } },\n },\n {\n title: 'Joiner: welcome email with a built variable',\n help: 'Define Variable builds a value from the trigger (here the first letter of the first name and the last name). Steps that read ISC, like Get Identity, are pretended with the output in the third box: edit it to try another person.',\n trigger: 1,\n definition: { start: 'Get Identity', steps: {\n 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Define Variable', type: 'action', versionNumber: 2 },\n 'Define Variable': { actionId: 'sp:define-variable', attributes: { id: 'sp:define-variable', variables: [{ name: 'Login', 'variableA.$': '$.trigger.attributes.firstname', transforms: [{ id: 'sp:transform:substring:string', input: { start: 0, length: 1 } }, { id: 'sp:transform:concatenate:string', input: { 'variableB.$': '$.trigger.attributes.lastname' } }, { id: 'sp:transform:lower:string', input: {} }] }] }, nextStep: 'Has Manager', type: 'Mutation' },\n 'Has Manager': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.getIdentity.attributes.manager.email', variableB: '', nextStep: 'End - No manager' }], defaultStep: 'Send Email' },\n 'Send Email': { actionId: 'sp:send-email', attributes: { 'recipientEmailList.$': '$.getIdentity.attributes.manager.email', subject: 'Welcome {{$.trigger.attributes.firstname}}', body: 'Login: {{$.defineVariable.login}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },\n 'End': { type: 'success' },\n 'End - No manager': { type: 'failure' },\n } },\n mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson', email: 'rob.robertson@acme.com' } } } },\n },\n {\n title: 'Loop over every changed attribute',\n help: 'A loop runs its own steps once per item; inside it, the item is $.loop.loopInput. The simulator runs the first five items and shows each one.',\n trigger: 0,\n definition: { start: 'For Each Change', steps: {\n 'For Each Change': { actionId: 'sp:loop:iterator', attributes: { 'input.$': '$.trigger.changes', start: 'Is Department', steps: {\n 'Is Department': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.loop.loopInput.attribute', variableB: 'department', nextStep: 'Notify' }], defaultStep: 'Skip' },\n 'Notify': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Department changed to {{$.loop.loopInput.newValue}}' }, nextStep: 'Done', type: 'action', versionNumber: 2 },\n 'Done': { type: 'success' },\n 'Skip': { type: 'success' },\n } }, nextStep: 'End', type: 'action', versionNumber: 1 },\n 'End': { type: 'success' },\n } },\n mocks: {},\n },\n {\n title: 'Alert when an aggregation fails',\n help: 'Uses the Account Aggregation Completed trigger. Set \"status\" in the trigger to \"Success\" and simulate again: no email.',\n trigger: 3,\n definition: { start: 'Failed?', steps: {\n 'Failed?': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.status', variableB: 'Error', nextStep: 'Alert' }], defaultStep: 'End' },\n 'Alert': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Aggregation of {{$.trigger.source.name}} failed', body: '{{$.trigger.errors}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },\n 'End': { type: 'success' },\n } },\n mocks: {},\n },\n ];\n // ---------- Quick finder: every page, tab and report in one search (Ctrl+K) ----------\n // Each entry: [label, where it is, extra words people search for, how to go there].\n function finderEntries() {\n var go = function (page, set) { return function () { if (set) set(); showPage(page); }; };\n var tab = function (obj, key, id) { return function () { obj()[key] = id; }; };\n var list = [\n ['Reports', 'All reports, by category', 'library run schedule export', go('reports')],\n ['Instant check', 'Health tiles for the whole tenant', 'dashboard tiles health status overview', go('checks')],\n ['Schedules', 'Reports sent by email or chat on a schedule', 'email teams slack webhook daily weekly', go('schedules')],\n ];\n var add = function (page, pageLabel, holder, key, tabs) {\n tabs.forEach(function (t) { list.push([t[1], pageLabel + ' > ' + t[1], (t[2] || '') + ' ' + pageLabel, go(page, tab(holder, key, t[0]))]); });\n };\n add('warnings', 'Warnings', wnState, 'tab', WN_TABS.map(function (t) { return [t[0], t[1], t[3]]; }));\n add('lookup', 'Lookup', function () { return state.lk; }, 'tab', [['person', 'Person', 'user identity everything one person has accounts access requests events'], ['source', 'Source', 'application connector errors aggregation'], ['ownership', 'Ownership', 'owners owner left without owner']]);\n add('tenant', 'Tenant', function () { return state.tn; }, 'tab', [\n ['overview', 'Overview', 'counts sources identities size'], ['clusters', 'Virtual Appliances', 'va cluster health'],\n ['workflows', 'Workflows', 'workflow health runs failures failed causes errors trends'], ['transforms', 'Transforms', 'transform impact where used unused references provisioning policies'],\n ['credentials', 'API credentials', 'pat personal access token oauth client expiry expiring'], ['cmap', 'Credential map', 'client id secret rotate promote parameter storage servicenow http'],\n ['compare', 'Compare tenants', 'sandbox production diff rules cloud rules connector rules promote'], ['rules', 'Rule usage', 'unused rules cleanup connector rule cloud rule where used missing']]);\n add('logs', 'Logs', lgState, 'tab', LG_TABS.map(function (t) { return [t[0], t[1], t[3] + ' log ccg virtual appliance va connector error aggregation']; }));\n add('nerm', 'Non-employees', nmState, 'tab', NM_TABS.map(function (t) { return [t[0], t[1], t[3] + ' nerm contractor vendor sponsor non-employee risk management']; }));\n add('build', 'Build & test', function () { return state.bt; }, 'tab', BUILD_TABS.map(function (t) {\n return [t[0], t[1], { tlab: 'transform test velocity offline try draft reference account attribute', policy: 'provisioning policy create account preview joiner fields', wlab: 'workflow simulate trigger replay test without disabling' }[t[0]]];\n }));\n add('certs', 'Audit', function () { return state.au; }, 'tab', [\n ['certs', 'Certifications', 'campaigns reviewers progress rubber stamp'], ['outmodel', 'Outside roles', 'entitlements not assigned via roles direct access standalone birthright outside the model'], ['composition', 'What is in every role', 'role composition entitlements by role access profiles breakdown export'], ['reassigned', 'Reassigned reviews', 'certification reassignment forwarded delegated reviewer'], ['sod', 'Separation of duties', 'sod toxic conflicts rules'],\n ['coverage', 'Review coverage', 'certified access never reviewed'], ['outliers', 'Access outliers', 'peer unusual compared with peers'],\n ['speed', 'Provisioning speed', 'slow removals how long'], ['adminaccts', 'Admin accounts', 'privileged admin service test accounts linked'],\n ['exceptions', 'Exceptions', 'accepted risk exception register'], ['trail', 'Request trail', 'access request approvals approver comment decision audit history who approved'], ['chain', 'Approver chain', 'approval schemes who approves governance group revoke approval'], ['leavertimes', 'Leaver removal times', 'termination leaver sla disabled how long per person'], ['attrhist', 'Attribute changes', 'manager change department title history who changed'], ['owners', 'Entitlement owners', 'owner review holders who has my entitlement'], ['changes', 'Change history', 'snapshot drift baseline approved release what changed'],\n ['evidence', 'Evidence pack', 'auditor zip excel evidence']]);\n add('roles', 'Role tools', function () { return state; }, 'roleTab', [['compare', 'Compare roles', 'role differences'], ['impact', 'Preview a role change', 'criteria membership who gains loses simulate'], ['mining', 'Find candidate roles', 'role mining common access']]);\n add('monthly', 'Insights', function () { return state.inz; }, 'tab', [['monthly', 'Monthly report', 'management summary trend'], ['reclaim', 'License reclaim', 'cost dormant licenses save money'], ['requests', 'Access requests', 'approvers requested reject rate']]);\n (state.reports || []).forEach(function (r) {\n var d = r.definition || r;\n if (!d || !d.name) return;\n list.push([d.name, 'Report · ' + (d.category || ''), (d.description || '') + ' ' + (d.tags || []).join(' '), function () { showPage('reports'); loadLibrary(d.id); }]);\n });\n return list;\n }\n function finderScore(e, words) {\n var name = String(e[0]).toLowerCase(), hay = (e[0] + ' ' + e[1] + ' ' + (e[2] || '')).toLowerCase(), score = 0;\n for (var i = 0; i < words.length; i++) {\n var w = words[i];\n if (hay.indexOf(w) < 0) return -1;\n score += name.indexOf(w) === 0 ? 6 : name.indexOf(w) >= 0 ? 4 : String(e[1]).toLowerCase().indexOf(w) >= 0 ? 2 : 1;\n }\n return score;\n }\n function openFinder() {\n if ($('btn-help').classList.contains('hidden') || document.querySelector('.finder')) return;\n var entries = finderEntries(), sel = 0, shown = [];\n var before = document.activeElement;\n var input = el('input', { className: 'input', placeholder: 'Find a page, tab or report...', 'aria-label': 'Find a page, tab or report', role: 'combobox', 'aria-expanded': 'true', 'aria-controls': 'finder-list', autocomplete: 'off' });\n var listBox = el('ul', { id: 'finder-list', role: 'listbox', className: 'finder-list', 'aria-label': 'Matches' });\n var back = el('div', { className: 'finder-back' });\n var box = el('div', { className: 'finder', role: 'dialog', 'aria-modal': 'true', 'aria-label': 'Find' }, input, listBox,\n el('div', { className: 'muted small', style: 'padding:8px 12px', text: '↑ ↓ to move, Enter to open, Esc to close' }));\n back.appendChild(box);\n var close = function () { back.remove(); if (before && before.focus) before.focus(); };\n var pick = function (e) { close(); e[3](); };\n var draw = function () {\n var words = input.value.toLowerCase().split(/\\s+/).filter(Boolean);\n shown = words.length ? entries.map(function (e) { return [finderScore(e, words), e]; }).filter(function (x) { return x[0] >= 0; }).sort(function (a, b) { return b[0] - a[0] || String(a[1][0]).length - String(b[1][0]).length; }).slice(0, 12).map(function (x) { return x[1]; }) : entries.slice(0, 12);\n sel = Math.min(sel, Math.max(0, shown.length - 1));\n listBox.textContent = '';\n shown.forEach(function (e, i) {\n var li = el('li', { id: 'finder-opt-' + i, role: 'option', className: 'finder-opt' + (i === sel ? ' active' : ''), 'aria-selected': i === sel ? 'true' : 'false' }, el('b', { text: e[0] }), el('span', { className: 'muted small', text: e[1] }));\n li.addEventListener('mousedown', function (ev) { ev.preventDefault(); pick(e); });\n listBox.appendChild(li);\n });\n if (!shown.length) listBox.appendChild(el('li', { className: 'muted', style: 'padding:10px 12px', text: 'Nothing matches.' }));\n input.setAttribute('aria-activedescendant', shown.length ? 'finder-opt-' + sel : '');\n };\n input.addEventListener('input', function () { sel = 0; draw(); });\n input.addEventListener('keydown', function (ev) {\n if (ev.key === 'ArrowDown') { sel = Math.min(sel + 1, shown.length - 1); draw(); ev.preventDefault(); }\n else if (ev.key === 'ArrowUp') { sel = Math.max(sel - 1, 0); draw(); ev.preventDefault(); }\n else if (ev.key === 'Enter' && shown[sel]) { pick(shown[sel]); ev.preventDefault(); }\n else if (ev.key === 'Escape') { close(); ev.preventDefault(); }\n });\n back.addEventListener('mousedown', function (ev) { if (ev.target === back) close(); });\n document.body.appendChild(back);\n draw();\n input.focus();\n }\n document.addEventListener('keydown', function (ev) {\n if ((ev.ctrlKey || ev.metaKey) && !ev.altKey && (ev.key === 'k' || ev.key === 'K')) { ev.preventDefault(); openFinder(); }\n });\n // ---------- 0.22.0: access request audit trail, approver chain, accounts expiring, revokes not done, person timeline ----------\n function gvState() {\n if (!state.gv) state.gv = { trail: { days: 30, item: '', person: '' }, chain: {}, expiry: { days: 30, attribute: 'accountExpires', sourceIds: [] }, revokes: { days: 90 } };\n return state.gv;\n }\n function gvRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/warnings/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function gvText(H, key, label, placeholder) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder, style: 'max-width:200px', 'aria-label': label });\n i.addEventListener('input', function () { H[key] = i.value; });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function gvTime(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }\n var GV_DECISION = { APPROVED: 'win', REJECTED: 'lose', PENDING: 'off', EXPIRED: 'lose', CANCELLED: 'off' };\n var GV_OUTCOME = { completed: ['completed', 'win'], rejected: ['rejected', 'lose'], cancelled: ['cancelled', 'off'], failed: ['failed', 'lose'], open: ['in progress', 'off'] };\n\n // Audit > Request trail\n function renderRequestTrail(w) {\n var H = gvState().trail;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Submitted in the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Period')),\n gvText(H, 'item', 'Access item contains', 'e.g. VPN'), gvText(H, 'person', 'Person contains', 'requester or recipient'));\n if (!gvRunBar(w, H, 'request-trail', 'Build the trail', 'Every access request with each approval step: who decided, the decision, their comment and when, and how provisioning ended. One row per step in the download, ready for auditors.', extras,\n function () { return { days: H.days, item: H.item || undefined, person: H.person || undefined }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.requests, 'requests'), stat(T.completed, 'completed'), stat(T.rejected, 'rejected', 'lose'), stat(T.failed, 'failed', 'lose'), stat(T.open, 'in progress'), stat(T.withoutApproval, 'without an approval step'),\n stat(T.decisions ? Math.round(T.decisionsWithComment * 100 / T.decisions) : 0, '% of decisions with a comment')));\n if (!d.requests.length) return;\n if ((d.approvers || []).length) w.appendChild(section('How fast approvers decide', d.approvers.length, simpleTable(['Approver', 'Decisions', 'Usual time', 'Slowest', 'Waiting now', 'Oldest waiting'], d.approvers.slice(0, 200).map(function (a) {\n return [a.approver, fmtNum(a.decided), hrs(a.medianHours), hrs(a.slowestHours), a.waiting ? pill(String(a.waiting), 'lose') : '0', a.oldestWaitingDays === null ? '—' : a.oldestWaitingDays + ' days'];\n }), 'How fast approvers decide')));\n var rows = d.requests.map(function (r) {\n var o = GV_OUTCOME[r.outcome] || [r.outcome, 'off'];\n var steps = r.steps.length ? el('div', {}, r.steps.map(function (s) {\n return el('div', { style: 'margin:2px 0' }, el('b', { text: s.step + '. ' }), s.approver || '?', s.originalApprover ? el('span', { className: 'muted', text: ' (was ' + s.originalApprover + ')' }) : null, ' ',\n pill(s.decision.toLowerCase(), GV_DECISION[s.decision] || 'off'), s.decided ? el('span', { className: 'muted small', text: ' ' + gvTime(s.decided) }) : null,\n s.comment ? el('div', { className: 'small', style: 'margin-left:16px;font-style:italic', text: '“' + s.comment + '”' }) : null);\n })) : el('span', { className: 'muted', text: 'No approval step' });\n return { r: r, cells: [gvTime(r.submitted), r.requestedFor, r.requestedBy, el('span', {}, r.access, r.accessType ? el('span', { className: 'muted small', text: ' ' + r.accessType.toLowerCase().replace('_', ' ') }) : null, r.requestType === 'REVOKE_ACCESS' ? el('span', {}, ' ', pill('revoke', 'lose')) : null),\n r.requesterComment ? el('span', { className: 'small', style: 'font-style:italic', text: '“' + r.requesterComment + '”' }) : '', steps, el('span', {}, pill(o[0], o[1]), r.errors.length ? el('div', { className: 'small', style: 'color:var(--bad)', text: r.errors.join('; ') }) : null)] };\n });\n w.appendChild(section('Requests', d.requests.length + (d.more || 0), filteredTable(H, rows, ['Submitted', 'Requested for', 'Requested by', 'Access', 'Requester comment', 'Approvals', 'Outcome'], function (x) { return x.cells; }, 'Access request audit trail')));\n }\n\n // Audit > Approver chain\n function renderApproverChain(w) {\n var H = gvState().chain;\n if (!gvRunBar(w, H, 'approver-chain', 'Read approval settings', 'Who approves a request, in what order, and who approves a revoke, for every access profile, role and requestable entitlement. Flags requestable access that needs no approval or whose approver cannot be reached.', null, null, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accessProfiles, 'access profiles'), stat(T.roles, 'roles'), stat(T.entitlements, 'requestable entitlements'), stat(T.noApproval, 'requestable without approval', 'lose'), stat(T.flagged, 'with a problem', 'lose')));\n var list = function (xs) { return xs.length ? el('div', {}, xs.map(function (x) { return el('div', { text: x }); })) : el('span', { className: 'muted', text: 'none' }); };\n var H2 = H.view || (H.view = { only: 'requestable' });\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['requestable', 'Requestable only'], ['problems', 'Only with problems'], ['all', 'Everything']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = H2.only;\n only.addEventListener('change', function () { H2.only = only.value; renderAudit(); });\n var rows = d.rows.filter(function (r) { return H2.only === 'all' || (H2.only === 'problems' ? r.flags.length : r.requestable); });\n w.appendChild(section('Approval settings', rows.length, filteredTable(H, rows, ['Type', 'Name', 'Source', 'Owner', 'Request approvals', 'Revoke approvals', 'Comment required', 'Problems'], function (r) {\n return [r.type, r.name, r.source, r.owner, list(r.request), list(r.revoke), r.commentsRequired ? 'Yes' : 'No', r.flags.length ? el('div', {}, r.flags.map(function (f) { return el('div', { className: 'small', style: 'color:var(--bad)', text: f }); })) : ''];\n }, 'Approver chain', only)));\n }\n\n // Warnings > Accounts expiring\n function wnExpiry(w, _H, desc) {\n var H = gvState().expiry;\n if (!H.sources) {\n H.sources = 'loading';\n api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(function () { if (state.page === 'warnings') renderWarnings(); });\n }\n var pick = el('select', { className: 'input', multiple: true, size: 4, style: 'min-width:220px', 'aria-label': 'Sources to check' }, (Array.isArray(H.sources) ? H.sources : []).map(function (s) {\n return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });\n }));\n if (!H.sourceIds.length && Array.isArray(H.sources)) {\n var ad = H.sources.filter(function (s) { return /active directory|\\bad\\b/i.test(s.name + ' ' + (s.type || '')); })[0];\n if (ad) { H.sourceIds = [ad.id]; Array.prototype.forEach.call(pick.options, function (o) { o.selected = o.value === ad.id; }); }\n }\n pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected; }).map(function (o) { return o.value; }); });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sources (Ctrl+click for more)' }), pick),\n attrInput(H, 'attribute', 'Expiry attribute', 'accountExpires'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Expiring within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Expiring within')));\n if (!gvRunBar(w, H, 'account-expiry', 'Find expiring accounts', desc, extras, function () { return { days: H.days, attribute: H.attribute || 'accountExpires', sourceIds: H.sourceIds }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.withDate, 'with an expiry date'), stat(T.never, 'set to never expire'), stat(T.missing, 'without a value'), stat(T.expiring, 'expire in the next ' + d.days + ' days', 'lose'), stat(T.expiredEnabled, 'expired but still enabled', 'lose'), stat(T.unreadable, 'values not readable as a date')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No account expires in this period.' })); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Person', 'Source', 'Expires', 'When', 'Account'], function (r) {\n return [r.account, r.person || el('span', { className: 'muted', text: 'not linked to a person' }), r.source, r.expires, pill(daysText(r.daysLeft), r.daysLeft <= 7 ? 'lose' : 'off'), r.disabled ? 'disabled' : 'enabled'];\n }, 'Accounts expiring')));\n }\n\n // Warnings > Revokes not done\n function wnRevokes(w, _H, desc) {\n var H = gvState().revokes;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Campaigns created in the last' }), numSelect(H, 'days', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Campaign period'));\n if (!gvRunBar(w, H, 'revokes', 'Check revokes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns checked'), stat(T.revokes, 'revoke decisions'), stat(T.removed, 'removed'), stat(T.stillHeld, 'signed off but still held', 'lose'), stat(T.notSignedOff, 'waiting for sign-off')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every revoked item has been removed.' })); return; }\n w.appendChild(section('Revoked but still there', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Access', 'Type', 'Campaign', 'Reviewer', 'Signed off', 'Status'], function (r) {\n return [r.person, r.access, r.accessType, r.campaign, r.reviewer, r.signedOff ? r.signedOff.slice(0, 10) + (r.daysSinceSignOff !== null ? ' (' + r.daysSinceSignOff + ' days ago)' : '') : '—',\n el('span', {}, pill(r.status, r.status === 'still held' ? 'lose' : 'off'), r.alsoFromRole ? el('div', { className: 'small muted', text: 'May also come from a role or access profile' }) : null)];\n }, 'Revoked but still held')));\n }\n\n // Person lookup > Timeline\n function timelineSection(p) {\n var items = p.timeline || [];\n var L = state.tl || (state.tl = { kind: '' });\n var kinds = ['Identity', 'Lifecycle', 'Audit event', 'Account change', 'Access request'];\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show in timeline' }, [el('option', { value: '', text: 'Everything' })].concat(kinds.map(function (k) { return el('option', { value: k, text: k }); })));\n sel.value = L.kind;\n var box = el('div');\n var draw = function () {\n box.textContent = '';\n var list = items.filter(function (x) { return !L.kind || x.kind === L.kind; });\n box.appendChild(simpleTable(['When', 'Kind', 'What', 'Detail', 'Status'], list.slice(0, 500).map(function (x) {\n return [gvTime(x.when), x.kind, x.what, x.detail, x.status ? pill(String(x.status).toLowerCase(), x.failed ? 'lose' : 'off') : ''];\n }), 'Timeline'));\n };\n sel.addEventListener('change', function () { L.kind = sel.value; draw(); });\n draw();\n return section('Timeline (30 days, newest first)', items.length, el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:8px' }, sel, el('span', { className: 'muted small', text: 'Lifecycle changes, audit events, account changes and access requests in one list.' })), box));\n }\n // ---------- 0.23.0: drift, incidents, cleanup, and Non-employees (NERM) ----------\n function owState() {\n if (!state.wt) state.wt = {\n massch: { days: 30, factor: 3, min: 50 }, loops: { days: 7, min: 5 }, outside: { days: 0, sourceIds: [] }, syncdrift: { sourceIds: [] },\n groupappr: {}, mgrleft: { query: '' }, leavertimes: { days: 30, limitHours: 24 }, attrhist: { attributes: 'manager, department, title, cloudLifecycleState' },\n owners: {}, rules: { cloudRules: false }\n };\n return state.wt;\n }\n function owRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, path, body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n /** Source picker (one or several), loaded once per page visit. */\n function sourcePick(H, multiple, rerender, label) {\n if (!H.sources) {\n H.sources = 'loading';\n api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(rerender);\n }\n var list = Array.isArray(H.sources) ? H.sources : [];\n var pick = el('select', { className: 'input', multiple: multiple, size: multiple ? 4 : null, style: 'min-width:220px;width:auto', 'aria-label': label }, (multiple ? [] : [el('option', { value: '', text: list.length ? 'Pick a source' : 'Loading sources...' })]).concat(list.map(function (s) {\n return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });\n })));\n pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected && o.value; }).map(function (o) { return o.value; }); });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label + (multiple ? ' (Ctrl+click for more)' : '') }), pick);\n }\n function hrs(h) { return h === null || h === undefined ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; }\n function when16(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }\n function warnRerender() { if (state.page === 'warnings') renderWarnings(); }\n\n // Warnings > Mass changes\n function wnMassChange(w, _H, desc) {\n var H = owState().massch;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Usual level from the last' }), numSelect(H, 'days', [[14, '14 days'], [30, '30 days'], [60, '60 days']], 'Baseline period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Spike at' }), numSelect(H, 'factor', [[2, '2× usual'], [3, '3× usual'], [5, '5× usual'], [10, '10× usual']], 'Spike factor')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'and at least' }), numSelect(H, 'min', [[20, '20 changes'], [50, '50 changes'], [200, '200 changes'], [1000, '1,000 changes']], 'Minimum changes')));\n if (!owRunBar(w, H, '/api/watch/mass-change/run', 'Check for spikes', desc, extras, function () { return { days: H.days, factor: H.factor, min: H.min }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, d.series.map(function (x) {\n return el('div', { className: 'bigstat' + (x.spike ? ' lose' : '') }, el('b', { text: fmtNum(x.latest) }), el('span', { text: x.label + ' on ' + x.latestDay + ' (usual ' + fmtNum(Math.round(x.usual)) + ')' + (x.spike ? ': spike' : '') }));\n })));\n d.series.filter(function (x) { return x.spike; }).forEach(function (x) {\n w.appendChild(section('Spike: ' + x.label.toLowerCase() + ' on ' + x.latestDay, x.latest, simpleTable(['Source', 'Changes'], x.bySource.map(function (s) { return [s.source, fmtNum(s.count)]; }), 'Spike by source: ' + x.label)));\n });\n var all = d.series[0];\n var maxv = Math.max.apply(null, all.daily.map(function (p) { return p.count; }).concat([1]));\n var bars = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:90px;margin:8px 0', role: 'img', 'aria-label': 'Provisioning per day: ' + all.daily.map(function (p) { return p.day + ' ' + p.count; }).join(', ') }, all.daily.map(function (p) {\n return el('div', { title: p.day + ': ' + p.count, style: 'flex:1;min-width:3px;background:' + (p.day === all.latestDay && all.spike ? 'var(--danger)' : 'var(--accent)') + ';height:' + Math.max(2, Math.round(p.count / maxv * 88)) + 'px;border-radius:2px 2px 0 0' });\n }));\n w.appendChild(section('All provisioning per day', null, el('div', {}, bars, el('div', { className: 'bar', style: 'justify-content:flex-end' }, downloads(H.job)))));\n }\n\n // Warnings > Provisioning loops\n function wnLoops(w, _H, desc) {\n var H = owState().loops;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sent at least' }), numSelect(H, 'min', [[3, '3 times'], [5, '5 times'], [10, '10 times'], [20, '20 times']], 'Minimum repeats')));\n if (!owRunBar(w, H, '/api/watch/loops/run', 'Find loops', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.read, 'activities read'), stat(d.rows.length + (d.more || 0), 'changes sent again and again', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No change was sent that often.' })); return; }\n w.appendChild(section('Loops', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Source', 'Operation', 'Change', 'Times', 'First', 'Last', 'Last result'], function (r) {\n return [r.person, r.source, r.op, el('span', { className: 'small', text: r.change }), pill(String(r.times), 'lose'), when16(r.first), when16(r.last), r.lastStatus];\n }, 'Provisioning loops')));\n }\n\n // Warnings > Changed outside ISC\n function wnOutside(w, _H, desc) {\n var H = owState().outside;\n var extras = el('div', { className: 'bar' }, sourcePick(H, true, warnRerender, 'Sources'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compare with what ISC sent in' }), numSelect(H, 'days', [[0, 'All history'], [30, 'the last 30 days'], [90, 'the last 90 days'], [180, 'the last 180 days'], [365, 'the last 365 days']], 'Period')));\n if (!owRunBar(w, H, '/api/watch/outside/run', 'Find changes made outside ISC', desc, extras, function () { return { days: H.days, sourceIds: H.sourceIds }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.disabledOutside, 'disabled outside ISC', 'lose'), stat(T.enabledOutside, 'enabled again outside ISC', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every account state matches what ISC sent.' })); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Person state', 'Account', 'Source', 'Finding', 'Last disable or enable ISC sent'], function (r) { return [r.person, r.personState, r.account, r.source, r.finding, r.lastIsc]; }, 'Changes made outside ISC')));\n }\n\n // Warnings > Attribute sync drift\n function wnSyncDrift(w, _H, desc) {\n var H = owState().syncdrift;\n var extras = el('div', { className: 'bar' }, sourcePick(H, false, warnRerender, 'Source'));\n if (!owRunBar(w, H, '/api/watch/sync-drift/run', 'Compare values', desc, extras, function () { return { sourceIds: H.sourceIds.slice(0, 1) }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.mappings.length, 'attributes synced'), stat(T.accounts, 'accounts'), stat(T.compared, 'values compared'), stat(T.drifted, 'values that differ', 'lose'), stat(T.failedSyncs, 'failed syncs (14 days)', 'lose')));\n if (d.mappings.length) w.appendChild(el('p', { className: 'muted small', text: 'Synced: ' + d.mappings.map(function (m) { return m.identityAttribute + ' → ' + m.accountAttribute; }).join(', ') }));\n if (d.rows.length) w.appendChild(section('Values that differ', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Account', 'Attribute', 'Value in ISC', 'Value on the account'], function (r) { return [r.person, r.account, r.identityAttribute + ' → ' + r.accountAttribute, r.inIsc, r.onAccount]; }, 'Attribute sync drift')));\n else if (d.mappings.length) w.appendChild(el('p', { className: 'muted', text: 'Every synced value matches.' }));\n if (d.failedSyncs.length) w.appendChild(section('Failed attribute syncs', d.failedSyncs.length, simpleTable(['When', 'Person', 'Detail'], d.failedSyncs.slice(0, 500).map(function (f) { return [when16(f.when), f.person, f.detail]; }), 'Failed attribute syncs')));\n }\n\n // Warnings > Group approvals\n function wnGroupApprovals(w, _H, desc) {\n var H = owState().groupappr;\n if (!owRunBar(w, H, '/api/watch/group-approvals/run', 'Check group approvers', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.pending, 'approvals waiting on a group'), stat(T.groups, 'groups'), stat(T.noActiveMember, 'with no active member left', 'lose')));\n if (!d.rows.length) return;\n w.appendChild(section('Approvals', d.rows.length, filteredTable(H, d.rows, ['Group', 'Access', 'Requested for', 'Waiting', 'Members', 'Members who left'], function (r) {\n return [r.group, r.request, r.requestedFor, r.waitingDays === null ? '—' : r.waitingDays + ' days', el('span', {}, r.activeMembers + ' of ' + r.members + ' active ', r.activeMembers === 0 ? pill('nobody can approve', 'lose') : null), r.leftMembers.join(', ')];\n }, 'Approvals waiting on governance groups')));\n }\n\n // Warnings > Manager left\n function wnManagerLeft(w, _H, desc) {\n var H = owState().mgrleft;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.employeeType:contractor', style: 'max-width:300px', 'aria-label': 'Only people matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only people matching (optional)' }), q);\n if (!owRunBar(w, H, '/api/watch/manager-left/run', 'Find people', desc, extras, function () { return { query: H.query || undefined }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'active people'), stat(d.totals.managerLeft, 'whose manager left', 'lose')));\n if (!d.rows.length) return;\n w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Identity profile', 'Manager', 'Manager state'], function (r) { return [r.person, r.lifecycle, r.profile, r.manager, pill(r.managerState, 'lose')]; }, 'People whose manager left')));\n }\n\n // Audit > Leaver removal times\n function renderLeaverTimes(w) {\n var H = owState().leavertimes;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Leavers of the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Limit' }), numSelect(H, 'limitHours', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '72 hours'], [168, '7 days']], 'Removal limit')));\n if (!owRunBar(w, H, '/api/watch/leaver-times/run', 'Time the leavers', 'For each leaver: when leaving started (lifecycle change), when each account was disabled, and which accounts are still enabled. The per-person figure auditors ask for.', extras, function () { return { days: H.days, limitHours: H.limitHours }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.leavers, 'leavers'), stat(T.late, 'over ' + d.limitHours + ' h or not done', 'lose'), stat(T.stillEnabled, 'with an account still enabled', 'lose'), el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHours) }), el('span', { text: 'median removal time' }))));\n if (!d.rows.length) return;\n w.appendChild(section('Leavers', d.rows.length, filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Started', 'Accounts', 'Slowest removal', 'Still enabled on', 'Result'], function (r) {\n return [r.person, r.lifecycle, el('span', {}, when16(r.started) || '—', el('div', { className: 'small muted', text: r.startedBy })), r.accounts, hrs(r.slowestHours), r.stillEnabled.join(', '), pill(r.late ? 'late' : 'on time', r.late ? 'lose' : 'win')];\n }, 'Leaver removal times')));\n }\n\n // Audit > Attribute changes\n function renderAttrHistory(w) {\n var H = owState().attrhist;\n var i = el('input', { className: 'input', value: H.attributes, style: 'max-width:380px', 'aria-label': 'Attributes to follow (comma-separated)' });\n i.addEventListener('input', function () { H.attributes = i.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Attributes to follow (comma-separated)' }), i);\n if (!owRunBar(w, H, '/api/watch/attr-history/run', 'Look now', 'Who changed manager, department, title or lifecycle state, from what to what. IdentityScope remembers the values at each look and lists the changes between looks.', extras,\n function () { return { attributes: H.attributes.split(',').map(function (x) { return x.trim(); }).filter(Boolean) }; }, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.people, 'people looked at'), stat(d.newChanges, 'changes since the last look'), stat(d.changes.length + (d.more || 0), 'changes on record')));\n if (d.previousLook) w.appendChild(el('p', { className: 'muted small', text: 'Previous look: ' + when16(d.previousLook) }));\n if (!d.changes.length) return;\n w.appendChild(section('Changes', d.changes.length + (d.more || 0), filteredTable(H, d.changes, ['Seen at', 'Person', 'Attribute', 'From', 'To'], function (r) { return [when16(r.at), r.person, r.attribute, r.from || '(empty)', r.to || '(empty)']; }, 'Attribute changes')));\n }\n\n // Audit > Entitlement owners\n function renderOwners(w) {\n var H = owState().owners;\n if (!owRunBar(w, H, '/api/watch/owners/run', 'Read owners', 'Every entitlement owner with what they own and how many people hold each item, so each owner can review their own access. Owners who left are listed first.', null, null, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.owners.length, 'owners'), stat(d.owners.filter(function (o) { return o.ownerState !== 'active'; }).length, 'owners who left or are not found', 'lose'), stat(d.rows.length + (d.more || 0), 'owned entitlements')));\n w.appendChild(section('Owners', d.owners.length, simpleTable(['Owner', 'State', 'Entitlements', 'Holders'], d.owners.map(function (o) {\n return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.entitlements), fmtNum(o.holders)];\n }), 'Entitlement owners')));\n w.appendChild(section('Entitlements', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Owner', 'Entitlement', 'Source', 'Privileged', 'Holders'], function (r) { return [r.owner, r.entitlement, r.source, r.privileged ? 'Yes' : '', r.holders === null ? '—' : fmtNum(r.holders)]; }, 'Entitlements by owner')));\n }\n\n // Tenant > Rule usage\n function renderRuleUsage(w) {\n var H = owState().rules;\n var cb = el('input', { type: 'checkbox', checked: H.cloudRules });\n cb.addEventListener('change', function () { H.cloudRules = cb.checked; });\n var extras = el('label', { className: 'check', title: 'Starts an SP-Config export job in the tenant (it reads only, but the job shows in ISC).' }, cb, 'Also list cloud rules (SP-Config export)');\n if (!owRunBar(w, H, '/api/watch/rules/run', 'Find where rules are used', 'Every connector rule and cloud rule with the sources, policies, transforms and identity attributes that use it. Unused rules are cleanup candidates; rules used but missing break at run time.', extras,\n function () { return { cloudRules: H.cloudRules }; }, renderTenant)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.rules, 'rules'), stat(T.unused, 'not used anywhere', 'lose'), stat(T.missing, 'used but missing', 'lose')));\n w.appendChild(section('Rules', d.rows.length, filteredTable(H, d.rows, ['Rule', 'Kind', 'Used by', 'Finding'], function (r) {\n return [r.rule, r.kind, r.usedBy.length ? el('div', {}, r.usedBy.map(function (u) { return el('div', { className: 'small', text: u }); })) : '', r.finding ? pill(r.finding, 'lose') : ''];\n }, 'Rule usage')));\n }\n\n // ---------- Non-employees (NERM) page ----------\n function nmState() {\n if (!state.nm) state.nm = { tab: 'overview', settings: null, overview: { days: 30, endAttribute: '' }, sync: {}, sessions: { minDays: 0 }, risk: {}, users: {} };\n return state.nm;\n }\n var NM_TABS = [\n ['overview', 'End dates and sponsors', 'clock', 'Active non-employees past their end date or ending soon, and non-employees without a sponsor or whose sponsor has left.'],\n ['sync', 'NERM vs ISC', 'cols', 'Profiles whose status in NERM does not match their identity in ISC: terminated in NERM but still active in ISC, and the reverse.'],\n ['sessions', 'Waiting workflows', 'lifecycle', 'NERM workflow sessions still waiting for an approval, review, fulfilment or another step.'],\n ['risk', 'High risk', 'shield', 'Non-employees with the highest NERM risk level, active ones first.'],\n ['users', 'Portal users who left', 'people', 'Sponsors, managers and admins who can still sign in to NERM although their identity in ISC has left.']\n ];\n function renderNerm() {\n var N = nmState();\n var outer = $('nerm');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#ccfbf1' }, icon('people')),\n el('div', {}, el('h2', { text: 'Non-employees' }), el('p', { className: 'desc', text: 'Contractors, vendors and other non-employees in Non-Employee Risk Management (NERM), checked against ISC. Read-only: GET requests on seven NERM read endpoints only.' }))));\n if (!N.settings) {\n N.settings = 'loading';\n api('/api/nerm/settings').then(function (s) { N.settings = s; }, function () { N.settings = {}; }).then(function () { if (state.page === 'nerm') renderNerm(); });\n }\n var S = N.settings && N.settings !== 'loading' ? N.settings : {};\n var addr = el('input', { className: 'input', value: N.addrDraft !== undefined ? N.addrDraft : (S.address || ''), placeholder: 'acme or https://acme.nonemployee.com', style: 'max-width:320px', 'aria-label': 'NERM address' });\n addr.addEventListener('input', function () { N.addrDraft = addr.value; });\n w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' }, el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'NERM address' }), addr),\n el('button', { className: 'btn', onclick: function () {\n api('/api/nerm/settings', 'PUT', { address: addr.value }).then(function (s) { N.settings = s; N.addrDraft = undefined; toast(s.address ? 'Saved' : 'Cleared'); renderNerm(); }, function (e) { toast(errorText(e)); });\n } }, 'Save'),\n el('span', { className: 'muted small', style: 'flex:1;min-width:260px', text: S.base ? 'Reads ' + S.base + ' with the same sign-in as ISC. The API client or token needs a NERM scope (nerm:api:read-only is enough).' : 'Uses the same sign-in as ISC: no second secret. The API client or token needs a NERM scope (nerm:api:read-only is enough).' }))));\n var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });\n NM_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (N.tab === t[0] ? ' active' : ''), onclick: function () { N.tab = t[0]; renderNerm(); } }, icon(t[2]), t[1])); });\n w.appendChild(tabs);\n var spec = NM_TABS.filter(function (t) { return t[0] === N.tab; })[0];\n ({ overview: nmOverview, sync: nmSync, sessions: nmSessions, risk: nmRisk, users: nmUsers })[N.tab](w, N[N.tab], spec[3]);\n }\n function nmBar(w, H, kind, label, desc, extras, body) { return owRunBar(w, H, '/api/nerm/' + kind + '/run', label, desc, extras, body, renderNerm); }\n function nmProfileTable(H, rows, label, withEnd) {\n return filteredTable(H, rows, withEnd ? ['Profile', 'Type', 'End date', 'When', 'Sponsor'] : ['Profile', 'Type', 'Sponsor', 'Problem'], function (r) {\n return withEnd ? [r.name, r.type, r.endDate, pill(daysText(r.daysLeft), r.daysLeft < 0 || r.daysLeft <= 7 ? 'lose' : 'off'), r.sponsors] : [r.name, r.type, r.sponsors || '—', pill(r.sponsorProblem, 'lose')];\n }, label);\n }\n function nmOverview(w, H, desc) {\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Ending within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Ending within')),\n attrInput(H, 'endAttribute', 'End-date attribute (optional)', 'found automatically'));\n if (!nmBar(w, H, 'overview', 'Check non-employees', desc, extras, function () { return { days: H.days, endAttribute: H.endAttribute || undefined }; })) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'profiles'), stat(T.active, 'active'), stat(T.pastEnd, 'active past their end date', 'lose'), stat(T.ending, 'ending in ' + H.days + ' days'), stat(T.noSponsor, 'without a sponsor', 'lose'), stat(T.sponsorLeft, 'whose sponsor left', 'lose')));\n if (d.endAttribute || d.sponsorAttributes.length) w.appendChild(el('p', { className: 'muted small', text: [d.endAttribute ? 'End date from: ' + d.endAttribute : '', d.sponsorAttributes.length ? 'Sponsor from: ' + d.sponsorAttributes.join(', ') : ''].filter(Boolean).join(' · ') }));\n w.appendChild(section('By profile type', d.byType.length, simpleTable(['Profile type', 'Category', 'Active', 'On leave', 'Inactive', 'Terminated'], d.byType.map(function (b) { return [b.type, b.category, fmtNum(b.active), fmtNum(b.onLeave), fmtNum(b.inactive), fmtNum(b.terminated)]; }), 'Profiles by type')));\n if (d.pastEnd.length) w.appendChild(section('Active past their end date', d.pastEnd.length, nmProfileTable(H.past || (H.past = { data: d, job: H.job }), d.pastEnd, 'Active past end date', true)));\n if (d.ending.length) w.appendChild(section('Ending soon', d.ending.length, nmProfileTable(H.soon || (H.soon = { data: d, job: H.job }), d.ending, 'Ending soon', true)));\n if (d.sponsorIssues.length) w.appendChild(section('Sponsor problems', d.sponsorIssues.length, nmProfileTable(H.sp || (H.sp = { data: d, job: H.job }), d.sponsorIssues, 'Sponsor problems', false)));\n }\n function nmSync(w, H, desc) {\n if (!nmBar(w, H, 'sync', 'Compare with ISC', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.synced, 'profiles of synced types'), stat(T.checked, 'matched to an identity'), stat(T.leftInNermActiveInIsc, 'left in NERM, active in ISC', 'lose'), stat(T.activeInNermLeftInIsc, 'active in NERM, inactive in ISC', 'lose'), stat(T.notInIsc, 'active but not in ISC', 'lose')));\n if (d.sources.length) w.appendChild(el('p', { className: 'muted small', text: 'Matched through the ISC source' + (d.sources.length > 1 ? 's ' : ' ') + d.sources.join(', ') + '.' }));\n if (!d.rows.length) return;\n w.appendChild(section('Out of step', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status in NERM', 'Identity in ISC', 'State in ISC', 'Problem'], function (r) { return [r.profile, r.type, r.nermStatus, r.iscPerson, r.iscState, pill(r.problem, 'lose')]; }, 'NERM and ISC out of step')));\n }\n function nmSessions(w, H, desc) {\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Waiting at least' }), numSelect(H, 'minDays', [[0, 'any time'], [3, '3 days'], [7, '7 days'], [30, '30 days']], 'Minimum age'));\n if (!nmBar(w, H, 'sessions', 'Find waiting sessions', desc, extras, function () { return { minDays: H.minDays }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.sessions, 'sessions'), stat(d.totals.waiting, 'waiting', 'lose')));\n w.appendChild(section('By status', d.byStatus.length, simpleTable(['Status', 'Sessions'], d.byStatus.map(function (b) { return [b.status.replace(/_/g, ' '), fmtNum(b.sessions)]; }), 'Sessions by status')));\n if (d.waiting.length) w.appendChild(section('Waiting', d.waiting.length, filteredTable(H, d.waiting, ['Workflow', 'Status', 'Profile', 'Age'], function (r) { return [r.workflow, r.status.replace(/_/g, ' '), r.profile, r.age === undefined || r.age === null ? '—' : r.age + ' days']; }, 'Waiting workflow sessions')));\n }\n function nmRisk(w, H, desc) {\n if (!nmBar(w, H, 'risk', 'Read risk', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.scored, 'profiles with a risk score'), stat(T.high, 'at the highest level'), stat(T.highActive, 'of them active', 'lose')));\n if (d.rows.length) w.appendChild(section('Highest risk', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status', 'Risk level', 'Score'], function (r) { return [r.profile, r.type, r.status, pill(r.level, 'lose'), r.score]; }, 'High-risk non-employees')));\n }\n function nmUsers(w, H, desc) {\n if (!nmBar(w, H, 'users', 'Check portal users', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.users, 'NERM users'), stat(T.active, 'active'), stat(T.leftInIsc, 'active in NERM but left in ISC', 'lose'), stat(T.neverLoggedIn, 'active, never signed in')));\n if (d.rows.length) w.appendChild(section('Users who left', d.rows.length, filteredTable(H, d.rows, ['User', 'Email', 'Type', 'Last sign-in', 'State in ISC'], function (r) { return [r.user, r.email, r.type, r.lastLogin ? String(r.lastLogin).slice(0, 10) : 'never', pill(r.iscState, 'lose')]; }, 'NERM users who left')));\n }\n // ---------- 0.24.0: grouped tabs, and the access model, aggregation safety, service accounts, duplicates, passwords, reassigned reviews ----------\n /**\n * Two-level navigation for pages with many tabs: a short row of sections,\n * then only the tabs of the section that is open.\n * groups: [[section label, [tab ids]]]; tabs: [[id, label, icon, ...]].\n */\n function groupedTabs(w, key, groups, tabs, current, pick) {\n var memo = state.tabMemo || (state.tabMemo = {});\n var gi = 0;\n groups.forEach(function (g, i) { if (g[1].indexOf(current) >= 0) gi = i; });\n memo[key + gi] = current;\n var seg = el('div', { className: 'seg' });\n groups.forEach(function (g, i) {\n seg.appendChild(el('button', { className: 'segbtn' + (i === gi ? ' active' : ''), 'aria-pressed': String(i === gi), onclick: function () {\n var last = memo[key + i];\n pick(last && g[1].indexOf(last) >= 0 ? last : g[1][0]);\n } }, g[0], el('span', { className: 'segn', text: String(g[1].length) })));\n });\n w.appendChild(seg);\n var row = el('div', { className: 'tabs sub' });\n groups[gi][1].forEach(function (id) {\n var t = tabs.filter(function (x) { return x[0] === id; })[0];\n if (t) row.appendChild(el('button', { className: 'tab' + (current === id ? ' active' : ''), onclick: function () { pick(id); } }, icon(t[2]), t[1]));\n });\n w.appendChild(row);\n }\n var WN_GROUPS = [\n ['Joiners, movers, leavers', ['upcoming', 'joiners', 'movers', 'leavers', 'mgrleft', 'people', 'expiry']],\n ['Accounts', ['outside', 'syncdrift', 'multi', 'svc', 'admins']],\n ['Provisioning', ['massch', 'loops', 'aggsafe', 'pwfail']],\n ['Requests and reviews', ['ending', 'stuckreq', 'stuck', 'groupappr', 'reminders', 'revokes']],\n ['Threat signals', ['risk', 'privgain', 'outacct', 'sensitive', 'signins', 'selfappr', 'adminact', 'spikes']],\n ['Tenant health', ['lcset', 'govgroups', 'catalog', 'growth', 'quality']]\n ];\n var AU_TABS = [['certs', 'Certifications', 'cert'], ['sod', 'Separation of duties', 'shield'], ['coverage', 'Review coverage', 'eye'], ['reassigned', 'Reassigned reviews', 'people'], ['exceptions', 'Exceptions', 'file'],\n ['outliers', 'Access outliers', 'people'], ['outmodel', 'Outside roles', 'eye'], ['composition', 'What is in every role', 'cols'], ['adminaccts', 'Admin accounts', 'shield'], ['owners', 'Entitlement owners', 'people'],\n ['trail', 'Request trail', 'file'], ['chain', 'Approver chain', 'people'],\n ['speed', 'Provisioning speed', 'pulse'], ['leavertimes', 'Leaver removal times', 'clock'], ['attrhist', 'Attribute changes', 'lifecycle'],\n ['changes', 'Change history', 'clock'], ['evidence', 'Evidence pack', 'download']];\n var AU_GROUPS = [\n ['Reviews', ['certs', 'coverage', 'reassigned', 'sod', 'exceptions']],\n ['Who has what', ['outliers', 'outmodel', 'composition', 'adminaccts', 'owners']],\n ['Requests', ['trail', 'chain']],\n ['Speed and history', ['speed', 'leavertimes', 'attrhist']],\n ['Changes and evidence', ['changes', 'evidence']]\n ];\n function mdState() {\n if (!state.md) state.md = { outmodel: { query: '', view: 'ent' }, composition: {}, aggsafe: { days: 14 }, signins: { days: 7, minFailed: 10 }, selfappr: { days: 90 }, adminact: { days: 7 }, spikes: { days: 7, min: 15 }, lcset: {}, govgroups: {}, svc: { unusedDays: 90 }, multi: {}, pwfail: { days: 14 }, reassigned: { days: 180 } };\n return state.md;\n }\n function mdRun(w, H, kind, label, desc, extras, body, rerender) { return owRunBar(w, H, '/api/watch/' + kind + '/run', label, desc, extras, body, rerender); }\n function pct(a, b) { return b ? Math.round(a * 100 / b) : 0; }\n\n // Audit > Outside roles\n function renderOutsideModel(w) {\n var H = mdState().outmodel;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.department:Finance', style: 'max-width:300px', 'aria-label': 'Only people matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only people matching (optional)' }), q);\n if (!mdRun(w, H, 'outside-model', 'Find direct access', 'Entitlements people hold on their own, not through any role or access profile: the access nobody designed. Shows which entitlements are mostly given directly and who holds them.', extras, function () { return { query: H.query || undefined }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'active people'), stat(T.assignments, 'entitlements held'), stat(T.direct, 'held directly', 'lose'), stat(pct(T.direct, T.assignments), '% held directly'), stat(T.peopleWithDirect, 'people with direct access'), stat(T.entitlementsOnlyDirect, 'entitlements never given by a role')));\n var sw = el('div', { className: 'seg', style: 'margin:0 0 10px' }, [['ent', 'By entitlement'], ['people', 'By person']].map(function (v) {\n return el('button', { className: 'segbtn' + (H.view === v[0] ? ' active' : ''), 'aria-pressed': String(H.view === v[0]), onclick: function () { H.view = v[0]; renderAudit(); } }, v[1]);\n }));\n w.appendChild(sw);\n if (H.view === 'ent') w.appendChild(section('Entitlements given directly', d.entitlements.length, filteredTable(H.e || (H.e = { data: d, job: H.job }), d.entitlements, ['Entitlement', 'Source', 'Privileged', 'Holders', 'Directly', 'Through a role or access profile'], function (r) {\n return [r.entitlement, r.source, r.privileged ? pill('privileged', 'lose') : '', fmtNum(r.holders), el('span', {}, fmtNum(r.direct), el('span', { className: 'muted small', text: ' (' + pct(r.direct, r.holders) + '%)' })), fmtNum(r.viaModel)];\n }, 'Entitlements given directly')));\n else w.appendChild(section('People with direct access', d.people.length + (d.morePeople || 0), filteredTable(H, d.people, ['Person', 'Entitlement', 'Source', 'Privileged'], function (r) { return [r.person, r.entitlement, r.source, r.privileged ? pill('privileged', 'lose') : '']; }, 'Access held directly')));\n }\n\n // Audit > What is in every role\n function renderComposition(w) {\n var H = mdState().composition;\n if (!mdRun(w, H, 'composition', 'Read every role', 'Every role with its access profiles and the entitlements inside them, as one table to filter and download. Flags empty roles and access profiles.', null, null, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.roles, 'roles'), stat(T.accessProfiles, 'access profiles'), stat(T.emptyRoles, 'empty roles', 'lose'), stat(T.emptyProfiles, 'access profiles without entitlements', 'lose'), stat(T.profilesNotInARole, 'access profiles in no role'), stat(T.disabledRoles, 'disabled roles')));\n if (!d.rows.length) return;\n w.appendChild(section('Composition', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Role', 'Owner', 'Assigned', 'Access profile', 'Entitlement', 'Source', 'Note'], function (r) {\n return [el('span', {}, r.role, r.roleState === 'disabled' ? el('span', {}, ' ', pill('disabled', 'off')) : null), r.roleOwner, r.assignment, r.accessProfile, r.entitlement, r.source, r.note ? pill(r.note, 'lose') : ''];\n }, 'What is in every role')));\n }\n\n // Audit > Reassigned reviews\n function renderReassigned(w) {\n var H = mdState().reassigned;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Campaigns of the last' }), numSelect(H, 'days', [[90, '90 days'], [180, '180 days'], [365, '365 days']], 'Campaign period'));\n if (!mdRun(w, H, 'reassigned', 'Find reassigned reviews', 'Certifications that were passed on: from whom, to whom, the reason given, and whether the new reviewer is still here.', extras, function () { return { days: H.days }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns checked'), stat(T.certifications, 'certifications'), stat(T.reassigned, 'reassigned'), stat(T.withoutComment, 'without a reason', 'lose'), stat(T.toSomeoneWhoLeft, 'now with someone who left', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No review was reassigned.' })); return; }\n if (d.byReceiver.length > 1) w.appendChild(section('Who received them', d.byReceiver.length, simpleTable(['Reviewer', 'Reviews received'], d.byReceiver.slice(0, 50).map(function (r) { return [r.reviewer, fmtNum(r.received)]; }), 'Reviews received by reviewer')));\n w.appendChild(section('Reassigned reviews', d.rows.length, filteredTable(H, d.rows, ['Campaign', 'Certification', 'From', 'Now with', 'Reason given', 'Decisions', 'Signed off'], function (r) {\n return [r.campaign, r.certification, r.from, el('span', {}, r.to, r.toState && r.toState !== 'active' ? el('span', {}, ' ', pill(r.toState, 'lose')) : null), r.comment || el('span', { className: 'muted', text: 'none' }), r.decisions, r.signed || '—'];\n }, 'Reassigned reviews')));\n }\n\n // Warnings > Aggregation safety\n function wnAggSafety(w, _H, desc) {\n var H = mdState().aggsafe;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Aggregations of the last' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period'));\n if (!mdRun(w, H, 'agg-safety', 'Check aggregations', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.sources, 'sources'), stat(T.flagged, 'with a finding', 'lose'), stat(T.failed, 'with failed aggregations', 'lose'), stat(T.highThreshold, 'with a delete threshold of 50% or more', 'lose'), stat(T.stale, 'did not aggregate')));\n var V = H.view || (H.view = { only: 'flagged' });\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['flagged', 'Only with findings'], ['all', 'All sources']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = V.only;\n only.addEventListener('change', function () { V.only = only.value; renderWarnings(); });\n var rows = d.rows.filter(function (r) { return V.only === 'all' || r.findings.length; });\n w.appendChild(section('Sources', rows.length, filteredTable(H, rows, ['Source', 'Delete threshold', 'Aggregations', 'Failed', 'Last good one', 'Findings'], function (r) {\n return [el('span', {}, r.source, r.authoritative ? el('span', {}, ' ', pill('authoritative', 'blue')) : null, el('div', { className: 'small muted', text: r.type })), r.deleteThreshold === null ? '—' : r.deleteThreshold + '%', r.runs, r.failed ? pill(String(r.failed), 'lose') : '0', when16(r.lastOk) || '—',\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'Aggregation safety', only)));\n }\n\n // Warnings > Service accounts\n function wnServiceAccounts(w, _H, desc) {\n var H = mdState().svc;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Unused after' }), numSelect(H, 'unusedDays', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Unused after'));\n if (!mdRun(w, H, 'service-accounts', 'Check service accounts', desc, extras, function () { return { unusedDays: H.unusedDays }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'service and machine accounts'), stat(T.noOwner, 'without an owner', 'lose'), stat(T.enabledNoOwner, 'of them enabled', 'lose'), stat(T.ownerLeft, 'whose owner left', 'lose'), stat(T.unused, 'not used for ' + H.unusedDays + ' days')));\n if (!d.rows.length) return;\n if (d.byOwner.length) w.appendChild(section('Who owns them', d.byOwner.length, simpleTable(['Owner', 'State', 'Accounts owned'], d.byOwner.slice(0, 200).map(function (o) { return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.accounts)]; }), 'Service account owners')));\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Source', 'Owner', 'Account', 'Last used', 'Findings'], function (r) {\n return [el('span', {}, r.account, r.subtype ? el('div', { className: 'small muted', text: r.subtype }) : null), r.source, r.owner || el('span', { className: 'muted', text: 'none' }), r.enabled ? 'enabled' : 'disabled', r.lastUsed ? String(r.lastUsed).slice(0, 10) : '—', r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', {}, pill(f, 'lose')); })) : ''];\n }, 'Service and machine accounts')));\n }\n\n // Warnings > Several accounts\n function wnMultiAccounts(w, _H, desc) {\n var H = mdState().multi;\n if (!mdRun(w, H, 'multi-accounts', 'Find people with several accounts', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'active people'), stat(T.withDuplicates, 'with several accounts on one source'), stat(T.onAuthoritative, 'on the authoritative source', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Nobody has more than one account on the same source.' })); return; }\n w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'People with several accounts'], d.bySource.map(function (s) { return [s.source, fmtNum(s.people)]; }), 'Several accounts by source')));\n w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Source', 'Accounts', 'Account names'], function (r) {\n return [r.person, r.personState, el('span', {}, r.source, r.authoritative ? el('span', {}, ' ', pill('authoritative', 'lose')) : null), r.accounts + ' (' + r.enabled + ' enabled)', el('span', { className: 'small', text: r.names })];\n }, 'People with several accounts on one source')));\n }\n\n // Warnings > Password failures\n function wnPasswordFailures(w, _H, desc) {\n var H = mdState().pwfail;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n if (!mdRun(w, H, 'password-failures', 'Find failed password changes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'password events'), stat(T.passed, 'passed'), stat(T.failed, 'failed', 'lose'), stat(T.people, 'people affected', 'lose')));\n if (d.bySource.length > 1) w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'Passed', 'Failed'], d.bySource.map(function (s) { return [s.source, fmtNum(s.passed), s.failed ? pill(fmtNum(s.failed), 'lose') : '0']; }), 'Password events by source')));\n if (d.rows.length) w.appendChild(section('Failures', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['When', 'Person', 'Source', 'Event', 'Error'], function (r) { return [when16(r.when), r.person, r.source, r.event, el('span', { className: 'small', text: r.error })]; }, 'Password failures')));\n }\n\n // Warnings > Lifecycle settings\n function wnLifecycleSettings(w, _H, desc) {\n var H = mdState().lcset;\n if (!mdRun(w, H, 'lifecycle-settings', 'Read lifecycle states', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'identity profiles'), stat(T.states, 'lifecycle states'), stat(T.leaverStates, 'leaver states'), stat(T.flagged, 'with a finding', 'lose')));\n w.appendChild(section('Lifecycle states', d.rows.length, filteredTable(H, d.rows, ['Identity profile', 'State', 'People', 'What it does to accounts', 'Removes all access', 'Findings'], function (r) {\n return [r.profile, el('span', {}, r.state, ' ', pill(r.kind === 'leaver' ? 'leaver' : 'active', r.kind === 'leaver' ? 'off' : 'blue'), r.enabled ? null : el('span', {}, ' ', pill('switched off', 'lose'))), r.people === null ? '—' : fmtNum(r.people), el('span', { className: 'small', text: r.accounts }), r.removesAccess ? 'Yes' : 'No',\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'What each lifecycle state does')));\n }\n\n // Warnings > Governance groups\n function wnGovGroups(w, _H, desc) {\n var H = mdState().govgroups;\n if (!mdRun(w, H, 'gov-groups', 'Check governance groups', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.groups, 'governance groups'), stat(T.empty, 'without members', 'lose'), stat(T.nobodyActive, 'where every member left', 'lose'), stat(T.ownerLeft, 'whose owner left', 'lose'), stat(T.unused, 'not used anywhere')));\n if (!d.rows.length) return;\n w.appendChild(section('Groups', d.rows.length, filteredTable(H, d.rows, ['Group', 'Owner', 'Members', 'Members who left', 'Used in', 'Findings'], function (r) {\n return [r.group, el('span', {}, r.owner || '—', r.ownerState !== 'active' && r.owner ? el('span', {}, ' ', pill(r.ownerState, 'lose')) : null), r.activeMembers + ' of ' + r.members + ' active', el('span', { className: 'small', text: r.left.join(', ') }), r.usedIn === null ? '—' : r.usedIn + ' place' + (r.usedIn === 1 ? '' : 's'),\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'Governance groups')));\n }\n\n // If the program closed by itself last time, say where it was (from the small activity file).\n function showLastCrash() {\n api('/api/last-crash').then(function (r) {\n var c = r && r.crash;\n if (!c || $('crash-note')) return;\n var box = el('div', { id: 'crash-note', className: 'error', style: 'margin:12px auto;max-width:1240px;display:flex;gap:12px;align-items:flex-start' },\n el('div', { style: 'flex:1' }, el('b', { text: 'IdentityScope closed unexpectedly last time. ' }),\n 'It was ' + (c.doing || 'working') + ' (' + String(c.at || '').slice(0, 16).replace('T', ' ') + ' UTC). Progress: ' + (c.progress || 'unknown') + '. Memory in use: ' + c.memoryMB + ' of ' + c.limitMB + ' MB. Please send this line when you report it.'),\n el('button', { className: 'btn sm', text: 'Dismiss', onclick: function () { api('/api/last-crash/dismiss', 'POST', {}); box.remove(); } }));\n var host = document.querySelector('header');\n if (host && host.parentNode) host.parentNode.insertBefore(box, host.nextSibling);\n }).catch(function () {});\n }\n setTimeout(showLastCrash, 1200);\n\n // ---------- Warnings > Threat signals ----------\n var THREAT_NOTE = 'Signals to look into, not proof of an attack. IdentityScope reads them when you press the button; it does not watch in real time.';\n function threatNote(w) { w.appendChild(el('p', { className: 'muted small', style: 'margin:-6px 0 12px', text: THREAT_NOTE })); }\n function sigList(xs) { return el('div', {}, xs.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })); }\n function wnSignIns(w, _H, desc) {\n var H = mdState().signins;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Flag from' }), numSelect(H, 'minFailed', [[5, '5 failures a day'], [10, '10 failures a day'], [25, '25 failures a day'], [50, '50 failures a day']], 'Failures per day')));\n threatNote(w);\n if (!mdRun(w, H, 'signins', 'Read sign-ins', desc, extras, function () { return { days: H.days, minFailed: H.minFailed }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'sign-in events'), stat(T.failed, 'failed'), stat(T.people, 'people'), stat(T.flagged, 'people with a signal', 'lose'), stat(T.leaversSignedIn, 'leavers who signed in', 'lose')));\n if (d.byAddress.length) w.appendChild(section('One address, many people', d.byAddress.length, simpleTable(['Network address', 'People tried', 'Failed sign-ins'], d.byAddress.map(function (a) { return [a.address, fmtNum(a.people), fmtNum(a.failed)]; }), 'Addresses with failures for many people')));\n if (d.rows.length) w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'State', 'Failed', 'Successful', 'Worst day', 'Signals'], function (r) {\n return [el('span', {}, r.person, el('div', { className: 'small muted', text: r.username })), r.state === 'active' ? 'active' : pill(r.state, 'lose'), fmtNum(r.failed), fmtNum(r.passed), r.worstDay + ' (' + r.worstDayFailed + ')', sigList(r.signals)];\n }, 'Sign-in signals')));\n else if (T.events) w.appendChild(el('p', { className: 'muted', text: 'No sign-in signal in this period.' }));\n }\n function wnSelfApprovals(w, _H, desc) {\n var H = mdState().selfappr;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Requests of the last' }), numSelect(H, 'days', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'self-approvals', 'Find self-approvals', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.requests, 'requests'), stat(T.approvedSteps, 'approvals'), stat(T.selfApproved, 'approved their own access', 'lose'), stat(T.requesterApproved, 'approved what they requested for someone', 'lose')));\n if (d.rows.length) w.appendChild(section('Self-approvals', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Approved at', 'Access', 'Requested for', 'Requested by', 'Approved by', 'Finding'], function (r) { return [when16(r.when), r.access, r.requestedFor, r.requestedBy, r.approver, pill(r.kind, 'lose')]; }, 'Self-approvals')));\n else if (T.requests) w.appendChild(el('p', { className: 'muted', text: 'Nobody approved their own request.' }));\n }\n function wnAdminActivity(w, _H, desc) {\n var H = mdState().adminact;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'admin-activity', 'Read admin activity', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'changes by people'), stat(T.actors, 'who made them'), stat(T.byLeavers, 'are people who left', 'lose'), stat(T.unknownActors, 'are not a person in ISC')));\n if (d.actors.length) w.appendChild(section('Who made changes', d.actors.length, simpleTable(['Who', 'State', 'Changes', 'To what', 'Last change', 'Signals'], d.actors.slice(0, 300).map(function (a) {\n return [a.actor, a.state === 'active' ? 'active' : pill(a.state, a.state === 'not a person in ISC' ? 'off' : 'lose'), fmtNum(a.changes), a.kinds, when16(a.last), a.signals.length ? sigList(a.signals) : ''];\n }), 'Who made changes')));\n if (d.events.length) w.appendChild(section('Changes', d.events.length + (d.more || 0), filteredTable(H, d.events, ['When', 'Who', 'Event', 'On'], function (r) { return [when16(r.when), r.actor, r.event, r.target]; }, 'Administration changes')));\n }\n function wnAccessSpikes(w, _H, desc) {\n var H = mdState().spikes;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Flag from' }), numSelect(H, 'min', [[5, '5 items a day'], [15, '15 items a day'], [30, '30 items a day'], [100, '100 items a day']], 'Items per day')));\n threatNote(w);\n if (!mdRun(w, H, 'access-spikes', 'Find access spikes', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.activities, 'provisioning activities read'), stat(T.people, 'people who gained access'), stat(T.flagged, 'with ' + d.min + ' or more in one day', 'lose')));\n if (d.rows.length) w.appendChild(section('Access spikes', d.rows.length, filteredTable(H, d.rows, ['Person', 'State', 'Day', 'Added', 'Sources', 'Requested by', 'Examples'], function (r) { return [r.person, r.personState, r.day, pill(String(r.added), 'lose'), r.sources, r.requestedBy, el('span', { className: 'small', text: r.examples })]; }, 'Access spikes per person')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nobody was given that much access in one day.' }));\n }\n // ---------- 0.27.0: Logs page; privileged access gained, accounts created outside ISC, sensitive changes, risk by person; joiner and leaver preview; stuck requests ----------\n function lgState() {\n if (!state.lg) {\n var saved = '';\n try { saved = localStorage.getItem('identityscope.logpath') || ''; } catch (e) { saved = ''; }\n state.lg = { tab: 'ccg', ccg: { path: saved, level: 'WARN', source: '', text: '', from: '', to: '', open: {} }, isc: { days: 2, source: '', failedOnly: true } };\n }\n return state.lg;\n }\n var LG_TABS = [\n ['ccg', 'Connector log (ccg.log)', 'file', 'Read the connector log of a Virtual Appliance from a copy on this computer: errors grouped and counted, per source, with the full error detail.'],\n ['isc', 'What ISC recorded', 'pulse', 'One timeline per source of what ISC itself recorded: aggregations, source changes, provisioning that ended with an error, and the state of the Virtual Appliances.']\n ];\n function tw() {\n if (!state.tw) state.tw = { priv: { remember: true }, outacct: { days: 7 }, sensitive: { days: 7 }, risk: { days: 7 }, upcoming: { days: 14, startDateAttribute: '', endDateAttribute: '', query: '' }, stuckreq: { hours: 24 } };\n return state.tw;\n }\n function renderLogs() {\n var L = lgState();\n var outer = $('logs');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#1d4ed8;background:#dbeafe' }, icon('file')),\n el('div', {}, el('h2', { text: 'Logs' }), el('p', { className: 'desc', text: 'Find out why a source failed without signing in to a server. Read-only; nothing from a log is stored or sent anywhere.' }))));\n var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });\n LG_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (L.tab === t[0] ? ' active' : ''), onclick: function () { L.tab = t[0]; renderLogs(); } }, icon(t[2]), t[1])); });\n w.appendChild(tabs);\n var spec = LG_TABS.filter(function (t) { return t[0] === L.tab; })[0];\n if (L.tab === 'ccg') lgCcg(w, L.ccg, spec[3]); else lgIsc(w, L.isc, spec[3]);\n }\n function lgField(H, key, label, placeholder, width, type) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder || '', style: 'max-width:' + (width || 200) + 'px', 'aria-label': label, type: type || 'text' });\n i.addEventListener('input', function () { H[key] = i.value; });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function lgFilter(H) { return { level: H.level, source: H.source || undefined, text: H.text || undefined, from: H.from || undefined, to: H.to || undefined }; }\n function lgCcg(w, H, desc) {\n w.appendChild(el('p', { className: 'muted', style: 'margin:0 0 10px', text: desc }));\n w.appendChild(el('div', { className: 'note', text: 'ISC has no way to hand out ccg.log, so IdentityScope reads a copy: copy the file from the Virtual Appliance (/home/sailpoint/log/ccg.log) to this computer or a shared folder once, then give its path here or choose the file. A folder reads every log file in it, rotated and .gz files included.' }));\n var path = el('input', { className: 'input', value: H.path || '', placeholder: 'C:\\\\logs\\\\ccg.log or /home/me/va-logs', style: 'min-width:320px;flex:1', 'aria-label': 'Path of ccg.log or its folder on this computer' });\n path.addEventListener('input', function () { H.path = path.value; });\n var picker = el('input', { type: 'file', className: 'hidden', 'aria-label': 'Choose a log file', accept: '.log,.txt,.json,.jsonl,.gz,*/*' });\n var run = function () {\n try { localStorage.setItem('identityscope.logpath', H.path || ''); } catch (e) { /* not kept */ }\n H.open = {};\n runJobInto(H, '/api/logs/ccg/run', Object.assign({ path: H.path }, lgFilter(H)), renderLogs);\n };\n picker.addEventListener('change', function () {\n var f = picker.files && picker.files[0];\n if (!f) return;\n var q = lgFilter(H); q.name = f.name;\n var qs = Object.keys(q).filter(function (k) { return q[k]; }).map(function (k) { return k + '=' + encodeURIComponent(q[k]); }).join('&');\n H.busy = 'Reading ' + f.name + ' (' + fmtNum(Math.round(f.size / 1048576)) + ' MB)...'; H.error = null; H.data = null; H.open = {}; renderLogs();\n fetch('/api/logs/ccg/upload?' + qs, { method: 'POST', headers: { 'x-isc-reports-key': KEY, 'content-type': 'application/octet-stream' }, body: f }).then(function (res) {\n return res.json().then(function (d) { if (!res.ok) throw new Error(d.error || 'The file could not be read.'); return d; });\n }).then(function (r) {\n H.job = r.job;\n pollJob(r.job, function (m) { H.busy = m; renderLogs(); }, function (s) { H.busy = null; H.data = s.extra; renderLogs(); }, function (e) { H.busy = null; H.error = e; renderLogs(); });\n }, function (e) { H.busy = null; H.error = errorText(e); renderLogs(); });\n });\n var level = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Which lines' }, [['ERROR', 'Errors only'], ['WARN', 'Errors and warnings'], ['INFO', 'Everything but debug'], ['DEBUG', 'Everything']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n level.value = H.level;\n level.addEventListener('change', function () { H.level = level.value; });\n w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' },\n el('div', { className: 'bar' }, el('label', { className: 'field', style: 'margin:0;flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'File or folder on this computer' }), path),\n el('button', { className: 'btn primary', disabled: !!H.busy || !(H.path || '').trim(), onclick: run }, icon('play'), H.data ? 'Read again' : 'Read the log'),\n el('span', { className: 'muted small', text: 'or' }),\n el('button', { className: 'btn', disabled: !!H.busy, onclick: function () { picker.click(); } }, icon('file'), 'Choose a file'), picker),\n el('div', { className: 'bar', style: 'margin-top:10px' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Lines' }), level),\n lgField(H, 'source', 'Source name contains', 'e.g. Active Directory', 200),\n lgField(H, 'text', 'Message contains', 'e.g. timeout', 180),\n lgField(H, 'from', 'From', '', 200, 'datetime-local'),\n lgField(H, 'to', 'To', '', 200, 'datetime-local'))));\n // The path field must be enabled as soon as something is typed.\n path.addEventListener('input', function () { var b = w.querySelector('button.primary'); if (b) b.disabled = !!H.busy || !path.value.trim(); });\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.lines, 'lines in the file'), stat(T.matched, 'lines kept by the filter'), stat(T.errors, 'errors', 'lose'), stat(T.warnings, 'warnings', 'lose'), stat(T.groups, 'different errors and warnings'), stat(d.bySource.length, 'sources')));\n if (T.first) w.appendChild(el('p', { className: 'muted small', style: 'margin:-4px 0 12px', text: 'From ' + when16(T.first) + ' to ' + when16(T.last) + ' (times as written in the log, UTC). ' + (d.files || []).length + ' file' + ((d.files || []).length === 1 ? '' : 's') + ' read.' }));\n if (d.byHour.length > 1) {\n var max = Math.max.apply(null, d.byHour.map(function (h) { return h.errors + h.warnings; })) || 1;\n var strip = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:64px;margin:4px 0 6px', role: 'img', 'aria-label': 'Errors and warnings per hour' });\n d.byHour.forEach(function (h) {\n var n = h.errors + h.warnings;\n strip.appendChild(el('div', { title: h.hour.replace('T', ' ') + ':00 ' + h.errors + ' errors, ' + h.warnings + ' warnings', style: 'flex:1;min-width:2px;max-width:18px;height:' + Math.max(2, Math.round(n * 60 / max)) + 'px;background:' + (h.errors ? '#dc2626' : n ? '#d97706' : '#e5e7eb') }));\n });\n w.appendChild(section('Errors and warnings per hour', d.byHour.length, el('div', {}, strip, el('div', { className: 'muted small', style: 'display:flex;justify-content:space-between' }, el('span', { text: d.byHour[0].hour.replace('T', ' ') + ':00' }), el('span', { text: d.byHour[d.byHour.length - 1].hour.replace('T', ' ') + ':00' })))));\n }\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'Type', 'Lines', 'Errors', 'Warnings', 'Last error', 'At'], d.bySource.map(function (r) {\n return [r.source, r.type, fmtNum(r.lines), r.errors ? pill(fmtNum(r.errors), 'lose') : '0', fmtNum(r.warnings), el('span', { className: 'small', text: r.lastError || '' }), when16(r.lastErrorAt)];\n }), 'Per source')));\n if (d.groups.length) {\n w.appendChild(section('Errors and warnings, repeats counted once', d.groups.length + (d.moreGroups || 0), filteredTable(H, d.groups, ['Level', 'Source', 'Operation', 'Times', 'First', 'Last', 'Message'], function (g) {\n var key = g.level + '|' + g.source + '|' + g.operation + '|' + g.pattern;\n var detail = el('div', { className: H.open[key] ? '' : 'hidden' }, el('pre', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word;margin:6px 0 0;max-height:320px;overflow:auto', text: g.example + (g.exception ? '\\n\\n' + g.exception : '') }), g.logger ? el('div', { className: 'muted small', text: 'Logger: ' + g.logger }) : null);\n var btn = el('button', { className: 'linkbtn small', 'aria-expanded': String(!!H.open[key]), onclick: function () { H.open[key] = !H.open[key]; detail.classList.toggle('hidden', !H.open[key]); btn.setAttribute('aria-expanded', String(!!H.open[key])); btn.textContent = H.open[key] ? 'Hide detail' : 'Show detail'; } }, H.open[key] ? 'Hide detail' : 'Show detail');\n return [(/ERR|FATAL/.test(g.level) ? pill(g.level, 'lose') : el('span', { style: 'color:#92400e;font-weight:600', text: g.level })), g.source, g.operation, fmtNum(g.count), when16(g.first), when16(g.last), el('div', {}, el('div', { className: 'small', text: g.example.slice(0, 260) + (g.example.length > 260 ? '…' : '') }), btn, detail)];\n }, 'Errors and warnings')));\n } else w.appendChild(el('p', { className: 'muted', text: T.read ? 'No errors or warnings in what the filter kept.' : '' }));\n if (d.latest.length) w.appendChild(section('Latest lines kept by the filter', d.latest.length, simpleTable(['Time', 'Level', 'Source', 'Operation', 'Message'], d.latest.slice(0, 200).map(function (r) {\n return [when16(r.time), r.level, r.source, r.operation, el('span', { className: 'small', text: r.message.slice(0, 400) })];\n }), 'Latest lines')));\n }\n function lgIsc(w, H, desc) {\n var only = el('input', { type: 'checkbox', checked: !!H.failedOnly, 'aria-label': 'Only what failed' });\n only.addEventListener('change', function () { H.failedOnly = only.checked; });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [2, '2 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n lgField(H, 'source', 'Source (exact name, optional)', 'all sources', 220),\n el('label', { style: 'display:flex;gap:6px;align-items:center' }, only, 'Only what failed'));\n if (!owRunBar(w, H, '/api/watch/source-log/run', 'Read what ISC recorded', desc, extras, function () { return { days: H.days, source: H.source || undefined, failedOnly: !!H.failedOnly }; }, renderLogs)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'aggregation and source events'), stat(T.failed, 'failed', 'lose'), stat(T.provisioningErrors, 'provisioning errors', 'lose'), stat(T.appliancesNotNormal, 'Virtual Appliances not normal', 'lose')));\n if (d.appliances.length) w.appendChild(section('Virtual Appliances now', d.appliances.length, simpleTable(['Cluster', 'Appliance', 'Status', 'Alert', 'Last seen', 'Sources on the cluster'], d.appliances.map(function (a) {\n return [a.cluster, a.client, a.status === 'NORMAL' ? a.status : pill(a.status || 'unknown', 'lose'), a.alert, when16(a.lastSeen), fmtNum(a.sources)];\n }), 'Virtual Appliances')));\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'Type', 'Aggregations', 'Failed', 'Last aggregation', 'Provisioning errors', 'Last error', 'Cluster'], d.bySource.map(function (r) {\n return [r.source, r.type, fmtNum(r.aggregations), r.failedAggregations ? pill(String(r.failedAggregations), 'lose') : '0', r.lastAggregation ? el('span', {}, when16(r.lastAggregation), ' ', /fail|error/i.test(r.lastAggregationStatus || '') ? pill(r.lastAggregationStatus, 'lose') : el('span', { className: 'muted small', text: r.lastAggregationStatus || '' })) : '', r.provisioningErrors ? pill(String(r.provisioningErrors), 'lose') : '0', el('span', { className: 'small', text: r.lastError || '' }), r.cluster ? el('span', {}, r.cluster, r.clusterStatus && r.clusterStatus !== 'NORMAL' ? el('div', {}, pill(r.clusterStatus, 'lose')) : null) : ''];\n }), 'Per source')));\n if (d.rows.length) w.appendChild(section('Timeline', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['When', 'Source', 'Kind', 'Status', 'What', 'Detail', 'Who'], function (r) {\n return [when16(r.when), r.source, r.kind, /fail|error/i.test(r.status) ? pill(r.status, 'lose') : r.status, r.what, el('span', { className: 'small', style: 'word-break:break-word', text: r.detail }), r.who];\n }, 'Timeline')));\n else w.appendChild(el('p', { className: 'muted', text: 'ISC recorded nothing ' + (H.failedOnly ? 'that failed ' : '') + 'in the period.' }));\n }\n\n // Warnings > Threat signals > Privileged access gained\n function wnPrivGained(w, _H, desc) {\n var H = tw().priv;\n var keep = el('input', { type: 'checkbox', checked: H.remember !== false, 'aria-label': 'Remember this look' });\n keep.addEventListener('change', function () { H.remember = keep.checked; });\n var extras = el('label', { style: 'display:flex;gap:6px;align-items:center', title: 'Untick to compare again with the same earlier look' }, keep, 'Remember this look for next time');\n threatNote(w);\n if (!mdRun(w, H, 'priv-gained', 'Find new privileged access', desc, extras, function () { return { remember: H.remember !== false }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.holdings, 'privileged entitlements held'), stat(T.people, 'people holding them'), stat(d.baseline ? null : T.fresh, 'gained since the previous look'), stat(d.baseline ? null : T.outside, 'of those with no ISC record', 'lose'), stat(d.baseline ? null : T.lost, 'no longer held')));\n if (d.since) w.appendChild(el('p', { className: 'muted small', style: 'margin:-4px 0 12px', text: 'Compared with the look of ' + when16(d.since) + '. Findings of the last 90 days stay listed while the person still holds the access.' }));\n var fresh = {}; (d.freshKeys || []).forEach(function (k) { fresh[k] = true; });\n if (d.findings && d.findings.length) w.appendChild(section('Privileged access gained', d.findings.length + (d.more || 0), filteredTable(H, d.findings, ['Found', 'Person', 'Privileged entitlement', 'Source', 'Held', 'How it got there', 'Requested by'], function (r) {\n return [el('span', {}, r.found.slice(0, 10), fresh[r.key] ? el('div', {}, pill('new', 'gain')) : null), el('span', {}, r.person, el('div', { className: 'muted small', text: r.personState + (r.newPerson ? ' · new identity' : '') })), r.entitlement, r.source, r.via, r.how === 'No ISC record' ? pill(r.how, 'lose') : el('span', {}, r.how, r.when ? el('div', { className: 'muted small', text: when16(r.when) }) : null), r.requestedBy || ''];\n }, 'Privileged access gained')));\n else if (!d.baseline) w.appendChild(el('p', { className: 'muted', text: 'Nobody gained a privileged entitlement since the previous look.' }));\n }\n // Warnings > Threat signals > Accounts created outside ISC\n function wnOutsideAccounts(w, _H, desc) {\n var H = tw().outacct;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Appeared in the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'outside-accounts', 'Find accounts created outside ISC', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts ISC did not create'), stat(T.uncorrelated, 'owned by nobody', 'lose'), stat(T.ownerLeft, 'owner has left', 'lose'), stat(T.withAccess, 'already have access'), stat(T.provisioned, 'new accounts ISC created itself')));\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'New accounts not created by ISC', 'Accounts on the source', 'Note'], d.bySource.map(function (r) { return [r.source, fmtNum(r.fresh), r.total === null ? '—' : fmtNum(r.total), el('span', { className: 'muted small', text: r.note })]; }), 'Per source')));\n if (d.rows.length) w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Appeared', 'Account', 'Source', 'Owner', 'Has access', 'State', 'Signals'], function (r) {\n return [when16(r.created), el('span', {}, r.account, r.nativeIdentity && r.nativeIdentity !== r.account ? el('div', { className: 'muted small', style: 'word-break:break-all', text: r.nativeIdentity }) : null), r.source, el('span', {}, r.owner || '—', el('div', { className: 'muted small', text: r.ownerState })), r.hasEntitlements ? 'yes' : 'no', r.disabled ? 'disabled' : 'enabled', r.signals.length ? (r.signals[0] === 'Source newly connected' ? el('span', { className: 'muted small', text: r.signals[0] }) : sigList(r.signals)) : ''];\n }, 'Accounts created outside ISC')));\n else w.appendChild(el('p', { className: 'muted', text: 'No account appeared in the period that ISC did not create itself.' }));\n }\n // Warnings > Threat signals > Sensitive changes\n function wnSensitive(w, _H, desc) {\n var H = tw().sensitive;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compared with' }), numSelect(H, 'days', [[1, 'yesterday or before'], [7, 'a week ago or before'], [30, 'a month ago or before'], [90, '3 months ago or before']], 'Compared with'));\n threatNote(w);\n if (!mdRun(w, H, 'sensitive', 'Find sensitive changes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n if (d.baseline) return;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.high, 'high', 'lose'), stat(T.medium, 'medium'), stat(T.credentials, 'new API credentials'), stat(T.areas, 'areas touched')));\n if (d.rows.length) w.appendChild(section('Changes since ' + d.from, d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Severity', 'Area', 'Object', 'Change', 'Why it matters', 'Who', 'When'], function (r) {\n return [r.severity === 'high' ? pill('high', 'lose') : 'medium', r.area, r.object, el('span', { className: 'small', style: 'word-break:break-word', text: r.change }), el('span', { className: 'muted small', text: r.why }), r.who, when16(r.when)];\n }, 'Sensitive changes')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nothing that touches a control changed since ' + d.from + '.' }));\n }\n // Warnings > Threat signals > Risk by person\n function wnRisk(w, _H, desc) {\n var H = tw().risk;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Signals of the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'risk', 'Add up the signals', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'people with a signal'), stat(T.several, 'on more than one screen', 'lose'), stat(T.signals, 'signals in all')));\n if (d.rows.length) w.appendChild(section('People, highest first', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Score', 'Screens', 'Signals'], function (r) {\n return [r.person, r.screens > 1 ? pill(String(r.score), 'lose') : String(r.score), String(r.screens), el('div', {}, r.signals.map(function (s) { return el('div', { className: 'small', text: s }); }))];\n }, 'Risk by person')));\n else w.appendChild(el('p', { className: 'muted', text: 'No person has a signal in the period.' }));\n }\n // Warnings > Joiners, movers, leavers > Coming up\n function wnUpcoming(w, _H, desc) {\n var H = tw().upcoming;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.country:US', style: 'max-width:220px', 'aria-label': 'Only people matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Next' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period')),\n attrInput(H, 'startDateAttribute', 'Start-date attribute', 'startDate'), attrInput(H, 'endDateAttribute', 'End-date attribute', 'endDate'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only people matching (optional)' }), q));\n if (!mdRun(w, H, 'jml-preview', 'Show who is coming up', desc, extras, function () { return { days: H.days, startDateAttribute: H.startDateAttribute || undefined, endDateAttribute: H.endDateAttribute || undefined, query: H.query || undefined }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.starts, 'start in the period'), stat(T.ends, 'end in the period'), stat(T.findings, 'with something to check', 'lose'), stat(T.checked, 'identities read')));\n var busy = d.perDay.filter(function (p) { return p.starts || p.ends; });\n if (busy.length) w.appendChild(section('Per day', busy.length, simpleTable(['Day', 'Start', 'End'], busy.map(function (p) { return [p.day, p.starts ? fmtNum(p.starts) : '', p.ends ? fmtNum(p.ends) : '']; }), 'Per day')));\n if (d.rows.length) w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Date', 'Kind', 'Person', 'Manager', 'Identity profile', 'Lifecycle state now', 'Accounts', 'Access', 'To check'], function (r) {\n return [el('span', {}, r.date, el('div', { className: 'muted small', text: daysText(r.inDays) })), pill(r.kind, r.kind === 'Ends' ? 'lose' : 'gain'), el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.manager || '', r.profile, el('span', {}, r.lifecycle, r.stateNow ? el('div', { className: 'muted small', text: r.stateNow }) : null), r.accounts === null ? '' : fmtNum(r.accounts), r.access === null ? '' : fmtNum(r.access), r.findings.length ? sigList(r.findings) : ''];\n }, 'Joiners and leavers coming up')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nobody has a start or end date in the period.' }));\n if (d.states.length) w.appendChild(section('What the lifecycle states of these identity profiles do', d.states.length, simpleTable(['Identity profile', 'Lifecycle state', 'Kind', 'Accounts', 'Removes all access', 'Findings'], d.states.map(function (s) {\n return [s.profile, el('span', {}, s.state, s.enabled ? null : el('span', { className: 'muted small', text: ' (off)' })), s.kind === 'leaver' ? 'leaver state' : 'active state', el('span', { className: 'small', text: s.accounts }), s.removesAccess ? 'yes' : 'no', s.findings.length ? sigList(s.findings) : ''];\n }), 'Lifecycle states')));\n }\n // Warnings > Requests and reviews > Stuck requests\n function wnStuckReq(w, _H, desc) {\n var H = tw().stuckreq;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Running for more than' }), numSelect(H, 'hours', [[4, '4 hours'], [24, '1 day'], [72, '3 days'], [168, '7 days'], [720, '30 days']], 'Running for more than'));\n if (!mdRun(w, H, 'stuck-requests', 'Find stuck requests', desc, extras, function () { return { hours: H.hours }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.running, 'requests still running'), stat(T.stuck, 'longer than the limit', 'lose'), stat(T.approval, 'waiting in approval'), stat(T.provisioning, 'waiting in provisioning'), stat(T.churningSources, 'sources ISC keeps re-sending to', 'lose')));\n if (d.byPhase.length) w.appendChild(section('Where they wait', d.byPhase.length, simpleTable(['Phase', 'Requests', 'Oldest'], d.byPhase.map(function (p) { return [p.phase, fmtNum(p.requests), hrs(p.oldestHours)]; }), 'Where they wait')));\n if (d.churn.length) w.appendChild(section('Sources ISC keeps sending the same change to (last 2 days)', d.churn.length, simpleTable(['Source', 'Repeated changes', 'People', 'Example'], d.churn.map(function (c) { return [c.source, pill(fmtNum(c.changes), 'lose'), fmtNum(c.people), el('span', { className: 'small', text: c.example })]; }), 'Churning sources')));\n if (d.rows.length) w.appendChild(section('Stuck requests', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Submitted', 'Running', 'Access', 'Requested for', 'Phase', 'Waiting on', 'Why'], function (r) {\n return [when16(r.submitted), hrs(r.hours), el('span', {}, r.access, el('div', { className: 'muted small', text: r.type })), el('span', {}, r.requestedFor, r.requestedBy && r.requestedBy !== r.requestedFor ? el('div', { className: 'muted small', text: 'by ' + r.requestedBy }) : null), el('span', {}, r.phase, r.phaseHours === null ? null : el('div', { className: 'muted small', text: 'for ' + hrs(r.phaseHours) })), r.waitingOn, el('span', {}, r.reason, r.errors ? el('div', { className: 'small', style: 'color:var(--danger)', text: r.errors }) : null)];\n }, 'Stuck requests')));\n else w.appendChild(el('p', { className: 'muted', text: 'No request has been running that long.' }));\n }\n})();\n</script>\n</body>\n</html>\n";
2
+ export const UI_PAGE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>IdentityScope</title>\n<style>\n:root{\n --bg:#f3f5f9;--panel:#fff;--sunken:#f7f8fb;--text:#0f172a;--text2:#334155;--muted:#5b6577;--faint:#64748b;\n --line:#e3e8ef;--line2:#cbd5e1;--accent:#2457d6;--accent2:#1d47b3;--accent-soft:#eaf0fd;--accent-ring:rgba(36,87,214,.18);\n --danger:#b42318;--danger-soft:#fdeceb;--warn:#8a5a00;--warn-soft:#fff6e0;--ok:#067647;--ok-soft:#e6f6ec;\n --nav:#0d1b33;--nav2:#16284a;--radius:10px;--shadow:0 1px 2px rgba(15,23,42,.05),0 1px 3px rgba(15,23,42,.06);--shadow2:0 10px 30px rgba(15,23,42,.14);\n}\n*{box-sizing:border-box}\nhtml,body{height:100%}\nbody{margin:0;font:14px/1.5 \"Segoe UI Variable Text\",\"Segoe UI\",-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased}\nbutton,input,select,textarea{font:inherit;color:inherit}\na{color:var(--accent)}\ncode{font:12.5px ui-monospace,\"Cascadia Mono\",Consolas,monospace;background:var(--sunken);border:1px solid var(--line);border-radius:5px;padding:1px 5px}\nsvg.i{width:16px;height:16px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:-3px}\n.hidden{display:none!important}\n.muted{color:var(--muted)}\n.small{font-size:12.5px}\n\n/* top bar */\nheader{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:14px;height:56px;padding:0 20px;background:var(--nav);color:#fff;box-shadow:0 1px 0 rgba(255,255,255,.04)}\n.brand{display:flex;align-items:center;gap:10px;font-weight:650;font-size:16px;letter-spacing:-.01em}\n.logo{width:30px;height:30px;border-radius:8px;background:linear-gradient(135deg,#3d7bff,#1d47b3);display:grid;place-items:center;font-size:12px;font-weight:800;letter-spacing:.02em}\nnav{display:flex;gap:2px;margin-left:10px}\n.navbtn{display:flex;align-items:center;gap:7px;background:transparent;border:none;color:rgba(255,255,255,.7);padding:7px 13px;border-radius:8px;cursor:pointer}\n.navbtn:hover{color:#fff;background:rgba(255,255,255,.07)}\n.navbtn.active{background:var(--nav2);color:#fff;font-weight:600}\n@media (max-width:2500px){.navbtn{padding:7px 9px}}\n@media (max-width:2280px){.navbtn{padding:7px 6px;gap:5px}.navbtn svg.i{display:none}.tenant{max-width:260px}.tagline{display:none}.hbtn{padding:6px 9px}}\n@media (max-width:1900px){.hbtn svg.i{display:none}.calls{display:none}.tenant{max-width:200px}header{gap:10px}}\n.navbtn,.hbtn,.tenant{white-space:nowrap}\n@media (max-width:1900px){.calls{display:none}.brand{font-size:0}.brand .logo{font-size:12px}nav{margin-left:2px}}\n.spacer{flex:1}\n.tenant{display:flex;align-items:center;gap:8px;font-size:12.5px;color:rgba(255,255,255,.82);background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);border-radius:999px;padding:4px 12px 4px 10px;max-width:420px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.dot{width:8px;height:8px;border-radius:50%;background:#34d399;box-shadow:0 0 0 3px rgba(52,211,153,.18);flex-shrink:0}\n.hbtn{display:flex;align-items:center;gap:7px;background:transparent;border:1px solid rgba(255,255,255,.2);color:#fff;border-radius:8px;padding:6px 12px;cursor:pointer;font-size:13px}\n.hbtn:hover{background:rgba(255,255,255,.08)}\n\n/* buttons and inputs */\n.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid var(--line2);background:#fff;border-radius:8px;padding:7px 14px;cursor:pointer;font-weight:500;white-space:nowrap;transition:background .12s,border-color .12s,box-shadow .12s}\n.btn:hover{background:var(--sunken);border-color:#b6c2d2}\n.btn:focus-visible,.input:focus,.field input:focus,.field select:focus,select.input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}\n.btn.primary:hover{background:var(--accent2);border-color:var(--accent2)}\n.btn.ghost{border-color:transparent;background:transparent;color:var(--text2)}\n.btn.ghost:hover{background:var(--sunken)}\n.btn.link{border:none;background:none;color:var(--accent);padding:6px 4px;font-weight:600}\n.btn.link:hover{text-decoration:underline;background:none}\n.btn.sm{padding:4px 10px;font-size:13px;border-radius:7px}\n.btn.icon{padding:5px 7px}\n.btn.danger{color:var(--danger)}\n.btn:disabled{opacity:.5;cursor:default}\na.btn{text-decoration:none}\na.btn:hover{text-decoration:none}\n.input,.field input,.field select,.field textarea{display:block;width:100%;padding:8px 11px;border:1px solid var(--line2);border-radius:8px;background:#fff;color:var(--text);font-size:14px;transition:border-color .12s,box-shadow .12s}\nselect.input,.field select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#64748b 50%),linear-gradient(135deg,#64748b 50%,transparent 50%);background-position:calc(100% - 15px) 52%,calc(100% - 10px) 52%;background-size:5px 5px;background-repeat:no-repeat;padding-right:30px}\n.field{display:block;margin-bottom:14px}\n.field>span.lbl{display:block;font-size:12.5px;font-weight:600;color:var(--text2);margin-bottom:5px}\n.field .hint{display:block;font-size:12px;color:var(--muted);margin-top:4px}\n.req{color:var(--danger);margin-left:2px}\n.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px 16px}\n.grid .field{margin-bottom:0}\n.bar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}\n.check{display:inline-flex;align-items:center;gap:7px;margin-right:16px;font-size:14px;cursor:pointer}\n.check input{width:16px;height:16px;accent-color:var(--accent)}\n\n/* messages */\n.error{background:var(--danger-soft);color:var(--danger);border:1px solid #f6c9c5;border-radius:8px;padding:9px 12px;margin:10px 0;white-space:pre-wrap;font-size:13px}\n.note{background:var(--warn-soft);color:var(--warn);border:1px solid #f3dd9f;border-radius:8px;padding:8px 12px;margin:8px 0;font-size:13px}\n.success{background:var(--ok-soft);color:var(--ok);border:1px solid #b9e5c8;border-radius:8px;padding:8px 12px;margin:8px 0;font-size:13px}\n.progress{display:flex;align-items:center;gap:10px;color:var(--muted);margin:14px 0}\n.spinner{width:16px;height:16px;border:2px solid #d5dde8;border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.pill{display:inline-flex;align-items:center;gap:5px;border-radius:999px;padding:2px 9px;font-size:12px;font-weight:600;white-space:nowrap}\n.pill.on{background:var(--ok-soft);color:var(--ok)}.pill.off{background:#eef1f5;color:var(--muted)}.pill.blue{background:var(--accent-soft);color:var(--accent)}\n.tag{display:inline-block;font-size:11.5px;color:var(--muted);background:var(--sunken);border:1px solid var(--line);border-radius:999px;padding:0 8px;margin:0 4px 4px 0}\n#toast{position:fixed;bottom:22px;left:50%;transform:translateX(-50%);background:#0f172a;color:#fff;border-radius:10px;padding:10px 16px;box-shadow:var(--shadow2);font-size:13.5px;z-index:30;transition:opacity .2s}\n\n/* cards */\n.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:18px 20px;margin-bottom:16px}\n.card-h{display:flex;align-items:center;gap:10px;margin:0 0 14px}\n.card-h h3{margin:0;font-size:15px;font-weight:650;flex:1;display:flex;align-items:center;gap:9px}\n.step{width:24px;height:24px;border-radius:50%;background:var(--accent-soft);color:var(--accent);display:grid;place-items:center;font-size:12px;font-weight:700;flex-shrink:0}\n\n/* connect */\n#connect{max-width:980px;margin:40px auto;padding:0 20px}\n.connect-hero{text-align:center;margin-bottom:26px}\n.connect-hero h2{font-size:26px;letter-spacing:-.02em;margin:10px 0 6px}\n.connect-hero p{color:var(--muted);margin:0}\n.connect-cols{display:grid;grid-template-columns:1.1fr 1fr;gap:18px;align-items:start}\n@media (max-width:860px){.connect-cols{grid-template-columns:1fr}}\n.connect-cols .card{padding:24px}\n.connect-cols h3{margin:0 0 4px;font-size:16px;display:flex;align-items:center;gap:8px}\n.connect-cols p.lead{color:var(--muted);margin:0 0 18px;font-size:13.5px}\ndetails.help{font-size:13px;color:var(--text2);background:var(--sunken);border:1px solid var(--line);border-radius:8px;padding:10px 12px;margin-top:16px}\ndetails.help summary{cursor:pointer;font-weight:600}\ndetails.help ol{margin:8px 0 0 18px;padding:0}\ndetails.help li{margin:3px 0}\n.saved{display:flex;align-items:center;gap:12px;background:var(--accent-soft);border:1px solid #cddcfb;border-radius:var(--radius);padding:12px 16px;margin-bottom:18px}\n\n/* reports layout */\n#app{display:flex;height:calc(100vh - 56px)}\naside{width:290px;flex-shrink:0;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column}\n.aside-top{padding:14px 14px 8px;display:flex;flex-direction:column;gap:10px}\n.searchbox{position:relative}\n.searchbox svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--faint)}\n.searchbox input{padding-left:33px}\n#library{overflow-y:auto;padding:4px 10px 18px;flex:1}\n.group{margin:10px 0 4px}\n.group-h{display:flex;align-items:center;gap:8px;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:700;padding:4px 6px}\n.group-h .count{margin-left:auto;font-weight:600;letter-spacing:0}\n.entry{display:block;width:100%;text-align:left;background:none;border:none;border-radius:7px;padding:6px 10px;cursor:pointer;color:var(--text2);font-size:13.5px;line-height:1.35}\n.entry:hover{background:var(--sunken);color:var(--text)}\n.entry.active{background:var(--accent-soft);color:var(--accent);font-weight:600}\n#main{flex:1;min-width:0;overflow-y:auto}\n#content{outline:none}\n.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\nbutton:focus-visible,a:focus-visible,[tabindex]:focus-visible,.navbtn:focus-visible,.hbtn:focus-visible,.tab:focus-visible,.chk:focus-visible,.pval:focus-visible{outline:2px solid #2563eb;outline-offset:2px}\n.skip{position:absolute;left:-9999px;top:8px;z-index:20;background:#fff;color:#0f172a;padding:8px 12px;border-radius:8px}\n.skip:focus{left:12px}\n.wrap{max-width:1240px;margin:0 auto;padding:22px 28px 60px}\n\n/* home */\n.hero{background:linear-gradient(135deg,#0d1b33 0%,#1b3a75 60%,#2457d6 100%);color:#fff;border-radius:14px;padding:28px 30px;margin-bottom:20px;position:relative;overflow:hidden}\n.hero h2{font-size:24px;letter-spacing:-.02em;margin:0 0 6px}\n.hero p{margin:0 0 18px;color:rgba(255,255,255,.8);max-width:640px}\n.hero .searchbox{max-width:560px}\n.hero .searchbox input{border:none;padding-top:11px;padding-bottom:11px;font-size:15px;box-shadow:0 6px 20px rgba(0,0,0,.18)}\n.hero-stats{display:flex;gap:22px;margin-top:18px;font-size:13px;color:rgba(255,255,255,.8)}\n.hero-stats b{color:#fff;font-size:18px;display:block}\n.hero .btn{background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.35);color:#fff}\n.hero .btn:hover{background:rgba(255,255,255,.2)}\n.chips{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 16px}\n.chip{border:1px solid var(--line2);background:#fff;border-radius:999px;padding:5px 12px;cursor:pointer;font-size:13px;color:var(--text2);display:inline-flex;align-items:center;gap:6px}\n.chip:hover{border-color:#9fb0c6}\n.chip.active{background:var(--text);border-color:var(--text);color:#fff}\n.sec-h{display:flex;align-items:baseline;gap:10px;margin:22px 0 10px}\n.sec-h h3{margin:0;font-size:15px}\n.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:14px}\n.rcard{display:flex;flex-direction:column;gap:8px;text-align:left;background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px;cursor:pointer;box-shadow:var(--shadow);transition:transform .12s,box-shadow .12s,border-color .12s;min-height:142px}\n.rcard:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(15,23,42,.1);border-color:#c9d5e6}\n.rcard .top{display:flex;align-items:center;gap:10px}\n.rcard h3{margin:0;font-size:14.5px;line-height:1.3}\n.rcard p{margin:0;color:var(--muted);font-size:13px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}\n.rcard .foot{margin-top:auto;display:flex;gap:6px;align-items:center;font-size:12px;color:var(--faint)}\n.cat-ico{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;flex-shrink:0}\n.cat-ico svg.i{width:18px;height:18px}\n\n/* report view */\n.crumbs{font-size:12.5px;color:var(--muted);display:flex;align-items:center;gap:6px;margin-bottom:8px}\n.crumbs button{background:none;border:none;color:var(--accent);cursor:pointer;padding:0}\n.rhead{display:flex;align-items:flex-start;gap:14px;margin-bottom:4px}\n.rhead h2{margin:0;font-size:22px;letter-spacing:-.015em;line-height:1.25}\n.rhead .desc{color:var(--muted);margin:6px 0 0;max-width:860px}\n.tabs{display:flex;flex-wrap:wrap;gap:2px;border-bottom:1px solid var(--line);margin:18px 0 18px}\n.tab{display:flex;align-items:center;gap:6px;background:none;border:none;border-bottom:2px solid transparent;padding:8px 12px;font-size:13.5px;white-space:nowrap;cursor:pointer;color:var(--muted);font-weight:500;margin-bottom:-1px}\n.tab:hover{color:var(--text)}\n.tab.active{color:var(--accent);border-bottom-color:var(--accent);font-weight:650}\n.runbar{display:flex;gap:10px;align-items:flex-end;flex-wrap:wrap;margin-top:16px;padding-top:16px;border-top:1px solid var(--line)}\n.runbar .field{margin:0;min-width:260px}\n\n/* results */\n.stats{display:flex;align-items:center;gap:16px;flex-wrap:wrap;margin-bottom:12px}\n.stat b{font-size:22px;letter-spacing:-.02em;display:block;line-height:1.1}\n.stat span{font-size:12px;color:var(--muted)}\n.table-wrap{overflow:auto;max-height:64vh;border:1px solid var(--line);border-radius:10px;background:#fff}\ntable{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}\nth,td{padding:8px 12px;border-bottom:1px solid #eef1f5;text-align:left;vertical-align:top}\nth{position:sticky;top:0;background:#f6f8fb;white-space:nowrap;font-weight:650;font-size:12.5px;color:var(--text2);cursor:pointer;user-select:none;z-index:1;border-bottom:1px solid var(--line)}\nth:hover{color:var(--text)}\nth .arrow{color:var(--accent);margin-left:4px}\ntbody tr:nth-child(even) td{background:#fbfcfe}\ntbody tr:hover td{background:#f1f5fd}\ntd.num{text-align:right;font-variant-numeric:tabular-nums}\ntd.empty-cell{color:var(--faint)}\n.yes{color:var(--ok);font-weight:600}.no{color:var(--muted)}\n.empty{padding:44px 20px;text-align:center;color:var(--muted)}\n.empty b{display:block;color:var(--text);font-size:15px;margin-bottom:4px}\n\n/* pickers */\n.picker{position:relative}\n.picker-btn{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-height:38px;width:100%;padding:5px 30px 5px 8px;border:1px solid var(--line2);border-radius:8px;background:#fff;cursor:pointer;text-align:left;position:relative}\n.picker-btn:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.picker-btn .ph{color:var(--faint);padding:2px 4px}\n.picker-btn .chev{position:absolute;right:9px;top:50%;transform:translateY(-50%);color:var(--muted)}\n.tok{display:inline-flex;align-items:center;gap:4px;background:var(--accent-soft);color:var(--accent);border-radius:6px;padding:1px 4px 1px 8px;font-size:12.5px;font-weight:600;max-width:100%}\n.tok span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.tok button{border:none;background:none;color:inherit;cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:.7}\n.tok button:hover{opacity:1}\n.pop{position:absolute;z-index:20;top:calc(100% + 4px);left:0;right:0;min-width:300px;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow2);padding:8px}\n.pop input.input{margin-bottom:6px}\n.pop-list{max-height:280px;overflow-y:auto}\n.opt{display:flex;align-items:center;gap:9px;padding:6px 8px;border-radius:6px;cursor:pointer;font-size:13.5px}\n.opt:hover,.opt.kb{background:var(--sunken)}\n.opt input{accent-color:var(--accent);width:15px;height:15px}\n.opt .hint{margin-left:auto;font-size:11.5px;color:var(--faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:45%}\n.pop-foot{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--line);margin-top:6px;padding-top:6px;font-size:12.5px;color:var(--muted)}\n.tokinput{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:38px;padding:5px 8px;border:1px solid var(--line2);border-radius:8px;background:#fff}\n.tokinput:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)}\n.tokinput input{border:none;outline:none;flex:1;min-width:120px;padding:3px 2px}\n\n/* designer */\n.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:10px}\n.tile{display:flex;gap:10px;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:10px;padding:11px 12px;cursor:pointer;transition:border-color .12s,background .12s}\n.tile:hover{border-color:#a9bbd6}\n.tile.active{border-color:var(--accent);background:var(--accent-soft);box-shadow:0 0 0 1px var(--accent)}\n.tile b{display:block;font-size:13.5px;margin-bottom:2px}\n.tile span{font-size:12px;color:var(--muted);line-height:1.35;display:block}\n.cond{display:grid;grid-template-columns:minmax(200px,1.3fr) minmax(150px,.8fr) minmax(220px,1.4fr) auto;gap:8px;align-items:start;padding:10px;border:1px solid var(--line);border-radius:10px;background:var(--sunken);margin-bottom:8px}\n@media (max-width:1000px){.cond{grid-template-columns:1fr 1fr}}\n.cond .ask{grid-column:1/-1;display:flex;align-items:center;gap:10px;font-size:12.5px;color:var(--muted)}\n.cond .ask .input{max-width:360px;padding:5px 9px;font-size:13px}\n.joiner{display:flex;align-items:center;gap:8px;margin:0 0 10px;font-size:13.5px}\n.joiner select{width:auto}\n.colrow{display:grid;grid-template-columns:28px minmax(220px,1.3fr) minmax(160px,1fr) 150px auto;gap:8px;align-items:center;padding:6px 8px;border:1px solid var(--line);border-radius:9px;background:#fff;margin-bottom:6px}\n.colrow .n{color:var(--faint);font-size:12px;text-align:center;font-weight:600}\n.actionbar{position:sticky;bottom:0;background:rgba(243,245,249,.92);backdrop-filter:blur(6px);border-top:1px solid var(--line);padding:12px 0;margin-top:6px;display:flex;gap:10px;align-items:center;z-index:4}\ndetails.adv summary{cursor:pointer;color:var(--text2);font-weight:600;font-size:13.5px}\ntextarea.yaml{width:100%;min-height:480px;font:13px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;padding:14px;border:1px solid var(--line2);border-radius:10px;background:#0f172a;color:#e2e8f0}\ntextarea.yaml:focus{outline:none;box-shadow:0 0 0 3px var(--accent-ring)}\n\n/* modal */\n.modal{position:fixed;inset:0;background:rgba(15,23,42,.5);display:flex;align-items:center;justify-content:center;z-index:25;backdrop-filter:blur(2px)}\n.modal .box{background:#fff;border-radius:14px;width:min(880px,92vw);max-height:86vh;display:flex;flex-direction:column;box-shadow:var(--shadow2)}\n.modal .head{display:flex;align-items:center;gap:8px;padding:14px 18px;border-bottom:1px solid var(--line)}\n.modal .head h3{margin:0;font-size:16px;flex:1}\n.modal pre{margin:0;padding:16px 18px;overflow:auto;font:12.5px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;white-space:pre-wrap}\n\n/* schedules */\n.drawer-back{position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:40;display:flex;justify-content:flex-end}\n.drawer{width:min(460px,94vw);height:100%;overflow-y:auto;background:#fff;box-shadow:var(--shadow2);padding:20px 22px;font-size:14px}\n.drawer h4{margin:18px 0 6px;font-size:13px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}\n.drawer ul{margin:0;padding-left:18px}.drawer li{margin:5px 0}\n.checklist{display:flex;flex-direction:column;gap:6px}\n.cl-item{display:flex;gap:10px;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 10px;cursor:pointer;font-size:13.5px}\n.cl-item:hover{border-color:var(--accent)}\n.cl-box{width:18px;height:18px;border:1.5px solid var(--line2);border-radius:5px;display:grid;place-items:center;font-size:12px;flex-shrink:0;color:var(--muted)}\n.cl-item.done{color:var(--muted)}.cl-item.done .cl-box{background:var(--ok);border-color:var(--ok);color:#fff}\n.fix{background:#f6f9ff;border:1px solid #d9e4fb;border-radius:10px;padding:10px 14px;margin:0 0 14px;font-size:13.5px}\n.fix ol{margin:6px 0 0;padding-left:20px}.fix li{margin:3px 0}\n#schedules,#roles,#checks,#lookup,#tenant-page,#certs,#monthly,#warnings,#nerm,#logs{height:calc(100vh - 56px);overflow-y:auto}\n.tagline{font-size:10.5px;font-weight:500;color:rgba(255,255,255,.55);letter-spacing:.01em}\n.calls{font-size:12px;color:rgba(255,255,255,.65);white-space:nowrap}\npre.json{margin:0;max-height:60vh;overflow:auto;background:#0f172a;color:#e2e8f0;border-radius:10px;padding:14px;font:12.5px/1.55 ui-monospace,\"Cascadia Mono\",Consolas,monospace;white-space:pre-wrap;word-break:break-word}\n.banner{display:flex;align-items:center;gap:14px;border-radius:12px;padding:14px 18px;margin-bottom:16px;border:1px solid var(--line);background:#fff}\n.banner b{font-size:17px}\n.banner.ok{background:var(--ok-soft);border-color:#b9e5c8;color:var(--ok)}\n.banner.warn{background:var(--warn-soft);border-color:#f3dd9f;color:var(--warn)}\n.banner.bad{background:var(--danger-soft);border-color:#f6c9c5;color:var(--danger)}\n.banner.idle,.banner.run{color:var(--text2)}\n.banner span{font-size:13px}\n.tiles-chk{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:12px}\n.chk{--c:#94a3b8;position:relative;display:flex;flex-direction:column;gap:6px;text-align:left;background:#fff;border:1px solid var(--line);border-left:4px solid var(--c);border-radius:12px;padding:12px 14px;cursor:pointer;box-shadow:var(--shadow);transition:box-shadow .12s,transform .12s}\n.chk:hover{box-shadow:0 8px 22px rgba(15,23,42,.1);transform:translateY(-1px)}\n.chk.sel{outline:2px solid var(--accent);outline-offset:1px}\n.chk.ok{--c:#15803d}.chk.warn{--c:#b45309}.chk.bad{--c:#dc2626}.chk.err{--c:#5b6577}.chk.off{--c:#64748b;background:#f8fafc;border-left-color:#cbd5e1}\n.chk.stale{background:#fbfcfe}\n.chk-top{display:flex;align-items:center;gap:8px}\n.chk-dot{width:9px;height:9px;border-radius:50%;background:var(--c);flex-shrink:0}\n.chk-label{font-weight:650;font-size:13.5px;flex:1}\n.chk-st{font-size:11.5px;font-weight:650;color:var(--c)}\n.chk-mid{display:flex;align-items:baseline;gap:6px}\n.chk-mid b{font-size:28px;letter-spacing:-.02em;line-height:1}\n.chk-mid svg.spark{color:var(--c);align-self:center}\n.chk-sum{font-size:12.5px;color:var(--muted);line-height:1.4}\n.chk .pill{align-self:flex-start}\n.chk-top3{border-top:1px solid #eef1f5;padding-top:6px;font-size:12px;display:flex;flex-direction:column;gap:2px}\n.chk-top3 div{display:flex;gap:8px;justify-content:space-between}\n.chk-top3 span{color:var(--text2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.trend{color:var(--accent);margin:4px 0 14px}\n.trend svg{width:100%;max-width:640px;height:90px}\n.matches{display:flex;flex-direction:column;gap:4px;margin-top:10px}\n.match{display:flex;flex-direction:column;align-items:flex-start;text-align:left;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 12px;cursor:pointer}\n.match:hover,.match.sel{border-color:var(--accent);background:var(--accent-soft)}\n.match span{font-size:12.5px}\n.avatar{width:44px;height:44px;border-radius:50%;background:linear-gradient(135deg,#3d7bff,#1d47b3);color:#fff;display:grid;place-items:center;font-weight:700;flex-shrink:0}\n.flags{display:flex;flex-direction:column;gap:6px;margin-top:14px}\n.flag{border-radius:8px;padding:8px 12px;font-size:13.5px;border-left:4px solid}\n.flag.bad{background:var(--danger-soft);border-color:#dc2626;color:#7a1a12}\n.flag.warn{background:var(--warn-soft);border-color:#d97706;color:#6b4500}\n.flag.info{background:var(--sunken);border-color:#94a3b8;color:var(--text2)}\n.rolecards{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin-bottom:14px}\n.rolecard{border:1px solid var(--line);border-radius:10px;padding:14px;background:#fff}\n.rolecard h4{margin:0 0 6px;font-size:15px}\n.rolecard .crit{font:12.5px/1.5 ui-monospace,\"Cascadia Mono\",Consolas,monospace;background:var(--sunken);border-radius:7px;padding:7px 9px;margin-top:8px;color:var(--text2);word-break:break-word}\n.kv{display:flex;gap:14px;flex-wrap:wrap;font-size:12.5px;color:var(--muted)}\n.kv b{color:var(--text);font-size:14px}\n.meter{height:8px;border-radius:99px;background:#e9edf3;overflow:hidden;margin:6px 0}\n.meter span{display:block;height:100%;background:linear-gradient(90deg,#3d7bff,#2457d6)}\n.tick{color:var(--ok);font-weight:700}.dash{color:var(--faint)}\n.chg{display:inline-block;border-radius:6px;padding:1px 8px;font-size:12px;font-weight:650}\n.chg.gain{background:var(--ok-soft);color:var(--ok)}.chg.lose{background:var(--danger-soft);color:var(--danger)}.chg.keep-other,.chg.off{background:#eef1f5;color:var(--muted)}\n.bigstats{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:14px}\n.bigstat{border:1px solid var(--line);border-radius:10px;padding:12px 14px;background:#fff}\n.bigstat b{display:block;font-size:24px;letter-spacing:-.02em}\n.bigstat span{font-size:12.5px;color:var(--muted)}\n.bigstat.gain b{color:var(--ok)}.bigstat.lose b{color:var(--danger)}\n.crit-group{border:1px dashed var(--line2);border-radius:10px;padding:10px;margin:8px 0;background:#fcfdff}\n.crit-row{display:grid;grid-template-columns:170px minmax(160px,1fr) minmax(150px,1fr) 150px minmax(160px,1fr) auto;gap:8px;align-items:start;margin-bottom:8px}\n@media (max-width:1100px){.crit-row{grid-template-columns:1fr 1fr 1fr}}\n.jobs td,.jobs th{vertical-align:middle}\n.jobs th{cursor:default}\n.actions{display:flex;gap:6px;flex-wrap:wrap}\n.log{background:#0f172a;color:#e2e8f0;border-radius:8px;padding:8px 10px;font:12px/1.45 ui-monospace,Consolas,monospace;white-space:pre-wrap;max-height:180px;overflow:auto;margin-top:6px}\n.inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}\n.inline .input{width:auto}\n.inline .field .input{width:100%}\n#schedules .grid{margin-bottom:14px}\n.partner-strip{margin:0 auto 18px;max-width:980px}\n.ptable{width:100%;border-collapse:collapse;font-size:13px}\n.ptable th,.ptable td{padding:8px 10px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle}\n.ptable th{background:#f6f8fb;font-weight:600;font-size:12px;color:var(--text2)}\n.ptable th.pcol{max-width:92px;white-space:normal;line-height:1.2;text-align:center}\n.ptable td.pcell{text-align:center}\n.ptable tr.sel td{background:#f4f8ff}\n.pval{border:0;border-radius:7px;min-width:44px;padding:5px 8px;font:600 13px inherit;cursor:pointer;position:relative}\n.pval.ok{background:var(--ok-soft);color:var(--ok)}.pval.warn{background:var(--warn-soft);color:var(--warn)}.pval.bad{background:var(--danger-soft);color:var(--danger)}.pval.err{background:#eef1f5;color:var(--muted)}\n.pnew{position:absolute;top:-7px;right:-8px;background:var(--danger);color:#fff;font-size:9px;border-radius:6px;padding:1px 4px;font-weight:700}\n.pstat{display:inline-block;border-radius:999px;padding:3px 10px;font-weight:600;font-size:12px}\n.pstat.ok{background:var(--ok-soft);color:var(--ok)}.pstat.warn{background:var(--warn-soft);color:var(--warn)}.pstat.bad{background:var(--danger-soft);color:var(--danger)}.pstat.err{background:#eef1f5;color:var(--muted)}\n.pdetail{background:#fbfcfe;border:1px solid var(--line);border-radius:10px;padding:12px 14px}\n#schedules .card .bar{margin-top:6px}\n.tokchip{border:0;cursor:pointer;background:#fef3c7;color:#92400e;border-radius:999px;padding:4px 12px;font-size:12.5px;font-weight:600;white-space:nowrap}\n.tokchip{flex-shrink:0}.tokchip .tk-short{display:none}\n@media (max-width:1440px){.navbtn{padding:6px 4px;font-size:13px}header{gap:7px}.hbtn{padding:6px 8px}}\n@media (max-width:1300px){.navbtn{padding:5px 3px;font-size:12.5px}header{gap:5px}.hbtn{padding:5px 7px;font-size:12.5px}}\n@media (max-width:1900px){.tokchip .tk-long{display:none}.tokchip .tk-short{display:inline}.tokchip{padding:4px 9px}}\n.wkbars{display:inline-flex;align-items:flex-end;gap:2px;height:24px;vertical-align:middle}\n.wkbar{width:9px;background:#cbd5e1;border-radius:2px 2px 0 0;display:flex;align-items:flex-end;overflow:hidden}\n.wkfail{width:100%;background:#dc2626}\n.linkbtn{background:none;border:0;padding:0;color:var(--accent,#2563eb);cursor:pointer;font:inherit;text-align:left;text-decoration:underline;text-underline-offset:2px}\n.linkbtn:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n.evlist{margin:6px 0 0;padding-left:16px;font-size:13px}\n.evlist li{margin-bottom:4px}\ndetails > summary{cursor:pointer;color:var(--accent,#2563eb)}\n.finder-back{position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:60;display:flex;justify-content:center;align-items:flex-start;padding-top:12vh}\n.finder{background:var(--card,#fff);border-radius:12px;box-shadow:0 20px 50px rgba(0,0,0,.25);width:min(640px,92vw);overflow:hidden}\n.finder > .input{border:0;border-bottom:1px solid var(--line,#e5e7eb);border-radius:0;font-size:16px;padding:14px 16px;width:100%;max-width:none}\n.finder-list{list-style:none;margin:0;padding:6px 0;max-height:52vh;overflow:auto}\n.finder-opt{display:flex;flex-direction:column;gap:2px;padding:8px 14px;cursor:pointer}\n.finder-opt.active,.finder-opt:hover{background:var(--accent-soft,#eef2ff)}\n\n/* two-level tabs: sections, then the tabs of the open section */\n.seg{display:inline-flex;flex-wrap:wrap;gap:3px;background:#e6ebf2;border-radius:10px;padding:3px;margin:16px 0 0;max-width:100%}\n.segbtn{display:inline-flex;align-items:center;gap:7px;border:0;background:transparent;border-radius:8px;padding:6px 13px;font-weight:600;font-size:13px;color:var(--text2);cursor:pointer;white-space:nowrap}\n.segbtn:hover{color:var(--text);background:rgba(255,255,255,.55)}\n.segbtn.active{background:#fff;color:var(--accent2);box-shadow:var(--shadow)}\n.segn{font-size:11px;font-weight:650;color:var(--text2);background:rgba(15,23,42,.08);border-radius:999px;padding:0 6px;line-height:17px}\n.segbtn.active .segn{background:var(--accent-soft);color:var(--accent2)}\n.tabs.sub{margin:8px 0 18px}\n.tab svg.i{width:15px;height:15px}\n</style>\n</head>\n<body>\n<a class=\"skip\" href=\"#content\">Skip to content</a>\n<header>\n <h1 class=\"sr-only\">IdentityScope</h1>\n <div class=\"brand\"><div class=\"logo\">IS</div><div style=\"display:flex;flex-direction:column;line-height:1.1\">IdentityScope<span class=\"tagline\">for SailPoint Identity Security Cloud</span></div></div>\n <nav id=\"nav\" class=\"hidden\"><button id=\"nav-reports\" class=\"navbtn active\"></button><button id=\"nav-checks\" class=\"navbtn\"></button><button id=\"nav-warnings\" class=\"navbtn\"></button><button id=\"nav-nerm\" class=\"navbtn\"></button><button id=\"nav-logs\" class=\"navbtn\"></button><button id=\"nav-lookup\" class=\"navbtn\"></button><button id=\"nav-tenant\" class=\"navbtn\"></button><button id=\"nav-build\" class=\"navbtn\"></button><button id=\"nav-certs\" class=\"navbtn\"></button><button id=\"nav-roles\" class=\"navbtn\"></button><button id=\"nav-monthly\" class=\"navbtn\"></button><button id=\"nav-schedules\" class=\"navbtn\"></button></nav>\n <span class=\"spacer\"></span>\n <span class=\"tenant hidden\" id=\"tenant-chip\"><span class=\"dot\"></span><span id=\"tenant\"></span></span>\n <button type=\"button\" class=\"tokchip hidden\" id=\"token-chip\"></button>\n <span class=\"calls hidden\" id=\"calls-chip\" title=\"Calls this screen made to ISC since it started\"><span id=\"calls\">0</span> API calls</span>\n <button id=\"btn-partner-nav\" class=\"hbtn hidden\" title=\"The instant check of every customer tenant\"></button>\n <button id=\"btn-help\" class=\"hbtn hidden\" title=\"What this page shows and how to use it\"></button>\n <button id=\"btn-doctor\" class=\"hbtn hidden\" title=\"Check permissions and data\"></button>\n <button id=\"btn-disconnect\" class=\"hbtn hidden\" title=\"Disconnect\"></button>\n</header>\n\n<main id=\"content\" tabindex=\"-1\">\n<div id=\"connect\" class=\"hidden\">\n <div class=\"connect-hero\">\n <div class=\"logo\" style=\"width:46px;height:46px;border-radius:12px;font-size:16px;margin:0 auto;color:#fff\">IS</div>\n <h2>Connect to your tenant</h2>\n <p>Reports only read data. Nothing you enter leaves this computer except to sign in to your tenant.</p>\n </div>\n <div class=\"saved partner-strip\" style=\"background:#f0fdf4;border-color:#bbf7d0\"><span style=\"flex:1\"><b>Just looking?</b> Try every screen on a made-up tenant. No sign-in, nothing leaves this computer.</span><button class=\"btn\" id=\"btn-demo\">Try the demo tenant</button></div>\n <div class=\"saved partner-strip\"><span style=\"flex:1\"><b>More than one tenant?</b> Sandbox, QA and production, or several customers: check them all in one place.</span><button class=\"btn\" id=\"btn-partner\">Open All tenants</button></div>\n <div id=\"saved-box\" class=\"saved hidden\">\n <span class=\"dot\" style=\"background:var(--accent);box-shadow:0 0 0 3px var(--accent-ring)\"></span>\n <span style=\"flex:1\">Saved tenant <b id=\"saved-url\"></b></span>\n <button class=\"btn primary\" id=\"btn-use-saved\">Use saved tenant</button>\n </div>\n <div class=\"connect-cols\">\n <section class=\"card\">\n <h3>Sign in with SailPoint <span class=\"pill on\">recommended</span></h3>\n <p class=\"lead\">Uses your normal ISC sign-in (SSO, MFA). You see only what your own ISC access allows.</p>\n <label class=\"field\"><span class=\"lbl\">Tenant</span><input id=\"si-base\" placeholder=\"yourtenant, or paste the ISC address from your browser\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">OAuth client ID</span><input id=\"si-client\" autocomplete=\"off\"><span class=\"hint\">Your ISC admin creates it once for everyone (see below).</span></label>\n <details class=\"adv\" style=\"margin:-4px 0 16px\"><summary>Client secret (only if your admin says so)</summary>\n <input id=\"si-secret\" class=\"input\" type=\"password\" autocomplete=\"off\" style=\"margin-top:8px\">\n </details>\n <button class=\"btn primary\" id=\"btn-signin\" style=\"width:100%;padding:10px\">Sign in with SailPoint</button>\n <div id=\"signin-wait\" class=\"hidden progress\"><span class=\"spinner\"></span><span>Finish signing in on the SailPoint tab that opened. This page continues by itself. <a id=\"signin-link\" target=\"_blank\" rel=\"noopener\">Open sign-in page</a></span></div>\n <div id=\"signin-error\" class=\"error hidden\"></div>\n <details class=\"help\"><summary>Set up once (ISC admin)</summary>\n <ol>\n <li>In ISC: <b>Admin</b> &rarr; <b>Global</b> &rarr; <b>Security Settings</b> &rarr; <b>API Management</b> &rarr; <b>New</b>.</li>\n <li>Description: <i>identityscope</i>. Grant types: <b>Authorization Code</b> and <b>Refresh Token</b>.</li>\n <li>Redirect URL: <code id=\"redirect-uri\">http://localhost:4317/callback</code></li>\n <li>Scopes: the read scopes below. Each user still only gets what their own ISC access allows.<details style=\"margin-top:6px\"><summary>The 28 read scopes</summary><code style=\"display:block;white-space:pre-wrap;word-break:break-word;margin-top:6px;font-size:12px;line-height:1.6\">sp:search:read idn:sources:read idn:accounts:read idn:entitlement:read idn:campaign:read idn:access-request-status:read idn:identity-profile:read idn:identity-profile-lifecycle-state:read idn:role-unchecked:read idn:access-profile:read idn:remote-client:read sp:workflow:read sp:workflow-execution:read idn:transform:read idn:provisioning-policy:read idn:workgroup:read idn:attr-sync-source-config:read idn:mis-account:read idn:rule-management-connector:read idn:identity-profile-attribute:read idn:sod-policy:read idn:password-policy:read sp:trigger-service-subscriptions:read sp:forms:read idn:segment:read sp:all-personal-access-tokens:read sp:oauth-client:read sp:config:read</code><div class=\"muted small\" style=\"margin-top:6px\">To sign in at all: the first two. A missing scope only switches off the screen that needs it, and that screen says which. Optional extras (API credentials, Non-employees) are in the README under Permissions.</div></details></li>\n <li>Share the <b>client ID</b> with report users. Everyone uses the same client ID.</li>\n </ol>\n </details>\n </section>\n <section class=\"card\">\n <h3>Personal access token</h3>\n <p class=\"lead\">Needed for automatic (scheduled) runs. Best with a dedicated read-only reporting identity.</p>\n <label class=\"field\"><span class=\"lbl\">Tenant</span><input id=\"in-base\" placeholder=\"yourtenant, or paste the ISC address from your browser\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">Client ID</span><input id=\"in-id\" autocomplete=\"off\"></label>\n <label class=\"field\"><span class=\"lbl\">Client secret</span><input id=\"in-secret\" type=\"password\" autocomplete=\"off\"></label>\n <button class=\"btn\" id=\"btn-connect\" style=\"width:100%;padding:10px\">Connect with token</button>\n <div id=\"connect-error\" class=\"error hidden\"></div>\n <details class=\"help\"><summary>Where do I get one, and which scopes?</summary>In ISC: your name (top right) &rarr; <b>Preferences</b> &rarr; <b>Personal Access Tokens</b> &rarr; <b>New Token</b>. The identity should have the <b>Org admin</b> user level; only read scopes are needed.<details style=\"margin-top:6px\"><summary>The 28 read scopes</summary><code style=\"display:block;white-space:pre-wrap;word-break:break-word;margin-top:6px;font-size:12px;line-height:1.6\">sp:search:read idn:sources:read idn:accounts:read idn:entitlement:read idn:campaign:read idn:access-request-status:read idn:identity-profile:read idn:identity-profile-lifecycle-state:read idn:role-unchecked:read idn:access-profile:read idn:remote-client:read sp:workflow:read sp:workflow-execution:read idn:transform:read idn:provisioning-policy:read idn:workgroup:read idn:attr-sync-source-config:read idn:mis-account:read idn:rule-management-connector:read idn:identity-profile-attribute:read idn:sod-policy:read idn:password-policy:read sp:trigger-service-subscriptions:read sp:forms:read idn:segment:read sp:all-personal-access-tokens:read sp:oauth-client:read sp:config:read</code><div class=\"muted small\" style=\"margin-top:6px\">To sign in at all: the first two. A missing scope only switches off the screen that needs it, and that screen says which. Optional extras (API credentials, Non-employees) are in the README under Permissions.</div></details></details>\n </section>\n </div>\n</div>\n\n<div id=\"demo-bar\" class=\"hidden\" role=\"status\" style=\"background:#fef3c7;border-bottom:1px solid #fcd34d;color:#78350f;padding:7px 18px;font-size:13px;text-align:center\"><b>Demo tenant.</b> Every identity, account and number here is made up. To use your own tenant, click Disconnect and connect to it.</div>\n<div id=\"app\" class=\"hidden\">\n <aside>\n <div class=\"aside-top\">\n <button class=\"btn primary\" id=\"btn-new\"></button>\n <div class=\"searchbox\"><span id=\"search-ico\"></span><input id=\"search\" class=\"input\" placeholder=\"Find a report\"></div>\n </div>\n <div id=\"library\"></div>\n </aside>\n <div id=\"main\"></div>\n</div>\n<div id=\"schedules\" class=\"hidden\"></div>\n<div id=\"roles\" class=\"hidden\"></div>\n<div id=\"checks\" class=\"hidden\"></div>\n<div id=\"lookup\" class=\"hidden\"></div>\n<div id=\"tenant-page\" class=\"hidden\"></div>\n<div id=\"build\" class=\"hidden\"></div>\n<div id=\"certs\" class=\"hidden\"></div>\n<div id=\"monthly\" class=\"hidden\"></div>\n<div id=\"warnings\" class=\"hidden\"></div>\n<div id=\"nerm\" class=\"hidden\"></div>\n<div id=\"logs\" class=\"hidden\"></div>\n<div id=\"partner\" class=\"hidden\"></div>\n</main>\n\n<div id=\"modal\" class=\"modal hidden\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"modal-title\">\n <div class=\"box\">\n <div class=\"head\"><h3 id=\"modal-title\"></h3><button class=\"btn sm\" id=\"modal-copy\">Copy</button><button class=\"btn sm\" id=\"modal-close\">Close</button></div>\n <pre id=\"modal-text\"></pre>\n </div>\n</div>\n<div id=\"toast\" class=\"hidden\" role=\"status\" aria-live=\"polite\"></div>\n<script>\n(function () {\n 'use strict';\n var hash = new URLSearchParams(location.hash.slice(1));\n var KEY = hash.get('k') || sessionStorage.getItem('isc-reports-key') || '';\n if (hash.get('k')) { sessionStorage.setItem('isc-reports-key', KEY); history.replaceState(null, '', location.pathname); }\n\n var state = { reports: [], catalog: null, current: null, tab: 'run', job: null, result: null, dirty: false, picks: {}, disc: {}, homeCat: '' };\n\n // ---------- small helpers ----------\n function $(id) { return document.getElementById(id); }\n function el(tag, attrs) {\n var e = document.createElement(tag);\n if (attrs) for (var k in attrs) {\n var v = attrs[k];\n if (v === undefined || v === null || v === false) continue;\n if (k === 'text') e.textContent = v;\n else if (k === 'className') e.className = v;\n else if (k.slice(0, 2) === 'on') e.addEventListener(k.slice(2), v);\n else if (k === 'value') e.value = v;\n else if (k === 'checked') e.checked = !!v;\n else e.setAttribute(k, v === true ? '' : v);\n }\n for (var i = 2; i < arguments.length; i++) add(e, arguments[i]);\n return e;\n }\n function add(e, c) {\n if (c === null || c === undefined || c === false) return;\n if (Array.isArray(c)) c.forEach(function (x) { add(e, x); });\n else e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c);\n }\n function clone(x) { return JSON.parse(JSON.stringify(x)); }\n var ICONS = {\n people: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 20c0-3.5 3.6-6 8-6s8 2.5 8 6',\n lifecycle: 'M4 12a8 8 0 0 1 14-5.3L20 9M20 4v5h-5M20 12a8 8 0 0 1-14 5.3L4 15M4 20v-5h5',\n shield: 'M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6zM8.5 12l2.5 2.5 4.5-5',\n layers: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5',\n apps: 'M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z',\n cert: 'M9 3h6v3H9zM7 4.5H5V21h14V4.5h-2M9 13.5l2 2 4-4',\n inbox: 'M4 13h4l2 3h4l2-3h4M4 13l3-8h10l3 8v6H4z',\n pulse: 'M3 12h4l3-7 4 14 3-7h4',\n file: 'M6 3h9l4 4v14H6zM14 3v5h5M9 13h7M9 17h5',\n search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM21 21l-5-5',\n download: 'M12 4v11M7 10l5 5 5-5M5 20h14',\n play: 'M7 5l12 7-12 7z',\n plus: 'M12 5v14M5 12h14',\n x: 'M6 6l12 12M18 6L6 18',\n chev: 'M6 9l6 6 6-6',\n clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2',\n up: 'M12 19V5M6 11l6-6 6 6',\n down: 'M12 5v14M6 13l6 6 6-6',\n trash: 'M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13',\n logout: 'M15 4h4v16h-4M10 8l-4 4 4 4M6 12h10',\n eye: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',\n save: 'M5 3h11l3 3v15H5zM8 3v5h7M8 14h8v7H8z',\n filter: 'M4 5h16l-6 7v6l-4 2v-8z',\n cols: 'M4 4h16v16H4zM10 4v16M16 4v16',\n sigma: 'M18 5H6l6 7-6 7h12',\n sort: 'M7 4v16M3 16l4 4 4-4M17 20V4M13 8l4-4 4 4',\n db: 'M12 8c4.4 0 8-1.3 8-3s-3.6-3-8-3-8 1.3-8 3 3.6 3 8 3zM4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3',\n grid: 'M4 4h16v16H4zM4 10h16M4 16h16M10 4v16',\n code: 'M8 8l-4 4 4 4M16 8l4 4-4 4M14 5l-4 14',\n sliders: 'M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0M14 4v4M8 10v4M16 16v4',\n copy: 'M8 8h12v12H8zM4 16V4h12',\n heart: 'M3 12h4l2-4 3 8 2-4h7'\n };\n function icon(name, cls) {\n var NS = 'http://www.w3.org/2000/svg';\n var s = document.createElementNS(NS, 'svg');\n s.setAttribute('viewBox', '0 0 24 24');\n s.setAttribute('class', 'i' + (cls ? ' ' + cls : ''));\n s.setAttribute('aria-hidden', 'true');\n var p = document.createElementNS(NS, 'path');\n p.setAttribute('d', ICONS[name] || ICONS.file);\n if (name === 'play') { p.setAttribute('fill', 'currentColor'); }\n s.appendChild(p);\n return s;\n }\n var CATS = {\n 'Identities': ['people', '#2457d6', '#eaf0fd'],\n 'Lifecycle': ['lifecycle', '#7c3aed', '#f1ebfe'],\n 'Hygiene': ['shield', '#0e7c66', '#e3f5f0'],\n 'Access model': ['layers', '#b45309', '#fdf1e2'],\n 'Application owners': ['apps', '#0369a1', '#e2f1fa'],\n 'Certifications': ['cert', '#be185d', '#fce8f1'],\n 'Requests': ['inbox', '#4d7c0f', '#eef6df'],\n 'Operations': ['pulse', '#b91c1c', '#fdeaea'],\n 'Configuration': ['sliders', '#0f766e', '#e0f4f1'],\n 'My reports': ['file', '#334155', '#eef1f5']\n };\n var CAT_ORDER = ['My reports', 'Identities', 'Lifecycle', 'Hygiene', 'Operations', 'Access model', 'Application owners', 'Certifications', 'Requests', 'Configuration'];\n function catOf(r) { return r.custom ? 'My reports' : (r.definition.category || 'Other'); }\n function catIcon(cat) {\n var c = CATS[cat] || ['file', '#334155', '#eef1f5'];\n return el('span', { className: 'cat-ico', style: 'color:' + c[1] + ';background:' + c[2] }, icon(c[0]));\n }\n var POPULAR = ['provisioning-errors', 'aggregation-failures', 'uncorrelated-accounts', 'terminated-users-with-active-accounts', 'person-access', 'application-accounts', 'identity-attribute-mappings', 'privileged-access', 'new-identities'];\n\n function api(path, method, body) {\n return fetch(path, {\n method: method || 'GET',\n headers: Object.assign({ 'x-isc-reports-key': KEY }, body ? { 'content-type': 'application/json' } : {}),\n body: body ? JSON.stringify(body) : undefined\n }).then(function (res) {\n var n = res.headers.get('x-isc-api-calls');\n if (n !== null && $('calls')) $('calls').textContent = Number(n).toLocaleString('en-US');\n return res.json().catch(function () { return {}; }).then(function (data) {\n if (!res.ok) {\n var err = new Error(data.error || ('Request failed (' + res.status + ')'));\n err.problems = data.problems || [];\n err.data = data;\n throw err;\n }\n return data;\n });\n });\n }\n var NOT_ANSWERING = 'IdentityScope on this computer is not answering. If its window was closed or shows an error, start it again and reload this page.';\n function errorText(e) { if (e && e.name === 'TypeError' && /fetch|network|load failed/i.test(e.message || '')) return NOT_ANSWERING; return e.message + (e.problems && e.problems.length ? '\\n- ' + e.problems.join('\\n- ') : ''); }\n var toastTimer;\n function toast(text) {\n var t = $('toast');\n t.textContent = text;\n t.classList.remove('hidden');\n clearTimeout(toastTimer);\n toastTimer = setTimeout(function () { t.classList.add('hidden'); }, 2600);\n }\n function fmtNum(n) { return Number(n).toLocaleString('en-US'); }\n\n // static icons in the page frame\n add($('nav-reports'), [icon('grid'), 'Reports']);\n add($('nav-schedules'), [icon('clock'), 'Schedules']);\n add($('nav-roles'), [icon('layers'), 'Role tools']);\n add($('nav-checks'), [icon('pulse'), 'Instant check']);\n add($('nav-warnings'), [icon('clock'), 'Warnings']);\n add($('nav-nerm'), [icon('people'), 'Non-employees']);\n add($('nav-logs'), [icon('file'), 'Logs']);\n add($('nav-lookup'), [icon('search'), 'Lookup']);\n add($('nav-tenant'), [icon('db'), 'Tenant']);\n add($('nav-build'), [icon('code'), 'Build & test']);\n add($('nav-certs'), [icon('cert'), 'Audit']);\n add($('nav-monthly'), [icon('sigma'), 'Insights']);\n add($('btn-doctor'), [icon('heart'), 'Health check']);\n add($('btn-help'), ['? Help']);\n add($('btn-partner-nav'), [icon('db'), 'All tenants']);\n $('btn-partner-nav').addEventListener('click', function () { showPartner(); });\n $('btn-partner').addEventListener('click', function () { showPartner(); });\n $('btn-help').addEventListener('click', function () { openHelp(); });\n add($('btn-disconnect'), [icon('logout'), 'Disconnect']);\n add($('btn-new'), [icon('plus'), 'New report']);\n add($('search-ico'), icon('search'));\n\n // ---------- connection ----------\n function showConnect(st) {\n $('connect').classList.remove('hidden');\n $('app').classList.add('hidden');\n $('partner').classList.add('hidden');\n $('btn-partner-nav').classList.add('hidden');\n $('demo-bar').classList.add('hidden');\n ['btn-doctor', 'btn-disconnect', 'nav', 'schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'tenant-chip', 'calls-chip', 'token-chip', 'btn-help'].forEach(function (id) { $(id).classList.add('hidden'); });\n if (st && st.signIn) {\n if (st.signIn.baseUrl && !$('si-base').value) $('si-base').value = st.signIn.baseUrl;\n if (st.signIn.clientId && !$('si-client').value) $('si-client').value = st.signIn.clientId;\n $('redirect-uri').textContent = st.signIn.redirectUri;\n }\n if (st && st.saved && st.saved.hasCredentials) {\n $('saved-box').classList.remove('hidden');\n $('saved-url').textContent = st.saved.baseUrl;\n } else $('saved-box').classList.add('hidden');\n }\n function showApp(tenant, user) {\n $('connect').classList.add('hidden');\n ['btn-doctor', 'btn-disconnect', 'nav', 'tenant-chip', 'calls-chip', 'btn-help'].forEach(function (id) { $(id).classList.remove('hidden'); });\n api('/api/state').then(function (st) { state.consoleUrl = st.consoleUrl; state.diagnostics = st.diagnostics; state.demo = !!st.demo; $('demo-bar').classList.toggle('hidden', !st.demo); });\n state.tn.data = {};\n state.ins = null; state.sd = {}; state.ch = {}; state.rc = {}; state.rq = { days: 90 }; state.mn.data = null; state.ev = { days: 365 };\n state.wn = null;\n state.ct.data = null; state.ow.data = null; state.cp.info = null; state.cp.data = null; state.mr.data = null;\n $('tenant').textContent = (tenant || '') + (user ? ' · ' + user : '');\n state.picks = {};\n state.disc = {};\n state.chk.meta = null; state.chk.results = null; state.chk.selected = null;\n state.lk.sources = null; state.lk.person = null; state.lk.source = null; state.lk.matches = null;\n showPage('reports');\n loadLibrary();\n state.pt.data = null;\n loadPartner().catch(function () {});\n if (!state.updateNoticed) { state.updateNoticed = true; noticeNewVersion(); }\n noticeTokenExpiry();\n }\n // Warns in the header when the token this connection uses expires within 14 days.\n function noticeTokenExpiry() {\n var chip = $('token-chip');\n chip.classList.add('hidden');\n api('/api/credentials/mine').then(function (m) {\n if (m.kind !== 'token' || m.daysToExpiry === null || m.daysToExpiry > 14) return;\n var long = m.daysToExpiry < 0 ? 'Token expired' : m.daysToExpiry === 0 ? 'Token expires today' : 'Token expires in ' + m.daysToExpiry + ' day' + (m.daysToExpiry === 1 ? '' : 's');\n var short = m.daysToExpiry < 0 ? 'Token expired' : 'Token: ' + m.daysToExpiry + 'd';\n chip.textContent = '';\n chip.appendChild(el('span', { className: 'tk-long', text: long }));\n chip.appendChild(el('span', { className: 'tk-short', text: short }));\n chip.title = 'The personal access token IdentityScope uses (' + m.name + ') expires ' + (m.expires || '').slice(0, 10) + '. Create a new one in ISC and sign in again with it; scheduled reports stop working when it expires.';\n chip.onclick = function () { state.tn.tab = 'credentials'; showPage('tenant'); };\n chip.classList.remove('hidden');\n }).catch(function () {});\n }\n function showPage(name) {\n state.page = name;\n $('partner').classList.add('hidden');\n $('nav-reports').classList.toggle('active', name === 'reports');\n $('nav-schedules').classList.toggle('active', name === 'schedules');\n $('nav-roles').classList.toggle('active', name === 'roles');\n $('nav-checks').classList.toggle('active', name === 'checks');\n $('nav-lookup').classList.toggle('active', name === 'lookup');\n $('nav-tenant').classList.toggle('active', name === 'tenant');\n $('nav-build').classList.toggle('active', name === 'build');\n $('nav-certs').classList.toggle('active', name === 'certs');\n $('nav-monthly').classList.toggle('active', name === 'monthly');\n $('nav-warnings').classList.toggle('active', name === 'warnings');\n $('nav-nerm').classList.toggle('active', name === 'nerm');\n $('nav-logs').classList.toggle('active', name === 'logs');\n $('app').classList.toggle('hidden', name !== 'reports');\n ['schedules', 'roles', 'checks', 'lookup', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.toggle('hidden', name !== p); });\n if (name === 'certs') renderAudit();\n if (name === 'monthly') { state.mr.data = null; renderInsights(); }\n if (name === 'warnings') renderWarnings();\n if (name === 'nerm') renderNerm();\n if (name === 'logs') renderLogs();\n $('tenant-page').classList.toggle('hidden', name !== 'tenant');\n if (name === 'tenant') renderTenant();\n if (name === 'build') renderBuild();\n if (name === 'schedules') loadSchedules();\n if (name === 'roles') renderRoles();\n if (name === 'checks') renderChecks();\n if (name === 'lookup') renderLookup();\n }\n $('nav-checks').addEventListener('click', function () { showPage('checks'); });\n $('nav-lookup').addEventListener('click', function () { showPage('lookup'); });\n $('nav-tenant').addEventListener('click', function () { showPage('tenant'); });\n $('nav-build').addEventListener('click', function () { showPage('build'); });\n $('nav-certs').addEventListener('click', function () { showPage('certs'); });\n $('nav-monthly').addEventListener('click', function () { showPage('monthly'); });\n $('nav-warnings').addEventListener('click', function () { showPage('warnings'); });\n $('nav-nerm').addEventListener('click', function () { showPage('nerm'); });\n $('nav-logs').addEventListener('click', function () { showPage('logs'); });\n $('nav-roles').addEventListener('click', function () { showPage('roles'); });\n $('nav-reports').addEventListener('click', function () { showPage('reports'); });\n $('nav-schedules').addEventListener('click', function () { state.editing = null; showPage('schedules'); });\n function doConnect(body, button) {\n var err = $('connect-error');\n err.classList.add('hidden');\n button.disabled = true;\n var label = button.textContent;\n button.textContent = 'Connecting...';\n api('/api/connect', 'POST', body).then(function (r) {\n $('in-secret').value = '';\n state.signedIn = false;\n showApp(r.tenant);\n }).catch(function (e) {\n err.textContent = errorText(e);\n err.classList.remove('hidden');\n }).then(function () { button.disabled = false; button.textContent = label; });\n }\n $('btn-connect').addEventListener('click', function () {\n doConnect({ baseUrl: $('in-base').value, clientId: $('in-id').value, clientSecret: $('in-secret').value }, $('btn-connect'));\n });\n $('in-secret').addEventListener('keydown', function (e) { if (e.key === 'Enter') $('btn-connect').click(); });\n $('btn-signin').addEventListener('click', function () {\n var err = $('signin-error');\n err.classList.add('hidden');\n var win = window.open('about:blank', '_blank');\n api('/api/login/start', 'POST', { baseUrl: $('si-base').value, clientId: $('si-client').value, clientSecret: $('si-secret').value }).then(function (r) {\n $('si-secret').value = '';\n if (win) win.location.href = r.authorizeUrl;\n $('signin-link').href = r.authorizeUrl;\n $('signin-wait').classList.remove('hidden');\n var waitUntil = Date.now() + 10 * 60 * 1000;\n (function check() {\n api('/api/state').then(function (st) {\n if (st.connected) { $('signin-wait').classList.add('hidden'); state.signedIn = true; showApp(st.tenant, st.signedInAs); }\n else if (Date.now() < waitUntil) setTimeout(check, 1500);\n else { $('signin-wait').classList.add('hidden'); err.textContent = 'Sign-in timed out. Try again.'; err.classList.remove('hidden'); }\n });\n })();\n }).catch(function (e) {\n if (win) win.close();\n err.textContent = errorText(e);\n err.classList.remove('hidden');\n });\n });\n $('btn-use-saved').addEventListener('click', function () { doConnect({ useSaved: true }, $('btn-use-saved')); });\n $('btn-demo').addEventListener('click', function () {\n var b = $('btn-demo'), err = $('connect-error');\n err.classList.add('hidden');\n b.disabled = true; b.textContent = 'Starting the demo...';\n api('/api/demo/start', 'POST', {}).then(function (r) { state.signedIn = false; showApp(r.tenant); }, function (e) { err.textContent = errorText(e); err.classList.remove('hidden'); })\n .then(function () { b.disabled = false; b.textContent = 'Try the demo tenant'; });\n });\n $('btn-disconnect').addEventListener('click', function () {\n api('/api/disconnect', 'POST', {}).then(function () { return api('/api/state'); }).then(showConnect);\n });\n\n // ---------- health check ----------\n function modal(title, text) {\n $('modal-title').textContent = title;\n $('modal-text').textContent = text;\n $('modal').classList.remove('hidden');\n }\n $('modal-close').addEventListener('click', function () { $('modal').classList.add('hidden'); });\n $('modal').addEventListener('click', function (e) { if (e.target === $('modal')) $('modal').classList.add('hidden'); });\n $('modal-copy').addEventListener('click', function () {\n navigator.clipboard.writeText($('modal-text').textContent).then(function () { toast('Copied'); });\n });\n $('btn-doctor').addEventListener('click', function () {\n modal('Health check', 'Checking sign-in, permissions and data... (about 30 seconds)');\n api('/api/doctor', 'POST', {}).then(function (r) { modal('Health check: safe to share, no names or IDs', r.text); })\n .catch(function (e) { modal('Health check failed', errorText(e)); });\n });\n\n // ---------- library ----------\n function loadLibrary(selectId) {\n return Promise.all([api('/api/reports'), state.catalog ? Promise.resolve(state.catalog) : api('/api/catalog')]).then(function (r) {\n state.reports = r[0];\n state.catalog = r[1];\n var pick = selectId && state.reports.filter(function (x) { return x.definition.id === selectId; })[0];\n if (pick) select(pick);\n else { renderLibrary(); if (!state.current) renderHome(); }\n }).catch(function (e) { $('main').textContent = ''; $('main').appendChild(el('div', { className: 'wrap' }, el('div', { className: 'error', text: errorText(e) }))); });\n }\n function matches(r, q) {\n var d = r.definition;\n return !q || (d.name + ' ' + (d.description || '') + ' ' + d.id + ' ' + (d.tags || []).join(' ') + ' ' + (d.category || '')).toLowerCase().indexOf(q) >= 0;\n }\n function grouped(q) {\n var groups = {};\n state.reports.forEach(function (r) {\n if (!matches(r, q)) return;\n var g = catOf(r);\n (groups[g] = groups[g] || []).push(r);\n });\n var order = Object.keys(groups).sort(function (a, b) {\n var ia = CAT_ORDER.indexOf(a), ib = CAT_ORDER.indexOf(b);\n return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib) || a.localeCompare(b);\n });\n return { groups: groups, order: order };\n }\n function renderLibrary() {\n var q = $('search').value.trim().toLowerCase();\n var g = grouped(q);\n var box = $('library');\n box.textContent = '';\n box.appendChild(el('button', { className: 'entry' + (!state.current ? ' active' : ''), onclick: goHome }, icon('grid'), ' All reports'));\n g.order.forEach(function (name) {\n box.appendChild(el('div', { className: 'group' },\n el('div', { className: 'group-h' }, el('span', { text: name }), el('span', { className: 'count', text: String(g.groups[name].length) })),\n g.groups[name].map(function (r) {\n var active = state.current && state.current.source === r;\n return el('button', { className: 'entry' + (active ? ' active' : ''), title: r.definition.description || '', text: r.definition.name, onclick: function () { select(r); } });\n })));\n });\n if (!g.order.length) box.appendChild(el('div', { className: 'muted small', style: 'padding:10px', text: 'No report matches.' }));\n }\n $('search').addEventListener('input', function () { renderLibrary(); if (!state.current) renderHome(); });\n function goHome() { state.current = null; renderLibrary(); renderHome(); }\n\n function reportCard(r) {\n var d = r.definition;\n var params = Object.keys(d.params || {});\n return el('button', { className: 'rcard', onclick: function () { select(r); } },\n el('div', { className: 'top' }, catIcon(catOf(r)), el('h3', { text: d.name })),\n el('p', { text: d.description || '' }),\n el('div', { className: 'foot' }, el('span', { text: catOf(r) }), params.length ? el('span', { text: '· ' + params.length + (params.length === 1 ? ' option' : ' options') }) : null));\n }\n function renderHome() {\n var m = $('main');\n m.textContent = '';\n var w = el('div', { className: 'wrap' });\n m.appendChild(w);\n var q = $('search').value.trim().toLowerCase();\n var big = el('input', { className: 'input', placeholder: 'Search reports: orphan accounts, leavers, roles, passwords...', value: $('search').value });\n big.addEventListener('input', function () { $('search').value = big.value; renderLibrary(); drawCards(); });\n var builtins = state.reports.filter(function (r) { return !r.custom; }).length;\n var mine = state.reports.length - builtins;\n w.appendChild(el('div', { className: 'hero' },\n el('h2', { text: 'What do you want to know about your tenant?' }),\n el('p', { text: 'Pick a ready-made report, or build your own with point-and-click filters. Everything is read-only.' }),\n el('div', { className: 'searchbox' }, icon('search'), big),\n el('div', { className: 'hero-stats' },\n el('div', {}, el('b', { text: String(builtins) }), 'ready-made reports'),\n el('div', {}, el('b', { text: String(mine) }), 'my reports'),\n el('div', {}, el('b', { text: String((state.catalog.datasets || []).length) }), 'kinds of data'),\n el('button', { className: 'btn sm', style: 'align-self:center;margin-left:auto', onclick: sharePanel }, icon('copy'), 'Share reports: import / export'))));\n var chips = el('div', { className: 'chips' });\n var cards = el('div');\n var glanceBox = el('div');\n w.appendChild(glanceBox);\n glance(glanceBox);\n w.appendChild(el('div', { className: 'cards', style: 'margin-bottom:18px' },\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { showPage('checks'); } },\n el('div', { className: 'top' }, catIcon('Operations'), el('h3', { text: 'Instant check' })), el('p', { text: 'Provisioning errors, failed aggregations, sources, leavers and more: every daily check in one click.' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.lk.tab = 'person'; showPage('lookup'); } },\n el('div', { className: 'top' }, catIcon('Identities'), el('h3', { text: 'Look up an identity or source' })), el('p', { text: 'Accounts, access, recent failures and hints on one page: \"why can\\u2019t this identity log in?\"' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.roleTab = 'compare'; showPage('roles'); } },\n el('div', { className: 'top' }, catIcon('Access model'), el('h3', { text: 'Compare roles' })), el('p', { text: 'Side by side: shared and different access, overlap of members, how similar they are.' })),\n el('button', { className: 'rcard', style: 'min-height:0', onclick: function () { state.roleTab = 'impact'; showPage('roles'); } },\n el('div', { className: 'top' }, catIcon('Lifecycle'), el('h3', { text: 'Preview a role change' })), el('p', { text: 'Change membership criteria and see who would gain or lose the role, before you save it in ISC.' }))));\n w.appendChild(chips);\n w.appendChild(cards);\n function drawCards() {\n var qq = $('search').value.trim().toLowerCase();\n var g = grouped(qq);\n chips.textContent = '';\n chips.appendChild(el('button', { className: 'chip' + (!state.homeCat ? ' active' : ''), text: 'All', onclick: function () { state.homeCat = ''; drawCards(); } }));\n g.order.forEach(function (c) {\n chips.appendChild(el('button', { className: 'chip' + (state.homeCat === c ? ' active' : ''), onclick: function () { state.homeCat = c; drawCards(); } }, c, el('span', { className: 'muted', text: String(g.groups[c].length) })));\n });\n cards.textContent = '';\n if (!qq && !state.homeCat) {\n var pop = POPULAR.map(function (id) { return state.reports.filter(function (r) { return r.definition.id === id; })[0]; }).filter(Boolean);\n if (pop.length) {\n cards.appendChild(el('div', { className: 'sec-h' }, el('h3', { text: 'Most used' }), el('span', { className: 'muted small', text: 'what IAM teams ask for most' })));\n cards.appendChild(el('div', { className: 'cards' }, pop.map(reportCard)));\n }\n }\n g.order.filter(function (c) { return !state.homeCat || c === state.homeCat; }).forEach(function (c) {\n cards.appendChild(el('div', { className: 'sec-h' }, el('h3', { text: c }), el('span', { className: 'muted small', text: g.groups[c].length + ' reports' })));\n cards.appendChild(el('div', { className: 'cards' }, g.groups[c].map(reportCard)));\n });\n if (!g.order.length) cards.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No report matches \"' + qq + '\".' }), 'Try another word, or build it yourself with ', el('button', { className: 'btn link', text: 'New report', onclick: function () { $('btn-new').click(); } }), '.'));\n }\n drawCards();\n if (q) big.focus();\n }\n\n function select(r) {\n state.current = { source: r, def: clone(r.definition), custom: r.custom, yaml: r.yaml };\n state.result = null;\n state.job = null;\n state.dirty = false;\n state.tab = 'run';\n state.groupBy = '';\n state.runError = null;\n state.running = false;\n state.paramValues = {};\n var p = r.definition.params || {};\n Object.keys(p).forEach(function (k) {\n var d = p[k].default;\n state.paramValues[k] = d === undefined ? (p[k].type === 'list' ? [] : '') : d;\n });\n renderLibrary();\n renderMain();\n $('main').scrollTop = 0;\n }\n\n // ---------- pickers ----------\n function loadPick(kind) {\n if (!state.picks[kind]) state.picks[kind] = api('/api/pick/' + kind).then(function (r) { return r.options; }).catch(function (e) { delete state.picks[kind]; throw e; });\n return state.picks[kind];\n }\n /**\n * A drop-down with search. opts: { options: Promise<[{value,label,hint}]> | array, multiple, value, onChange, placeholder, valueKey }\n * valueKey 'label' stores the names instead of the IDs.\n */\n function picker(opts) {\n var multiple = !!opts.multiple;\n var key = opts.valueKey || 'value';\n var selected = multiple ? (Array.isArray(opts.value) ? opts.value.slice() : opts.value ? String(opts.value).split(',').map(function (s) { return s.trim(); }).filter(Boolean) : []) : (opts.value ? [String(opts.value)] : []);\n var all = null, failed = null;\n var wrap = el('div', { className: 'picker' });\n var btn = el('button', { type: 'button', className: 'picker-btn' });\n wrap.appendChild(btn);\n var pop = null;\n function labelOf(v) {\n if (!all) return v;\n var o = all.filter(function (x) { return x[key] === v; })[0];\n return o ? o.label : v;\n }\n function emit() { opts.onChange(multiple ? selected.slice() : (selected[0] || '')); }\n function drawBtn() {\n btn.textContent = '';\n if (!selected.length) btn.appendChild(el('span', { className: 'ph', text: opts.placeholder || (multiple ? 'All (pick to narrow)' : 'Choose...') }));\n selected.forEach(function (v) {\n btn.appendChild(el('span', { className: 'tok' }, el('span', { text: labelOf(v) }), el('button', { type: 'button', title: 'Remove', text: '×', onclick: function (e) {\n e.stopPropagation();\n selected = selected.filter(function (x) { return x !== v; });\n drawBtn(); emit(); if (pop) drawList();\n } })));\n });\n btn.appendChild(el('span', { className: 'chev' }, icon('chev')));\n }\n var search, list, foot;\n function drawList() {\n list.textContent = '';\n if (failed) { list.appendChild(el('div', { className: 'error', text: failed })); return; }\n if (!all) { list.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading from your tenant...')); return; }\n var q = search.value.trim().toLowerCase();\n var shown = all.filter(function (o) { return !q || (o.label + ' ' + (o.hint || '')).toLowerCase().indexOf(q) >= 0; });\n shown.slice(0, 300).forEach(function (o) {\n var on = selected.indexOf(o[key]) >= 0;\n var row = el('label', { className: 'opt' });\n if (multiple) row.appendChild(el('input', { type: 'checkbox', checked: on }));\n row.appendChild(el('span', { text: o.label, style: on && !multiple ? 'font-weight:600;color:var(--accent)' : '' }));\n if (o.hint) row.appendChild(el('span', { className: 'hint', text: o.hint }));\n row.addEventListener('click', function (e) {\n e.preventDefault();\n if (multiple) {\n if (on) selected = selected.filter(function (x) { return x !== o[key]; }); else selected.push(o[key]);\n drawList();\n } else { selected = [o[key]]; close(); }\n drawBtn(); emit();\n });\n list.appendChild(row);\n });\n if (!shown.length) list.appendChild(el('div', { className: 'muted small', style: 'padding:8px', text: 'Nothing matches.' }));\n if (shown.length > 300) list.appendChild(el('div', { className: 'muted small', style: 'padding:8px', text: 'Showing 300 of ' + shown.length + '. Type to narrow.' }));\n foot.textContent = '';\n foot.appendChild(el('span', { text: all.length + ' in your tenant' + (multiple ? ' · ' + selected.length + ' picked' : '') }));\n if (selected.length) foot.appendChild(el('button', { type: 'button', className: 'btn link', text: 'Clear', onclick: function () { selected = []; drawBtn(); emit(); drawList(); } }));\n }\n function open() {\n if (pop) return;\n search = el('input', { className: 'input', placeholder: 'Search...' });\n list = el('div', { className: 'pop-list' });\n foot = el('div', { className: 'pop-foot' });\n pop = el('div', { className: 'pop' }, search, list, foot);\n wrap.appendChild(pop);\n search.addEventListener('input', drawList);\n search.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });\n drawList();\n setTimeout(function () { search.focus(); document.addEventListener('mousedown', outside); }, 0);\n }\n function close() { if (pop) { pop.remove(); pop = null; document.removeEventListener('mousedown', outside); } }\n function outside(e) { if (!wrap.contains(e.target)) close(); }\n btn.addEventListener('click', function () { if (pop) close(); else open(); });\n Promise.resolve(opts.options).then(function (o) { all = o; drawBtn(); if (pop) drawList(); }, function (e) { failed = errorText(e); if (pop) drawList(); });\n drawBtn();\n return wrap;\n }\n /** Free-text list with suggestions: type and press Enter or comma. */\n function tokenInput(opts) {\n var values = Array.isArray(opts.value) ? opts.value.slice() : opts.value ? String(opts.value).split(',').map(function (s) { return s.trim(); }).filter(Boolean) : [];\n var id = 'dl' + Math.random().toString(36).slice(2);\n var input = el('input', { placeholder: values.length ? '' : (opts.placeholder || 'Type and press Enter'), 'aria-label': opts.label || opts.placeholder || 'Add a value (press Enter)', list: opts.suggestions && opts.suggestions.length ? id : null });\n var box = el('div', { className: 'tokinput' });\n function draw() {\n box.textContent = '';\n values.forEach(function (v) {\n box.appendChild(el('span', { className: 'tok' }, el('span', { text: v }), el('button', { type: 'button', text: '×', 'aria-label': 'Remove ' + v, onclick: function () { values = values.filter(function (x) { return x !== v; }); draw(); opts.onChange(values.slice()); } })));\n });\n input.placeholder = values.length ? '' : (opts.placeholder || 'Type and press Enter');\n box.appendChild(input);\n if (opts.suggestions && opts.suggestions.length) box.appendChild(el('datalist', { id: id }, opts.suggestions.map(function (s) { return el('option', { value: s }); })));\n }\n function commit() {\n input.value.split(',').map(function (s) { return s.trim(); }).filter(Boolean).forEach(function (v) { if (values.indexOf(v) < 0) values.push(v); });\n input.value = '';\n draw(); opts.onChange(values.slice()); input.focus();\n }\n input.addEventListener('keydown', function (e) {\n if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); commit(); }\n else if (e.key === 'Backspace' && !input.value && values.length) { values.pop(); draw(); opts.onChange(values.slice()); input.focus(); }\n });\n input.addEventListener('change', function () { if (input.value.trim()) commit(); });\n input.addEventListener('blur', function () { if (input.value.trim()) commit(); });\n box.addEventListener('click', function (e) { if (e.target === box) input.focus(); });\n draw();\n return box;\n }\n /** Values seen in the tenant for the field a parameter filters on (for suggestions). */\n function suggestionsFor(d, name) {\n if (!d || !state.catalog) return [];\n var field = null;\n (function walk(c) {\n if (!c || field) return;\n if (c.all || c.any) (c.all || c.any).forEach(walk);\n else if (c.not) walk(c.not);\n else if (c.value === '${' + name + '}') field = c.field;\n })({ all: [d.where, d.filter, d.expand && d.expand.where].filter(Boolean) });\n if (!field) return [];\n var disc = state.disc[d.from.dataset];\n if (!disc || !disc.fields) { ensureDisc(d.from.dataset); return []; }\n return fieldInfo(d, field).values || [];\n }\n /** The input for one report parameter. */\n function paramInput(p, value, onChange, suggestions) {\n if (p.pick) return picker({ options: loadPick(p.pick), multiple: p.type === 'list', value: value, onChange: onChange, placeholder: p.type === 'list' ? (p.required ? 'Pick one or more' : 'All (pick to narrow)') : 'Choose...' });\n if (p.options) {\n if (p.type === 'list') return picker({ options: p.options.map(function (o) { return { value: o, label: o }; }), multiple: true, value: value, onChange: onChange });\n var s = el('select', { className: 'input' }, el('option', { value: '', text: p.required ? 'Choose...' : '(any)' }), p.options.map(function (o) { return el('option', { value: o, text: o }); }));\n s.value = value || '';\n s.addEventListener('change', function () { onChange(s.value); });\n return s;\n }\n if (p.type === 'list') return tokenInput({ value: value, onChange: onChange, suggestions: suggestions, placeholder: suggestions && suggestions.length ? 'e.g. ' + suggestions.slice(0, 3).join(', ') : 'Type a value and press Enter' });\n if (p.type === 'boolean') {\n var b = el('select', { className: 'input' }, el('option', { value: '', text: '(default)' }), el('option', { value: 'true', text: 'Yes' }), el('option', { value: 'false', text: 'No' }));\n b.value = value === true ? 'true' : value === false ? 'false' : String(value || '');\n b.addEventListener('change', function () { onChange(b.value); });\n return b;\n }\n var dlId = suggestions && suggestions.length && p.type !== 'number' ? 'pv' + Math.random().toString(36).slice(2) : null;\n var i = el('input', { className: 'input', type: p.type === 'number' ? 'number' : 'text', value: value === undefined || value === null ? '' : String(value), list: dlId });\n i.addEventListener('input', function () { onChange(i.value); });\n if (!dlId) return i;\n return el('div', {}, i, el('datalist', { id: dlId }, suggestions.map(function (v) { return el('option', { value: v }); })));\n }\n function paramsGrid(params, values, onChange, def) {\n var names = Object.keys(params || {});\n if (!names.length) return null;\n return el('div', { className: 'grid' }, names.map(function (k) {\n var p = params[k];\n return el('label', { className: 'field', onclick: function (e) { if (e.target.tagName === 'LABEL') e.preventDefault(); } },\n el('span', { className: 'lbl' }, p.description || k, p.required ? el('span', { className: 'req', text: '*' }) : null),\n paramInput(p, values[k], function (v) { values[k] = v; if (onChange) onChange(k, v); }, def ? suggestionsFor(def, k) : null));\n }));\n }\n\n // ---------- report view ----------\n function renderMain() {\n var m = $('main');\n var keep = m.scrollTop;\n m.textContent = '';\n var c = state.current;\n if (!c) { renderHome(); return; }\n var d = c.def;\n var w = el('div', { className: 'wrap' });\n m.appendChild(w);\n var cat = c.custom ? 'My reports' : (d.category || 'Other');\n w.appendChild(el('div', { className: 'crumbs' }, el('button', { text: 'All reports', onclick: goHome }), '/', el('span', { text: cat })));\n w.appendChild(el('div', { className: 'rhead' }, catIcon(cat), el('div', { style: 'flex:1' },\n el('h2', { text: d.name || 'New report' }),\n d.description ? el('p', { className: 'desc', text: d.description }) : null,\n (d.tags && d.tags.length) ? el('div', { style: 'margin-top:8px' }, d.tags.map(function (t) { return el('span', { className: 'tag', text: t }); })) : null)));\n var tabs = el('div', { className: 'tabs' });\n [['run', 'Run', 'play'], ['design', c.custom ? 'Design' : 'Customize', 'sliders'], ['yaml', 'YAML', 'code']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.tab === t[0] ? ' active' : ''), onclick: function () { state.tab = t[0]; renderMain(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.tab === 'run') renderRun(w);\n else if (state.tab === 'design') renderDesign(w);\n else renderYaml(w);\n m.scrollTop = keep;\n }\n\n function renderRun(w) {\n var c = state.current, d = c.def;\n var card = el('section', { className: 'card' });\n var grid = paramsGrid(d.params, state.paramValues, null, d);\n if (grid) card.appendChild(el('div', { className: 'card-h' }, el('h3', {}, icon('sliders'), 'Options')));\n if (grid) card.appendChild(grid);\n var groupSel = el('select', { className: 'input' }, el('option', { value: '', text: 'Every row' }), fieldChoices(d, true).map(function (g) {\n return el('optgroup', { label: g.label }, g.fields.map(function (o) { return el('option', { value: o.value, text: 'Count by ' + o.label }); }));\n }));\n groupSel.value = state.groupBy || '';\n groupSel.addEventListener('change', function () { state.groupBy = groupSel.value; });\n card.appendChild(el('div', { className: 'runbar', style: grid ? '' : 'margin-top:0;padding-top:0;border-top:none' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Show' }), groupSel),\n el('button', { className: 'btn', title: 'Reads only the first 500 records, to check the report quickly', onclick: function () { run(500); } }, icon('eye'), 'Preview'),\n el('button', { className: 'btn primary', onclick: function () { run(); } }, icon('play'), 'Run report'),\n el('span', { className: 'spacer' }),\n c.isNew ? null : el('button', { className: 'btn ghost', title: 'Send it by email or Teams on a schedule', onclick: function () {\n state.editing = { isNew: true, report: d.id, params: clone(state.paramValues || {}) };\n showPage('schedules');\n } }, icon('clock'), 'Schedule this report')));\n w.appendChild(card);\n var out = el('div', { id: 'run-out' });\n w.appendChild(out);\n renderResult();\n }\n\n function paramsForRun() {\n var out = {};\n Object.keys(state.paramValues || {}).forEach(function (k) {\n var v = state.paramValues[k];\n if (v === '' || v === null || v === undefined || (Array.isArray(v) && !v.length)) return;\n out[k] = v;\n });\n return out;\n }\n function run(preview) {\n var c = state.current;\n var params = paramsForRun();\n Object.keys(params).forEach(function (k) { if (!c.def.params || !c.def.params[k]) delete params[k]; });\n var body = { definition: c.def, params: params, preview: preview, groupBy: state.groupBy && state.tab === 'run' ? [state.groupBy] : [] };\n state.result = null;\n state.runError = null;\n state.progress = 'Starting...';\n state.running = true;\n state.sortCol = null;\n state.quick = '';\n renderResult();\n api('/api/run', 'POST', body).then(function (r) {\n state.job = r.job;\n poll(r.job);\n }).catch(function (e) { state.running = false; state.runError = errorText(e); renderResult(); });\n }\n function poll(job) {\n state.activeJob = job;\n api('/api/jobs/' + job).then(function (s) {\n if (state.job !== job) return;\n if (s.state === 'running') {\n state.progress = s.progress + ' · ' + s.seconds + 's';\n renderResult();\n setTimeout(function () { poll(job); }, 700);\n } else {\n state.running = false;\n if (s.state === 'error') state.runError = s.error;\n else state.result = s.result;\n renderResult();\n }\n }).catch(function (e) { state.running = false; state.runError = errorText(e); renderResult(); });\n }\n function cellText(v) { return v === null || v === undefined ? '' : typeof v === 'boolean' ? (v ? 'Yes' : 'No') : typeof v === 'number' ? fmtNum(v) : String(v); }\n function renderResult() {\n var out = $('run-out');\n if (!out) return;\n out.textContent = '';\n if (state.running) {\n out.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { text: state.progress, style: 'flex:1' }), stopButton())));\n return;\n }\n if (state.runError) { out.appendChild(el('div', { className: 'error', text: state.runError })); return; }\n var r = state.result;\n if (!r) {\n out.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Ready when you are' }), 'Press Preview for a quick look at the first 500 records, or Run report for the full result.'));\n return;\n }\n var dl = function (f, label, primary) {\n return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + state.job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label);\n };\n var quick = el('input', { className: 'input', placeholder: 'Filter these rows...', value: state.quick || '', style: 'width:230px;padding:6px 10px' });\n var card = el('section', { className: 'card', style: 'padding:16px' });\n card.appendChild(el('div', { className: 'stats' },\n el('div', { className: 'stat' }, el('b', { text: fmtNum(r.total) }), el('span', { text: r.total === 1 ? 'row' : 'rows' })),\n el('div', { className: 'stat' }, el('b', { text: (r.durationMs / 1000).toFixed(1) + 's' }), el('span', { text: 'to run' })),\n el('span', { className: 'spacer', style: 'flex:1' }),\n r.total ? quick : null,\n dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML')));\n r.warnings.forEach(function (x) { card.appendChild(el('div', { className: 'note', text: x })); });\n if (r.total > r.shown) card.appendChild(el('div', { className: 'note', text: 'Showing the first ' + fmtNum(r.shown) + ' rows here. Downloads contain all ' + fmtNum(r.total) + '.' }));\n out.appendChild(card);\n if (!r.total) { card.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No rows' }), 'Nothing in the tenant matches this report. That can be good news.')); return; }\n var tableBox = el('div', { className: 'table-wrap' });\n card.appendChild(tableBox);\n function drawTable() {\n var q = (state.quick || '').toLowerCase();\n var rows = r.rows.filter(function (row) { return !q || row.some(function (v) { return cellText(v).toLowerCase().indexOf(q) >= 0; }); });\n if (state.sortCol !== null && state.sortCol !== undefined) {\n var i = state.sortCol, dir = state.sortDir;\n rows = rows.slice().sort(function (a, b) {\n var x = a[i], y = b[i];\n if (x === null || x === '') return 1; if (y === null || y === '') return -1;\n if (typeof x === 'number' && typeof y === 'number') return (x - y) * dir;\n return String(x).localeCompare(String(y), 'en', { numeric: true, sensitivity: 'base' }) * dir;\n });\n }\n tableBox.textContent = '';\n tableBox.appendChild(el('table', {},\n el('thead', {}, el('tr', {}, r.columns.map(function (col, i) {\n return el('th', { title: 'Sort', onclick: function () { state.sortDir = state.sortCol === i ? -state.sortDir : 1; state.sortCol = i; drawTable(); } },\n col.label, state.sortCol === i ? el('span', { className: 'arrow', text: state.sortDir > 0 ? '▲' : '▼' }) : null);\n }))),\n el('tbody', {}, rows.map(function (row) {\n return el('tr', {}, row.map(function (v) {\n if (typeof v === 'boolean') return el('td', {}, el('span', { className: v ? 'yes' : 'no', text: v ? 'Yes' : 'No' }));\n return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) });\n }));\n }))));\n if (!rows.length) tableBox.appendChild(el('div', { className: 'empty', text: 'No shown row contains \"' + state.quick + '\".' }));\n }\n quick.addEventListener('input', function () { state.quick = quick.value; drawTable(); });\n drawTable();\n }\n\n // ---------- fields ----------\n var ALIAS_LABEL = { profile: 'Identity profile', mapping: 'Mapping', identity: 'Identity', account: 'Account', access: 'Access item', entitlement: 'Entitlement', source: 'Source', role: 'Role', accessProfile: 'Access profile', event: 'Audit event', activity: 'Account activity', campaign: 'Campaign', item: 'Review item', request: 'Access request', request2: 'Request' };\n function datasetOf(name) { return state.catalog.datasets.filter(function (d) { return d.name === name; })[0]; }\n function ensureDisc(dataset) {\n if (state.disc[dataset]) return;\n state.disc[dataset] = { loading: true };\n api('/api/discover/' + dataset).then(function (r) { state.disc[dataset] = r; }, function (e) { state.disc[dataset] = { error: errorText(e) }; })\n .then(function () {\n if (state.page === 'build' && state.bt && state.bt.tab === 'roles' && dataset === 'identities' && !state.imp.busy) { renderBuild(); return; }\n if (!$('roles').classList.contains('hidden')) { if (dataset === 'identities' && ((state.roleTab === 'impact' && !state.imp.busy) || (state.roleTab === 'mining' && !state.mn.busy))) renderRoles(); return; }\n if (state.current && !state.running && state.tab !== 'yaml' && state.current.def.from.dataset === dataset) renderMain();\n });\n }\n /** Field choices grouped by alias. Each field: { value, label, type, values, path }. */\n function fieldChoices(d, forCounting) {\n var ds = datasetOf(d.from.dataset);\n if (!ds) return [];\n var disc = state.disc[d.from.dataset];\n var discOk = disc && disc.fields;\n var groups = [];\n function addGroup(alias, label, catalog, found) {\n var byPath = {};\n (found || []).forEach(function (f) { byPath[f.path] = f; });\n var known = [], extra = [];\n (catalog || []).forEach(function (f) {\n if (f.type === 'object' || (forCounting && f.type === 'list' && !f.expandable && f.path !== 'tags')) return;\n if (f.expandable) return;\n var df = byPath[f.path];\n known.push({ value: alias + '.' + f.path, label: f.label, type: f.type, values: df ? df.values : [], path: f.path });\n });\n (found || []).forEach(function (f) {\n if (f.known || f.type === 'object') return;\n if ((catalog || []).some(function (c) { return c.path === f.path || f.path.indexOf(c.path + '.') === 0 && c.expandable; })) return;\n extra.push({ value: alias + '.' + f.path, label: f.label, type: f.type, values: f.values, path: f.path });\n });\n if (known.length) groups.push({ label: label, fields: known });\n if (extra.length) groups.push({ label: label + ': more found in your tenant', fields: extra });\n }\n var root = d.from.as || ds.alias;\n addGroup(root, ALIAS_LABEL[root] || ds.label, ds.fields, discOk ? disc.fields : null);\n if (d.expand) {\n var key = d.expand.path.split('.').slice(1).join('.');\n var items = ds.itemFields && ds.itemFields[key];\n if (items) addGroup(d.expand.as, ALIAS_LABEL[d.expand.as] || d.expand.as, items, discOk && disc.items ? disc.items[key] : null);\n }\n (d.joins || []).forEach(function (j) {\n var jd = datasetOf(j.dataset);\n if (jd) addGroup(j.as, (ALIAS_LABEL[j.as] || jd.label) + ' (looked up)', jd.fields, null);\n });\n return groups;\n }\n function flatFields(d) { return [].concat.apply([], fieldChoices(d).map(function (g) { return g.fields; })); }\n function fieldInfo(d, value) {\n var f = flatFields(d).filter(function (x) { return x.value === value; })[0];\n return f || { value: value, label: value, type: 'string', values: [] };\n }\n function fieldSelect(d, value, onChange, opts) {\n opts = opts || {};\n var s = el('select', { className: 'input' });\n if (opts.empty) s.appendChild(el('option', { value: '', text: opts.empty }));\n var found = false;\n fieldChoices(d, opts.counting).forEach(function (g) {\n s.appendChild(el('optgroup', { label: g.label }, g.fields.map(function (f) { if (f.value === value) found = true; return el('option', { value: f.value, text: f.label }); })));\n });\n if (value && !found) s.insertBefore(el('option', { value: value, text: value }), s.firstChild);\n s.value = value || '';\n s.addEventListener('change', function () { onChange(s.value); });\n return s;\n }\n function isSourceId(path) { return /(^|\\.)source\\.id$|(^|\\.)sourceId$/.test(path); }\n function isSourceName(path) { return /(^|\\.)source\\.name$|(^|\\.)sourceName$|(^|\\.)source\\.displayableName$/.test(path); }\n function formatFor(type) { return type === 'date' ? 'date' : type === 'boolean' ? 'boolean' : type === 'number' ? 'number' : type === 'list' ? 'list' : undefined; }\n\n // operators shown for each kind of field\n var OPS_BY_TYPE = {\n string: [['eq', 'is'], ['ne', 'is not'], ['in', 'is one of'], ['notIn', 'is none of'], ['contains', 'contains'], ['notContains', 'does not contain'], ['startsWith', 'starts with'], ['endsWith', 'ends with'], ['exists', 'has a value'], ['missing', 'is empty'], ['matches', 'matches pattern']],\n list: [['eq', 'includes'], ['in', 'includes one of'], ['notIn', 'includes none of'], ['contains', 'has an item containing'], ['exists', 'is not empty'], ['missing', 'is empty']],\n boolean: [['isTrue', 'is Yes'], ['isFalse', 'is No'], ['missing', 'is empty']],\n number: [['eq', '='], ['ne', '≠'], ['gt', '>'], ['gte', '≥'], ['lt', '<'], ['lte', '≤'], ['exists', 'has a value'], ['missing', 'is empty']],\n date: [['newerThanDays', 'in the last (days)'], ['olderThanDays', 'more than (days) ago'], ['exists', 'has a value'], ['missing', 'is empty']]\n };\n function opsFor(type) { return OPS_BY_TYPE[type] || OPS_BY_TYPE.string; }\n function needsValue(op) { var o = state.catalog.operators.filter(function (x) { return x.op === op; })[0]; return o ? o.needsValue : true; }\n var ASK = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\n\n // ---------- designer ----------\n var TEMPLATES = [\n { key: 'people', label: 'Identities', desc: 'One row per identity', icon: 'people', dataset: 'identities', cols: ['identity.displayName', 'identity.email', 'identity.attributes.department', 'identity.attributes.cloudLifecycleState', 'identity.manager.displayName'] },\n { key: 'people-accounts', label: 'Identities and their accounts', desc: 'One row per account of each identity', icon: 'apps', dataset: 'identities', expand: 'identity.accounts', cols: ['identity.displayName', 'identity.attributes.cloudLifecycleState', 'account.source.name', 'account.name', 'account.disabled'] },\n { key: 'people-access', label: 'Identities and their access', desc: 'One row per role, access profile or entitlement held', icon: 'layers', dataset: 'identities', expand: 'identity.access', cols: ['identity.displayName', 'identity.email', 'access.type', 'access.displayName', 'access.source.name', 'access.privileged'] },\n { key: 'accounts', label: 'Accounts', desc: 'All accounts, linked or not', icon: 'apps', dataset: 'accounts', cols: ['account.sourceName', 'account.name', 'account.nativeIdentity', 'account.uncorrelated', 'account.disabled'] },\n { key: 'entitlements', label: 'Entitlements', desc: 'Groups, profiles, permissions', icon: 'layers', dataset: 'entitlements', cols: ['entitlement.source.name', 'entitlement.name', 'entitlement.owner.name', 'entitlement.privileged', 'entitlement.requestable'] },\n { key: 'roles', label: 'Roles', desc: 'Role catalog', icon: 'layers', dataset: 'roles', cols: ['role.name', 'role.owner.name', 'role.enabled', 'role.requestable', 'role.accessProfileCount'] },\n { key: 'accessProfiles', label: 'Access profiles', desc: 'Access profile catalog', icon: 'layers', dataset: 'accessProfiles', cols: ['accessProfile.source.name', 'accessProfile.name', 'accessProfile.owner.name', 'accessProfile.enabled', 'accessProfile.requestable'] },\n { key: 'sources', label: 'Sources', desc: 'Connected applications', icon: 'db', dataset: 'sources', cols: ['source.name', 'source.type', 'source.status', 'source.owner.name', 'source.authoritative'] },\n { key: 'events', label: 'Audit events', desc: 'What happened, when, by whom', icon: 'pulse', dataset: 'events', cols: ['event.created', 'event.name', 'event.type', 'event.status', 'event.target.name', 'event.actor.name'] },\n { key: 'accessRequests', label: 'Access requests', desc: 'Requests and where they stand', icon: 'inbox', dataset: 'accessRequests', cols: ['request.created', 'request.requestedFor.name', 'request.name', 'request.type', 'request.state'] },\n { key: 'certificationItems', label: 'Review decisions', desc: 'Certification items and decisions', icon: 'cert', dataset: 'certificationItems', cols: ['item.campaign.name', 'item.certification.reviewer.name', 'item.identitySummary.name', 'item.accessSummary.access.name', 'item.decision'] },\n { key: 'activities', label: 'Account activities', desc: 'Provisioning: creates, changes, errors', icon: 'pulse', dataset: 'accountActivities', cols: ['activity.created', 'activity.action', 'activity.recipient.name', 'activity.sources', 'activity.status', 'activity.errors'] },\n { key: 'mappings', label: 'Identity mappings', desc: 'Where each identity attribute comes from', icon: 'db', dataset: 'identityProfiles', expand: 'profile.mappings', cols: ['profile.name', 'mapping.attribute', 'mapping.kind', 'mapping.source', 'mapping.sourceAttribute', 'mapping.transform'] },\n { key: 'campaigns', label: 'Campaigns', desc: 'Certification campaigns', icon: 'cert', dataset: 'campaigns', cols: ['campaign.name', 'campaign.status', 'campaign.deadline', 'campaign.totalCertifications', 'campaign.completedCertifications'] }\n ];\n function templateFor(d) {\n return TEMPLATES.filter(function (t) { return t.dataset === d.from.dataset && (t.expand || '') === (d.expand ? d.expand.path : ''); })[0];\n }\n function applyTemplate(d, t) {\n d.from = { dataset: t.dataset };\n if (t.expand) d.expand = { path: t.expand, as: t.expand === 'identity.access' ? 'access' : t.expand === 'profile.mappings' ? 'mapping' : 'account' }; else delete d.expand;\n delete d.where; delete d.joins; delete d.filter; delete d.sort; delete d.group; delete d.limit;\n Object.keys(d.params || {}).forEach(function (k) { delete d.params[k]; });\n delete d.params;\n var ds = datasetOf(t.dataset);\n d.columns = t.cols.map(function (p) {\n var root = p.split('.')[0], rest = p.split('.').slice(1).join('.');\n var list = root === (ds.alias) ? ds.fields : (ds.itemFields && ds.itemFields[(t.expand || '').split('.').slice(1).join('.')]) || [];\n var f = list.filter(function (x) { return x.path === rest; })[0];\n return { field: p, label: f ? f.label : undefined, format: f ? formatFor(f.type) : undefined };\n });\n }\n function newReport() {\n var def = { id: 'my-report-' + Date.now().toString(36), name: 'New report', category: 'My reports', from: { dataset: 'identities' } };\n applyTemplate(def, TEMPLATES[0]);\n state.current = { source: null, def: def, custom: true, isNew: true };\n state.tab = 'design';\n state.result = null;\n state.groupBy = '';\n state.runError = null;\n state.paramValues = {};\n state.dirty = true;\n renderLibrary();\n renderMain();\n }\n $('btn-new').addEventListener('click', newReport);\n\n function changed() { state.dirty = true; state.current.yaml = null; }\n function card(stepNo, iconName, title, hint) {\n return el('section', { className: 'card' }, el('div', { className: 'card-h' },\n el('h3', {}, stepNo ? el('span', { className: 'step', text: String(stepNo) }) : icon(iconName), title),\n hint ? el('span', { className: 'muted small', text: hint }) : null));\n }\n\n function renderDesign(w) {\n var c = state.current, d = c.def, ds = datasetOf(d.from.dataset);\n ensureDisc(d.from.dataset);\n var disc = state.disc[d.from.dataset] || {};\n\n // about\n var nameIn = el('input', { className: 'input', value: d.name });\n nameIn.addEventListener('input', function () { d.name = nameIn.value; changed(); });\n var descIn = el('input', { className: 'input', value: d.description || '', placeholder: 'What this report shows and who it is for' });\n descIn.addEventListener('input', function () { d.description = descIn.value || undefined; changed(); });\n var about = card(0, 'file', 'About this report');\n about.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:1fr 2fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Name' }), nameIn),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Description' }), descIn)));\n if (!c.custom) about.appendChild(el('div', { className: 'note', text: 'This is a ready-made report. Your changes are saved as your own copy under \"My reports\".' }));\n w.appendChild(about);\n\n // 1. data\n var tpl = templateFor(d);\n var data = card(1, null, 'What do you want a row to be?', disc.loading ? 'reading a sample of your tenant...' : disc.sampled !== undefined ? 'fields checked against ' + disc.sampled + ' records of your tenant' : '');\n data.appendChild(el('div', { className: 'tiles' }, TEMPLATES.map(function (t) {\n return el('button', { className: 'tile' + (tpl === t ? ' active' : ''), onclick: function () {\n if (tpl === t) return;\n if ((d.filter || d.where || d.group) && !confirm('Start over with \"' + t.label + '\"? Filters and columns are reset.')) return;\n applyTemplate(d, t); changed(); renderMain();\n } }, catIcon({ people: 'Identities', apps: 'Application owners', layers: 'Access model', db: 'Hygiene', pulse: 'Operations', inbox: 'Requests', cert: 'Certifications' }[t.icon]), el('div', {}, el('b', { text: t.label }), el('span', { text: t.desc })));\n })));\n if (!tpl) data.appendChild(el('div', { className: 'note', text: 'This report reads ' + ds.label.toLowerCase() + (d.expand ? ', one row per item of ' + d.expand.path : '') + '. Pick a tile to start over with another kind of row.' }));\n if (disc.error) data.appendChild(el('div', { className: 'note', text: 'Could not read a sample from your tenant, so only the standard fields are offered. ' + disc.error }));\n if (d.where || (d.expand && d.expand.where) || (d.joins && d.joins.length)) {\n data.appendChild(el('div', { className: 'note', text: 'This report also has built-in rules and lookups. They are kept as they are; see the YAML tab.' }));\n }\n w.appendChild(data);\n\n // 2. filters\n w.appendChild(filtersCard(d));\n\n // 3. columns or counts\n w.appendChild(columnsCard(d));\n\n // 4. sort and limit\n var sortCard = card(4, null, 'Order and size');\n var s0 = (d.sort && d.sort[0]) || '';\n var dir = el('select', { className: 'input' }, el('option', { value: '', text: 'A → Z, smallest, oldest first' }), el('option', { value: '-', text: 'Z → A, largest, newest first' }));\n dir.value = s0.charAt(0) === '-' ? '-' : '';\n var sortField = s0.replace(/^[-+]/, '');\n var writeSort = function () { if (sortField) d.sort = [dir.value + sortField]; else delete d.sort; changed(); };\n dir.addEventListener('change', writeSort);\n var lim = el('input', { className: 'input', type: 'number', min: '1', placeholder: 'all rows', value: d.limit || '' });\n lim.addEventListener('input', function () { var n = Number(lim.value); if (lim.value && n > 0) d.limit = Math.floor(n); else delete d.limit; changed(); });\n sortCard.appendChild(el('div', { className: 'grid' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Sort by' }), fieldSelect(d, sortField, function (v) { sortField = v; writeSort(); }, { empty: 'Report order' })),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Direction' }), dir),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Only the first' }), lim)));\n w.appendChild(sortCard);\n\n // advanced\n var search = ds.kind === 'search';\n var qv = search ? d.from.query : d.from.filter;\n var qIn = el('input', { className: 'input', value: Array.isArray(qv) ? qv.join(search ? ' AND ' : ' and ') : (qv || ''), placeholder: ds.hint || '' });\n qIn.addEventListener('input', function () {\n var key = search ? 'query' : 'filter';\n if (qIn.value.trim()) d.from[key] = qIn.value; else delete d.from[key];\n changed();\n });\n w.appendChild(el('section', { className: 'card' }, el('details', { className: 'adv' }, el('summary', { text: 'Advanced: make big reports faster' }),\n el('p', { className: 'muted small', text: search ? 'An ISC search query narrows what is read from the tenant before your filters run. Your filters above still decide the result.' : 'An ISC API filter narrows what is read from the tenant before your filters run.' }),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: search ? 'Search query' : 'API filter' }), qIn))));\n\n // values to try the asked filters with\n if (d.params && Object.keys(d.params).length) {\n state.paramValues = state.paramValues || {};\n var tc = card(0, 'sliders', 'Try it with', 'these are asked each time the report runs');\n tc.appendChild(paramsGrid(d.params, state.paramValues, null, d));\n w.appendChild(tc);\n }\n\n // actions\n var msg = el('span', { className: 'muted small' });\n w.appendChild(el('div', { className: 'actionbar' },\n el('button', { className: 'btn', onclick: function () { run(500); setTimeout(function () { var o = $('run-out'); if (o) o.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, 50); } }, icon('eye'), 'Preview'),\n el('button', { className: 'btn primary', onclick: function () { save(msg); } }, icon('save'), c.custom ? 'Save' : 'Save as my report'),\n c.custom && !c.isNew ? el('button', { className: 'btn ghost danger', onclick: function () {\n if (!confirm('Delete \"' + c.def.name + '\"?')) return;\n api('/api/reports/' + c.def.id, 'DELETE').then(function () { state.current = null; toast('Report deleted'); loadLibrary(); }).catch(function (e) { msg.textContent = errorText(e); });\n } }, icon('trash'), 'Delete') : null,\n msg));\n w.appendChild(el('div', { id: 'run-out' }));\n renderResult();\n }\n\n function filtersCard(d) {\n var fc = card(2, null, 'Which rows?', 'leave empty for all');\n var f = d.filter;\n var list = !f ? [] : f.all ? f.all : f.any ? f.any : f.not ? null : [f];\n var flat = list && list.every(function (x) { return typeof x.field === 'string'; });\n if (!flat) { fc.appendChild(el('div', { className: 'muted', text: 'These filters are nested; edit them in the YAML tab.' })); return fc; }\n var mode = f && f.any ? 'any' : 'all';\n var write = function () {\n list.forEach(function (x) { if (!needsValue(x.op)) delete x.value; });\n var valid = list.filter(function (x) { return x.field; });\n if (!valid.length) delete d.filter; else if (valid.length === 1) d.filter = valid[0]; else d.filter = mode === 'any' ? { any: valid } : { all: valid };\n changed();\n };\n if (list.length > 1) {\n var modeSel = el('select', { className: 'input', style: 'width:auto' }, el('option', { value: 'all', text: 'all' }), el('option', { value: 'any', text: 'any' }));\n modeSel.value = mode;\n modeSel.addEventListener('change', function () { mode = modeSel.value; write(); });\n fc.appendChild(el('div', { className: 'joiner' }, 'Keep rows that match', modeSel, 'of these:'));\n }\n list.forEach(function (x, i) { fc.appendChild(conditionRow(d, x, function () { write(); }, function () { removeAsk(d, x); list.splice(i, 1); write(); renderMain(); })); });\n fc.appendChild(el('button', { className: 'btn', onclick: function () {\n var first = flatFields(d)[0];\n list.push({ field: first ? first.value : '', op: opsFor(first ? first.type : 'string')[0][0], value: '' });\n if (!needsValue(list[list.length - 1].op)) delete list[list.length - 1].value;\n write(); renderMain();\n } }, icon('plus'), 'Add a filter'));\n return fc;\n }\n\n function paramNameFor(d, label) {\n var base = label.replace(/[^A-Za-z0-9 ]/g, ' ').trim().split(/\\s+/).map(function (w, i) { w = w.toLowerCase(); return i ? w.charAt(0).toUpperCase() + w.slice(1) : w; }).join('') || 'value';\n if (/^[0-9]/.test(base)) base = 'p' + base;\n var n = base, k = 2;\n while (d.params && d.params[n]) n = base + k++;\n return n;\n }\n function removeAsk(d, x) {\n var m = typeof x.value === 'string' && ASK.exec(x.value);\n if (m && d.params) { delete d.params[m[1]]; if (!Object.keys(d.params).length) delete d.params; }\n }\n\n function conditionRow(d, x, write, remove) {\n var info = fieldInfo(d, x.field);\n var ops = opsFor(info.type);\n if (!ops.some(function (o) { return o[0] === x.op; })) ops = ops.concat([[x.op, (state.catalog.operators.filter(function (o) { return o.op === x.op; })[0] || { label: x.op }).label]]);\n var askM = typeof x.value === 'string' && ASK.exec(x.value);\n var fieldSel = fieldSelect(d, x.field, function (v) {\n removeAsk(d, x);\n x.field = v;\n var t = fieldInfo(d, v).type;\n x.op = opsFor(t)[0][0];\n if (needsValue(x.op)) x.value = ''; else delete x.value;\n write(); renderMain();\n });\n var opSel = el('select', { className: 'input' }, ops.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n opSel.value = x.op;\n opSel.addEventListener('change', function () {\n var wasList = x.op === 'in' || x.op === 'notIn';\n x.op = opSel.value;\n var isList = x.op === 'in' || x.op === 'notIn';\n if (!needsValue(x.op)) { removeAsk(d, x); delete x.value; }\n else if (!askM && wasList !== isList) x.value = isList ? (x.value ? [String(x.value)] : []) : (Array.isArray(x.value) ? (x.value[0] || '') : x.value || '');\n else if (askM) { var p = d.params[askM[1]]; p.type = isList ? 'list' : (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') ? 'number' : 'string'; }\n write(); renderMain();\n });\n var valueBox = el('div');\n if (askM) {\n var p = (d.params || {})[askM[1]] || {};\n var q = el('input', { className: 'input', value: p.description || '', placeholder: 'Question shown when running' });\n q.addEventListener('input', function () { p.description = q.value || undefined; changed(); });\n valueBox.appendChild(q);\n } else if (needsValue(x.op)) {\n valueBox.appendChild(valueEditor(d, x, info, write));\n }\n var askBox = el('input', { type: 'checkbox', checked: !!askM });\n askBox.addEventListener('change', function () {\n if (askBox.checked) {\n // Source names become a source drop-down: ask for the source, filter on its ID.\n var idField = isSourceName(x.field) ? x.field.replace(/source\\.name$|source\\.displayableName$/, 'source.id').replace(/sourceName$/, 'sourceId') : null;\n if (idField && flatFields(d).some(function (f) { return f.value === idField; })) { x.field = idField; x.value = Array.isArray(x.value) ? [] : ''; }\n var listOp = x.op === 'in' || x.op === 'notIn';\n var numeric = x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number';\n var name = paramNameFor(d, fieldInfo(d, x.field).label);\n d.params = d.params || {};\n var spec = { type: listOp ? 'list' : numeric ? 'number' : 'string', description: fieldInfo(d, x.field).label + (numeric && x.op !== 'eq' ? ' (days)' : '') };\n if (isSourceId(x.field)) spec.pick = 'sources';\n var cur = x.value;\n if (cur !== '' && cur !== undefined && !(Array.isArray(cur) && !cur.length) && !isSourceId(x.field)) spec['default'] = cur;\n d.params[name] = spec;\n x.value = '${' + name + '}';\n state.paramValues = state.paramValues || {};\n state.paramValues[name] = spec['default'] !== undefined ? spec['default'] : spec.type === 'list' ? [] : '';\n } else {\n var m = ASK.exec(x.value);\n var prev = m && d.params && d.params[m[1]];\n removeAsk(d, x);\n x.value = prev && prev['default'] !== undefined ? prev['default'] : (x.op === 'in' || x.op === 'notIn') ? [] : '';\n }\n write(); renderMain();\n });\n var ask = needsValue(x.op) ? el('label', { className: 'ask' }, askBox, el('span', { text: askM ? 'Asked when the report runs (and in schedules).' : 'Ask for this value each time the report runs' })) : null;\n return el('div', { className: 'cond' }, fieldSel, opSel, valueBox,\n el('button', { className: 'btn icon ghost', title: 'Remove this filter', onclick: remove }, icon('x')), ask);\n }\n\n function valueEditor(d, x, info, write) {\n var listOp = x.op === 'in' || x.op === 'notIn';\n var path = info.path || x.field;\n if (isSourceId(path) || isSourceName(path)) {\n return picker({ options: loadPick('sources'), multiple: listOp, value: x.value, valueKey: isSourceId(path) ? 'value' : 'label', onChange: function (v) { x.value = v; write(); }, placeholder: listOp ? 'Pick sources' : 'Pick a source' });\n }\n if (x.op === 'newerThanDays' || x.op === 'olderThanDays' || info.type === 'number') {\n var n = el('input', { className: 'input', type: 'number', value: x.value === undefined ? '' : String(x.value), placeholder: x.op === 'newerThanDays' || x.op === 'olderThanDays' ? 'days, e.g. 30' : 'number' });\n n.addEventListener('input', function () { x.value = n.value === '' ? '' : Number(n.value); write(); });\n return n;\n }\n if (listOp) {\n if (info.values && info.values.length && info.values.length <= 50) {\n return picker({ options: info.values.map(function (v) { return { value: v, label: v }; }), multiple: true, value: x.value, onChange: function (v) { x.value = v; write(); }, placeholder: 'Pick or type values' });\n }\n return tokenInput({ value: x.value, suggestions: info.values, onChange: function (v) { x.value = v; write(); } });\n }\n var id = 'sv' + Math.random().toString(36).slice(2);\n var t = el('input', { className: 'input', value: x.value === undefined ? '' : String(x.value), list: info.values && info.values.length ? id : null, placeholder: info.values && info.values.length ? 'e.g. ' + info.values.slice(0, 2).join(', ') : 'value' });\n t.addEventListener('input', function () { x.value = t.value; write(); });\n return el('div', {}, t, info.values && info.values.length ? el('datalist', { id: id }, info.values.map(function (v) { return el('option', { value: v }); })) : null);\n }\n\n function columnsCard(d) {\n var counting = !!(d.group && d.group.by && d.group.by.length);\n var cc = card(3, null, 'What to show', null);\n var modeSel = el('div', { className: 'chips', style: 'margin-bottom:14px' },\n el('button', { className: 'chip' + (!counting ? ' active' : ''), onclick: function () {\n if (!counting) return;\n d.columns = state.current.stash || d.columns; delete d.group; changed(); renderMain();\n } }, icon('cols'), 'A list of rows'),\n el('button', { className: 'chip' + (counting ? ' active' : ''), onclick: function () {\n if (counting) return;\n state.current.stash = clone(d.columns || []);\n var first = (d.columns && d.columns[0] && d.columns[0].field) || (flatFields(d)[0] || {}).value;\n d.group = { by: [first], countLabel: 'Count' };\n syncGroupColumns(d); changed(); renderMain();\n } }, icon('sigma'), 'Counts (summary)'));\n cc.appendChild(modeSel);\n if (counting) {\n cc.appendChild(el('p', { className: 'muted small', style: 'margin-top:0', text: 'One row per combination of these fields, with how many rows have it. Largest first.' }));\n d.group.by.forEach(function (b, i) {\n cc.appendChild(el('div', { className: 'colrow', style: 'grid-template-columns:28px 1fr auto' }, el('span', { className: 'n', text: String(i + 1) }),\n fieldSelect(d, b, function (v) { d.group.by[i] = v; syncGroupColumns(d); changed(); }, { counting: true }),\n el('button', { className: 'btn icon ghost', title: 'Remove', disabled: d.group.by.length === 1, onclick: function () { d.group.by.splice(i, 1); syncGroupColumns(d); changed(); renderMain(); } }, icon('x'))));\n });\n if (d.group.by.length < 4) cc.appendChild(fieldSelect(d, '', function (v) { if (!v) return; d.group.by.push(v); syncGroupColumns(d); changed(); renderMain(); }, { empty: '+ Also count by...', counting: true }));\n var cl = el('input', { className: 'input', value: d.group.countLabel || 'Count', style: 'max-width:260px' });\n cl.addEventListener('input', function () { d.group.countLabel = cl.value || undefined; changed(); });\n cc.appendChild(el('label', { className: 'field', style: 'margin:14px 0 0' }, el('span', { className: 'lbl', text: 'Heading of the count column' }), cl));\n return cc;\n }\n var formats = [['', 'Automatic'], ['text', 'Text'], ['date', 'Date'], ['datetime', 'Date and time'], ['number', 'Number'], ['boolean', 'Yes / No'], ['list', 'List'], ['count', 'How many'], ['json', 'Raw']];\n d.columns = d.columns || [];\n d.columns.forEach(function (col, i) {\n var li = el('input', { className: 'input', value: col.label || '', placeholder: fieldInfo(d, col.field).label });\n li.addEventListener('input', function () { col.label = li.value || undefined; changed(); });\n var fs = el('select', { className: 'input' }, formats.map(function (x) { return el('option', { value: x[0], text: x[1] }); }));\n fs.value = col.format || '';\n fs.addEventListener('change', function () { col.format = fs.value || undefined; changed(); });\n var move = function (delta) {\n var j = i + delta;\n if (j < 0 || j >= d.columns.length) return;\n var t = d.columns[i]; d.columns[i] = d.columns[j]; d.columns[j] = t;\n changed(); renderMain();\n };\n cc.appendChild(el('div', { className: 'colrow' }, el('span', { className: 'n', text: String(i + 1) }),\n fieldSelect(d, col.field, function (v) { col.field = v; var inf = fieldInfo(d, v); col.label = inf.label; col.format = formatFor(inf.type); changed(); renderMain(); }),\n li, fs,\n el('div', { className: 'bar', style: 'gap:2px' },\n el('button', { className: 'btn icon ghost', title: 'Move up', disabled: i === 0, onclick: function () { move(-1); } }, icon('up')),\n el('button', { className: 'btn icon ghost', title: 'Move down', disabled: i === d.columns.length - 1, onclick: function () { move(1); } }, icon('down')),\n el('button', { className: 'btn icon ghost', title: 'Remove', onclick: function () { d.columns.splice(i, 1); changed(); renderMain(); } }, icon('x')))));\n });\n if (!d.columns.length) cc.appendChild(el('div', { className: 'note', text: 'Add at least one column.' }));\n var addSel = fieldSelect(d, '', function (v) {\n if (!v) return;\n var inf = fieldInfo(d, v);\n d.columns.push({ field: v, label: inf.label, format: formatFor(inf.type) });\n changed(); renderMain();\n }, { empty: '+ Add a column...' });\n addSel.style.maxWidth = '420px';\n cc.appendChild(el('div', { style: 'margin-top:10px' }, addSel));\n return cc;\n }\n function syncGroupColumns(d) {\n d.columns = d.group.by.filter(Boolean).map(function (b) { var inf = fieldInfo(d, b); return { field: b, label: inf.label, format: inf.type === 'date' ? 'date' : undefined }; });\n }\n\n function save(msg) {\n var c = state.current;\n var def = clone(c.def);\n if (!c.custom) {\n def.id = def.id + '-copy';\n def.name = def.name + ' (my copy)';\n var n = 2;\n while (state.reports.some(function (r) { return r.definition.id === def.id; })) def.id = c.def.id + '-copy-' + n++;\n }\n def.category = c.custom ? (def.category || 'My reports') : 'My reports';\n msg.textContent = '';\n api('/api/reports', 'POST', { definition: def }).then(function (r) {\n toast('Saved \"' + def.name + '\" to My reports');\n state.dirty = false;\n state.current = null;\n return loadLibrary(r.saved);\n }).catch(function (e) { msg.textContent = ''; msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });\n }\n\n // ---------- yaml ----------\n function renderYaml(w) {\n var c = state.current;\n var ta = el('textarea', { className: 'yaml', spellcheck: 'false' });\n var problems = el('div');\n w.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'The full report definition. Copy it to share the report, or edit it directly and press Apply.' }));\n w.appendChild(ta);\n w.appendChild(problems);\n w.appendChild(el('div', { className: 'bar', style: 'margin-top:12px' },\n el('button', { className: 'btn primary', onclick: function () {\n problems.textContent = '';\n api('/api/parse', 'POST', { yaml: ta.value }).then(function (r) { c.def = r.definition; changed(); c.yaml = ta.value; state.tab = 'design'; toast('Applied'); renderMain(); })\n .catch(function (e) { problems.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, 'Apply'),\n el('button', { className: 'btn', onclick: function () { navigator.clipboard.writeText(ta.value).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')));\n if (c.yaml && !state.dirty) ta.value = c.yaml;\n else api('/api/yaml', 'POST', { definition: c.def }).then(function (r) {\n ta.value = r.yaml;\n if (r.problems.length) problems.appendChild(el('div', { className: 'error', text: 'Fix before running:\\n- ' + r.problems.join('\\n- ') }));\n });\n }\n\n // ---------- instant check ----------\n state.chk = { results: null, meta: null, selected: null, auto: 0, timer: null, busy: null };\n var STATUS = { ok: ['OK', 'ok'], warn: ['Attention', 'warn'], bad: ['Problem', 'bad'], error: ['Could not check', 'err'], off: ['Off', 'off'] };\n function ago(iso) {\n if (!iso) return '';\n var s = Math.round((Date.now() - Date.parse(iso)) / 1000);\n if (s < 60) return 'just now';\n if (s < 3600) return Math.round(s / 60) + ' min ago';\n if (s < 86400) return Math.round(s / 3600) + ' h ago';\n return Math.round(s / 86400) + ' days ago';\n }\n function when(iso) { return iso ? iso.replace('T', ' ').slice(0, 16) : '—'; }\n function sparkline(points, w, h) {\n var NS = 'http://www.w3.org/2000/svg';\n var svg = document.createElementNS(NS, 'svg');\n svg.setAttribute('viewBox', '0 0 ' + w + ' ' + h);\n svg.setAttribute('width', w); svg.setAttribute('height', h);\n svg.setAttribute('class', 'spark');\n var vals = (points || []).filter(function (p) { return p.value !== null && p.value !== undefined; }).slice(-30);\n if (vals.length < 2) return svg;\n var max = Math.max.apply(null, vals.map(function (p) { return p.value; })), min = Math.min.apply(null, vals.map(function (p) { return p.value; }));\n var span = max - min || 1;\n var pts = vals.map(function (p, i) { return (i * (w - 4) / (vals.length - 1) + 2).toFixed(1) + ',' + (h - 3 - ((p.value - min) / span) * (h - 6)).toFixed(1); });\n var line = document.createElementNS(NS, 'polyline');\n line.setAttribute('points', pts.join(' '));\n line.setAttribute('fill', 'none'); line.setAttribute('stroke', 'currentColor'); line.setAttribute('stroke-width', '1.8'); line.setAttribute('stroke-linejoin', 'round');\n svg.appendChild(line);\n var last = pts[pts.length - 1].split(',');\n var dot = document.createElementNS(NS, 'circle');\n dot.setAttribute('cx', last[0]); dot.setAttribute('cy', last[1]); dot.setAttribute('r', '2.6'); dot.setAttribute('fill', 'currentColor');\n svg.appendChild(dot);\n var t = document.createElementNS(NS, 'title');\n t.textContent = vals.length + ' checks, from ' + fmtNum(min) + ' to ' + fmtNum(max);\n svg.appendChild(t);\n return svg;\n }\n function loadCheckMeta() { return api('/api/checks').then(function (m) { state.chk.meta = m; return m; }); }\n function runAllChecks() {\n var c = state.chk;\n if (c.busy) return;\n c.busy = 'Starting the checks...'; c.error = null; renderChecks();\n api('/api/checks/run', 'POST', {}).then(function (r) {\n c.job = r.job;\n pollJob(r.job, function (m) { c.busy = m; var p = $('chk-progress'); if (p) p.textContent = m; },\n function (s) { c.busy = null; c.results = s.extra.results; c.headline = s.extra.headline; c.at = new Date().toISOString(); loadCheckMeta().then(renderChecks, renderChecks); },\n function (e) { c.busy = null; c.error = e; renderChecks(); });\n }).catch(function (e) { c.busy = null; c.error = errorText(e); renderChecks(); });\n }\n function setAuto(min) {\n var c = state.chk;\n c.auto = min;\n if (c.timer) clearInterval(c.timer);\n c.timer = min ? setInterval(function () { if (!$('checks').classList.contains('hidden')) runAllChecks(); }, min * 60000) : null;\n }\n function renderChecks() {\n var c = state.chk;\n var outer = $('checks');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n if (!c.meta) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadCheckMeta().then(renderChecks, function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }\n var autoSel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Refresh the instant check automatically' }, [[0, 'Refresh: off'], [5, 'Every 5 min'], [15, 'Every 15 min'], [30, 'Every 30 min'], [60, 'Every hour']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n autoSel.value = String(c.auto || 0);\n autoSel.addEventListener('change', function () { setAuto(Number(autoSel.value)); });\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:#b91c1c;background:#fdeaea' }, icon('pulse')),\n el('div', { style: 'flex:1' }, el('h2', { text: 'Instant check' }), el('p', { className: 'desc', text: 'Every daily check in one click: provisioning, aggregations, sources, identities, requests, leavers, campaigns. Read-only.' })),\n autoSel,\n el('button', { className: 'btn', onclick: function () { c.showLimits = !c.showLimits; renderChecks(); } }, icon('sliders'), 'Limits'),\n el('button', { className: 'btn primary', disabled: !!c.busy, onclick: runAllChecks }, icon('play'), c.results ? 'Check again' : 'Run all checks')));\n if (c.showLimits) w.appendChild(limitsCard());\n if (c.error) w.appendChild(el('div', { className: 'error', text: c.error }));\n var trends = c.meta.trends || {};\n var results = c.results;\n var bad = 0, warn = 0, err = 0;\n (results || []).forEach(function (r) { if (r.status === 'bad') bad++; else if (r.status === 'warn') warn++; else if (r.status === 'error') err++; });\n if (c.busy) w.appendChild(el('div', { className: 'banner run' }, el('span', { className: 'spinner' }), el('span', { id: 'chk-progress', text: c.busy, style: 'flex:1' }), stopButton()));\n else if (results) {\n var level = bad ? 'bad' : warn || err ? 'warn' : 'ok';\n w.appendChild(el('div', { className: 'banner ' + level },\n el('b', { text: level === 'ok' ? 'All checks OK' : c.headline.charAt(0).toUpperCase() + c.headline.slice(1) }),\n el('span', { text: 'Checked ' + ago(c.at) + (c.auto ? ' · refreshes every ' + c.auto + ' min' : '') }),\n el('span', { style: 'flex:1' }),\n c.job ? el('a', { className: 'btn sm', href: '/api/jobs/' + c.job + '/download?format=xlsx&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Summary in Excel') : null));\n } else {\n var lastAt = null;\n Object.keys(trends).forEach(function (k) { var p = trends[k].points; if (p && p.length && (!lastAt || p[p.length - 1].at > lastAt)) lastAt = p[p.length - 1].at; });\n w.appendChild(el('div', { className: 'banner idle' }, el('b', { text: lastAt ? 'Last checked ' + ago(lastAt) : 'Not checked yet' }), el('span', { text: 'Press \"Run all checks\". A full check takes from a few seconds to a few minutes on large tenants.' })));\n }\n var grid = el('div', { className: 'tiles-chk' });\n var byId = {};\n (results || []).forEach(function (r) { byId[r.id] = r; });\n c.meta.checks.forEach(function (m) {\n var r = byId[m.id];\n var tr = trends[m.id] || {};\n var off = m.optIn ? !(m.settings && m.settings.enabled === true) : (m.settings && m.settings.enabled === false);\n var st = off ? 'off' : r ? r.status : (tr.status || null);\n var stale = !r && st;\n var tile = el('button', { className: 'chk ' + (st ? STATUS[st][1] : 'none') + (c.selected === m.id ? ' sel' : '') + (stale ? ' stale' : ''), onclick: function () { c.selected = c.selected === m.id ? null : m.id; renderChecks(); } });\n tile.appendChild(el('div', { className: 'chk-top' }, el('span', { className: 'chk-dot' }), el('span', { className: 'chk-label', text: m.label }), st ? el('span', { className: 'chk-st', text: STATUS[st][0] + (stale && !off ? ' (last time)' : '') }) : null));\n var value = r ? r.value : (tr.points && tr.points.length ? tr.points[tr.points.length - 1].value : null);\n tile.appendChild(el('div', { className: 'chk-mid' }, el('b', { text: value === null || value === undefined ? '—' : fmtNum(value) }), el('span', { className: 'muted', text: value === 1 ? (m.unit === 'people' ? 'person' : m.unit.replace(/ies$/, 'y').replace(/s$/, '')) : m.unit }),\n el('span', { style: 'flex:1' }), sparkline(tr.points, 92, 30)));\n tile.appendChild(el('div', { className: 'chk-sum', text: off ? (m.optIn && !(m.settings && m.settings.enabled === false) ? 'Needs setting up: save the end-date attribute on Warnings > End dates.' : 'Switched off in Limits.') : r ? r.summary : (tr.summary || m.description) }));\n if (r && r.newCount && !m.growth) tile.appendChild(el('span', { className: 'pill blue', text: r.newCount + ' new' }));\n if (r && r.top && r.top.length) tile.appendChild(el('div', { className: 'chk-top3' }, r.top.map(function (x) { return el('div', {}, el('span', { text: x.label }), el('b', { text: fmtNum(x.count) })); })));\n grid.appendChild(tile);\n });\n w.appendChild(grid);\n if (c.selected) w.appendChild(checkDetail(c.meta.checks.filter(function (m) { return m.id === c.selected; })[0], byId[c.selected], trends[c.selected]));\n }\n function checkDetail(m, r, tr) {\n var card = el('section', { className: 'card', style: 'margin-top:16px' });\n card.appendChild(el('div', { className: 'card-h' }, el('h3', { text: m.label }),\n m.report ? el('button', { className: 'btn sm', onclick: function () {\n var rep = state.reports.filter(function (x) { return x.definition.id === m.report; })[0];\n if (!rep) return;\n showPage('reports'); select(rep);\n if (r && r.params) Object.keys(r.params).forEach(function (k) { state.paramValues[k] = r.params[k]; });\n renderMain();\n } }, icon('file'), 'Open the full report') : null));\n card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: m.description + ' Amber from ' + fmtNum((m.settings.warn || m.defaults.warn)) + ', red from ' + fmtNum((m.settings.bad || m.defaults.bad)) + (m.growth ? ' more than the previous check.' : '.') }));\n var pts = (tr && tr.points) || [];\n if (pts.length >= 2) {\n card.appendChild(el('div', { className: 'trend' }, el('div', { className: 'muted small', text: 'Trend (' + pts.length + ' checks since ' + when(pts[0].at).slice(0, 10) + ')' }), sparkline(pts, 640, 90)));\n }\n var fx = fixCard(m.id);\n if (fx && (!r || r.status !== 'ok')) card.appendChild(fx);\n if (!r) { card.appendChild(el('div', { className: 'muted', text: 'Run the checks to see the details.' })); return card; }\n if (r.newItems && r.newItems.length) card.appendChild(el('div', { className: 'note', text: 'New since the previous check: ' + r.newItems.join('; ') + (r.newCount > r.newItems.length ? ' and ' + (r.newCount - r.newItems.length) + ' more' : '') }));\n if (r.status === 'error') { card.appendChild(el('div', { className: 'error', text: r.error })); return card; }\n if (!r.rows.length) { card.appendChild(el('div', { className: 'empty', text: 'Nothing found. Good.' })); return card; }\n card.appendChild(el('div', { className: 'table-wrap', style: 'max-height:50vh' }, el('table', {},\n el('thead', {}, el('tr', {}, r.columns.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }), m.growth ? null : el('th', { style: 'cursor:default' }, el('span', { className: 'sr-only', text: 'Exception' })))),\n el('tbody', {}, r.rows.map(function (row, i) {\n var key = r.rowKeys && r.rowKeys[i];\n return el('tr', {}, row.map(function (v) { return el('td', { className: typeof v === 'number' ? 'num' : v === null || v === '' ? 'empty-cell' : '', text: v === null || v === '' ? '—' : cellText(v) }); }),\n m.growth ? null : el('td', { style: 'width:1%;white-space:nowrap' }, key ? el('button', { className: 'btn sm', title: 'Accept this item as an exception, with a reason and an end date', 'aria-label': 'Accept ' + key + ' as an exception', onclick: function () { acceptDialog(m, key, runAllChecks); } }, 'Accept…') : null));\n })))));\n if (r.value > r.rows.length) card.appendChild(el('div', { className: 'note', text: 'Showing ' + r.rows.length + ' of ' + fmtNum(r.value) + '. Open the full report for everything.' }));\n if (r.accepted) card.appendChild(el('p', { className: 'muted small' }, fmtNum(r.accepted) + ' accepted as exception' + (r.accepted === 1 ? '' : 's') + ' and left out. ', el('button', { className: 'btn link', style: 'padding:0', text: 'See exceptions', onclick: function () { state.au.tab = 'exceptions'; showPage('certs'); } })));\n return card;\n }\n function limitsCard() {\n var c = state.chk;\n var edits = {};\n var rows = c.meta.checks.map(function (m) {\n var s = m.settings || {};\n var e = edits[m.id] = { enabled: m.optIn ? s.enabled === true : s.enabled !== false, optIn: !!m.optIn, warn: s.warn, bad: s.bad, days: s.days };\n var on = el('input', { type: 'checkbox', checked: e.enabled });\n on.addEventListener('change', function () { e.enabled = on.checked; });\n var num = function (key, ph) {\n var i = el('input', { className: 'input', type: 'number', min: '1', value: e[key] === undefined ? '' : String(e[key]), placeholder: String(ph), style: 'width:110px;padding:5px 8px' });\n i.addEventListener('input', function () { e[key] = i.value === '' ? undefined : Number(i.value); });\n return i;\n };\n return el('tr', {}, el('td', {}, el('label', { className: 'check' }, on, m.label)),\n el('td', {}, num('warn', m.defaults.warn)), el('td', {}, num('bad', m.defaults.bad)),\n el('td', {}, m.defaults.days !== undefined ? num('days', m.defaults.days) : el('span', { className: 'muted', text: '—' })),\n el('td', { className: 'muted small', text: m.growth ? 'limits apply to the increase' : '' }));\n });\n var msg = el('span');\n return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Limits' }), el('span', { className: 'muted small', text: 'empty = default (shown in grey). Also used by scheduled instant checks.' })),\n el('div', { className: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ['Check', 'Amber from', 'Red from', 'Days', ''].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))), el('tbody', {}, rows))),\n el('div', { className: 'bar', style: 'margin-top:12px' }, el('button', { className: 'btn primary', onclick: function () {\n var out = {};\n Object.keys(edits).forEach(function (k) { var e = edits[k]; var o = {}; if (!e.enabled) o.enabled = false; else if (e.optIn) o.enabled = true; ['warn', 'bad', 'days'].forEach(function (x) { if (e[x] !== undefined && !isNaN(e[x])) o[x] = e[x]; }); out[k] = o; });\n msg.textContent = '';\n api('/api/checks/settings', 'PUT', { checks: out }).then(function () { toast('Limits saved'); c.showLimits = false; return loadCheckMeta(); }).then(renderChecks).catch(function (e) { msg.appendChild(el('span', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save limits'), msg));\n }\n\n // ---------- lookup ----------\n state.lk = { tab: 'person', q: '', matches: null, person: null, sources: null, source: null, filter: '' };\n function renderLookup() {\n var L = state.lk;\n var outer = $('lookup');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#2457d6;background:#eaf0fd' }, icon('search')),\n el('div', {}, el('h2', { text: 'Lookup' }), el('p', { className: 'desc', text: 'Everything about one identity or one source on one page. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['person', 'Identity', 'people'], ['source', 'Source', 'db'], ['ownership', 'Ownership', 'layers']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (L.tab === t[0] ? ' active' : ''), onclick: function () { L.tab = t[0]; renderLookup(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (L.tab === 'person') renderPerson(w); else if (L.tab === 'ownership') renderOwnership(w); else renderSourceLookup(w);\n }\n var searchTimer;\n function renderPerson(w) {\n var L = state.lk;\n var input = el('input', { className: 'input', value: L.q, placeholder: 'Name, username or email (at least 2 characters)', style: 'font-size:15px;padding:11px 12px 11px 36px' });\n var list = el('div');\n input.addEventListener('input', function () {\n L.q = input.value;\n clearTimeout(searchTimer);\n searchTimer = setTimeout(function () {\n if (L.q.trim().length < 2) { L.matches = null; drawMatches(); return; }\n list.textContent = ''; list.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Searching...'));\n var asked = L.q;\n api('/api/people?q=' + encodeURIComponent(asked)).then(function (r) { if (asked === L.q) { L.matches = r.people; drawMatches(); } }).catch(function (e) { list.textContent = ''; list.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }, 300);\n });\n function drawMatches() {\n list.textContent = '';\n if (!L.matches) return;\n if (!L.matches.length) { list.appendChild(el('div', { className: 'muted', style: 'padding:10px', text: 'Nobody found.' })); return; }\n list.appendChild(el('div', { className: 'matches' }, L.matches.map(function (m) {\n return el('button', { className: 'match' + (L.person && L.person.id === m.id ? ' sel' : ''), onclick: function () { openPerson(m.id); } },\n el('b', { text: m.name }), el('span', { className: 'muted', text: [m.username, m.email, m.department, m.lifecycleState].filter(Boolean).join(' · ') }));\n })));\n }\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'searchbox' }, icon('search'), input), list));\n drawMatches();\n setTimeout(function () { input.focus(); input.setSelectionRange(input.value.length, input.value.length); }, 0);\n if (L.loading) w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading accounts, access and recent activity...'));\n else if (L.personError) w.appendChild(el('div', { className: 'error', text: L.personError }));\n else if (L.person) w.appendChild(personView(L.person));\n }\n function openPerson(id) {\n var L = state.lk;\n L.loading = true; L.personError = null; renderLookup();\n api('/api/people/' + id).then(function (p) { L.person = p; L.loading = false; L.matches = null; renderLookup(); }).catch(function (e) { L.loading = false; L.personError = errorText(e); renderLookup(); });\n }\n function section(title, count, body) {\n return el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, title, count !== null && count !== undefined ? el('span', { className: 'pill off', text: String(count) }) : null)), body);\n }\n function simpleTable(headers, rows, label) {\n if (!rows.length) return el('div', { className: 'muted', text: 'None.' });\n // Focusable so a long table can be scrolled with the keyboard.\n return el('div', { className: 'table-wrap', style: 'max-height:46vh', tabindex: '0', role: 'region', 'aria-label': label || 'Table: ' + headers.filter(Boolean).join(', ') }, el('table', {},\n el('thead', {}, el('tr', {}, headers.map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, rows.map(function (r) { return el('tr', {}, r.map(function (v) {\n if (v && v.nodeType) return el('td', {}, v);\n return el('td', { className: v === null || v === undefined || v === '' ? 'empty-cell' : '', text: v === null || v === undefined || v === '' ? '—' : String(v) });\n })); }))));\n }\n function yesNo(v, badWhenYes) { return el('span', { className: v ? (badWhenYes ? 'chg lose' : 'yes') : 'no', text: v ? 'Yes' : 'No' }); }\n function personView(p) {\n var box = el('div');\n var lcBad = p.inactive || /inactive|terminat|disabled|leaver/i.test(p.lifecycleState || '');\n box.appendChild(el('section', { className: 'card' },\n el('div', { className: 'bar', style: 'align-items:flex-start' }, el('div', { className: 'avatar', text: (p.name || '?').split(/\\s+/).map(function (x) { return x.charAt(0); }).slice(0, 2).join('').toUpperCase() }),\n el('div', { style: 'flex:1' }, el('h2', { style: 'margin:0;font-size:20px', text: p.name }),\n el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: p.username || '' }), el('span', { text: p.email || 'no email' }), el('span', { text: 'Manager: ' + (p.manager || 'none') }), el('span', { text: 'Profile: ' + (p.identityProfile || '?') }))),\n el('span', { className: 'pill ' + (lcBad ? 'off' : 'on'), text: p.lifecycleState || 'no lifecycle state' }), openInIsc('/ui/a/admin/identities/' + encodeURIComponent(p.id) + '/details/attributes', true)),\n el('div', { className: 'flags' }, p.flags.map(function (f) { return el('div', { className: 'flag ' + f.level, text: f.text }); }))));\n p.notes.forEach(function (n) { box.appendChild(el('div', { className: 'note', text: n })); });\n var byType = {}, srcs = {}, priv = 0, direct = 0;\n p.access.forEach(function (a) { byType[a.type] = (byType[a.type] || 0) + 1; if (a.source) srcs[a.source] = 1; if (a.privileged) priv++; if (a.type === 'ENTITLEMENT' && a.direct) direct++; });\n box.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: String(p.accounts.length) }), el('span', { text: 'accounts' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ROLE || 0) }), el('span', { text: 'roles' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ACCESS_PROFILE || 0) }), el('span', { text: 'access profiles' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(byType.ENTITLEMENT || 0) }), el('span', { text: 'entitlements (' + direct + ' assigned directly)' })),\n el('div', { className: 'bigstat' + (priv ? ' lose' : '') }, el('b', { text: String(priv) }), el('span', { text: 'privileged access items' })),\n el('div', { className: 'bigstat' }, el('b', { text: String(Object.keys(srcs).length) }), el('span', { text: 'sources with access' }))));\n box.appendChild(section('Accounts', p.accounts.length, simpleTable(['Source', 'Account', 'Disabled', 'Locked', 'Privileged', 'Password set'],\n p.accounts.map(function (a) { return [a.source, a.name, yesNo(a.disabled, true), yesNo(a.locked, true), yesNo(a.privileged), (a.passwordLastSet || '').slice(0, 10)]; }))));\n box.appendChild(section('Recent provisioning (30 days)', p.activities.length, simpleTable(['Time', 'Action', 'Sources', 'Status', 'Errors'],\n p.activities.map(function (a) { return [when(a.created), a.action, a.sources, a.status, a.errors.join('; ')]; }))));\n box.appendChild(section('Access', p.access.length, simpleTable(['Type', 'Access', 'Source', 'Privileged', 'Assigned directly'],\n p.access.map(function (a) { return [a.type, a.name, a.source, yesNo(a.privileged), a.type === 'ENTITLEMENT' ? (a.direct ? 'Yes' : 'Through a role or access profile') : 'Yes']; }))));\n box.appendChild(timelineSection(p));\n box.appendChild(section('Access requests', p.requests.length, simpleTable(['Submitted', 'Access', 'Type', 'State'], p.requests.map(function (r) { return [when(r.created), r.name, r.type, r.state]; }))));\n box.appendChild(section('Audit events about this identity (30 days)', p.events.length, simpleTable(['Time', 'Event', 'Status', 'By'], p.events.map(function (e) { return [when(e.created), e.name, e.status, e.actor]; }))));\n box.appendChild(section('Identity attributes', p.attributes.length, simpleTable(['Attribute', 'Value'], p.attributes.map(function (a) { return [a.name, a.value]; }))));\n return box;\n }\n function renderSourceLookup(w) {\n var L = state.lk;\n if (L.source || L.sourceLoading || L.sourceError) {\n w.appendChild(el('button', { className: 'btn ghost', style: 'margin-bottom:10px', onclick: function () { L.source = null; L.sourceError = null; renderLookup(); } }, '← All sources'));\n if (L.sourceLoading) w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading counts, aggregations and errors for this source...'));\n else if (L.sourceError) w.appendChild(el('div', { className: 'error', text: L.sourceError }));\n else w.appendChild(sourceView(L.source));\n return;\n }\n if (!L.sources) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading sources and their recent aggregations...'));\n api('/api/sources').then(function (r) { L.sources = r; renderLookup(); }).catch(function (e) { L.sources = { sources: [], notes: [errorText(e)] }; renderLookup(); });\n return;\n }\n var f = el('input', { className: 'input', placeholder: 'Filter sources...', value: L.filter, style: 'max-width:320px' });\n var tableBox = el('div');\n function draw() {\n var q = L.filter.toLowerCase();\n var list = L.sources.sources.filter(function (s) { return !q || (s.name + ' ' + (s.type || '') + ' ' + (s.owner || '')).toLowerCase().indexOf(q) >= 0; });\n tableBox.textContent = '';\n tableBox.appendChild(simpleTable(['Source', 'Connection', 'Last aggregation', 'Last success', 'Owner', 'Type'], list.map(function (s) {\n var agg = s.lastAggregation ? el('span', {}, el('span', { className: 'chg ' + (s.lastAggregation.status === 'PASSED' ? 'gain' : 'lose'), text: s.lastAggregation.status === 'PASSED' ? 'Passed' : 'Failed' }), ' ' + ago(s.lastAggregation.created)) : el('span', { className: 'muted', text: 'none in 7 days' });\n return [el('button', { className: 'btn link', style: 'padding:0', text: s.name, onclick: function () { openSource(s.id); } }), el('span', { className: 'chg ' + (s.healthy ? 'gain' : 'lose'), text: s.healthy ? 'OK' : (s.status || '').replace('SOURCE_STATE_', '').replace(/_/g, ' ').toLowerCase() }), agg, s.lastSuccess ? ago(s.lastSuccess) : null, s.owner || null, s.type || null];\n })));\n }\n f.addEventListener('input', function () { L.filter = f.value; draw(); });\n var bad = L.sources.sources.filter(function (s) { return !s.healthy; }).length;\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Sources' }), el('span', { className: 'muted small', text: L.sources.sources.length + ' sources, ' + bad + ' with a connection problem' }), f), tableBox));\n L.sources.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n draw();\n }\n function openSource(id) {\n var L = state.lk;\n L.sourceLoading = true; L.sourceError = null; renderLookup();\n api('/api/sources/' + id).then(function (d) { L.source = d; L.sourceLoading = false; renderLookup(); }).catch(function (e) { L.sourceLoading = false; L.sourceError = errorText(e); renderLookup(); });\n }\n function sourceView(d) {\n var s = d.source, box = el('div');\n box.appendChild(el('section', { className: 'card' },\n el('div', { className: 'bar' }, el('h2', { style: 'margin:0;font-size:20px;flex:1', text: s.name }), el('span', { className: 'pill ' + (s.healthy ? 'on' : 'off'), text: s.healthy ? 'Connection OK' : (s.status || '').replace('SOURCE_STATE_', '').replace(/_/g, ' ').toLowerCase() }), openInIsc('/ui/a/admin/connections/sources/' + encodeURIComponent(s.id) + '/menu/base_configuration')),\n el('div', { className: 'kv', style: 'margin-top:6px' }, el('span', { text: s.type || '' }), el('span', { text: 'Owner: ' + (s.owner || 'none') }), el('span', { text: s.authoritative ? 'Authoritative' : 'Not authoritative' }), s.description ? el('span', { text: s.description }) : null)));\n var cnt = d.counts;\n var stat = function (v, label, cls) { return el('div', { className: 'bigstat' + (cls ? ' ' + cls : '') }, el('b', { text: v === null ? '—' : fmtNum(v) }), el('span', { text: label })); };\n box.appendChild(el('div', { className: 'bigstats' }, stat(cnt.accounts, 'accounts'), stat(cnt.uncorrelated, 'not linked to an identity', cnt.uncorrelated ? 'lose' : ''), stat(cnt.entitlements, 'entitlements'), stat(cnt.entitlementsWithoutOwner, 'entitlements without owner', cnt.entitlementsWithoutOwner ? 'lose' : ''),\n el('div', { className: 'bigstat' }, el('b', { text: s.lastSuccess ? ago(s.lastSuccess) : 'none' }), el('span', { text: 'last successful aggregation (30 days)' }))));\n var open = function (id, params) { return el('button', { className: 'btn sm', onclick: function () {\n var rep = state.reports.filter(function (x) { return x.definition.id === id; })[0];\n showPage('reports'); select(rep); Object.keys(params).forEach(function (k) { state.paramValues[k] = params[k]; }); renderMain();\n } }, icon('file'), 'Open report'); };\n box.appendChild(el('div', { className: 'bar', style: 'margin-bottom:16px' }, el('span', { className: 'muted', text: 'Reports for this source:' }),\n el('span', {}, 'Unlinked accounts ', open('uncorrelated-accounts', { sources: [s.id] })), el('span', {}, 'Everyone with an account ', open('application-accounts', { sources: [s.id] })), el('span', {}, 'Entitlements without owner ', open('entitlements-without-owner', { sources: [s.id] }))));\n d.notes.forEach(function (n) { box.appendChild(el('div', { className: 'note', text: n })); });\n if (d.usedBy) box.appendChild(section('Used by', null, el('div', {},\n d.usedBy.identityProfiles.length ? simpleTable(['Identity profile', 'How it uses this source'], d.usedBy.identityProfiles.map(function (x) { return [x.name, x.how]; })) : el('div', { className: 'muted', text: 'No identity profile reads this source.' }),\n el('div', { className: 'kv', style: 'margin-top:10px' }, el('span', {}, el('b', { text: d.usedBy.accessProfiles === null ? '\\u2014' : fmtNum(d.usedBy.accessProfiles) }), ' access profiles on this source'), el('span', {}, el('b', { text: fmtNum(d.usedBy.mappedAttributes) }), ' identity attribute mappings read it')))));\n box.appendChild(diagnosticsCard(s));\n box.appendChild(sourceConfigCard(s.id));\n box.appendChild(section('Provisioning errors by cause (7 days)', d.causes.length, simpleTable(['Cause', 'Errors'], d.causes.map(function (c) { return [c.cause, c.count]; }))));\n box.appendChild(section('Aggregations (30 days)', d.aggregations.length, simpleTable(['Time', 'Event', 'Status', 'Errors'], d.aggregations.map(function (a) { return [when(a.created), a.name, el('span', { className: 'chg ' + (a.status === 'PASSED' ? 'gain' : 'lose'), text: a.status || '?' }), a.errors]; }))));\n box.appendChild(section('Latest provisioning errors (7 days)', d.errors.length, simpleTable(['Time', 'Action', 'For', 'Error'], d.errors.map(function (e) { return [when(e.created), e.action, e.person, e.error]; }))));\n return box;\n }\n\n // ---------- tenant ----------\n state.tn = { tab: 'overview', data: {}, days: 1, filter: '' };\n function renderTenant() {\n var T = state.tn;\n var outer = $('tenant-page');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#e0f4f1' }, icon('db')),\n el('div', {}, el('h2', { text: 'Tenant' }), el('p', { className: 'desc', text: 'The size and health of the setup behind the identities: Virtual Appliances, workflows, transforms and API credentials. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['overview', 'Overview', 'grid'], ['clusters', 'Virtual Appliances', 'db'], ['workflows', 'Workflows', 'lifecycle'], ['transforms', 'Transforms', 'code'], ['credentials', 'API credentials', 'shield'], ['cmap', 'Credential map', 'eye'], ['rules', 'Rule usage', 'code'], ['compare', 'Compare tenants', 'cols']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (T.tab === t[0] ? ' active' : ''), onclick: function () { T.tab = t[0]; renderTenant(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (T.tab === 'compare') { renderCompare2(w); return; }\n if (T.tab === 'credentials') { renderCredentials(w); return; }\n // One home for each: runs and failures, where transforms are used, where credentials are used.\n if (T.tab === 'workflows') { renderWorkflowHealth(w); return; }\n if (T.tab === 'transforms') { renderImpactMap(w); return; }\n if (T.tab === 'cmap') { renderCredentialMap(w); return; }\n if (T.tab === 'rules') { renderRuleUsage(w); return; }\n var key = T.tab;\n var d = T.data[key];\n var reload = el('button', { className: 'btn sm', onclick: function () { delete T.data[key]; renderTenant(); } }, icon('lifecycle'), 'Reload');\n if (!d) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading from your tenant...'));\n T.data[key] = { loading: true };\n api('/api/tenant/' + T.tab).then(function (r) { T.data[key] = r; }, function (e) { T.data[key] = { error: errorText(e) }; }).then(function () { if (!$('tenant-page').classList.contains('hidden')) renderTenant(); });\n return;\n }\n if (d.loading) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Reading from your tenant...')); return; }\n if (d.error) { w.appendChild(el('div', { className: 'error', text: d.error })); w.appendChild(reload); return; }\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n if (T.tab === 'overview') {\n w.appendChild(el('div', { className: 'bigstats' }, d.counts.map(function (c) { return el('div', { className: 'bigstat' }, el('b', { text: c.count === null ? '—' : fmtNum(c.count) }), el('span', { text: c.label })); })));\n w.appendChild(el('div', { className: 'bar' }, reload, el('span', { className: 'muted small', text: 'A dash means the current sign-in or token cannot read that number.' })));\n var gl = el('div', { style: 'margin-top:18px' });\n w.appendChild(gl);\n glance(gl);\n } else if (T.tab === 'clusters') {\n var bad = d.clusters.filter(function (c) { return !c.healthy; }).length;\n w.appendChild(el('div', { className: 'banner ' + (bad ? 'bad' : 'ok') }, el('b', { text: bad ? bad + ' cluster' + (bad > 1 ? 's' : '') + ' need attention' : 'All clusters normal' }), el('span', { text: d.clusters.length + ' clusters' }), el('span', { style: 'flex:1' }), reload));\n d.clusters.forEach(function (c) {\n w.appendChild(section(c.name, c.clients.length, el('div', {},\n el('div', { className: 'kv', style: 'margin-bottom:10px' }, el('span', {}, el('span', { className: 'chg ' + (c.healthy ? 'gain' : 'lose'), text: c.status || (c.healthy ? 'NORMAL' : '?') })), c.type ? el('span', { text: 'Type: ' + c.type }) : null, c.alert ? el('span', { text: 'Alert: ' + c.alert }) : null, c.operational === false ? el('span', { text: 'Not operational' }) : null),\n simpleTable(['Appliance', 'Status', 'Last seen', 'Version', 'IP address'], c.clients.map(function (v) {\n return [v.name, el('span', { className: 'chg ' + (v.healthy ? 'gain' : 'lose'), text: v.status || '?' }), v.sinceLastSeen ? v.sinceLastSeen + ' ago' : when(v.lastSeen), v.version, v.ip];\n }), 'Appliances in ' + c.name))));\n });\n }\n }\n\n\n // ---------- API credentials ----------\n state.cr = { expiringDays: 30, unusedDays: 90, only: 'attention', q: '' };\n function credFlagClass(f) { return /^Expired|^Owner|^Expires (today|in [0-9] )/.test(f) ? 'lose' : /^Expires|^Never expires|^Not used|^Never used|^Can change|^All of/.test(f) ? 'off' : 'keep-other'; }\n function renderCredentials(w) {\n var C = state.cr;\n var exp = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Expiring within' }, [7, 14, 30, 60, 90].map(function (n) { return el('option', { value: String(n), text: 'Expiring within ' + n + ' days' }); }));\n exp.value = String(C.expiringDays);\n exp.addEventListener('change', function () { C.expiringDays = Number(exp.value); });\n var un = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Unused for' }, [30, 60, 90, 180, 365].map(function (n) { return el('option', { value: String(n), text: 'Unused for ' + n + '+ days' }); }));\n un.value = String(C.unusedDays);\n un.addEventListener('change', function () { C.unusedDays = Number(un.value); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Personal access tokens and API clients: when they expire, when they were last used, whether their owner is still here, and how much they can do. Secrets are never read.' }), exp, un,\n el('button', { className: 'btn primary', disabled: !!C.busy, onclick: function () { runJobInto(C, '/api/credentials/run', { expiringDays: C.expiringDays, unusedDays: C.unusedDays }, renderTenant); } }, icon('play'), C.data ? 'Read again' : 'Read credentials')));\n if (C.busy) { w.appendChild(busyBox(C.busy)); return; }\n if (C.error) { w.appendChild(el('div', { className: 'error', text: C.error })); return; }\n var d = C.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n if (d.thisConnection) {\n var dd = d.thisConnection.daysToExpiry;\n w.appendChild(el('div', { className: 'banner ' + (dd !== null && dd <= 14 ? 'bad' : 'ok') }, el('b', { text: 'The token IdentityScope uses (' + d.thisConnection.name + ')' }),\n el('span', { text: d.thisConnection.expires === null ? 'never expires' : dd < 0 ? 'expired ' + (-dd) + ' days ago' : 'expires ' + d.thisConnection.expires.slice(0, 10) + ' (in ' + dd + ' day' + (dd === 1 ? '' : 's') + ')' })));\n }\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.tokens) }), el('span', { text: 'personal access tokens' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.clients) }), el('span', { text: 'API clients' })),\n el('div', { className: 'bigstat' + (T.expiringSoon ? ' lose' : '') }, el('b', { text: fmtNum(T.expiringSoon) }), el('span', { text: 'expire within ' + d.expiringDays + ' days' })),\n el('div', { className: 'bigstat' + (T.ownerLeft ? ' lose' : '') }, el('b', { text: fmtNum(T.ownerLeft) }), el('span', { text: 'active, owner has left' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.neverExpire) }), el('span', { text: 'tokens that never expire' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.unused) }), el('span', { text: 'unused ' + d.unusedDays + '+ days' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.expired) }), el('span', { text: 'already expired' }))));\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['attention', 'Needing attention'], ['all', 'All'], ['tokens', 'Personal access tokens'], ['clients', 'API clients']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = C.only;\n var f = el('input', { className: 'input', placeholder: 'Filter by name or owner...', value: C.q, style: 'max-width:260px', 'aria-label': 'Filter by name or owner' });\n var box = el('div');\n var draw = function () {\n var q = C.q.toLowerCase();\n var list = d.credentials.filter(function (c) {\n if (C.only === 'attention' && !c.flags.length) return false;\n if (C.only === 'tokens' && c.kind !== 'Personal access token') return false;\n if (C.only === 'clients' && c.kind !== 'API client') return false;\n return !q || (c.name + ' ' + (c.owner || '')).toLowerCase().indexOf(q) >= 0;\n });\n box.textContent = '';\n box.appendChild(list.length ? simpleTable(['Type', 'Name', 'Owner', 'Expires', 'Last used', 'Scopes', 'Needs attention'], list.map(function (c) {\n return [c.kind === 'API client' ? 'API client' : 'Token',\n el('span', {}, c.name, c.thisConnection ? el('span', { className: 'chg gain', style: 'margin-left:6px', text: 'used by IdentityScope' }) : null, c.managed ? el('span', { className: 'chg keep-other', style: 'margin-left:6px', text: 'managed by SailPoint' }) : null),\n c.owner ? c.owner + (c.ownerStatus && c.ownerStatus !== 'active' ? ' (' + c.ownerStatus + ')' : '') : null,\n el('span', { style: 'white-space:nowrap', text: c.kind === 'API client' ? 'does not expire' : c.expires === null ? 'never' : c.expires.slice(0, 10) }),\n el('span', { style: 'white-space:nowrap', text: c.lastUsed ? c.lastUsed.slice(0, 10) : 'never' }),\n el('span', { className: 'small', text: c.scopes.length ? c.scopes.join(' ') : 'all of the owner\\u2019s rights' }),\n el('span', {}, c.flags.map(function (x) { return el('span', { className: 'chg ' + credFlagClass(x), style: 'margin:0 4px 2px 0;display:inline-block', text: x }); }))];\n })) : el('p', { className: 'muted', text: C.only === 'attention' ? 'Nothing needs attention.' : 'None.' }));\n };\n only.addEventListener('change', function () { C.only = only.value; draw(); });\n f.addEventListener('input', function () { C.q = f.value; draw(); });\n w.appendChild(section('Credentials', d.credentials.length, el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, only, f, el('span', { style: 'flex:1' }), downloads(C.job)), box)));\n draw();\n w.appendChild(el('p', { className: 'muted small', text: 'API clients have no expiry date in ISC; their secret can be rotated. \"Last used\" is updated by SailPoint about once a day. Tokens managed by SailPoint (for example for workflows) are not flagged for never expiring.' }));\n }\n // ---------- source configuration and diagnostics (used by the source page) ----------\n function openInIsc(path, unverified) {\n if (!state.consoleUrl) return null;\n return el('a', { className: 'btn sm', href: state.consoleUrl + path, target: '_blank', rel: 'noopener', title: unverified ? 'Opens the ISC admin console. If the page is not found, tell us the right address.' : 'Opens the ISC admin console' }, icon('eye'), 'Open in ISC');\n }\n function sourceConfigCard(id) {\n var pre = el('pre', { className: 'json' });\n var det = el('details', { className: 'adv' }, el('summary', { text: 'Configuration (secrets hidden)' }), el('div', { className: 'bar', style: 'margin:10px 0' },\n el('button', { className: 'btn sm', onclick: function () { navigator.clipboard.writeText(pre.textContent).then(function () { toast('Copied'); }); } }, icon('copy'), 'Copy')), pre);\n det.addEventListener('toggle', function () {\n if (!det.open || pre.textContent) return;\n pre.textContent = 'Loading...';\n api('/api/sources/' + id + '/config').then(function (r) { pre.textContent = JSON.stringify(r.config, null, 2); }).catch(function (e) { pre.textContent = errorText(e); });\n });\n return el('section', { className: 'card' }, det);\n }\n function diagnosticsCard(s) {\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, icon('pulse'), 'Connector diagnostics'), el('span', { className: 'pill ' + (state.diagnostics ? 'on' : 'off'), text: state.diagnostics ? 'on' : 'off' })));\n if (!state.diagnostics) {\n card.appendChild(el('p', { className: 'muted', style: 'margin-top:0', text: 'Test connection, ping cluster and peek change nothing in ISC or in the application, but they make the Virtual Appliance contact the application, and peek shows live data from it. They are off unless you turn them on. Every use is written to logs/diagnostics.log.' }));\n card.appendChild(el('button', { className: 'btn', onclick: function () {\n if (!confirm('Turn on connector diagnostics on this computer? Each action still asks before it runs.')) return;\n api('/api/settings/diagnostics', 'PUT', { enabled: true }).then(function (r) { state.diagnostics = r.diagnostics; renderLookup(); });\n } }, 'Turn on diagnostics'));\n return card;\n }\n var out = el('div', { style: 'margin-top:12px' });\n var run = function (action, extra) {\n var label = { test: 'Test the connection to', ping: 'Ping the VA cluster of', peek: 'Read live objects from' }[action];\n if (!confirm(label + ' \"' + s.name + '\"?')) return;\n out.textContent = '';\n out.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Waiting for the Virtual Appliance...'));\n api('/api/sources/' + s.id + '/diagnostics', 'POST', Object.assign({ action: action, confirm: true }, extra || {})).then(function (r) {\n out.textContent = '';\n var res = r.result || {};\n if (action === 'peek') {\n var objs = res.resourceObjects || [];\n out.appendChild(el('div', { className: 'muted small', text: objs.length + ' object(s) in ' + (res.elapsedMillis || '?') + ' ms. Shown here only, not saved.' }));\n objs.forEach(function (o) {\n var attrs = o.attributes || {};\n out.appendChild(el('details', { className: 'adv', style: 'margin-top:8px' }, el('summary', { text: (o.name || o.identity || '?') + (o.identity && o.identity !== o.name ? ' (' + o.identity + ')' : '') }),\n simpleTable(['Attribute', 'Value'], Object.keys(attrs).sort().map(function (k) { var v = attrs[k]; return [k, typeof v === 'object' ? JSON.stringify(v) : String(v)]; }))));\n });\n } else {\n var good = /success/i.test(res.status || '');\n out.appendChild(el('div', { className: good ? 'success' : 'error', text: (good ? 'Succeeded' : 'Result: ' + (res.status || 'unknown')) + (res.elapsedMillis ? ' in ' + res.elapsedMillis + ' ms' : '') + '.' }));\n if (res.details && Object.keys(res.details).length) out.appendChild(el('pre', { className: 'json', text: JSON.stringify(res.details, null, 2) }));\n }\n }).catch(function (e) { out.textContent = ''; out.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n };\n var objType = el('select', { className: 'input', style: 'width:auto' }, el('option', { value: 'account', text: 'accounts' }), el('option', { value: 'group', text: 'groups' }));\n var count = el('select', { className: 'input', style: 'width:auto' }, [5, 10, 25].map(function (n) { return el('option', { value: String(n), text: String(n) }); }));\n count.value = '10';\n card.appendChild(el('div', { className: 'bar' },\n el('button', { className: 'btn', onclick: function () { run('test'); } }, 'Test connection'),\n el('button', { className: 'btn', onclick: function () { run('ping'); } }, 'Ping VA cluster'),\n el('span', { className: 'muted', style: 'margin-left:10px', text: 'Peek' }), count, objType,\n el('button', { className: 'btn', onclick: function () { run('peek', { objectType: objType.value, maxCount: Number(count.value) }); } }, 'Peek live objects'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn ghost sm', onclick: function () { api('/api/settings/diagnostics', 'PUT', { enabled: false }).then(function (r) { state.diagnostics = r.diagnostics; renderLookup(); }); } }, 'Turn off')));\n card.appendChild(out);\n return card;\n }\n\n // ---------- certifications ----------\n state.ct = { days: 90, items: true };\n function runJobInto(holder, path, body, rerender) {\n holder.busy = 'Starting...'; holder.error = null; holder.data = null; rerender();\n api(path, 'POST', body || {}).then(function (r) {\n holder.job = r.job;\n pollJob(r.job, function (m) { holder.busy = m; var p = document.querySelector('[data-progress]'); if (p) p.textContent = m; },\n function (s) {\n holder.busy = null; holder.data = s.extra;\n // Anything ISC cut short is shown as a note on the result.\n if (s.warnings && s.warnings.length && holder.data && typeof holder.data === 'object') holder.data.notes = (holder.data.notes || []).concat(s.warnings);\n rerender();\n },\n function (e) { holder.busy = null; holder.error = e; rerender(); });\n }).catch(function (e) { holder.busy = null; holder.error = errorText(e); rerender(); });\n }\n function stopButton() {\n var b = el('button', { className: 'btn sm ghost', title: 'Stop this job. Nothing is changed in ISC; a partly done check is not saved.', onclick: function () {\n if (!state.activeJob) return;\n b.disabled = true; b.textContent = 'Stopping...';\n api('/api/jobs/' + state.activeJob + '/stop', 'POST', {}).catch(function (e) { toast(errorText(e)); });\n } }, icon('x'), 'Stop');\n return b;\n }\n function busyBox(text) { return el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0', role: 'status', 'aria-live': 'polite' }, el('span', { className: 'spinner' }), el('span', { 'data-progress': '1', text: text, style: 'flex:1' }), stopButton())); }\n function pageHead(w, iconName, color, bg, title, desc, right) {\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:16px;align-items:center' }, el('span', { className: 'cat-ico', style: 'color:' + color + ';background:' + bg }, icon(iconName)),\n el('div', { style: 'flex:1' }, el('h2', { text: title }), el('p', { className: 'desc', text: desc })), right || null));\n }\n function progressBar(pct, warn) {\n return el('div', { style: 'display:flex;align-items:center;gap:8px;min-width:140px' }, el('div', { className: 'meter', style: 'flex:1;margin:0' }, el('span', { style: 'width:' + Math.min(100, pct) + '%;' + (warn ? 'background:linear-gradient(90deg,#f59e0b,#d97706)' : '') })), el('span', { className: 'small', text: pct + '%' }));\n }\n function renderCerts() { renderAudit(); }\n function certsTab(w) {\n var C = state.ct;\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(C.days);\n period.addEventListener('change', function () { C.days = Number(period.value); });\n var items = el('input', { type: 'checkbox', checked: C.items });\n items.addEventListener('change', function () { C.items = items.checked; });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Campaign progress, reviewers who are behind, and reviews that look rubber-stamped.' }), period, el('label', { className: 'check', title: 'Reads every review item: slower on big campaigns' }, items, 'Approve/revoke counts'),\n el('button', { className: 'btn primary', disabled: !!C.busy, onclick: function () { runJobInto(C, '/api/certifications/run', { days: C.days, items: C.items }, renderCerts); } }, icon('play'), C.data ? 'Read again' : 'Read certifications')));\n if (C.busy) { w.appendChild(busyBox(C.busy)); return; }\n if (C.error) { w.appendChild(el('div', { className: 'error', text: C.error })); return; }\n var d = C.data;\n if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Are reviews on track?' }), 'Reads campaigns, every reviewer’s progress and their decisions. A certification admin’s token or sign-in sees all reviewers.')); return; }\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.active) }), el('span', { text: 'active campaigns' })),\n el('div', { className: 'bigstat' + (T.overdue ? ' lose' : '') }, el('b', { text: fmtNum(T.overdue) }), el('span', { text: 'past the deadline' })),\n el('div', { className: 'bigstat' + (T.atRisk ? ' lose' : '') }, el('b', { text: fmtNum(T.atRisk) }), el('span', { text: 'due within 7 days, under 80%' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.openDecisions) }), el('span', { text: 'decisions still open' })),\n el('div', { className: 'bigstat' }, el('b', { text: T.approvedInPeriod + T.revokedInPeriod ? Math.round(T.revokedInPeriod * 100 / (T.approvedInPeriod + T.revokedInPeriod)) + '%' : '—' }), el('span', { text: 'of decisions were revokes' }))));\n w.appendChild(section('Campaigns', d.campaigns.length, simpleTable(['Campaign', 'Type', 'Status', 'Deadline', 'Progress', ''], d.campaigns.map(function (c) {\n var flag = c.overdue ? el('span', { className: 'chg lose', text: 'Overdue' }) : c.atRisk ? el('span', { className: 'chg lose', text: 'At risk' }) : null;\n return [c.name, c.type, c.status, c.deadline ? c.deadline.slice(0, 10) + (c.status === 'ACTIVE' && c.daysLeft !== null ? ' (' + (c.daysLeft >= 0 ? c.daysLeft + ' days left' : -c.daysLeft + ' days late') + ')' : '') : null, progressBar(c.percent, c.overdue || c.atRisk), flag];\n }))));\n w.appendChild(section('Reviewers', d.reviewers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, el('button', { className: 'btn sm', onclick: function () { wnState().tab = 'reminders'; showPage('warnings'); } }, icon('clock'), 'Remind reviewers before the deadline'), downloads(C.job)),\n simpleTable(['Reviewer', 'Campaigns', 'Reviews', 'Decisions', 'Approved', 'Revoked', 'Approve %', 'Overdue reviews'], d.reviewers.map(function (r) {\n var pct = r.decisionsTotal ? Math.round(r.decisionsMade * 100 / r.decisionsTotal) : 0;\n return [r.name, r.campaigns.join(', '), r.certifications, r.decisionsTotal ? progressBar(pct, r.overdueOpen > 0) : null, r.approved, r.revoked, r.approveRate === null ? null : r.approveRate + '%', r.overdueOpen ? el('span', { className: 'chg lose', text: String(r.overdueOpen) }) : 0];\n })))));\n w.appendChild(section('Reviews that may be rubber-stamped', d.flags.length, d.flags.length ? el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'Everything approved and signed off very fast, or a large review with not a single revoke. A signal worth a conversation, not proof.' }),\n simpleTable(['Reviewer', 'Campaign', 'Review', 'Decisions', 'Why it stands out'], d.flags.map(function (f) { return [f.reviewer, f.campaign, f.certification, f.decisions, f.reason]; }))) : el('div', { className: 'muted', text: 'None found.' })));\n }\n\n // ---------- monthly report ----------\n state.mr = { month: '' };\n function renderMonthly() { renderInsights(); }\n function monthlyTab(w) {\n var M = state.mr;\n if (!M.data) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Building the report...'));\n api('/api/monthly' + (M.month ? '?month=' + M.month : '')).then(function (d) { M.data = d; M.month = d.month; renderMonthly(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n return;\n }\n var d = M.data;\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Month' }, (d.months.length ? d.months : [d.month]).map(function (m) { return el('option', { value: m, text: m }); }));\n sel.value = d.month;\n sel.addEventListener('change', function () { M.month = sel.value; M.data = null; renderMonthly(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { style: 'flex:1' }, el('b', { text: 'Monthly report: ' + d.monthLabel }), el('span', { className: 'muted', text: ' — from the instant checks recorded on this computer. Lower is better for every check.' })), sel, el('a', { className: 'btn primary', href: '/api/monthly/download?month=' + d.month + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download (open and print to PDF)')));\n w.appendChild(section('Highlights', null, el('ul', { style: 'margin:0;padding-left:20px' }, d.highlights.map(function (h) { return el('li', { style: 'margin:4px 0', text: h }); }))));\n w.appendChild(section('Daily checks during the month', null, simpleTable(['Check', 'First day', 'Last day', 'Change', 'Days checked', 'Days red / amber', 'Trend'], d.checks.map(function (c) {\n var ch = c.change === null ? null : el('span', { style: 'font-weight:600;color:' + (c.change < 0 ? 'var(--ok)' : c.change > 0 ? 'var(--danger)' : 'var(--text2)'), text: c.change === 0 ? 'no change' : (c.change > 0 ? '+' : '−') + fmtNum(Math.abs(c.change)) + (c.changePercent !== null ? ' (' + (c.changePercent > 0 ? '+' : '') + c.changePercent + '%)' : '') });\n var sp = el('span', { style: 'color:var(--accent)' }, sparkline(c.days.map(function (x) { return { value: x.value }; }), 140, 30));\n return [c.label, c.start === null ? null : fmtNum(c.start), c.end === null ? null : fmtNum(c.end), ch, c.daysChecked, c.daysRed + ' / ' + c.daysAmber, sp];\n }))));\n if (d.snapshot) w.appendChild(section('The tenant today', null, el('div', { className: 'bigstats', style: 'margin:0' }, d.snapshot.map(function (s) { return el('div', { className: 'bigstat' }, el('b', { text: s.count === null ? '—' : fmtNum(s.count) }), el('span', { text: s.label })); }))));\n }\n\n // ---------- ownership (a Lookup tab) ----------\n state.ow = { filter: '', owner: null };\n function renderOwnership(w) {\n var O = state.ow;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'Who owns sources, roles, access profiles, entitlements, workflows and identity profiles, and what is owned by identities who left. Reads every entitlement, so it takes a while on big tenants.' }),\n el('button', { className: 'btn primary', disabled: !!O.busy, onclick: function () { runJobInto(O, '/api/ownership/run', {}, renderLookup); } }, icon('play'), O.data ? 'Read again' : 'Read ownership')));\n if (O.busy) { w.appendChild(busyBox(O.busy)); return; }\n if (O.error) { w.appendChild(el('div', { className: 'error', text: O.error })); return; }\n var d = O.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var types = ['Source', 'Role', 'Access profile', 'Entitlement', 'Workflow', 'Identity profile'];\n w.appendChild(el('div', { className: 'bigstats' }, types.map(function (ty) {\n var total = d.totals[ty] || 0, un = d.unowned[ty] || 0;\n return el('div', { className: 'bigstat' + (un ? ' lose' : '') }, el('b', { text: fmtNum(un) }), el('span', { text: ty.toLowerCase() + 's without owner (of ' + fmtNum(total) + ')' }));\n })));\n var ownerWord = function (st) { return st === 'not found' ? 'no longer in ISC' : st; };\n var left = d.owners.filter(function (o) { return o.status !== 'active'; });\n w.appendChild(el('div', { className: 'banner ' + (d.orphaned.length ? 'bad' : 'ok') }, el('b', { text: d.orphaned.length ? fmtNum(d.orphaned.length) + ' objects are owned by ' + left.length + ' identities who left or no longer exist' : 'Every owner is an active identity' }), el('span', { style: 'flex:1' }), downloads(O.job)));\n if (d.orphaned.length) w.appendChild(section('Owned by identities who left (hand these over)', d.orphaned.length, simpleTable(['Type', 'Object', 'Source', 'Owner', 'Owner status'], d.orphaned.slice(0, 1000).map(function (x) { return [x.type, x.name, x.source, x.ownerName, el('span', { className: 'chg lose', text: ownerWord(x.ownerStatus) + (x.lifecycleState ? ' (' + x.lifecycleState + ')' : '') })]; }))));\n var f = el('input', { className: 'input', placeholder: 'Filter owners...', value: O.filter, style: 'max-width:280px' });\n var box = el('div');\n var draw = function () {\n var q = O.filter.toLowerCase();\n box.textContent = '';\n box.appendChild(simpleTable(['Owner', 'Status', 'Sources', 'Roles', 'Access profiles', 'Entitlements', 'Workflows', 'Identity profiles', 'Total'], d.owners.filter(function (o) { return !q || (o.name + ' ' + (o.email || '')).toLowerCase().indexOf(q) >= 0; }).slice(0, 500).map(function (o) {\n return [el('button', { className: 'btn link', style: 'padding:0', text: o.name, onclick: function () { O.owner = o.id; renderLookup(); } }), el('span', { className: 'chg ' + (o.status === 'active' ? 'gain' : 'lose'), text: ownerWord(o.status) }), o.counts['Source'] || 0, o.counts['Role'] || 0, o.counts['Access profile'] || 0, o.counts['Entitlement'] || 0, o.counts['Workflow'] || 0, o.counts['Identity profile'] || 0, o.total];\n })));\n };\n f.addEventListener('input', function () { O.filter = f.value; draw(); });\n w.appendChild(section('Owners', d.owners.length, el('div', {}, el('div', { style: 'margin-bottom:10px' }, f), box)));\n draw();\n if (O.owner) {\n var who = d.owners.filter(function (o) { return o.id === O.owner; })[0];\n var mine = d.objects.filter(function (x) { return x.ownerId === O.owner; });\n w.appendChild(section('Owned by ' + (who ? who.name : '?'), mine.length, simpleTable(['Type', 'Object', 'Source'], mine.slice(0, 2000).map(function (x) { return [x.type, x.name, x.source]; }))));\n }\n }\n\n // ---------- compare tenants (a Tenant tab) ----------\n state.cp = { kinds: null };\n function cmpKey(path) { return String(path).replace(/ \\(.*$/, '').replace(/\\[\\d+\\]/g, '[]'); }\n function cmpIgnore(P, kind, setting, on) {\n api('/api/compare/ignore', 'POST', { kind: kind, setting: setting, ignore: on }).then(function (r) {\n P.info.ignore = r.ignore;\n if (on && P.data) {\n // Apply now to what is on screen; the next Compare applies it to the results and the exports.\n P.data.kinds.forEach(function (k) {\n if (k.kind !== kind) return;\n var keep = [];\n k.different.forEach(function (x) { var left = x.differences.filter(function (y) { return cmpKey(y.path) !== setting; }); if (left.length) keep.push({ name: x.name, differences: left }); else k.same++; });\n k.different = keep;\n });\n }\n renderTenant();\n }, function (e) { toast(errorText(e)); });\n }\n function renderCompare2(w) {\n var P = state.cp;\n if (!P.info) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/compare').then(function (r) { P.info = r; if (!P.kinds) P.kinds = r.kinds.map(function (k) { return k.kind; }); renderTenant(); });\n return;\n }\n if (!P.info.other) {\n var base = el('input', { className: 'input', placeholder: 'production tenant, e.g. acme or https://acme.api.identitynow.com', autocomplete: 'off' });\n var cid = el('input', { className: 'input', autocomplete: 'off' });\n var sec = el('input', { className: 'input', type: 'password', autocomplete: 'off' });\n var msg = el('div');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Connect the other tenant' })),\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Compares ' + (P.info.tenant || 'this tenant') + ' with another tenant (for example sandbox with production) by object name. Read-only on both. The other tenant’s token is kept in memory only, never saved.' }),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Other tenant' }), base), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID (personal access token)' }), cid), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client secret' }), sec)),\n el('button', { className: 'btn primary', style: 'margin-top:14px', onclick: function () {\n msg.textContent = '';\n api('/api/compare/connect', 'POST', { baseUrl: base.value, clientId: cid.value, clientSecret: sec.value }).then(function (r) { sec.value = ''; P.info.other = r.tenant; renderTenant(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, 'Connect'), msg));\n return;\n }\n var boxes = el('div', { className: 'bar' }, P.info.kinds.map(function (k) {\n var c = el('input', { type: 'checkbox', checked: P.kinds.indexOf(k.kind) >= 0, 'aria-label': k.label });\n c.addEventListener('change', function () { P.kinds = P.kinds.filter(function (x) { return x !== k.kind; }); if (c.checked) P.kinds.push(k.kind); renderTenant(); });\n return el('label', { className: 'check' }, c, k.label);\n }));\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', {}, 'Compare ', el('span', { className: 'pill blue', text: P.info.tenant }), ' with ', el('span', { className: 'pill blue', text: P.info.other })),\n el('button', { className: 'btn ghost sm', onclick: function () { api('/api/compare/disconnect', 'POST', {}).then(function () { P.info.other = null; P.data = null; renderTenant(); }); } }, 'Disconnect other tenant')),\n boxes,\n el('p', { className: 'muted small', text: '\"Where rules are used\" compares which sources, transforms, identity profiles, identity attributes and provisioning policies use each rule: a rule used in one tenant and not the other is a deployment gap. Connector rules are compared in full, code included.' }),\n (function () {\n var c = el('input', { type: 'checkbox', checked: !!P.cloudRuleCode, 'aria-describedby': 'cloud-rule-note' });\n c.addEventListener('change', function () { P.cloudRuleCode = c.checked; renderTenant(); });\n return el('div', { className: 'note', style: 'margin-top:10px' },\n el('label', { className: 'check', style: 'font-weight:600' }, c, 'Also compare cloud rule code'),\n el('div', { id: 'cloud-rule-note', className: 'small', style: 'margin-top:4px', text: 'ISC has no plain read for cloud rules. With this on, IdentityScope starts one SP-Config export job of rules in each tenant, waits for it and compares the code. The export reads configuration and changes nothing, but it is a job you will see in the tenant, and the API client needs SP-Config access (the sp:config:read or sp:config:manage scope). Off by default; not used by change history or the drift check.' }));\n })(),\n el('div', { className: 'bar', style: 'margin-top:12px' },\n el('button', { className: 'btn primary', disabled: !!P.busy || (!P.kinds.length && !P.cloudRuleCode), onclick: function () { runJobInto(P, '/api/compare/run', { kinds: P.kinds, cloudRuleCode: !!P.cloudRuleCode }, renderTenant); } }, icon('cols'), 'Compare'),\n el('button', { className: 'btn ghost sm', onclick: function () { P.kinds = P.info.kinds.map(function (k) { return k.kind; }); renderTenant(); } }, 'All'),\n el('button', { className: 'btn ghost sm', onclick: function () { P.kinds = []; renderTenant(); } }, 'None'))));\n if (P.busy) { w.appendChild(busyBox(P.busy)); return; }\n if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }\n var d = P.data;\n if (!d) return;\n w.appendChild(el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:10px' }, downloads(P.job)));\n w.appendChild(simpleTable(['Type', 'Only in ' + d.a, 'Only in ' + d.b, 'Different', 'Same'], d.kinds.map(function (k) {\n return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : k.onlyA.length, k.error ? null : k.onlyB.length, k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];\n })));\n var ignored = (P.info && P.info.ignore) || [];\n if (ignored.length) {\n w.appendChild(el('div', { className: 'note', style: 'margin:12px 0' }, el('b', { text: 'Ignored settings: ' }),\n el('span', {}, ignored.map(function (key) {\n var parts = key.split('|'), label = (P.info.kinds.filter(function (k) { return k.kind === parts[0]; })[0] || { label: parts[0] }).label;\n return el('span', { className: 'chip', style: 'display:inline-flex;gap:6px;align-items:center;margin:2px 6px 2px 0' }, label + ': ', el('code', { text: parts.slice(1).join('|') }),\n el('button', { className: 'linkbtn small', 'aria-label': 'Stop ignoring ' + parts.slice(1).join('|'), onclick: function () { cmpIgnore(P, parts[0], parts.slice(1).join('|'), false); } }, 'undo'));\n })),\n el('div', { className: 'small muted', text: 'Undo takes effect at the next Compare.' })));\n }\n d.kinds.forEach(function (k) {\n if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;\n var body = el('div');\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Only in ' + d.a + ': ' }), k.onlyA.join(', ')));\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Only in ' + d.b + ': ' }), k.onlyB.join(', ')));\n if (k.different.length > 1) {\n // Which settings differ most often: usually tenant-specific values (cluster, owner) worth ignoring.\n var counts = {};\n k.different.forEach(function (x) { var seen = {}; x.differences.forEach(function (y) { var key = cmpKey(y.path); if (!seen[key]) { seen[key] = 1; counts[key] = (counts[key] || 0) + 1; } }); });\n var top = Object.keys(counts).sort(function (a, b) { return counts[b] - counts[a]; }).slice(0, 8);\n body.appendChild(el('div', { className: 'note', style: 'margin:8px 0' }, el('b', { text: 'Most common differences: ' }),\n el('div', {}, top.map(function (key) {\n return el('div', { style: 'display:flex;gap:10px;align-items:center;margin:3px 0' }, el('code', { text: key }), el('span', { className: 'muted small', text: counts[key] + ' of ' + k.different.length }),\n el('button', { className: 'btn ghost sm', 'aria-label': 'Ignore ' + key + ' for ' + k.label, onclick: function () { cmpIgnore(P, k.kind, key, true); } }, 'Ignore'));\n })),\n el('div', { className: 'small muted', text: 'Ignore a setting that is meant to differ between tenants (for example a cluster or an owner). It is remembered on this computer for future comparisons.' })));\n }\n k.different.forEach(function (x) {\n body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' difference' + (x.differences.length > 1 ? 's' : '') + ')' }),\n simpleTable(['Setting', d.a, d.b], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));\n });\n w.appendChild(section(k.label, null, body));\n });\n }\n\n // ---------- Audit (Certifications, Separation of duties, Review coverage, Access outliers, Provisioning speed, Change history, Evidence pack) ----------\n state.au = { tab: 'certs' };\n function renderAudit() {\n var outer = $('certs');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#be185d;background:#fce8f1' }, icon('cert')),\n el('div', {}, el('h2', { text: 'Audit' }), el('p', { className: 'desc', text: 'Certifications, separation of duties, review coverage, access outliers, provisioning speed, configuration changes and a ready-made evidence pack for auditors. Read-only.' }))));\n groupedTabs(w, 'au', AU_GROUPS, AU_TABS, state.au.tab, function (id) { state.au.tab = id; renderAudit(); });\n if (state.au.tab === 'sod') renderSod(w);\n else if (state.au.tab === 'changes') renderChanges(w);\n else if (state.au.tab === 'evidence') renderEvidence(w);\n else if (state.au.tab === 'coverage') renderCoverage(w);\n else if (state.au.tab === 'outliers') renderOutliers(w);\n else if (state.au.tab === 'speed') renderSpeed(w);\n else if (state.au.tab === 'adminaccts') renderAdminAccounts(w);\n else if (state.au.tab === 'exceptions') renderExceptions(w);\n else if (state.au.tab === 'trail') renderRequestTrail(w);\n else if (state.au.tab === 'chain') renderApproverChain(w);\n else if (state.au.tab === 'leavertimes') renderLeaverTimes(w);\n else if (state.au.tab === 'attrhist') renderAttrHistory(w);\n else if (state.au.tab === 'owners') renderOwners(w);\n else if (state.au.tab === 'outmodel') renderOutsideModel(w);\n else if (state.au.tab === 'composition') renderComposition(w);\n else if (state.au.tab === 'reassigned') renderReassigned(w);\n else certsTab(w);\n }\n function moneyText(n, cur) { return n === null || n === undefined ? '—' : (cur ? cur + ' ' : '') + Number(n).toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 2 }); }\n function loadInsightSettings(then) {\n api('/api/insights/settings').then(function (s) { state.ins = s; then(); }).catch(function (e) { toast(errorText(e)); });\n }\n\n // separation of duties\n state.sd = {};\n function renderSod(w) {\n var S = state.sd;\n if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderAudit); return; }\n if (!S.rules) S.rules = clone(state.ins.sod || []);\n var msg = el('div');\n var list = el('div');\n var draw = function () {\n list.textContent = '';\n if (!S.rules.length) list.appendChild(el('div', { className: 'muted', style: 'margin-bottom:10px', text: 'No rules yet. Example: \"Create vendor\" and \"Approve payment\" should not be held by the same identity.' }));\n S.rules.forEach(function (r, i) {\n var name = el('input', { className: 'input', value: r.name || '', placeholder: 'Rule name, e.g. Create and approve payments' });\n name.addEventListener('input', function () { r.name = name.value; });\n var desc = el('input', { className: 'input', value: r.description || '', placeholder: 'Why (optional), e.g. SOX control FIN-07' });\n desc.addEventListener('input', function () { r.description = desc.value; });\n list.appendChild(el('div', { className: 'card', style: 'margin-bottom:10px;padding:14px' },\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr auto;align-items:end' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Rule' }), name),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Reason' }), desc),\n el('button', { className: 'btn ghost sm', title: 'Remove rule', onclick: function () { S.rules.splice(i, 1); draw(); } }, icon('trash'))),\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr;margin-top:10px' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side A: any of' }), tokenInput({ value: r.sideA || [], placeholder: 'Access name, e.g. SF Admin (Salesforce)', onChange: function (v) { r.sideA = v; } })),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side B: any of' }), tokenInput({ value: r.sideB || [], placeholder: 'Access name, e.g. Approve Payments', onChange: function (v) { r.sideB = v; } })))));\n });\n };\n draw();\n w.appendChild(section('Rules', S.rules.length, el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'An identity breaks a rule when they hold at least one item of side A and one of side B. Use the name of an entitlement, access profile or role as ISC shows it; add the source in brackets to be exact: \"Domain Admins (Active Directory)\". Matching ignores case.' }),\n list,\n el('div', { className: 'bar' },\n el('button', { className: 'btn', onclick: function () { S.rules.push({ name: '', sideA: [], sideB: [] }); draw(); } }, icon('plus'), 'Add rule'),\n el('button', { className: 'btn', onclick: function () {\n msg.textContent = '';\n api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); toast('Rules saved'); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save rules'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn primary', disabled: !!S.busy, onclick: function () {\n msg.textContent = '';\n api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); runJobInto(S, '/api/sod/run', {}, renderAudit); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('play'), S.data ? 'Check again' : 'Save and check')),\n msg)));\n if (S.busy) { w.appendChild(busyBox(S.busy)); return; }\n if (S.error) { w.appendChild(el('div', { className: 'error', text: S.error })); return; }\n var d = S.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'banner ' + (d.violations.length ? 'bad' : 'ok') }, el('b', { text: d.violations.length ? fmtNum(d.violations.length) + ' violation' + (d.violations.length > 1 ? 's' : '') : 'No violations' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' identities checked' }), el('span', { style: 'flex:1' }), downloads(S.job)));\n w.appendChild(section('Per rule', null, simpleTable(['Rule', 'Reason', 'Identities'], d.rules.map(function (r) { return [r.name, r.description, r.violations ? el('span', { className: 'chg lose', text: String(r.violations) }) : 0]; }))));\n if (d.violations.length) w.appendChild(section('Identities who break a rule', d.violations.length, simpleTable(['Rule', 'Identity', 'Username', 'Lifecycle state', 'Holds (side A)', 'Holds (side B)'], d.violations.slice(0, 2000).map(function (v) {\n return [v.rule, el('button', { className: 'btn link', style: 'padding:0', text: v.person, onclick: function () { openPerson(v.personId); } }), v.username, v.lifecycleState, v.heldA.join(', '), v.heldB.join(', ')];\n }))));\n }\n\n // configuration change history\n state.ch = {};\n function changeTable(d, labels) {\n var box = el('div');\n box.appendChild(simpleTable(['Type', labels[1], labels[0], 'Changed', 'Unchanged'], d.kinds.map(function (k) {\n return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : (k.onlyB.length ? el('span', { className: 'chg gain', text: String(k.onlyB.length) }) : 0), k.error ? null : (k.onlyA.length ? el('span', { className: 'chg lose', text: String(k.onlyA.length) }) : 0), k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];\n })));\n d.kinds.forEach(function (k) {\n if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;\n var body = el('div');\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: labels[1] + ': ' }), k.onlyB.join(', ')));\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: labels[0] + ': ' }), k.onlyA.join(', ')));\n k.different.forEach(function (x) {\n body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' change' + (x.differences.length > 1 ? 's' : '') + ')' }),\n simpleTable(['Setting', labels[2], labels[3]], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));\n });\n box.appendChild(section(k.label, null, body));\n });\n return box;\n }\n function renderChanges(w) {\n // What changed between two snapshots, then drift from the approved baseline (the release that went live).\n var top = el('div');\n w.appendChild(top);\n renderChangesBetween(top);\n var drift = el('div', { style: 'margin-top:26px' }, el('h3', { style: 'margin:0 0 8px', text: 'Drift from an approved baseline' }));\n w.appendChild(drift);\n renderDrift(drift);\n }\n function renderChangesBetween(w) {\n var H = state.ch;\n if (!H.days) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/changes').then(function (r) { H.days = r.days; H.from = r.days[1] || r.days[0] || ''; H.to = r.days[0] || ''; renderAudit(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n return;\n }\n var snapBtn = el('button', { className: 'btn' + (H.days.length ? '' : ' primary'), disabled: !!H.busy, onclick: function () {\n runJobInto(H, '/api/changes/snapshot', {}, function () { if (!H.busy && !H.error) { H.days = null; H.diff = null; } renderAudit(); });\n } }, icon('save'), 'Take a snapshot now');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'A snapshot keeps the settings of sources, transforms, identity profiles, roles, access profiles and workflows on this computer (secrets hidden). Scheduled instant checks save one every day by themselves. Compare two days to see what changed.' }), snapBtn));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) w.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.days.length < 2) {\n w.appendChild(el('div', { className: 'empty' }, el('b', { text: H.days.length ? 'One snapshot so far (' + H.days[0] + ')' : 'No snapshots yet' }), 'Take a snapshot now and another one later (or schedule the instant check daily); then pick two days to compare.'));\n return;\n }\n var mk = function (v, set, label) { var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, H.days.map(function (d) { return el('option', { value: d, text: d }); })); s.value = v; s.addEventListener('change', function () { set(s.value); }); return s; };\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'bar' }, el('span', { text: 'What changed from' }), mk(H.from, function (v) { H.from = v; }, 'From snapshot'), el('span', { text: 'to' }), mk(H.to, function (v) { H.to = v; }, 'To snapshot'),\n el('button', { className: 'btn primary', onclick: function () {\n H.diff = 'loading'; renderAudit();\n api('/api/changes/diff?from=' + H.from + '&to=' + H.to).then(function (r) { H.diff = r; renderAudit(); }).catch(function (e) { H.diff = null; H.error = errorText(e); renderAudit(); });\n } }, icon('cols'), 'Show changes'),\n el('span', { className: 'muted small', text: H.days.length + ' snapshots kept' }))));\n if (H.diff === 'loading') { w.appendChild(busyBox('Comparing...')); return; }\n if (H.diff) {\n var n = H.diff.kinds.reduce(function (s, k) { return s + k.onlyA.length + k.onlyB.length + k.different.length; }, 0);\n w.appendChild(el('div', { className: 'banner ' + (n ? 'warn' : 'ok') }, el('b', { text: n ? fmtNum(n) + ' change' + (n > 1 ? 's' : '') + ' from ' + H.diff.from + ' to ' + H.diff.to : 'Nothing changed from ' + H.diff.from + ' to ' + H.diff.to })));\n w.appendChild(changeTable(H.diff, ['Removed', 'Added', H.diff.from, H.diff.to]));\n }\n }\n\n // evidence pack\n state.ev = { days: 365 };\n function renderEvidence(w) {\n var E = state.ev;\n if (!E.sections) {\n w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));\n api('/api/evidence').then(function (r) { E.sections = r.sections; E.chosen = r.sections.map(function (s) { return s.id; }); renderAudit(); });\n return;\n }\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year'], [730, 'Last 2 years']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(E.days);\n period.addEventListener('change', function () { E.days = Number(period.value); });\n w.appendChild(section('What goes into the pack', null, el('div', {},\n el('p', { className: 'muted small', style: 'margin-top:0', text: 'One zip for your auditors: an Excel file per part, a README saying when, by whom and from which tenant it was produced, and SHA-256 fingerprints (SHA256SUMS.txt) so they can check nothing was changed afterwards. Nothing is sent anywhere; you download it.' }),\n el('div', { className: 'checklist' }, E.sections.map(function (s) {\n var c = el('input', { type: 'checkbox', checked: E.chosen.indexOf(s.id) >= 0 });\n c.addEventListener('change', function () { E.chosen = E.chosen.filter(function (x) { return x !== s.id; }); if (c.checked) E.chosen.push(s.id); });\n return el('label', { className: 'cl-item' }, c, el('span', {}, el('b', { text: s.label }), el('span', { className: 'muted small', text: ' — ' + s.description })));\n })),\n el('div', { className: 'bar', style: 'margin-top:12px' }, el('span', { text: 'Period for leavers and requests' }), period, el('span', { style: 'flex:1' }),\n el('button', { className: 'btn primary', disabled: !!E.busy, onclick: function () { runJobInto(E, '/api/evidence/run', { sections: E.chosen, days: E.days }, renderAudit); } }, icon('play'), 'Build the pack')))));\n if (E.busy) { w.appendChild(busyBox(E.busy)); return; }\n if (E.error) { w.appendChild(el('div', { className: 'error', text: E.error })); return; }\n var d = E.data;\n if (!d) return;\n var bad = d.files.filter(function (f) { return f.error; }).length;\n w.appendChild(el('div', { className: 'banner ' + (bad ? 'warn' : 'ok') }, el('b', { text: (d.files.length - bad) + ' of ' + d.files.length + ' parts ready' }), el('span', { className: 'muted', text: d.fileName }), el('span', { style: 'flex:1' }),\n el('a', { className: 'btn primary sm', href: '/api/evidence/' + E.job + '/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download zip')));\n w.appendChild(section('Contents', d.files.length, simpleTable(['Part', 'File', 'Rows', 'SHA-256 fingerprint'], d.files.map(function (f) {\n return [f.section, f.error ? el('span', { className: 'chg lose', text: 'not included' }) : f.name, f.rows === null ? null : fmtNum(f.rows), f.error ? f.error : el('code', { className: 'small', text: f.sha256.slice(0, 16) + '…' })];\n }))));\n }\n\n // ---------- Insights (Monthly report, License reclaim, Access requests) ----------\n state.inz = { tab: 'monthly' };\n function renderInsights() {\n var outer = $('monthly');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0e7c66;background:#e3f5f0' }, icon('sigma')),\n el('div', {}, el('h2', { text: 'Insights' }), el('p', { className: 'desc', text: 'The monthly report for management, licenses you could reclaim, and how access requests flow. Read-only.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['monthly', 'Monthly report', 'file'], ['reclaim', 'License reclaim', 'down'], ['requests', 'Access requests', 'inbox']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.inz.tab === t[0] ? ' active' : ''), onclick: function () { state.inz.tab = t[0]; if (t[0] === 'monthly') state.mr.data = null; renderInsights(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.inz.tab === 'reclaim') renderReclaim(w);\n else if (state.inz.tab === 'requests') renderRequests(w);\n else monthlyTab(w);\n }\n\n // license reclaim\n state.rc = {};\n function renderReclaim(w) {\n var R = state.rc;\n if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderInsights); return; }\n var cfg = state.ins.reclaim || {};\n if (!R.form) R.form = { dormantDays: cfg.dormantDays || 90, currency: cfg.currency || '', leaverStates: (cfg.leaverStates || ['inactive', 'terminated']).slice(), sources: clone(cfg.sources || {}) };\n var F = R.form;\n var sources = R.sources;\n if (!sources) loadPick('sources').then(function (list) { R.sources = list; if (state.page === 'monthly' && state.inz.tab === 'reclaim') renderInsights(); }).catch(function (e) { toast(errorText(e)); });\n var msg = el('div');\n var days = el('input', { className: 'input', type: 'number', min: '7', value: String(F.dormantDays), style: 'width:100px', 'aria-label': 'Dormant after (days)' });\n days.addEventListener('input', function () { F.dormantDays = Number(days.value); });\n var cur = el('input', { className: 'input', value: F.currency, placeholder: 'USD', style: 'width:90px', 'aria-label': 'Currency' });\n cur.addEventListener('input', function () { F.currency = cur.value; });\n var rows = (sources || []).map(function (s) {\n var one = F.sources[s.label] || {};\n var cost = el('input', { className: 'input', type: 'number', min: '0', step: '0.01', 'aria-label': 'Cost per account per month for ' + s.label, value: one.cost === undefined ? '' : String(one.cost), placeholder: 'e.g. 12.50', style: 'width:120px' });\n cost.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].cost = cost.value === '' ? undefined : Number(cost.value); });\n var ll = el('input', { className: 'input', 'aria-label': 'Last login attribute for ' + s.label, value: one.lastLogin || '', placeholder: s.hint && /active directory/i.test(s.hint) ? 'lastLogonTimestamp' : 'attribute name', style: 'width:220px' });\n ll.addEventListener('input', function () { F.sources[s.label] = F.sources[s.label] || {}; F.sources[s.label].lastLogin = ll.value; });\n return [s.label, s.hint, cost, ll];\n });\n w.appendChild(el('details', { className: 'card adv', open: !Object.keys(cfg.sources || {}).length || null }, el('summary', { style: 'font-weight:600', text: 'Settings: cost per account and sign-in dates' }),\n el('p', { className: 'muted small', text: 'Cost: what one account on the application costs per month (license or subscription), to estimate savings. Sign-in attribute: the account attribute that holds the last sign-in date, for example lastLogonTimestamp for Active Directory. It must be in the source’s account schema in ISC. Leave both empty for sources you do not pay for.' }),\n el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('span', { text: 'Dormant after' }), days, el('span', { text: 'days without sign-in. Currency' }), cur,\n el('span', { text: 'Identities have left when lifecycle state is' }), tokenInput({ value: F.leaverStates, onChange: function (v) { F.leaverStates = v; } })),\n sources ? simpleTable(['Source', 'Type', 'Monthly cost per account', 'Sign-in date attribute'], rows) : el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading sources...'),\n el('div', { className: 'bar', style: 'margin-top:10px' }, el('button', { className: 'btn', onclick: function () {\n msg.textContent = '';\n api('/api/reclaim/settings', 'PUT', F).then(function () { return loadInsightSettings(function () { R.form = null; toast('Settings saved'); renderInsights(); }); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save settings')), msg));\n w.appendChild(el('div', { className: 'bar', style: 'margin:14px 0' }, el('span', { className: 'muted', style: 'flex:1', text: 'Finds enabled accounts of identities who left and accounts nobody signed in with for a long time, so licenses can be taken back. Disabling them is up to you in ISC.' }),\n el('button', { className: 'btn primary', disabled: !!R.busy, onclick: function () { runJobInto(R, '/api/reclaim/run', {}, renderInsights); } }, icon('play'), R.data ? 'Look again' : 'Find licenses to reclaim')));\n if (R.busy) { w.appendChild(busyBox(R.busy)); return; }\n if (R.error) { w.appendChild(el('div', { className: 'error', text: R.error })); return; }\n var d = R.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' + (T.accounts ? ' lose' : '') }, el('b', { text: fmtNum(T.accounts) }), el('span', { text: 'accounts to reclaim' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.leaver) }), el('span', { text: 'held by identities who left' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.dormant) }), el('span', { text: 'no sign-in for ' + d.dormantDays + '+ days' })),\n el('div', { className: 'bigstat' + (T.monthly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.monthly, d.currency) : '—' }), el('span', { text: 'possible saving per month' })),\n el('div', { className: 'bigstat' + (T.yearly ? ' gain' : '') }, el('b', { text: T.priced ? moneyText(T.yearly, d.currency) : '—' }), el('span', { text: 'per year' }))));\n w.appendChild(section('By application', d.sources.length, simpleTable(['Source', 'Identities who left', 'Dormant', 'Cost per account', 'Per month', 'Per year'], d.sources.map(function (s) {\n return [el('button', { className: 'btn link', style: 'padding:0', text: s.source, onclick: function () { R.only = R.only === s.source ? null : s.source; renderInsights(); } }), s.leaver, s.dormant, moneyText(s.costPerAccount, d.currency), moneyText(s.monthly, d.currency), moneyText(s.yearly, d.currency)];\n }))));\n var list = d.rows.filter(function (r) { return !R.only || r.source === R.only; });\n w.appendChild(section(R.only ? 'Accounts on ' + R.only : 'Accounts', list.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, R.only ? el('button', { className: 'btn ghost sm', onclick: function () { R.only = null; renderInsights(); } }, 'Show all') : null, downloads(R.job)),\n simpleTable(['Source', 'Account', 'Identity', 'Why', 'Last sign-in', 'Privileged'], list.slice(0, 2000).map(function (r) {\n return [r.source, r.account, r.person, el('span', { className: 'chg ' + (r.reason === 'Identity has left' ? 'lose' : 'off'), text: r.reason + (r.lifecycleState && r.reason === 'Identity has left' ? ' (' + r.lifecycleState + ')' : '') }), r.lastLogin ? r.lastLogin.slice(0, 10) + ' (' + r.daysSince + ' days)' : null, yesNo(r.privileged, true)];\n })))));\n }\n\n // access requests\n state.rq = { days: 90 };\n function renderRequests(w) {\n var Q = state.rq;\n var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[30, 'Last 30 days'], [90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n period.value = String(Q.days);\n period.addEventListener('change', function () { Q.days = Number(period.value); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'How long requests wait for approval, which approvers are slow or have requests waiting, and which access is requested and rejected most. An admin sign-in sees everyone’s requests.' }), period,\n el('button', { className: 'btn primary', disabled: !!Q.busy, onclick: function () { runJobInto(Q, '/api/requests/run', { days: Q.days }, renderInsights); } }, icon('play'), Q.data ? 'Read again' : 'Read requests')));\n if (Q.busy) { w.appendChild(busyBox(Q.busy)); return; }\n if (Q.error) { w.appendChild(el('div', { className: 'error', text: Q.error })); return; }\n var d = Q.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var T = d.totals;\n var hrs = function (h) { return h === null ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; };\n w.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.requests) }), el('span', { text: 'requests in ' + d.days + ' days' })),\n el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToApprove) }), el('span', { text: 'typical wait for an approval' })),\n el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHoursToComplete) }), el('span', { text: 'typical time to get the access' })),\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(T.rejected) }), el('span', { text: 'rejected' })),\n el('div', { className: 'bigstat' + (T.open ? ' lose' : '') }, el('b', { text: fmtNum(T.open) }), el('span', { text: 'still open' })),\n el('div', { className: 'bigstat' + (T.failed ? ' lose' : '') }, el('b', { text: fmtNum(T.failed) }), el('span', { text: 'failed' }))));\n if (d.weekly.length > 1) w.appendChild(section('Requests per week', null, el('div', { style: 'color:var(--accent)' }, sparkline(d.weekly.map(function (x) { return { value: x.requests }; }), 900, 60), el('div', { className: 'muted small', text: d.weekly[0].week + ' to ' + d.weekly[d.weekly.length - 1].week }))));\n w.appendChild(section('Approvers', d.approvers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(Q.job)),\n simpleTable(['Approver', 'Decisions', 'Approved', 'Rejected', 'Typical time to decide', 'Waiting now', 'Oldest waiting'], d.approvers.map(function (a) {\n return [a.name, a.decisions, a.approved, a.rejected, hrs(a.medianHours), a.pending ? el('span', { className: 'chg lose', text: String(a.pending) }) : 0, a.oldestPendingDays === null ? null : a.oldestPendingDays + ' days'];\n })))));\n w.appendChild(section('Most requested access', d.items.length, simpleTable(['Access', 'Type', 'Requests', 'Completed', 'Rejected', 'Reject rate'], d.items.slice(0, 100).map(function (i) {\n return [i.name, i.type, i.requests, i.completed, i.rejected, i.rejectRate === null ? null : (i.rejectRate >= 50 && i.rejected > 1 ? el('span', { className: 'chg lose', text: i.rejectRate + '%' }) : i.rejectRate + '%')];\n }))));\n }\n\n // ---------- role mining (a Role tools tab) ----------\n state.mn = { attribute: 'department', minGroup: 5, minShare: 80 };\n function renderMining(w) {\n var M = state.mn;\n var attrs = identityAttrs();\n var names = attrs.map(function (a) { return a.name; });\n if (names.indexOf(M.attribute) < 0) names.unshift(M.attribute);\n var attr = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Group identities by' }, names.map(function (n) { return el('option', { value: n, text: n }); }));\n attr.value = M.attribute;\n attr.addEventListener('change', function () { M.attribute = attr.value; });\n var minG = el('input', { className: 'input', type: 'number', min: '1', value: String(M.minGroup), style: 'width:80px', 'aria-label': 'Smallest group size' });\n minG.addEventListener('input', function () { M.minGroup = Number(minG.value); });\n var share = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Held by at least' }, [60, 70, 80, 90, 100].map(function (n) { return el('option', { value: String(n), text: n + '%' }); }));\n share.value = String(M.minShare);\n share.addEventListener('change', function () { M.minShare = Number(share.value); });\n w.appendChild(el('section', { className: 'card' },\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Groups identities by an identity attribute (department, job title, location...) and lists the entitlements most of each group already hold. Those are candidates for a birthright role with that attribute as membership criteria. Items an existing role already gives are marked.' }),\n el('div', { className: 'bar' }, el('span', { text: 'Group identities by' }), attr, el('span', { text: 'groups of at least' }), minG, el('span', { text: 'identities, access held by at least' }), share,\n el('button', { className: 'btn primary', disabled: !!M.busy, onclick: function () { runJobInto(M, '/api/mining/run', { attribute: M.attribute, minGroup: M.minGroup, minShare: M.minShare }, renderRoles); } }, icon('play'), 'Find candidate roles'))));\n if (M.busy) { w.appendChild(busyBox(M.busy)); return; }\n if (M.error) { w.appendChild(el('div', { className: 'error', text: M.error })); return; }\n var d = M.data;\n if (!d) return;\n d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var fresh = d.candidates.filter(function (c) { return c.newItems > 0; }).length;\n w.appendChild(el('div', { className: 'banner ' + (fresh ? 'warn' : 'ok') }, el('b', { text: fresh ? fresh + ' group' + (fresh > 1 ? 's have' : ' has') + ' common access no role gives yet' : 'No new candidate roles' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' active identities in ' + fmtNum(d.groups) + ' groups' }), el('span', { style: 'flex:1' }), downloads(M.job)));\n d.candidates.slice(0, 60).forEach(function (c) {\n w.appendChild(section(d.attribute + ' = ' + c.value, fmtNum(c.members) + (c.members === 1 ? ' identity' : ' identities'), el('div', {},\n simpleTable(['Entitlement', 'Source', 'Held by', 'Already in a role'], c.items.map(function (i) {\n return [i.name, i.source, i.holders + ' (' + i.share + '%)', i.covered ? el('span', { className: 'chg gain', text: 'Yes' }) : el('span', { className: 'chg lose', text: 'No' })];\n })),\n c.newItems ? el('p', { className: 'muted small', text: 'Candidate role: members where ' + d.attribute + ' is \"' + c.value + '\", with the ' + c.newItems + ' item' + (c.newItems > 1 ? 's' : '') + ' marked No. Check it first with \"Preview a role change\".' }) : null)));\n });\n }\n\n // ---------- share reports (report packs) ----------\n function sharePanel() {\n var m = $('main');\n m.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:980px' });\n m.appendChild(w);\n pageHead(w, 'copy', '#334155', '#eef1f5', 'Share reports', 'Export reports to one file and import packs from colleagues or other companies. A pack holds report definitions only, never data or credentials.');\n var mine = state.reports.filter(function (r) { return r.custom; });\n var chosen = mine.map(function (r) { return r.definition.id; });\n var exportList = el('div', { className: 'checklist' }, (mine.length ? mine : state.reports.slice(0, 0)).map(function (r) {\n var c = el('input', { type: 'checkbox', checked: true });\n c.addEventListener('change', function () { chosen = chosen.filter(function (x) { return x !== r.definition.id; }); if (c.checked) chosen.push(r.definition.id); });\n return el('label', { className: 'cl-item' }, c, el('span', { text: r.definition.name + ' (' + r.definition.id + ')' }));\n }));\n w.appendChild(section('Export my reports', mine.length, mine.length ? el('div', {}, exportList, el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {\n if (!chosen.length) { toast('Choose at least one report'); return; }\n var a = el('a', { href: '/api/packs/download?ids=' + encodeURIComponent(chosen.join(',')) + '&k=' + encodeURIComponent(KEY), download: '' });\n document.body.appendChild(a); a.click(); a.remove();\n } }, icon('download'), 'Download pack')) : el('div', { className: 'muted', text: 'You have no reports of your own yet. Use New report or Customize on a ready-made report.' })));\n var box = el('div');\n var file = el('input', { type: 'file', accept: '.json,application/json' });\n file.addEventListener('change', function () {\n var f = file.files && file.files[0];\n if (!f) return;\n if (f.size > 1500000) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: 'The file is too large for a report pack.' })); return; }\n f.text().then(function (text) {\n return api('/api/packs/preview', 'POST', { text: text }).then(function (p) {\n box.textContent = '';\n var pick = p.entries.filter(function (e) { return e.status === 'new' || e.status === 'replaces yours'; }).map(function (e) { return e.id; });\n box.appendChild(simpleTable(['', 'Report', 'ID', 'What happens'], p.entries.map(function (e) {\n var ok = e.status === 'new' || e.status === 'replaces yours';\n var c = el('input', { type: 'checkbox', checked: ok, disabled: !ok });\n c.addEventListener('change', function () { pick = pick.filter(function (x) { return x !== e.id; }); if (c.checked) pick.push(e.id); });\n var what = e.status === 'new' ? el('span', { className: 'chg gain', text: 'Added' }) : e.status === 'replaces yours' ? el('span', { className: 'chg lose', text: 'Replaces your report with this ID' }) : e.status === 'built in' ? el('span', { className: 'chg off', text: 'Skipped: same ID as a ready-made report' }) : el('span', { className: 'chg lose', text: 'Skipped: ' + e.problems.join('; ') });\n return [c, e.name, e.id, what];\n })));\n box.appendChild(el('button', { className: 'btn primary', style: 'margin-top:12px', onclick: function () {\n api('/api/packs/import', 'POST', { text: text, ids: pick }).then(function (r) { toast(r.saved.length + ' report' + (r.saved.length === 1 ? '' : 's') + ' added'); loadLibrary(); }).catch(function (e) { box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('plus'), 'Add the chosen reports'));\n });\n }).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n });\n w.appendChild(section('Import a pack', null, el('div', {}, el('p', { className: 'muted small', style: 'margin-top:0', text: 'Choose a .json pack file. You see every report before anything is added. Ready-made reports are never replaced.' }), file, box)));\n }\n\n // ---------- partner overview: all customer tenants ----------\n state.pt = { only: false, form: null, sel: null };\n var ST_WORD = { ok: 'OK', warn: 'Attention', bad: 'Problem', error: 'Could not check', off: 'Off' };\n var ST_CLS = { ok: 'ok', warn: 'warn', bad: 'bad', error: 'err', off: 'off' };\n function showPartner() {\n state.page = 'partner';\n $('connect').classList.add('hidden');\n $('app').classList.add('hidden');\n ['schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.add('hidden'); });\n ['nav-reports', 'nav-schedules', 'nav-roles', 'nav-checks', 'nav-lookup', 'nav-tenant', 'nav-build', 'nav-certs', 'nav-monthly', 'nav-warnings', 'nav-nerm', 'nav-logs'].forEach(function (n) { $(n).classList.remove('active'); });\n $('partner').classList.remove('hidden');\n $('btn-help').classList.remove('hidden');\n renderPartner();\n }\n function hidePartner() { $('partner').classList.add('hidden'); }\n function loadPartner() {\n return api('/api/tenants').then(function (d) { state.pt.data = d; state.pt.count = d.tenants.length; $('btn-partner-nav').classList.toggle('hidden', !d.tenants.length || $('nav').classList.contains('hidden')); return d; });\n }\n function renderPartner() {\n var P = state.pt;\n var outer = $('partner');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1500px' });\n outer.appendChild(w);\n var back = $('nav').classList.contains('hidden')\n ? el('button', { className: 'btn', onclick: function () { hidePartner(); api('/api/state').then(showConnect); } }, icon('logout'), 'Back to sign-in')\n : el('button', { className: 'btn', onclick: function () { hidePartner(); showPage('reports'); } }, 'Back to ' + ($('tenant').textContent || 'the tenant'));\n pageHead(w, 'db', '#0e7c66', '#e3f5f0', 'All tenants', 'The instant check of all your tenants in one place: sandbox, QA and production of one company, or the tenants of every customer a partner looks after. Read-only: each tenant uses its own credentials, kept only on this computer.', back);\n if (!P.data) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadPartner().then(renderPartner).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }\n var d = P.data;\n var R = state.ptRun;\n var runBtn = el('button', { className: 'btn primary', disabled: !!R.busy || !d.tenants.length, onclick: function () { partnerRun({}); } }, icon('play'), d.lastRun ? 'Check all again' : 'Check all tenants');\n var only = el('input', { type: 'checkbox', checked: P.only });\n only.addEventListener('change', function () { P.only = only.checked; renderPartner(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('button', { className: 'btn', onclick: function () { P.form = { isNew: true }; renderPartner(); } }, icon('plus'), 'Add a tenant'),\n el('label', { className: 'inline small' }, only, 'Only tenants that need attention'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn', 'aria-expanded': String(!!P.pick), onclick: function () { P.pick = P.pick ? null : d.checks.map(function (c) { return c.id; }); renderPartner(); } }, icon('cols'), 'Checks (' + d.checks.length + ' of ' + (d.allChecks || d.checks).length + ')'), runBtn));\n if (P.pick) {\n var boxes = el('div', { style: 'display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:6px 18px;margin:10px 0' });\n (d.allChecks || []).forEach(function (c) {\n var cb = el('input', { type: 'checkbox', checked: P.pick.indexOf(c.id) >= 0 });\n cb.addEventListener('change', function () { P.pick = cb.checked ? P.pick.concat([c.id]) : P.pick.filter(function (x) { return x !== c.id; }); });\n boxes.appendChild(el('label', { className: 'inline small' }, cb, c.label, c.quick ? null : el('span', { className: 'muted', text: ' (reads every identity or account; slow on large tenants)' })));\n });\n var savePick = function (ids) {\n api('/api/tenants/checks', 'PUT', { ids: ids }).then(function () { P.pick = null; P.data = null; renderPartner(); }, function (e) { toast(errorText(e)); });\n };\n w.appendChild(el('div', { className: 'card', style: 'padding:14px 16px' },\n el('b', { text: 'Checks on this page' }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'The quick checks show whether each tenant is running. The others stay on each tenant\\u2019s own Instant check; tick one here only if you want it across all tenants. This also applies to the scheduled All tenants summary.' }),\n boxes,\n el('div', { className: 'bar' }, el('button', { className: 'btn primary', onclick: function () { savePick(P.pick); } }, 'Save'),\n el('button', { className: 'btn', onclick: function () { savePick((d.allChecks || []).filter(function (c) { return c.quick; }).map(function (c) { return c.id; })); } }, 'Back to the quick checks'),\n el('button', { className: 'btn', onclick: function () { P.pick = null; renderPartner(); } }, 'Cancel'))));\n }\n if (P.form) w.appendChild(partnerForm(P));\n if (R.busy) w.appendChild(busyBox(R.busy));\n if (R.error) w.appendChild(el('div', { className: 'error', text: R.error }));\n if (!d.tenants.length) {\n w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No tenants yet' }), 'Add each tenant (your sandbox, QA and production, or each customer) with a read-only personal access token or API client from that tenant. Then check all of them with one click, or schedule \"All tenants\" daily for one summary by email or Teams.'));\n return;\n }\n var run = P.data.lastRun;\n var byId = {};\n if (run) run.results.forEach(function (r) { byId[r.id] = r; });\n var known = {};\n d.lastKnown.forEach(function (k) { known[k.id] = k; });\n if (run) w.appendChild(el('div', { className: 'banner ' + (/problem/.test(run.headline) ? 'bad' : /look at/.test(run.headline) ? 'warn' : 'ok') }, el('b', { text: run.headline }), el('span', { className: 'muted', text: 'checked ' + fmtWhen(run.at) }), el('span', { style: 'flex:1' }), R.job && R.data ? downloads(R.job) : null));\n else w.appendChild(el('div', { className: 'note', text: 'Showing the last results kept on this computer. Check all tenants for fresh numbers.' }));\n var order = { error: 0, bad: 1, warn: 2, ok: 3, off: 4, none: 5 };\n var rows = d.tenants.map(function (t) {\n var r = byId[t.id];\n var k = known[t.id] || { status: {}, values: {} };\n var overall = r ? r.status : worstOf(d.checks.map(function (c) { return k.status[c.id]; }).filter(Boolean));\n return { t: t, r: r, k: k, overall: overall || 'none' };\n }).filter(function (x) { return !P.only || x.overall === 'warn' || x.overall === 'bad' || x.overall === 'error'; })\n .sort(function (a, b) { return order[a.overall] - order[b.overall] || a.t.name.localeCompare(b.t.name); });\n var table = el('table', { className: 'grid-table ptable' });\n var head = el('tr', {}, el('th', { text: 'Tenant' }), el('th', { text: 'Overall' }), d.checks.map(function (c) { return el('th', { className: 'pcol', title: c.label, text: c.label }); }), el('th', {}, el('span', { className: 'sr-only', text: 'Actions' })));\n table.appendChild(el('thead', {}, head));\n var body = el('tbody');\n rows.forEach(function (x) {\n var t = x.t;\n var tr = el('tr', { className: P.sel && P.sel.id === t.id ? 'sel' : '' });\n tr.appendChild(el('td', {}, el('b', { text: t.name }), el('div', { className: 'muted small', text: new URL(t.baseUrl).host }), t.hasSecret ? null : el('div', { className: 'error small', text: 'No secret saved' }), tokenNote(x.r)));\n tr.appendChild(el('td', {}, x.overall === 'none' ? el('span', { className: 'muted small', text: 'Not checked yet' }) : el('span', { className: 'pstat ' + ST_CLS[x.overall], text: x.r && x.r.error ? 'Could not check' : ST_WORD[x.overall] })));\n if (x.r && x.r.error) {\n tr.appendChild(el('td', { colSpan: String(d.checks.length), className: 'small' }, el('span', { className: 'error', style: 'display:inline-block;margin:0', text: x.r.error })));\n } else d.checks.forEach(function (c) {\n var res = x.r ? x.r.results.filter(function (y) { return y.id === c.id; })[0] : null;\n var st = res ? res.status : x.k.status[c.id];\n var v = res ? res.value : x.k.values[c.id];\n var cell = el('td', { className: 'pcell' });\n if (st && st !== 'off') {\n var b = el('button', { className: 'pval ' + ST_CLS[st], title: c.label + ': ' + (res ? res.summary : ST_WORD[st]), text: st === 'error' ? '!' : (v === null || v === undefined ? '—' : fmtNum(v)), onclick: function () { P.sel = { id: t.id, check: c.id }; renderPartner(); } });\n if (res && x.r.worse.indexOf(c.id) >= 0) b.appendChild(el('span', { className: 'pnew', text: 'new' }));\n cell.appendChild(b);\n } else cell.appendChild(el('span', { className: 'muted', text: st === 'off' ? 'off' : '' }));\n tr.appendChild(cell);\n });\n tr.appendChild(el('td', { style: 'white-space:nowrap' },\n el('button', { className: 'btn sm primary', title: 'Open this tenant with all pages', disabled: !t.hasSecret, onclick: function () { openTenant(t); } }, 'Open'),\n el('button', { className: 'btn sm ghost', title: 'Edit', onclick: function () { P.form = { id: t.id, name: t.name, baseUrl: t.baseUrl, clientId: t.clientId, notes: t.notes || '' }; renderPartner(); } }, icon('sliders')),\n el('button', { className: 'btn sm ghost', title: 'Check only this tenant', disabled: !!R.busy, onclick: function () { partnerRun({ ids: [t.id] }); } }, icon('play'))));\n body.appendChild(tr);\n if (P.sel && P.sel.id === t.id) {\n var res = x.r ? x.r.results.filter(function (y) { return y.id === P.sel.check; })[0] : null;\n var c = d.checks.filter(function (y) { return y.id === P.sel.check; })[0];\n var inner = el('div', { className: 'pdetail' }, el('b', { text: t.name + ' · ' + (c ? c.label : '') }));\n if (res) {\n inner.appendChild(el('div', { text: res.summary }));\n if (res.error) inner.appendChild(el('div', { className: 'error small', text: res.error }));\n if (res.top && res.top.length) inner.appendChild(el('div', { className: 'muted small', text: res.top.slice(0, 5).map(function (y) { return y.label + ' (' + y.count + ')'; }).join(' · ') }));\n if (FIX && FIX[res.id]) inner.appendChild(el('div', { className: 'small', style: 'margin-top:6px' }, el('b', { text: 'How to fix: ' }), FIX[res.id][0]));\n } else inner.appendChild(el('div', { className: 'muted', text: 'From the last check kept on this computer. Check this tenant for details.' }));\n var go = CHECK_GOTO[P.sel.check];\n inner.appendChild(el('div', { className: 'bar', style: 'margin-top:8px' },\n el('button', { className: 'btn sm primary', disabled: !t.hasSecret, title: go ? 'Opens ' + t.name + ' on ' + go[2] : 'Opens ' + t.name, onclick: function () { openTenant(t, null, P.sel.check); } }, icon('play'), go ? 'Open ' + go[2] : 'Open in this tenant'),\n el('button', { className: 'btn sm ghost', onclick: function () { P.sel = null; renderPartner(); } }, 'Close')));\n body.appendChild(el('tr', {}, el('td', { colSpan: String(d.checks.length + 3) }, inner)));\n }\n });\n table.appendChild(body);\n w.appendChild(el('div', { className: 'card', style: 'padding:0;overflow-x:auto' }, table));\n w.appendChild(el('p', { className: 'muted small', text: 'Click a number for details and a link to the report or page behind it. \"new\" means new or worse since that tenant\\'s previous check. Limits are the ones set on the Instant check page. Schedule \"All tenants\" on the Schedules page for one daily summary of every tenant.' }));\n }\n state.ptRun = {};\n function partnerRun(body) {\n runJobInto(state.ptRun, '/api/tenants/run', body, function () {\n if (state.ptRun.data && state.pt.data) state.pt.data.lastRun = state.ptRun.data;\n if (state.page === 'partner') renderPartner();\n });\n }\n function worstOf(list) {\n var rank = { error: 4, bad: 3, warn: 2, ok: 1, off: 0 };\n var best = null;\n list.forEach(function (s) { if (s && (best === null || rank[s] > rank[best])) best = s; });\n return best;\n }\n function fmtWhen(iso) { try { return new Date(iso).toLocaleString(); } catch (e) { return iso; } }\n // Where each check's details are: a report (run as soon as it opens) or a page and tab.\n var CHECK_GOTO = {\n 'provisioning-errors': ['report', 'provisioning-errors', 'the Provisioning errors report'],\n 'aggregation-failures': ['report', 'aggregation-failures', 'the Aggregation failures report'],\n 'stale-sources': ['report', 'aggregation-history', 'the Aggregation runs per source report'],\n 'sources-in-error': ['report', 'sources-needing-attention', 'the Sources needing attention report'],\n 'identity-errors': ['report', 'identities-with-processing-errors', 'the Identities with processing errors report'],\n 'stuck-requests': ['report', 'stuck-access-requests', 'the Stuck access requests report'],\n 'leavers-with-access': ['report', 'terminated-users-with-active-accounts', 'the Terminated identities with active accounts report'],\n 'uncorrelated-growth': ['report', 'uncorrelated-accounts', 'the Uncorrelated accounts report'],\n 'campaigns-at-risk': ['report', 'campaign-progress', 'the Campaign progress report'],\n 'va-clusters': ['tenant', 'clusters', 'Tenant > Virtual Appliances'],\n 'api-credentials': ['tenant', 'credentials', 'Tenant > API credentials'],\n 'workflow-failures': ['tenant', 'workflows', 'Tenant > Workflows'],\n 'access-ending': ['warnings', 'ending', 'Warnings > Access ending'],\n 'stuck-on-leavers': ['warnings', 'stuck', 'Warnings > Waiting on leavers'],\n 'admins-left': ['warnings', 'admins', 'Warnings > ISC admins'],\n 'past-end-date': ['warnings', 'people', 'Warnings > End dates'],\n 'lifecycle-gaps': ['warnings', 'joiners', 'Warnings > Missed joiners'],\n 'slow-removals': ['certs', 'speed', 'Audit > Provisioning speed'],\n };\n function goToCheck(id) {\n var g = CHECK_GOTO[id];\n if (!g) { showPage('checks'); return; }\n if (g[0] === 'report') {\n showPage('reports');\n loadLibrary(g[1]).then(function () { if (state.current && state.current.def.id === g[1]) run(false); });\n return;\n }\n if (g[0] === 'tenant') state.tn.tab = g[1];\n if (g[0] === 'build') state.bt.tab = g[1];\n if (g[0] === 'warnings') wnState().tab = g[1];\n if (g[0] === 'certs') state.au.tab = g[1];\n showPage(g[0]);\n }\n function openTenant(t, page, check) {\n toast('Opening ' + t.name + '...');\n api('/api/tenants/' + t.id + '/open', 'POST', {}).then(function (r) {\n hidePartner();\n state.signedIn = false;\n showApp(r.tenant);\n $('tenant').textContent = t.name + ' · ' + r.tenant;\n $('tenant-chip').title = t.name + ' · ' + r.tenant;\n $('btn-partner-nav').classList.remove('hidden');\n if (check) goToCheck(check);\n else if (page) showPage(page);\n }).catch(function (e) { toast(errorText(e)); });\n }\n function partnerForm(P) {\n var F = P.form;\n var msg = el('div');\n var inp = function (key, ph, type) { var i = el('input', { className: 'input', value: F[key] || '', placeholder: ph || '', type: type || 'text', autocomplete: 'off' }); i.addEventListener('input', function () { F[key] = i.value; }); return i; };\n var save = el('button', { className: 'btn primary', onclick: function () {\n msg.textContent = '';\n save.disabled = true;\n var body = { name: F.name, baseUrl: F.baseUrl, clientId: F.clientId, clientSecret: F.clientSecret || '', notes: F.notes };\n (F.isNew ? api('/api/tenants', 'POST', body) : api('/api/tenants/' + F.id, 'PUT', body)).then(function (r) {\n P.form = null; P.data = null;\n toast((F.isNew ? 'Added ' : 'Saved ') + r.tenant.name + (r.note ? ' · ' + r.note : ''));\n renderPartner();\n }).catch(function (e) { save.disabled = false; msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), F.isNew ? 'Test and add' : 'Save');\n var remove = F.isNew ? null : el('button', { className: 'btn ghost', onclick: function () {\n remove.replaceWith(el('span', { className: 'inline' }, el('span', { text: 'Remove ' + F.name + ' and its saved secret from this computer?' }),\n el('button', { className: 'btn sm', onclick: function () { api('/api/tenants/' + F.id, 'DELETE').then(function () { P.form = null; P.data = null; P.sel = null; toast('Removed'); renderPartner(); }); } }, 'Yes, remove'),\n el('button', { className: 'btn sm ghost', onclick: function () { renderPartner(); } }, 'No')));\n } }, icon('trash'), 'Remove');\n return el('section', { className: 'card', style: 'margin-bottom:14px' },\n el('h3', { style: 'margin-top:0', text: F.isNew ? 'Add a tenant' : 'Edit ' + F.name }),\n el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Customer name' }), inp('name', 'e.g. Acme Corp')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Tenant' }), inp('baseUrl', 'acme, or paste the ISC address from your browser')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID' }), inp('clientId')),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: F.isNew ? 'Client secret' : 'Client secret (leave empty to keep the saved one)' }), inp('clientSecret', '', 'password'))),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Notes (optional)' }), inp('notes', 'e.g. contract ends June, contact: J. Smith')),\n el('p', { className: 'muted small', text: 'Use a personal access token or API client of a read-only identity in that tenant (for a customer\\u2019s tenant, ask the customer for one). The secret is kept only in the owner-only secrets file on this computer and is never shown again. IdentityScope tests the connection before saving.' }),\n el('div', { className: 'bar' }, save, el('button', { className: 'btn ghost', onclick: function () { P.form = null; renderPartner(); } }, 'Cancel'), el('span', { style: 'flex:1' }), remove),\n msg);\n }\n\n\n function tokenNote(r) {\n var d = r && r.token ? r.token.daysToExpiry : null;\n if (d === null || d === undefined || d > 30) return null;\n return el('div', { className: 'small', style: 'margin-top:2px;white-space:nowrap;font-weight:600;color:' + (d <= 14 ? 'var(--danger)' : 'var(--warn)'), title: 'The personal access token IdentityScope uses for this tenant', text: d < 0 ? 'Token expired' : d === 0 ? 'Token expires today' : 'Token: ' + d + ' day' + (d === 1 ? '' : 's') + ' left' });\n }\n // ---------- in-app guidance ----------\n var HELP = {\n reports: { title: 'Reports', what: 'Ready-made reports and the ones you build. Pick a report, fill in its options and press Preview (first 500 records, quick) or Run report (everything).', read: ['\"Show: Count by\" turns any report into a summary: one row per value with how many.', 'Click a column heading to sort; type in \"Filter these rows\" to search what is shown.', 'Downloads (Excel, CSV, HTML) always contain every row, also when the screen shows only the first part.'], act: ['Customize makes your own copy you can change with drop-downs.', 'New report: pick what a row is (identities, accounts, access...), add filters, choose columns, save.', 'Schedule this report sends it by email or Teams on a schedule.'], perms: 'Depends on the data: search needs sp:search:read; accounts, entitlements and sources need their read permissions. The Health check shows what your sign-in can read.' },\n checks: { title: 'Instant check', what: 'Every daily check in one click. Each tile is green (fine), amber (look at it) or red (act now), based on the limits you set.', read: ['\"N new\" means rows that were not there at the previous check, so you see what changed since yesterday.', 'The small line is the trend: the value of each past check, kept on this computer.', 'Grey \"(last time)\" tiles show the previous result until you run the checks again.', '\"Could not check\" usually means the sign-in or token lacks a permission for that check.'], act: ['Click a tile for the rows behind it, how to fix it and a link to the full report.', 'Limits sets when a check turns amber or red, the period it looks at, or switches it off.', 'Schedules > New schedule > \"Instant check\" with \"only when something is new or got worse\" gives a quiet daily alert.'], perms: 'Each check needs read access to its data (search, sources, VA clusters, workflows, campaigns, access requests).' },\n 'lookup-person': { title: 'Identity lookup', what: 'One identity on one page: lifecycle state, manager, every account, all access, the last 30 days of provisioning, access requests and audit events.', read: ['The coloured lines at the top are hints: red needs action (locked account, failed provisioning), amber is worth checking (disabled account, no manager or email).', '\"Assigned directly\" means the entitlement was given on its own, not through a role or access profile.'], act: ['Use it for \"why can’t this identity log in\" and \"why does this identity have this access\".', 'Open in ISC jumps to the identity in the admin console.'], perms: 'Search (identities, account activities, events); access requests need an admin.' },\n 'lookup-source': { title: 'Source lookup', what: 'Every source with its connection status and last aggregation; click one for counts, aggregations, errors, configuration and what depends on it.', read: ['\"Last successful aggregation\" comes from audit events, so it only reaches back as far as ISC keeps them.', '\"Used by\" lists the identity profiles that read this source; a failing authoritative source affects every identity in that profile.', 'The configuration hides passwords, secrets, keys and encrypted values.'], act: ['Open in ISC goes to the source’s configuration (Admin > Connections > Sources).', 'Connector diagnostics (test connection, ping VA cluster, peek) are off until you turn them on, and ask before every action.'], perms: 'Sources, accounts and entitlements read; diagnostics need source admin rights.' },\n ownership: { title: 'Ownership', what: 'Who owns every source, role, access profile, entitlement, workflow and identity profile, what has no owner, and what is owned by identities who left.', read: ['Owners who left or no longer exist cannot approve requests or review access, so those requests and reviews get stuck.', '\"Not found\" means the owner identity no longer exists.'], act: ['Hand over the objects listed under \"Owned by identities who left\" (Excel download for the handover).', 'Click an owner to see everything they own before they change jobs.'], perms: 'Read access to sources, roles, access profiles, entitlements, workflows and identity profiles.' },\n tenant: { title: 'Tenant', what: 'The size and health of the setup: counts, Virtual Appliances, workflows, transforms, API credentials and a comparison with another tenant. To try transforms and workflows before changing them, see Build & test.', read: ['A dash in the overview means the sign-in or token cannot read that number.', 'Virtual Appliances: anything not NORMAL is listed first. A VA in error stops aggregation and provisioning for its sources.', 'Transforms \"not referenced\" are not used by an identity profile or another transform; they may still be used in provisioning policies or rules.', 'API credentials: personal access tokens show their expiry date; API clients have none in ISC. \"Owner has left\" means the owner is inactive or in a leaver lifecycle state; the token keeps working until someone deletes it.'], act: ['API credentials: renew tokens that expire soon before scripts and schedules stop, and delete tokens of identities who left after checking with their team.', 'Compare tenants: connect production with a token (kept in memory only) to see what differs from sandbox before you move changes.'], perms: 'idn:remote-client:read, sp:workflow:read, sp:workflow-execution:read, idn:transform:read. API credentials: sp:all-personal-access-tokens:read (or sp:my-personal-access-tokens:read for your own) and sp:oauth-client:read.' },\n 'build-tlab': { title: 'Transform lab', what: 'Run a transform on this computer and see each step. Nothing is saved to ISC.', read: ['\"Only ISC can say\" marks custom rules, uniqueness checks and anything else the offline engine cannot know.', 'Assumptions are listed where SailPoint\\'s documentation does not say what happens.', 'Try it on real identities with an attribute to compare: \"different\" shows where the result is not what ISC holds now. Check a mapping this way before trusting a result.'], act: ['Save test cases for a transform and run them after every change.'], perms: 'idn:transform:read; on identities also sp:search:read, idn:accounts:read and idn:identity-profile:read.' },\n 'build-impact': { title: 'Transform impact', what: 'Where each transform is used: identity profiles, other transforms and provisioning policies, also through chains of transforms, and how many identities that covers.', read: ['\"Through A → B\" means the transform is used inside A, which is used by B.', 'Identities counts are the identities in the identity profiles that use it.', 'Rules run code IdentityScope cannot read, so anything a rule does is not included.'], act: ['Before changing a transform, try the change in the Transform lab on identities of every profile listed.', 'Transforms used by nothing are candidates for clean-up; check rules first.'], perms: 'idn:transform:read, idn:identity-profile:read, idn:sources:read, sp:search:read.' },\n 'build-policy': { title: 'Account create preview', what: 'What a source\\'s provisioning policy would produce for one identity, worked out on this computer. Nothing is created.', read: ['\"Not set here\" means the field has no transform in the policy; the value comes from the source, a rule or the connector.', 'Password fields are never worked out or shown. Generators and rules are only known to ISC.', 'A required field that would be empty stops the account from being created.'], act: ['Preview a joiner before their start date to find empty required fields.'], perms: 'idn:sources:read, sp:search:read, idn:accounts:read, idn:transform:read.' },\n 'build-wlab': { title: 'Workflow lab', what: 'Walk a workflow step by step on this computer with a trigger you give it. Nothing is called, so the workflow does not need to be disabled.', read: ['Replay reads the history of real runs (kept 90 days by ISC). \"Same path\" means the simulator took the branches ISC took.', 'Secrets in steps show as \"(hidden)\".', 'Loops run their first five items.'], act: ['\"Replay with my edits\" shows which real runs would take a different path before you publish a change.'], perms: 'sp:workflow:read, sp:workflow-execution:read.' },\n 'build-health': { title: 'Workflow health', what: 'Runs and failures of each workflow per week, and the causes of failed runs grouped.', read: ['Causes come from the history of failed runs; IDs, numbers and names are taken out so the same problem groups together.', 'Runs older than 90 days have no history in ISC.', '\"Enabled, never ran\" can be normal for rare events; check the trigger if it should have run.'], act: ['A workflow that fails every run usually has an expired credential: see the Credential map.'], perms: 'sp:workflow:read, sp:workflow-execution:read.' },\n 'build-roles': { title: 'Role change preview', what: 'Who would gain or lose a role if its membership criteria changed.', read: ['\"Keeps it\" are identities who hold the role another way (request or assignment).'], act: ['Try the criteria here before saving them in ISC.'], perms: 'idn:role-unchecked:read, sp:search:read; account conditions also idn:accounts:read.' },\n 'build-drift': { title: 'Drift check', what: 'Compare the configuration now with an approved baseline: what was added, removed or changed since.', read: ['The baseline is a copy of a change-history snapshot, kept on this computer, so later snapshots cannot change it.', 'IDs, timestamps and secrets are not compared.'], act: ['Approve a baseline after each release to production, and check for drift before the next one.'], perms: 'The scopes of the Tenant page plus idn:sources:read, idn:identity-profile:read, idn:role-unchecked:read and sp:search:read.' },\n 'build-cmap': { title: 'Credential map', what: 'Every client ID, user and endpoint used in workflows and source connections.', read: ['Secret values are never read; \"typed in\" only means the field is filled in.', 'HTTP Request steps before version 3 cannot use Parameter Storage.'], act: ['When a secret is rotated in an application, update each place listed (or once in Parameter Storage).'], perms: 'sp:workflow:read, idn:sources:read.' },\n partner: { title: 'All tenants (partner overview)', what: 'The instant check of every tenant you look after, side by side: sandbox, QA and production of one company, or each customer of a partner.', read: ['Each row is one tenant; each column one check. Green is OK, amber needs a look, red is a problem, grey could not be checked.', '\"new\" marks a check that is new or worse since that tenant\\'s previous check.', 'Rows with problems come first. Click a number for the cause and how to fix it; Open switches to that tenant with all pages.'], act: ['Schedule \"All tenants\" daily (Schedules page) to get one summary by email or Teams, only when something is new or worse.', 'Use a read-only token for each tenant: the overview never changes anything, but a read-only identity keeps it that way by design.'], perms: 'Per tenant: the read scopes the instant check uses (search, sources, account activities, events, clusters, workflows, campaigns, access request status).' },\n sod: { title: 'Separation of duties', what: 'Rules for access one identity should not hold together, and everyone who breaks them.', read: ['An identity breaks a rule when they hold any item of side A and any item of side B, however they got it (role, access profile, request).', 'Write items as ISC shows them; add the source in brackets to be exact, e.g. \"Domain Admins (Active Directory)\". Case is ignored.', 'Some ISC editions have their own SOD policies; these rules work without them and stay on this computer.'], act: ['Remove one side, or record an approved exception (mitigating control) for the auditors.', 'The Evidence pack can include the violations list.'], perms: 'Search on identities (sp:search:read).' },\n changes: { title: 'Change history', what: 'What changed in the configuration between two days: sources, transforms, identity profiles, roles, access profiles and workflows.', read: ['Drift from an approved baseline: approve the snapshot of a release, then \"Check for drift now\" lists what was added, removed or changed since. The baseline is a copy kept on this computer.', 'Added and Removed are by name; a renamed object shows as one removed and one added.', 'Snapshots hide secrets and ignore IDs and timestamps, so only real setting changes show.', 'Snapshots are kept on this computer (the \"changes\" folder), one per day, at most 400 days.'], act: ['Schedule the instant check daily: it saves a snapshot every day by itself.', 'Use it after \"something broke yesterday\": compare yesterday with today.'], perms: 'Read on sources, transforms, identity profiles, workflows; search on roles and access profiles.' },\n evidence: { title: 'Evidence pack', what: 'One zip with the reports auditors ask for, a README and SHA-256 fingerprints of every file.', read: ['README.txt says which tenant, when, by whom and with which version it was produced.', 'SHA256SUMS.txt lets an auditor check that no file was changed afterwards (sha256sum -c SHA256SUMS.txt).', 'A part the sign-in cannot read is listed as NOT INCLUDED, with the reason.'], act: ['Build it at the start of the audit and hand the zip over as is.', 'Keep a copy: rebuilding later gives today’s data, not the data of that day.'], perms: 'Whatever each part reads: search, sources, campaigns and certifications, access requests.' },\n reclaim: { title: 'License reclaim', what: 'Enabled accounts of identities who left, and accounts nobody signed in with for a long time, with what they cost.', read: ['Authoritative sources (HR) and disabled accounts are skipped.', 'Dormant accounts need a sign-in date attribute per source; without one only leavers are listed.', 'Savings are an estimate: accounts times the monthly cost you entered.'], act: ['Download the list and agree with the application owners which accounts to disable or delete in ISC.', 'Check service and shared accounts before removing them.'], perms: 'Search on identities, accounts and sources read.' },\n requests: { title: 'Access requests', what: 'How fast access requests are approved and fulfilled, who approves slowly, and what is requested and rejected most.', read: ['\"Typical\" is the median: half of the requests were faster.', 'Waiting now counts approvals that are still open, per approver.', 'A high reject rate on an item often means it is requestable by the wrong people or badly described.'], act: ['Remind or replace slow approvers; add a backup approver.', 'Make often-approved items part of a role so nobody has to request them.'], perms: 'Access request status read; an admin sees everyone’s requests.' },\n mining: { title: 'Find candidate roles', what: 'Entitlements most identities with the same attribute value (for example the same department) already hold: candidates for a birthright role.', read: ['\"Held by\" shows how many identities of the group hold the item.', '\"Already in a role\" means an existing role gives it, directly or through an access profile.'], act: ['Try the candidate in \"Preview a role change\" with the attribute as criteria, then create the role in ISC.'], perms: 'Search on identities, roles and access profiles.' },\n certs: { title: 'Certifications', what: 'Campaign progress, every reviewer’s progress and decisions, and reviews that may be rubber-stamped.', read: ['At risk: due within 7 days and under 80% complete. Overdue: past the deadline and not complete.', 'Approve % close to 100 on large reviews, or a sign-off minutes after the review opened, are signals worth a conversation, not proof.', 'A high share of revokes is usually healthy: reviewers are actually removing access.'], act: ['Download the reviewer list and send reminders to the reviewers who are behind.', 'Reassign reviews of reviewers who are absent, or extend the deadline in ISC.'], perms: 'A certification admin’s sign-in or token sees every reviewer; others may see only their own reviews.' },\n roles: { title: 'Role tools', what: 'Compare roles side by side, and preview who would gain or lose a role before you change its membership criteria in ISC.', read: ['The preview evaluates the criteria like ISC does, ignoring upper and lower case in values.', '\"Each condition on its own\" shows how many identities match each condition, how many have the attribute at all, and its most common values: the quickest way to spot a typo.', 'Only attributes that are searchable in ISC can be checked.', '\"Keeps it (other way)\" are identities who hold the role by request or assignment, not by the criteria.'], act: ['Show JSON gives the criteria in the format of the ISC role API.', 'Download the list of identities affected for the change approval.'], perms: 'Role read (idn:role-unchecked:read or idn:role-checked:read) and search.' },\n coverage: { title: 'Review coverage', what: 'Which sources and privileged entitlements a certification campaign reviewed in the period, and which none did.', read: ['A source counts as reviewed when at least one review item named it.', 'Privileged entitlements are matched by ID, or by name and source.'], act: ['Add the sources and privileged entitlements that were not reviewed to your next campaign.', 'Download the list as evidence that coverage was checked.'], perms: 'idn:campaign:read, idn:sources:read, sp:search:read.' },\n outliers: { title: 'Access outliers', what: 'Active identities with far more access items than the median of their group (department by default).', read: ['Groups need at least 5 identities; the difference must be at least 10 items.', 'Admins and long-serving staff often have more access; an outlier is a place to start, not a finding.'], act: ['Review the top outliers with their managers first.', 'Compare by job title or another attribute if department is too broad.'], perms: 'sp:search:read on identities.' },\n speed: { title: 'Provisioning speed', what: 'How long account changes take per source, and access removals (disable, delete) that took longer than your limit or are still not done.', read: ['Time runs from when ISC started the change to its last update.', 'For connectors that work through tickets or queues, waiting time is included.'], act: ['Follow up removals \"not done\" first: someone who left may still have access.', 'Use the 90% figure per source to agree a realistic target with application owners.'], perms: 'sp:search:read on account activity.' },\n 'wn-quality': { title: 'Identity data', what: 'Active identities without a manager, an email or an attribute you choose, and emails used by more than one identity.', read: ['Identities who left are not checked.', 'Shared emails often mean duplicate identities, test accounts or a mapping problem.'], act: ['Fix the data in the HR source; ISC takes it from there.', 'Missing managers first: approvals and manager certifications depend on them.'], perms: 'sp:search:read on identities.' },\n 'wn-joiners': { title: 'Missed joiners', what: 'Active identities missing an account on a source that nearly everyone in their identity profile has (a birthright account), and identities past their start date still in a pre-hire lifecycle state.', read: ['Birthright sources are worked out per identity profile; nothing needs setting up.', 'Identities created within the grace period are not flagged yet.'], act: ['Check the provisioning policy and the account activity for the identity; a failed create often explains it.', 'Fix the lifecycle state or the start date for identities stuck in pre-hire.'], perms: 'sp:search:read on identities.' },\n 'wn-leavers': { title: 'Missed leavers', what: 'Identities whose account on their own authoritative (HR) source is disabled while ISC treats them as active, and leavers who still have enabled accounts, roles or access profiles.', read: ['Accounts on the HR source and on ISC itself are not counted for leavers.', 'Identities active after their end date are on the End dates tab.'], act: ['For \"HR says gone\", check the lifecycle state rules: they should follow the HR status.', 'Disable or remove what leavers still have, starting with privileged accounts.'], perms: 'sp:search:read on identities.' },\n movers: { title: 'Mover leftovers', what: 'Access that almost nobody else in the identity\\u2019s group (department by default) has.', read: ['Often left over from a previous job, or granted as a one-off.', 'Groups need at least 10 identities.'], act: ['Ask the manager whether the identity still needs it; remove what is left from a previous job.'], perms: 'sp:search:read on identities.' },\n adminaccts: { title: 'Admin accounts', what: 'Accounts named like admin, svc, test or shared that are linked to an identity.', read: ['A word matches only as a separate part of the account name.', 'You can change the words.'], act: ['Give service accounts an owner instead of linking them to an identity; remove test accounts; keep admin accounts separate and reviewed.'], perms: 'sp:search:read on identities.' },\n exceptions: { title: 'Exceptions', what: 'Findings someone accepted, with a reason, who accepted it and an end date.', read: ['In force: left out of the instant check until the end date.', 'Expired: shown again; decide again or fix it.'], act: ['Accept from the details of an instant check tile; end an exception here when the reason no longer holds.', 'Include the register in the evidence pack.'], perms: 'None: kept on this computer.' },\n 'wn-massch': { title: 'Mass changes', what: 'Provisioning per day, with a spike flagged when today or yesterday is far above the usual day.', read: ['Usual = the median day of the period before.', 'A spike lists the sources behind it.'], act: ['Check the last HR file, transform or role change before the next aggregation; pause the source if needed.'], perms: 'sp:search:read on account activities.' },\n 'wn-loops': { title: 'Provisioning loops', what: 'The same change for the same identity and source sent many times.', read: ['Often an attribute sync whose value the connector changes back, or a request ISC keeps re-sending.'], act: ['Fix the transform or the connector mapping; remove the stale assignment.'], perms: 'sp:search:read on account activities.' },\n 'wn-outside': { title: 'Changed outside ISC', what: 'Account states that ISC did not cause: disabled without an ISC disable, or enabled again after ISC disabled them.', read: ['Account state is from the last aggregation.', 'By default every disable and enable ISC still has on record is checked, not only recent ones.', 'The last column shows the last disable or enable ISC itself sent to the account.'], act: ['Ask the application team who changed it; turn on native change detection where the source supports it.'], perms: 'Read access to accounts and account activities.' },\n 'wn-syncdrift': { title: 'Attribute sync drift', what: 'Attributes ISC syncs to a source whose value on the account differs from ISC, plus failed syncs.', read: ['Only active identities and enabled accounts are compared.', 'Manager is compared by display name.'], act: ['Run an attribute sync for the identity, or fix the target attribute mapping.'], perms: 'idn:attr-sync-source-config:read (ORG_ADMIN or HELPDESK) and read access to accounts.' },\n 'wn-groupappr': { title: 'Group approvals', what: 'Pending approvals assigned to a governance group, with how many members are still active.', read: ['\"Nobody can approve\" means every member has left.'], act: ['Add active members to the group or forward the approval.'], perms: 'An org admin token; idn:workgroup:read.' },\n 'wn-mgrleft': { title: 'Manager left', what: 'Active identities whose manager has left or is not in ISC.', read: ['Narrow to contractors with a search query.'], act: ['Fix the manager in the HR or NERM source.'], perms: 'sp:search:read on identities.' },\n leavertimes: { title: 'Leaver removal times', what: 'Per leaver: when leaving started and how long each account took to be disabled.', read: ['Start is the lifecycle state change event when ISC has one, otherwise the first disable ISC sent.', 'Accounts on the authoritative source are left out.'], act: ['Fix slow sources first; give auditors the download.'], perms: 'sp:search:read on identities, events and account activities.' },\n attrhist: { title: 'Attribute changes', what: 'Changes of the attributes you follow, between looks by IdentityScope.', read: ['The first look records values only.', 'Kept on this computer, owner-only.'], act: ['Schedule a look every day for a running history.'], perms: 'sp:search:read on identities.' },\n owners: { title: 'Entitlement owners', what: 'Each entitlement owner with what they own and how many identities hold it.', read: ['Owners who left come first.', 'Holders are counted for up to 3,000 entitlements.'], act: ['Give each owner their filtered download; replace owners who left.'], perms: 'Read access to entitlements; sp:search:read on identities.' },\n rules: { title: 'Rule usage', what: 'Every connector and cloud rule and where it is used.', read: ['Cloud rules can only be listed with the opt-in SP-Config export.', 'Rules called from other rules or workflows are not seen.'], act: ['Remove unused rules after a check; deploy missing ones before they are called.'], perms: 'Read access to sources, transforms, identity profiles and connector rules; sp:config:read for the export.' },\n 'nerm-overview': { title: 'End dates and sponsors', what: 'Active non-employees past or near their end date, and sponsor problems.', read: ['The end date comes from a date attribute with end, expiry or termination in its name, unless you name one.', 'Sponsors are owner attributes, matched to ISC by email.'], act: ['Ask sponsors to renew or end the engagement; give profiles without a sponsor a new one.'], perms: 'A NERM scope on the API token (nerm:api:read-only), plus sp:search:read in ISC.' },\n 'nerm-sync': { title: 'NERM vs ISC', what: 'Profiles whose NERM status and ISC identity state differ.', read: ['Matched through the accounts on the NERM source in ISC.', 'Only profile types marked as synced to ISC are compared.'], act: ['Aggregate the NERM source, then check the identity profile and lifecycle states.'], perms: 'nerm:api:read-only, and read access to accounts in ISC.' },\n 'nerm-sessions': { title: 'Waiting workflows', what: 'NERM workflow sessions still waiting on a step.', read: ['Age shows only when NERM returns the start date.'], act: ['Follow up with the approver or reviewer in NERM.'], perms: 'nerm:api:read-only (or workflow-operator).' },\n 'nerm-risk': { title: 'High risk', what: 'Profiles at the highest NERM risk level.', read: ['Risk levels and scores come from NERM.'], act: ['Review these first in certifications and end dates.'], perms: 'nerm:api:read-only.' },\n 'nerm-users': { title: 'Portal users who left', what: 'NERM users who can still sign in although their ISC identity has left.', read: ['Users not linked to an ISC identity are counted in a note.'], act: ['Disable the user in NERM.'], perms: 'nerm:api:read-only, plus sp:search:read in ISC.' },\n outmodel: { title: 'Outside roles', what: 'Entitlements active identities hold directly instead of through a role or access profile.', read: ['Directly = by request, by an admin, or found on the source by aggregation.', '\"Never given by a role\" entitlements are not in any role or access profile that someone has.'], act: ['Put common direct access into a role or access profile; review privileged direct access first.'], perms: 'sp:search:read on identities.' },\n composition: { title: 'What is in every role', what: 'One row per role, access profile and entitlement.', read: ['Entitlements put straight into a role have no access profile.', 'Empty roles grant nothing.'], act: ['Give the download to role owners for review; remove or fill empty roles.'], perms: 'idn:role-unchecked:read and idn:access-profile:read.' },\n reassigned: { title: 'Reassigned reviews', what: 'Certifications passed on to another reviewer.', read: ['Shows who passed it on, the reason given, and whether the new reviewer is still active.'], act: ['Ask for a reason where none was given; reassign reviews that sit with someone who left.'], perms: 'A certification admin token (idn:campaign:read).' },\n 'wn-aggsafe': { title: 'Aggregation safety', what: 'Per source: the delete threshold, how many account aggregations ran and failed, and sources that did not aggregate.', read: ['A high delete threshold lets one broken read remove most accounts.', 'Sources fed by file upload aggregate only when a file is loaded.'], act: ['Lower thresholds of 50% or more; fix sources whose aggregations keep failing.'], perms: 'Read access to sources; sp:search:read on events.' },\n 'wn-svc': { title: 'Service accounts', what: 'Service and machine accounts with no owner, an owner who left, or no recent use.', read: ['Owners and last-used dates come from Machine Identity Security when the tenant has it.'], act: ['Give every enabled account an owner; disable the unused ones after checking.'], perms: 'idn:mis-account:read, or read access to accounts.' },\n 'wn-multi': { title: 'Several accounts', what: 'Identities with more than one account on the same source.', read: ['On the authoritative source it usually means a duplicate HR record or a rehire.'], act: ['Fix the correlation or merge the HR records.'], perms: 'sp:search:read on identities.' },\n 'wn-pwfail': { title: 'Password failures', what: 'Password changes, resets and syncs that failed.', read: ['From audit events of type password activity.'], act: ['Fix the source connection or password policy mismatch; ask the person to change the password again.'], perms: 'sp:search:read on events.' },\n 'wn-lcset': { title: 'Lifecycle settings', what: 'What each lifecycle state of each identity profile does to accounts and access.', read: ['A leaver state is one where ISC marks identities inactive, or whose name says so.', 'Findings: leaver states that turn nothing off, or leave some sources on; states switched off that still hold identities.'], act: ['Add the missing sources to the state’s account settings in the identity profile, or confirm a workflow handles them.'], perms: 'idn:identity-profile:read, idn:identity-profile-lifecycle-state:read and idn:sources:read.' },\n 'wn-govgroups': { title: 'Governance groups', what: 'Every governance group with its owner, members and where it is used.', read: ['A group with no active member cannot approve or review anything sent to it.'], act: ['Add active members, replace owners who left, delete groups that are not used.'], perms: 'idn:workgroup:read; sp:search:read on identities.' },\n 'logs-ccg': { title: 'Connector log (ccg.log)', what: 'Reads the connector log of a Virtual Appliance from a copy on this computer and shows the errors and warnings grouped and counted, per source, with the full error detail.', read: ['ISC has no API for this file: copy it from the appliance (/home/sailpoint/log/ccg.log) or point to a folder where it is dropped.', 'Repeats are one row with a count; IDs, numbers and names are ignored when grouping.', 'Times are as written in the log (UTC).', 'Values that look like passwords, tokens or keys are hidden.'], act: ['Open the detail of the most frequent error for the source that fails; the first line of the error detail usually names the cause (timeout, permission, certificate, bad attribute).', 'Compare the time with “What ISC recorded”.'], perms: 'None in ISC. The file must be readable on this computer.' },\n 'logs-isc': { title: 'What ISC recorded', what: 'One timeline of aggregations, source changes and provisioning errors per source, and the state of the Virtual Appliances now.', read: ['This is ISC’s summary of each error, not the full connector log.', 'Event names and statuses are shown as ISC wrote them.'], act: ['A source failing while its cluster is not NORMAL: fix the appliance first.', 'For the detail behind an error of a Virtual Appliance source, read its ccg.log in the other tab.'], perms: 'sp:search:read on events and account activities; idn:sources:read; idn:remote-client:read for the appliances.' },\n 'wn-privgain': { title: 'Privileged access gained', what: 'Privileged entitlements an identity holds now and did not hold at the previous look, each checked against what ISC itself provisioned in between.', read: ['The first run only remembers who holds what; findings appear from the second run.', '“No ISC record” means the access appeared at aggregation without ISC provisioning it: granted on the application, or arrived with a new account.', 'Kept on this computer: identity and entitlement IDs, and the findings of the last 90 days.'], act: ['Ask the application owner who granted it; remove it or put it through a request so it is approved and reviewed.'], perms: 'sp:search:read on identities and account activities.' },\n 'wn-outacct': { title: 'Accounts created outside ISC', what: 'Accounts that appeared in the period and that ISC marks as aggregated, not provisioned, on sources that are not authoritative.', read: ['A source where most accounts are new was probably just connected; its accounts are listed last.', 'Accounts without an origin in ISC are left out and counted in a note.'], act: ['An account nobody owns that already has access: find who created it on the application, then correlate or remove it.'], perms: 'idn:accounts:read, idn:sources:read; sp:search:read for the owners.' },\n 'wn-sensitive': { title: 'Sensitive changes', what: 'What changed in the configuration that touches a control, compared with an earlier snapshot on this computer, plus API clients and tokens created since.', read: ['Needs two snapshots: the first run takes one; schedule a daily snapshot for a steady record.', '“Who” is the last identity ISC’s audit log names for an object of the same name; it can be empty.', 'High: rules, lifecycle states, password and SOD policies, event subscriptions, anything removed, and source safety settings.'], act: ['Confirm each change was planned and approved; revert what was not.'], perms: 'The reads of Change history; sp:search:read for who; an org admin token for API credentials.' },\n 'wn-risk': { title: 'Risk by identity', what: 'The signals of the threat screens added up per identity.', read: ['Identities on more than one screen come first.', 'The score only orders the list.', 'Matched by display name: two identities with the same name count as one.'], act: ['Start with the identities on several screens; open the screen named in each signal for the detail.'], perms: 'Those of the threat screens; a screen this sign-in cannot read is left out and named.' },\n 'wn-upcoming': { title: 'Coming up', what: 'Identities whose start or end date falls in the next days, the lifecycle state they are in now, and what the states of their identity profile do.', read: ['ISC decides the state from the profile’s mapping; this page does not predict it.', '“To check” lists what could go wrong on the day: no manager, no leaver state, a leaver state that leaves accounts on.'], act: ['Fix the lifecycle state or the manager before the date; for starters, check the birthright accounts exist.'], perms: 'sp:search:read on identities; idn:identity-profile:read, idn:identity-profile-lifecycle-state:read and idn:sources:read for the states.' },\n 'wn-stuckreq': { title: 'Stuck requests', what: 'Access requests still running after the limit, the phase each is in and on whom it waits, with the sources ISC keeps re-sending the same change to.', read: ['ISC shows a request as pending until its last phase ends, even after it was approved.', 'A churning source fills the queue that requests wait in.'], act: ['Waiting for an approver: remind or reassign in ISC. Waiting in provisioning: check the source, its Virtual Appliance and Warnings > Provisioning loops.'], perms: 'An org admin token for all requests; sp:search:read on account activities.' },\n 'wn-signins': { title: 'Sign-in signals', what: 'Sign-ins to ISC that deserve a look: many failures for one identity, a success right after a run of failures, sign-ins by identities who have left, and one network address trying many identities.', read: ['From ISC audit events of type AUTH. Sign-ins handled by a separate identity provider are recorded there, not here.', 'The address table appears only if the events carry a network address.'], act: ['Check with the identity; reset the password and sign-in method if they did not do it; disable identities that left.'], perms: 'sp:search:read on events and identities.' },\n 'wn-selfappr': { title: 'Self-approvals', what: 'Access requests approved by the identity who gets the access, or by whoever requested it for someone else.', read: ['Approvals by a governance group are not attributed to a member.'], act: ['Change the approval settings so the owner or manager step cannot be the requester; review what was granted.'], perms: 'An org admin token (idn:access-request-status:read).' },\n 'wn-adminact': { title: 'Admin activity', what: 'Changes to tenant settings, sources, users and access items, by who made them.', read: ['Changes ISC made itself are left out.', '\"Not an identity in ISC\" is an API client, a token or a deleted identity.', 'Event names are shown as ISC wrote them.'], act: ['Confirm each change was planned; remove admin rights and tokens of identities who left.'], perms: 'sp:search:read on events and identities.' },\n 'wn-spikes': { title: 'Access spikes', what: 'Identities who were given many access items in one day.', read: ['New joiners and role changes do this legitimately.'], act: ['Check who requested it and whether the identity changed job; review what was added.'], perms: 'sp:search:read on account activities and identities.' },\n trail: { title: 'Request trail', what: 'Every access request in the period with each approval step: who decided, approved or rejected, their comment and when, and how the request ended.', read: ['\"Was\" shows the original approver when a step was forwarded or reassigned.', 'A request with no approval step was auto-approved or needed no approval.', '“How fast approvers decide” times each step from the step before it (or from submission) to the decision.', 'The download has one row per approval step.'], act: ['Give the download to auditors as approval evidence.', 'Requests that failed after approval: check the error on the request and the source.'], perms: 'An org admin token (idn:access-request-status:read); other users only see their own requests.' },\n chain: { title: 'Approver chain', what: 'For every access profile, role and requestable entitlement: who approves a request, in what order, and who approves a revoke.', read: ['Steps are in approval order; \"Manager of the identity\" is the manager of whoever the access is for.', 'Problems: no approval at all, an owner step with no owner, a governance group that is empty or deleted.', 'At most 300 requestable entitlements are read (one call each).'], act: ['Add an owner, fix the governance group, or add an approval step in the access item settings in ISC.'], perms: 'Read access to access profiles, roles, entitlements, sources and governance groups.' },\n 'wn-expiry': { title: 'Accounts expiring', what: 'Accounts whose expiry attribute is within the period, and accounts that expired but ISC still shows as enabled.', read: ['Read: never (in words, 0, -1, the AD maximum), FILETIME, Unix seconds or milliseconds, LDAP time, ISO dates, MM/dd/yyyy and dd/MM/yyyy with or without a time, and month names.', 'Day-first dates are detected per source (a value like 31/12/2026 anywhere).', 'The attribute must be in the source account schema and aggregated.'], act: ['Ask the manager whether the account should be extended; for expired but enabled accounts, check the leaver process.'], perms: 'Read access to accounts on the chosen sources.' },\n 'wn-revokes': { title: 'Revokes not done', what: 'Items a reviewer revoked in a certification that the identity still holds.', read: ['ISC removes revoked access only after sign-off, so unsigned certifications show \"waiting for sign-off\".', '\"Still held\" after sign-off: the removal failed, is still running, or the item also comes from a role, access profile or another assignment.'], act: ['Look at the account activity for the identity (Identity lookup), fix the source or connector, and remove the item again.'], perms: 'A certification admin token sees every campaign; others only see their own reviews.' },\n 'wn-ending': { title: 'Access ending', what: 'Access granted through a request with an end date. ISC removes it on that date without asking anyone.', read: ['Grouped by manager so you can tell each manager what their people will lose.', 'Comes from completed access requests that had an end date.'], act: ['If the access is still needed, the identity requests it again with a later end date before it ends.'], perms: 'idn:access-request-status:read (an admin sees everyone’s requests); search on identities for managers.' },\n 'wn-stuck': { title: 'Waiting on leavers', what: 'Open certification reviews and pending access approvals assigned to someone who left or is no longer in ISC.', read: ['\"Has left\" means inactive or in a leaver lifecycle state.', 'Approvals assigned to a governance group are not listed; a group has other members.'], act: ['Reassign the reviews in the campaign and forward the approvals in ISC.', 'Hand over objects owned by identities who left on Lookup > Ownership.'], perms: 'idn:campaign:read, idn:access-request-status:read, search on identities.' },\n 'wn-reminders': { title: 'Review deadlines', what: 'Open certifications due within the period you choose, grouped by reviewer.', read: ['Decisions left is decisions total minus decisions made.', 'Reviewers who left are not in the copied emails.'], act: ['Copy the emails or open an email draft with the reviewers in BCC.', 'Reassign reviews of reviewers who are away.'], perms: 'idn:campaign:read; search on identities.' },\n 'wn-people': { title: 'End dates', what: 'Active identities whose end date is coming up, and identities still active after their end date.', read: ['Uses the identity attribute you set as the end date; contractors often have one.', 'Saving the attribute turns on the \"Active after end date\" tile in the instant check.'], act: ['Check with HR whether the identity really left, then fix the HR record or the lifecycle state.'], perms: 'sp:search:read on identities.' },\n 'wn-admins': { title: 'ISC admins', what: 'Everyone with a user level in ISC itself (Org admin, Source admin, Help desk and others), found as \"IdentityNow\" source entitlements.', read: ['\"New\" means not there at the previous look on this computer.', 'Last sign-in is not shown.'], act: ['Remove user levels of identities who left first, then review whether each Org admin still needs it.', 'Download the list as evidence for your yearly admin review.'], perms: 'sp:search:read on identities.' },\n 'wn-catalog': { title: 'Access catalog', what: 'Requestable entitlements, access profiles and roles without a description or owner, or whose owner left.', read: ['The score is the share of requestable items with a description and an active owner.', 'Sources with the lowest score come first.'], act: ['Ask application owners to write one plain sentence per item, starting with the lowest-scoring sources.', 'Give every requestable item an owner so approvals have someone to go to.'], perms: 'sp:search:read on entitlements, access profiles and roles.' },\n 'wn-growth': { title: 'Identity count', what: 'How many identities you have, how many are new each month, and when you reach your licensed number.', read: ['Until four weeks of counts are kept on this computer, the pace counts new identities only, so it is an upper estimate.', 'Scheduled instant checks keep one count per day.'], act: ['Enter your licensed number and check which identities your contract counts.', 'Plan the renewal before you reach it.'], perms: 'sp:search:read on identities.' },\n monthly: { title: 'Monthly report', what: 'How every daily check moved during a month, with highlights and the tenant’s size, for management.', read: ['Each day counts once: the last check of that day.', 'Lower is better for every check; green change is an improvement.'], act: ['Download it and open it in a browser, then print to PDF to send.', 'Schedule the instant check daily so every month has data.'], perms: 'None beyond the checks themselves; built from this computer’s history.' },\n schedules: { title: 'Schedules', what: 'Send reports or the instant check by email or Teams/Slack automatically, using Windows Task Scheduler.', read: ['Email goes only to addresses of active identities in ISC (shared mailboxes can be allowed one by one).', 'Chat messages carry counts and check results only, never names.'], act: ['\"Only when something is new or got worse\" keeps alerts quiet on good days.', 'Automatic runs need \"Remember my tenant\" with a token of a read-only reporting identity, because sign-ins expire.'], perms: 'The saved token needs read access to what the scheduled reports read.' }\n };\n var FIX = {\n 'provisioning-errors': ['Fix the top cause first: the tile and the \"grouped by cause\" report collapse hundreds of errors into a few problems.', 'Duplicate or invalid usernames: check the naming attribute in the source’s create account profile.', 'Timeouts or connection errors: check the source and its Virtual Appliance (Tenant > Virtual Appliances).', 'Missing required attribute: check the create account profile and the identity attribute it reads.'],\n 'aggregation-failures': ['Open the source (Lookup > Source) to see the error ISC recorded.', 'Common causes: an expired service account password, a changed firewall rule, or the Virtual Appliance being down.', 'After fixing, run the aggregation again from the source in ISC (Admin > Connections > Sources).'],\n 'stale-sources': ['Check the source’s aggregation schedule in ISC: it may be off or failing.', 'Sources loaded by file upload are not counted here.'],\n 'va-clusters': ['Check that the Virtual Appliance machine is running and can reach SailPoint over the network.', 'The appliance status and its logs are in the ISC admin console under Virtual Appliances; contact SailPoint support if it stays in error.'],\n 'workflow-failures': ['Open the workflow’s execution history in ISC to see the step that failed.', 'Common causes: expired credentials in an HTTP step, renamed attributes, or rate limits.'],\n 'sources-in-error': ['Connection problems: see failed aggregations above and use Test connection on the source page.', 'No owner: assign one in ISC; owners approve access and review the source.'],\n 'identity-errors': ['Read the error message in the detail table: often a transform that fails or a manager that cannot be found.', 'The \"Identity attribute mappings\" report shows where each attribute comes from; fix the mapping, then refresh the identity in ISC.'],\n 'stuck-requests': ['Open the request in ISC: usually waiting for an approver who left (see Lookup > Ownership) or a provisioning error.'],\n 'leavers-with-access': ['Check the leaver lifecycle state in the identity profile: its \"disable accounts\" list must include these sources.', 'Disable the remaining accounts, and check why the lifecycle state change did not reach them.'],\n 'campaigns-at-risk': ['Send reminders to the reviewers who are behind (Certifications page), reassign reviews of absent reviewers, or extend the deadline.'],\n 'lifecycle-gaps': ['Open Warnings > Missed joiners and Missed leavers for details; a missed joiner usually means a failed or missing provisioning policy, \"HR says gone\" usually means the lifecycle state is not driven by the HR status.'],\n 'slow-removals': ['Open Audit > Provisioning speed to see which source is slow; removals \"not done\" usually wait on a ticket, a queue or a failed connector.'],\n 'access-ending': ['Tell the managers on Warnings > Access ending; if the access is still needed, it must be requested again with a later end date.'],\n 'stuck-on-leavers': ['Reassign the certification reviews in the campaign and forward the approvals in ISC (list on Warnings > Waiting on leavers).'],\n 'admins-left': ['Remove the user level in ISC under Admin > Identities > the identity > User level, then check why the leaver process did not.'],\n 'past-end-date': ['Check with HR whether these identities left; then fix the HR record or the lifecycle state rules (list on Warnings > End dates).'],\n 'uncorrelated-growth': ['A sudden jump usually means a correlation rule stopped matching after an attribute changed, or new service accounts arrived.', 'Check the source’s correlation settings and the \"Uncorrelated accounts\" report for that source.']\n };\n function currentHelpKey() {\n var p = state.page || 'reports';\n if (p === 'partner') return 'partner';\n if (p === 'certs') return state.au.tab === 'certs' ? 'certs' : state.au.tab;\n if (p === 'monthly') return state.inz.tab;\n if (p === 'warnings') return state.wn && state.wn.tab === 'movers' ? 'movers' : 'wn-' + (state.wn ? state.wn.tab : 'ending');\n if (p === 'tenant' && state.tn) {\n var moved = { workflows: 'build-health', transforms: 'build-impact', cmap: 'build-cmap' }[state.tn.tab];\n if (moved) return moved;\n }\n if (p === 'roles' && state.roleTab === 'mining') return 'mining';\n if (p === 'build') return 'build-' + state.bt.tab;\n if (p === 'nerm') return 'nerm-' + nmState().tab;\n if (p === 'logs') return 'logs-' + lgState().tab;\n if (p === 'tenant' && state.tn && state.tn.tab === 'rules') return 'rules';\n if (p === 'roles' && state.roleTab === 'impact') return 'build-roles';\n if (p === 'lookup') return state.lk.tab === 'ownership' ? 'ownership' : state.lk.tab === 'source' ? 'lookup-source' : 'lookup-person';\n return p;\n }\n function openHelp() {\n var h = HELP[currentHelpKey()] || HELP.reports;\n var drawer = el('aside', { className: 'drawer', 'aria-label': 'Help' });\n drawer.appendChild(el('button', { className: 'btn sm', style: 'margin-bottom:12px', onclick: function () { close(); openFinder(); } }, icon('search'), 'Find any page, tab or report (Ctrl+K)'));\n var onKey = function (e) { if (e.key === 'Escape') close(); };\n var close = function () { back.remove(); document.removeEventListener('keydown', onKey); if (!$('btn-help').classList.contains('hidden')) $('btn-help').focus(); };\n document.addEventListener('keydown', onKey);\n var back = el('div', { className: 'drawer-back', onclick: function (e) { if (e.target === back) close(); } }, drawer);\n var list = function (title, items) { return items && items.length ? el('div', {}, el('h4', { text: title }), el('ul', {}, items.map(function (x) { return el('li', { text: x }); }))) : null; };\n drawer.appendChild(el('div', { className: 'bar', style: 'margin-bottom:6px' }, el('h3', { style: 'margin:0;flex:1', text: h.title }), el('button', { className: 'btn icon ghost', title: 'Close', onclick: close }, icon('x'))));\n drawer.appendChild(el('p', { text: h.what }));\n drawer.appendChild(list('How to read it', h.read));\n drawer.appendChild(list('What you can do', h.act));\n drawer.appendChild(el('div', {}, el('h4', { text: 'Permissions' }), el('p', { className: 'muted', text: h.perms })));\n var checklist = el('div');\n drawer.appendChild(el('div', {}, el('h4', { text: 'Getting started' }), checklist));\n renderChecklist(checklist);\n drawer.appendChild(el('div', {}, el('h4', { text: 'Getting help' }),\n el('p', { className: 'small', text: 'A support file lists versions, settings, schedules, recent errors and log lines, with secrets, names, email addresses, tenant addresses and IDs removed. Read it before you send it to whoever helps you.' }),\n el('a', { className: 'btn sm', href: '/api/support/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download a support file')));\n var upd = el('div');\n drawer.appendChild(upd);\n renderUpdates(upd);\n drawer.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'IdentityScope only reads from ISC. Nothing on these pages changes your tenant (connector diagnostics excepted, which are off unless you turn them on).' }));\n document.body.appendChild(back);\n var first = drawer.querySelector('button');\n if (first) first.focus();\n }\n function renderUpdates(box, now) {\n api('/api/updates' + (now ? '?now=1' : '')).then(function (u) {\n box.textContent = '';\n if (!u.available) return;\n var on = el('input', { type: 'checkbox', checked: u.enabled });\n on.addEventListener('change', function () { api('/api/updates', 'PUT', { enabled: on.checked }).then(function () { renderUpdates(box); }); });\n var line = u.error ? el('p', { className: 'small error', text: u.error })\n : u.latest ? el('p', { className: 'small', text: u.newer ? 'Version ' + u.latest + ' is available (you have ' + u.current + ').' : 'You have the latest version (' + u.current + ').' }, u.newer && u.page ? el('a', { href: u.page, target: '_blank', rel: 'noopener', text: ' Open the release page' }) : null)\n : el('p', { className: 'small muted', text: 'You have version ' + u.current + '.' });\n box.appendChild(el('div', {}, el('h4', { text: 'New versions' }), line,\n el('div', { className: 'bar' }, el('button', { className: 'btn sm', onclick: function () { renderUpdates(box, true); } }, 'Check now'),\n el('label', { className: 'inline small' }, on, 'Check when the screen opens')),\n el('p', { className: 'muted small', text: 'Checking asks the release page for the latest version number. Nothing about you or your tenant is sent.' })));\n }).catch(function () { box.textContent = ''; });\n }\n function noticeNewVersion() {\n api('/api/updates').then(function (u) { if (u.enabled && u.newer) toast('IdentityScope ' + u.latest + ' is available. See Help for the release page.'); }).catch(function () {});\n }\n function renderChecklist(box) {\n box.textContent = '';\n box.appendChild(el('div', { className: 'muted small', text: 'Checking...' }));\n Promise.all([api('/api/checks').catch(function () { return null; }), api('/api/schedules').catch(function () { return null; })]).then(function (r) {\n var checks = r[0], sched = r[1];\n var ran = checks && Object.keys(checks.trends || {}).some(function (k) { return (checks.trends[k].points || []).length; });\n var limits = checks && checks.checks.some(function (c) { return c.settings && Object.keys(c.settings).length; });\n var daily = sched && sched.jobs.some(function (j) { return j.report === '@instant-check'; });\n var delivery = sched && (sched.email || sched.jobs.some(function (j) { return j.webhookKind; }));\n var items = [\n [true, 'Connected to your tenant', null],\n [null, 'Run the Health check (top right) once to see what your sign-in can read', function () { $('btn-doctor').click(); }],\n [ran, 'Run the instant check', function () { showPage('checks'); }],\n [limits, 'Adjust the limits to your tenant (optional)', function () { state.chk.showLimits = true; showPage('checks'); }],\n [delivery, 'Set up email or a Teams/Slack webhook', function () { showPage('schedules'); }],\n [daily, 'Schedule the instant check daily (builds trends and the monthly report)', function () { state.editing = { isNew: true, report: '@instant-check', params: {} }; showPage('schedules'); }]\n ];\n box.textContent = '';\n box.appendChild(el('div', { className: 'checklist' }, items.map(function (it) {\n return el('button', { className: 'cl-item' + (it[0] ? ' done' : ''), onclick: function () { if (it[2]) { document.querySelectorAll('.drawer-back').forEach(function (d) { d.remove(); }); it[2](); } } },\n el('span', { className: 'cl-box', text: it[0] ? '✓' : it[0] === null ? '•' : '' }), el('span', { text: it[1] }));\n })));\n });\n }\n function fixCard(id) {\n var steps = FIX[id];\n if (!steps) return null;\n return el('div', { className: 'fix' }, el('b', { text: 'How to fix' }), el('ol', {}, steps.map(function (s) { return el('li', { text: s }); })));\n }\n /** \"Today at a glance\" for the home page, from the last instant check on this computer. */\n function glance(box) {\n api('/api/checks').then(function (m) {\n var last = null, worst = { bad: 0, warn: 0 };\n Object.keys(m.trends || {}).forEach(function (k) {\n var tr = m.trends[k], p = tr.points && tr.points[tr.points.length - 1];\n if (!p) return;\n if (!last || p.at > last) last = p.at;\n if (tr.status === 'bad') worst.bad++; else if (tr.status === 'warn') worst.warn++;\n });\n box.textContent = '';\n var level = !last ? 'idle' : worst.bad ? 'bad' : worst.warn ? 'warn' : 'ok';\n box.appendChild(el('div', { className: 'banner ' + level, style: 'margin-bottom:18px' },\n el('b', { text: !last ? 'Start your day with the instant check' : worst.bad + worst.warn ? (worst.bad ? worst.bad + ' problem' + (worst.bad > 1 ? 's' : '') : '') + (worst.bad && worst.warn ? ', ' : '') + (worst.warn ? worst.warn + ' to look at' : '') : 'All checks OK' }),\n el('span', { text: last ? 'Last instant check ' + ago(last) : 'Provisioning, aggregations, VAs, workflows, leavers and more in one click.' }),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn sm', onclick: function () { showPage('checks'); } }, icon('pulse'), last ? 'Open instant check' : 'Run it now')));\n }).catch(function () { box.textContent = ''; });\n }\n\n // ---------- role tools ----------\n function pollJob(id, onProgress, onDone, onError, misses) {\n state.activeJob = id;\n api('/api/jobs/' + id).then(function (s) {\n if (s.state === 'running') { onProgress(s.progress + ' · ' + s.seconds + 's'); setTimeout(function () { pollJob(id, onProgress, onDone, onError); }, 800); }\n else if (s.state === 'error') onError(s.error);\n else onDone(s);\n }).catch(function (e) {\n // The local program may be busy for a moment: try again for about a minute before giving up.\n var n = (misses || 0) + 1;\n if (e && e.name === 'TypeError' && n <= 20) { onProgress('Waiting for IdentityScope to answer...'); setTimeout(function () { pollJob(id, onProgress, onDone, onError, n); }, 3000); }\n else onError(errorText(e));\n });\n }\n function downloads(job) {\n var dl = function (f, label, primary) { return el('a', { className: 'btn sm' + (primary ? ' primary' : ''), href: '/api/jobs/' + job + '/download?format=' + f + '&k=' + encodeURIComponent(KEY), download: '' }, icon('download'), label); };\n return el('div', { className: 'bar' }, dl('xlsx', 'Excel', true), dl('csv', 'CSV'), dl('html', 'HTML'));\n }\n state.roleTab = state.roleTab || 'compare';\n state.cmp = { roles: [] };\n state.imp = { roleId: '', criteria: null, loaded: null };\n\n function renderRoles() {\n // The role change preview also lives on the Build & test page: redraw that page when it is open.\n if (state.page === 'build') { renderBuild(); return; }\n var outer = $('roles');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1180px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, catIcon('Access model'),\n el('div', {}, el('h2', { text: 'Role tools' }), el('p', { className: 'desc', text: 'Understand roles before you change them. Read-only: nothing is changed in ISC.' }))));\n var tabs = el('div', { className: 'tabs' });\n [['compare', 'Compare roles', 'cols'], ['impact', 'Preview a role change', 'eye'], ['mining', 'Find candidate roles', 'search']].forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (state.roleTab === t[0] ? ' active' : ''), onclick: function () { state.roleTab = t[0]; renderRoles(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (state.roleTab === 'compare') renderCompare(w); else if (state.roleTab === 'mining') renderMining(w); else renderImpact(w);\n }\n\n function renderCompare(w) {\n var c = state.cmp;\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Pick two to six roles' })));\n card.appendChild(el('div', { className: 'runbar', style: 'margin-top:0;padding-top:0;border-top:none' },\n el('label', { className: 'field', style: 'flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'Roles' }), picker({ options: loadPick('roles'), multiple: true, value: c.roles, placeholder: 'Pick roles', onChange: function (v) { c.roles = v; } })),\n el('button', { className: 'btn primary', onclick: function () {\n c.error = null; c.data = null; c.busy = 'Starting...'; renderRoles();\n api('/api/roles/compare', 'POST', { roles: c.roles }).then(function (r) {\n c.job = r.job;\n pollJob(r.job, function (m) { c.busy = m; var p = $('cmp-progress'); if (p) p.textContent = m; }, function (s) { c.busy = null; c.data = s.extra; renderRoles(); }, function (e) { c.busy = null; c.error = e; renderRoles(); });\n }).catch(function (e) { c.busy = null; c.error = errorText(e); renderRoles(); });\n } }, icon('cols'), 'Compare')));\n w.appendChild(card);\n if (c.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'cmp-progress', text: c.busy, style: 'flex:1' }), stopButton()))); return; }\n if (c.error) { w.appendChild(el('div', { className: 'error', text: c.error })); return; }\n var d = c.data;\n if (!d) { w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'Which roles overlap?' }), 'Compare roles to find duplicates to merge, or to explain how two job roles differ.')); return; }\n w.appendChild(el('div', { className: 'rolecards' }, d.roles.map(function (r) {\n return el('div', { className: 'rolecard' }, el('h4', { text: r.name }),\n el('div', { className: 'kv' }, el('span', {}, el('b', { text: fmtNum(r.members) }), ' members'), el('span', {}, el('b', { text: String(r.accessProfiles.length) }), ' access profiles'), el('span', {}, el('b', { text: String(r.effectiveEntitlements) }), ' entitlements')),\n el('div', { className: 'kv', style: 'margin-top:4px' }, el('span', { text: 'Owner: ' + (r.owner || 'none') }), el('span', { text: r.enabled === false ? 'Disabled' : 'Enabled' }), el('span', { text: r.requestable ? 'Requestable' : 'Not requestable' })),\n el('div', { className: 'crit', text: r.criteriaText }));\n })));\n var stats = el('section', { className: 'card' });\n if (d.similarity !== undefined && d.similarity !== null) {\n var pct = Math.round(d.similarity * 100);\n stats.appendChild(el('div', { className: 'bar', style: 'justify-content:space-between' }, el('b', { text: 'Entitlement overlap of the first two roles: ' + pct + '%' }),\n el('span', { className: 'muted small', text: pct >= 80 ? 'Very similar: candidates to merge.' : pct >= 40 ? 'Partly overlapping.' : 'Mostly different.' })));\n stats.appendChild(el('div', { className: 'meter' }, el('span', { style: 'width:' + pct + '%' })));\n }\n stats.appendChild(el('div', { className: 'kv', style: 'margin-top:6px' },\n el('span', {}, el('b', { text: fmtNum(d.members.inAll) }), ' identities hold all of them'),\n d.roles.map(function (r, i) { return el('span', {}, el('b', { text: fmtNum(d.members.only[i]) }), ' only ' + r.name); })));\n w.appendChild(stats);\n var filter = c.filter || 'all';\n var chips = el('div', { className: 'chips' }, [['all', 'All access'], ['shared', 'In every role'], ['diff', 'Differences']].map(function (f) {\n return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { c.filter = f[0]; renderRoles(); } });\n }));\n var rows = d.items.filter(function (x) { var all = x.inRole.every(Boolean); return filter === 'all' || (filter === 'shared' ? all : !all); });\n var tcard = el('section', { className: 'card', style: 'padding:16px' }, el('div', { className: 'bar', style: 'justify-content:space-between;margin-bottom:12px' }, chips, downloads(c.job)));\n tcard.appendChild(el('div', { className: 'table-wrap' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Type', 'Access', 'Source'].concat(d.roles.map(function (r) { return r.name; }), ['Granted through']).map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, rows.map(function (x) {\n return el('tr', {}, el('td', { text: x.type }), el('td', { text: x.name }), el('td', { className: x.source ? '' : 'empty-cell', text: x.source || '—' }),\n x.inRole.map(function (v) { return el('td', {}, el('span', { className: v ? 'tick' : 'dash', text: v ? '✓' : '—' })); }),\n el('td', { className: 'muted', text: x.via.join(', ') }));\n })))));\n if (!rows.length) tcard.appendChild(el('div', { className: 'empty', text: 'Nothing in this view.' }));\n w.appendChild(tcard);\n }\n\n var CRIT_OPS = [['EQUALS', 'is'], ['NOT_EQUALS', 'is not'], ['CONTAINS', 'contains'], ['DOES_NOT_CONTAIN', 'does not contain'], ['STARTS_WITH', 'starts with'], ['ENDS_WITH', 'ends with'], ['GREATER_THAN', '>'], ['LESS_THAN', '<'], ['GREATER_THAN_EQUALS', '≥'], ['LESS_THAN_EQUALS', '≤']];\n function newLeaf() { return { operation: 'EQUALS', key: { type: 'IDENTITY', property: 'attribute.department', sourceId: null }, stringValue: '' }; }\n function normalizeCriteria(c) {\n if (!c) return { operation: 'AND', children: [newLeaf()] };\n c = clone(c);\n if (c.operation !== 'AND' && c.operation !== 'OR') return { operation: 'AND', children: [c] };\n return c;\n }\n function identityAttrs() {\n var disc = state.disc.identities;\n if (!disc) { ensureDisc('identities'); return []; }\n return (disc.fields || []).filter(function (f) { return f.path.indexOf('attributes.') === 0; }).map(function (f) { return { name: f.path.slice(11), values: f.values }; });\n }\n function critRow(leaf, onRemove) {\n leaf.key = leaf.key || { type: 'IDENTITY', property: '', sourceId: null };\n var attrs = identityAttrs();\n var type = el('select', { className: 'input', 'aria-label': 'Condition on' }, el('option', { value: 'IDENTITY', text: 'Identity attribute' }), el('option', { value: 'ACCOUNT', text: 'Account attribute' }), el('option', { value: 'ENTITLEMENT', text: 'Entitlement' }));\n type.value = leaf.key.type;\n type.addEventListener('change', function () {\n leaf.key.type = type.value;\n leaf.key.sourceId = type.value === 'IDENTITY' ? null : leaf.key.sourceId;\n if (type.value === 'ENTITLEMENT') leaf.key.property = 'attribute.memberOf';\n renderRoles();\n });\n var src = leaf.key.type === 'IDENTITY' ? el('div', { className: 'muted small', style: 'padding:9px 4px', text: 'any source' })\n : picker({ options: loadPick('sources'), value: leaf.key.sourceId || '', placeholder: 'Pick a source', onChange: function (v) { leaf.key.sourceId = v || null; } });\n var dl1 = 'ca' + Math.random().toString(36).slice(2), dl2 = 'cv' + Math.random().toString(36).slice(2);\n var name = (leaf.key.property || '').replace(/^attribute\\./, '');\n var prop = el('input', { className: 'input', value: name, placeholder: leaf.key.type === 'ENTITLEMENT' ? 'memberOf' : 'attribute name', list: leaf.key.type === 'IDENTITY' ? dl1 : null });\n prop.addEventListener('input', function () { leaf.key.property = 'attribute.' + prop.value.trim(); });\n prop.addEventListener('change', function () { renderRoles(); });\n var op = el('select', { className: 'input', 'aria-label': 'Comparison' }, CRIT_OPS.map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n op.value = leaf.operation;\n op.addEventListener('change', function () { leaf.operation = op.value; });\n var a = attrs.filter(function (x) { return x.name === name; })[0];\n var val = el('input', { className: 'input', value: leaf.stringValue || '', placeholder: leaf.key.type === 'ENTITLEMENT' ? 'entitlement value, e.g. CN=VPN Users,...' : 'value', list: a && a.values.length ? dl2 : null });\n val.addEventListener('input', function () { leaf.stringValue = val.value; });\n return el('div', { className: 'crit-row' }, type, src, el('div', {}, prop, leaf.key.type === 'IDENTITY' ? el('datalist', { id: dl1 }, attrs.map(function (x) { return el('option', { value: x.name }); })) : null),\n op, el('div', {}, val, a && a.values.length ? el('datalist', { id: dl2 }, a.values.map(function (v) { return el('option', { value: v }); })) : null),\n el('button', { className: 'btn icon ghost', title: 'Remove', onclick: onRemove }, icon('x')));\n }\n function opSelect(node) {\n var s = el('select', { className: 'input', style: 'width:auto;display:inline-block', 'aria-label': 'All or any' }, el('option', { value: 'AND', text: 'all' }), el('option', { value: 'OR', text: 'any' }));\n s.value = node.operation;\n s.addEventListener('change', function () { node.operation = s.value; });\n return s;\n }\n function renderImpact(w) {\n var im = state.imp;\n if (!im.criteria) im.criteria = normalizeCriteria(null);\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Which role?' })));\n card.appendChild(el('div', { className: 'grid', style: 'grid-template-columns:minmax(280px,1fr) 2fr' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Role (leave empty to try criteria for a new role)' }),\n picker({ options: loadPick('roles'), value: im.roleId, placeholder: 'New role', onChange: function (v) {\n im.roleId = v; im.loaded = null; im.data = null; im.error = null;\n if (!v) { im.criteria = normalizeCriteria(null); renderRoles(); return; }\n api('/api/roles/' + v).then(function (r) { im.loaded = r; im.criteria = normalizeCriteria(r.criteria); renderRoles(); }).catch(function (e) { im.error = errorText(e); renderRoles(); });\n } })),\n im.loaded ? el('div', { className: 'field' }, el('span', { className: 'lbl', text: 'Current criteria' }), el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px', text: im.loaded.criteriaText })) : el('div')));\n if (im.loaded && im.loaded.membershipType === 'IDENTITY_LIST') card.appendChild(el('div', { className: 'note', text: 'This role is given to a fixed list of identities today. You can still try criteria to see who they would cover.' }));\n w.appendChild(card);\n\n var ed = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'New criteria' }), el('span', { className: 'muted small', text: 'compared without case, like ISC' })));\n var root = im.criteria;\n ed.appendChild(el('div', { className: 'joiner' }, 'Give the role to identities who match', opSelect(root), 'of:'));\n (root.children || []).forEach(function (ch, i) {\n var removeMe = function () { root.children.splice(i, 1); renderRoles(); };\n if (ch.operation === 'AND' || ch.operation === 'OR') {\n var g = el('div', { className: 'crit-group' }, el('div', { className: 'joiner', style: 'justify-content:space-between' }, el('span', {}, 'A group matching ', opSelect(ch), ' of:'), el('button', { className: 'btn icon ghost', title: 'Remove group', onclick: removeMe }, icon('x'))));\n (ch.children || []).forEach(function (leaf, j) { g.appendChild(critRow(leaf, function () { ch.children.splice(j, 1); if (!ch.children.length) root.children.splice(i, 1); renderRoles(); })); });\n g.appendChild(el('button', { className: 'btn sm', onclick: function () { ch.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Condition in this group'));\n ed.appendChild(g);\n } else ed.appendChild(critRow(ch, removeMe));\n });\n ed.appendChild(el('div', { className: 'bar', style: 'margin-top:6px' },\n el('button', { className: 'btn', onclick: function () { root.children.push(newLeaf()); renderRoles(); } }, icon('plus'), 'Add condition'),\n el('button', { className: 'btn', onclick: function () { root.children.push({ operation: root.operation === 'AND' ? 'OR' : 'AND', children: [newLeaf()] }); renderRoles(); } }, icon('plus'), 'Add group'),\n el('span', { style: 'flex:1' }),\n el('button', { className: 'btn ghost', onclick: function () { modal('Criteria as JSON (for the ISC role API, membership.criteria)', JSON.stringify(im.criteria, null, 2)); } }, icon('code'), 'Show JSON'),\n el('button', { className: 'btn primary', onclick: function () {\n im.error = null; im.data = null; im.busy = 'Starting...'; renderRoles();\n api('/api/roles/impact', 'POST', { roleId: im.roleId || undefined, criteria: im.criteria }).then(function (r) {\n im.job = r.job;\n pollJob(r.job, function (m) { im.busy = m; var p = $('imp-progress'); if (p) p.textContent = m; }, function (s) { im.busy = null; im.data = s.extra; renderRoles(); }, function (e) { im.busy = null; im.error = e; renderRoles(); });\n }).catch(function (e) { im.busy = null; im.error = errorText(e); renderRoles(); });\n } }, icon('eye'), 'Preview who is affected')));\n w.appendChild(ed);\n if (im.busy) { w.appendChild(el('section', { className: 'card' }, el('div', { className: 'progress', style: 'margin:0' }, el('span', { className: 'spinner' }), el('span', { id: 'imp-progress', text: im.busy, style: 'flex:1' }), stopButton()))); return; }\n if (im.error) { w.appendChild(el('div', { className: 'error', text: im.error })); return; }\n var d = im.data;\n if (!d) return;\n var res = el('section', { className: 'card' });\n res.appendChild(el('div', { className: 'card-h' }, el('h3', { text: 'What would change' }), downloads(im.job)));\n res.appendChild(el('div', { className: 'crit', style: 'font:12.5px/1.5 ui-monospace,Consolas,monospace;background:var(--sunken);border-radius:8px;padding:9px 11px;margin-bottom:12px', text: 'New: ' + d.newCriteria }));\n res.appendChild(el('div', { className: 'bigstats' },\n el('div', { className: 'bigstat gain' }, el('b', { text: '+' + fmtNum(d.gain) }), el('span', { text: 'would gain the role' })),\n el('div', { className: 'bigstat lose' }, el('b', { text: '−' + fmtNum(d.lose) }), el('span', { text: 'would lose it' })),\n d.role ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.holdersNow) }), el('span', { text: 'hold it now' })) : null,\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.matchNew) }), el('span', { text: 'match the new criteria' })),\n d.keepOther ? el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.keepOther) }), el('span', { text: 'keep it (given another way)' })) : null,\n el('div', { className: 'bigstat' }, el('b', { text: fmtNum(d.identitiesChecked) }), el('span', { text: 'identities checked' }))));\n d.warnings.forEach(function (x) { res.appendChild(el('div', { className: 'note', text: x })); });\n if (d.conditions && d.conditions.length) {\n res.appendChild(el('div', { className: 'muted small', style: 'margin:14px 0 6px;font-weight:600', text: 'Each condition on its own (of ' + fmtNum(d.identitiesChecked) + ' identities)' }));\n res.appendChild(el('div', { className: 'table-wrap', style: 'margin-bottom:14px' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Condition', 'Identities matching', 'Identities with any value', 'Most common values'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, d.conditions.map(function (c) {\n return el('tr', {}, el('td', { style: 'font-family:ui-monospace,Consolas,monospace;font-size:12.5px', text: c.text }),\n el('td', { className: 'num' }, el('span', { className: c.matches ? '' : 'chg lose', text: fmtNum(c.matches) })),\n el('td', { className: 'num', text: c.withValue === null ? '\\u2014' : fmtNum(c.withValue) }),\n el('td', { className: 'muted', text: c.topValues.map(function (v) { return v.value + ' (' + fmtNum(v.count) + ')'; }).join(', ') || '\\u2014' }));\n })))));\n }\n var filter = im.filter || 'all';\n res.appendChild(el('div', { className: 'chips' }, [['all', 'Everyone affected'], ['gain', 'Gain'], ['lose', 'Lose'], ['keep-other', 'Keep (other way)']].map(function (f) {\n return el('button', { className: 'chip' + (filter === f[0] ? ' active' : ''), text: f[1], onclick: function () { im.filter = f[0]; renderRoles(); } });\n })));\n var people = d.people.filter(function (p) { return filter === 'all' || p.change === filter; });\n var label = { gain: 'Gains', lose: 'Loses', 'keep-other': 'Keeps' };\n if (people.length) {\n res.appendChild(el('div', { className: 'table-wrap' }, el('table', {},\n el('thead', {}, el('tr', {}, ['Change', 'Identity', 'Email', 'Department', 'Lifecycle state', 'Manager'].map(function (h) { return el('th', { text: h, style: 'cursor:default' }); }))),\n el('tbody', {}, people.slice(0, 1000).map(function (p) {\n return el('tr', {}, el('td', {}, el('span', { className: 'chg ' + p.change, text: label[p.change] })), el('td', { text: p.name }), el('td', { text: p.email || '—' }), el('td', { text: p.department || '—' }), el('td', { text: p.lifecycleState || '—' }), el('td', { text: p.manager || '—' }));\n })))));\n if (people.length > 1000) res.appendChild(el('div', { className: 'note', text: 'Showing 1,000 of ' + fmtNum(people.length) + '. Downloads contain everyone.' }));\n } else res.appendChild(el('div', { className: 'empty', text: d.gain + d.lose === 0 ? 'Nobody would gain or lose the role.' : 'Nobody in this view.' }));\n w.appendChild(res);\n }\n\n // ---------- schedules ----------\n var DAYNAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\n function loadSchedules(message) {\n var box = $('schedules');\n box.textContent = '';\n box.appendChild(el('div', { className: 'wrap' }, el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Loading schedules...' }))));\n Promise.all([api('/api/schedules'), state.reports.length ? Promise.resolve(state.reports) : api('/api/reports')]).then(function (r) {\n state.sched = r[0];\n state.reports = r[1];\n renderSchedules(message);\n }).catch(function (e) { box.textContent = ''; box.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }\n\n function renderSchedules(message) {\n var sd = state.sched, outer = $('schedules');\n outer.textContent = '';\n var box = el('div', { className: 'wrap', style: 'max-width:1120px' });\n outer.appendChild(box);\n box.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:18px' }, el('span', { className: 'cat-ico', style: 'color:#2457d6;background:#eaf0fd' }, icon('clock')),\n el('div', {}, el('h2', { text: 'Schedules' }), el('p', { className: 'desc', text: 'Send reports by email or to Teams/Slack automatically. Files are also saved in ' + sd.outputDir + '.' }))));\n if (message) box.appendChild(el('div', { className: 'success', text: message }));\n\n if (state.editing) {\n box.appendChild(jobForm(state.editing));\n if (!sd.email) {\n box.appendChild(el('div', { className: 'note', text: 'To send this report by email, fill in the email server once (below). For Teams or Slack only, you can skip it.' }));\n box.appendChild(emailCard(true));\n }\n return;\n }\n\n // tenant for automatic runs\n var remember = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Tenant for automatic runs' })));\n if (sd.remembered) {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill on', text: 'Saved on this computer' }),\n el('span', { className: 'muted', text: 'Automatic runs sign in with the saved token, even when this screen is closed.' }),\n el('button', { className: 'btn sm', text: 'Forget it', onclick: function () { api('/api/remember', 'POST', { remember: false }).then(function () { loadSchedules('Saved tenant details removed.'); }); } })));\n } else if (state.signedIn) {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill off', text: 'Not saved' }),\n el('span', { className: 'muted', text: 'You signed in with SailPoint. Sign-ins expire, so automatic runs need a personal access token: disconnect, connect with a token of a reporting identity, then click \"Remember my tenant\". \"Run now\" works with your sign-in.' })));\n } else {\n remember.appendChild(el('div', { className: 'bar' }, el('span', { className: 'pill off', text: 'Not saved' }),\n el('span', { className: 'muted', text: 'Automatic runs happen when this screen is closed, so they need your tenant details saved on this computer (in your user profile, readable only by you).' }),\n el('button', { className: 'btn primary sm', text: 'Remember my tenant', onclick: function () {\n api('/api/remember', 'POST', { remember: true }).then(function () { loadSchedules('Tenant details saved for automatic runs.'); }).catch(function (e) { alert(errorText(e)); });\n } })));\n }\n box.appendChild(remember);\n\n // jobs\n var jobsCard = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'My schedules' }),\n el('button', { className: 'btn primary', text: '+ New schedule', onclick: function () { state.editing = { isNew: true }; renderSchedules(); } })));\n if (!sd.jobs.length) jobsCard.appendChild(el('div', { className: 'muted', text: 'No schedules yet. Click \"New schedule\", or open a report and click \"Schedule this report\".' }));\n else {\n var t = el('table', { className: 'jobs' }, el('thead', {}, el('tr', {}, ['Name', 'Report', 'When', 'Sends to', 'Runs automatically', ''].map(function (h) { return el('th', { text: h }); }))));\n var tb = el('tbody');\n sd.jobs.forEach(function (j) {\n var to = [];\n if (j.emailTo.length) to.push(j.emailTo.join(', '));\n if (j.webhookKind) to.push(j.webhookKind === 'teams' ? 'Teams' : j.webhookKind === 'slack' ? 'Slack' : 'Webhook');\n var status = el('div');\n var auto = j.automatic\n ? el('div', {}, el('span', { className: 'pill on', text: 'On' }), el('div', { className: 'muted', style: 'font-size:12px', text: 'Next: ' + j.automatic.next }))\n : el('span', { className: 'pill off', text: 'Off' });\n tb.appendChild(el('tr', {},\n el('td', { text: j.name }), el('td', { text: j.reportName }), el('td', { text: j.whenText }), el('td', { text: to.join(' + ') || 'files only' }), el('td', {}, auto),\n el('td', {}, el('div', { className: 'actions' },\n el('button', { className: 'btn sm', text: 'Run now', onclick: function () { runNow(j, status); } }),\n el('button', { className: 'btn sm', text: j.automatic ? 'Turn off' : 'Turn on', title: sd.windows === false ? '' : 'Uses Windows Task Scheduler', onclick: function () { toggleAuto(j); } }),\n el('button', { className: 'btn sm', text: 'Edit', onclick: function () { state.editing = j; renderSchedules(); } }),\n el('button', { className: 'btn sm', text: 'Delete', onclick: function () {\n if (!confirm('Delete the schedule \"' + j.name + '\"?')) return;\n api('/api/schedules/jobs/' + encodeURIComponent(j.name), 'DELETE').then(function () { loadSchedules('Schedule deleted.'); });\n } })))));\n tb.appendChild(el('tr', {}, el('td', { colspan: '6', style: 'border-bottom:none;padding-top:0' }, status, j.lastLog ? el('details', {}, el('summary', { className: 'muted', text: 'Last automatic runs' }), el('div', { className: 'log', text: j.lastLog })) : null)));\n });\n t.appendChild(tb);\n jobsCard.appendChild(el('div', { className: 'table-wrap', style: 'max-height:none' }, t));\n }\n box.appendChild(jobsCard);\n box.appendChild(emailCard());\n }\n\n function runNow(j, status) {\n status.textContent = '';\n status.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Running \"' + j.name + '\" now...' })));\n api('/api/schedules/jobs/' + encodeURIComponent(j.name) + '/run', 'POST', {}).then(function (r) {\n var check = function () {\n api('/api/schedules/runs/' + r.run).then(function (s) {\n if (s.state === 'running') { setTimeout(check, 1000); return; }\n var o = s.outcome;\n status.textContent = '';\n if (o.ok) {\n var parts = [(o.rows || 0).toLocaleString('en-US') + ' rows'];\n if (o.skipped) parts.push('nothing sent (no rows)');\n if (o.delivered.length) parts.push('sent: ' + o.delivered.join(', '));\n if (o.files.length) parts.push('saved ' + o.files.length + ' file(s)');\n status.appendChild(el('div', { className: 'success', text: 'Done: ' + parts.join(' · ') }));\n } else status.appendChild(el('div', { className: 'error', text: o.error || 'Failed' }));\n });\n };\n check();\n }).catch(function (e) { status.textContent = ''; status.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n }\n\n function toggleAuto(j) {\n api('/api/schedules/jobs/' + encodeURIComponent(j.name) + '/automatic', 'POST', { on: !j.automatic })\n .then(function () { loadSchedules(j.automatic ? 'Automatic runs turned off for \"' + j.name + '\".' : '\"' + j.name + '\" will now run automatically (' + j.whenText + ') while this computer is on.'); })\n .catch(function (e) { alert(errorText(e)); });\n }\n\n function emailCard(inForm) {\n var e = state.sched.email || {};\n var host = el('input', { className: 'input', value: e.host || '', placeholder: 'smtp.office365.com' });\n var port = el('input', { className: 'input', value: e.port || 587, style: 'width:90px' });\n var user = el('input', { className: 'input', value: e.user || '', placeholder: 'reports@company.com' });\n var pass = el('input', { className: 'input', type: 'password', placeholder: e.passwordSaved ? 'saved (leave empty to keep)' : '' });\n var from = el('input', { className: 'input', value: e.from || '', placeholder: 'IAM Reports <reports@company.com>' });\n var testTo = el('input', { className: 'input', placeholder: 'you@company.com', style: 'width:240px' });\n var msg = el('div');\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Email server' })),\n el('p', { className: 'muted', style: 'margin-top:0', text: 'Ask your mail team for an SMTP relay or an app password. The password is stored only on this computer.' }),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Server' }), host), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Port' }), port),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'User name' }), user), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Password' }), pass)),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'From' }), from)),\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', text: 'Save email settings', onclick: function () {\n msg.textContent = '';\n api('/api/schedules/email', 'PUT', { host: host.value, port: Number(port.value), user: user.value, password: pass.value, from: from.value })\n .then(function () {\n if (!inForm) return loadSchedules('Email settings saved.');\n return api('/api/schedules').then(function (sd) {\n state.sched = sd;\n msg.appendChild(el('div', { className: 'success', text: 'Email settings saved. Now click \"Save schedule\" above.' }));\n });\n })\n .catch(function (er) { msg.appendChild(el('div', { className: 'error', text: errorText(er) })); });\n } }),\n el('span', { className: 'muted', text: 'Send a test to' }), testTo,\n el('button', { className: 'btn', text: 'Send test email', onclick: function () {\n msg.textContent = '';\n msg.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), el('span', { text: 'Sending...' })));\n api('/api/schedules/email/test', 'POST', { to: testTo.value }).then(function () { msg.textContent = ''; msg.appendChild(el('div', { className: 'success', text: 'Test email sent to ' + testTo.value + '.' })); })\n .catch(function (er) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(er) })); });\n } })),\n msg);\n return card;\n }\n\n function jobForm(j) {\n var editing = !j.isNew;\n var reports = state.reports.map(function (r) { return r.definition; });\n var name = el('input', { className: 'input', value: j.name || '', placeholder: 'weekly-leavers' });\n var reportSel = el('select', { className: 'input' }, el('option', { value: '', text: 'Choose a report' }), el('option', { value: '@instant-check', text: 'Instant check (all checks, a summary)' }), el('option', { value: '@all-tenants-check', text: 'All tenants: instant check of every customer tenant (partner overview)' }), reports.map(function (d) { return el('option', { value: d.id, text: d.name }); }));\n reportSel.value = j.report || '';\n var paramsBox = el('div');\n var paramValues = Object.assign({}, j.params || {});\n function drawParams() {\n paramsBox.textContent = '';\n var d = reports.filter(function (x) { return x.id === reportSel.value; })[0];\n if (!d || !d.params) return;\n var g = paramsGrid(d.params, paramValues);\n if (g) { g.style.marginBottom = '14px'; paramsBox.appendChild(g); }\n }\n var nameFor = function (r) { return r === '@instant-check' ? 'daily-instant-check' : r === '@all-tenants-check' ? 'daily-all-tenants' : r; };\n reportSel.addEventListener('change', function () { paramValues = {}; drawParams(); if ((!name.value || name.value === '@instant-check' || name.value === '@all-tenants-check') && reportSel.value) name.value = nameFor(reportSel.value); });\n drawParams();\n if (!name.value && j.report) name.value = nameFor(j.report);\n\n var w = j.when || { every: 'week', time: '08:00', weekday: 1, day: 1 };\n var every = el('select', { className: 'input' }, el('option', { value: 'day', text: 'Every day' }), el('option', { value: 'week', text: 'Every week' }), el('option', { value: 'month', text: 'Every month' }));\n every.value = w.every;\n var time = el('input', { className: 'input', type: 'time', value: w.time || '08:00' });\n var weekday = el('select', { className: 'input' }, DAYNAMES.map(function (n, i) { return el('option', { value: String(i), text: 'on ' + n }); }));\n weekday.value = String(w.weekday === undefined ? 1 : w.weekday);\n var day = el('select', { className: 'input' }, Array.from({ length: 28 }, function (_, i) { return el('option', { value: String(i + 1), text: 'on day ' + (i + 1) }); }));\n day.value = String(w.day || 1);\n var syncWhen = function () { weekday.style.display = every.value === 'week' ? '' : 'none'; day.style.display = every.value === 'month' ? '' : 'none'; };\n every.addEventListener('change', syncWhen); syncWhen();\n\n var fmts = j.formats || ['xlsx'];\n var checks = ['xlsx', 'csv', 'html'].map(function (f) {\n var c = el('input', { type: 'checkbox' });\n c.checked = fmts.indexOf(f) >= 0;\n return { f: f, c: c };\n });\n var emailTo = el('input', { className: 'input', value: (j.emailTo || []).join(', '), placeholder: 'audit@company.com, you@company.com' });\n var allow = {};\n (j.allowUnverified || []).forEach(function (a) { allow[a.toLowerCase()] = true; });\n var recipientsBox = el('div');\n function showRecipients(list) {\n recipientsBox.textContent = '';\n list.forEach(function (r) {\n var line = el('div', { style: 'font-size:13px;margin:3px 0' });\n if (r.ok) {\n line.appendChild(el('span', { className: 'ok', text: '\\u2713 ' + r.email }));\n line.appendChild(el('span', { className: 'muted', text: r.identity ? ' (' + r.identity + ')' : r.reason ? ' (' + r.reason + ')' : '' }));\n } else {\n line.appendChild(el('span', { style: 'color:var(--danger)', text: '\\u2717 ' + r.email + ': ' + r.reason }));\n if (r.reason === 'no identity in ISC has this email') {\n var c = el('input', { type: 'checkbox' });\n c.checked = !!allow[r.email.toLowerCase()];\n c.addEventListener('change', function () { if (c.checked) allow[r.email.toLowerCase()] = true; else delete allow[r.email.toLowerCase()]; });\n line.appendChild(el('label', { className: 'check', style: 'margin-left:12px' }, c, 'It is a shared mailbox or distribution list of our company: allow it'));\n }\n }\n recipientsBox.appendChild(line);\n });\n }\n var checkBtn = el('button', { className: 'btn sm', text: 'Check recipients in ISC', onclick: function () {\n recipientsBox.textContent = 'Checking...';\n api('/api/schedules/recipients', 'POST', { emails: emailTo.value, allowUnverified: Object.keys(allow) })\n .then(function (r) { showRecipients(r.recipients); })\n .catch(function (e) { recipientsBox.textContent = ''; recipientsBox.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } });\n var kind = el('select', { className: 'input' }, el('option', { value: '', text: 'No chat message' }), el('option', { value: 'teams', text: 'Microsoft Teams' }), el('option', { value: 'slack', text: 'Slack' }));\n kind.value = j.webhookKind || '';\n var hook = el('input', { className: 'input', placeholder: j.webhookSaved ? 'saved (leave empty to keep)' : 'https://...' });\n var syncHook = function () { hook.parentNode.style.display = kind.value ? '' : 'none'; };\n var sendWhen = el('select', { className: 'input', style: 'width:auto' },\n el('option', { value: 'always', text: 'every time it runs' }),\n el('option', { value: 'rows', text: 'only when there is something (rows, or a check that is not OK)' }),\n el('option', { value: 'new', text: 'only when something is new or got worse since the last run' }));\n sendWhen.value = j.sendWhen || (j.skipWhenEmpty ? 'rows' : (j.isNew && (j.report === '@instant-check' || j.report === '@all-tenants-check') ? 'new' : 'always'));\n reportSel.addEventListener('change', function () { if ((reportSel.value === '@instant-check' || reportSel.value === '@all-tenants-check') && sendWhen.value === 'always') sendWhen.value = 'new'; });\n var msg = el('div');\n var hookLabel = el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Webhook address (Teams: channel > Workflows > \"Send webhook alerts to a channel\")' }), hook);\n var form = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: editing ? 'Edit schedule' : 'New schedule' })),\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Name' }), name), el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Report' }), reportSel)),\n paramsBox,\n el('div', { className: 'inline', style: 'margin-bottom:14px' }, el('span', { className: 'muted', text: 'Runs' }), every, weekday, day, el('span', { className: 'muted', text: 'at' }), time),\n el('div', { className: 'bar', style: 'margin-bottom:12px' }, el('span', { className: 'muted', text: 'Files:' }), checks.map(function (x) { return el('label', { className: 'check' }, x.c, x.f === 'xlsx' ? 'Excel' : x.f.toUpperCase()); }),\n el('span', { className: 'muted', style: 'margin-left:12px', text: 'Send' }), sendWhen),\n el('div', { className: 'inline', style: 'align-items:flex-start;margin:6px 0 16px' },\n el('label', { className: 'field', style: 'flex:1;min-width:300px;margin:0' }, el('span', { className: 'lbl', text: 'Email to' }), emailTo, el('span', { className: 'hint', text: 'Comma separated. Each address must belong to an active identity in ISC.' })),\n el('div', { style: 'padding-top:23px' }, checkBtn)),\n recipientsBox,\n el('div', { className: 'grid' }, el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Also post a summary to' }), kind), hookLabel),\n el('p', { className: 'muted', text: 'Chat messages carry only counts and check results, never names; the data goes by email or stays in the saved files.' }),\n msg,\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', text: 'Save schedule', onclick: function () {\n msg.textContent = '';\n var body = {\n previousName: editing ? j.name : undefined,\n name: name.value.trim(), report: reportSel.value, params: paramValues,\n when: { every: every.value, time: time.value, weekday: Number(weekday.value), day: Number(day.value) },\n formats: checks.filter(function (x) { return x.c.checked; }).map(function (x) { return x.f; }),\n emailTo: emailTo.value, allowUnverified: Object.keys(allow), webhookKind: kind.value || undefined, webhookUrl: hook.value, sendWhen: sendWhen.value\n };\n api('/api/schedules/jobs', 'POST', body).then(function (r) {\n state.editing = null;\n loadSchedules('Schedule \"' + r.saved + '\" saved. Click \"Run now\" to try it, and \"Turn on\" to run it automatically.');\n }).catch(function (e) {\n if (e.data && e.data.recipients) { msg.appendChild(el('div', { className: 'error', text: e.message })); showRecipients(e.data.recipients); }\n else msg.appendChild(el('div', { className: 'error', text: errorText(e) }));\n });\n } }),\n el('button', { className: 'btn', text: 'Cancel', onclick: function () { state.editing = null; renderSchedules(); } })));\n kind.addEventListener('change', syncHook);\n setTimeout(syncHook, 0);\n return form;\n }\n\n // ---------- start ----------\n api('/api/state').then(function (st) {\n if (st.connected) { state.signedIn = st.signedInAs !== undefined && st.signedInAs !== null; showApp(st.tenant, st.signedInAs); } else showConnect(st);\n }).catch(function (e) {\n document.body.textContent = '';\n document.body.appendChild(el('div', { className: 'error', style: 'margin:40px', text: errorText(e) }));\n });\n // ---------- Warnings: what breaks on a date or stalls without anyone noticing ----------\n function wnState() {\n if (!state.wn) state.wn = { tab: 'ending', ending: { days: 30 }, stuck: {}, reminders: { days: 7 }, people: { days: 30 }, admins: {}, catalog: { q: '' }, growth: {}, settings: null };\n return state.wn;\n }\n var WN_TABS = [\n ['joiners', 'Missed joiners', 'up', 'Active identities missing an account that nearly everyone in their identity profile has, and identities past their start date still in a pre-hire state.'],\n ['movers', 'Mover leftovers', 'people', 'Access that almost no one else in the identity\\u2019s group has: often left over from a previous job (movers) or given as a one-off.'],\n ['leavers', 'Missed leavers', 'people', 'Identities whose HR account is disabled but who are active in ISC, and leavers who still have enabled accounts, roles or access profiles.'],\n ['expiry', 'Accounts expiring', 'clock', 'Accounts whose expiry date (Active Directory accountExpires, or any date attribute you name) is close, and expired accounts that are still enabled.'],\n ['revokes', 'Revokes not done', 'cert', 'Access a reviewer revoked in a certification that the identity still has after sign-off.'],\n ['massch', 'Mass changes', 'pulse', 'Days with far more disables, deletes, new accounts or removed access than usual: a bad HR file or transform can change thousands of accounts overnight.'],\n ['loops', 'Provisioning loops', 'lifecycle', 'The same change sent to the same account again and again: an attribute sync that never sticks or a request ISC keeps re-sending.'],\n ['outside', 'Changed outside ISC', 'eye', 'Accounts disabled on the application although ISC never disabled them, and accounts enabled again after ISC disabled them.'],\n ['syncdrift', 'Attribute sync drift', 'cols', 'Synced attributes whose value on the account differs from ISC, and attribute syncs that failed.'],\n ['groupappr', 'Group approvals', 'people', 'Access approvals waiting on a governance group, with how many members can still approve.'],\n ['mgrleft', 'Manager left', 'people', 'Active identities (contractors included) whose manager or sponsor has left: their approvals and reviews reach nobody.'],\n ['aggsafe', 'Aggregation safety', 'pulse', 'Per source: the delete threshold, failed aggregations, and sources that did not aggregate at all.'],\n ['svc', 'Service accounts', 'code', 'Service and machine accounts without an owner, with an owner who left, or not used for a long time, and who owns which.'],\n ['multi', 'Several accounts', 'people', 'Identities with more than one account on the same source; on the authoritative source this usually means a duplicate HR record or a rehire.'],\n ['pwfail', 'Password failures', 'shield', 'Password changes, resets and syncs that failed, per identity and source.'],\n ['lcset', 'Lifecycle settings', 'lifecycle', 'What each lifecycle state does to accounts and access, and leaver states that leave accounts switched on.'],\n ['govgroups', 'Governance groups', 'people', 'Governance groups with no members, only members who left, an owner who left, or no use anywhere.'],\n ['signins', 'Sign-in signals', 'shield', 'Many failed sign-ins for one identity, a sign-in right after a run of failures, sign-ins by identities who have left, and one network address trying many identities.'],\n ['selfappr', 'Self-approvals', 'eye', 'Access requests approved by the identity who gets the access, or by the identity who asked for it on someone’s behalf.'],\n ['adminact', 'Admin activity', 'code', 'Who changed tenant settings, sources, admins and access items, with changes made by identities who have left or by something that is not an identity.'],\n ['spikes', 'Access spikes', 'pulse', 'Identities who were given an unusual number of access items in one day.'],\n ['privgain', 'Privileged access gained', 'shield', 'Privileged entitlements identities hold now and did not hold at the previous look, and whether ISC provisioned them or they appeared on the application.'],\n ['outacct', 'Accounts created outside ISC', 'eye', 'New accounts ISC found on a source and did not create itself, with the ones nobody owns or that already have access first.'],\n ['sensitive', 'Sensitive changes', 'code', 'Configuration changes that touch a control (rules, lifecycle states, sources, password and SOD policies, event subscriptions) and new API credentials, with who made them where ISC says.'],\n ['risk', 'Risk by identity', 'people', 'The signals of all threat screens added up per person: someone who shows on several screens comes first.'],\n ['upcoming', 'Coming up', 'clock', 'Who starts or ends in the next days, the lifecycle state they are in now and what the states of their identity profile are set to do. Before the day, not after.'],\n ['stuckreq', 'Stuck requests', 'pulse', 'Access requests still running after a day or more: the phase each waits in and on whom, next to the sources ISC keeps re-sending the same change to.'],\n ['ending', 'Access ending', 'clock', 'Access granted with an end date. ISC removes it on that date; renew it before then if it is still needed.'],\n ['stuck', 'Waiting on leavers', 'people', 'Certification reviews and access approvals assigned to someone who left. They do not move until someone reassigns them.'],\n ['reminders', 'Review deadlines', 'cert', 'Certifications still open close to their deadline, per reviewer, so you can send reminders in time.'],\n ['people', 'End dates', 'lifecycle', 'Active identities whose end date is coming up, and identities still active after their end date.'],\n ['admins', 'ISC admins', 'shield', 'Who holds a user level in ISC itself, such as Org admin, and who of them has left.'],\n ['catalog', 'Access catalog', 'apps', 'Requestable access without a description or owner: identities request the wrong thing and approvals stall.'],\n ['growth', 'Identity count', 'up', 'How many identities you have, how fast the number grows, and when you reach your licensed number.'],\n ['quality', 'Identity data', 'people', 'Active identities without a manager, email or a key attribute, and emails used by more than one identity.']\n ];\n function renderWarnings() {\n var W = wnState();\n var outer = $('warnings');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#b45309;background:#fef3c7' }, icon('clock')),\n el('div', {}, el('h2', { text: 'Warnings' }), el('p', { className: 'desc', text: 'Things that break on a date or stall quietly, found before someone notices the hard way. Read-only.' }))));\n groupedTabs(w, 'wn', WN_GROUPS, WN_TABS, W.tab, function (id) { W.tab = id; renderWarnings(); });\n var spec = WN_TABS.filter(function (t) { return t[0] === W.tab; })[0];\n if (!W.settings && (W.tab === 'people' || W.tab === 'growth')) {\n W.settings = 'loading';\n api('/api/warnings/settings').then(function (s) { W.settings = s; }, function () { W.settings = {}; }).then(function () { if (state.page === 'warnings') renderWarnings(); });\n }\n ({ ending: wnEnding, stuck: wnStuck, reminders: wnReminders, people: wnPeople, admins: wnAdmins, catalog: wnCatalog, growth: wnGrowth, quality: wnQuality, joiners: wnJoiners, leavers: wnLeavers, expiry: wnExpiry, revokes: wnRevokes, massch: wnMassChange, signins: wnSignIns, selfappr: wnSelfApprovals, adminact: wnAdminActivity, spikes: wnAccessSpikes, lcset: wnLifecycleSettings, govgroups: wnGovGroups, aggsafe: wnAggSafety, svc: wnServiceAccounts, multi: wnMultiAccounts, pwfail: wnPasswordFailures, loops: wnLoops, outside: wnOutside, syncdrift: wnSyncDrift, groupappr: wnGroupApprovals, mgrleft: wnManagerLeft, privgain: wnPrivGained, outacct: wnOutsideAccounts, sensitive: wnSensitive, risk: wnRisk, upcoming: wnUpcoming, stuckreq: wnStuckReq, movers: function (w) { renderMovers(w); } })[W.tab](w, W[W.tab] || {}, spec[3]);\n }\n function wnRunBar(w, H, path, label, desc, extras, body) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/warnings/' + path + '/run', body ? body() : {}, renderWarnings); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function daysSelect(H, options, label) {\n var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, options.map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n s.value = String(H.days);\n s.addEventListener('change', function () { H.days = Number(s.value); });\n return s;\n }\n function stat(n, label, tone) { return el('div', { className: 'bigstat' + (tone && n ? ' ' + tone : '') }, el('b', { text: n === null || n === undefined ? '—' : fmtNum(n) }), el('span', { text: label })); }\n function pill(text, tone) { return el('span', { className: 'chg ' + tone, text: text }); }\n function statusPill(s) { return !s || s === 'active' ? null : pill(s === 'left' ? 'has left' : s, 'lose'); }\n function daysText(n) { return n === 0 ? 'today' : n === 1 ? 'tomorrow' : n < 0 ? (-n) + ' days ago' : 'in ' + n + ' days'; }\n\n function wnEnding(w, H, desc) {\n var sel = daysSelect(H, [[7, 'Next 7 days'], [14, 'Next 14 days'], [30, 'Next 30 days'], [90, 'Next 90 days']], 'Period');\n if (!wnRunBar(w, H, 'access-ending', 'Find access ending', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'items end in the next ' + d.days + ' days'), stat(d.rows.filter(function (r) { return r.daysLeft <= 7; }).length, 'within 7 days', 'lose'), stat(d.byManager.length, 'managers to tell')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No access with an end date in this period.' })); return; }\n w.appendChild(section('By manager', d.byManager.length, simpleTable(['Manager', 'Items ending', 'Soonest'], d.byManager.map(function (m) { return [m.manager, m.count, daysText(m.soonest)]; }))));\n w.appendChild(section('Access ending', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Identity', 'Access', 'Type', 'Ends', 'Manager', 'Requested by'], d.rows.slice(0, 2000).map(function (r) {\n return [el('span', {}, r.person, ' ', statusPill(r.personStatus)), r.access, r.type, el('span', { style: 'white-space:nowrap' }, r.removeDate.slice(0, 10) + ' ', pill(daysText(r.daysLeft), r.daysLeft <= 7 ? 'lose' : 'off')), r.manager, r.requester];\n })))));\n w.appendChild(el('p', { className: 'muted small', text: 'From completed access requests that had an end date. Access removed earlier by another route may still show here.' }));\n }\n\n function wnStuck(w, H, desc) {\n if (!wnRunBar(w, H, 'stuck', 'Find stuck items', desc)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.reviews, 'certification reviews', 'lose'), stat(d.totals.approvals, 'access approvals', 'lose')));\n if (!d.rows.length) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'Nothing is waiting on identities who left' })));\n else w.appendChild(section('Waiting on identities who left', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['What', 'Item', 'Waiting on', 'When'], d.rows.map(function (r) { return [r.kind, r.item, el('span', {}, r.waitingOn, ' ', statusPill(r.status)), r.detail]; })))));\n w.appendChild(el('p', { className: 'muted small' }, 'Reassign them in ISC: certification reviews from the campaign, approvals from the request. Objects owned by identities who left (sources, roles, access profiles) are on ',\n el('button', { className: 'btn link', style: 'padding:0', text: 'Lookup → Ownership', onclick: function () { state.lk.tab = 'ownership'; showPage('lookup'); } }), '.'));\n }\n\n function wnReminders(w, H, desc) {\n var sel = daysSelect(H, [[3, 'Due within 3 days'], [7, 'Due within 7 days'], [14, 'Due within 14 days'], [30, 'Due within 30 days']], 'Due within');\n if (!wnRunBar(w, H, 'reminders', 'Find reviews due', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n var left = d.reviewers.reduce(function (a, r) { return a + r.decisionsLeft; }, 0);\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.reviewers.length, 'reviewers to remind'), stat(d.rows.length, 'open certifications'), stat(left, 'decisions still to make'), stat(d.rows.filter(function (r) { return r.daysLeft < 0; }).length, 'already overdue', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No open certification is due in this period.' })); return; }\n var copy = el('button', { className: 'btn sm', disabled: !d.emails.length, onclick: function () {\n try { navigator.clipboard.writeText(d.emails.join('; ')).then(function () { toast(d.emails.length + ' email addresses copied'); }, function () { toast('Could not copy; select them from the download instead'); }); } catch (e) { toast('Could not copy; select them from the download instead'); }\n } }, icon('copy'), 'Copy reviewer emails');\n var mail = d.emails.length ? el('a', { className: 'btn sm', href: 'mailto:?bcc=' + encodeURIComponent(d.emails.join(',')) + '&subject=' + encodeURIComponent('Reminder: your access review is due soon') + '&body=' + encodeURIComponent('Hello,\\n\\nYou have an access review in SailPoint that is due soon. Please open SailPoint, go to Certifications, and complete your decisions before the deadline.\\n\\nThank you.') }, icon('inbox'), 'Email draft (BCC)') : null;\n w.appendChild(section('Reviewers', d.reviewers.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, copy, mail, downloads(H.job)),\n simpleTable(['Reviewer', 'Email', 'Certifications', 'Decisions left', 'Soonest deadline', 'Campaigns'], d.reviewers.map(function (r) {\n return [el('span', {}, r.reviewer, ' ', statusPill(r.status)), r.email, r.certifications, r.decisionsLeft, r.soonest === null ? null : pill(daysText(r.soonest), r.soonest <= 2 ? 'lose' : 'off'), r.campaigns.join(', ')];\n })))));\n w.appendChild(el('p', { className: 'muted small' }, 'Reviewers who left are not in the copied emails; reassign their reviews instead (see \"Waiting on leavers\"). For progress, approve rates and rubber-stamped reviews, see ',\n el('button', { className: 'btn link', style: 'padding:0', text: 'Audit > Certifications', onclick: function () { state.au.tab = 'certs'; showPage('certs'); } }), '.'));\n }\n\n function wnPeople(w, H, desc) {\n var W = wnState();\n var st = W.settings && W.settings !== 'loading' ? W.settings : null;\n var p = (st && st.people) || {};\n var attr = el('input', { className: 'input', value: p.endDateAttribute || '', placeholder: 'endDate', style: 'max-width:220px', 'aria-label': 'End-date attribute' });\n var q = el('input', { className: 'input', value: p.query || '', placeholder: 'All active identities, or e.g. attributes.employeeType:contractor', style: 'max-width:420px', 'aria-label': 'Which identities' });\n var msg = el('span');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Settings' })),\n el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Identity attribute with the end date' }), attr),\n el('label', { className: 'field', style: 'margin:0;flex:1' }, el('span', { className: 'lbl', text: 'Which identities (search query, optional)' }), q),\n el('button', { className: 'btn', style: 'align-self:flex-end', onclick: function () {\n msg.textContent = '';\n api('/api/warnings/settings', 'PUT', { people: { endDateAttribute: attr.value.trim(), query: q.value.trim() } }).then(function () { W.settings = null; toast('Saved. The instant check now includes \"Active after end date\".'); renderWarnings(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save')), msg,\n el('p', { className: 'muted small', style: 'margin:8px 0 0', text: 'Use the name of the identity attribute as in the identity profile (not the display name). Dates like 2026-12-31, 12/31/2026 or epoch numbers are understood.' })));\n var sel = daysSelect(H, [[7, 'Ending within 7 days'], [30, 'Ending within 30 days'], [90, 'Ending within 90 days']], 'Ending within');\n if (!wnRunBar(w, H, 'people', 'Check end dates', desc, sel, function () { return { days: H.days }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.pastEnd.length, 'still active after end date', 'lose'), stat(d.endingSoon.length, 'ending within ' + d.days + ' days'), stat(d.withDate, 'of ' + fmtNum(d.checked) + ' have an end date')));\n var tbl = function (list, label) { return simpleTable(['Identity', 'End date', 'Manager', 'Lifecycle state'], list.slice(0, 2000).map(function (r) { return [r.person, el('span', { style: 'white-space:nowrap' }, r.endDate.slice(0, 10) + ' ', pill(daysText(r.daysLeft), r.daysLeft < 0 ? 'lose' : 'off')), r.manager, r.lifecycle]; }), label); };\n if (d.pastEnd.length) w.appendChild(section('Still active after their end date', d.pastEnd.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)), tbl(d.pastEnd, 'Identities still active after their end date'))));\n if (d.endingSoon.length) w.appendChild(section('Ending soon', d.endingSoon.length, tbl(d.endingSoon, 'Identities ending soon')));\n if (!d.pastEnd.length && !d.endingSoon.length && d.withDate) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No one is past or near their end date' })));\n w.appendChild(el('p', { className: 'muted small', text: 'Identities past their end date usually mean the HR source still sends them as active, or the lifecycle state does not react to the end date. Check with HR before disabling anyone.' }));\n }\n\n function wnAdmins(w, H, desc) {\n if (!wnRunBar(w, H, 'admins', 'List ISC admins', desc)) return;\n var d = H.data;\n var fresh = d.rows.filter(function (r) { return r.isNew; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'identities with a user level'), stat(d.totals.orgAdmins, 'Org admins'), stat(d.totals.left, 'who have left', 'lose'), stat(d.since ? fresh : null, d.since ? 'new since ' + d.since.slice(0, 10) : 'new: from the next look on', 'lose')));\n w.appendChild(el('div', { style: 'display:grid;grid-template-columns:minmax(220px,1fr) 3fr;gap:16px;align-items:start' },\n section('By user level', d.byLevel.length, simpleTable(['User level', 'Identities'], d.byLevel.map(function (l) { return [levelName(l.level), l.people]; }))),\n section('Identities', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Identity', 'User levels', 'Lifecycle state', 'Status'], d.rows.map(function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.levels.map(levelName).join(', '), r.lifecycle, el('span', {}, statusPill(r.status), r.isNew ? pill('new', 'off') : null)];\n }))))));\n w.appendChild(el('p', { className: 'muted small', text: 'User levels are the \"IdentityNow\" source entitlements found by search. Last sign-in is not shown: ISC gives it per identity through another API. Remove user levels in ISC under Admin > Identities > the identity > User level.' }));\n }\n function levelName(l) {\n var M = { ORG_ADMIN: 'Org admin', CERT_ADMIN: 'Certification admin', HELPDESK: 'Help desk', DASHBOARD: 'Dashboard', REPORT_ADMIN: 'Report admin', ROLE_ADMIN: 'Role admin', ROLE_SUBADMIN: 'Role sub-admin', SOURCE_ADMIN: 'Source admin', SOURCE_SUBADMIN: 'Source sub-admin', SAAS_MANAGEMENT_ADMIN: 'SaaS management admin', SAAS_MANAGEMENT_READER: 'SaaS management reader' };\n return M[l] || l;\n }\n\n function wnCatalog(w, H, desc) {\n if (!wnRunBar(w, H, 'catalog', 'Check the catalog', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.score === null ? null : T.score, 'quality score (% complete)'), stat(T.items, 'requestable items'), stat(T.noDescription, 'without a description', 'lose'), stat(T.noOwner, 'without an owner', 'lose'), stat(T.ownerLeft, 'owner has left', 'lose')));\n w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'Requestable items', 'Complete', 'Score'], d.bySource.map(function (s) { return [s.source, s.items, s.complete, progressBar(s.score, s.score < 60)]; }))));\n if (d.unused) {\n w.appendChild(section('Nobody has it', d.unused.length, d.unused.length ? el('div', {},\n el('p', { className: 'muted', text: 'Roles and access profiles that no identity holds, out of ' + fmtNum(T.unusedChecked || 0) + ' checked. Candidates to retire, or roles whose membership criteria match nobody (check those with Role tools > Preview a role change).' }),\n simpleTable(['Type', 'Name', 'Source', 'Owner', 'Requestable', 'Enabled'], d.unused.slice(0, 2000).map(function (r) { return [r.type, r.name, r.source || null, r.owner || null, r.requestable ? 'yes' : 'no', r.enabled ? 'yes' : pill('disabled', 'off')]; }), 'Roles and access profiles nobody has'))\n : el('p', { className: 'muted', text: 'Every role and access profile checked (' + fmtNum(T.unusedChecked || 0) + ') is held by at least one identity.' })));\n }\n if (!d.rows.length) return;\n var f = el('input', { className: 'input', placeholder: 'Filter by name, source or owner...', value: H.q || '', style: 'max-width:300px', 'aria-label': 'Filter' });\n var box = el('div');\n var draw = function () {\n var q = (H.q || '').toLowerCase();\n var list = d.rows.filter(function (r) { return !q || (r.name + ' ' + (r.source || '') + ' ' + (r.owner || '')).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(simpleTable(['Type', 'Name', 'Source', 'Owner', 'Missing'], list.slice(0, 2000).map(function (r) { return [r.type, r.name, r.source, r.owner, el('span', {}, r.issues.map(function (x) { return el('span', { className: 'chg ' + (/left|longer/.test(x) ? 'lose' : 'off'), style: 'margin:0 4px 2px 0;display:inline-block', text: x }); }))]; })));\n if (list.length > 2000 || d.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { H.q = f.value; draw(); });\n w.appendChild(section('Items to fix', d.rows.length + (d.more || 0), el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, el('span', { style: 'flex:1' }), downloads(H.job)), box)));\n draw();\n }\n\n function wnGrowth(w, H, desc) {\n var W = wnState();\n var st = W.settings && W.settings !== 'loading' ? W.settings : {};\n var lic = el('input', { className: 'input', type: 'number', min: '1', value: st.licensed || '', placeholder: 'e.g. 10000', style: 'max-width:160px', 'aria-label': 'Licensed identities' });\n var basis = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Count' }, [['all', 'All identities'], ['active', 'Active identities only']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n basis.value = st.basis || 'all';\n var msg = el('span');\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Your license' })),\n el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Licensed identities' }), lic),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Count' }), basis),\n el('button', { className: 'btn', style: 'align-self:flex-end', onclick: function () {\n msg.textContent = '';\n api('/api/warnings/settings', 'PUT', { licensed: lic.value === '' ? '' : Number(lic.value), basis: basis.value }).then(function () { W.settings = null; toast('Saved'); renderWarnings(); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });\n } }, icon('save'), 'Save')), msg));\n if (!wnRunBar(w, H, 'growth', 'Count identities', desc)) return;\n var d = H.data;\n var cur = d.basis === 'active' ? d.active : d.total;\n var pace = d.netPerMonth !== null ? d.netPerMonth : d.addedPerMonth;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.total, 'identities'), stat(d.active, 'active'), stat(pace, d.forecastFrom === 'kept counts' ? 'net change per month' : 'new per month (3-month average)'),\n d.licensed ? stat(d.licensed - cur, 'left of your ' + fmtNum(d.licensed), d.licensed - cur < 0 ? 'lose' : '') : null));\n if (d.licensed) {\n var used = cur === null ? 0 : Math.round((cur * 100) / d.licensed);\n var when = d.monthsToLicensed === null ? (pace && pace > 0 ? null : 'not growing at the current pace') : d.monthsToLicensed === 0 ? 'already reached' : 'in about ' + d.monthsToLicensed + ' months (' + new Date(Date.now() + d.monthsToLicensed * 30.4 * 86400000).toISOString().slice(0, 7) + ')';\n w.appendChild(el('div', { className: 'banner ' + (used >= 100 ? 'bad' : d.monthsToLicensed !== null && d.monthsToLicensed <= 6 ? 'warn' : 'ok') }, el('b', { text: used + '% of your license used' }), when ? el('span', { text: 'Licensed number reached ' + when }) : null));\n } else w.appendChild(el('div', { className: 'note', text: 'Enter your licensed number above to see when you reach it.' }));\n var max = Math.max.apply(null, d.monthly.map(function (m) { return m.added || 0; }).concat([1]));\n w.appendChild(section('New identities per month', d.monthly.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Month', 'New identities', 'Compared'], d.monthly.map(function (m) { return [m.month, m.added, m.added === null ? null : el('div', { className: 'meter', style: 'width:240px;margin:4px 0' }, el('span', { style: 'width:' + Math.round(((m.added || 0) * 100) / max) + '%' }))]; })))));\n if (d.history && d.history.length > 1) w.appendChild(section('Counts kept on this computer', d.history.length, simpleTable(['Date', 'Identities', 'Active'], d.history.slice(-12).reverse().map(function (p) { return [p.date, p.total, p.active]; }))));\n }\n // ---------- Audit readiness: access outliers, review coverage, provisioning speed (Audit); identity data (Warnings) ----------\n function arState() {\n if (!state.ar) state.ar = { outliers: { groupBy: 'department', factor: 3 }, coverage: { months: 12 }, speed: { days: 30, limit: 24 }, quality: { attribute: 'department' } };\n return state.ar;\n }\n function arRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/audit/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function attrInput(H, key, label, placeholder) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder, style: 'max-width:180px', 'aria-label': label });\n i.addEventListener('input', function () { H[key] = i.value.trim(); });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function numSelect(H, key, options, label) {\n var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, options.map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));\n s.value = String(H[key]);\n s.addEventListener('change', function () { H[key] = Number(s.value); });\n return s;\n }\n function hoursText(h) { return h < 1 ? Math.round(h * 60) + ' min' : h < 48 ? (Math.round(h * 10) / 10) + ' h' : (Math.round(h / 2.4) / 10) + ' days'; }\n\n // access outliers\n function renderOutliers(w) {\n var H = arState().outliers;\n var extras = el('div', { className: 'bar' }, attrInput(H, 'groupBy', 'Compare identities by attribute', 'department'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Outlier when at least' }), numSelect(H, 'factor', [[2, '2× the group median'], [3, '3× the group median'], [5, '5× the group median']], 'Outlier factor')));\n if (!arRunBar(w, H, 'outliers', 'Find outliers', 'Identities with far more access than others in the same group. Groups need at least 5 identities; a difference of 10 items or more counts.', extras, function () { return { groupBy: H.groupBy || 'department', factor: H.factor }; }, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'outliers', 'lose'), stat(d.groups.length, 'groups compared'), stat(d.checked, 'active identities checked'), stat(d.skippedSmallGroups, 'in groups too small to compare')));\n if (d.rows.length) w.appendChild(section('Outliers', d.rows.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Identity', 'Group (' + d.groupBy + ')', 'Access items', 'Group median', 'Times', 'Entitlements', 'Roles'], d.rows.slice(0, 2000).map(function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.group, r.access, r.groupMedian, pill(r.times + '×', r.times >= 5 ? 'lose' : 'off'), r.entitlements, r.roles];\n }), 'Access outliers'))));\n else if (d.groups.length) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No outliers at this level' })));\n if (d.groups.length) w.appendChild(section('Groups', d.groups.length, simpleTable(['Group', 'Identities', 'Median access items', 'Outliers'], d.groups.slice(0, 500).map(function (g) { return [g.group, g.people, g.median, g.outliers]; }), 'Groups compared')));\n w.appendChild(el('p', { className: 'muted small', text: 'Access items are what ISC counts for each identity (entitlements, roles and access profiles). An outlier is not wrong by itself: admins and long-serving staff often have more. Use it to pick whom to review first.' }));\n }\n\n // certification coverage\n function renderCoverage(w) {\n var H = arState().coverage;\n var extras = numSelect(H, 'months', [[6, 'Last 6 months'], [12, 'Last 12 months'], [24, 'Last 24 months']], 'Period');\n if (!arRunBar(w, H, 'coverage', 'Check coverage', 'Which sources and privileged entitlements a certification reviewed in the period, and which none did.', extras, function () { return { months: H.months }; }, renderAudit)) return;\n var d = H.data, P = d.privileged;\n var srcTotal = d.sources.length + d.notReviewedSources.length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns in ' + d.months + ' months'), stat(d.reviewItems, 'review items'),\n stat(d.notReviewedSources.length, 'of ' + fmtNum(srcTotal) + ' sources not reviewed', 'lose'), stat(P.notReviewed.length, 'of ' + fmtNum(P.total) + ' privileged entitlements not reviewed', 'lose')));\n w.appendChild(el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)));\n if (d.notReviewedSources.length) w.appendChild(section('Sources no certification reviewed', d.notReviewedSources.length, el('div', { style: 'display:flex;flex-wrap:wrap;gap:6px' }, d.notReviewedSources.map(function (s) { return pill(s, 'lose'); }))));\n if (P.notReviewed.length) w.appendChild(section('Privileged entitlements not reviewed', P.notReviewed.length, simpleTable(['Entitlement', 'Source'], P.notReviewed.slice(0, 2000).map(function (x) { return [x.name, x.source]; }), 'Privileged entitlements not reviewed')));\n if (d.sources.length) w.appendChild(section('Reviewed sources', d.sources.length, simpleTable(['Source', 'Items reviewed', 'Latest review', 'Campaigns'], d.sources.map(function (s) { return [s.source, s.reviewedItems, s.lastReviewed ? s.lastReviewed.slice(0, 10) : null, s.campaigns.slice(0, 3).join(', ') + (s.campaigns.length > 3 ? ' +' + (s.campaigns.length - 3) : '')]; }), 'Reviewed sources')));\n if (d.byAccessType.length) w.appendChild(el('p', { className: 'muted small', text: 'Review items by type: ' + d.byAccessType.map(function (x) { return x.type.toLowerCase().replace(/_/g, ' ') + ' ' + fmtNum(x.items); }).join(', ') + '. Roles and access profiles count for the source of their entitlements only when ISC names it in the review item. A campaign still running counts as reviewing what it contains.' }));\n }\n\n // provisioning speed\n function renderSpeed(w) {\n var H = arState().speed;\n var extras = el('div', { className: 'bar' }, numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [90, 'Last 90 days']], 'Period'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Removals should take at most' }), numSelect(H, 'limit', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '3 days']], 'Removal limit')));\n if (!arRunBar(w, H, 'speed', 'Measure', 'How long account changes take per source, and access removals (disable, delete) that were slow or are still not done.', extras, function () { return { days: H.days, removalLimitHours: H.limit }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.changes, 'account changes'), stat(T.removals, 'removals'), stat(T.openRemovals, 'removals still not done after ' + d.removalLimitHours + ' h', 'lose'), stat(T.slowRemovals, 'removals that took longer', 'lose')));\n if (d.slow.length) w.appendChild(section('Slow or open removals', d.slow.length, el('div', {}, el('div', { className: 'bar', style: 'justify-content:flex-end;margin-bottom:8px' }, downloads(H.job)),\n simpleTable(['Identity', 'Source', 'Change', 'Started (UTC)', 'Took', 'State'], d.slow.slice(0, 2000).map(function (x) { return [x.person, x.source, x.op, x.started.slice(0, 16).replace('T', ' '), hoursText(x.hours), pill(x.state, x.state === 'not done' ? 'lose' : 'off')]; }), 'Slow or open removals'))));\n else if (T.removals) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'Every removal finished within ' + d.removalLimitHours + ' hours' })));\n if (d.rows.length) w.appendChild(section('By source', d.rows.length, simpleTable(['Source', 'Change', 'Count', 'Median', '90% within', 'Longest', 'Over the limit'], d.rows.map(function (r) {\n return [r.source, r.op, r.count, hoursText(r.medianHours), hoursText(r.p90Hours), hoursText(r.maxHours), r.slower ? pill(String(r.slower), 'lose') : 0];\n }), 'Provisioning speed by source')));\n }\n\n // identity data quality (Warnings tab)\n function wnQuality(w, H, desc) {\n var A = arState().quality;\n var extras = attrInput(A, 'attribute', 'Attribute everyone should have', 'department');\n if (!arRunBar(w, A, 'quality', 'Check identity data', desc, extras, function () { return { attribute: A.attribute || 'department' }; }, renderWarnings)) return;\n var d = A.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.noManager, 'without a manager', 'lose'), stat(T.noEmail, 'without an email', 'lose'), stat(T.noAttribute, 'without ' + d.attribute, 'lose'), stat(T.sharedEmail, 'sharing an email', 'lose'), stat(d.checked, 'active identities checked')));\n if (d.sharedEmails.length) w.appendChild(section('Emails used by more than one identity', d.sharedEmails.length, simpleTable(['Email', 'Identities'], d.sharedEmails.map(function (s) { return [s.email, s.people.join(', ')]; }), 'Shared emails')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No gaps found' }))); return; }\n var f = el('input', { className: 'input', placeholder: 'Filter by identity or issue...', value: A.q || '', style: 'max-width:280px', 'aria-label': 'Filter' });\n var box = el('div');\n var draw = function () {\n var q = (A.q || '').toLowerCase();\n var list = d.rows.filter(function (r) { return !q || (r.person + ' ' + r.issue).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(simpleTable(['Identity', 'Email', 'Lifecycle state', 'Issue'], list.slice(0, 2000).map(function (r) { return [r.person, r.email, r.lifecycle, r.issue]; }), 'Identity data issues'));\n if (list.length > 2000 || d.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { A.q = f.value; draw(); });\n w.appendChild(section('Issues', d.rows.length + (d.more || 0), el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, el('span', { style: 'flex:1' }), downloads(A.job)), box)));\n draw();\n w.appendChild(el('p', { className: 'muted small', text: 'Missing managers break approvals and manager certifications; missing emails break notifications; shared emails often mean duplicate identities or test accounts. Fix them in the HR source, not in ISC.' }));\n }\n // ---------- Joiner, mover and leaver gaps; admin accounts; accepted exceptions ----------\n function lcState() {\n if (!state.lc) state.lc = { joiners: { graceDays: 3, share: 90, startDateAttribute: '' }, leavers: { kind: 'all' }, movers: { groupBy: 'department', maxShare: 5 }, accounts: { words: 'admin, adm, svc, service, test, tst, sa, root, sys, shared, generic' }, exceptions: {} };\n return state.lc;\n }\n function lcRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lifecycle/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function filteredTable(H, rows, headers, toCells, label, extraBar) {\n var f = el('input', { className: 'input', placeholder: 'Filter...', value: H.q || '', style: 'max-width:280px', 'aria-label': 'Filter ' + label });\n var box = el('div');\n var draw = function () {\n var q = (H.q || '').toLowerCase();\n var list = rows.filter(function (r) { return !q || JSON.stringify(r).toLowerCase().indexOf(q) >= 0; });\n box.textContent = '';\n box.appendChild(list.length ? simpleTable(headers, list.slice(0, 2000).map(toCells), label) : el('p', { className: 'muted', text: 'Nothing matches.' }));\n if (list.length > 2000 || H.data.more) box.appendChild(el('p', { className: 'muted small', text: 'Showing the first 2,000. The download has all of them.' }));\n };\n f.addEventListener('input', function () { H.q = f.value; draw(); });\n draw();\n return el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, f, extraBar || null, el('span', { style: 'flex:1' }), downloads(H.job)), box);\n }\n\n // Warnings > Missed joiners\n function wnJoiners(w, _H, desc) {\n var H = lcState().joiners;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Birthright when held by' }), numSelect(H, 'share', [[80, '80% of the profile'], [90, '90% of the profile'], [95, '95% of the profile']], 'Birthright share')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Grace period' }), numSelect(H, 'graceDays', [[1, '1 day'], [3, '3 days'], [7, '7 days'], [14, '14 days']], 'Grace period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Also check joiners of the last' }), numSelect(H, 'recentDays', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Recent joiners')),\n attrInput(H, 'startDateAttribute', 'Start-date attribute (optional)', 'startDate'));\n if (!H.recentDays) H.recentDays = 30;\n if (!lcRunBar(w, H, 'joiners', 'Find missed joiners', desc, extras, function () { return { share: H.share, graceDays: H.graceDays, recentDays: H.recentDays, startDateAttribute: H.startDateAttribute || undefined }; }, renderWarnings)) return;\n var d = H.data, E = d.evidence;\n if (!E) {\n var started = d.rows.filter(function (r) { return !r.missing.length; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length - started, 'missing a birthright account', 'lose'), stat(started, 'past start date, still pre-hire', 'lose'), stat(d.checked, 'active identities checked')));\n if (d.rows.length) w.appendChild(section('Missed joiners', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Identity profile', 'Created', 'Why', 'Missing accounts on'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.profile, r.created ? r.created.slice(0, 10) : null, r.reason, r.missing.length ? el('span', {}, r.missing.map(function (m) { return pill(m, 'lose'); })) : null];\n }, 'Missed joiners')));\n return;\n }\n var T = E.totals, bad = T['Criteria met, state not applied'] + T['Joiner ran, provisioning failed'] + T['No joiner activity recorded'] + T['Joiner ran, access not in place'];\n w.appendChild(el('div', { className: 'bigstats' },\n stat(T['Criteria met, state not applied'], 'criteria met, state not applied', 'lose'), stat(T['Joiner ran, provisioning failed'], 'joiner ran, provisioning failed', 'lose'),\n stat(T['No joiner activity recorded'] + T['Joiner ran, access not in place'], 'access missing, no create recorded', 'lose'), stat(T['Joiner ran, still in progress'], 'still in progress'),\n stat(T['Joiner complete'], 'joiner complete'), stat(T.checked, 'identities checked')));\n w.appendChild(el('p', { className: 'muted', text: 'ISC has no single \"joiner triggered\" event, so each identity is checked three ways: what their lifecycle state is set up to grant, whether the identity profile\\'s lifecycle mapping puts them in that state today (worked out with the Transform lab engine), and what ISC recorded (lifecycle changes, account activities, account creates passed or failed).' }));\n if (E.states.length) w.appendChild(section('What each lifecycle state grants', E.states.length, simpleTable(['Identity profile', 'Lifecycle state', 'Access profiles', 'Enables accounts on'], E.states.map(function (x) {\n return [x.profile, x.name + (x.enabled ? '' : ' (disabled)'), x.accessProfiles.map(function (a) { return a.name + (a.source ? ' (' + a.source + ')' : ''); }).join(', ') || '—', x.enableSources.map(function (a) { return a.name; }).join(', ') || '—'];\n }), 'Lifecycle state configuration')));\n if (d.birthright.length) w.appendChild(section('Accounts most of each profile has', d.birthright.length, simpleTable(['Identity profile', 'Active identities', 'Sources nearly everyone has'], d.birthright.map(function (b) {\n return [b.profile, b.people, b.sources.length ? b.sources.map(function (s) { return s.source + ' (' + s.share + '%)'; }).join(', ') : '—'];\n }), 'Birthright accounts per identity profile')));\n if (!bad && !T['State does not match the criteria']) w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No missed joiners: every identity checked has what their lifecycle state grants, or it is in progress' })));\n var tone = function (v) { return v === 'Joiner complete' ? 'gain' : v === 'Joiner ran, still in progress' || v === 'Could not tell' ? 'keep-other' : 'lose'; };\n w.appendChild(section('Identities checked', E.rows.length, filteredTable(H, E.rows, ['Identity', 'Lifecycle state', 'Verdict', 'Why', 'Recorded by ISC'], function (r) {\n var ev = r.evidence.length ? el('details', {}, el('summary', { text: r.evidence.length + ' record' + (r.evidence.length === 1 ? '' : 's') }),\n el('ul', { className: 'evlist' }, r.evidence.map(function (e) { return el('li', {}, el('span', { className: 'muted small', text: e.when ? e.when.slice(0, 16).replace('T', ' ') + ' ' : '' }), e.what, e.status ? ' ' : null, e.status ? pill(e.status.toLowerCase(), /fail|error/i.test(e.status) ? 'lose' : /pass|complete|commit/i.test(e.status) ? 'gain' : 'keep-other') : null, e.detail ? el('div', { className: 'small', text: e.detail }) : null); })))\n : el('span', { className: 'muted', text: 'nothing' });\n return [el('span', {}, r.person, el('div', { className: 'muted small', text: r.profile + (r.created ? ' · created ' + r.created.slice(0, 10) : '') })),\n el('span', {}, r.lifecycle || '—', r.criteria ? el('div', { className: 'small' + (r.criteria === r.lifecycle ? ' muted' : ''), text: 'criteria: ' + r.criteria }) : r.criteriaNote ? el('div', { className: 'muted small', text: r.criteriaNote }) : null),\n el('span', {}, pill(r.verdict, tone(r.verdict)), el('div', { className: 'muted small', text: r.reason })), r.why, ev];\n }, 'Joiner check')));\n w.appendChild(el('p', { className: 'muted small', text: 'Checked: identities missing what their lifecycle state grants, identities flagged by the birthright pattern (a source most of their identity profile has), past start dates, and everyone who joined in the period chosen. Birthright access given by roles with membership criteria is covered by the pattern, not the lifecycle state.' }));\n }\n\n // Warnings > Missed leavers\n function wnLeavers(w, _H, desc) {\n var H = lcState().leavers;\n if (!lcRunBar(w, H, 'leavers', 'Find missed leavers', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.hrDisabled, 'HR says gone, ISC says active', 'lose'), stat(T.enabledAccounts, 'enabled accounts of leavers', 'lose'), stat(T.roles, 'roles or access profiles of leavers', 'lose'), stat(T.leavers, 'leavers checked')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No missed leavers found' }))); return; }\n var kinds = [['all', 'All gaps'], ['HR account disabled, identity active', 'HR says gone, ISC says active'], ['Left, account still enabled', 'Accounts still enabled'], ['Left, still holds a role or access profile', 'Roles and access profiles']];\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Which gaps' }, kinds.map(function (k) { return el('option', { value: k[0], text: k[1] }); }));\n sel.value = H.kind;\n sel.addEventListener('change', function () { H.kind = sel.value; renderWarnings(); });\n var rows = H.kind === 'all' ? d.rows : d.rows.filter(function (r) { return r.kind === H.kind; });\n w.appendChild(section('Missed leavers', rows.length, filteredTable(H, rows, ['Identity', 'Lifecycle state', 'Gap', 'Detail', 'Source'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.lifecycle, pill(r.kind, /HR/.test(r.kind) ? 'lose' : 'off'), r.detail, r.source];\n }, 'Missed leavers', sel)));\n w.appendChild(el('p', { className: 'muted small', text: '\"HR says gone\" means the account on the identity’s own authoritative source is disabled while ISC still treats them as active: usually the lifecycle state does not follow the HR status. Identities active after their end date are on the End dates tab.' }));\n }\n\n // Warnings > Mover leftovers\n function renderMovers(w) {\n var H = lcState().movers;\n var extras = el('div', { className: 'bar' }, attrInput(H, 'groupBy', 'Compare identities by attribute', 'department'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Unusual when held by under' }), numSelect(H, 'maxShare', [[2, '2% of the group'], [5, '5% of the group'], [10, '10% of the group']], 'Unusual share')));\n if (!lcRunBar(w, H, 'movers', 'Find unusual access', 'Access that almost no one else in the identity’s group has: often left over from a previous job (movers) or given as a one-off.', extras, function () { return { groupBy: H.groupBy || 'department', maxShare: H.maxShare }; }, renderWarnings)) return;\n var d = H.data;\n var people = {}; d.rows.forEach(function (r) { people[r.person] = 1; });\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'unusual access items', 'lose'), stat(Object.keys(people).length, 'identities'), stat(d.rows.filter(function (r) { return r.privileged; }).length, 'of them privileged', 'lose'), stat(d.groups, 'groups compared')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No unusual access found' }))); return; }\n w.appendChild(section('Unusual access', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Group (' + d.groupBy + ')', 'Access', 'Source', 'Holders in group'], function (r) {\n return [el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.group, el('span', {}, r.access + ' ', r.privileged ? pill('privileged', 'lose') : null, el('div', { className: 'muted small', text: r.type })), r.source, r.holders + ' of ' + fmtNum(r.groupSize)];\n }, 'Unusual access')));\n w.appendChild(el('p', { className: 'muted small', text: 'Groups need at least 10 active identities. Access held by at most 3 identities of the group, and by fewer than the share you chose, counts as unusual. ISC user levels are left out (see Warnings > ISC admins).' }));\n }\n\n // Audit > Admin accounts\n function renderAdminAccounts(w) {\n var H = lcState().accounts;\n var inp = el('input', { className: 'input', value: H.words, style: 'min-width:340px', 'aria-label': 'Words in account names' });\n inp.addEventListener('input', function () { H.words = inp.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Words in account names' }), inp);\n if (!lcRunBar(w, H, 'accounts', 'Find accounts', 'Admin, service and test accounts that are linked to a person: often shared or privileged accounts hiding under a normal identity.', extras, function () { return { words: H.words.split(/[\\s,;]+/).filter(Boolean) }; }, renderAudit)) return;\n var d = H.data;\n var leftEnabled = d.rows.filter(function (r) { return r.left && !r.disabled; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.rows.length, 'accounts found'), stat(leftEnabled, 'enabled, identity has left', 'lose'), stat(d.rows.filter(function (r) { return r.privileged; }).length, 'privileged')));\n if (!d.rows.length) { w.appendChild(el('div', { className: 'banner ok' }, el('b', { text: 'No such accounts linked to identities' }))); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Source', 'Linked to', 'Matched', 'State'], function (r) {\n return [el('span', {}, r.account + ' ', r.privileged ? pill('privileged', 'lose') : null), r.source, el('span', {}, r.person, ' ', r.left ? pill('has left', 'lose') : null), r.word, r.disabled ? 'disabled' : 'enabled'];\n }, 'Admin and service accounts linked to identities')));\n w.appendChild(el('p', { className: 'muted small', text: 'A word matches when it is a separate part of the name: adm.alice, svc_backup and alice-test match; \"sample\" does not match \"sa\". Decide per account whether it should belong to the identity, to a service owner, or be removed.' }));\n }\n\n // Audit > Exceptions\n function renderExceptions(w) {\n var H = lcState().exceptions;\n if (!H.data && !H.busy) {\n H.busy = 'Loading...';\n api('/api/exceptions').then(function (d) { H.data = d; }, function (e) { H.error = errorText(e); }).then(function () { H.busy = null; if (state.au && state.au.tab === 'exceptions') renderAudit(); });\n }\n w.appendChild(el('p', { className: 'muted', text: 'Known findings someone accepted, with a reason and an end date. Until then they are left out of the instant check (on this computer and in scheduled checks), and they go into the evidence pack as your risk-acceptance register. Accept an item from the details of an instant check tile.' }));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n var mine = H.data.exceptions.filter(function (e) { return e.tenant === H.data.tenant; });\n var inForce = mine.filter(function (e) { return e.state === 'in force'; }).length;\n w.appendChild(el('div', { className: 'bigstats' }, stat(inForce, 'in force'), stat(mine.filter(function (e) { return e.state === 'expired'; }).length, 'expired: decide again', 'lose'), stat(mine.filter(function (e) { return e.state === 'ended'; }).length, 'ended')));\n if (!mine.length) { w.appendChild(el('p', { className: 'muted', text: 'No exceptions for this tenant yet.' })); return; }\n w.appendChild(section('Exceptions for this tenant', mine.length, simpleTable(['Check', 'Item', 'Reason', 'Accepted by', 'Until', 'State', 'Action'], mine.map(function (e) {\n return [e.checkLabel, e.key, e.reason, e.acceptedBy + ' (' + e.created.slice(0, 10) + ')', e.until,\n pill(e.state + (e.ended ? ' ' + e.ended.slice(0, 10) : ''), e.state === 'in force' ? 'keep-other' : e.state === 'expired' ? 'lose' : 'off'),\n e.state === 'in force' ? el('button', { className: 'btn sm', onclick: function () { endExceptionDialog(e); } }, 'End now') : null];\n }), 'Accepted exceptions')));\n }\n function endExceptionDialog(e) {\n var who = el('input', { className: 'input', placeholder: 'Your name', 'aria-label': 'Ended by' });\n var msg = el('div');\n var box = el('div', { className: 'card', role: 'dialog', 'aria-label': 'End exception', style: 'position:fixed;inset:auto 0 0 0;margin:0 auto 24px;max-width:520px;z-index:50;box-shadow:0 10px 40px rgba(0,0,0,.25)' },\n el('h3', { text: 'End this exception now?' }), el('p', { className: 'muted', text: e.checkLabel + ': ' + e.key }), who, msg,\n el('div', { className: 'bar', style: 'margin-top:10px;justify-content:flex-end' },\n el('button', { className: 'btn', onclick: function () { box.remove(); } }, 'Cancel'),\n el('button', { className: 'btn primary', onclick: function () {\n if (who.value.trim().length < 2) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: 'Say who ends it.' })); return; }\n api('/api/exceptions/' + e.id + '/end', 'POST', { by: who.value.trim() }).then(function () { box.remove(); lcState().exceptions.data = null; toast('Exception ended'); renderAudit(); }, function (err) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(err) })); });\n } }, 'End it')));\n box.addEventListener('keydown', function (ev) { if (ev.key === 'Escape') box.remove(); });\n document.body.appendChild(box);\n who.focus();\n }\n // Instant check: accept one row as an exception\n function acceptDialog(m, key, done) {\n var inYear = new Date(Date.now() + 90 * 86400000).toISOString().slice(0, 10);\n var reason = el('textarea', { className: 'input', rows: '2', placeholder: 'Why this is acceptable (e.g. vendor-managed account, reviewed by the security team)', 'aria-label': 'Reason' });\n var who = el('input', { className: 'input', placeholder: 'Name and role, e.g. Priya Shah, IAM lead', 'aria-label': 'Accepted by' });\n var until = el('input', { className: 'input', type: 'date', value: inYear, 'aria-label': 'Until', style: 'max-width:180px' });\n var msg = el('div');\n var box = el('div', { className: 'card', role: 'dialog', 'aria-label': 'Accept as exception', style: 'position:fixed;inset:auto 0 0 0;margin:0 auto 24px;max-width:560px;z-index:50;box-shadow:0 10px 40px rgba(0,0,0,.25)' },\n el('h3', { text: 'Accept as an exception' }), el('p', { className: 'muted', text: m.label + ': ' + key }),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Reason' }), reason),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Accepted by' }), who),\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Until (at most two years)' }), until), msg,\n el('div', { className: 'bar', style: 'justify-content:flex-end' },\n el('button', { className: 'btn', onclick: function () { box.remove(); } }, 'Cancel'),\n el('button', { className: 'btn primary', onclick: function () {\n api('/api/exceptions', 'POST', { check: m.id, key: key, reason: reason.value, acceptedBy: who.value, until: until.value }).then(function () {\n box.remove(); lcState().exceptions.data = null; toast('Accepted until ' + until.value + '. It is left out from the next check.'); if (done) done();\n }, function (err) { msg.textContent = ''; msg.appendChild(el('div', { className: 'error', text: errorText(err) })); });\n } }, 'Accept')));\n box.addEventListener('keydown', function (ev) { if (ev.key === 'Escape') box.remove(); });\n document.body.appendChild(box);\n reason.focus();\n }\n // ---------- Transform lab, Workflow lab, Credential map (all read-only; evaluated on this computer) ----------\n var LAB_SAMPLE_TRANSFORM = { type: 'static', attributes: { fn: { type: 'identityAttribute', attributes: { name: 'firstname' } }, ln: { type: 'identityAttribute', attributes: { name: 'lastname' } }, value: '$fn.substring(0,1).toLowerCase()$ln.toLowerCase()' } };\n var LAB_SAMPLE_TRIGGER = { identity: { id: 'id-1', name: 'jane.doe' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }] };\n function labState() {\n if (!state.lab) state.lab = {\n t: { json: JSON.stringify(LAB_SAMPLE_TRANSFORM, null, 2), name: '', implicit: '', identity: JSON.stringify(LAB_IDENTITY, null, 2), accounts: JSON.stringify([LAB_HR_ACCOUNT], null, 2), drafts: '', result: null, cases: [], people: {}, count: 200, query: '', attribute: '' },\n w: { json: '', trigger: JSON.stringify(LAB_SAMPLE_TRIGGER, null, 2), mocks: '{}', pick: '', result: null, replay: {} },\n c: {},\n };\n return state.lab;\n }\n function labCode(value, label, rows, oninput) {\n var ta = el('textarea', { className: 'yaml', spellcheck: 'false', 'aria-label': label, style: 'min-height:' + (rows * 20 + 28) + 'px' });\n ta.value = value;\n ta.addEventListener('input', function () { oninput(ta.value); });\n return ta;\n }\n function labParse(text, what) {\n if (!String(text).trim()) return undefined;\n try { return JSON.parse(text); } catch (e) { throw new Error(what + ' is not valid JSON: ' + e.message); }\n }\n function labValue(v) {\n if (v === null || v === undefined) return el('span', { className: 'muted', text: 'null (no value)' });\n return el('code', { text: typeof v === 'string' ? v : JSON.stringify(v) });\n }\n var LAB_STATUS = { ok: ['worked offline', 'gain'], error: ['fails (ISC would fail too)', 'lose'], 'isc-only': ['only ISC can work this out', 'keep-other'], random: ['different every run', 'keep-other'] };\n function labStatus(s) { var x = LAB_STATUS[s] || [s, 'keep-other']; return pill(x[0], x[1]); }\n function labLoadTenant(H, path, rerender) {\n if (H.list || H.loading) return;\n H.loading = true;\n api(path).then(function (r) { H.list = r; }, function (e) { H.listError = errorText(e); }).then(function () { H.loading = false; rerender(); });\n }\n\n // Tenant > Transform lab\n function renderTransformLab(w) {\n var L = labState().t, rr = renderBuild;\n labLoadTenant(L, '/api/lab/transforms', rr);\n w.appendChild(el('div', { className: 'note', text: 'Runs the transform on this computer, nothing is saved to ISC. Pick one of your transforms or identity profile mappings, or paste a draft. Velocity, dates and lookups work the way SailPoint documents them; anything only ISC can know (custom rules, uniqueness) is marked.' }));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Start from' }, el('option', { value: '', text: L.listError ? 'Could not read transforms' : L.list ? 'Start from one of yours...' : 'Reading your transforms...' }));\n if (L.list) {\n var g1 = el('optgroup', { label: 'Identity profile mappings' });\n L.list.mappings.forEach(function (m, i) { g1.appendChild(el('option', { value: 'm' + i, text: m.profile + ': ' + m.attribute + ' (' + m.summary + ')' })); });\n var g2 = el('optgroup', { label: 'Transforms' });\n L.list.transforms.forEach(function (t, i) { g2.appendChild(el('option', { value: 't' + i, text: t.name + ' (' + t.type + ')' })); });\n pick.appendChild(g1); pick.appendChild(g2);\n }\n pick.addEventListener('change', function () {\n var v = pick.value; if (!v) return;\n if (v[0] === 'm') { var m = L.list.mappings[Number(v.slice(1))]; L.json = JSON.stringify(m.transformDefinition, null, 2); L.name = m.profile + ' / ' + m.attribute; L.attribute = m.attribute; }\n else { var t = L.list.transforms[Number(v.slice(1))]; L.json = JSON.stringify({ type: t.type, attributes: t.attributes || {} }, null, 2); L.name = t.name; L.attribute = ''; }\n L.help = ''; L.result = null; L.people = {}; L.cases = (L.saved && L.saved[L.name]) || [];\n rr();\n });\n if (!L.saved) api('/api/lab/tests').then(function (r) { L.saved = r; }, function () { L.saved = {}; });\n var nameIn = el('input', { className: 'input', value: L.name, placeholder: 'Name (for saved test cases)', style: 'max-width:260px', 'aria-label': 'Transform name' });\n nameIn.addEventListener('input', function () { L.name = nameIn.value; });\n var exPick = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Examples' }, el('option', { value: '', text: 'Or start from an example...' }));\n TRANSFORM_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });\n exPick.addEventListener('change', function () {\n var x = TRANSFORM_EXAMPLES[Number(exPick.value)]; if (!x) return;\n L.json = JSON.stringify(x.transform, null, 2); L.name = x.title; L.attribute = '';\n L.implicit = x.implicit || ''; L.identity = JSON.stringify(x.identity || LAB_IDENTITY, null, 2);\n L.accounts = JSON.stringify(x.accounts || [], null, 2); L.drafts = x.drafts ? JSON.stringify(x.drafts, null, 2) : '';\n L.help = x.help; L.result = null; L.people = {}; L.cases = [];\n rr();\n });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, nameIn));\n if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));\n\n var runBtn = el('button', { className: 'btn primary', onclick: function () { labRunTransform(L, rr); } }, icon('play'), 'Run');\n var left = el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Transform (JSON)' }), labCode(L.json, 'Transform JSON', 16, function (v) { L.json = v; }));\n var imp = el('input', { className: 'input', value: L.implicit, placeholder: 'e.g. 2024-03-01 or Sales', 'aria-label': 'Input value' });\n imp.addEventListener('input', function () { L.implicit = imp.value; });\n var right = el('div', { style: 'flex:1;min-width:300px' },\n el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Input value (what the identity profile mapping passes in)' }), imp),\n el('div', { className: 'lbl', text: 'Identity attributes (JSON)' }), labCode(L.identity, 'Identity attributes JSON', 4, function (v) { L.identity = v; }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Accounts (JSON list; used by accountAttribute)' }), labCode(L.accounts, 'Accounts JSON', 7, function (v) { L.accounts = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Each account: \"source\" (the source name the transform asks for), \"attributes\" (the account\\'s attributes); optional \"nativeIdentity\", \"name\" and \"created\", which accountFilter and the oldest-first rule use.' }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Other transforms (JSON list; used by reference)' }), labCode(L.drafts, 'Other transforms JSON', 4, function (v) { L.drafts = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Drafts with a \"name\", \"type\" and \"attributes\". A reference looks here first, then in your tenant\\'s saved transforms, so you can test a chain before saving any of it.' }),\n el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn));\n w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' }, left, right));\n\n if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));\n var R = L.result;\n if (R) {\n var r = R.result;\n w.appendChild(section('Result', null, el('div', {},\n el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('b', { text: 'Value: ' }), labValue(r.value), labStatus(r.status)),\n r.error ? el('div', { className: 'error', text: r.error }) : null,\n r.assumptions.length ? el('div', { className: 'note' }, el('b', { text: 'Assumed where SailPoint does not document it: ' }), r.assumptions.join(' · ')) : null,\n simpleTable(['Step', 'Transform', 'Input', 'Output', 'Note'], r.trace.map(function (s) {\n return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.type }), s.name || null, s.input === undefined ? null : labValue(s.input), s.error ? pill(s.error, 'lose') : labValue(s.output), s.note || null];\n }), 'How the value was worked out'))));\n }\n renderLabCases(w, L, rr);\n renderLabPeople(w, L, rr);\n }\n function labInput(L, implicit) {\n var input = { implicit: implicit === undefined ? (L.implicit === '' ? undefined : L.implicit) : implicit };\n var id = labParse(L.identity, 'Identity attributes'); if (id) input.identity = id;\n var ac = labParse(L.accounts, 'Accounts'); if (ac) input.accounts = ac;\n return input;\n }\n function labRunTransform(L, rr) {\n L.error = null;\n try {\n var tr = labParse(L.json, 'The transform');\n var cases = L.cases.map(function (c) { return { name: c.name, expected: c.expected, input: labInput(L, c.implicit) }; });\n api('/api/lab/transform/run', 'POST', { transform: tr, input: labInput(L), cases: cases, transforms: labParse(L.drafts, 'Other transforms') }).then(function (r) {\n L.result = r;\n (r.cases || []).forEach(function (x, i) { if (L.cases[i]) L.cases[i].last = x; });\n }, function (e) { L.error = errorText(e); }).then(rr);\n } catch (e) { L.error = e.message; rr(); }\n }\n function renderLabCases(w, L, rr) {\n var addBtn = el('button', { className: 'btn sm', onclick: function () {\n var got = L.result && L.result.result.value;\n L.cases.push({ name: 'Case ' + (L.cases.length + 1), implicit: L.implicit, expected: got === null || got === undefined ? '' : String(got) });\n rr();\n } }, icon('plus'), 'Add the current input as a case');\n var saveBtn = el('button', { className: 'btn sm', disabled: !L.name, onclick: function () {\n api('/api/lab/tests', 'POST', { transform: L.name, cases: L.cases.map(function (c) { return { name: c.name, implicit: c.implicit, expected: c.expected }; }) }).then(function (r) { L.saved = r; toast('Test cases saved on this computer'); }, function (e) { toast(errorText(e)); });\n } }, icon('save'), 'Save cases');\n var passed = L.cases.filter(function (c) { return c.last && c.last.pass; }).length, ran = L.cases.filter(function (c) { return c.last; }).length;\n var body = el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, addBtn, saveBtn, el('span', { className: 'muted small', text: L.name ? 'Saved for \"' + L.name + '\" in your IdentityScope folder.' : 'Give the transform a name to save its cases.' }), el('span', { style: 'flex:1' }), ran ? pill(passed + ' of ' + ran + ' pass', passed === ran ? 'gain' : 'lose') : null));\n if (L.cases.length) {\n body.appendChild(simpleTable(['Case', 'Input value', 'Expected', 'Got', ''], L.cases.map(function (c, i) {\n var n = el('input', { className: 'input', value: c.name, 'aria-label': 'Case name ' + (i + 1) }); n.addEventListener('input', function () { c.name = n.value; });\n var v = el('input', { className: 'input', value: c.implicit || '', 'aria-label': 'Case input ' + (i + 1) }); v.addEventListener('input', function () { c.implicit = v.value; });\n var x = el('input', { className: 'input', value: c.expected || '', 'aria-label': 'Expected value ' + (i + 1) }); x.addEventListener('input', function () { c.expected = x.value; });\n return [n, v, x, c.last ? el('span', {}, pill(c.last.pass ? 'pass' : 'fail', c.last.pass ? 'gain' : 'lose'), ' ', el('code', { text: c.last.got })) : null,\n el('button', { className: 'btn sm', 'aria-label': 'Remove case ' + (i + 1), onclick: function () { L.cases.splice(i, 1); rr(); } }, icon('trash'))];\n }), 'Test cases'));\n body.appendChild(el('p', { className: 'muted small', text: 'Cases use the identity attributes and accounts above with their own input value. Run checks every case.' }));\n }\n w.appendChild(section('Test cases', L.cases.length, body));\n }\n function renderLabPeople(w, L, rr) {\n var H = L.people;\n var count = numSelect(L, 'count', [[50, '50 identities'], [200, '200 identities'], [500, '500 identities'], [2000, '2,000 identities']], 'How many identities');\n var q = attrInput(L, 'query', 'Which identities (search query, optional)', 'attributes.department:Sales');\n var at = attrInput(L, 'attribute', 'Compare with identity attribute (optional)', 'email');\n var go = el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () {\n try { runJobInto(H, '/api/lab/transform/people', { transform: labParse(L.json, 'The transform'), transforms: labParse(L.drafts, 'Other transforms'), attribute: L.attribute || undefined, query: L.query || undefined, count: L.count }, rr); } catch (e) { toast(e.message); }\n } }, icon('people'), 'Run on real identities');\n var body = el('div', {}, el('p', { className: 'muted', text: 'Reads real identities and their accounts from ISC and works the value out for each, on this computer. With an attribute to compare, it shows where the offline result differs from what ISC holds now: use it before changing a mapping, or to check this engine against your tenant.' }),\n el('div', { className: 'bar', style: 'margin-bottom:12px;align-items:flex-end' }, q, at, el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'How many' }), count), go));\n if (H.busy) body.appendChild(busyBox(H.busy));\n if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.data) {\n var d = H.data, S = d.summary;\n (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });\n body.appendChild(el('div', { className: 'bigstats' }, d.attribute ? stat(S.same, 'same as ISC') : null, d.attribute ? stat(S.different, 'different from ISC', 'lose') : null, stat(S.empty, 'no value'), stat(S.errors, 'errors', 'lose'), stat(S.iscOnly + S.random, 'only ISC can say'), stat(d.people, 'identities')));\n if (d.distinct.length) body.appendChild(el('p', { className: 'muted small', text: 'Most common results: ' + d.distinct.slice(0, 8).map(function (x) { return (x.value || '(empty)') + ' × ' + x.people; }).join(', ') }));\n var show = d.attribute ? d.rows.slice().sort(function (a, b) { return (a.same === false ? 0 : 1) - (b.same === false ? 0 : 1); }) : d.rows;\n body.appendChild(filteredTable(H, show, ['Identity', d.attribute ? 'In ISC now' : 'Current', 'Offline result', 'Result'], function (r) {\n return [r.person, r.current === undefined ? null : labValue(r.current), labValue(r.result), r.status !== 'ok' ? labStatus(r.status) : d.attribute ? pill(r.same ? 'same' : 'different', r.same ? 'gain' : 'lose') : null];\n }, 'Transform results per identity'));\n }\n w.appendChild(section('Try it on real identities', null, body));\n }\n\n // Tenant > Workflow lab\n function renderWorkflowLab(w) {\n var L = labState().w, rr = renderBuild;\n labLoadTenant(L, '/api/lab/workflows', rr);\n w.appendChild(el('div', { className: 'note', text: 'Walks a workflow step by step on this computer with a trigger you give it: which branch each condition takes, what each variable becomes and what each action would send. Nothing is called, so the workflow does not need to be disabled. Secrets are never shown.' }));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Workflow' }, el('option', { value: '', text: L.listError ? 'Could not read workflows' : L.list ? 'Pick one of your workflows...' : 'Reading your workflows...' }));\n (L.list || []).forEach(function (x) { pick.appendChild(el('option', { value: x.id, text: x.name + (x.enabled ? '' : ' (disabled)') })); });\n pick.value = L.pick;\n pick.addEventListener('change', function () {\n L.pick = pick.value;\n var x = (L.list || []).filter(function (y) { return y.id === L.pick; })[0];\n if (x) L.json = JSON.stringify(x.definition || {}, null, 2);\n L.help = '';\n L.result = null; L.replay = {}; rr();\n });\n var exPick = el('select', { className: 'input', style: 'max-width:360px', 'aria-label': 'Workflow examples' }, el('option', { value: '', text: 'Or start from an example...' }));\n WORKFLOW_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });\n exPick.addEventListener('change', function () {\n var x = WORKFLOW_EXAMPLES[Number(exPick.value)]; if (!x) return;\n L.pick = ''; L.json = JSON.stringify(x.definition, null, 2); L.trigger = JSON.stringify(TRIGGER_SAMPLES[x.trigger].input, null, 2);\n L.mocks = JSON.stringify(x.mocks || {}, null, 2); L.help = x.help; L.result = null; L.replay = {};\n rr();\n });\n var trPick = el('select', { className: 'input', style: 'max-width:280px', 'aria-label': 'Trigger input samples' }, el('option', { value: '', text: 'Trigger input sample...' }));\n TRIGGER_SAMPLES.forEach(function (x, i) { trPick.appendChild(el('option', { value: String(i), text: x.title })); });\n trPick.addEventListener('change', function () { var x = TRIGGER_SAMPLES[Number(trPick.value)]; if (!x) return; L.trigger = JSON.stringify(x.input, null, 2); L.result = null; rr(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, trPick));\n if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));\n var runBtn = el('button', { className: 'btn primary', onclick: function () {\n L.error = null;\n try {\n api('/api/lab/workflow/simulate', 'POST', { definition: labParse(L.json, 'The definition'), trigger: labParse(L.trigger, 'The trigger') || {}, mocks: labParse(L.mocks, 'Step outputs') || {} }).then(function (r) { L.result = r; }, function (e) { L.error = errorText(e); }).then(rr);\n } catch (e) { L.error = e.message; rr(); }\n } }, icon('play'), 'Simulate');\n w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' },\n el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Definition (JSON: \"start\" and \"steps\")' }), labCode(L.json, 'Workflow definition JSON', 16, function (v) { L.json = v; })),\n el('div', { style: 'flex:1;min-width:300px' }, el('div', { className: 'lbl', text: 'Trigger input (JSON)' }), labCode(L.trigger, 'Trigger JSON', 8, function (v) { L.trigger = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'What the trigger passes in; steps read it as $.trigger. Pick a sample above for the shape SailPoint documents per trigger, or replay a real run to use its actual input.' }),\n el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Step outputs to pretend (JSON: step name → output, optional)' }), labCode(L.mocks, 'Step outputs JSON', 4, function (v) { L.mocks = v; }),\n el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'For steps that would read ISC or call a system, e.g. {\"Get Identity\": {\"attributes\": {\"manager\": {\"email\": \"x@acme.com\"}}}}. Later steps read it as $.getIdentity (the step name in camel case).' }),\n el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn))));\n if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));\n var R = L.result;\n if (R) {\n var tone = R.outcome === 'success' ? 'ok' : 'bad';\n w.appendChild(el('div', { className: 'banner ' + tone }, el('b', { text: 'Ends in ' + R.outcome + (R.endStep ? ' at \"' + R.endStep + '\"' : '') }), el('span', { text: R.path.join(' → ') })));\n R.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'note', text: x })); });\n if (R.failure) w.appendChild(el('div', { className: 'error', text: R.failure }));\n w.appendChild(section('Steps', R.steps.length, simpleTable(['Step', 'Kind', 'What happens', 'Details', 'Next'], R.steps.map(function (s) {\n var details = s.resolved !== undefined ? s.resolved : s.output;\n return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.step }), s.kind + (s.mocked ? ' (' + s.mocked + ' output)' : ''), el('span', {}, s.note || '', s.warning ? el('div', {}, pill(s.warning, 'lose')) : null), details === undefined ? null : el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: JSON.stringify(details) }), s.next || null];\n }), 'Simulated steps')));\n }\n renderReplay(w, L, rr);\n }\n function renderReplay(w, L, rr) {\n var H = L.replay;\n if (!L.replayCount) L.replayCount = 20;\n var count = numSelect(L, 'replayCount', [[10, 'Last 10 runs'], [20, 'Last 20 runs'], [50, 'Last 50 runs'], [100, 'Last 100 runs']], 'How many runs');\n var go = function (draft) {\n return function () {\n try { runJobInto(H, '/api/lab/workflow/replay', { workflowId: L.pick, count: L.replayCount, definition: draft ? labParse(L.json, 'The definition') : undefined }, rr); } catch (e) { toast(e.message); }\n };\n };\n var body = el('div', {}, el('p', { className: 'muted', text: 'Reads the history of real runs (ISC keeps it for 90 days) and runs each one again here. \"As it ran\" checks the simulator against ISC. \"With my edits\" uses the definition above, so you can see which real runs would now take a different path before you publish.' }),\n el('div', { className: 'bar', style: 'margin-bottom:12px' }, count,\n el('button', { className: 'btn primary', disabled: !L.pick || !!H.busy, onclick: go(false) }, icon('lifecycle'), 'Replay as it ran'),\n el('button', { className: 'btn', disabled: !L.pick || !!H.busy, onclick: go(true) }, icon('play'), 'Replay with my edits'),\n L.pick ? null : el('span', { className: 'muted small', text: 'Pick one of your workflows first.' })));\n if (H.busy) body.appendChild(busyBox(H.busy));\n if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));\n if (H.data) {\n var d = H.data;\n (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });\n body.appendChild(el('div', { className: 'bigstats' }, stat(d.same, d.draft ? 'would take the same path' : 'same path as ISC'), stat(d.total - d.same, d.draft ? 'would take a different path' : 'different from ISC', 'lose'), stat(d.total, 'runs replayed')));\n body.appendChild(filteredTable(H, d.results, ['Started', 'Status in ISC', 'Path in ISC', d.draft ? 'Path with your edits' : 'Simulated path', 'Result'], function (x) {\n return [x.started ? x.started.slice(0, 16).replace('T', ' ') : null, x.status || null, x.realPath.join(' → '), x.simPath.join(' → '), x.same ? pill('same', 'gain') : pill(x.noTrigger ? 'no trigger recorded' : 'different at step ' + ((x.divergence && x.divergence.index + 1) || '?'), 'lose')];\n }, 'Replayed runs'));\n }\n w.appendChild(section('Replay real runs', null, body));\n }\n\n // Tenant > Credential map\n function renderCredentialMap(w) {\n var H = labState().c, rr = rerenderHost;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Every place a client ID, user or endpoint is used in workflows and source connections: a checklist for rotating a secret or promoting to production. Secret values are never read or shown; only whether one is typed in.' }),\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lab/credentials/run', {}, rr); } }, icon('search'), H.data ? 'Read again' : 'Map credentials')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.inline, 'secrets typed into a step or source', 'lose'), stat(T.otherTenant, 'calls to another ISC tenant', T.otherTenant ? 'lose' : undefined), stat(T.thisTenantByName, 'call this tenant by its name (break when promoted)', T.thisTenantByName ? 'lose' : undefined), stat(T.parameterStorage, 'use Parameter Storage'), stat(T.workflowSteps, 'workflow steps with a connection'), stat(T.sources, 'sources with a connection')));\n w.appendChild(section('By credential', d.groups.length, simpleTable(['Target', 'Client ID or user', 'Uses', 'Workflows', 'Sources', 'Secret typed in'], d.groups.map(function (g) {\n return [g.target || '—', g.clientId || g.user || '—', g.uses, g.workflows, g.sources, g.inline ? pill(String(g.inline), 'lose') : 0];\n }), 'Credentials grouped by target')));\n w.appendChild(section('Every use', d.uses.length, filteredTable(H, d.uses, ['Where', 'Name', 'Step', 'Target', 'Client ID or user', 'Secret kept as', 'Notes'], function (u) {\n return [u.where, el('span', {}, u.object, u.objectEnabled === false ? el('div', { className: 'muted small', text: 'disabled' }) : null), u.step || null, u.target || null, u.clientId || u.user || null,\n u.parameterStorage ? pill('Parameter Storage', 'gain') : u.hasSecret ? pill('typed in', 'lose') : 'none', u.flags.length ? el('span', {}, u.flags.map(function (f) { return el('div', { className: 'small', text: f }); })) : null];\n }, 'Credential uses')));\n w.appendChild(el('p', { className: 'muted small', text: 'To rotate: change the secret in the application, then update each place listed here in ISC (or once, in Parameter Storage, for steps that use it). IdentityScope stays read-only and does not change them for you.' }));\n }\n // ---------- Build & test: try changes before making them in ISC (read-only) ----------\n state.bt = { tab: 'tlab', impact: {}, pick: '', policy: { usageType: 'CREATE', person: '' }, health: { days: 30 }, drift: {} };\n // Build & test holds the tools for trying a change before making it. Where transforms and credentials\n // are used and workflow health live on the Tenant page, drift on Audit > Change history, and the role\n // change preview on Role tools: one home each.\n var BUILD_TABS = [\n ['tlab', 'Transform lab', 'sliders'], ['policy', 'Account create preview', 'plus'], ['wlab', 'Workflow lab', 'play'],\n ];\n /** Redraws whichever page the shared tools are on. */\n function rerenderHost() {\n if (state.page === 'tenant') renderTenant();\n else if (state.page === 'certs') renderAudit();\n else renderBuild();\n }\n function renderBuild() {\n var B = state.bt;\n var outer = $('build');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#6d28d9;background:#ede9fe' }, icon('code')),\n el('div', {}, el('h2', { text: 'Build & test' }), el('p', { className: 'desc', text: 'Try changes before you make them in ISC. Everything here runs on this computer or only reads ISC: nothing is created, changed or started.' }))));\n var tabs = el('div', { className: 'tabs' });\n BUILD_TABS.forEach(function (t) {\n tabs.appendChild(el('button', { className: 'tab' + (B.tab === t[0] ? ' active' : ''), onclick: function () { B.tab = t[0]; renderBuild(); } }, icon(t[2]), t[1]));\n });\n w.appendChild(tabs);\n if (!BUILD_TABS.some(function (t) { return t[0] === B.tab; })) B.tab = 'tlab';\n if (B.tab === 'policy') renderPolicyPreview(w);\n else if (B.tab === 'wlab') renderWorkflowLab(w);\n else renderTransformLab(w);\n w.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'Also: where each transform is used (Tenant > Transforms), workflow runs and failures (Tenant > Workflows), where credentials are used (Tenant > Credential map), drift from an approved baseline (Audit > Change history), and who a role change would affect (Role tools > Preview a role change).' }));\n }\n\n // Transform impact\n function renderImpactMap(w) {\n var B = state.bt, H = B.impact;\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Before you change a transform: every identity profile, other transform and provisioning policy that uses it, also through other transforms, and how many identities that covers. Also lists transforms nothing uses.' }),\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/impact/run', {}, rerenderHost); } }, icon('search'), H.data ? 'Read again' : 'Find where transforms are used')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.transforms.length, 'transforms'), stat(d.unused.length, 'used by nothing', d.unused.length ? 'lose' : undefined), stat(d.profiles.length, 'identity profiles'), stat(d.policiesRead, 'provisioning policies read')));\n var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Transform' }, el('option', { value: '', text: 'Pick a transform to see where it is used...' }));\n d.transforms.forEach(function (t) { pick.appendChild(el('option', { value: t.name, text: t.name + ' (' + t.uses.length + ' use' + (t.uses.length === 1 ? '' : 's') + ')' })); });\n pick.value = B.pick;\n pick.addEventListener('change', function () { B.pick = pick.value; rerenderHost(); });\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:12px' }, pick));\n var t = d.transforms.filter(function (x) { return x.name === B.pick; })[0];\n if (t) {\n var people = t.people === null ? 'an unknown number of' : fmtNum(t.people);\n w.appendChild(el('div', { className: 'banner ' + (t.uses.length ? 'bad' : 'ok') }, el('b', { text: t.uses.length ? 'Changing \"' + t.name + '\" affects ' + t.uses.length + ' place' + (t.uses.length === 1 ? '' : 's') : '\"' + t.name + '\" is not used anywhere IdentityScope can see' }),\n t.uses.length ? el('span', { text: t.people ? ' · identity attributes of ' + people + ' identities' : '' }) : null));\n if (t.uses.length) w.appendChild(section('Where \"' + t.name + '\" is used', t.uses.length, simpleTable(['Used by', 'Where', 'Attribute or field', 'How'], t.uses.map(function (u) {\n return [u.kind, u.where, u.detail || null, u.via.length ? 'through ' + u.via.join(' → ') : 'directly'];\n }), 'Uses of the transform')));\n }\n if (d.unused.length) w.appendChild(section('Used by nothing', d.unused.length, el('p', { className: 'muted', text: d.unused.join(', ') + '. Check rules before deleting: a rule can use a transform in its own code.' })));\n w.appendChild(section('All transforms', d.transforms.length, filteredTable(H, d.transforms, ['Transform', 'Type', 'Used directly', 'All uses', 'Identities'], function (x) {\n return [el('button', { className: 'linkbtn', text: x.name, onclick: function () { B.pick = x.name; rerenderHost(); } }), x.type, x.direct, x.uses.length ? x.uses.length : pill('not used', 'lose'), x.people === null ? null : x.people];\n }, 'Transforms and their uses')));\n }\n\n // Account create preview\n function renderPolicyPreview(w) {\n var P = state.bt.policy;\n if (!P.sources && !P.loading) {\n P.loading = true;\n api('/api/build/sources').then(function (r) { P.sources = r; }, function (e) { P.sourcesError = errorText(e); }).then(function () { P.loading = false; if (state.bt.tab === 'policy') renderBuild(); });\n }\n w.appendChild(el('div', { className: 'note', text: 'What a source\\'s create policy would produce for one identity, worked out on this computer with the Transform lab engine. Nothing is created. Use it to check a new or changed policy before the next joiner, or why a create failed.' }));\n var src = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Source' }, el('option', { value: '', text: P.sourcesError ? 'Could not read sources' : P.sources ? 'Pick a source...' : 'Reading sources...' }));\n (P.sources || []).forEach(function (s) { src.appendChild(el('option', { value: s.id, text: s.name })); });\n src.value = P.sourceId || '';\n src.addEventListener('change', function () { P.sourceId = src.value; });\n var use = el('select', { className: 'input', style: 'max-width:160px', 'aria-label': 'Policy' });\n ['CREATE', 'UPDATE', 'ENABLE', 'DISABLE', 'CHANGE_PASSWORD'].forEach(function (u) { use.appendChild(el('option', { value: u, text: u === 'CREATE' ? 'Create account' : u.charAt(0) + u.slice(1).toLowerCase().replace('_', ' ') })); });\n use.value = P.usageType;\n use.addEventListener('change', function () { P.usageType = use.value; });\n var who = el('input', { className: 'input', value: P.person, placeholder: 'Username, email or display name', style: 'max-width:280px', 'aria-label': 'Identity' });\n who.addEventListener('input', function () { P.person = who.value; });\n who.addEventListener('keydown', function (e) { if (e.key === 'Enter') go.click(); });\n var go = el('button', { className: 'btn primary', disabled: !!P.busy, onclick: function () {\n if (!P.sourceId) { toast('Pick a source first'); return; }\n if (!P.person.trim()) { toast('Name the identity first'); return; }\n runJobInto(P, '/api/build/policy/run', { sourceId: P.sourceId, usageType: P.usageType, person: P.person }, renderBuild);\n } }, icon('play'), 'Preview');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, src, use, who, go));\n if (P.busy) { w.appendChild(busyBox(P.busy)); return; }\n if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }\n if (!P.data) return;\n var d = P.data;\n d.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'banner bad' }, el('span', { text: x }))); });\n if (!d.fields.length) return;\n w.appendChild(el('p', { className: 'muted', text: d.source + ' · ' + (d.policy || d.usageType) + (d.person ? ' · for ' + d.person.name : '') }));\n w.appendChild(section('Fields', d.fields.length, simpleTable(['Field', 'Required', 'Value', 'Result', 'Note'], d.fields.map(function (f) {\n return [el('code', { text: f.field }), f.required ? 'yes' : null, f.status === 'ok' || f.status === 'random' ? labValue(f.value) : null,\n f.status === 'none' ? pill('not set here', 'keep-other') : f.status === 'hidden' ? pill('hidden', 'keep-other') : labStatus(f.status), f.error || f.note || null];\n }), 'Account fields')));\n if (d.assumptions.length) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'Assumed: ' }), d.assumptions.join(' · ')));\n }\n\n // Workflow health\n function weekBars(weeks) {\n var max = Math.max.apply(null, weeks.map(function (x) { return x.runs; }).concat([1]));\n var label = weeks.map(function (x, i) { return 'week ' + (i + 1) + ': ' + x.failed + ' failed of ' + x.runs; }).join(', ');\n var box = el('span', { className: 'wkbars', role: 'img', 'aria-label': label, title: label });\n weeks.forEach(function (x) {\n var h = x.runs ? Math.max(3, Math.round(22 * x.runs / max)) : 2;\n var bar = el('span', { className: 'wkbar', style: 'height:' + h + 'px' });\n if (x.failed) bar.appendChild(el('span', { className: 'wkfail', style: 'height:' + Math.max(2, Math.round(h * x.failed / x.runs)) + 'px' }));\n box.appendChild(bar);\n });\n return box;\n }\n function renderWorkflowHealth(w) {\n var H = state.bt.health;\n var days = numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [60, 'Last 60 days'], [90, 'Last 90 days']], 'Period');\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },\n el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Runs and failures of every workflow per week, and why runs failed, grouped: the same error with different IDs or names counts as one cause.' }),\n days, el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/health/run', { days: H.days }, rerenderHost); } }, icon('heart'), H.data ? 'Read again' : 'Check workflow health')));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n var rate = T.runs ? Math.round(1000 * T.failed / T.runs) / 10 : null;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.runs, 'runs'), stat(T.failed, 'failed', T.failed ? 'lose' : undefined), stat(rate, 'failure rate (%)'), stat(T.failingEveryRun, 'fail every run', T.failingEveryRun ? 'lose' : undefined), stat(T.worse, 'failing more this week', T.worse ? 'lose' : undefined), stat(T.quiet, 'enabled, never ran')));\n w.appendChild(section('Workflows', d.workflows.length, filteredTable(H, d.workflows, ['Workflow', 'Runs', 'Failed', 'Failure rate', 'Per week (grey: runs, red: failed)', 'Last run', 'Flags', 'Most common cause'], function (x) {\n return [el('span', {}, x.name, el('div', { className: 'muted small', text: [x.enabled ? null : 'disabled', x.trigger, x.owner ? 'owner ' + x.owner : null].filter(Boolean).join(' · ') })), x.failedOnly ? '—' : x.runs, x.failed, x.rate === null ? null : x.rate + '%', weekBars(x.weeks), x.lastRun ? x.lastRun.slice(0, 16).replace('T', ' ') + (x.lastStatus ? ' · ' + x.lastStatus : '') : null,\n x.flags.length ? el('span', {}, x.flags.map(function (f) { return el('div', {}, pill(f, /Enabled/.test(f) ? 'keep-other' : 'lose')); })) : null, x.topCause || null];\n }, 'Workflow health')));\n if (d.causes.length) w.appendChild(section('Why runs failed', d.causes.length, simpleTable(['Workflow', 'Step', 'Cause', 'Runs', 'Last'], d.causes.map(function (c) {\n return [c.workflow, c.step || null, el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: c.cause }), c.runs, c.last.slice(0, 16).replace('T', ' ')];\n }), 'Failure causes')));\n }\n\n // Drift check\n function renderDrift(w) {\n var D = state.bt.drift;\n if (!D.info && !D.loading) {\n D.loading = true;\n api('/api/build/drift').then(function (r) { D.info = r; }, function (e) { D.infoError = errorText(e); }).then(function () { D.loading = false; if (state.bt.tab === 'drift') rerenderHost(); });\n }\n w.appendChild(el('div', { className: 'note', text: 'Approve a configuration snapshot as the baseline (for example the day a release went live), then check at any time what changed since: sources, transforms, identity profiles, roles, access profiles and workflows added, removed or changed outside a release. The baseline is kept on this computer.' }));\n if (D.infoError) { w.appendChild(el('div', { className: 'error', text: D.infoError })); return; }\n if (!D.info) { w.appendChild(busyBox('Reading saved snapshots...')); return; }\n var I = D.info;\n var reload = function () { D.info = null; rerenderHost(); };\n var takeSnap = el('button', { className: 'btn', disabled: !!D.snapBusy, onclick: function () {\n D.snapBusy = 'Taking a snapshot...'; rerenderHost();\n api('/api/changes/snapshot', 'POST', {}).then(function (r) {\n pollJob(r.job, function (p) { D.snapBusy = p; rerenderHost(); }, function () { D.snapBusy = null; toast('Snapshot saved'); reload(); }, function (e) { D.snapBusy = null; toast(e); rerenderHost(); });\n }, function (e) { D.snapBusy = null; toast(errorText(e)); rerenderHost(); });\n } }, icon('save'), D.snapBusy ? D.snapBusy : 'Take a snapshot now');\n if (!I.baseline || D.changing) {\n var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: I.baseline ? 'Change the baseline' : 'Approve a baseline' })));\n if (!I.days.length) {\n card.appendChild(el('p', { className: 'muted', text: 'There is no configuration snapshot yet. Take one now (it reads the configuration; nothing changes in ISC), then approve it.' }));\n card.appendChild(el('div', { className: 'bar' }, takeSnap));\n } else {\n var day = el('select', { className: 'input', style: 'max-width:200px', 'aria-label': 'Snapshot day' });\n I.days.forEach(function (x) { day.appendChild(el('option', { value: x, text: x })); });\n var note = el('input', { className: 'input', placeholder: 'Note, e.g. Release 2026.12 to production', style: 'max-width:360px', 'aria-label': 'Note' });\n card.appendChild(el('div', { className: 'bar' }, day, note,\n el('button', { className: 'btn primary', onclick: function () {\n api('/api/build/drift/baseline', 'POST', { day: day.value, note: note.value }).then(function () { D.changing = false; D.data = null; toast('Baseline approved'); reload(); }, function (e) { toast(errorText(e)); });\n } }, icon('save'), 'Approve as baseline'), takeSnap,\n D.changing ? el('button', { className: 'btn', onclick: function () { D.changing = false; rerenderHost(); } }, 'Cancel') : null));\n }\n w.appendChild(card);\n return;\n }\n var b = I.baseline;\n w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Baseline: ' + b.day })),\n el('p', { className: 'muted', text: (b.note ? b.note + ' · ' : '') + 'approved by ' + b.by + ' on ' + b.approvedAt.slice(0, 16).replace('T', ' ') }),\n el('div', { className: 'bar' },\n el('button', { className: 'btn primary', disabled: !!D.busy, onclick: function () { runJobInto(D, '/api/build/drift/run', {}, rerenderHost); } }, icon('cols'), 'Check for drift now'),\n el('button', { className: 'btn', onclick: function () { D.changing = true; rerenderHost(); } }, 'Change baseline'),\n el('button', { className: 'btn', onclick: function () { api('/api/build/drift/baseline', 'POST', { day: '' }).then(function () { D.data = null; reload(); }); } }, icon('trash'), 'Remove'))));\n if (D.busy) { w.appendChild(busyBox(D.busy)); return; }\n if (D.error) { w.appendChild(el('div', { className: 'error', text: D.error })); return; }\n if (!D.data) return;\n var d = D.data, T = d.totals, any = T.added + T.removed + T.changed;\n w.appendChild(el('div', { className: 'banner ' + (any ? 'bad' : 'ok') }, el('b', { text: any ? any + ' change' + (any === 1 ? '' : 's') + ' since the baseline' : 'No drift: the configuration matches the baseline' })));\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.added, 'added', T.added ? 'lose' : undefined), stat(T.removed, 'removed', T.removed ? 'lose' : undefined), stat(T.changed, 'changed', T.changed ? 'lose' : undefined), stat(T.same, 'unchanged')));\n d.kinds.forEach(function (k) {\n if (k.error) { w.appendChild(el('div', { className: 'note', text: k.label + ': ' + k.error })); return; }\n var n = k.onlyA.length + k.onlyB.length + k.different.length;\n if (!n) return;\n var body = el('div', {});\n if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Added: ' }), k.onlyB.join(', ')));\n if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Removed: ' }), k.onlyA.join(', ')));\n if (k.different.length) body.appendChild(simpleTable(['Name', 'Setting', 'At the baseline', 'Now'], k.different.flatMap(function (x) {\n return x.differences.map(function (f, i) { return [i ? '' : x.name, el('code', { text: f.path || '(whole object)' }), f.a, f.b]; });\n }), k.label + ' changed since the baseline'));\n w.appendChild(section(k.label, n, body));\n });\n w.appendChild(el('div', { className: 'bar', style: 'margin-top:10px' }, downloads(D.job)));\n }\n // ---------- Worked examples for the Transform lab and the Workflow lab ----------\n // Each transform example fills every box: the transform, the input value, identity attributes,\n // accounts and, for references, the other transforms it uses. Values are made up.\n var LAB_HR_ACCOUNT = { source: 'Workday', nativeIdentity: '100234', created: '2024-03-01T09:00:00Z', attributes: { firstName: 'José', lastName: 'García Núñez', department: 'FIN', workerType: 'Employee', startDate: '2025-01-06', email: 'jose.garcia@acme.com' } };\n var LAB_AD_ACCOUNTS = [\n { source: 'Active Directory', nativeIdentity: 'CN=adm_jgarcia,OU=Admins,DC=acme,DC=com', name: 'adm_jgarcia', created: '2024-02-01T09:00:00Z', attributes: { sAMAccountName: 'adm_jgarcia', mail: 'adm_jgarcia@acme.com' } },\n { source: 'Active Directory', nativeIdentity: 'CN=jgarcia,OU=Users,DC=acme,DC=com', name: 'jgarcia', created: '2024-03-02T09:00:00Z', attributes: { sAMAccountName: 'jgarcia', mail: 'jose.garcia@acme.com' } },\n ];\n var LAB_IDENTITY = { firstname: 'José', lastname: 'García Núñez', department: 'Finance', email: 'jose.garcia@acme.com' };\n var CLEAN_NAME = { name: 'Clean Name', type: 'lower', attributes: { input: { type: 'replace', attributes: { regex: '[^A-Za-z]', replacement: '', input: { type: 'decomposeDiacriticalMarks', attributes: {} } } } } };\n var TRANSFORM_EXAMPLES = [\n {\n title: 'Account attribute from one source',\n help: 'accountAttribute reads a value from the identity\\'s account on a source. Put the account in the Accounts box: \"source\" is the source name the transform asks for, \"attributes\" are the account\\'s attributes.',\n transform: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'department' } },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'Pick one of several accounts',\n help: 'With more than one account on a source, ISC takes the oldest unless you filter or sort. Here accountFilter skips the admin account. Remove the filter and run again to see the admin account picked instead.',\n transform: { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith(\"CN=adm_\"))' } },\n accounts: LAB_AD_ACCOUNTS,\n },\n {\n title: 'Use another transform (reference)',\n help: 'A reference runs another transform by name. IdentityScope looks for it first in Other transforms (your drafts), then in the tenant\\'s saved transforms, so you can test a change to \"Clean Name\" before saving it. The trace shows the referenced steps indented.',\n transform: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'lastName' } } } },\n accounts: [LAB_HR_ACCOUNT],\n drafts: [CLEAN_NAME],\n },\n {\n title: 'Chain of transforms: email from names',\n help: 'Builds an email from first and last name, each cleaned by the \"Clean Name\" transform, with the domain picked from the department by a second transform, \"Email Domain\". Change \"Clean Name\" under Other transforms and run again: every transform that uses it changes too.',\n transform: {\n type: 'static',\n attributes: {\n fn: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'firstname' } } } },\n ln: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'lastname' } } } },\n domain: { type: 'reference', attributes: { id: 'Email Domain', input: { type: 'identityAttribute', attributes: { name: 'department' } } } },\n value: '$fn.$ln@$domain',\n },\n },\n identity: LAB_IDENTITY,\n drafts: [CLEAN_NAME, { name: 'Email Domain', type: 'lookup', attributes: { table: { Finance: 'acme.com', Research: 'labs.acme.com', default: 'acme.com' } } }],\n },\n {\n title: 'Lifecycle state from HR dates',\n help: 'The classic joiner criteria: \"active\" from the start date on, \"prehire\" before. Change startDate in the account to a future date and run again. Dates are compared in GMT, as ISC does.',\n transform: {\n type: 'dateCompare',\n attributes: {\n firstDate: { type: 'dateFormat', attributes: { inputFormat: 'yyyy-MM-dd', outputFormat: 'ISO8601', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'startDate' } } } },\n secondDate: 'now',\n operator: 'LTE',\n positiveCondition: 'active',\n negativeCondition: 'prehire',\n },\n },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'Lookup table with a default',\n help: 'lookup turns a code into a name. The input value box is what the identity profile mapping passes in; try \"RND\" and then a code that is not in the table to see the default.',\n transform: { type: 'lookup', attributes: { table: { FIN: 'Finance', RND: 'Research', OPS: 'Operations', default: 'Unknown department' } } },\n implicit: 'FIN',\n },\n {\n title: 'Conditional on an account value',\n help: 'conditional compares two values with \"eq\" and returns one of two results. The variable $type is defined in the attributes from the HR account.',\n transform: { type: 'conditional', attributes: { type: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'workerType' } }, expression: '$type eq Employee', positiveCondition: 'E', negativeCondition: 'C' } },\n accounts: [LAB_HR_ACCOUNT],\n },\n {\n title: 'First value that exists',\n help: 'firstValid returns the first value that is not empty: here the AD mail, then the HR email, then a fixed text. Empty the Accounts box to see the fallback.',\n transform: { type: 'firstValid', attributes: { values: [\n { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith(\"CN=adm_\"))' } },\n { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'email' } },\n 'no-email@acme.com',\n ], ignoreErrors: true } },\n accounts: [LAB_HR_ACCOUNT].concat(LAB_AD_ACCOUNTS),\n },\n ];\n\n // Workflow examples: a definition, a trigger input in the shape SailPoint documents for that trigger,\n // and outputs to pretend for steps that would call ISC or another system.\n var TRIGGER_SAMPLES = [\n { title: 'Identity Attributes Changed', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }, { attribute: 'department', oldValue: 'Sales', newValue: 'Marketing' }] } },\n { title: 'Identity Created', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, attributes: { firstname: 'William', lastname: 'Wilson', email: 'william.wilson@acme.com', department: 'Sales', cloudLifecycleState: 'prehire' } } },\n { title: 'Access Request Submitted', input: { accessRequestId: '2c91808b6ef1d43e016efba0ce470904', requestedFor: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'William Wilson' }, requestedItems: [{ id: '2c91808b6ef1d43e016efba0ce470905', name: 'Engineering Access', description: 'Access to engineering database', type: 'ACCESS_PROFILE', operation: 'Add', comment: 'Needed for the project.' }], requestedBy: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1314', name: 'Rob Robertson' } } },\n { title: 'Account Aggregation Completed', input: { source: { type: 'SOURCE', id: '2c9180835d191a86015d28455b4b232a', name: 'HR Source' }, status: 'Error', started: '2026-11-20T22:01:50.474Z', completed: '2026-11-20T22:02:04.090Z', errors: ['Accounts unable to be aggregated.'], warnings: ['Account Skipped'], stats: { scanned: 200, unchanged: 190, changed: 6, added: 4, removed: 3 } } },\n { title: 'Scheduled or external (empty)', input: {} },\n ];\n var WORKFLOW_EXAMPLES = [\n {\n title: 'Leaver: open a ticket when someone becomes inactive',\n help: 'The comparison reads the changed lifecycle state with a JSONPath filter. Change \"newValue\" in the trigger to \"active\" and simulate again: the workflow takes the other branch and ends without the ticket.',\n trigger: 0,\n definition: { start: 'Is Leaver', steps: {\n 'Is Leaver': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.changes[?(@.attribute == \"cloudLifecycleState\")].newValue', variableB: 'inactive', nextStep: 'Get Identity' }], defaultStep: 'End - Not a leaver' },\n 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Open Ticket', type: 'action', versionNumber: 2 },\n 'Open Ticket': { actionId: 'sp:http', attributes: { method: 'post', url: 'https://acme.service-now.com/api/now/table/incident', authenticationType: 'OAuth', jsonRequestBody: { short_description: 'Leaver: {{$.getIdentity.attributes.displayName}}', manager: '{{$.getIdentity.attributes.manager.name}}' } }, nextStep: 'End - Ticket opened', type: 'action', versionNumber: 3 },\n 'End - Ticket opened': { type: 'success' },\n 'End - Not a leaver': { type: 'success' },\n } },\n mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson' } } } },\n },\n {\n title: 'Joiner: welcome email with a built variable',\n help: 'Define Variable builds a value from the trigger (here the first letter of the first name and the last name). Steps that read ISC, like Get Identity, are pretended with the output in the third box: edit it to try another identity.',\n trigger: 1,\n definition: { start: 'Get Identity', steps: {\n 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Define Variable', type: 'action', versionNumber: 2 },\n 'Define Variable': { actionId: 'sp:define-variable', attributes: { id: 'sp:define-variable', variables: [{ name: 'Login', 'variableA.$': '$.trigger.attributes.firstname', transforms: [{ id: 'sp:transform:substring:string', input: { start: 0, length: 1 } }, { id: 'sp:transform:concatenate:string', input: { 'variableB.$': '$.trigger.attributes.lastname' } }, { id: 'sp:transform:lower:string', input: {} }] }] }, nextStep: 'Has Manager', type: 'Mutation' },\n 'Has Manager': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.getIdentity.attributes.manager.email', variableB: '', nextStep: 'End - No manager' }], defaultStep: 'Send Email' },\n 'Send Email': { actionId: 'sp:send-email', attributes: { 'recipientEmailList.$': '$.getIdentity.attributes.manager.email', subject: 'Welcome {{$.trigger.attributes.firstname}}', body: 'Login: {{$.defineVariable.login}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },\n 'End': { type: 'success' },\n 'End - No manager': { type: 'failure' },\n } },\n mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson', email: 'rob.robertson@acme.com' } } } },\n },\n {\n title: 'Loop over every changed attribute',\n help: 'A loop runs its own steps once per item; inside it, the item is $.loop.loopInput. The simulator runs the first five items and shows each one.',\n trigger: 0,\n definition: { start: 'For Each Change', steps: {\n 'For Each Change': { actionId: 'sp:loop:iterator', attributes: { 'input.$': '$.trigger.changes', start: 'Is Department', steps: {\n 'Is Department': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.loop.loopInput.attribute', variableB: 'department', nextStep: 'Notify' }], defaultStep: 'Skip' },\n 'Notify': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Department changed to {{$.loop.loopInput.newValue}}' }, nextStep: 'Done', type: 'action', versionNumber: 2 },\n 'Done': { type: 'success' },\n 'Skip': { type: 'success' },\n } }, nextStep: 'End', type: 'action', versionNumber: 1 },\n 'End': { type: 'success' },\n } },\n mocks: {},\n },\n {\n title: 'Alert when an aggregation fails',\n help: 'Uses the Account Aggregation Completed trigger. Set \"status\" in the trigger to \"Success\" and simulate again: no email.',\n trigger: 3,\n definition: { start: 'Failed?', steps: {\n 'Failed?': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.status', variableB: 'Error', nextStep: 'Alert' }], defaultStep: 'End' },\n 'Alert': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Aggregation of {{$.trigger.source.name}} failed', body: '{{$.trigger.errors}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },\n 'End': { type: 'success' },\n } },\n mocks: {},\n },\n ];\n // ---------- Quick finder: every page, tab and report in one search (Ctrl+K) ----------\n // Each entry: [label, where it is, extra words people search for, how to go there].\n function finderEntries() {\n var go = function (page, set) { return function () { if (set) set(); showPage(page); }; };\n var tab = function (obj, key, id) { return function () { obj()[key] = id; }; };\n var list = [\n ['Reports', 'All reports, by category', 'library run schedule export', go('reports')],\n ['Instant check', 'Health tiles for the whole tenant', 'dashboard tiles health status overview', go('checks')],\n ['Schedules', 'Reports sent by email or chat on a schedule', 'email teams slack webhook daily weekly', go('schedules')],\n ];\n var add = function (page, pageLabel, holder, key, tabs) {\n tabs.forEach(function (t) { list.push([t[1], pageLabel + ' > ' + t[1], (t[2] || '') + ' ' + pageLabel, go(page, tab(holder, key, t[0]))]); });\n };\n add('warnings', 'Warnings', wnState, 'tab', WN_TABS.map(function (t) { return [t[0], t[1], t[3]]; }));\n add('lookup', 'Lookup', function () { return state.lk; }, 'tab', [['person', 'Identity', 'user identity everything one identity has accounts access requests events'], ['source', 'Source', 'application connector errors aggregation'], ['ownership', 'Ownership', 'owners owner left without owner']]);\n add('tenant', 'Tenant', function () { return state.tn; }, 'tab', [\n ['overview', 'Overview', 'counts sources identities size'], ['clusters', 'Virtual Appliances', 'va cluster health'],\n ['workflows', 'Workflows', 'workflow health runs failures failed causes errors trends'], ['transforms', 'Transforms', 'transform impact where used unused references provisioning policies'],\n ['credentials', 'API credentials', 'pat personal access token oauth client expiry expiring'], ['cmap', 'Credential map', 'client id secret rotate promote parameter storage servicenow http'],\n ['compare', 'Compare tenants', 'sandbox production diff rules cloud rules connector rules promote'], ['rules', 'Rule usage', 'unused rules cleanup connector rule cloud rule where used missing']]);\n add('logs', 'Logs', lgState, 'tab', LG_TABS.map(function (t) { return [t[0], t[1], t[3] + ' log ccg virtual appliance va connector error aggregation']; }));\n add('nerm', 'Non-employees', nmState, 'tab', NM_TABS.map(function (t) { return [t[0], t[1], t[3] + ' nerm contractor vendor sponsor non-employee risk management']; }));\n add('build', 'Build & test', function () { return state.bt; }, 'tab', BUILD_TABS.map(function (t) {\n return [t[0], t[1], { tlab: 'transform test velocity offline try draft reference account attribute', policy: 'provisioning policy create account preview joiner fields', wlab: 'workflow simulate trigger replay test without disabling' }[t[0]]];\n }));\n add('certs', 'Audit', function () { return state.au; }, 'tab', [\n ['certs', 'Certifications', 'campaigns reviewers progress rubber stamp'], ['outmodel', 'Outside roles', 'entitlements not assigned via roles direct access standalone birthright outside the model'], ['composition', 'What is in every role', 'role composition entitlements by role access profiles breakdown export'], ['reassigned', 'Reassigned reviews', 'certification reassignment forwarded delegated reviewer'], ['sod', 'Separation of duties', 'sod toxic conflicts rules'],\n ['coverage', 'Review coverage', 'certified access never reviewed'], ['outliers', 'Access outliers', 'peer unusual compared with peers'],\n ['speed', 'Provisioning speed', 'slow removals how long'], ['adminaccts', 'Admin accounts', 'privileged admin service test accounts linked'],\n ['exceptions', 'Exceptions', 'accepted risk exception register'], ['trail', 'Request trail', 'access request approvals approver comment decision audit history who approved'], ['chain', 'Approver chain', 'approval schemes who approves governance group revoke approval'], ['leavertimes', 'Leaver removal times', 'termination leaver sla disabled how long per identity'], ['attrhist', 'Attribute changes', 'manager change department title history who changed'], ['owners', 'Entitlement owners', 'owner review holders who has my entitlement'], ['changes', 'Change history', 'snapshot drift baseline approved release what changed'],\n ['evidence', 'Evidence pack', 'auditor zip excel evidence']]);\n add('roles', 'Role tools', function () { return state; }, 'roleTab', [['compare', 'Compare roles', 'role differences'], ['impact', 'Preview a role change', 'criteria membership who gains loses simulate'], ['mining', 'Find candidate roles', 'role mining common access']]);\n add('monthly', 'Insights', function () { return state.inz; }, 'tab', [['monthly', 'Monthly report', 'management summary trend'], ['reclaim', 'License reclaim', 'cost dormant licenses save money'], ['requests', 'Access requests', 'approvers requested reject rate']]);\n (state.reports || []).forEach(function (r) {\n var d = r.definition || r;\n if (!d || !d.name) return;\n list.push([d.name, 'Report · ' + (d.category || ''), (d.description || '') + ' ' + (d.tags || []).join(' '), function () { showPage('reports'); loadLibrary(d.id); }]);\n });\n return list;\n }\n function finderScore(e, words) {\n var name = String(e[0]).toLowerCase(), hay = (e[0] + ' ' + e[1] + ' ' + (e[2] || '')).toLowerCase(), score = 0;\n for (var i = 0; i < words.length; i++) {\n var w = words[i];\n if (hay.indexOf(w) < 0) return -1;\n score += name.indexOf(w) === 0 ? 6 : name.indexOf(w) >= 0 ? 4 : String(e[1]).toLowerCase().indexOf(w) >= 0 ? 2 : 1;\n }\n return score;\n }\n function openFinder() {\n if ($('btn-help').classList.contains('hidden') || document.querySelector('.finder')) return;\n var entries = finderEntries(), sel = 0, shown = [];\n var before = document.activeElement;\n var input = el('input', { className: 'input', placeholder: 'Find a page, tab or report...', 'aria-label': 'Find a page, tab or report', role: 'combobox', 'aria-expanded': 'true', 'aria-controls': 'finder-list', autocomplete: 'off' });\n var listBox = el('ul', { id: 'finder-list', role: 'listbox', className: 'finder-list', 'aria-label': 'Matches' });\n var back = el('div', { className: 'finder-back' });\n var box = el('div', { className: 'finder', role: 'dialog', 'aria-modal': 'true', 'aria-label': 'Find' }, input, listBox,\n el('div', { className: 'muted small', style: 'padding:8px 12px', text: '↑ ↓ to move, Enter to open, Esc to close' }));\n back.appendChild(box);\n var close = function () { back.remove(); if (before && before.focus) before.focus(); };\n var pick = function (e) { close(); e[3](); };\n var draw = function () {\n var words = input.value.toLowerCase().split(/\\s+/).filter(Boolean);\n shown = words.length ? entries.map(function (e) { return [finderScore(e, words), e]; }).filter(function (x) { return x[0] >= 0; }).sort(function (a, b) { return b[0] - a[0] || String(a[1][0]).length - String(b[1][0]).length; }).slice(0, 12).map(function (x) { return x[1]; }) : entries.slice(0, 12);\n sel = Math.min(sel, Math.max(0, shown.length - 1));\n listBox.textContent = '';\n shown.forEach(function (e, i) {\n var li = el('li', { id: 'finder-opt-' + i, role: 'option', className: 'finder-opt' + (i === sel ? ' active' : ''), 'aria-selected': i === sel ? 'true' : 'false' }, el('b', { text: e[0] }), el('span', { className: 'muted small', text: e[1] }));\n li.addEventListener('mousedown', function (ev) { ev.preventDefault(); pick(e); });\n listBox.appendChild(li);\n });\n if (!shown.length) listBox.appendChild(el('li', { className: 'muted', style: 'padding:10px 12px', text: 'Nothing matches.' }));\n input.setAttribute('aria-activedescendant', shown.length ? 'finder-opt-' + sel : '');\n };\n input.addEventListener('input', function () { sel = 0; draw(); });\n input.addEventListener('keydown', function (ev) {\n if (ev.key === 'ArrowDown') { sel = Math.min(sel + 1, shown.length - 1); draw(); ev.preventDefault(); }\n else if (ev.key === 'ArrowUp') { sel = Math.max(sel - 1, 0); draw(); ev.preventDefault(); }\n else if (ev.key === 'Enter' && shown[sel]) { pick(shown[sel]); ev.preventDefault(); }\n else if (ev.key === 'Escape') { close(); ev.preventDefault(); }\n });\n back.addEventListener('mousedown', function (ev) { if (ev.target === back) close(); });\n document.body.appendChild(back);\n draw();\n input.focus();\n }\n document.addEventListener('keydown', function (ev) {\n if ((ev.ctrlKey || ev.metaKey) && !ev.altKey && (ev.key === 'k' || ev.key === 'K')) { ev.preventDefault(); openFinder(); }\n });\n // ---------- 0.22.0: access request audit trail, approver chain, accounts expiring, revokes not done, person timeline ----------\n function gvState() {\n if (!state.gv) state.gv = { trail: { days: 30, item: '', person: '' }, chain: {}, expiry: { days: 30, attribute: 'accountExpires', sourceIds: [] }, revokes: { days: 90 } };\n return state.gv;\n }\n function gvRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/warnings/' + path + '/run', body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n function gvText(H, key, label, placeholder) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder, style: 'max-width:200px', 'aria-label': label });\n i.addEventListener('input', function () { H[key] = i.value; });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function gvTime(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }\n var GV_DECISION = { APPROVED: 'win', REJECTED: 'lose', PENDING: 'off', EXPIRED: 'lose', CANCELLED: 'off' };\n var GV_OUTCOME = { completed: ['completed', 'win'], rejected: ['rejected', 'lose'], cancelled: ['cancelled', 'off'], failed: ['failed', 'lose'], open: ['in progress', 'off'] };\n\n // Audit > Request trail\n function renderRequestTrail(w) {\n var H = gvState().trail;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Submitted in the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Period')),\n gvText(H, 'item', 'Access item contains', 'e.g. VPN'), gvText(H, 'person', 'Identity contains', 'requester or recipient'));\n if (!gvRunBar(w, H, 'request-trail', 'Build the trail', 'Every access request with each approval step: who decided, the decision, their comment and when, and how provisioning ended. One row per step in the download, ready for auditors.', extras,\n function () { return { days: H.days, item: H.item || undefined, person: H.person || undefined }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.requests, 'requests'), stat(T.completed, 'completed'), stat(T.rejected, 'rejected', 'lose'), stat(T.failed, 'failed', 'lose'), stat(T.open, 'in progress'), stat(T.withoutApproval, 'without an approval step'),\n stat(T.decisions ? Math.round(T.decisionsWithComment * 100 / T.decisions) : 0, '% of decisions with a comment')));\n if (!d.requests.length) return;\n if ((d.approvers || []).length) w.appendChild(section('How fast approvers decide', d.approvers.length, simpleTable(['Approver', 'Decisions', 'Usual time', 'Slowest', 'Waiting now', 'Oldest waiting'], d.approvers.slice(0, 200).map(function (a) {\n return [a.approver, fmtNum(a.decided), hrs(a.medianHours), hrs(a.slowestHours), a.waiting ? pill(String(a.waiting), 'lose') : '0', a.oldestWaitingDays === null ? '—' : a.oldestWaitingDays + ' days'];\n }), 'How fast approvers decide')));\n var rows = d.requests.map(function (r) {\n var o = GV_OUTCOME[r.outcome] || [r.outcome, 'off'];\n var steps = r.steps.length ? el('div', {}, r.steps.map(function (s) {\n return el('div', { style: 'margin:2px 0' }, el('b', { text: s.step + '. ' }), s.approver || '?', s.originalApprover ? el('span', { className: 'muted', text: ' (was ' + s.originalApprover + ')' }) : null, ' ',\n pill(s.decision.toLowerCase(), GV_DECISION[s.decision] || 'off'), s.decided ? el('span', { className: 'muted small', text: ' ' + gvTime(s.decided) }) : null,\n s.comment ? el('div', { className: 'small', style: 'margin-left:16px;font-style:italic', text: '“' + s.comment + '”' }) : null);\n })) : el('span', { className: 'muted', text: 'No approval step' });\n return { r: r, cells: [gvTime(r.submitted), r.requestedFor, r.requestedBy, el('span', {}, r.access, r.accessType ? el('span', { className: 'muted small', text: ' ' + r.accessType.toLowerCase().replace('_', ' ') }) : null, r.requestType === 'REVOKE_ACCESS' ? el('span', {}, ' ', pill('revoke', 'lose')) : null),\n r.requesterComment ? el('span', { className: 'small', style: 'font-style:italic', text: '“' + r.requesterComment + '”' }) : '', steps, el('span', {}, pill(o[0], o[1]), r.errors.length ? el('div', { className: 'small', style: 'color:var(--bad)', text: r.errors.join('; ') }) : null)] };\n });\n w.appendChild(section('Requests', d.requests.length + (d.more || 0), filteredTable(H, rows, ['Submitted', 'Requested for', 'Requested by', 'Access', 'Requester comment', 'Approvals', 'Outcome'], function (x) { return x.cells; }, 'Access request audit trail')));\n }\n\n // Audit > Approver chain\n function renderApproverChain(w) {\n var H = gvState().chain;\n if (!gvRunBar(w, H, 'approver-chain', 'Read approval settings', 'Who approves a request, in what order, and who approves a revoke, for every access profile, role and requestable entitlement. Flags requestable access that needs no approval or whose approver cannot be reached.', null, null, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accessProfiles, 'access profiles'), stat(T.roles, 'roles'), stat(T.entitlements, 'requestable entitlements'), stat(T.noApproval, 'requestable without approval', 'lose'), stat(T.flagged, 'with a problem', 'lose')));\n var list = function (xs) { return xs.length ? el('div', {}, xs.map(function (x) { return el('div', { text: x }); })) : el('span', { className: 'muted', text: 'none' }); };\n var H2 = H.view || (H.view = { only: 'requestable' });\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['requestable', 'Requestable only'], ['problems', 'Only with problems'], ['all', 'Everything']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = H2.only;\n only.addEventListener('change', function () { H2.only = only.value; renderAudit(); });\n var rows = d.rows.filter(function (r) { return H2.only === 'all' || (H2.only === 'problems' ? r.flags.length : r.requestable); });\n w.appendChild(section('Approval settings', rows.length, filteredTable(H, rows, ['Type', 'Name', 'Source', 'Owner', 'Request approvals', 'Revoke approvals', 'Comment required', 'Problems'], function (r) {\n return [r.type, r.name, r.source, r.owner, list(r.request), list(r.revoke), r.commentsRequired ? 'Yes' : 'No', r.flags.length ? el('div', {}, r.flags.map(function (f) { return el('div', { className: 'small', style: 'color:var(--bad)', text: f }); })) : ''];\n }, 'Approver chain', only)));\n }\n\n // Warnings > Accounts expiring\n function wnExpiry(w, _H, desc) {\n var H = gvState().expiry;\n if (!H.sources) {\n H.sources = 'loading';\n api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(function () { if (state.page === 'warnings') renderWarnings(); });\n }\n var pick = el('select', { className: 'input', multiple: true, size: 4, style: 'min-width:220px', 'aria-label': 'Sources to check' }, (Array.isArray(H.sources) ? H.sources : []).map(function (s) {\n return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });\n }));\n if (!H.sourceIds.length && Array.isArray(H.sources)) {\n var ad = H.sources.filter(function (s) { return /active directory|\\bad\\b/i.test(s.name + ' ' + (s.type || '')); })[0];\n if (ad) { H.sourceIds = [ad.id]; Array.prototype.forEach.call(pick.options, function (o) { o.selected = o.value === ad.id; }); }\n }\n pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected; }).map(function (o) { return o.value; }); });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sources (Ctrl+click for more)' }), pick),\n attrInput(H, 'attribute', 'Expiry attribute', 'accountExpires'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Expiring within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Expiring within')));\n if (!gvRunBar(w, H, 'account-expiry', 'Find expiring accounts', desc, extras, function () { return { days: H.days, attribute: H.attribute || 'accountExpires', sourceIds: H.sourceIds }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.withDate, 'with an expiry date'), stat(T.never, 'set to never expire'), stat(T.missing, 'without a value'), stat(T.expiring, 'expire in the next ' + d.days + ' days', 'lose'), stat(T.expiredEnabled, 'expired but still enabled', 'lose'), stat(T.unreadable, 'values not readable as a date')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No account expires in this period.' })); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Identity', 'Source', 'Expires', 'When', 'Account'], function (r) {\n return [r.account, r.person || el('span', { className: 'muted', text: 'not linked to an identity' }), r.source, r.expires, pill(daysText(r.daysLeft), r.daysLeft <= 7 ? 'lose' : 'off'), r.disabled ? 'disabled' : 'enabled'];\n }, 'Accounts expiring')));\n }\n\n // Warnings > Revokes not done\n function wnRevokes(w, _H, desc) {\n var H = gvState().revokes;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Campaigns created in the last' }), numSelect(H, 'days', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Campaign period'));\n if (!gvRunBar(w, H, 'revokes', 'Check revokes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns checked'), stat(T.revokes, 'revoke decisions'), stat(T.removed, 'removed'), stat(T.stillHeld, 'signed off but still held', 'lose'), stat(T.notSignedOff, 'waiting for sign-off')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every revoked item has been removed.' })); return; }\n w.appendChild(section('Revoked but still there', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Access', 'Type', 'Campaign', 'Reviewer', 'Signed off', 'Status'], function (r) {\n return [r.person, r.access, r.accessType, r.campaign, r.reviewer, r.signedOff ? r.signedOff.slice(0, 10) + (r.daysSinceSignOff !== null ? ' (' + r.daysSinceSignOff + ' days ago)' : '') : '—',\n el('span', {}, pill(r.status, r.status === 'still held' ? 'lose' : 'off'), r.alsoFromRole ? el('div', { className: 'small muted', text: 'May also come from a role or access profile' }) : null)];\n }, 'Revoked but still held')));\n }\n\n // Person lookup > Timeline\n function timelineSection(p) {\n var items = p.timeline || [];\n var L = state.tl || (state.tl = { kind: '' });\n var kinds = ['Identity', 'Lifecycle', 'Audit event', 'Account change', 'Access request'];\n var sel = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show in timeline' }, [el('option', { value: '', text: 'Everything' })].concat(kinds.map(function (k) { return el('option', { value: k, text: k }); })));\n sel.value = L.kind;\n var box = el('div');\n var draw = function () {\n box.textContent = '';\n var list = items.filter(function (x) { return !L.kind || x.kind === L.kind; });\n box.appendChild(simpleTable(['When', 'Kind', 'What', 'Detail', 'Status'], list.slice(0, 500).map(function (x) {\n return [gvTime(x.when), x.kind, x.what, x.detail, x.status ? pill(String(x.status).toLowerCase(), x.failed ? 'lose' : 'off') : ''];\n }), 'Timeline'));\n };\n sel.addEventListener('change', function () { L.kind = sel.value; draw(); });\n draw();\n return section('Timeline (30 days, newest first)', items.length, el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:8px' }, sel, el('span', { className: 'muted small', text: 'Lifecycle changes, audit events, account changes and access requests in one list.' })), box));\n }\n // ---------- 0.23.0: drift, incidents, cleanup, and Non-employees (NERM) ----------\n function owState() {\n if (!state.wt) state.wt = {\n massch: { days: 30, factor: 3, min: 50 }, loops: { days: 7, min: 5 }, outside: { days: 0, sourceIds: [] }, syncdrift: { sourceIds: [] },\n groupappr: {}, mgrleft: { query: '' }, leavertimes: { days: 30, limitHours: 24 }, attrhist: { attributes: 'manager, department, title, cloudLifecycleState' },\n owners: {}, rules: { cloudRules: false }\n };\n return state.wt;\n }\n function owRunBar(w, H, path, label, desc, extras, body, rerender) {\n w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,\n el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, path, body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));\n if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }\n if (!H.data) return false;\n (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n return true;\n }\n /** Source picker (one or several), loaded once per page visit. */\n function sourcePick(H, multiple, rerender, label) {\n if (!H.sources) {\n H.sources = 'loading';\n api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(rerender);\n }\n var list = Array.isArray(H.sources) ? H.sources : [];\n var pick = el('select', { className: 'input', multiple: multiple, size: multiple ? 4 : null, style: 'min-width:220px;width:auto', 'aria-label': label }, (multiple ? [] : [el('option', { value: '', text: list.length ? 'Pick a source' : 'Loading sources...' })]).concat(list.map(function (s) {\n return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });\n })));\n pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected && o.value; }).map(function (o) { return o.value; }); });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label + (multiple ? ' (Ctrl+click for more)' : '') }), pick);\n }\n function hrs(h) { return h === null || h === undefined ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; }\n function when16(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }\n function warnRerender() { if (state.page === 'warnings') renderWarnings(); }\n\n // Warnings > Mass changes\n function wnMassChange(w, _H, desc) {\n var H = owState().massch;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Usual level from the last' }), numSelect(H, 'days', [[14, '14 days'], [30, '30 days'], [60, '60 days']], 'Baseline period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Spike at' }), numSelect(H, 'factor', [[2, '2× usual'], [3, '3× usual'], [5, '5× usual'], [10, '10× usual']], 'Spike factor')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'and at least' }), numSelect(H, 'min', [[20, '20 changes'], [50, '50 changes'], [200, '200 changes'], [1000, '1,000 changes']], 'Minimum changes')));\n if (!owRunBar(w, H, '/api/watch/mass-change/run', 'Check for spikes', desc, extras, function () { return { days: H.days, factor: H.factor, min: H.min }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, d.series.map(function (x) {\n return el('div', { className: 'bigstat' + (x.spike ? ' lose' : '') }, el('b', { text: fmtNum(x.latest) }), el('span', { text: x.label + ' on ' + x.latestDay + ' (usual ' + fmtNum(Math.round(x.usual)) + ')' + (x.spike ? ': spike' : '') }));\n })));\n d.series.filter(function (x) { return x.spike; }).forEach(function (x) {\n w.appendChild(section('Spike: ' + x.label.toLowerCase() + ' on ' + x.latestDay, x.latest, simpleTable(['Source', 'Changes'], x.bySource.map(function (s) { return [s.source, fmtNum(s.count)]; }), 'Spike by source: ' + x.label)));\n });\n var all = d.series[0];\n var maxv = Math.max.apply(null, all.daily.map(function (p) { return p.count; }).concat([1]));\n var bars = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:90px;margin:8px 0', role: 'img', 'aria-label': 'Provisioning per day: ' + all.daily.map(function (p) { return p.day + ' ' + p.count; }).join(', ') }, all.daily.map(function (p) {\n return el('div', { title: p.day + ': ' + p.count, style: 'flex:1;min-width:3px;background:' + (p.day === all.latestDay && all.spike ? 'var(--danger)' : 'var(--accent)') + ';height:' + Math.max(2, Math.round(p.count / maxv * 88)) + 'px;border-radius:2px 2px 0 0' });\n }));\n w.appendChild(section('All provisioning per day', null, el('div', {}, bars, el('div', { className: 'bar', style: 'justify-content:flex-end' }, downloads(H.job)))));\n }\n\n // Warnings > Provisioning loops\n function wnLoops(w, _H, desc) {\n var H = owState().loops;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sent at least' }), numSelect(H, 'min', [[3, '3 times'], [5, '5 times'], [10, '10 times'], [20, '20 times']], 'Minimum repeats')));\n if (!owRunBar(w, H, '/api/watch/loops/run', 'Find loops', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.read, 'activities read'), stat(d.rows.length + (d.more || 0), 'changes sent again and again', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No change was sent that often.' })); return; }\n w.appendChild(section('Loops', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Source', 'Operation', 'Change', 'Times', 'First', 'Last', 'Last result'], function (r) {\n return [r.person, r.source, r.op, el('span', { className: 'small', text: r.change }), pill(String(r.times), 'lose'), when16(r.first), when16(r.last), r.lastStatus];\n }, 'Provisioning loops')));\n }\n\n // Warnings > Changed outside ISC\n function wnOutside(w, _H, desc) {\n var H = owState().outside;\n var extras = el('div', { className: 'bar' }, sourcePick(H, true, warnRerender, 'Sources'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compare with what ISC sent in' }), numSelect(H, 'days', [[0, 'All history'], [30, 'the last 30 days'], [90, 'the last 90 days'], [180, 'the last 180 days'], [365, 'the last 365 days']], 'Period')));\n if (!owRunBar(w, H, '/api/watch/outside/run', 'Find changes made outside ISC', desc, extras, function () { return { days: H.days, sourceIds: H.sourceIds }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.disabledOutside, 'disabled outside ISC', 'lose'), stat(T.enabledOutside, 'enabled again outside ISC', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every account state matches what ISC sent.' })); return; }\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Identity state', 'Account', 'Source', 'Finding', 'Last disable or enable ISC sent'], function (r) { return [r.person, r.personState, r.account, r.source, r.finding, r.lastIsc]; }, 'Changes made outside ISC')));\n }\n\n // Warnings > Attribute sync drift\n function wnSyncDrift(w, _H, desc) {\n var H = owState().syncdrift;\n var extras = el('div', { className: 'bar' }, sourcePick(H, false, warnRerender, 'Source'));\n if (!owRunBar(w, H, '/api/watch/sync-drift/run', 'Compare values', desc, extras, function () { return { sourceIds: H.sourceIds.slice(0, 1) }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.mappings.length, 'attributes synced'), stat(T.accounts, 'accounts'), stat(T.compared, 'values compared'), stat(T.drifted, 'values that differ', 'lose'), stat(T.failedSyncs, 'failed syncs (14 days)', 'lose')));\n if (d.mappings.length) w.appendChild(el('p', { className: 'muted small', text: 'Synced: ' + d.mappings.map(function (m) { return m.identityAttribute + ' → ' + m.accountAttribute; }).join(', ') }));\n if (d.rows.length) w.appendChild(section('Values that differ', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Account', 'Attribute', 'Value in ISC', 'Value on the account'], function (r) { return [r.person, r.account, r.identityAttribute + ' → ' + r.accountAttribute, r.inIsc, r.onAccount]; }, 'Attribute sync drift')));\n else if (d.mappings.length) w.appendChild(el('p', { className: 'muted', text: 'Every synced value matches.' }));\n if (d.failedSyncs.length) w.appendChild(section('Failed attribute syncs', d.failedSyncs.length, simpleTable(['When', 'Identity', 'Detail'], d.failedSyncs.slice(0, 500).map(function (f) { return [when16(f.when), f.person, f.detail]; }), 'Failed attribute syncs')));\n }\n\n // Warnings > Group approvals\n function wnGroupApprovals(w, _H, desc) {\n var H = owState().groupappr;\n if (!owRunBar(w, H, '/api/watch/group-approvals/run', 'Check group approvers', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.pending, 'approvals waiting on a group'), stat(T.groups, 'groups'), stat(T.noActiveMember, 'with no active member left', 'lose')));\n if (!d.rows.length) return;\n w.appendChild(section('Approvals', d.rows.length, filteredTable(H, d.rows, ['Group', 'Access', 'Requested for', 'Waiting', 'Members', 'Members who left'], function (r) {\n return [r.group, r.request, r.requestedFor, r.waitingDays === null ? '—' : r.waitingDays + ' days', el('span', {}, r.activeMembers + ' of ' + r.members + ' active ', r.activeMembers === 0 ? pill('nobody can approve', 'lose') : null), r.leftMembers.join(', ')];\n }, 'Approvals waiting on governance groups')));\n }\n\n // Warnings > Manager left\n function wnManagerLeft(w, _H, desc) {\n var H = owState().mgrleft;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.employeeType:contractor', style: 'max-width:300px', 'aria-label': 'Only identities matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only identities matching (optional)' }), q);\n if (!owRunBar(w, H, '/api/watch/manager-left/run', 'Find identities', desc, extras, function () { return { query: H.query || undefined }; }, renderWarnings)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'active identities'), stat(d.totals.managerLeft, 'whose manager left', 'lose')));\n if (!d.rows.length) return;\n w.appendChild(section('Identities', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Lifecycle state', 'Identity profile', 'Manager', 'Manager state'], function (r) { return [r.person, r.lifecycle, r.profile, r.manager, pill(r.managerState, 'lose')]; }, 'Identities whose manager left')));\n }\n\n // Audit > Leaver removal times\n function renderLeaverTimes(w) {\n var H = owState().leavertimes;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Leavers of the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Limit' }), numSelect(H, 'limitHours', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '72 hours'], [168, '7 days']], 'Removal limit')));\n if (!owRunBar(w, H, '/api/watch/leaver-times/run', 'Time the leavers', 'For each leaver: when leaving started (lifecycle change), when each account was disabled, and which accounts are still enabled. The per-person figure auditors ask for.', extras, function () { return { days: H.days, limitHours: H.limitHours }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.leavers, 'leavers'), stat(T.late, 'over ' + d.limitHours + ' h or not done', 'lose'), stat(T.stillEnabled, 'with an account still enabled', 'lose'), el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHours) }), el('span', { text: 'median removal time' }))));\n if (!d.rows.length) return;\n w.appendChild(section('Leavers', d.rows.length, filteredTable(H, d.rows, ['Identity', 'Lifecycle state', 'Started', 'Accounts', 'Slowest removal', 'Still enabled on', 'Result'], function (r) {\n return [r.person, r.lifecycle, el('span', {}, when16(r.started) || '—', el('div', { className: 'small muted', text: r.startedBy })), r.accounts, hrs(r.slowestHours), r.stillEnabled.join(', '), pill(r.late ? 'late' : 'on time', r.late ? 'lose' : 'win')];\n }, 'Leaver removal times')));\n }\n\n // Audit > Attribute changes\n function renderAttrHistory(w) {\n var H = owState().attrhist;\n var i = el('input', { className: 'input', value: H.attributes, style: 'max-width:380px', 'aria-label': 'Attributes to follow (comma-separated)' });\n i.addEventListener('input', function () { H.attributes = i.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Attributes to follow (comma-separated)' }), i);\n if (!owRunBar(w, H, '/api/watch/attr-history/run', 'Look now', 'Who changed manager, department, title or lifecycle state, from what to what. IdentityScope remembers the values at each look and lists the changes between looks.', extras,\n function () { return { attributes: H.attributes.split(',').map(function (x) { return x.trim(); }).filter(Boolean) }; }, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.people, 'identities looked at'), stat(d.newChanges, 'changes since the last look'), stat(d.changes.length + (d.more || 0), 'changes on record')));\n if (d.previousLook) w.appendChild(el('p', { className: 'muted small', text: 'Previous look: ' + when16(d.previousLook) }));\n if (!d.changes.length) return;\n w.appendChild(section('Changes', d.changes.length + (d.more || 0), filteredTable(H, d.changes, ['Seen at', 'Identity', 'Attribute', 'From', 'To'], function (r) { return [when16(r.at), r.person, r.attribute, r.from || '(empty)', r.to || '(empty)']; }, 'Attribute changes')));\n }\n\n // Audit > Entitlement owners\n function renderOwners(w) {\n var H = owState().owners;\n if (!owRunBar(w, H, '/api/watch/owners/run', 'Read owners', 'Every entitlement owner with what they own and how many identities hold each item, so each owner can review their own access. Owners who left are listed first.', null, null, renderAudit)) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.owners.length, 'owners'), stat(d.owners.filter(function (o) { return o.ownerState !== 'active'; }).length, 'owners who left or are not found', 'lose'), stat(d.rows.length + (d.more || 0), 'owned entitlements')));\n w.appendChild(section('Owners', d.owners.length, simpleTable(['Owner', 'State', 'Entitlements', 'Holders'], d.owners.map(function (o) {\n return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.entitlements), fmtNum(o.holders)];\n }), 'Entitlement owners')));\n w.appendChild(section('Entitlements', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Owner', 'Entitlement', 'Source', 'Privileged', 'Holders'], function (r) { return [r.owner, r.entitlement, r.source, r.privileged ? 'Yes' : '', r.holders === null ? '—' : fmtNum(r.holders)]; }, 'Entitlements by owner')));\n }\n\n // Tenant > Rule usage\n function renderRuleUsage(w) {\n var H = owState().rules;\n var cb = el('input', { type: 'checkbox', checked: H.cloudRules });\n cb.addEventListener('change', function () { H.cloudRules = cb.checked; });\n var extras = el('label', { className: 'check', title: 'Starts an SP-Config export job in the tenant (it reads only, but the job shows in ISC).' }, cb, 'Also list cloud rules (SP-Config export)');\n if (!owRunBar(w, H, '/api/watch/rules/run', 'Find where rules are used', 'Every connector rule and cloud rule with the sources, policies, transforms and identity attributes that use it. Unused rules are cleanup candidates; rules used but missing break at run time.', extras,\n function () { return { cloudRules: H.cloudRules }; }, renderTenant)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.rules, 'rules'), stat(T.unused, 'not used anywhere', 'lose'), stat(T.missing, 'used but missing', 'lose')));\n w.appendChild(section('Rules', d.rows.length, filteredTable(H, d.rows, ['Rule', 'Kind', 'Used by', 'Finding'], function (r) {\n return [r.rule, r.kind, r.usedBy.length ? el('div', {}, r.usedBy.map(function (u) { return el('div', { className: 'small', text: u }); })) : '', r.finding ? pill(r.finding, 'lose') : ''];\n }, 'Rule usage')));\n }\n\n // ---------- Non-employees (NERM) page ----------\n function nmState() {\n if (!state.nm) state.nm = { tab: 'overview', settings: null, overview: { days: 30, endAttribute: '' }, sync: {}, sessions: { minDays: 0 }, risk: {}, users: {} };\n return state.nm;\n }\n var NM_TABS = [\n ['overview', 'End dates and sponsors', 'clock', 'Active non-employees past their end date or ending soon, and non-employees without a sponsor or whose sponsor has left.'],\n ['sync', 'NERM vs ISC', 'cols', 'Profiles whose status in NERM does not match their identity in ISC: terminated in NERM but still active in ISC, and the reverse.'],\n ['sessions', 'Waiting workflows', 'lifecycle', 'NERM workflow sessions still waiting for an approval, review, fulfilment or another step.'],\n ['risk', 'High risk', 'shield', 'Non-employees with the highest NERM risk level, active ones first.'],\n ['users', 'Portal users who left', 'people', 'Sponsors, managers and admins who can still sign in to NERM although their identity in ISC has left.']\n ];\n function renderNerm() {\n var N = nmState();\n var outer = $('nerm');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#ccfbf1' }, icon('people')),\n el('div', {}, el('h2', { text: 'Non-employees' }), el('p', { className: 'desc', text: 'Contractors, vendors and other non-employees in Non-Employee Risk Management (NERM), checked against ISC. Read-only: GET requests on seven NERM read endpoints only.' }))));\n if (!N.settings) {\n N.settings = 'loading';\n api('/api/nerm/settings').then(function (s) { N.settings = s; }, function () { N.settings = {}; }).then(function () { if (state.page === 'nerm') renderNerm(); });\n }\n var S = N.settings && N.settings !== 'loading' ? N.settings : {};\n var addr = el('input', { className: 'input', value: N.addrDraft !== undefined ? N.addrDraft : (S.address || ''), placeholder: 'acme or https://acme.nonemployee.com', style: 'max-width:320px', 'aria-label': 'NERM address' });\n addr.addEventListener('input', function () { N.addrDraft = addr.value; });\n w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' }, el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'NERM address' }), addr),\n el('button', { className: 'btn', onclick: function () {\n api('/api/nerm/settings', 'PUT', { address: addr.value }).then(function (s) { N.settings = s; N.addrDraft = undefined; toast(s.address ? 'Saved' : 'Cleared'); renderNerm(); }, function (e) { toast(errorText(e)); });\n } }, 'Save'),\n el('span', { className: 'muted small', style: 'flex:1;min-width:260px', text: S.base ? 'Reads ' + S.base + ' with the same sign-in as ISC. The API client or token needs a NERM scope (nerm:api:read-only is enough).' : 'Uses the same sign-in as ISC: no second secret. The API client or token needs a NERM scope (nerm:api:read-only is enough).' }))));\n var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });\n NM_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (N.tab === t[0] ? ' active' : ''), onclick: function () { N.tab = t[0]; renderNerm(); } }, icon(t[2]), t[1])); });\n w.appendChild(tabs);\n var spec = NM_TABS.filter(function (t) { return t[0] === N.tab; })[0];\n ({ overview: nmOverview, sync: nmSync, sessions: nmSessions, risk: nmRisk, users: nmUsers })[N.tab](w, N[N.tab], spec[3]);\n }\n function nmBar(w, H, kind, label, desc, extras, body) { return owRunBar(w, H, '/api/nerm/' + kind + '/run', label, desc, extras, body, renderNerm); }\n function nmProfileTable(H, rows, label, withEnd) {\n return filteredTable(H, rows, withEnd ? ['Profile', 'Type', 'End date', 'When', 'Sponsor'] : ['Profile', 'Type', 'Sponsor', 'Problem'], function (r) {\n return withEnd ? [r.name, r.type, r.endDate, pill(daysText(r.daysLeft), r.daysLeft < 0 || r.daysLeft <= 7 ? 'lose' : 'off'), r.sponsors] : [r.name, r.type, r.sponsors || '—', pill(r.sponsorProblem, 'lose')];\n }, label);\n }\n function nmOverview(w, H, desc) {\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Ending within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Ending within')),\n attrInput(H, 'endAttribute', 'End-date attribute (optional)', 'found automatically'));\n if (!nmBar(w, H, 'overview', 'Check non-employees', desc, extras, function () { return { days: H.days, endAttribute: H.endAttribute || undefined }; })) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'profiles'), stat(T.active, 'active'), stat(T.pastEnd, 'active past their end date', 'lose'), stat(T.ending, 'ending in ' + H.days + ' days'), stat(T.noSponsor, 'without a sponsor', 'lose'), stat(T.sponsorLeft, 'whose sponsor left', 'lose')));\n if (d.endAttribute || d.sponsorAttributes.length) w.appendChild(el('p', { className: 'muted small', text: [d.endAttribute ? 'End date from: ' + d.endAttribute : '', d.sponsorAttributes.length ? 'Sponsor from: ' + d.sponsorAttributes.join(', ') : ''].filter(Boolean).join(' · ') }));\n w.appendChild(section('By profile type', d.byType.length, simpleTable(['Profile type', 'Category', 'Active', 'On leave', 'Inactive', 'Terminated'], d.byType.map(function (b) { return [b.type, b.category, fmtNum(b.active), fmtNum(b.onLeave), fmtNum(b.inactive), fmtNum(b.terminated)]; }), 'Profiles by type')));\n if (d.pastEnd.length) w.appendChild(section('Active past their end date', d.pastEnd.length, nmProfileTable(H.past || (H.past = { data: d, job: H.job }), d.pastEnd, 'Active past end date', true)));\n if (d.ending.length) w.appendChild(section('Ending soon', d.ending.length, nmProfileTable(H.soon || (H.soon = { data: d, job: H.job }), d.ending, 'Ending soon', true)));\n if (d.sponsorIssues.length) w.appendChild(section('Sponsor problems', d.sponsorIssues.length, nmProfileTable(H.sp || (H.sp = { data: d, job: H.job }), d.sponsorIssues, 'Sponsor problems', false)));\n }\n function nmSync(w, H, desc) {\n if (!nmBar(w, H, 'sync', 'Compare with ISC', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.synced, 'profiles of synced types'), stat(T.checked, 'matched to an identity'), stat(T.leftInNermActiveInIsc, 'left in NERM, active in ISC', 'lose'), stat(T.activeInNermLeftInIsc, 'active in NERM, inactive in ISC', 'lose'), stat(T.notInIsc, 'active but not in ISC', 'lose')));\n if (d.sources.length) w.appendChild(el('p', { className: 'muted small', text: 'Matched through the ISC source' + (d.sources.length > 1 ? 's ' : ' ') + d.sources.join(', ') + '.' }));\n if (!d.rows.length) return;\n w.appendChild(section('Out of step', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status in NERM', 'Identity in ISC', 'State in ISC', 'Problem'], function (r) { return [r.profile, r.type, r.nermStatus, r.iscPerson, r.iscState, pill(r.problem, 'lose')]; }, 'NERM and ISC out of step')));\n }\n function nmSessions(w, H, desc) {\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Waiting at least' }), numSelect(H, 'minDays', [[0, 'any time'], [3, '3 days'], [7, '7 days'], [30, '30 days']], 'Minimum age'));\n if (!nmBar(w, H, 'sessions', 'Find waiting sessions', desc, extras, function () { return { minDays: H.minDays }; })) return;\n var d = H.data;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.sessions, 'sessions'), stat(d.totals.waiting, 'waiting', 'lose')));\n w.appendChild(section('By status', d.byStatus.length, simpleTable(['Status', 'Sessions'], d.byStatus.map(function (b) { return [b.status.replace(/_/g, ' '), fmtNum(b.sessions)]; }), 'Sessions by status')));\n if (d.waiting.length) w.appendChild(section('Waiting', d.waiting.length, filteredTable(H, d.waiting, ['Workflow', 'Status', 'Profile', 'Age'], function (r) { return [r.workflow, r.status.replace(/_/g, ' '), r.profile, r.age === undefined || r.age === null ? '—' : r.age + ' days']; }, 'Waiting workflow sessions')));\n }\n function nmRisk(w, H, desc) {\n if (!nmBar(w, H, 'risk', 'Read risk', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.scored, 'profiles with a risk score'), stat(T.high, 'at the highest level'), stat(T.highActive, 'of them active', 'lose')));\n if (d.rows.length) w.appendChild(section('Highest risk', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status', 'Risk level', 'Score'], function (r) { return [r.profile, r.type, r.status, pill(r.level, 'lose'), r.score]; }, 'High-risk non-employees')));\n }\n function nmUsers(w, H, desc) {\n if (!nmBar(w, H, 'users', 'Check portal users', desc)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.users, 'NERM users'), stat(T.active, 'active'), stat(T.leftInIsc, 'active in NERM but left in ISC', 'lose'), stat(T.neverLoggedIn, 'active, never signed in')));\n if (d.rows.length) w.appendChild(section('Users who left', d.rows.length, filteredTable(H, d.rows, ['User', 'Email', 'Type', 'Last sign-in', 'State in ISC'], function (r) { return [r.user, r.email, r.type, r.lastLogin ? String(r.lastLogin).slice(0, 10) : 'never', pill(r.iscState, 'lose')]; }, 'NERM users who left')));\n }\n // ---------- 0.24.0: grouped tabs, and the access model, aggregation safety, service accounts, duplicates, passwords, reassigned reviews ----------\n /**\n * Two-level navigation for pages with many tabs: a short row of sections,\n * then only the tabs of the section that is open.\n * groups: [[section label, [tab ids]]]; tabs: [[id, label, icon, ...]].\n */\n function groupedTabs(w, key, groups, tabs, current, pick) {\n var memo = state.tabMemo || (state.tabMemo = {});\n var gi = 0;\n groups.forEach(function (g, i) { if (g[1].indexOf(current) >= 0) gi = i; });\n memo[key + gi] = current;\n var seg = el('div', { className: 'seg' });\n groups.forEach(function (g, i) {\n seg.appendChild(el('button', { className: 'segbtn' + (i === gi ? ' active' : ''), 'aria-pressed': String(i === gi), onclick: function () {\n var last = memo[key + i];\n pick(last && g[1].indexOf(last) >= 0 ? last : g[1][0]);\n } }, g[0], el('span', { className: 'segn', text: String(g[1].length) })));\n });\n w.appendChild(seg);\n var row = el('div', { className: 'tabs sub' });\n groups[gi][1].forEach(function (id) {\n var t = tabs.filter(function (x) { return x[0] === id; })[0];\n if (t) row.appendChild(el('button', { className: 'tab' + (current === id ? ' active' : ''), onclick: function () { pick(id); } }, icon(t[2]), t[1]));\n });\n w.appendChild(row);\n }\n var WN_GROUPS = [\n ['Joiners, movers, leavers', ['upcoming', 'joiners', 'movers', 'leavers', 'mgrleft', 'people', 'expiry']],\n ['Accounts', ['outside', 'syncdrift', 'multi', 'svc', 'admins']],\n ['Provisioning', ['massch', 'loops', 'aggsafe', 'pwfail']],\n ['Requests and reviews', ['ending', 'stuckreq', 'stuck', 'groupappr', 'reminders', 'revokes']],\n ['Threat signals', ['risk', 'privgain', 'outacct', 'sensitive', 'signins', 'selfappr', 'adminact', 'spikes']],\n ['Tenant health', ['lcset', 'govgroups', 'catalog', 'growth', 'quality']]\n ];\n var AU_TABS = [['certs', 'Certifications', 'cert'], ['sod', 'Separation of duties', 'shield'], ['coverage', 'Review coverage', 'eye'], ['reassigned', 'Reassigned reviews', 'people'], ['exceptions', 'Exceptions', 'file'],\n ['outliers', 'Access outliers', 'people'], ['outmodel', 'Outside roles', 'eye'], ['composition', 'What is in every role', 'cols'], ['adminaccts', 'Admin accounts', 'shield'], ['owners', 'Entitlement owners', 'people'],\n ['trail', 'Request trail', 'file'], ['chain', 'Approver chain', 'people'],\n ['speed', 'Provisioning speed', 'pulse'], ['leavertimes', 'Leaver removal times', 'clock'], ['attrhist', 'Attribute changes', 'lifecycle'],\n ['changes', 'Change history', 'clock'], ['evidence', 'Evidence pack', 'download']];\n var AU_GROUPS = [\n ['Reviews', ['certs', 'coverage', 'reassigned', 'sod', 'exceptions']],\n ['Who has what', ['outliers', 'outmodel', 'composition', 'adminaccts', 'owners']],\n ['Requests', ['trail', 'chain']],\n ['Speed and history', ['speed', 'leavertimes', 'attrhist']],\n ['Changes and evidence', ['changes', 'evidence']]\n ];\n function mdState() {\n if (!state.md) state.md = { outmodel: { query: '', view: 'ent' }, composition: {}, aggsafe: { days: 14 }, signins: { days: 7, minFailed: 10 }, selfappr: { days: 90 }, adminact: { days: 7 }, spikes: { days: 7, min: 15 }, lcset: {}, govgroups: {}, svc: { unusedDays: 90 }, multi: {}, pwfail: { days: 14 }, reassigned: { days: 180 } };\n return state.md;\n }\n function mdRun(w, H, kind, label, desc, extras, body, rerender) { return owRunBar(w, H, '/api/watch/' + kind + '/run', label, desc, extras, body, rerender); }\n function pct(a, b) { return b ? Math.round(a * 100 / b) : 0; }\n\n // Audit > Outside roles\n function renderOutsideModel(w) {\n var H = mdState().outmodel;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.department:Finance', style: 'max-width:300px', 'aria-label': 'Only identities matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only identities matching (optional)' }), q);\n if (!mdRun(w, H, 'outside-model', 'Find direct access', 'Entitlements identities hold on their own, not through any role or access profile: the access nobody designed. Shows which entitlements are mostly given directly and who holds them.', extras, function () { return { query: H.query || undefined }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'active identities'), stat(T.assignments, 'entitlements held'), stat(T.direct, 'held directly', 'lose'), stat(pct(T.direct, T.assignments), '% held directly'), stat(T.peopleWithDirect, 'identities with direct access'), stat(T.entitlementsOnlyDirect, 'entitlements never given by a role')));\n var sw = el('div', { className: 'seg', style: 'margin:0 0 10px' }, [['ent', 'By entitlement'], ['people', 'By identity']].map(function (v) {\n return el('button', { className: 'segbtn' + (H.view === v[0] ? ' active' : ''), 'aria-pressed': String(H.view === v[0]), onclick: function () { H.view = v[0]; renderAudit(); } }, v[1]);\n }));\n w.appendChild(sw);\n if (H.view === 'ent') w.appendChild(section('Entitlements given directly', d.entitlements.length, filteredTable(H.e || (H.e = { data: d, job: H.job }), d.entitlements, ['Entitlement', 'Source', 'Privileged', 'Holders', 'Directly', 'Through a role or access profile'], function (r) {\n return [r.entitlement, r.source, r.privileged ? pill('privileged', 'lose') : '', fmtNum(r.holders), el('span', {}, fmtNum(r.direct), el('span', { className: 'muted small', text: ' (' + pct(r.direct, r.holders) + '%)' })), fmtNum(r.viaModel)];\n }, 'Entitlements given directly')));\n else w.appendChild(section('Identities with direct access', d.people.length + (d.morePeople || 0), filteredTable(H, d.people, ['Identity', 'Entitlement', 'Source', 'Privileged'], function (r) { return [r.person, r.entitlement, r.source, r.privileged ? pill('privileged', 'lose') : '']; }, 'Access held directly')));\n }\n\n // Audit > What is in every role\n function renderComposition(w) {\n var H = mdState().composition;\n if (!mdRun(w, H, 'composition', 'Read every role', 'Every role with its access profiles and the entitlements inside them, as one table to filter and download. Flags empty roles and access profiles.', null, null, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.roles, 'roles'), stat(T.accessProfiles, 'access profiles'), stat(T.emptyRoles, 'empty roles', 'lose'), stat(T.emptyProfiles, 'access profiles without entitlements', 'lose'), stat(T.profilesNotInARole, 'access profiles in no role'), stat(T.disabledRoles, 'disabled roles')));\n if (!d.rows.length) return;\n w.appendChild(section('Composition', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Role', 'Owner', 'Assigned', 'Access profile', 'Entitlement', 'Source', 'Note'], function (r) {\n return [el('span', {}, r.role, r.roleState === 'disabled' ? el('span', {}, ' ', pill('disabled', 'off')) : null), r.roleOwner, r.assignment, r.accessProfile, r.entitlement, r.source, r.note ? pill(r.note, 'lose') : ''];\n }, 'What is in every role')));\n }\n\n // Audit > Reassigned reviews\n function renderReassigned(w) {\n var H = mdState().reassigned;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Campaigns of the last' }), numSelect(H, 'days', [[90, '90 days'], [180, '180 days'], [365, '365 days']], 'Campaign period'));\n if (!mdRun(w, H, 'reassigned', 'Find reassigned reviews', 'Certifications that were passed on: from whom, to whom, the reason given, and whether the new reviewer is still here.', extras, function () { return { days: H.days }; }, renderAudit)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(d.campaigns, 'campaigns checked'), stat(T.certifications, 'certifications'), stat(T.reassigned, 'reassigned'), stat(T.withoutComment, 'without a reason', 'lose'), stat(T.toSomeoneWhoLeft, 'now with someone who left', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No review was reassigned.' })); return; }\n if (d.byReceiver.length > 1) w.appendChild(section('Who received them', d.byReceiver.length, simpleTable(['Reviewer', 'Reviews received'], d.byReceiver.slice(0, 50).map(function (r) { return [r.reviewer, fmtNum(r.received)]; }), 'Reviews received by reviewer')));\n w.appendChild(section('Reassigned reviews', d.rows.length, filteredTable(H, d.rows, ['Campaign', 'Certification', 'From', 'Now with', 'Reason given', 'Decisions', 'Signed off'], function (r) {\n return [r.campaign, r.certification, r.from, el('span', {}, r.to, r.toState && r.toState !== 'active' ? el('span', {}, ' ', pill(r.toState, 'lose')) : null), r.comment || el('span', { className: 'muted', text: 'none' }), r.decisions, r.signed || '—'];\n }, 'Reassigned reviews')));\n }\n\n // Warnings > Aggregation safety\n function wnAggSafety(w, _H, desc) {\n var H = mdState().aggsafe;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Aggregations of the last' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period'));\n if (!mdRun(w, H, 'agg-safety', 'Check aggregations', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.sources, 'sources'), stat(T.flagged, 'with a finding', 'lose'), stat(T.failed, 'with failed aggregations', 'lose'), stat(T.highThreshold, 'with a delete threshold of 50% or more', 'lose'), stat(T.stale, 'did not aggregate')));\n var V = H.view || (H.view = { only: 'flagged' });\n var only = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Show' }, [['flagged', 'Only with findings'], ['all', 'All sources']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n only.value = V.only;\n only.addEventListener('change', function () { V.only = only.value; renderWarnings(); });\n var rows = d.rows.filter(function (r) { return V.only === 'all' || r.findings.length; });\n w.appendChild(section('Sources', rows.length, filteredTable(H, rows, ['Source', 'Delete threshold', 'Aggregations', 'Failed', 'Last good one', 'Findings'], function (r) {\n return [el('span', {}, r.source, r.authoritative ? el('span', {}, ' ', pill('authoritative', 'blue')) : null, el('div', { className: 'small muted', text: r.type })), r.deleteThreshold === null ? '—' : r.deleteThreshold + '%', r.runs, r.failed ? pill(String(r.failed), 'lose') : '0', when16(r.lastOk) || '—',\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'Aggregation safety', only)));\n }\n\n // Warnings > Service accounts\n function wnServiceAccounts(w, _H, desc) {\n var H = mdState().svc;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Unused after' }), numSelect(H, 'unusedDays', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Unused after'));\n if (!mdRun(w, H, 'service-accounts', 'Check service accounts', desc, extras, function () { return { unusedDays: H.unusedDays }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'service and machine accounts'), stat(T.noOwner, 'without an owner', 'lose'), stat(T.enabledNoOwner, 'of them enabled', 'lose'), stat(T.ownerLeft, 'whose owner left', 'lose'), stat(T.unused, 'not used for ' + H.unusedDays + ' days')));\n if (!d.rows.length) return;\n if (d.byOwner.length) w.appendChild(section('Who owns them', d.byOwner.length, simpleTable(['Owner', 'State', 'Accounts owned'], d.byOwner.slice(0, 200).map(function (o) { return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.accounts)]; }), 'Service account owners')));\n w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Account', 'Source', 'Owner', 'Account', 'Last used', 'Findings'], function (r) {\n return [el('span', {}, r.account, r.subtype ? el('div', { className: 'small muted', text: r.subtype }) : null), r.source, r.owner || el('span', { className: 'muted', text: 'none' }), r.enabled ? 'enabled' : 'disabled', r.lastUsed ? String(r.lastUsed).slice(0, 10) : '—', r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', {}, pill(f, 'lose')); })) : ''];\n }, 'Service and machine accounts')));\n }\n\n // Warnings > Several accounts\n function wnMultiAccounts(w, _H, desc) {\n var H = mdState().multi;\n if (!mdRun(w, H, 'multi-accounts', 'Find identities with several accounts', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'active identities'), stat(T.withDuplicates, 'with several accounts on one source'), stat(T.onAuthoritative, 'on the authoritative source', 'lose')));\n if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Nobody has more than one account on the same source.' })); return; }\n w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'Identities with several accounts'], d.bySource.map(function (s) { return [s.source, fmtNum(s.people)]; }), 'Several accounts by source')));\n w.appendChild(section('Identities', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Lifecycle state', 'Source', 'Accounts', 'Account names'], function (r) {\n return [r.person, r.personState, el('span', {}, r.source, r.authoritative ? el('span', {}, ' ', pill('authoritative', 'lose')) : null), r.accounts + ' (' + r.enabled + ' enabled)', el('span', { className: 'small', text: r.names })];\n }, 'Identities with several accounts on one source')));\n }\n\n // Warnings > Password failures\n function wnPasswordFailures(w, _H, desc) {\n var H = mdState().pwfail;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n if (!mdRun(w, H, 'password-failures', 'Find failed password changes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'password events'), stat(T.passed, 'passed'), stat(T.failed, 'failed', 'lose'), stat(T.people, 'identities affected', 'lose')));\n if (d.bySource.length > 1) w.appendChild(section('By source', d.bySource.length, simpleTable(['Source', 'Passed', 'Failed'], d.bySource.map(function (s) { return [s.source, fmtNum(s.passed), s.failed ? pill(fmtNum(s.failed), 'lose') : '0']; }), 'Password events by source')));\n if (d.rows.length) w.appendChild(section('Failures', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['When', 'Identity', 'Source', 'Event', 'Error'], function (r) { return [when16(r.when), r.person, r.source, r.event, el('span', { className: 'small', text: r.error })]; }, 'Password failures')));\n }\n\n // Warnings > Lifecycle settings\n function wnLifecycleSettings(w, _H, desc) {\n var H = mdState().lcset;\n if (!mdRun(w, H, 'lifecycle-settings', 'Read lifecycle states', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'identity profiles'), stat(T.states, 'lifecycle states'), stat(T.leaverStates, 'leaver states'), stat(T.flagged, 'with a finding', 'lose')));\n w.appendChild(section('Lifecycle states', d.rows.length, filteredTable(H, d.rows, ['Identity profile', 'State', 'Identities', 'What it does to accounts', 'Removes all access', 'Findings'], function (r) {\n return [r.profile, el('span', {}, r.state, ' ', pill(r.kind === 'leaver' ? 'leaver' : 'active', r.kind === 'leaver' ? 'off' : 'blue'), r.enabled ? null : el('span', {}, ' ', pill('switched off', 'lose'))), r.people === null ? '—' : fmtNum(r.people), el('span', { className: 'small', text: r.accounts }), r.removesAccess ? 'Yes' : 'No',\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'What each lifecycle state does')));\n }\n\n // Warnings > Governance groups\n function wnGovGroups(w, _H, desc) {\n var H = mdState().govgroups;\n if (!mdRun(w, H, 'gov-groups', 'Check governance groups', desc, null, null, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.groups, 'governance groups'), stat(T.empty, 'without members', 'lose'), stat(T.nobodyActive, 'where every member left', 'lose'), stat(T.ownerLeft, 'whose owner left', 'lose'), stat(T.unused, 'not used anywhere')));\n if (!d.rows.length) return;\n w.appendChild(section('Groups', d.rows.length, filteredTable(H, d.rows, ['Group', 'Owner', 'Members', 'Members who left', 'Used in', 'Findings'], function (r) {\n return [r.group, el('span', {}, r.owner || '—', r.ownerState !== 'active' && r.owner ? el('span', {}, ' ', pill(r.ownerState, 'lose')) : null), r.activeMembers + ' of ' + r.members + ' active', el('span', { className: 'small', text: r.left.join(', ') }), r.usedIn === null ? '—' : r.usedIn + ' place' + (r.usedIn === 1 ? '' : 's'),\n r.findings.length ? el('div', {}, r.findings.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })) : ''];\n }, 'Governance groups')));\n }\n\n // If the program closed by itself last time, say where it was (from the small activity file).\n function showLastCrash() {\n api('/api/last-crash').then(function (r) {\n var c = r && r.crash;\n if (!c || $('crash-note')) return;\n var box = el('div', { id: 'crash-note', className: 'error', style: 'margin:12px auto;max-width:1240px;display:flex;gap:12px;align-items:flex-start' },\n el('div', { style: 'flex:1' }, el('b', { text: 'IdentityScope closed unexpectedly last time. ' }),\n 'It was ' + (c.doing || 'working') + ' (' + String(c.at || '').slice(0, 16).replace('T', ' ') + ' UTC). Progress: ' + (c.progress || 'unknown') + '. Memory in use: ' + c.memoryMB + ' of ' + c.limitMB + ' MB. Please send this line when you report it.'),\n el('button', { className: 'btn sm', text: 'Dismiss', onclick: function () { api('/api/last-crash/dismiss', 'POST', {}); box.remove(); } }));\n var host = document.querySelector('header');\n if (host && host.parentNode) host.parentNode.insertBefore(box, host.nextSibling);\n }).catch(function () {});\n }\n setTimeout(showLastCrash, 1200);\n\n // ---------- Warnings > Threat signals ----------\n var THREAT_NOTE = 'Signals to look into, not proof of an attack. IdentityScope reads them when you press the button; it does not watch in real time.';\n function threatNote(w) { w.appendChild(el('p', { className: 'muted small', style: 'margin:-6px 0 12px', text: THREAT_NOTE })); }\n function sigList(xs) { return el('div', {}, xs.map(function (f) { return el('div', { className: 'small', style: 'color:var(--danger)', text: f }); })); }\n function wnSignIns(w, _H, desc) {\n var H = mdState().signins;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Flag from' }), numSelect(H, 'minFailed', [[5, '5 failures a day'], [10, '10 failures a day'], [25, '25 failures a day'], [50, '50 failures a day']], 'Failures per day')));\n threatNote(w);\n if (!mdRun(w, H, 'signins', 'Read sign-ins', desc, extras, function () { return { days: H.days, minFailed: H.minFailed }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'sign-in events'), stat(T.failed, 'failed'), stat(T.people, 'identities'), stat(T.flagged, 'identities with a signal', 'lose'), stat(T.leaversSignedIn, 'leavers who signed in', 'lose')));\n if (d.byAddress.length) w.appendChild(section('One address, many identities', d.byAddress.length, simpleTable(['Network address', 'Identities tried', 'Failed sign-ins'], d.byAddress.map(function (a) { return [a.address, fmtNum(a.people), fmtNum(a.failed)]; }), 'Addresses with failures for many identities')));\n if (d.rows.length) w.appendChild(section('Identities', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'State', 'Failed', 'Successful', 'Worst day', 'Signals'], function (r) {\n return [el('span', {}, r.person, el('div', { className: 'small muted', text: r.username })), r.state === 'active' ? 'active' : pill(r.state, 'lose'), fmtNum(r.failed), fmtNum(r.passed), r.worstDay + ' (' + r.worstDayFailed + ')', sigList(r.signals)];\n }, 'Sign-in signals')));\n else if (T.events) w.appendChild(el('p', { className: 'muted', text: 'No sign-in signal in this period.' }));\n }\n function wnSelfApprovals(w, _H, desc) {\n var H = mdState().selfappr;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Requests of the last' }), numSelect(H, 'days', [[30, '30 days'], [90, '90 days'], [180, '180 days'], [365, '365 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'self-approvals', 'Find self-approvals', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.requests, 'requests'), stat(T.approvedSteps, 'approvals'), stat(T.selfApproved, 'approved their own access', 'lose'), stat(T.requesterApproved, 'approved what they requested for someone', 'lose')));\n if (d.rows.length) w.appendChild(section('Self-approvals', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Approved at', 'Access', 'Requested for', 'Requested by', 'Approved by', 'Finding'], function (r) { return [when16(r.when), r.access, r.requestedFor, r.requestedBy, r.approver, pill(r.kind, 'lose')]; }, 'Self-approvals')));\n else if (T.requests) w.appendChild(el('p', { className: 'muted', text: 'Nobody approved their own request.' }));\n }\n function wnAdminActivity(w, _H, desc) {\n var H = mdState().adminact;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'admin-activity', 'Read admin activity', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'changes by identities'), stat(T.actors, 'who made them'), stat(T.byLeavers, 'are identities who left', 'lose'), stat(T.unknownActors, 'are not an identity in ISC')));\n if (d.actors.length) w.appendChild(section('Who made changes', d.actors.length, simpleTable(['Who', 'State', 'Changes', 'To what', 'Last change', 'Signals'], d.actors.slice(0, 300).map(function (a) {\n return [a.actor, a.state === 'active' ? 'active' : pill(a.state, a.state === 'not an identity in ISC' ? 'off' : 'lose'), fmtNum(a.changes), a.kinds, when16(a.last), a.signals.length ? sigList(a.signals) : ''];\n }), 'Who made changes')));\n if (d.events.length) w.appendChild(section('Changes', d.events.length + (d.more || 0), filteredTable(H, d.events, ['When', 'Who', 'Event', 'On'], function (r) { return [when16(r.when), r.actor, r.event, r.target]; }, 'Administration changes')));\n }\n function wnAccessSpikes(w, _H, desc) {\n var H = mdState().spikes;\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Flag from' }), numSelect(H, 'min', [[5, '5 items a day'], [15, '15 items a day'], [30, '30 items a day'], [100, '100 items a day']], 'Items per day')));\n threatNote(w);\n if (!mdRun(w, H, 'access-spikes', 'Find access spikes', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.activities, 'provisioning activities read'), stat(T.people, 'identities who gained access'), stat(T.flagged, 'with ' + d.min + ' or more in one day', 'lose')));\n if (d.rows.length) w.appendChild(section('Access spikes', d.rows.length, filteredTable(H, d.rows, ['Identity', 'State', 'Day', 'Added', 'Sources', 'Requested by', 'Examples'], function (r) { return [r.person, r.personState, r.day, pill(String(r.added), 'lose'), r.sources, r.requestedBy, el('span', { className: 'small', text: r.examples })]; }, 'Access spikes per identity')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nobody was given that much access in one day.' }));\n }\n // ---------- 0.27.0: Logs page; privileged access gained, accounts created outside ISC, sensitive changes, risk by person; joiner and leaver preview; stuck requests ----------\n function lgState() {\n if (!state.lg) {\n var saved = '';\n try { saved = localStorage.getItem('identityscope.logpath') || ''; } catch (e) { saved = ''; }\n state.lg = { tab: 'ccg', ccg: { path: saved, level: 'WARN', source: '', text: '', from: '', to: '', open: {} }, isc: { days: 2, source: '', failedOnly: true } };\n }\n return state.lg;\n }\n var LG_TABS = [\n ['ccg', 'Connector log (ccg.log)', 'file', 'Read the connector log of a Virtual Appliance from a copy on this computer: errors grouped and counted, per source, with the full error detail.'],\n ['isc', 'What ISC recorded', 'pulse', 'One timeline per source of what ISC itself recorded: aggregations, source changes, provisioning that ended with an error, and the state of the Virtual Appliances.']\n ];\n function tw() {\n if (!state.tw) state.tw = { priv: { remember: true }, outacct: { days: 7 }, sensitive: { days: 7 }, risk: { days: 7 }, upcoming: { days: 14, startDateAttribute: '', endDateAttribute: '', query: '' }, stuckreq: { hours: 24 } };\n return state.tw;\n }\n function renderLogs() {\n var L = lgState();\n var outer = $('logs');\n outer.textContent = '';\n var w = el('div', { className: 'wrap', style: 'max-width:1240px' });\n outer.appendChild(w);\n w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#1d4ed8;background:#dbeafe' }, icon('file')),\n el('div', {}, el('h2', { text: 'Logs' }), el('p', { className: 'desc', text: 'Find out why a source failed without signing in to a server. Read-only; nothing from a log is stored or sent anywhere.' }))));\n var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });\n LG_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (L.tab === t[0] ? ' active' : ''), onclick: function () { L.tab = t[0]; renderLogs(); } }, icon(t[2]), t[1])); });\n w.appendChild(tabs);\n var spec = LG_TABS.filter(function (t) { return t[0] === L.tab; })[0];\n if (L.tab === 'ccg') lgCcg(w, L.ccg, spec[3]); else lgIsc(w, L.isc, spec[3]);\n }\n function lgField(H, key, label, placeholder, width, type) {\n var i = el('input', { className: 'input', value: H[key] || '', placeholder: placeholder || '', style: 'max-width:' + (width || 200) + 'px', 'aria-label': label, type: type || 'text' });\n i.addEventListener('input', function () { H[key] = i.value; });\n return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label }), i);\n }\n function lgFilter(H) { return { level: H.level, source: H.source || undefined, text: H.text || undefined, from: H.from || undefined, to: H.to || undefined }; }\n function lgCcg(w, H, desc) {\n w.appendChild(el('p', { className: 'muted', style: 'margin:0 0 10px', text: desc }));\n w.appendChild(el('div', { className: 'note', text: 'ISC has no way to hand out ccg.log, so IdentityScope reads a copy: copy the file from the Virtual Appliance (/home/sailpoint/log/ccg.log) to this computer or a shared folder once, then give its path here or choose the file. A folder reads every log file in it, rotated and .gz files included.' }));\n var path = el('input', { className: 'input', value: H.path || '', placeholder: 'C:\\\\logs\\\\ccg.log or /home/me/va-logs', style: 'min-width:320px;flex:1', 'aria-label': 'Path of ccg.log or its folder on this computer' });\n path.addEventListener('input', function () { H.path = path.value; });\n var picker = el('input', { type: 'file', className: 'hidden', 'aria-label': 'Choose a log file', accept: '.log,.txt,.json,.jsonl,.gz,*/*' });\n var run = function () {\n try { localStorage.setItem('identityscope.logpath', H.path || ''); } catch (e) { /* not kept */ }\n H.open = {};\n runJobInto(H, '/api/logs/ccg/run', Object.assign({ path: H.path }, lgFilter(H)), renderLogs);\n };\n picker.addEventListener('change', function () {\n var f = picker.files && picker.files[0];\n if (!f) return;\n var q = lgFilter(H); q.name = f.name;\n var qs = Object.keys(q).filter(function (k) { return q[k]; }).map(function (k) { return k + '=' + encodeURIComponent(q[k]); }).join('&');\n H.busy = 'Reading ' + f.name + ' (' + fmtNum(Math.round(f.size / 1048576)) + ' MB)...'; H.error = null; H.data = null; H.open = {}; renderLogs();\n fetch('/api/logs/ccg/upload?' + qs, { method: 'POST', headers: { 'x-isc-reports-key': KEY, 'content-type': 'application/octet-stream' }, body: f }).then(function (res) {\n return res.json().then(function (d) { if (!res.ok) throw new Error(d.error || 'The file could not be read.'); return d; });\n }).then(function (r) {\n H.job = r.job;\n pollJob(r.job, function (m) { H.busy = m; renderLogs(); }, function (s) { H.busy = null; H.data = s.extra; renderLogs(); }, function (e) { H.busy = null; H.error = e; renderLogs(); });\n }, function (e) { H.busy = null; H.error = errorText(e); renderLogs(); });\n });\n var level = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Which lines' }, [['ERROR', 'Errors only'], ['WARN', 'Errors and warnings'], ['INFO', 'Everything but debug'], ['DEBUG', 'Everything']].map(function (o) { return el('option', { value: o[0], text: o[1] }); }));\n level.value = H.level;\n level.addEventListener('change', function () { H.level = level.value; });\n w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' },\n el('div', { className: 'bar' }, el('label', { className: 'field', style: 'margin:0;flex:1;min-width:320px' }, el('span', { className: 'lbl', text: 'File or folder on this computer' }), path),\n el('button', { className: 'btn primary', disabled: !!H.busy || !(H.path || '').trim(), onclick: run }, icon('play'), H.data ? 'Read again' : 'Read the log'),\n el('span', { className: 'muted small', text: 'or' }),\n el('button', { className: 'btn', disabled: !!H.busy, onclick: function () { picker.click(); } }, icon('file'), 'Choose a file'), picker),\n el('div', { className: 'bar', style: 'margin-top:10px' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Lines' }), level),\n lgField(H, 'source', 'Source name contains', 'e.g. Active Directory', 200),\n lgField(H, 'text', 'Message contains', 'e.g. timeout', 180),\n lgField(H, 'from', 'From', '', 200, 'datetime-local'),\n lgField(H, 'to', 'To', '', 200, 'datetime-local'))));\n // The path field must be enabled as soon as something is typed.\n path.addEventListener('input', function () { var b = w.querySelector('button.primary'); if (b) b.disabled = !!H.busy || !path.value.trim(); });\n if (H.busy) { w.appendChild(busyBox(H.busy)); return; }\n if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }\n if (!H.data) return;\n var d = H.data, T = d.totals;\n (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.lines, 'lines in the file'), stat(T.matched, 'lines kept by the filter'), stat(T.errors, 'errors', 'lose'), stat(T.warnings, 'warnings', 'lose'), stat(T.groups, 'different errors and warnings'), stat(d.bySource.length, 'sources')));\n if (T.first) w.appendChild(el('p', { className: 'muted small', style: 'margin:-4px 0 12px', text: 'From ' + when16(T.first) + ' to ' + when16(T.last) + ' (times as written in the log, UTC). ' + (d.files || []).length + ' file' + ((d.files || []).length === 1 ? '' : 's') + ' read.' }));\n if (d.byHour.length > 1) {\n var max = Math.max.apply(null, d.byHour.map(function (h) { return h.errors + h.warnings; })) || 1;\n var strip = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:64px;margin:4px 0 6px', role: 'img', 'aria-label': 'Errors and warnings per hour' });\n d.byHour.forEach(function (h) {\n var n = h.errors + h.warnings;\n strip.appendChild(el('div', { title: h.hour.replace('T', ' ') + ':00 ' + h.errors + ' errors, ' + h.warnings + ' warnings', style: 'flex:1;min-width:2px;max-width:18px;height:' + Math.max(2, Math.round(n * 60 / max)) + 'px;background:' + (h.errors ? '#dc2626' : n ? '#d97706' : '#e5e7eb') }));\n });\n w.appendChild(section('Errors and warnings per hour', d.byHour.length, el('div', {}, strip, el('div', { className: 'muted small', style: 'display:flex;justify-content:space-between' }, el('span', { text: d.byHour[0].hour.replace('T', ' ') + ':00' }), el('span', { text: d.byHour[d.byHour.length - 1].hour.replace('T', ' ') + ':00' })))));\n }\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'Type', 'Lines', 'Errors', 'Warnings', 'Last error', 'At'], d.bySource.map(function (r) {\n return [r.source, r.type, fmtNum(r.lines), r.errors ? pill(fmtNum(r.errors), 'lose') : '0', fmtNum(r.warnings), el('span', { className: 'small', text: r.lastError || '' }), when16(r.lastErrorAt)];\n }), 'Per source')));\n if (d.groups.length) {\n w.appendChild(section('Errors and warnings, repeats counted once', d.groups.length + (d.moreGroups || 0), filteredTable(H, d.groups, ['Level', 'Source', 'Operation', 'Times', 'First', 'Last', 'Message'], function (g) {\n var key = g.level + '|' + g.source + '|' + g.operation + '|' + g.pattern;\n var detail = el('div', { className: H.open[key] ? '' : 'hidden' }, el('pre', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word;margin:6px 0 0;max-height:320px;overflow:auto', text: g.example + (g.exception ? '\\n\\n' + g.exception : '') }), g.logger ? el('div', { className: 'muted small', text: 'Logger: ' + g.logger }) : null);\n var btn = el('button', { className: 'linkbtn small', 'aria-expanded': String(!!H.open[key]), onclick: function () { H.open[key] = !H.open[key]; detail.classList.toggle('hidden', !H.open[key]); btn.setAttribute('aria-expanded', String(!!H.open[key])); btn.textContent = H.open[key] ? 'Hide detail' : 'Show detail'; } }, H.open[key] ? 'Hide detail' : 'Show detail');\n return [(/ERR|FATAL/.test(g.level) ? pill(g.level, 'lose') : el('span', { style: 'color:#92400e;font-weight:600', text: g.level })), g.source, g.operation, fmtNum(g.count), when16(g.first), when16(g.last), el('div', {}, el('div', { className: 'small', text: g.example.slice(0, 260) + (g.example.length > 260 ? '…' : '') }), btn, detail)];\n }, 'Errors and warnings')));\n } else w.appendChild(el('p', { className: 'muted', text: T.read ? 'No errors or warnings in what the filter kept.' : '' }));\n if (d.latest.length) w.appendChild(section('Latest lines kept by the filter', d.latest.length, simpleTable(['Time', 'Level', 'Source', 'Operation', 'Message'], d.latest.slice(0, 200).map(function (r) {\n return [when16(r.time), r.level, r.source, r.operation, el('span', { className: 'small', text: r.message.slice(0, 400) })];\n }), 'Latest lines')));\n }\n function lgIsc(w, H, desc) {\n var only = el('input', { type: 'checkbox', checked: !!H.failedOnly, 'aria-label': 'Only what failed' });\n only.addEventListener('change', function () { H.failedOnly = only.checked; });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[1, '24 hours'], [2, '2 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),\n lgField(H, 'source', 'Source (exact name, optional)', 'all sources', 220),\n el('label', { style: 'display:flex;gap:6px;align-items:center' }, only, 'Only what failed'));\n if (!owRunBar(w, H, '/api/watch/source-log/run', 'Read what ISC recorded', desc, extras, function () { return { days: H.days, source: H.source || undefined, failedOnly: !!H.failedOnly }; }, renderLogs)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.events, 'aggregation and source events'), stat(T.failed, 'failed', 'lose'), stat(T.provisioningErrors, 'provisioning errors', 'lose'), stat(T.appliancesNotNormal, 'Virtual Appliances not normal', 'lose')));\n if (d.appliances.length) w.appendChild(section('Virtual Appliances now', d.appliances.length, simpleTable(['Cluster', 'Appliance', 'Status', 'Alert', 'Last seen', 'Sources on the cluster'], d.appliances.map(function (a) {\n return [a.cluster, a.client, a.status === 'NORMAL' ? a.status : pill(a.status || 'unknown', 'lose'), a.alert, when16(a.lastSeen), fmtNum(a.sources)];\n }), 'Virtual Appliances')));\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'Type', 'Aggregations', 'Failed', 'Last aggregation', 'Provisioning errors', 'Last error', 'Cluster'], d.bySource.map(function (r) {\n return [r.source, r.type, fmtNum(r.aggregations), r.failedAggregations ? pill(String(r.failedAggregations), 'lose') : '0', r.lastAggregation ? el('span', {}, when16(r.lastAggregation), ' ', /fail|error/i.test(r.lastAggregationStatus || '') ? pill(r.lastAggregationStatus, 'lose') : el('span', { className: 'muted small', text: r.lastAggregationStatus || '' })) : '', r.provisioningErrors ? pill(String(r.provisioningErrors), 'lose') : '0', el('span', { className: 'small', text: r.lastError || '' }), r.cluster ? el('span', {}, r.cluster, r.clusterStatus && r.clusterStatus !== 'NORMAL' ? el('div', {}, pill(r.clusterStatus, 'lose')) : null) : ''];\n }), 'Per source')));\n if (d.rows.length) w.appendChild(section('Timeline', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['When', 'Source', 'Kind', 'Status', 'What', 'Detail', 'Who'], function (r) {\n return [when16(r.when), r.source, r.kind, /fail|error/i.test(r.status) ? pill(r.status, 'lose') : r.status, r.what, el('span', { className: 'small', style: 'word-break:break-word', text: r.detail }), r.who];\n }, 'Timeline')));\n else w.appendChild(el('p', { className: 'muted', text: 'ISC recorded nothing ' + (H.failedOnly ? 'that failed ' : '') + 'in the period.' }));\n }\n\n // Warnings > Threat signals > Privileged access gained\n function wnPrivGained(w, _H, desc) {\n var H = tw().priv;\n var keep = el('input', { type: 'checkbox', checked: H.remember !== false, 'aria-label': 'Remember this look' });\n keep.addEventListener('change', function () { H.remember = keep.checked; });\n var extras = el('label', { style: 'display:flex;gap:6px;align-items:center', title: 'Untick to compare again with the same earlier look' }, keep, 'Remember this look for next time');\n threatNote(w);\n if (!mdRun(w, H, 'priv-gained', 'Find new privileged access', desc, extras, function () { return { remember: H.remember !== false }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.holdings, 'privileged entitlements held'), stat(T.people, 'identities holding them'), stat(d.baseline ? null : T.fresh, 'gained since the previous look'), stat(d.baseline ? null : T.outside, 'of those with no ISC record', 'lose'), stat(d.baseline ? null : T.lost, 'no longer held')));\n if (d.since) w.appendChild(el('p', { className: 'muted small', style: 'margin:-4px 0 12px', text: 'Compared with the look of ' + when16(d.since) + '. Findings of the last 90 days stay listed while the identity still holds the access.' }));\n var fresh = {}; (d.freshKeys || []).forEach(function (k) { fresh[k] = true; });\n if (d.findings && d.findings.length) w.appendChild(section('Privileged access gained', d.findings.length + (d.more || 0), filteredTable(H, d.findings, ['Found', 'Identity', 'Privileged entitlement', 'Source', 'Held', 'How it got there', 'Requested by'], function (r) {\n return [el('span', {}, r.found.slice(0, 10), fresh[r.key] ? el('div', {}, pill('new', 'gain')) : null), el('span', {}, r.person, el('div', { className: 'muted small', text: r.personState + (r.newPerson ? ' · new identity' : '') })), r.entitlement, r.source, r.via, r.how === 'No ISC record' ? pill(r.how, 'lose') : el('span', {}, r.how, r.when ? el('div', { className: 'muted small', text: when16(r.when) }) : null), r.requestedBy || ''];\n }, 'Privileged access gained')));\n else if (!d.baseline) w.appendChild(el('p', { className: 'muted', text: 'Nobody gained a privileged entitlement since the previous look.' }));\n }\n // Warnings > Threat signals > Accounts created outside ISC\n function wnOutsideAccounts(w, _H, desc) {\n var H = tw().outacct;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Appeared in the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'outside-accounts', 'Find accounts created outside ISC', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts ISC did not create'), stat(T.uncorrelated, 'owned by nobody', 'lose'), stat(T.ownerLeft, 'owner has left', 'lose'), stat(T.withAccess, 'already have access'), stat(T.provisioned, 'new accounts ISC created itself')));\n if (d.bySource.length) w.appendChild(section('Per source', d.bySource.length, simpleTable(['Source', 'New accounts not created by ISC', 'Accounts on the source', 'Note'], d.bySource.map(function (r) { return [r.source, fmtNum(r.fresh), r.total === null ? '—' : fmtNum(r.total), el('span', { className: 'muted small', text: r.note })]; }), 'Per source')));\n if (d.rows.length) w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Appeared', 'Account', 'Source', 'Owner', 'Has access', 'State', 'Signals'], function (r) {\n return [when16(r.created), el('span', {}, r.account, r.nativeIdentity && r.nativeIdentity !== r.account ? el('div', { className: 'muted small', style: 'word-break:break-all', text: r.nativeIdentity }) : null), r.source, el('span', {}, r.owner || '—', el('div', { className: 'muted small', text: r.ownerState })), r.hasEntitlements ? 'yes' : 'no', r.disabled ? 'disabled' : 'enabled', r.signals.length ? (r.signals[0] === 'Source newly connected' ? el('span', { className: 'muted small', text: r.signals[0] }) : sigList(r.signals)) : ''];\n }, 'Accounts created outside ISC')));\n else w.appendChild(el('p', { className: 'muted', text: 'No account appeared in the period that ISC did not create itself.' }));\n }\n // Warnings > Threat signals > Sensitive changes\n function wnSensitive(w, _H, desc) {\n var H = tw().sensitive;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compared with' }), numSelect(H, 'days', [[1, 'yesterday or before'], [7, 'a week ago or before'], [30, 'a month ago or before'], [90, '3 months ago or before']], 'Compared with'));\n threatNote(w);\n if (!mdRun(w, H, 'sensitive', 'Find sensitive changes', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n if (d.baseline) return;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.high, 'high', 'lose'), stat(T.medium, 'medium'), stat(T.credentials, 'new API credentials'), stat(T.areas, 'areas touched')));\n if (d.rows.length) w.appendChild(section('Changes since ' + d.from, d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Severity', 'Area', 'Object', 'Change', 'Why it matters', 'Who', 'When'], function (r) {\n return [r.severity === 'high' ? pill('high', 'lose') : 'medium', r.area, r.object, el('span', { className: 'small', style: 'word-break:break-word', text: r.change }), el('span', { className: 'muted small', text: r.why }), r.who, when16(r.when)];\n }, 'Sensitive changes')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nothing that touches a control changed since ' + d.from + '.' }));\n }\n // Warnings > Threat signals > Risk by person\n function wnRisk(w, _H, desc) {\n var H = tw().risk;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Signals of the last' }), numSelect(H, 'days', [[1, '24 hours'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period'));\n threatNote(w);\n if (!mdRun(w, H, 'risk', 'Add up the signals', desc, extras, function () { return { days: H.days }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.people, 'identities with a signal'), stat(T.several, 'on more than one screen', 'lose'), stat(T.signals, 'signals in all')));\n if (d.rows.length) w.appendChild(section('Identities, highest first', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Identity', 'Score', 'Screens', 'Signals'], function (r) {\n return [r.person, r.screens > 1 ? pill(String(r.score), 'lose') : String(r.score), String(r.screens), el('div', {}, r.signals.map(function (s) { return el('div', { className: 'small', text: s }); }))];\n }, 'Risk by identity')));\n else w.appendChild(el('p', { className: 'muted', text: 'No identity has a signal in the period.' }));\n }\n // Warnings > Joiners, movers, leavers > Coming up\n function wnUpcoming(w, _H, desc) {\n var H = tw().upcoming;\n var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.country:US', style: 'max-width:220px', 'aria-label': 'Only identities matching (search query, optional)' });\n q.addEventListener('input', function () { H.query = q.value; });\n var extras = el('div', { className: 'bar' },\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Next' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days'], [90, '90 days']], 'Period')),\n attrInput(H, 'startDateAttribute', 'Start-date attribute', 'startDate'), attrInput(H, 'endDateAttribute', 'End-date attribute', 'endDate'),\n el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only identities matching (optional)' }), q));\n if (!mdRun(w, H, 'jml-preview', 'Show who is coming up', desc, extras, function () { return { days: H.days, startDateAttribute: H.startDateAttribute || undefined, endDateAttribute: H.endDateAttribute || undefined, query: H.query || undefined }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.starts, 'start in the period'), stat(T.ends, 'end in the period'), stat(T.findings, 'with something to check', 'lose'), stat(T.checked, 'identities read')));\n var busy = d.perDay.filter(function (p) { return p.starts || p.ends; });\n if (busy.length) w.appendChild(section('Per day', busy.length, simpleTable(['Day', 'Start', 'End'], busy.map(function (p) { return [p.day, p.starts ? fmtNum(p.starts) : '', p.ends ? fmtNum(p.ends) : '']; }), 'Per day')));\n if (d.rows.length) w.appendChild(section('Identities', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Date', 'Kind', 'Identity', 'Manager', 'Identity profile', 'Lifecycle state now', 'Accounts', 'Access', 'To check'], function (r) {\n return [el('span', {}, r.date, el('div', { className: 'muted small', text: daysText(r.inDays) })), pill(r.kind, r.kind === 'Ends' ? 'lose' : 'gain'), el('span', {}, r.person, r.email ? el('div', { className: 'muted small', text: r.email }) : null), r.manager || '', r.profile, el('span', {}, r.lifecycle, r.stateNow ? el('div', { className: 'muted small', text: r.stateNow }) : null), r.accounts === null ? '' : fmtNum(r.accounts), r.access === null ? '' : fmtNum(r.access), r.findings.length ? sigList(r.findings) : ''];\n }, 'Joiners and leavers coming up')));\n else w.appendChild(el('p', { className: 'muted', text: 'Nobody has a start or end date in the period.' }));\n if (d.states.length) w.appendChild(section('What the lifecycle states of these identity profiles do', d.states.length, simpleTable(['Identity profile', 'Lifecycle state', 'Kind', 'Accounts', 'Removes all access', 'Findings'], d.states.map(function (s) {\n return [s.profile, el('span', {}, s.state, s.enabled ? null : el('span', { className: 'muted small', text: ' (off)' })), s.kind === 'leaver' ? 'leaver state' : 'active state', el('span', { className: 'small', text: s.accounts }), s.removesAccess ? 'yes' : 'no', s.findings.length ? sigList(s.findings) : ''];\n }), 'Lifecycle states')));\n }\n // Warnings > Requests and reviews > Stuck requests\n function wnStuckReq(w, _H, desc) {\n var H = tw().stuckreq;\n var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Running for more than' }), numSelect(H, 'hours', [[4, '4 hours'], [24, '1 day'], [72, '3 days'], [168, '7 days'], [720, '30 days']], 'Running for more than'));\n if (!mdRun(w, H, 'stuck-requests', 'Find stuck requests', desc, extras, function () { return { hours: H.hours }; }, renderWarnings)) return;\n var d = H.data, T = d.totals;\n w.appendChild(el('div', { className: 'bigstats' }, stat(T.running, 'requests still running'), stat(T.stuck, 'longer than the limit', 'lose'), stat(T.approval, 'waiting in approval'), stat(T.provisioning, 'waiting in provisioning'), stat(T.churningSources, 'sources ISC keeps re-sending to', 'lose')));\n if (d.byPhase.length) w.appendChild(section('Where they wait', d.byPhase.length, simpleTable(['Phase', 'Requests', 'Oldest'], d.byPhase.map(function (p) { return [p.phase, fmtNum(p.requests), hrs(p.oldestHours)]; }), 'Where they wait')));\n if (d.churn.length) w.appendChild(section('Sources ISC keeps sending the same change to (last 2 days)', d.churn.length, simpleTable(['Source', 'Repeated changes', 'Identities', 'Example'], d.churn.map(function (c) { return [c.source, pill(fmtNum(c.changes), 'lose'), fmtNum(c.people), el('span', { className: 'small', text: c.example })]; }), 'Churning sources')));\n if (d.rows.length) w.appendChild(section('Stuck requests', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Submitted', 'Running', 'Access', 'Requested for', 'Phase', 'Waiting on', 'Why'], function (r) {\n return [when16(r.submitted), hrs(r.hours), el('span', {}, r.access, el('div', { className: 'muted small', text: r.type })), el('span', {}, r.requestedFor, r.requestedBy && r.requestedBy !== r.requestedFor ? el('div', { className: 'muted small', text: 'by ' + r.requestedBy }) : null), el('span', {}, r.phase, r.phaseHours === null ? null : el('div', { className: 'muted small', text: 'for ' + hrs(r.phaseHours) })), r.waitingOn, el('span', {}, r.reason, r.errors ? el('div', { className: 'small', style: 'color:var(--danger)', text: r.errors }) : null)];\n }, 'Stuck requests')));\n else w.appendChild(el('p', { className: 'muted', text: 'No request has been running that long.' }));\n }\n})();\n</script>\n</body>\n</html>\n";
3
3
  //# sourceMappingURL=ui-page.js.map