import { BKDRHash } from './utils' ; export class AribSubtitleRegion { public text : string ; public fontColor : number ; public fontAlpha : number ; public backColor : number ; public backAlpha : number ; public width : number ; public height : number ; public fontWidth : number ; public fontHeight : number ; public verticalInterval : number ; public horizontalInterval : number ; public charLeft : number ; public charBottom : number ; } export class AribSubtitle { public text : string ; public pts : number ; public duration : number ; public planeWidth : number ; public planeHeight : number ; public regions : AribSubtitleRegion [ ] ; public hashCode ( ) { return this . pts ^ BKDRHash ( this . text ) ; } public rubylessText ( ) { let furiganas = new Map ( ) ; let start = 0 ; for ( let region of this . regions ) { if ( region . fontHeight === 18 && region . fontWidth === 18 ) { furiganas . set ( start , region . text . length ) ; } start += region . text . length ; } if ( furiganas . size === 0 ) { return this . text ; } let text = '' ; for ( let i = 0 ; i < this . text . length ; ) { let length = furiganas . get ( i ) ; if ( length !== undefined ) { i += length ; } else { text += this . text . charAt ( i ) ; i ++ ; } } return text ; } }