
# Accessibility categories (highest match wins): # "Inline machine-readable structured data" # "Structured reporting format" # "Combined static formats" # "Structured tabular format" # "Text-based static format" # "Image-based static format" # "No disclosure" getAccessibilityCategory = (report_formats) -> formats = (report_formats ? []).map (s) -> ("" + s).trim().toLowerCase() # Normalize into a set of canonical flags has = pdfImage: false pdfText: false webHtml: false sheet: false xbrlStandalone:false xbrlInline: false noReport: false for f in formats if /no report available/.test f then has.noReport = true else if /pdf.*image/.test f then has.pdfImage = true else if /^pdf|pdf.*text|text.*pdf/.test f then has.pdfText = true else if /web.*html|^html$|^xhtml$/.test f then has.webHtml = true else if /spreadsheet|excel|xlsx|csv/.test f then has.sheet = true else if /(inline|ixbrl).*xbrl|^ixbrl$|inline xbrl|xhtml.*xbrl/.test f then has.xbrlInline = true else if /standalone.*xbrl|^xbrl$/.test f and not /(inline|ixbrl)/.test f then has.xbrlStandalone = true # Helper booleans hasDoc = has.pdfText or has.webHtml hasAny = has.pdfImage or has.pdfText or has.webHtml or has.sheet or has.xbrlStandalone or has.xbrlInline onlyOne = (Object.values(has).filter((v) -> v).length is 1) # Level 6: Inline XBRL present return "Inline machine-readable structured data" if has.xbrlInline # Level 5: Standalone XBRL + (PDF text OR Web HTML) return "Structured reporting format" if has.xbrlStandalone and hasDoc # Level 4: (PDF text AND Web HTML) OR ((PDF text OR Web HTML) AND Spreadsheet) return "Combined static formats" if (has.pdfText and has.webHtml) or (hasDoc and has.sheet) # Level 3: Spreadsheet return "Structured tabular format" if has.sheet # Level 2: PDF (text) OR Web HTML return "Text-based static format" if hasDoc # Level 1: ONLY PDF (image) return "Image-based static format" if has.pdfImage and onlyOne # Level 0: ONLY "No report available" (or empty input) return "No disclosure" if (has.noReport and onlyOne) or not hasAny getAccessibilityCategory(report_formats)