import Foundation extension RDEPUBParser { public func readingProfile() -> RDEPUBReadingProfile { if metadata.layout == .fixed { return .webFixedLayout } return hasInteractiveContent() ? .webInteractive : .textReflowable } public func hasInteractiveContent() -> Bool { let interactiveMediaTypes = [ "application/javascript", "text/javascript", "application/ecmascript" ] if manifest.values.contains(where: { item in interactiveMediaTypes.contains(item.mediaType.lowercased()) || item.properties.contains("scripted") }) { return true } let interactivePattern = #"<(script|iframe|video|audio|canvas|svg|form)\b|\bon(load|click|touchstart|touchend|mouseover)=|hype_generated_script|swiper|webview"# for item in spine where item.linear && (item.mediaType.contains("html") || item.mediaType.contains("xhtml")) { guard let html = htmlString(forRelativePath: item.href) else { continue } if html.range(of: interactivePattern, options: [.regularExpression, .caseInsensitive]) != nil { return true } } return false } }