pdf.worker.js 1.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = root.pdfjsWorker = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf.worker", [], () => { return (root.pdfjsWorker = factory()); });
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf.worker"] = root.pdfjsWorker = factory();
  29. else
  30. root["pdfjs-dist/build/pdf.worker"] = root.pdfjsWorker = factory();
  31. })(globalThis, () => {
  32. return /******/ (() => { // webpackBootstrap
  33. /******/ "use strict";
  34. /******/ var __webpack_modules__ = ([
  35. /* 0 */,
  36. /* 1 */
  37. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38. Object.defineProperty(exports, "__esModule", ({
  39. value: true
  40. }));
  41. exports.WorkerTask = exports.WorkerMessageHandler = void 0;
  42. var _util = __w_pdfjs_require__(2);
  43. var _core_utils = __w_pdfjs_require__(3);
  44. var _primitives = __w_pdfjs_require__(4);
  45. var _pdf_manager = __w_pdfjs_require__(6);
  46. var _annotation = __w_pdfjs_require__(10);
  47. var _cleanup_helper = __w_pdfjs_require__(72);
  48. var _writer = __w_pdfjs_require__(66);
  49. var _message_handler = __w_pdfjs_require__(104);
  50. var _worker_stream = __w_pdfjs_require__(105);
  51. class WorkerTask {
  52. constructor(name) {
  53. this.name = name;
  54. this.terminated = false;
  55. this._capability = new _util.PromiseCapability();
  56. }
  57. get finished() {
  58. return this._capability.promise;
  59. }
  60. finish() {
  61. this._capability.resolve();
  62. }
  63. terminate() {
  64. this.terminated = true;
  65. }
  66. ensureNotTerminated() {
  67. if (this.terminated) {
  68. throw new Error("Worker task was terminated");
  69. }
  70. }
  71. }
  72. exports.WorkerTask = WorkerTask;
  73. class WorkerMessageHandler {
  74. static setup(handler, port) {
  75. let testMessageProcessed = false;
  76. handler.on("test", function (data) {
  77. if (testMessageProcessed) {
  78. return;
  79. }
  80. testMessageProcessed = true;
  81. handler.send("test", data instanceof Uint8Array);
  82. });
  83. handler.on("configure", function (data) {
  84. (0, _util.setVerbosityLevel)(data.verbosity);
  85. });
  86. handler.on("GetDocRequest", function (data) {
  87. return WorkerMessageHandler.createDocumentHandler(data, port);
  88. });
  89. }
  90. static createDocumentHandler(docParams, port) {
  91. let pdfManager;
  92. let terminated = false;
  93. let cancelXHRs = null;
  94. const WorkerTasks = new Set();
  95. const verbosity = (0, _util.getVerbosityLevel)();
  96. const {
  97. docId,
  98. apiVersion
  99. } = docParams;
  100. const workerVersion = '3.10.111';
  101. if (apiVersion !== workerVersion) {
  102. throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
  103. }
  104. const enumerableProperties = [];
  105. for (const property in []) {
  106. enumerableProperties.push(property);
  107. }
  108. if (enumerableProperties.length) {
  109. throw new Error("The `Array.prototype` contains unexpected enumerable properties: " + enumerableProperties.join(", ") + "; thus breaking e.g. `for...in` iteration of `Array`s.");
  110. }
  111. const workerHandlerName = docId + "_worker";
  112. let handler = new _message_handler.MessageHandler(workerHandlerName, docId, port);
  113. function ensureNotTerminated() {
  114. if (terminated) {
  115. throw new Error("Worker was terminated");
  116. }
  117. }
  118. function startWorkerTask(task) {
  119. WorkerTasks.add(task);
  120. }
  121. function finishWorkerTask(task) {
  122. task.finish();
  123. WorkerTasks.delete(task);
  124. }
  125. async function loadDocument(recoveryMode) {
  126. await pdfManager.ensureDoc("checkHeader");
  127. await pdfManager.ensureDoc("parseStartXRef");
  128. await pdfManager.ensureDoc("parse", [recoveryMode]);
  129. await pdfManager.ensureDoc("checkFirstPage", [recoveryMode]);
  130. await pdfManager.ensureDoc("checkLastPage", [recoveryMode]);
  131. const isPureXfa = await pdfManager.ensureDoc("isPureXfa");
  132. if (isPureXfa) {
  133. const task = new WorkerTask("loadXfaFonts");
  134. startWorkerTask(task);
  135. await Promise.all([pdfManager.loadXfaFonts(handler, task).catch(reason => {}).then(() => finishWorkerTask(task)), pdfManager.loadXfaImages()]);
  136. }
  137. const [numPages, fingerprints] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprints")]);
  138. const htmlForXfa = isPureXfa ? await pdfManager.ensureDoc("htmlForXfa") : null;
  139. return {
  140. numPages,
  141. fingerprints,
  142. htmlForXfa
  143. };
  144. }
  145. function getPdfManager({
  146. data,
  147. password,
  148. disableAutoFetch,
  149. rangeChunkSize,
  150. length,
  151. docBaseUrl,
  152. enableXfa,
  153. evaluatorOptions
  154. }) {
  155. const pdfManagerArgs = {
  156. source: null,
  157. disableAutoFetch,
  158. docBaseUrl,
  159. docId,
  160. enableXfa,
  161. evaluatorOptions,
  162. handler,
  163. length,
  164. password,
  165. rangeChunkSize
  166. };
  167. const pdfManagerCapability = new _util.PromiseCapability();
  168. let newPdfManager;
  169. if (data) {
  170. try {
  171. pdfManagerArgs.source = data;
  172. newPdfManager = new _pdf_manager.LocalPdfManager(pdfManagerArgs);
  173. pdfManagerCapability.resolve(newPdfManager);
  174. } catch (ex) {
  175. pdfManagerCapability.reject(ex);
  176. }
  177. return pdfManagerCapability.promise;
  178. }
  179. let pdfStream,
  180. cachedChunks = [];
  181. try {
  182. pdfStream = new _worker_stream.PDFWorkerStream(handler);
  183. } catch (ex) {
  184. pdfManagerCapability.reject(ex);
  185. return pdfManagerCapability.promise;
  186. }
  187. const fullRequest = pdfStream.getFullReader();
  188. fullRequest.headersReady.then(function () {
  189. if (!fullRequest.isRangeSupported) {
  190. return;
  191. }
  192. pdfManagerArgs.source = pdfStream;
  193. pdfManagerArgs.length = fullRequest.contentLength;
  194. pdfManagerArgs.disableAutoFetch ||= fullRequest.isStreamingSupported;
  195. newPdfManager = new _pdf_manager.NetworkPdfManager(pdfManagerArgs);
  196. for (const chunk of cachedChunks) {
  197. newPdfManager.sendProgressiveData(chunk);
  198. }
  199. cachedChunks = [];
  200. pdfManagerCapability.resolve(newPdfManager);
  201. cancelXHRs = null;
  202. }).catch(function (reason) {
  203. pdfManagerCapability.reject(reason);
  204. cancelXHRs = null;
  205. });
  206. let loaded = 0;
  207. const flushChunks = function () {
  208. const pdfFile = (0, _core_utils.arrayBuffersToBytes)(cachedChunks);
  209. if (length && pdfFile.length !== length) {
  210. (0, _util.warn)("reported HTTP length is different from actual");
  211. }
  212. try {
  213. pdfManagerArgs.source = pdfFile;
  214. newPdfManager = new _pdf_manager.LocalPdfManager(pdfManagerArgs);
  215. pdfManagerCapability.resolve(newPdfManager);
  216. } catch (ex) {
  217. pdfManagerCapability.reject(ex);
  218. }
  219. cachedChunks = [];
  220. };
  221. new Promise(function (resolve, reject) {
  222. const readChunk = function ({
  223. value,
  224. done
  225. }) {
  226. try {
  227. ensureNotTerminated();
  228. if (done) {
  229. if (!newPdfManager) {
  230. flushChunks();
  231. }
  232. cancelXHRs = null;
  233. return;
  234. }
  235. loaded += value.byteLength;
  236. if (!fullRequest.isStreamingSupported) {
  237. handler.send("DocProgress", {
  238. loaded,
  239. total: Math.max(loaded, fullRequest.contentLength || 0)
  240. });
  241. }
  242. if (newPdfManager) {
  243. newPdfManager.sendProgressiveData(value);
  244. } else {
  245. cachedChunks.push(value);
  246. }
  247. fullRequest.read().then(readChunk, reject);
  248. } catch (e) {
  249. reject(e);
  250. }
  251. };
  252. fullRequest.read().then(readChunk, reject);
  253. }).catch(function (e) {
  254. pdfManagerCapability.reject(e);
  255. cancelXHRs = null;
  256. });
  257. cancelXHRs = function (reason) {
  258. pdfStream.cancelAllRequests(reason);
  259. };
  260. return pdfManagerCapability.promise;
  261. }
  262. function setupDoc(data) {
  263. function onSuccess(doc) {
  264. ensureNotTerminated();
  265. handler.send("GetDoc", {
  266. pdfInfo: doc
  267. });
  268. }
  269. function onFailure(ex) {
  270. ensureNotTerminated();
  271. if (ex instanceof _util.PasswordException) {
  272. const task = new WorkerTask(`PasswordException: response ${ex.code}`);
  273. startWorkerTask(task);
  274. handler.sendWithPromise("PasswordRequest", ex).then(function ({
  275. password
  276. }) {
  277. finishWorkerTask(task);
  278. pdfManager.updatePassword(password);
  279. pdfManagerReady();
  280. }).catch(function () {
  281. finishWorkerTask(task);
  282. handler.send("DocException", ex);
  283. });
  284. } else if (ex instanceof _util.InvalidPDFException || ex instanceof _util.MissingPDFException || ex instanceof _util.UnexpectedResponseException || ex instanceof _util.UnknownErrorException) {
  285. handler.send("DocException", ex);
  286. } else {
  287. handler.send("DocException", new _util.UnknownErrorException(ex.message, ex.toString()));
  288. }
  289. }
  290. function pdfManagerReady() {
  291. ensureNotTerminated();
  292. loadDocument(false).then(onSuccess, function (reason) {
  293. ensureNotTerminated();
  294. if (!(reason instanceof _core_utils.XRefParseException)) {
  295. onFailure(reason);
  296. return;
  297. }
  298. pdfManager.requestLoadedStream().then(function () {
  299. ensureNotTerminated();
  300. loadDocument(true).then(onSuccess, onFailure);
  301. });
  302. });
  303. }
  304. ensureNotTerminated();
  305. getPdfManager(data).then(function (newPdfManager) {
  306. if (terminated) {
  307. newPdfManager.terminate(new _util.AbortException("Worker was terminated."));
  308. throw new Error("Worker was terminated");
  309. }
  310. pdfManager = newPdfManager;
  311. pdfManager.requestLoadedStream(true).then(stream => {
  312. handler.send("DataLoaded", {
  313. length: stream.bytes.byteLength
  314. });
  315. });
  316. }).then(pdfManagerReady, onFailure);
  317. }
  318. handler.on("GetPage", function (data) {
  319. return pdfManager.getPage(data.pageIndex).then(function (page) {
  320. return Promise.all([pdfManager.ensure(page, "rotate"), pdfManager.ensure(page, "ref"), pdfManager.ensure(page, "userUnit"), pdfManager.ensure(page, "view")]).then(function ([rotate, ref, userUnit, view]) {
  321. return {
  322. rotate,
  323. ref,
  324. userUnit,
  325. view
  326. };
  327. });
  328. });
  329. });
  330. handler.on("GetPageIndex", function (data) {
  331. const pageRef = _primitives.Ref.get(data.num, data.gen);
  332. return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
  333. });
  334. handler.on("GetDestinations", function (data) {
  335. return pdfManager.ensureCatalog("destinations");
  336. });
  337. handler.on("GetDestination", function (data) {
  338. return pdfManager.ensureCatalog("getDestination", [data.id]);
  339. });
  340. handler.on("GetPageLabels", function (data) {
  341. return pdfManager.ensureCatalog("pageLabels");
  342. });
  343. handler.on("GetPageLayout", function (data) {
  344. return pdfManager.ensureCatalog("pageLayout");
  345. });
  346. handler.on("GetPageMode", function (data) {
  347. return pdfManager.ensureCatalog("pageMode");
  348. });
  349. handler.on("GetViewerPreferences", function (data) {
  350. return pdfManager.ensureCatalog("viewerPreferences");
  351. });
  352. handler.on("GetOpenAction", function (data) {
  353. return pdfManager.ensureCatalog("openAction");
  354. });
  355. handler.on("GetAttachments", function (data) {
  356. return pdfManager.ensureCatalog("attachments");
  357. });
  358. handler.on("GetDocJSActions", function (data) {
  359. return pdfManager.ensureCatalog("jsActions");
  360. });
  361. handler.on("GetPageJSActions", function ({
  362. pageIndex
  363. }) {
  364. return pdfManager.getPage(pageIndex).then(function (page) {
  365. return pdfManager.ensure(page, "jsActions");
  366. });
  367. });
  368. handler.on("GetOutline", function (data) {
  369. return pdfManager.ensureCatalog("documentOutline");
  370. });
  371. handler.on("GetOptionalContentConfig", function (data) {
  372. return pdfManager.ensureCatalog("optionalContentConfig");
  373. });
  374. handler.on("GetPermissions", function (data) {
  375. return pdfManager.ensureCatalog("permissions");
  376. });
  377. handler.on("GetMetadata", function (data) {
  378. return Promise.all([pdfManager.ensureDoc("documentInfo"), pdfManager.ensureCatalog("metadata")]);
  379. });
  380. handler.on("GetMarkInfo", function (data) {
  381. return pdfManager.ensureCatalog("markInfo");
  382. });
  383. handler.on("GetData", function (data) {
  384. return pdfManager.requestLoadedStream().then(function (stream) {
  385. return stream.bytes;
  386. });
  387. });
  388. handler.on("GetAnnotations", function ({
  389. pageIndex,
  390. intent
  391. }) {
  392. return pdfManager.getPage(pageIndex).then(function (page) {
  393. const task = new WorkerTask(`GetAnnotations: page ${pageIndex}`);
  394. startWorkerTask(task);
  395. return page.getAnnotationsData(handler, task, intent).then(data => {
  396. finishWorkerTask(task);
  397. return data;
  398. }, reason => {
  399. finishWorkerTask(task);
  400. throw reason;
  401. });
  402. });
  403. });
  404. handler.on("GetFieldObjects", function (data) {
  405. return pdfManager.ensureDoc("fieldObjects");
  406. });
  407. handler.on("HasJSActions", function (data) {
  408. return pdfManager.ensureDoc("hasJSActions");
  409. });
  410. handler.on("GetCalculationOrderIds", function (data) {
  411. return pdfManager.ensureDoc("calculationOrderIds");
  412. });
  413. handler.on("SaveDocument", async function ({
  414. isPureXfa,
  415. numPages,
  416. annotationStorage,
  417. filename
  418. }) {
  419. const promises = [pdfManager.requestLoadedStream(), pdfManager.ensureCatalog("acroForm"), pdfManager.ensureCatalog("acroFormRef"), pdfManager.ensureDoc("startXRef"), pdfManager.ensureDoc("linearization")];
  420. const newAnnotationsByPage = !isPureXfa ? (0, _core_utils.getNewAnnotationsMap)(annotationStorage) : null;
  421. const xref = await pdfManager.ensureDoc("xref");
  422. if (newAnnotationsByPage) {
  423. const imagePromises = _annotation.AnnotationFactory.generateImages(annotationStorage.values(), xref, pdfManager.evaluatorOptions.isOffscreenCanvasSupported);
  424. for (const [pageIndex, annotations] of newAnnotationsByPage) {
  425. promises.push(pdfManager.getPage(pageIndex).then(page => {
  426. const task = new WorkerTask(`Save (editor): page ${pageIndex}`);
  427. return page.saveNewAnnotations(handler, task, annotations, imagePromises).finally(function () {
  428. finishWorkerTask(task);
  429. });
  430. }));
  431. }
  432. }
  433. if (isPureXfa) {
  434. promises.push(pdfManager.serializeXfaData(annotationStorage));
  435. } else {
  436. for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
  437. promises.push(pdfManager.getPage(pageIndex).then(function (page) {
  438. const task = new WorkerTask(`Save: page ${pageIndex}`);
  439. return page.save(handler, task, annotationStorage).finally(function () {
  440. finishWorkerTask(task);
  441. });
  442. }));
  443. }
  444. }
  445. return Promise.all(promises).then(function ([stream, acroForm, acroFormRef, startXRef, linearization, ...refs]) {
  446. let newRefs = [];
  447. let xfaData = null;
  448. if (isPureXfa) {
  449. xfaData = refs[0];
  450. if (!xfaData) {
  451. return stream.bytes;
  452. }
  453. } else {
  454. newRefs = refs.flat(2);
  455. if (newRefs.length === 0) {
  456. return stream.bytes;
  457. }
  458. }
  459. const needAppearances = acroFormRef && acroForm instanceof _primitives.Dict && newRefs.some(ref => ref.needAppearances);
  460. const xfa = acroForm instanceof _primitives.Dict && acroForm.get("XFA") || null;
  461. let xfaDatasetsRef = null;
  462. let hasXfaDatasetsEntry = false;
  463. if (Array.isArray(xfa)) {
  464. for (let i = 0, ii = xfa.length; i < ii; i += 2) {
  465. if (xfa[i] === "datasets") {
  466. xfaDatasetsRef = xfa[i + 1];
  467. hasXfaDatasetsEntry = true;
  468. }
  469. }
  470. if (xfaDatasetsRef === null) {
  471. xfaDatasetsRef = xref.getNewTemporaryRef();
  472. }
  473. } else if (xfa) {
  474. (0, _util.warn)("Unsupported XFA type.");
  475. }
  476. let newXrefInfo = Object.create(null);
  477. if (xref.trailer) {
  478. const infoObj = Object.create(null);
  479. const xrefInfo = xref.trailer.get("Info") || null;
  480. if (xrefInfo instanceof _primitives.Dict) {
  481. xrefInfo.forEach((key, value) => {
  482. if (typeof value === "string") {
  483. infoObj[key] = (0, _util.stringToPDFString)(value);
  484. }
  485. });
  486. }
  487. newXrefInfo = {
  488. rootRef: xref.trailer.getRaw("Root") || null,
  489. encryptRef: xref.trailer.getRaw("Encrypt") || null,
  490. newRef: xref.getNewTemporaryRef(),
  491. infoRef: xref.trailer.getRaw("Info") || null,
  492. info: infoObj,
  493. fileIds: xref.trailer.get("ID") || null,
  494. startXRef: linearization ? startXRef : xref.lastXRefStreamPos ?? startXRef,
  495. filename
  496. };
  497. }
  498. return (0, _writer.incrementalUpdate)({
  499. originalData: stream.bytes,
  500. xrefInfo: newXrefInfo,
  501. newRefs,
  502. xref,
  503. hasXfa: !!xfa,
  504. xfaDatasetsRef,
  505. hasXfaDatasetsEntry,
  506. needAppearances,
  507. acroFormRef,
  508. acroForm,
  509. xfaData
  510. }).finally(() => {
  511. xref.resetNewTemporaryRef();
  512. });
  513. });
  514. });
  515. handler.on("GetOperatorList", function (data, sink) {
  516. const pageIndex = data.pageIndex;
  517. pdfManager.getPage(pageIndex).then(function (page) {
  518. const task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
  519. startWorkerTask(task);
  520. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  521. page.getOperatorList({
  522. handler,
  523. sink,
  524. task,
  525. intent: data.intent,
  526. cacheKey: data.cacheKey,
  527. annotationStorage: data.annotationStorage
  528. }).then(function (operatorListInfo) {
  529. finishWorkerTask(task);
  530. if (start) {
  531. (0, _util.info)(`page=${pageIndex + 1} - getOperatorList: time=` + `${Date.now() - start}ms, len=${operatorListInfo.length}`);
  532. }
  533. sink.close();
  534. }, function (reason) {
  535. finishWorkerTask(task);
  536. if (task.terminated) {
  537. return;
  538. }
  539. sink.error(reason);
  540. });
  541. });
  542. });
  543. handler.on("GetTextContent", function (data, sink) {
  544. const {
  545. pageIndex,
  546. includeMarkedContent,
  547. disableNormalization
  548. } = data;
  549. pdfManager.getPage(pageIndex).then(function (page) {
  550. const task = new WorkerTask("GetTextContent: page " + pageIndex);
  551. startWorkerTask(task);
  552. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  553. page.extractTextContent({
  554. handler,
  555. task,
  556. sink,
  557. includeMarkedContent,
  558. disableNormalization
  559. }).then(function () {
  560. finishWorkerTask(task);
  561. if (start) {
  562. (0, _util.info)(`page=${pageIndex + 1} - getTextContent: time=` + `${Date.now() - start}ms`);
  563. }
  564. sink.close();
  565. }, function (reason) {
  566. finishWorkerTask(task);
  567. if (task.terminated) {
  568. return;
  569. }
  570. sink.error(reason);
  571. });
  572. });
  573. });
  574. handler.on("GetStructTree", function (data) {
  575. return pdfManager.getPage(data.pageIndex).then(function (page) {
  576. return pdfManager.ensure(page, "getStructTree");
  577. });
  578. });
  579. handler.on("FontFallback", function (data) {
  580. return pdfManager.fontFallback(data.id, handler);
  581. });
  582. handler.on("Cleanup", function (data) {
  583. return pdfManager.cleanup(true);
  584. });
  585. handler.on("Terminate", function (data) {
  586. terminated = true;
  587. const waitOn = [];
  588. if (pdfManager) {
  589. pdfManager.terminate(new _util.AbortException("Worker was terminated."));
  590. const cleanupPromise = pdfManager.cleanup();
  591. waitOn.push(cleanupPromise);
  592. pdfManager = null;
  593. } else {
  594. (0, _cleanup_helper.clearGlobalCaches)();
  595. }
  596. if (cancelXHRs) {
  597. cancelXHRs(new _util.AbortException("Worker was terminated."));
  598. }
  599. for (const task of WorkerTasks) {
  600. waitOn.push(task.finished);
  601. task.terminate();
  602. }
  603. return Promise.all(waitOn).then(function () {
  604. handler.destroy();
  605. handler = null;
  606. });
  607. });
  608. handler.on("Ready", function (data) {
  609. setupDoc(docParams);
  610. docParams = null;
  611. });
  612. return workerHandlerName;
  613. }
  614. static initializeFromPort(port) {
  615. const handler = new _message_handler.MessageHandler("worker", "main", port);
  616. WorkerMessageHandler.setup(handler, port);
  617. handler.send("ready", null);
  618. }
  619. }
  620. exports.WorkerMessageHandler = WorkerMessageHandler;
  621. function isMessagePort(maybePort) {
  622. return typeof maybePort.postMessage === "function" && "onmessage" in maybePort;
  623. }
  624. if (typeof window === "undefined" && !_util.isNodeJS && typeof self !== "undefined" && isMessagePort(self)) {
  625. WorkerMessageHandler.initializeFromPort(self);
  626. }
  627. /***/ }),
  628. /* 2 */
  629. /***/ ((__unused_webpack_module, exports) => {
  630. Object.defineProperty(exports, "__esModule", ({
  631. value: true
  632. }));
  633. exports.VerbosityLevel = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.RenderingIntentFlag = exports.PromiseCapability = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.MAX_IMAGE_SIZE_TO_CACHE = exports.LINE_FACTOR = exports.LINE_DESCENT_FACTOR = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FeatureTest = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.CMapCompressionType = exports.BaseException = exports.BASELINE_FACTOR = exports.AnnotationType = exports.AnnotationReplyType = exports.AnnotationMode = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationEditorType = exports.AnnotationEditorPrefix = exports.AnnotationEditorParamsType = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
  634. exports.assert = assert;
  635. exports.bytesToString = bytesToString;
  636. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  637. exports.getModificationDate = getModificationDate;
  638. exports.getUuid = getUuid;
  639. exports.getVerbosityLevel = getVerbosityLevel;
  640. exports.info = info;
  641. exports.isArrayBuffer = isArrayBuffer;
  642. exports.isArrayEqual = isArrayEqual;
  643. exports.isNodeJS = void 0;
  644. exports.normalizeUnicode = normalizeUnicode;
  645. exports.objectFromMap = objectFromMap;
  646. exports.objectSize = objectSize;
  647. exports.setVerbosityLevel = setVerbosityLevel;
  648. exports.shadow = shadow;
  649. exports.string32 = string32;
  650. exports.stringToBytes = stringToBytes;
  651. exports.stringToPDFString = stringToPDFString;
  652. exports.stringToUTF8String = stringToUTF8String;
  653. exports.unreachable = unreachable;
  654. exports.utf8StringToString = utf8StringToString;
  655. exports.warn = warn;
  656. const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  657. exports.isNodeJS = isNodeJS;
  658. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  659. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  660. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  661. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  662. const MAX_IMAGE_SIZE_TO_CACHE = 10e6;
  663. exports.MAX_IMAGE_SIZE_TO_CACHE = MAX_IMAGE_SIZE_TO_CACHE;
  664. const LINE_FACTOR = 1.35;
  665. exports.LINE_FACTOR = LINE_FACTOR;
  666. const LINE_DESCENT_FACTOR = 0.35;
  667. exports.LINE_DESCENT_FACTOR = LINE_DESCENT_FACTOR;
  668. const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
  669. exports.BASELINE_FACTOR = BASELINE_FACTOR;
  670. const RenderingIntentFlag = {
  671. ANY: 0x01,
  672. DISPLAY: 0x02,
  673. PRINT: 0x04,
  674. SAVE: 0x08,
  675. ANNOTATIONS_FORMS: 0x10,
  676. ANNOTATIONS_STORAGE: 0x20,
  677. ANNOTATIONS_DISABLE: 0x40,
  678. OPLIST: 0x100
  679. };
  680. exports.RenderingIntentFlag = RenderingIntentFlag;
  681. const AnnotationMode = {
  682. DISABLE: 0,
  683. ENABLE: 1,
  684. ENABLE_FORMS: 2,
  685. ENABLE_STORAGE: 3
  686. };
  687. exports.AnnotationMode = AnnotationMode;
  688. const AnnotationEditorPrefix = "pdfjs_internal_editor_";
  689. exports.AnnotationEditorPrefix = AnnotationEditorPrefix;
  690. const AnnotationEditorType = {
  691. DISABLE: -1,
  692. NONE: 0,
  693. FREETEXT: 3,
  694. STAMP: 13,
  695. INK: 15
  696. };
  697. exports.AnnotationEditorType = AnnotationEditorType;
  698. const AnnotationEditorParamsType = {
  699. RESIZE: 1,
  700. CREATE: 2,
  701. FREETEXT_SIZE: 11,
  702. FREETEXT_COLOR: 12,
  703. FREETEXT_OPACITY: 13,
  704. INK_COLOR: 21,
  705. INK_THICKNESS: 22,
  706. INK_OPACITY: 23
  707. };
  708. exports.AnnotationEditorParamsType = AnnotationEditorParamsType;
  709. const PermissionFlag = {
  710. PRINT: 0x04,
  711. MODIFY_CONTENTS: 0x08,
  712. COPY: 0x10,
  713. MODIFY_ANNOTATIONS: 0x20,
  714. FILL_INTERACTIVE_FORMS: 0x100,
  715. COPY_FOR_ACCESSIBILITY: 0x200,
  716. ASSEMBLE: 0x400,
  717. PRINT_HIGH_QUALITY: 0x800
  718. };
  719. exports.PermissionFlag = PermissionFlag;
  720. const TextRenderingMode = {
  721. FILL: 0,
  722. STROKE: 1,
  723. FILL_STROKE: 2,
  724. INVISIBLE: 3,
  725. FILL_ADD_TO_PATH: 4,
  726. STROKE_ADD_TO_PATH: 5,
  727. FILL_STROKE_ADD_TO_PATH: 6,
  728. ADD_TO_PATH: 7,
  729. FILL_STROKE_MASK: 3,
  730. ADD_TO_PATH_FLAG: 4
  731. };
  732. exports.TextRenderingMode = TextRenderingMode;
  733. const ImageKind = {
  734. GRAYSCALE_1BPP: 1,
  735. RGB_24BPP: 2,
  736. RGBA_32BPP: 3
  737. };
  738. exports.ImageKind = ImageKind;
  739. const AnnotationType = {
  740. TEXT: 1,
  741. LINK: 2,
  742. FREETEXT: 3,
  743. LINE: 4,
  744. SQUARE: 5,
  745. CIRCLE: 6,
  746. POLYGON: 7,
  747. POLYLINE: 8,
  748. HIGHLIGHT: 9,
  749. UNDERLINE: 10,
  750. SQUIGGLY: 11,
  751. STRIKEOUT: 12,
  752. STAMP: 13,
  753. CARET: 14,
  754. INK: 15,
  755. POPUP: 16,
  756. FILEATTACHMENT: 17,
  757. SOUND: 18,
  758. MOVIE: 19,
  759. WIDGET: 20,
  760. SCREEN: 21,
  761. PRINTERMARK: 22,
  762. TRAPNET: 23,
  763. WATERMARK: 24,
  764. THREED: 25,
  765. REDACT: 26
  766. };
  767. exports.AnnotationType = AnnotationType;
  768. const AnnotationReplyType = {
  769. GROUP: "Group",
  770. REPLY: "R"
  771. };
  772. exports.AnnotationReplyType = AnnotationReplyType;
  773. const AnnotationFlag = {
  774. INVISIBLE: 0x01,
  775. HIDDEN: 0x02,
  776. PRINT: 0x04,
  777. NOZOOM: 0x08,
  778. NOROTATE: 0x10,
  779. NOVIEW: 0x20,
  780. READONLY: 0x40,
  781. LOCKED: 0x80,
  782. TOGGLENOVIEW: 0x100,
  783. LOCKEDCONTENTS: 0x200
  784. };
  785. exports.AnnotationFlag = AnnotationFlag;
  786. const AnnotationFieldFlag = {
  787. READONLY: 0x0000001,
  788. REQUIRED: 0x0000002,
  789. NOEXPORT: 0x0000004,
  790. MULTILINE: 0x0001000,
  791. PASSWORD: 0x0002000,
  792. NOTOGGLETOOFF: 0x0004000,
  793. RADIO: 0x0008000,
  794. PUSHBUTTON: 0x0010000,
  795. COMBO: 0x0020000,
  796. EDIT: 0x0040000,
  797. SORT: 0x0080000,
  798. FILESELECT: 0x0100000,
  799. MULTISELECT: 0x0200000,
  800. DONOTSPELLCHECK: 0x0400000,
  801. DONOTSCROLL: 0x0800000,
  802. COMB: 0x1000000,
  803. RICHTEXT: 0x2000000,
  804. RADIOSINUNISON: 0x2000000,
  805. COMMITONSELCHANGE: 0x4000000
  806. };
  807. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  808. const AnnotationBorderStyleType = {
  809. SOLID: 1,
  810. DASHED: 2,
  811. BEVELED: 3,
  812. INSET: 4,
  813. UNDERLINE: 5
  814. };
  815. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  816. const AnnotationActionEventType = {
  817. E: "Mouse Enter",
  818. X: "Mouse Exit",
  819. D: "Mouse Down",
  820. U: "Mouse Up",
  821. Fo: "Focus",
  822. Bl: "Blur",
  823. PO: "PageOpen",
  824. PC: "PageClose",
  825. PV: "PageVisible",
  826. PI: "PageInvisible",
  827. K: "Keystroke",
  828. F: "Format",
  829. V: "Validate",
  830. C: "Calculate"
  831. };
  832. exports.AnnotationActionEventType = AnnotationActionEventType;
  833. const DocumentActionEventType = {
  834. WC: "WillClose",
  835. WS: "WillSave",
  836. DS: "DidSave",
  837. WP: "WillPrint",
  838. DP: "DidPrint"
  839. };
  840. exports.DocumentActionEventType = DocumentActionEventType;
  841. const PageActionEventType = {
  842. O: "PageOpen",
  843. C: "PageClose"
  844. };
  845. exports.PageActionEventType = PageActionEventType;
  846. const VerbosityLevel = {
  847. ERRORS: 0,
  848. WARNINGS: 1,
  849. INFOS: 5
  850. };
  851. exports.VerbosityLevel = VerbosityLevel;
  852. const CMapCompressionType = {
  853. NONE: 0,
  854. BINARY: 1
  855. };
  856. exports.CMapCompressionType = CMapCompressionType;
  857. const OPS = {
  858. dependency: 1,
  859. setLineWidth: 2,
  860. setLineCap: 3,
  861. setLineJoin: 4,
  862. setMiterLimit: 5,
  863. setDash: 6,
  864. setRenderingIntent: 7,
  865. setFlatness: 8,
  866. setGState: 9,
  867. save: 10,
  868. restore: 11,
  869. transform: 12,
  870. moveTo: 13,
  871. lineTo: 14,
  872. curveTo: 15,
  873. curveTo2: 16,
  874. curveTo3: 17,
  875. closePath: 18,
  876. rectangle: 19,
  877. stroke: 20,
  878. closeStroke: 21,
  879. fill: 22,
  880. eoFill: 23,
  881. fillStroke: 24,
  882. eoFillStroke: 25,
  883. closeFillStroke: 26,
  884. closeEOFillStroke: 27,
  885. endPath: 28,
  886. clip: 29,
  887. eoClip: 30,
  888. beginText: 31,
  889. endText: 32,
  890. setCharSpacing: 33,
  891. setWordSpacing: 34,
  892. setHScale: 35,
  893. setLeading: 36,
  894. setFont: 37,
  895. setTextRenderingMode: 38,
  896. setTextRise: 39,
  897. moveText: 40,
  898. setLeadingMoveText: 41,
  899. setTextMatrix: 42,
  900. nextLine: 43,
  901. showText: 44,
  902. showSpacedText: 45,
  903. nextLineShowText: 46,
  904. nextLineSetSpacingShowText: 47,
  905. setCharWidth: 48,
  906. setCharWidthAndBounds: 49,
  907. setStrokeColorSpace: 50,
  908. setFillColorSpace: 51,
  909. setStrokeColor: 52,
  910. setStrokeColorN: 53,
  911. setFillColor: 54,
  912. setFillColorN: 55,
  913. setStrokeGray: 56,
  914. setFillGray: 57,
  915. setStrokeRGBColor: 58,
  916. setFillRGBColor: 59,
  917. setStrokeCMYKColor: 60,
  918. setFillCMYKColor: 61,
  919. shadingFill: 62,
  920. beginInlineImage: 63,
  921. beginImageData: 64,
  922. endInlineImage: 65,
  923. paintXObject: 66,
  924. markPoint: 67,
  925. markPointProps: 68,
  926. beginMarkedContent: 69,
  927. beginMarkedContentProps: 70,
  928. endMarkedContent: 71,
  929. beginCompat: 72,
  930. endCompat: 73,
  931. paintFormXObjectBegin: 74,
  932. paintFormXObjectEnd: 75,
  933. beginGroup: 76,
  934. endGroup: 77,
  935. beginAnnotation: 80,
  936. endAnnotation: 81,
  937. paintImageMaskXObject: 83,
  938. paintImageMaskXObjectGroup: 84,
  939. paintImageXObject: 85,
  940. paintInlineImageXObject: 86,
  941. paintInlineImageXObjectGroup: 87,
  942. paintImageXObjectRepeat: 88,
  943. paintImageMaskXObjectRepeat: 89,
  944. paintSolidColorImageMask: 90,
  945. constructPath: 91
  946. };
  947. exports.OPS = OPS;
  948. const PasswordResponses = {
  949. NEED_PASSWORD: 1,
  950. INCORRECT_PASSWORD: 2
  951. };
  952. exports.PasswordResponses = PasswordResponses;
  953. let verbosity = VerbosityLevel.WARNINGS;
  954. function setVerbosityLevel(level) {
  955. if (Number.isInteger(level)) {
  956. verbosity = level;
  957. }
  958. }
  959. function getVerbosityLevel() {
  960. return verbosity;
  961. }
  962. function info(msg) {
  963. if (verbosity >= VerbosityLevel.INFOS) {
  964. console.log(`Info: ${msg}`);
  965. }
  966. }
  967. function warn(msg) {
  968. if (verbosity >= VerbosityLevel.WARNINGS) {
  969. console.log(`Warning: ${msg}`);
  970. }
  971. }
  972. function unreachable(msg) {
  973. throw new Error(msg);
  974. }
  975. function assert(cond, msg) {
  976. if (!cond) {
  977. unreachable(msg);
  978. }
  979. }
  980. function _isValidProtocol(url) {
  981. switch (url?.protocol) {
  982. case "http:":
  983. case "https:":
  984. case "ftp:":
  985. case "mailto:":
  986. case "tel:":
  987. return true;
  988. default:
  989. return false;
  990. }
  991. }
  992. function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
  993. if (!url) {
  994. return null;
  995. }
  996. try {
  997. if (options && typeof url === "string") {
  998. if (options.addDefaultProtocol && url.startsWith("www.")) {
  999. const dots = url.match(/\./g);
  1000. if (dots?.length >= 2) {
  1001. url = `http://${url}`;
  1002. }
  1003. }
  1004. if (options.tryConvertEncoding) {
  1005. try {
  1006. url = stringToUTF8String(url);
  1007. } catch {}
  1008. }
  1009. }
  1010. const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  1011. if (_isValidProtocol(absoluteUrl)) {
  1012. return absoluteUrl;
  1013. }
  1014. } catch {}
  1015. return null;
  1016. }
  1017. function shadow(obj, prop, value, nonSerializable = false) {
  1018. Object.defineProperty(obj, prop, {
  1019. value,
  1020. enumerable: !nonSerializable,
  1021. configurable: true,
  1022. writable: false
  1023. });
  1024. return value;
  1025. }
  1026. const BaseException = function BaseExceptionClosure() {
  1027. function BaseException(message, name) {
  1028. if (this.constructor === BaseException) {
  1029. unreachable("Cannot initialize BaseException.");
  1030. }
  1031. this.message = message;
  1032. this.name = name;
  1033. }
  1034. BaseException.prototype = new Error();
  1035. BaseException.constructor = BaseException;
  1036. return BaseException;
  1037. }();
  1038. exports.BaseException = BaseException;
  1039. class PasswordException extends BaseException {
  1040. constructor(msg, code) {
  1041. super(msg, "PasswordException");
  1042. this.code = code;
  1043. }
  1044. }
  1045. exports.PasswordException = PasswordException;
  1046. class UnknownErrorException extends BaseException {
  1047. constructor(msg, details) {
  1048. super(msg, "UnknownErrorException");
  1049. this.details = details;
  1050. }
  1051. }
  1052. exports.UnknownErrorException = UnknownErrorException;
  1053. class InvalidPDFException extends BaseException {
  1054. constructor(msg) {
  1055. super(msg, "InvalidPDFException");
  1056. }
  1057. }
  1058. exports.InvalidPDFException = InvalidPDFException;
  1059. class MissingPDFException extends BaseException {
  1060. constructor(msg) {
  1061. super(msg, "MissingPDFException");
  1062. }
  1063. }
  1064. exports.MissingPDFException = MissingPDFException;
  1065. class UnexpectedResponseException extends BaseException {
  1066. constructor(msg, status) {
  1067. super(msg, "UnexpectedResponseException");
  1068. this.status = status;
  1069. }
  1070. }
  1071. exports.UnexpectedResponseException = UnexpectedResponseException;
  1072. class FormatError extends BaseException {
  1073. constructor(msg) {
  1074. super(msg, "FormatError");
  1075. }
  1076. }
  1077. exports.FormatError = FormatError;
  1078. class AbortException extends BaseException {
  1079. constructor(msg) {
  1080. super(msg, "AbortException");
  1081. }
  1082. }
  1083. exports.AbortException = AbortException;
  1084. function bytesToString(bytes) {
  1085. if (typeof bytes !== "object" || bytes?.length === undefined) {
  1086. unreachable("Invalid argument for bytesToString");
  1087. }
  1088. const length = bytes.length;
  1089. const MAX_ARGUMENT_COUNT = 8192;
  1090. if (length < MAX_ARGUMENT_COUNT) {
  1091. return String.fromCharCode.apply(null, bytes);
  1092. }
  1093. const strBuf = [];
  1094. for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  1095. const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  1096. const chunk = bytes.subarray(i, chunkEnd);
  1097. strBuf.push(String.fromCharCode.apply(null, chunk));
  1098. }
  1099. return strBuf.join("");
  1100. }
  1101. function stringToBytes(str) {
  1102. if (typeof str !== "string") {
  1103. unreachable("Invalid argument for stringToBytes");
  1104. }
  1105. const length = str.length;
  1106. const bytes = new Uint8Array(length);
  1107. for (let i = 0; i < length; ++i) {
  1108. bytes[i] = str.charCodeAt(i) & 0xff;
  1109. }
  1110. return bytes;
  1111. }
  1112. function string32(value) {
  1113. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  1114. }
  1115. function objectSize(obj) {
  1116. return Object.keys(obj).length;
  1117. }
  1118. function objectFromMap(map) {
  1119. const obj = Object.create(null);
  1120. for (const [key, value] of map) {
  1121. obj[key] = value;
  1122. }
  1123. return obj;
  1124. }
  1125. function isLittleEndian() {
  1126. const buffer8 = new Uint8Array(4);
  1127. buffer8[0] = 1;
  1128. const view32 = new Uint32Array(buffer8.buffer, 0, 1);
  1129. return view32[0] === 1;
  1130. }
  1131. function isEvalSupported() {
  1132. try {
  1133. new Function("");
  1134. return true;
  1135. } catch {
  1136. return false;
  1137. }
  1138. }
  1139. class FeatureTest {
  1140. static get isLittleEndian() {
  1141. return shadow(this, "isLittleEndian", isLittleEndian());
  1142. }
  1143. static get isEvalSupported() {
  1144. return shadow(this, "isEvalSupported", isEvalSupported());
  1145. }
  1146. static get isOffscreenCanvasSupported() {
  1147. return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
  1148. }
  1149. static get platform() {
  1150. if (typeof navigator === "undefined") {
  1151. return shadow(this, "platform", {
  1152. isWin: false,
  1153. isMac: false
  1154. });
  1155. }
  1156. return shadow(this, "platform", {
  1157. isWin: navigator.platform.includes("Win"),
  1158. isMac: navigator.platform.includes("Mac")
  1159. });
  1160. }
  1161. static get isCSSRoundSupported() {
  1162. return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
  1163. }
  1164. }
  1165. exports.FeatureTest = FeatureTest;
  1166. const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
  1167. class Util {
  1168. static makeHexColor(r, g, b) {
  1169. return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
  1170. }
  1171. static scaleMinMax(transform, minMax) {
  1172. let temp;
  1173. if (transform[0]) {
  1174. if (transform[0] < 0) {
  1175. temp = minMax[0];
  1176. minMax[0] = minMax[1];
  1177. minMax[1] = temp;
  1178. }
  1179. minMax[0] *= transform[0];
  1180. minMax[1] *= transform[0];
  1181. if (transform[3] < 0) {
  1182. temp = minMax[2];
  1183. minMax[2] = minMax[3];
  1184. minMax[3] = temp;
  1185. }
  1186. minMax[2] *= transform[3];
  1187. minMax[3] *= transform[3];
  1188. } else {
  1189. temp = minMax[0];
  1190. minMax[0] = minMax[2];
  1191. minMax[2] = temp;
  1192. temp = minMax[1];
  1193. minMax[1] = minMax[3];
  1194. minMax[3] = temp;
  1195. if (transform[1] < 0) {
  1196. temp = minMax[2];
  1197. minMax[2] = minMax[3];
  1198. minMax[3] = temp;
  1199. }
  1200. minMax[2] *= transform[1];
  1201. minMax[3] *= transform[1];
  1202. if (transform[2] < 0) {
  1203. temp = minMax[0];
  1204. minMax[0] = minMax[1];
  1205. minMax[1] = temp;
  1206. }
  1207. minMax[0] *= transform[2];
  1208. minMax[1] *= transform[2];
  1209. }
  1210. minMax[0] += transform[4];
  1211. minMax[1] += transform[4];
  1212. minMax[2] += transform[5];
  1213. minMax[3] += transform[5];
  1214. }
  1215. static transform(m1, m2) {
  1216. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  1217. }
  1218. static applyTransform(p, m) {
  1219. const xt = p[0] * m[0] + p[1] * m[2] + m[4];
  1220. const yt = p[0] * m[1] + p[1] * m[3] + m[5];
  1221. return [xt, yt];
  1222. }
  1223. static applyInverseTransform(p, m) {
  1224. const d = m[0] * m[3] - m[1] * m[2];
  1225. const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  1226. const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  1227. return [xt, yt];
  1228. }
  1229. static getAxialAlignedBoundingBox(r, m) {
  1230. const p1 = this.applyTransform(r, m);
  1231. const p2 = this.applyTransform(r.slice(2, 4), m);
  1232. const p3 = this.applyTransform([r[0], r[3]], m);
  1233. const p4 = this.applyTransform([r[2], r[1]], m);
  1234. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  1235. }
  1236. static inverseTransform(m) {
  1237. const d = m[0] * m[3] - m[1] * m[2];
  1238. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  1239. }
  1240. static singularValueDecompose2dScale(m) {
  1241. const transpose = [m[0], m[2], m[1], m[3]];
  1242. const a = m[0] * transpose[0] + m[1] * transpose[2];
  1243. const b = m[0] * transpose[1] + m[1] * transpose[3];
  1244. const c = m[2] * transpose[0] + m[3] * transpose[2];
  1245. const d = m[2] * transpose[1] + m[3] * transpose[3];
  1246. const first = (a + d) / 2;
  1247. const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
  1248. const sx = first + second || 1;
  1249. const sy = first - second || 1;
  1250. return [Math.sqrt(sx), Math.sqrt(sy)];
  1251. }
  1252. static normalizeRect(rect) {
  1253. const r = rect.slice(0);
  1254. if (rect[0] > rect[2]) {
  1255. r[0] = rect[2];
  1256. r[2] = rect[0];
  1257. }
  1258. if (rect[1] > rect[3]) {
  1259. r[1] = rect[3];
  1260. r[3] = rect[1];
  1261. }
  1262. return r;
  1263. }
  1264. static intersect(rect1, rect2) {
  1265. const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
  1266. const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
  1267. if (xLow > xHigh) {
  1268. return null;
  1269. }
  1270. const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
  1271. const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
  1272. if (yLow > yHigh) {
  1273. return null;
  1274. }
  1275. return [xLow, yLow, xHigh, yHigh];
  1276. }
  1277. static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3) {
  1278. const tvalues = [],
  1279. bounds = [[], []];
  1280. let a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  1281. for (let i = 0; i < 2; ++i) {
  1282. if (i === 0) {
  1283. b = 6 * x0 - 12 * x1 + 6 * x2;
  1284. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  1285. c = 3 * x1 - 3 * x0;
  1286. } else {
  1287. b = 6 * y0 - 12 * y1 + 6 * y2;
  1288. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  1289. c = 3 * y1 - 3 * y0;
  1290. }
  1291. if (Math.abs(a) < 1e-12) {
  1292. if (Math.abs(b) < 1e-12) {
  1293. continue;
  1294. }
  1295. t = -c / b;
  1296. if (0 < t && t < 1) {
  1297. tvalues.push(t);
  1298. }
  1299. continue;
  1300. }
  1301. b2ac = b * b - 4 * c * a;
  1302. sqrtb2ac = Math.sqrt(b2ac);
  1303. if (b2ac < 0) {
  1304. continue;
  1305. }
  1306. t1 = (-b + sqrtb2ac) / (2 * a);
  1307. if (0 < t1 && t1 < 1) {
  1308. tvalues.push(t1);
  1309. }
  1310. t2 = (-b - sqrtb2ac) / (2 * a);
  1311. if (0 < t2 && t2 < 1) {
  1312. tvalues.push(t2);
  1313. }
  1314. }
  1315. let j = tvalues.length,
  1316. mt;
  1317. const jlen = j;
  1318. while (j--) {
  1319. t = tvalues[j];
  1320. mt = 1 - t;
  1321. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  1322. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  1323. }
  1324. bounds[0][jlen] = x0;
  1325. bounds[1][jlen] = y0;
  1326. bounds[0][jlen + 1] = x3;
  1327. bounds[1][jlen + 1] = y3;
  1328. bounds[0].length = bounds[1].length = jlen + 2;
  1329. return [Math.min(...bounds[0]), Math.min(...bounds[1]), Math.max(...bounds[0]), Math.max(...bounds[1])];
  1330. }
  1331. }
  1332. exports.Util = Util;
  1333. const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
  1334. function stringToPDFString(str) {
  1335. if (str[0] >= "\xEF") {
  1336. let encoding;
  1337. if (str[0] === "\xFE" && str[1] === "\xFF") {
  1338. encoding = "utf-16be";
  1339. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  1340. encoding = "utf-16le";
  1341. } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
  1342. encoding = "utf-8";
  1343. }
  1344. if (encoding) {
  1345. try {
  1346. const decoder = new TextDecoder(encoding, {
  1347. fatal: true
  1348. });
  1349. const buffer = stringToBytes(str);
  1350. return decoder.decode(buffer);
  1351. } catch (ex) {
  1352. warn(`stringToPDFString: "${ex}".`);
  1353. }
  1354. }
  1355. }
  1356. const strBuf = [];
  1357. for (let i = 0, ii = str.length; i < ii; i++) {
  1358. const code = PDFStringTranslateTable[str.charCodeAt(i)];
  1359. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1360. }
  1361. return strBuf.join("");
  1362. }
  1363. function stringToUTF8String(str) {
  1364. return decodeURIComponent(escape(str));
  1365. }
  1366. function utf8StringToString(str) {
  1367. return unescape(encodeURIComponent(str));
  1368. }
  1369. function isArrayBuffer(v) {
  1370. return typeof v === "object" && v?.byteLength !== undefined;
  1371. }
  1372. function isArrayEqual(arr1, arr2) {
  1373. if (arr1.length !== arr2.length) {
  1374. return false;
  1375. }
  1376. for (let i = 0, ii = arr1.length; i < ii; i++) {
  1377. if (arr1[i] !== arr2[i]) {
  1378. return false;
  1379. }
  1380. }
  1381. return true;
  1382. }
  1383. function getModificationDate(date = new Date()) {
  1384. const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  1385. return buffer.join("");
  1386. }
  1387. class PromiseCapability {
  1388. #settled = false;
  1389. constructor() {
  1390. this.promise = new Promise((resolve, reject) => {
  1391. this.resolve = data => {
  1392. this.#settled = true;
  1393. resolve(data);
  1394. };
  1395. this.reject = reason => {
  1396. this.#settled = true;
  1397. reject(reason);
  1398. };
  1399. });
  1400. }
  1401. get settled() {
  1402. return this.#settled;
  1403. }
  1404. }
  1405. exports.PromiseCapability = PromiseCapability;
  1406. let NormalizeRegex = null;
  1407. let NormalizationMap = null;
  1408. function normalizeUnicode(str) {
  1409. if (!NormalizeRegex) {
  1410. NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
  1411. NormalizationMap = new Map([["ſt", "ſt"]]);
  1412. }
  1413. return str.replaceAll(NormalizeRegex, (_, p1, p2) => {
  1414. return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2);
  1415. });
  1416. }
  1417. function getUuid() {
  1418. if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
  1419. return crypto.randomUUID();
  1420. }
  1421. const buf = new Uint8Array(32);
  1422. if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
  1423. crypto.getRandomValues(buf);
  1424. } else {
  1425. for (let i = 0; i < 32; i++) {
  1426. buf[i] = Math.floor(Math.random() * 255);
  1427. }
  1428. }
  1429. return bytesToString(buf);
  1430. }
  1431. /***/ }),
  1432. /* 3 */
  1433. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1434. Object.defineProperty(exports, "__esModule", ({
  1435. value: true
  1436. }));
  1437. exports.XRefParseException = exports.XRefEntryException = exports.ParserEOFException = exports.PDF_VERSION_REGEXP = exports.MissingDataException = void 0;
  1438. exports.arrayBuffersToBytes = arrayBuffersToBytes;
  1439. exports.collectActions = collectActions;
  1440. exports.encodeToXmlString = encodeToXmlString;
  1441. exports.escapePDFName = escapePDFName;
  1442. exports.escapeString = escapeString;
  1443. exports.getInheritableProperty = getInheritableProperty;
  1444. exports.getLookupTableFactory = getLookupTableFactory;
  1445. exports.getNewAnnotationsMap = getNewAnnotationsMap;
  1446. exports.getRotationMatrix = getRotationMatrix;
  1447. exports.isAscii = isAscii;
  1448. exports.isWhiteSpace = isWhiteSpace;
  1449. exports.log2 = log2;
  1450. exports.numberToString = numberToString;
  1451. exports.parseXFAPath = parseXFAPath;
  1452. exports.readInt8 = readInt8;
  1453. exports.readUint16 = readUint16;
  1454. exports.readUint32 = readUint32;
  1455. exports.recoverJsURL = recoverJsURL;
  1456. exports.stringToUTF16HexString = stringToUTF16HexString;
  1457. exports.stringToUTF16String = stringToUTF16String;
  1458. exports.toRomanNumerals = toRomanNumerals;
  1459. exports.validateCSSFont = validateCSSFont;
  1460. exports.validateFontName = validateFontName;
  1461. var _util = __w_pdfjs_require__(2);
  1462. var _primitives = __w_pdfjs_require__(4);
  1463. var _base_stream = __w_pdfjs_require__(5);
  1464. const PDF_VERSION_REGEXP = /^[1-9]\.\d$/;
  1465. exports.PDF_VERSION_REGEXP = PDF_VERSION_REGEXP;
  1466. function getLookupTableFactory(initializer) {
  1467. let lookup;
  1468. return function () {
  1469. if (initializer) {
  1470. lookup = Object.create(null);
  1471. initializer(lookup);
  1472. initializer = null;
  1473. }
  1474. return lookup;
  1475. };
  1476. }
  1477. class MissingDataException extends _util.BaseException {
  1478. constructor(begin, end) {
  1479. super(`Missing data [${begin}, ${end})`, "MissingDataException");
  1480. this.begin = begin;
  1481. this.end = end;
  1482. }
  1483. }
  1484. exports.MissingDataException = MissingDataException;
  1485. class ParserEOFException extends _util.BaseException {
  1486. constructor(msg) {
  1487. super(msg, "ParserEOFException");
  1488. }
  1489. }
  1490. exports.ParserEOFException = ParserEOFException;
  1491. class XRefEntryException extends _util.BaseException {
  1492. constructor(msg) {
  1493. super(msg, "XRefEntryException");
  1494. }
  1495. }
  1496. exports.XRefEntryException = XRefEntryException;
  1497. class XRefParseException extends _util.BaseException {
  1498. constructor(msg) {
  1499. super(msg, "XRefParseException");
  1500. }
  1501. }
  1502. exports.XRefParseException = XRefParseException;
  1503. function arrayBuffersToBytes(arr) {
  1504. const length = arr.length;
  1505. if (length === 0) {
  1506. return new Uint8Array(0);
  1507. }
  1508. if (length === 1) {
  1509. return new Uint8Array(arr[0]);
  1510. }
  1511. let dataLength = 0;
  1512. for (let i = 0; i < length; i++) {
  1513. dataLength += arr[i].byteLength;
  1514. }
  1515. const data = new Uint8Array(dataLength);
  1516. let pos = 0;
  1517. for (let i = 0; i < length; i++) {
  1518. const item = new Uint8Array(arr[i]);
  1519. data.set(item, pos);
  1520. pos += item.byteLength;
  1521. }
  1522. return data;
  1523. }
  1524. function getInheritableProperty({
  1525. dict,
  1526. key,
  1527. getArray = false,
  1528. stopWhenFound = true
  1529. }) {
  1530. let values;
  1531. const visited = new _primitives.RefSet();
  1532. while (dict instanceof _primitives.Dict && !(dict.objId && visited.has(dict.objId))) {
  1533. if (dict.objId) {
  1534. visited.put(dict.objId);
  1535. }
  1536. const value = getArray ? dict.getArray(key) : dict.get(key);
  1537. if (value !== undefined) {
  1538. if (stopWhenFound) {
  1539. return value;
  1540. }
  1541. (values ||= []).push(value);
  1542. }
  1543. dict = dict.get("Parent");
  1544. }
  1545. return values;
  1546. }
  1547. const ROMAN_NUMBER_MAP = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
  1548. function toRomanNumerals(number, lowerCase = false) {
  1549. (0, _util.assert)(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
  1550. const romanBuf = [];
  1551. let pos;
  1552. while (number >= 1000) {
  1553. number -= 1000;
  1554. romanBuf.push("M");
  1555. }
  1556. pos = number / 100 | 0;
  1557. number %= 100;
  1558. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  1559. pos = number / 10 | 0;
  1560. number %= 10;
  1561. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  1562. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  1563. const romanStr = romanBuf.join("");
  1564. return lowerCase ? romanStr.toLowerCase() : romanStr;
  1565. }
  1566. function log2(x) {
  1567. if (x <= 0) {
  1568. return 0;
  1569. }
  1570. return Math.ceil(Math.log2(x));
  1571. }
  1572. function readInt8(data, offset) {
  1573. return data[offset] << 24 >> 24;
  1574. }
  1575. function readUint16(data, offset) {
  1576. return data[offset] << 8 | data[offset + 1];
  1577. }
  1578. function readUint32(data, offset) {
  1579. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  1580. }
  1581. function isWhiteSpace(ch) {
  1582. return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
  1583. }
  1584. function parseXFAPath(path) {
  1585. const positionPattern = /(.+)\[(\d+)\]$/;
  1586. return path.split(".").map(component => {
  1587. const m = component.match(positionPattern);
  1588. if (m) {
  1589. return {
  1590. name: m[1],
  1591. pos: parseInt(m[2], 10)
  1592. };
  1593. }
  1594. return {
  1595. name: component,
  1596. pos: 0
  1597. };
  1598. });
  1599. }
  1600. function escapePDFName(str) {
  1601. const buffer = [];
  1602. let start = 0;
  1603. for (let i = 0, ii = str.length; i < ii; i++) {
  1604. const char = str.charCodeAt(i);
  1605. if (char < 0x21 || char > 0x7e || char === 0x23 || char === 0x28 || char === 0x29 || char === 0x3c || char === 0x3e || char === 0x5b || char === 0x5d || char === 0x7b || char === 0x7d || char === 0x2f || char === 0x25) {
  1606. if (start < i) {
  1607. buffer.push(str.substring(start, i));
  1608. }
  1609. buffer.push(`#${char.toString(16)}`);
  1610. start = i + 1;
  1611. }
  1612. }
  1613. if (buffer.length === 0) {
  1614. return str;
  1615. }
  1616. if (start < str.length) {
  1617. buffer.push(str.substring(start, str.length));
  1618. }
  1619. return buffer.join("");
  1620. }
  1621. function escapeString(str) {
  1622. return str.replaceAll(/([()\\\n\r])/g, match => {
  1623. if (match === "\n") {
  1624. return "\\n";
  1625. } else if (match === "\r") {
  1626. return "\\r";
  1627. }
  1628. return `\\${match}`;
  1629. });
  1630. }
  1631. function _collectJS(entry, xref, list, parents) {
  1632. if (!entry) {
  1633. return;
  1634. }
  1635. let parent = null;
  1636. if (entry instanceof _primitives.Ref) {
  1637. if (parents.has(entry)) {
  1638. return;
  1639. }
  1640. parent = entry;
  1641. parents.put(parent);
  1642. entry = xref.fetch(entry);
  1643. }
  1644. if (Array.isArray(entry)) {
  1645. for (const element of entry) {
  1646. _collectJS(element, xref, list, parents);
  1647. }
  1648. } else if (entry instanceof _primitives.Dict) {
  1649. if ((0, _primitives.isName)(entry.get("S"), "JavaScript")) {
  1650. const js = entry.get("JS");
  1651. let code;
  1652. if (js instanceof _base_stream.BaseStream) {
  1653. code = js.getString();
  1654. } else if (typeof js === "string") {
  1655. code = js;
  1656. }
  1657. code &&= (0, _util.stringToPDFString)(code).replaceAll("\x00", "");
  1658. if (code) {
  1659. list.push(code);
  1660. }
  1661. }
  1662. _collectJS(entry.getRaw("Next"), xref, list, parents);
  1663. }
  1664. if (parent) {
  1665. parents.remove(parent);
  1666. }
  1667. }
  1668. function collectActions(xref, dict, eventType) {
  1669. const actions = Object.create(null);
  1670. const additionalActionsDicts = getInheritableProperty({
  1671. dict,
  1672. key: "AA",
  1673. stopWhenFound: false
  1674. });
  1675. if (additionalActionsDicts) {
  1676. for (let i = additionalActionsDicts.length - 1; i >= 0; i--) {
  1677. const additionalActions = additionalActionsDicts[i];
  1678. if (!(additionalActions instanceof _primitives.Dict)) {
  1679. continue;
  1680. }
  1681. for (const key of additionalActions.getKeys()) {
  1682. const action = eventType[key];
  1683. if (!action) {
  1684. continue;
  1685. }
  1686. const actionDict = additionalActions.getRaw(key);
  1687. const parents = new _primitives.RefSet();
  1688. const list = [];
  1689. _collectJS(actionDict, xref, list, parents);
  1690. if (list.length > 0) {
  1691. actions[action] = list;
  1692. }
  1693. }
  1694. }
  1695. }
  1696. if (dict.has("A")) {
  1697. const actionDict = dict.get("A");
  1698. const parents = new _primitives.RefSet();
  1699. const list = [];
  1700. _collectJS(actionDict, xref, list, parents);
  1701. if (list.length > 0) {
  1702. actions.Action = list;
  1703. }
  1704. }
  1705. return (0, _util.objectSize)(actions) > 0 ? actions : null;
  1706. }
  1707. const XMLEntities = {
  1708. 0x3c: "&lt;",
  1709. 0x3e: "&gt;",
  1710. 0x26: "&amp;",
  1711. 0x22: "&quot;",
  1712. 0x27: "&apos;"
  1713. };
  1714. function encodeToXmlString(str) {
  1715. const buffer = [];
  1716. let start = 0;
  1717. for (let i = 0, ii = str.length; i < ii; i++) {
  1718. const char = str.codePointAt(i);
  1719. if (0x20 <= char && char <= 0x7e) {
  1720. const entity = XMLEntities[char];
  1721. if (entity) {
  1722. if (start < i) {
  1723. buffer.push(str.substring(start, i));
  1724. }
  1725. buffer.push(entity);
  1726. start = i + 1;
  1727. }
  1728. } else {
  1729. if (start < i) {
  1730. buffer.push(str.substring(start, i));
  1731. }
  1732. buffer.push(`&#x${char.toString(16).toUpperCase()};`);
  1733. if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
  1734. i++;
  1735. }
  1736. start = i + 1;
  1737. }
  1738. }
  1739. if (buffer.length === 0) {
  1740. return str;
  1741. }
  1742. if (start < str.length) {
  1743. buffer.push(str.substring(start, str.length));
  1744. }
  1745. return buffer.join("");
  1746. }
  1747. function validateFontName(fontFamily, mustWarn = false) {
  1748. const m = /^("|').*("|')$/.exec(fontFamily);
  1749. if (m && m[1] === m[2]) {
  1750. const re = new RegExp(`[^\\\\]${m[1]}`);
  1751. if (re.test(fontFamily.slice(1, -1))) {
  1752. if (mustWarn) {
  1753. (0, _util.warn)(`FontFamily contains unescaped ${m[1]}: ${fontFamily}.`);
  1754. }
  1755. return false;
  1756. }
  1757. } else {
  1758. for (const ident of fontFamily.split(/[ \t]+/)) {
  1759. if (/^(\d|(-(\d|-)))/.test(ident) || !/^[\w-\\]+$/.test(ident)) {
  1760. if (mustWarn) {
  1761. (0, _util.warn)(`FontFamily contains invalid <custom-ident>: ${fontFamily}.`);
  1762. }
  1763. return false;
  1764. }
  1765. }
  1766. }
  1767. return true;
  1768. }
  1769. function validateCSSFont(cssFontInfo) {
  1770. const DEFAULT_CSS_FONT_OBLIQUE = "14";
  1771. const DEFAULT_CSS_FONT_WEIGHT = "400";
  1772. const CSS_FONT_WEIGHT_VALUES = new Set(["100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "normal", "bold", "bolder", "lighter"]);
  1773. const {
  1774. fontFamily,
  1775. fontWeight,
  1776. italicAngle
  1777. } = cssFontInfo;
  1778. if (!validateFontName(fontFamily, true)) {
  1779. return false;
  1780. }
  1781. const weight = fontWeight ? fontWeight.toString() : "";
  1782. cssFontInfo.fontWeight = CSS_FONT_WEIGHT_VALUES.has(weight) ? weight : DEFAULT_CSS_FONT_WEIGHT;
  1783. const angle = parseFloat(italicAngle);
  1784. cssFontInfo.italicAngle = isNaN(angle) || angle < -90 || angle > 90 ? DEFAULT_CSS_FONT_OBLIQUE : italicAngle.toString();
  1785. return true;
  1786. }
  1787. function recoverJsURL(str) {
  1788. const URL_OPEN_METHODS = ["app.launchURL", "window.open", "xfa.host.gotoURL"];
  1789. const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").replaceAll(".", "\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
  1790. const jsUrl = regex.exec(str);
  1791. if (jsUrl?.[2]) {
  1792. const url = jsUrl[2];
  1793. let newWindow = false;
  1794. if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
  1795. newWindow = true;
  1796. }
  1797. return {
  1798. url,
  1799. newWindow
  1800. };
  1801. }
  1802. return null;
  1803. }
  1804. function numberToString(value) {
  1805. if (Number.isInteger(value)) {
  1806. return value.toString();
  1807. }
  1808. const roundedValue = Math.round(value * 100);
  1809. if (roundedValue % 100 === 0) {
  1810. return (roundedValue / 100).toString();
  1811. }
  1812. if (roundedValue % 10 === 0) {
  1813. return value.toFixed(1);
  1814. }
  1815. return value.toFixed(2);
  1816. }
  1817. function getNewAnnotationsMap(annotationStorage) {
  1818. if (!annotationStorage) {
  1819. return null;
  1820. }
  1821. const newAnnotationsByPage = new Map();
  1822. for (const [key, value] of annotationStorage) {
  1823. if (!key.startsWith(_util.AnnotationEditorPrefix)) {
  1824. continue;
  1825. }
  1826. let annotations = newAnnotationsByPage.get(value.pageIndex);
  1827. if (!annotations) {
  1828. annotations = [];
  1829. newAnnotationsByPage.set(value.pageIndex, annotations);
  1830. }
  1831. annotations.push(value);
  1832. }
  1833. return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
  1834. }
  1835. function isAscii(str) {
  1836. return /^[\x00-\x7F]*$/.test(str);
  1837. }
  1838. function stringToUTF16HexString(str) {
  1839. const buf = [];
  1840. for (let i = 0, ii = str.length; i < ii; i++) {
  1841. const char = str.charCodeAt(i);
  1842. buf.push((char >> 8 & 0xff).toString(16).padStart(2, "0"), (char & 0xff).toString(16).padStart(2, "0"));
  1843. }
  1844. return buf.join("");
  1845. }
  1846. function stringToUTF16String(str, bigEndian = false) {
  1847. const buf = [];
  1848. if (bigEndian) {
  1849. buf.push("\xFE\xFF");
  1850. }
  1851. for (let i = 0, ii = str.length; i < ii; i++) {
  1852. const char = str.charCodeAt(i);
  1853. buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
  1854. }
  1855. return buf.join("");
  1856. }
  1857. function getRotationMatrix(rotation, width, height) {
  1858. switch (rotation) {
  1859. case 90:
  1860. return [0, 1, -1, 0, width, 0];
  1861. case 180:
  1862. return [-1, 0, 0, -1, width, height];
  1863. case 270:
  1864. return [0, -1, 1, 0, 0, height];
  1865. default:
  1866. throw new Error("Invalid rotation");
  1867. }
  1868. }
  1869. /***/ }),
  1870. /* 4 */
  1871. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1872. Object.defineProperty(exports, "__esModule", ({
  1873. value: true
  1874. }));
  1875. exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.EOF = exports.Dict = exports.Cmd = exports.CIRCULAR_REF = void 0;
  1876. exports.clearPrimitiveCaches = clearPrimitiveCaches;
  1877. exports.isCmd = isCmd;
  1878. exports.isDict = isDict;
  1879. exports.isName = isName;
  1880. exports.isRefsEqual = isRefsEqual;
  1881. var _util = __w_pdfjs_require__(2);
  1882. const CIRCULAR_REF = Symbol("CIRCULAR_REF");
  1883. exports.CIRCULAR_REF = CIRCULAR_REF;
  1884. const EOF = Symbol("EOF");
  1885. exports.EOF = EOF;
  1886. let CmdCache = Object.create(null);
  1887. let NameCache = Object.create(null);
  1888. let RefCache = Object.create(null);
  1889. function clearPrimitiveCaches() {
  1890. CmdCache = Object.create(null);
  1891. NameCache = Object.create(null);
  1892. RefCache = Object.create(null);
  1893. }
  1894. class Name {
  1895. constructor(name) {
  1896. this.name = name;
  1897. }
  1898. static get(name) {
  1899. return NameCache[name] ||= new Name(name);
  1900. }
  1901. }
  1902. exports.Name = Name;
  1903. class Cmd {
  1904. constructor(cmd) {
  1905. this.cmd = cmd;
  1906. }
  1907. static get(cmd) {
  1908. return CmdCache[cmd] ||= new Cmd(cmd);
  1909. }
  1910. }
  1911. exports.Cmd = Cmd;
  1912. const nonSerializable = function nonSerializableClosure() {
  1913. return nonSerializable;
  1914. };
  1915. class Dict {
  1916. constructor(xref = null) {
  1917. this._map = Object.create(null);
  1918. this.xref = xref;
  1919. this.objId = null;
  1920. this.suppressEncryption = false;
  1921. this.__nonSerializable__ = nonSerializable;
  1922. }
  1923. assignXref(newXref) {
  1924. this.xref = newXref;
  1925. }
  1926. get size() {
  1927. return Object.keys(this._map).length;
  1928. }
  1929. get(key1, key2, key3) {
  1930. let value = this._map[key1];
  1931. if (value === undefined && key2 !== undefined) {
  1932. value = this._map[key2];
  1933. if (value === undefined && key3 !== undefined) {
  1934. value = this._map[key3];
  1935. }
  1936. }
  1937. if (value instanceof Ref && this.xref) {
  1938. return this.xref.fetch(value, this.suppressEncryption);
  1939. }
  1940. return value;
  1941. }
  1942. async getAsync(key1, key2, key3) {
  1943. let value = this._map[key1];
  1944. if (value === undefined && key2 !== undefined) {
  1945. value = this._map[key2];
  1946. if (value === undefined && key3 !== undefined) {
  1947. value = this._map[key3];
  1948. }
  1949. }
  1950. if (value instanceof Ref && this.xref) {
  1951. return this.xref.fetchAsync(value, this.suppressEncryption);
  1952. }
  1953. return value;
  1954. }
  1955. getArray(key1, key2, key3) {
  1956. let value = this._map[key1];
  1957. if (value === undefined && key2 !== undefined) {
  1958. value = this._map[key2];
  1959. if (value === undefined && key3 !== undefined) {
  1960. value = this._map[key3];
  1961. }
  1962. }
  1963. if (value instanceof Ref && this.xref) {
  1964. value = this.xref.fetch(value, this.suppressEncryption);
  1965. }
  1966. if (Array.isArray(value)) {
  1967. value = value.slice();
  1968. for (let i = 0, ii = value.length; i < ii; i++) {
  1969. if (value[i] instanceof Ref && this.xref) {
  1970. value[i] = this.xref.fetch(value[i], this.suppressEncryption);
  1971. }
  1972. }
  1973. }
  1974. return value;
  1975. }
  1976. getRaw(key) {
  1977. return this._map[key];
  1978. }
  1979. getKeys() {
  1980. return Object.keys(this._map);
  1981. }
  1982. getRawValues() {
  1983. return Object.values(this._map);
  1984. }
  1985. set(key, value) {
  1986. this._map[key] = value;
  1987. }
  1988. has(key) {
  1989. return this._map[key] !== undefined;
  1990. }
  1991. forEach(callback) {
  1992. for (const key in this._map) {
  1993. callback(key, this.get(key));
  1994. }
  1995. }
  1996. static get empty() {
  1997. const emptyDict = new Dict(null);
  1998. emptyDict.set = (key, value) => {
  1999. (0, _util.unreachable)("Should not call `set` on the empty dictionary.");
  2000. };
  2001. return (0, _util.shadow)(this, "empty", emptyDict);
  2002. }
  2003. static merge({
  2004. xref,
  2005. dictArray,
  2006. mergeSubDicts = false
  2007. }) {
  2008. const mergedDict = new Dict(xref),
  2009. properties = new Map();
  2010. for (const dict of dictArray) {
  2011. if (!(dict instanceof Dict)) {
  2012. continue;
  2013. }
  2014. for (const [key, value] of Object.entries(dict._map)) {
  2015. let property = properties.get(key);
  2016. if (property === undefined) {
  2017. property = [];
  2018. properties.set(key, property);
  2019. } else if (!mergeSubDicts || !(value instanceof Dict)) {
  2020. continue;
  2021. }
  2022. property.push(value);
  2023. }
  2024. }
  2025. for (const [name, values] of properties) {
  2026. if (values.length === 1 || !(values[0] instanceof Dict)) {
  2027. mergedDict._map[name] = values[0];
  2028. continue;
  2029. }
  2030. const subDict = new Dict(xref);
  2031. for (const dict of values) {
  2032. for (const [key, value] of Object.entries(dict._map)) {
  2033. if (subDict._map[key] === undefined) {
  2034. subDict._map[key] = value;
  2035. }
  2036. }
  2037. }
  2038. if (subDict.size > 0) {
  2039. mergedDict._map[name] = subDict;
  2040. }
  2041. }
  2042. properties.clear();
  2043. return mergedDict.size > 0 ? mergedDict : Dict.empty;
  2044. }
  2045. }
  2046. exports.Dict = Dict;
  2047. class Ref {
  2048. constructor(num, gen) {
  2049. this.num = num;
  2050. this.gen = gen;
  2051. }
  2052. toString() {
  2053. if (this.gen === 0) {
  2054. return `${this.num}R`;
  2055. }
  2056. return `${this.num}R${this.gen}`;
  2057. }
  2058. static fromString(str) {
  2059. const ref = RefCache[str];
  2060. if (ref) {
  2061. return ref;
  2062. }
  2063. const m = /^(\d+)R(\d*)$/.exec(str);
  2064. if (!m || m[1] === "0") {
  2065. return null;
  2066. }
  2067. return RefCache[str] = new Ref(parseInt(m[1]), !m[2] ? 0 : parseInt(m[2]));
  2068. }
  2069. static get(num, gen) {
  2070. const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
  2071. return RefCache[key] ||= new Ref(num, gen);
  2072. }
  2073. }
  2074. exports.Ref = Ref;
  2075. class RefSet {
  2076. constructor(parent = null) {
  2077. this._set = new Set(parent?._set);
  2078. }
  2079. has(ref) {
  2080. return this._set.has(ref.toString());
  2081. }
  2082. put(ref) {
  2083. this._set.add(ref.toString());
  2084. }
  2085. remove(ref) {
  2086. this._set.delete(ref.toString());
  2087. }
  2088. [Symbol.iterator]() {
  2089. return this._set.values();
  2090. }
  2091. clear() {
  2092. this._set.clear();
  2093. }
  2094. }
  2095. exports.RefSet = RefSet;
  2096. class RefSetCache {
  2097. constructor() {
  2098. this._map = new Map();
  2099. }
  2100. get size() {
  2101. return this._map.size;
  2102. }
  2103. get(ref) {
  2104. return this._map.get(ref.toString());
  2105. }
  2106. has(ref) {
  2107. return this._map.has(ref.toString());
  2108. }
  2109. put(ref, obj) {
  2110. this._map.set(ref.toString(), obj);
  2111. }
  2112. putAlias(ref, aliasRef) {
  2113. this._map.set(ref.toString(), this.get(aliasRef));
  2114. }
  2115. [Symbol.iterator]() {
  2116. return this._map.values();
  2117. }
  2118. clear() {
  2119. this._map.clear();
  2120. }
  2121. }
  2122. exports.RefSetCache = RefSetCache;
  2123. function isName(v, name) {
  2124. return v instanceof Name && (name === undefined || v.name === name);
  2125. }
  2126. function isCmd(v, cmd) {
  2127. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2128. }
  2129. function isDict(v, type) {
  2130. return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
  2131. }
  2132. function isRefsEqual(v1, v2) {
  2133. return v1.num === v2.num && v1.gen === v2.gen;
  2134. }
  2135. /***/ }),
  2136. /* 5 */
  2137. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2138. Object.defineProperty(exports, "__esModule", ({
  2139. value: true
  2140. }));
  2141. exports.BaseStream = void 0;
  2142. var _util = __w_pdfjs_require__(2);
  2143. class BaseStream {
  2144. constructor() {
  2145. if (this.constructor === BaseStream) {
  2146. (0, _util.unreachable)("Cannot initialize BaseStream.");
  2147. }
  2148. }
  2149. get length() {
  2150. (0, _util.unreachable)("Abstract getter `length` accessed");
  2151. }
  2152. get isEmpty() {
  2153. (0, _util.unreachable)("Abstract getter `isEmpty` accessed");
  2154. }
  2155. get isDataLoaded() {
  2156. return (0, _util.shadow)(this, "isDataLoaded", true);
  2157. }
  2158. getByte() {
  2159. (0, _util.unreachable)("Abstract method `getByte` called");
  2160. }
  2161. getBytes(length) {
  2162. (0, _util.unreachable)("Abstract method `getBytes` called");
  2163. }
  2164. peekByte() {
  2165. const peekedByte = this.getByte();
  2166. if (peekedByte !== -1) {
  2167. this.pos--;
  2168. }
  2169. return peekedByte;
  2170. }
  2171. peekBytes(length) {
  2172. const bytes = this.getBytes(length);
  2173. this.pos -= bytes.length;
  2174. return bytes;
  2175. }
  2176. getUint16() {
  2177. const b0 = this.getByte();
  2178. const b1 = this.getByte();
  2179. if (b0 === -1 || b1 === -1) {
  2180. return -1;
  2181. }
  2182. return (b0 << 8) + b1;
  2183. }
  2184. getInt32() {
  2185. const b0 = this.getByte();
  2186. const b1 = this.getByte();
  2187. const b2 = this.getByte();
  2188. const b3 = this.getByte();
  2189. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2190. }
  2191. getByteRange(begin, end) {
  2192. (0, _util.unreachable)("Abstract method `getByteRange` called");
  2193. }
  2194. getString(length) {
  2195. return (0, _util.bytesToString)(this.getBytes(length));
  2196. }
  2197. skip(n) {
  2198. this.pos += n || 1;
  2199. }
  2200. reset() {
  2201. (0, _util.unreachable)("Abstract method `reset` called");
  2202. }
  2203. moveStart() {
  2204. (0, _util.unreachable)("Abstract method `moveStart` called");
  2205. }
  2206. makeSubStream(start, length, dict = null) {
  2207. (0, _util.unreachable)("Abstract method `makeSubStream` called");
  2208. }
  2209. getBaseStreams() {
  2210. return null;
  2211. }
  2212. }
  2213. exports.BaseStream = BaseStream;
  2214. /***/ }),
  2215. /* 6 */
  2216. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2217. Object.defineProperty(exports, "__esModule", ({
  2218. value: true
  2219. }));
  2220. exports.NetworkPdfManager = exports.LocalPdfManager = void 0;
  2221. var _util = __w_pdfjs_require__(2);
  2222. var _chunked_stream = __w_pdfjs_require__(7);
  2223. var _core_utils = __w_pdfjs_require__(3);
  2224. var _document = __w_pdfjs_require__(9);
  2225. var _stream = __w_pdfjs_require__(8);
  2226. function parseDocBaseUrl(url) {
  2227. if (url) {
  2228. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url);
  2229. if (absoluteUrl) {
  2230. return absoluteUrl.href;
  2231. }
  2232. (0, _util.warn)(`Invalid absolute docBaseUrl: "${url}".`);
  2233. }
  2234. return null;
  2235. }
  2236. class BasePdfManager {
  2237. constructor(args) {
  2238. if (this.constructor === BasePdfManager) {
  2239. (0, _util.unreachable)("Cannot initialize BasePdfManager.");
  2240. }
  2241. this._docBaseUrl = parseDocBaseUrl(args.docBaseUrl);
  2242. this._docId = args.docId;
  2243. this._password = args.password;
  2244. this.enableXfa = args.enableXfa;
  2245. args.evaluatorOptions.isOffscreenCanvasSupported &&= _util.FeatureTest.isOffscreenCanvasSupported;
  2246. this.evaluatorOptions = args.evaluatorOptions;
  2247. }
  2248. get docId() {
  2249. return this._docId;
  2250. }
  2251. get password() {
  2252. return this._password;
  2253. }
  2254. get docBaseUrl() {
  2255. const catalog = this.pdfDocument.catalog;
  2256. return (0, _util.shadow)(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
  2257. }
  2258. ensureDoc(prop, args) {
  2259. return this.ensure(this.pdfDocument, prop, args);
  2260. }
  2261. ensureXRef(prop, args) {
  2262. return this.ensure(this.pdfDocument.xref, prop, args);
  2263. }
  2264. ensureCatalog(prop, args) {
  2265. return this.ensure(this.pdfDocument.catalog, prop, args);
  2266. }
  2267. getPage(pageIndex) {
  2268. return this.pdfDocument.getPage(pageIndex);
  2269. }
  2270. fontFallback(id, handler) {
  2271. return this.pdfDocument.fontFallback(id, handler);
  2272. }
  2273. loadXfaFonts(handler, task) {
  2274. return this.pdfDocument.loadXfaFonts(handler, task);
  2275. }
  2276. loadXfaImages() {
  2277. return this.pdfDocument.loadXfaImages();
  2278. }
  2279. serializeXfaData(annotationStorage) {
  2280. return this.pdfDocument.serializeXfaData(annotationStorage);
  2281. }
  2282. cleanup(manuallyTriggered = false) {
  2283. return this.pdfDocument.cleanup(manuallyTriggered);
  2284. }
  2285. async ensure(obj, prop, args) {
  2286. (0, _util.unreachable)("Abstract method `ensure` called");
  2287. }
  2288. requestRange(begin, end) {
  2289. (0, _util.unreachable)("Abstract method `requestRange` called");
  2290. }
  2291. requestLoadedStream(noFetch = false) {
  2292. (0, _util.unreachable)("Abstract method `requestLoadedStream` called");
  2293. }
  2294. sendProgressiveData(chunk) {
  2295. (0, _util.unreachable)("Abstract method `sendProgressiveData` called");
  2296. }
  2297. updatePassword(password) {
  2298. this._password = password;
  2299. }
  2300. terminate(reason) {
  2301. (0, _util.unreachable)("Abstract method `terminate` called");
  2302. }
  2303. }
  2304. class LocalPdfManager extends BasePdfManager {
  2305. constructor(args) {
  2306. super(args);
  2307. const stream = new _stream.Stream(args.source);
  2308. this.pdfDocument = new _document.PDFDocument(this, stream);
  2309. this._loadedStreamPromise = Promise.resolve(stream);
  2310. }
  2311. async ensure(obj, prop, args) {
  2312. const value = obj[prop];
  2313. if (typeof value === "function") {
  2314. return value.apply(obj, args);
  2315. }
  2316. return value;
  2317. }
  2318. requestRange(begin, end) {
  2319. return Promise.resolve();
  2320. }
  2321. requestLoadedStream(noFetch = false) {
  2322. return this._loadedStreamPromise;
  2323. }
  2324. terminate(reason) {}
  2325. }
  2326. exports.LocalPdfManager = LocalPdfManager;
  2327. class NetworkPdfManager extends BasePdfManager {
  2328. constructor(args) {
  2329. super(args);
  2330. this.streamManager = new _chunked_stream.ChunkedStreamManager(args.source, {
  2331. msgHandler: args.handler,
  2332. length: args.length,
  2333. disableAutoFetch: args.disableAutoFetch,
  2334. rangeChunkSize: args.rangeChunkSize
  2335. });
  2336. this.pdfDocument = new _document.PDFDocument(this, this.streamManager.getStream());
  2337. }
  2338. async ensure(obj, prop, args) {
  2339. try {
  2340. const value = obj[prop];
  2341. if (typeof value === "function") {
  2342. return value.apply(obj, args);
  2343. }
  2344. return value;
  2345. } catch (ex) {
  2346. if (!(ex instanceof _core_utils.MissingDataException)) {
  2347. throw ex;
  2348. }
  2349. await this.requestRange(ex.begin, ex.end);
  2350. return this.ensure(obj, prop, args);
  2351. }
  2352. }
  2353. requestRange(begin, end) {
  2354. return this.streamManager.requestRange(begin, end);
  2355. }
  2356. requestLoadedStream(noFetch = false) {
  2357. return this.streamManager.requestAllChunks(noFetch);
  2358. }
  2359. sendProgressiveData(chunk) {
  2360. this.streamManager.onReceiveData({
  2361. chunk
  2362. });
  2363. }
  2364. terminate(reason) {
  2365. this.streamManager.abort(reason);
  2366. }
  2367. }
  2368. exports.NetworkPdfManager = NetworkPdfManager;
  2369. /***/ }),
  2370. /* 7 */
  2371. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2372. Object.defineProperty(exports, "__esModule", ({
  2373. value: true
  2374. }));
  2375. exports.ChunkedStreamManager = exports.ChunkedStream = void 0;
  2376. var _core_utils = __w_pdfjs_require__(3);
  2377. var _util = __w_pdfjs_require__(2);
  2378. var _stream = __w_pdfjs_require__(8);
  2379. class ChunkedStream extends _stream.Stream {
  2380. constructor(length, chunkSize, manager) {
  2381. super(new Uint8Array(length), 0, length, null);
  2382. this.chunkSize = chunkSize;
  2383. this._loadedChunks = new Set();
  2384. this.numChunks = Math.ceil(length / chunkSize);
  2385. this.manager = manager;
  2386. this.progressiveDataLength = 0;
  2387. this.lastSuccessfulEnsureByteChunk = -1;
  2388. }
  2389. getMissingChunks() {
  2390. const chunks = [];
  2391. for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  2392. if (!this._loadedChunks.has(chunk)) {
  2393. chunks.push(chunk);
  2394. }
  2395. }
  2396. return chunks;
  2397. }
  2398. get numChunksLoaded() {
  2399. return this._loadedChunks.size;
  2400. }
  2401. get isDataLoaded() {
  2402. return this.numChunksLoaded === this.numChunks;
  2403. }
  2404. onReceiveData(begin, chunk) {
  2405. const chunkSize = this.chunkSize;
  2406. if (begin % chunkSize !== 0) {
  2407. throw new Error(`Bad begin offset: ${begin}`);
  2408. }
  2409. const end = begin + chunk.byteLength;
  2410. if (end % chunkSize !== 0 && end !== this.bytes.length) {
  2411. throw new Error(`Bad end offset: ${end}`);
  2412. }
  2413. this.bytes.set(new Uint8Array(chunk), begin);
  2414. const beginChunk = Math.floor(begin / chunkSize);
  2415. const endChunk = Math.floor((end - 1) / chunkSize) + 1;
  2416. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  2417. this._loadedChunks.add(curChunk);
  2418. }
  2419. }
  2420. onReceiveProgressiveData(data) {
  2421. let position = this.progressiveDataLength;
  2422. const beginChunk = Math.floor(position / this.chunkSize);
  2423. this.bytes.set(new Uint8Array(data), position);
  2424. position += data.byteLength;
  2425. this.progressiveDataLength = position;
  2426. const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  2427. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  2428. this._loadedChunks.add(curChunk);
  2429. }
  2430. }
  2431. ensureByte(pos) {
  2432. if (pos < this.progressiveDataLength) {
  2433. return;
  2434. }
  2435. const chunk = Math.floor(pos / this.chunkSize);
  2436. if (chunk > this.numChunks) {
  2437. return;
  2438. }
  2439. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  2440. return;
  2441. }
  2442. if (!this._loadedChunks.has(chunk)) {
  2443. throw new _core_utils.MissingDataException(pos, pos + 1);
  2444. }
  2445. this.lastSuccessfulEnsureByteChunk = chunk;
  2446. }
  2447. ensureRange(begin, end) {
  2448. if (begin >= end) {
  2449. return;
  2450. }
  2451. if (end <= this.progressiveDataLength) {
  2452. return;
  2453. }
  2454. const beginChunk = Math.floor(begin / this.chunkSize);
  2455. if (beginChunk > this.numChunks) {
  2456. return;
  2457. }
  2458. const endChunk = Math.min(Math.floor((end - 1) / this.chunkSize) + 1, this.numChunks);
  2459. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2460. if (!this._loadedChunks.has(chunk)) {
  2461. throw new _core_utils.MissingDataException(begin, end);
  2462. }
  2463. }
  2464. }
  2465. nextEmptyChunk(beginChunk) {
  2466. const numChunks = this.numChunks;
  2467. for (let i = 0; i < numChunks; ++i) {
  2468. const chunk = (beginChunk + i) % numChunks;
  2469. if (!this._loadedChunks.has(chunk)) {
  2470. return chunk;
  2471. }
  2472. }
  2473. return null;
  2474. }
  2475. hasChunk(chunk) {
  2476. return this._loadedChunks.has(chunk);
  2477. }
  2478. getByte() {
  2479. const pos = this.pos;
  2480. if (pos >= this.end) {
  2481. return -1;
  2482. }
  2483. if (pos >= this.progressiveDataLength) {
  2484. this.ensureByte(pos);
  2485. }
  2486. return this.bytes[this.pos++];
  2487. }
  2488. getBytes(length) {
  2489. const bytes = this.bytes;
  2490. const pos = this.pos;
  2491. const strEnd = this.end;
  2492. if (!length) {
  2493. if (strEnd > this.progressiveDataLength) {
  2494. this.ensureRange(pos, strEnd);
  2495. }
  2496. return bytes.subarray(pos, strEnd);
  2497. }
  2498. let end = pos + length;
  2499. if (end > strEnd) {
  2500. end = strEnd;
  2501. }
  2502. if (end > this.progressiveDataLength) {
  2503. this.ensureRange(pos, end);
  2504. }
  2505. this.pos = end;
  2506. return bytes.subarray(pos, end);
  2507. }
  2508. getByteRange(begin, end) {
  2509. if (begin < 0) {
  2510. begin = 0;
  2511. }
  2512. if (end > this.end) {
  2513. end = this.end;
  2514. }
  2515. if (end > this.progressiveDataLength) {
  2516. this.ensureRange(begin, end);
  2517. }
  2518. return this.bytes.subarray(begin, end);
  2519. }
  2520. makeSubStream(start, length, dict = null) {
  2521. if (length) {
  2522. if (start + length > this.progressiveDataLength) {
  2523. this.ensureRange(start, start + length);
  2524. }
  2525. } else if (start >= this.progressiveDataLength) {
  2526. this.ensureByte(start);
  2527. }
  2528. function ChunkedStreamSubstream() {}
  2529. ChunkedStreamSubstream.prototype = Object.create(this);
  2530. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  2531. const chunkSize = this.chunkSize;
  2532. const beginChunk = Math.floor(this.start / chunkSize);
  2533. const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  2534. const missingChunks = [];
  2535. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2536. if (!this._loadedChunks.has(chunk)) {
  2537. missingChunks.push(chunk);
  2538. }
  2539. }
  2540. return missingChunks;
  2541. };
  2542. Object.defineProperty(ChunkedStreamSubstream.prototype, "isDataLoaded", {
  2543. get() {
  2544. if (this.numChunksLoaded === this.numChunks) {
  2545. return true;
  2546. }
  2547. return this.getMissingChunks().length === 0;
  2548. },
  2549. configurable: true
  2550. });
  2551. const subStream = new ChunkedStreamSubstream();
  2552. subStream.pos = subStream.start = start;
  2553. subStream.end = start + length || this.end;
  2554. subStream.dict = dict;
  2555. return subStream;
  2556. }
  2557. getBaseStreams() {
  2558. return [this];
  2559. }
  2560. }
  2561. exports.ChunkedStream = ChunkedStream;
  2562. class ChunkedStreamManager {
  2563. constructor(pdfNetworkStream, args) {
  2564. this.length = args.length;
  2565. this.chunkSize = args.rangeChunkSize;
  2566. this.stream = new ChunkedStream(this.length, this.chunkSize, this);
  2567. this.pdfNetworkStream = pdfNetworkStream;
  2568. this.disableAutoFetch = args.disableAutoFetch;
  2569. this.msgHandler = args.msgHandler;
  2570. this.currRequestId = 0;
  2571. this._chunksNeededByRequest = new Map();
  2572. this._requestsByChunk = new Map();
  2573. this._promisesByRequest = new Map();
  2574. this.progressiveDataLength = 0;
  2575. this.aborted = false;
  2576. this._loadedStreamCapability = new _util.PromiseCapability();
  2577. }
  2578. sendRequest(begin, end) {
  2579. const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  2580. if (!rangeReader.isStreamingSupported) {
  2581. rangeReader.onProgress = this.onProgress.bind(this);
  2582. }
  2583. let chunks = [],
  2584. loaded = 0;
  2585. return new Promise((resolve, reject) => {
  2586. const readChunk = ({
  2587. value,
  2588. done
  2589. }) => {
  2590. try {
  2591. if (done) {
  2592. const chunkData = (0, _core_utils.arrayBuffersToBytes)(chunks);
  2593. chunks = null;
  2594. resolve(chunkData);
  2595. return;
  2596. }
  2597. loaded += value.byteLength;
  2598. if (rangeReader.isStreamingSupported) {
  2599. this.onProgress({
  2600. loaded
  2601. });
  2602. }
  2603. chunks.push(value);
  2604. rangeReader.read().then(readChunk, reject);
  2605. } catch (e) {
  2606. reject(e);
  2607. }
  2608. };
  2609. rangeReader.read().then(readChunk, reject);
  2610. }).then(data => {
  2611. if (this.aborted) {
  2612. return;
  2613. }
  2614. this.onReceiveData({
  2615. chunk: data,
  2616. begin
  2617. });
  2618. });
  2619. }
  2620. requestAllChunks(noFetch = false) {
  2621. if (!noFetch) {
  2622. const missingChunks = this.stream.getMissingChunks();
  2623. this._requestChunks(missingChunks);
  2624. }
  2625. return this._loadedStreamCapability.promise;
  2626. }
  2627. _requestChunks(chunks) {
  2628. const requestId = this.currRequestId++;
  2629. const chunksNeeded = new Set();
  2630. this._chunksNeededByRequest.set(requestId, chunksNeeded);
  2631. for (const chunk of chunks) {
  2632. if (!this.stream.hasChunk(chunk)) {
  2633. chunksNeeded.add(chunk);
  2634. }
  2635. }
  2636. if (chunksNeeded.size === 0) {
  2637. return Promise.resolve();
  2638. }
  2639. const capability = new _util.PromiseCapability();
  2640. this._promisesByRequest.set(requestId, capability);
  2641. const chunksToRequest = [];
  2642. for (const chunk of chunksNeeded) {
  2643. let requestIds = this._requestsByChunk.get(chunk);
  2644. if (!requestIds) {
  2645. requestIds = [];
  2646. this._requestsByChunk.set(chunk, requestIds);
  2647. chunksToRequest.push(chunk);
  2648. }
  2649. requestIds.push(requestId);
  2650. }
  2651. if (chunksToRequest.length > 0) {
  2652. const groupedChunksToRequest = this.groupChunks(chunksToRequest);
  2653. for (const groupedChunk of groupedChunksToRequest) {
  2654. const begin = groupedChunk.beginChunk * this.chunkSize;
  2655. const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  2656. this.sendRequest(begin, end).catch(capability.reject);
  2657. }
  2658. }
  2659. return capability.promise.catch(reason => {
  2660. if (this.aborted) {
  2661. return;
  2662. }
  2663. throw reason;
  2664. });
  2665. }
  2666. getStream() {
  2667. return this.stream;
  2668. }
  2669. requestRange(begin, end) {
  2670. end = Math.min(end, this.length);
  2671. const beginChunk = this.getBeginChunk(begin);
  2672. const endChunk = this.getEndChunk(end);
  2673. const chunks = [];
  2674. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2675. chunks.push(chunk);
  2676. }
  2677. return this._requestChunks(chunks);
  2678. }
  2679. requestRanges(ranges = []) {
  2680. const chunksToRequest = [];
  2681. for (const range of ranges) {
  2682. const beginChunk = this.getBeginChunk(range.begin);
  2683. const endChunk = this.getEndChunk(range.end);
  2684. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2685. if (!chunksToRequest.includes(chunk)) {
  2686. chunksToRequest.push(chunk);
  2687. }
  2688. }
  2689. }
  2690. chunksToRequest.sort(function (a, b) {
  2691. return a - b;
  2692. });
  2693. return this._requestChunks(chunksToRequest);
  2694. }
  2695. groupChunks(chunks) {
  2696. const groupedChunks = [];
  2697. let beginChunk = -1;
  2698. let prevChunk = -1;
  2699. for (let i = 0, ii = chunks.length; i < ii; ++i) {
  2700. const chunk = chunks[i];
  2701. if (beginChunk < 0) {
  2702. beginChunk = chunk;
  2703. }
  2704. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  2705. groupedChunks.push({
  2706. beginChunk,
  2707. endChunk: prevChunk + 1
  2708. });
  2709. beginChunk = chunk;
  2710. }
  2711. if (i + 1 === chunks.length) {
  2712. groupedChunks.push({
  2713. beginChunk,
  2714. endChunk: chunk + 1
  2715. });
  2716. }
  2717. prevChunk = chunk;
  2718. }
  2719. return groupedChunks;
  2720. }
  2721. onProgress(args) {
  2722. this.msgHandler.send("DocProgress", {
  2723. loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
  2724. total: this.length
  2725. });
  2726. }
  2727. onReceiveData(args) {
  2728. const chunk = args.chunk;
  2729. const isProgressive = args.begin === undefined;
  2730. const begin = isProgressive ? this.progressiveDataLength : args.begin;
  2731. const end = begin + chunk.byteLength;
  2732. const beginChunk = Math.floor(begin / this.chunkSize);
  2733. const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  2734. if (isProgressive) {
  2735. this.stream.onReceiveProgressiveData(chunk);
  2736. this.progressiveDataLength = end;
  2737. } else {
  2738. this.stream.onReceiveData(begin, chunk);
  2739. }
  2740. if (this.stream.isDataLoaded) {
  2741. this._loadedStreamCapability.resolve(this.stream);
  2742. }
  2743. const loadedRequests = [];
  2744. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  2745. const requestIds = this._requestsByChunk.get(curChunk);
  2746. if (!requestIds) {
  2747. continue;
  2748. }
  2749. this._requestsByChunk.delete(curChunk);
  2750. for (const requestId of requestIds) {
  2751. const chunksNeeded = this._chunksNeededByRequest.get(requestId);
  2752. if (chunksNeeded.has(curChunk)) {
  2753. chunksNeeded.delete(curChunk);
  2754. }
  2755. if (chunksNeeded.size > 0) {
  2756. continue;
  2757. }
  2758. loadedRequests.push(requestId);
  2759. }
  2760. }
  2761. if (!this.disableAutoFetch && this._requestsByChunk.size === 0) {
  2762. let nextEmptyChunk;
  2763. if (this.stream.numChunksLoaded === 1) {
  2764. const lastChunk = this.stream.numChunks - 1;
  2765. if (!this.stream.hasChunk(lastChunk)) {
  2766. nextEmptyChunk = lastChunk;
  2767. }
  2768. } else {
  2769. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  2770. }
  2771. if (Number.isInteger(nextEmptyChunk)) {
  2772. this._requestChunks([nextEmptyChunk]);
  2773. }
  2774. }
  2775. for (const requestId of loadedRequests) {
  2776. const capability = this._promisesByRequest.get(requestId);
  2777. this._promisesByRequest.delete(requestId);
  2778. capability.resolve();
  2779. }
  2780. this.msgHandler.send("DocProgress", {
  2781. loaded: this.stream.numChunksLoaded * this.chunkSize,
  2782. total: this.length
  2783. });
  2784. }
  2785. onError(err) {
  2786. this._loadedStreamCapability.reject(err);
  2787. }
  2788. getBeginChunk(begin) {
  2789. return Math.floor(begin / this.chunkSize);
  2790. }
  2791. getEndChunk(end) {
  2792. return Math.floor((end - 1) / this.chunkSize) + 1;
  2793. }
  2794. abort(reason) {
  2795. this.aborted = true;
  2796. this.pdfNetworkStream?.cancelAllRequests(reason);
  2797. for (const capability of this._promisesByRequest.values()) {
  2798. capability.reject(reason);
  2799. }
  2800. }
  2801. }
  2802. exports.ChunkedStreamManager = ChunkedStreamManager;
  2803. /***/ }),
  2804. /* 8 */
  2805. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2806. Object.defineProperty(exports, "__esModule", ({
  2807. value: true
  2808. }));
  2809. exports.StringStream = exports.Stream = exports.NullStream = void 0;
  2810. var _base_stream = __w_pdfjs_require__(5);
  2811. var _util = __w_pdfjs_require__(2);
  2812. class Stream extends _base_stream.BaseStream {
  2813. constructor(arrayBuffer, start, length, dict) {
  2814. super();
  2815. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2816. this.start = start || 0;
  2817. this.pos = this.start;
  2818. this.end = start + length || this.bytes.length;
  2819. this.dict = dict;
  2820. }
  2821. get length() {
  2822. return this.end - this.start;
  2823. }
  2824. get isEmpty() {
  2825. return this.length === 0;
  2826. }
  2827. getByte() {
  2828. if (this.pos >= this.end) {
  2829. return -1;
  2830. }
  2831. return this.bytes[this.pos++];
  2832. }
  2833. getBytes(length) {
  2834. const bytes = this.bytes;
  2835. const pos = this.pos;
  2836. const strEnd = this.end;
  2837. if (!length) {
  2838. return bytes.subarray(pos, strEnd);
  2839. }
  2840. let end = pos + length;
  2841. if (end > strEnd) {
  2842. end = strEnd;
  2843. }
  2844. this.pos = end;
  2845. return bytes.subarray(pos, end);
  2846. }
  2847. getByteRange(begin, end) {
  2848. if (begin < 0) {
  2849. begin = 0;
  2850. }
  2851. if (end > this.end) {
  2852. end = this.end;
  2853. }
  2854. return this.bytes.subarray(begin, end);
  2855. }
  2856. reset() {
  2857. this.pos = this.start;
  2858. }
  2859. moveStart() {
  2860. this.start = this.pos;
  2861. }
  2862. makeSubStream(start, length, dict = null) {
  2863. return new Stream(this.bytes.buffer, start, length, dict);
  2864. }
  2865. }
  2866. exports.Stream = Stream;
  2867. class StringStream extends Stream {
  2868. constructor(str) {
  2869. super((0, _util.stringToBytes)(str));
  2870. }
  2871. }
  2872. exports.StringStream = StringStream;
  2873. class NullStream extends Stream {
  2874. constructor() {
  2875. super(new Uint8Array(0));
  2876. }
  2877. }
  2878. exports.NullStream = NullStream;
  2879. /***/ }),
  2880. /* 9 */
  2881. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2882. Object.defineProperty(exports, "__esModule", ({
  2883. value: true
  2884. }));
  2885. exports.Page = exports.PDFDocument = void 0;
  2886. var _util = __w_pdfjs_require__(2);
  2887. var _annotation = __w_pdfjs_require__(10);
  2888. var _core_utils = __w_pdfjs_require__(3);
  2889. var _primitives = __w_pdfjs_require__(4);
  2890. var _xfa_fonts = __w_pdfjs_require__(51);
  2891. var _base_stream = __w_pdfjs_require__(5);
  2892. var _crypto = __w_pdfjs_require__(68);
  2893. var _catalog = __w_pdfjs_require__(70);
  2894. var _cleanup_helper = __w_pdfjs_require__(72);
  2895. var _dataset_reader = __w_pdfjs_require__(102);
  2896. var _parser = __w_pdfjs_require__(16);
  2897. var _stream = __w_pdfjs_require__(8);
  2898. var _object_loader = __w_pdfjs_require__(76);
  2899. var _operator_list = __w_pdfjs_require__(64);
  2900. var _evaluator = __w_pdfjs_require__(13);
  2901. var _decode_stream = __w_pdfjs_require__(18);
  2902. var _struct_tree = __w_pdfjs_require__(75);
  2903. var _writer = __w_pdfjs_require__(66);
  2904. var _factory = __w_pdfjs_require__(77);
  2905. var _xref = __w_pdfjs_require__(103);
  2906. const DEFAULT_USER_UNIT = 1.0;
  2907. const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
  2908. class Page {
  2909. constructor({
  2910. pdfManager,
  2911. xref,
  2912. pageIndex,
  2913. pageDict,
  2914. ref,
  2915. globalIdFactory,
  2916. fontCache,
  2917. builtInCMapCache,
  2918. standardFontDataCache,
  2919. globalImageCache,
  2920. systemFontCache,
  2921. nonBlendModesSet,
  2922. xfaFactory
  2923. }) {
  2924. this.pdfManager = pdfManager;
  2925. this.pageIndex = pageIndex;
  2926. this.pageDict = pageDict;
  2927. this.xref = xref;
  2928. this.ref = ref;
  2929. this.fontCache = fontCache;
  2930. this.builtInCMapCache = builtInCMapCache;
  2931. this.standardFontDataCache = standardFontDataCache;
  2932. this.globalImageCache = globalImageCache;
  2933. this.systemFontCache = systemFontCache;
  2934. this.nonBlendModesSet = nonBlendModesSet;
  2935. this.evaluatorOptions = pdfManager.evaluatorOptions;
  2936. this.resourcesPromise = null;
  2937. this.xfaFactory = xfaFactory;
  2938. const idCounters = {
  2939. obj: 0
  2940. };
  2941. this._localIdFactory = class extends globalIdFactory {
  2942. static createObjId() {
  2943. return `p${pageIndex}_${++idCounters.obj}`;
  2944. }
  2945. static getPageObjId() {
  2946. return `p${ref.toString()}`;
  2947. }
  2948. };
  2949. }
  2950. _getInheritableProperty(key, getArray = false) {
  2951. const value = (0, _core_utils.getInheritableProperty)({
  2952. dict: this.pageDict,
  2953. key,
  2954. getArray,
  2955. stopWhenFound: false
  2956. });
  2957. if (!Array.isArray(value)) {
  2958. return value;
  2959. }
  2960. if (value.length === 1 || !(value[0] instanceof _primitives.Dict)) {
  2961. return value[0];
  2962. }
  2963. return _primitives.Dict.merge({
  2964. xref: this.xref,
  2965. dictArray: value
  2966. });
  2967. }
  2968. get content() {
  2969. return this.pageDict.getArray("Contents");
  2970. }
  2971. get resources() {
  2972. const resources = this._getInheritableProperty("Resources");
  2973. return (0, _util.shadow)(this, "resources", resources instanceof _primitives.Dict ? resources : _primitives.Dict.empty);
  2974. }
  2975. _getBoundingBox(name) {
  2976. if (this.xfaData) {
  2977. return this.xfaData.bbox;
  2978. }
  2979. let box = this._getInheritableProperty(name, true);
  2980. if (Array.isArray(box) && box.length === 4) {
  2981. box = _util.Util.normalizeRect(box);
  2982. if (box[2] - box[0] > 0 && box[3] - box[1] > 0) {
  2983. return box;
  2984. }
  2985. (0, _util.warn)(`Empty, or invalid, /${name} entry.`);
  2986. }
  2987. return null;
  2988. }
  2989. get mediaBox() {
  2990. return (0, _util.shadow)(this, "mediaBox", this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX);
  2991. }
  2992. get cropBox() {
  2993. return (0, _util.shadow)(this, "cropBox", this._getBoundingBox("CropBox") || this.mediaBox);
  2994. }
  2995. get userUnit() {
  2996. let obj = this.pageDict.get("UserUnit");
  2997. if (typeof obj !== "number" || obj <= 0) {
  2998. obj = DEFAULT_USER_UNIT;
  2999. }
  3000. return (0, _util.shadow)(this, "userUnit", obj);
  3001. }
  3002. get view() {
  3003. const {
  3004. cropBox,
  3005. mediaBox
  3006. } = this;
  3007. if (cropBox !== mediaBox && !(0, _util.isArrayEqual)(cropBox, mediaBox)) {
  3008. const box = _util.Util.intersect(cropBox, mediaBox);
  3009. if (box && box[2] - box[0] > 0 && box[3] - box[1] > 0) {
  3010. return (0, _util.shadow)(this, "view", box);
  3011. }
  3012. (0, _util.warn)("Empty /CropBox and /MediaBox intersection.");
  3013. }
  3014. return (0, _util.shadow)(this, "view", mediaBox);
  3015. }
  3016. get rotate() {
  3017. let rotate = this._getInheritableProperty("Rotate") || 0;
  3018. if (rotate % 90 !== 0) {
  3019. rotate = 0;
  3020. } else if (rotate >= 360) {
  3021. rotate %= 360;
  3022. } else if (rotate < 0) {
  3023. rotate = (rotate % 360 + 360) % 360;
  3024. }
  3025. return (0, _util.shadow)(this, "rotate", rotate);
  3026. }
  3027. _onSubStreamError(reason, objId) {
  3028. if (this.evaluatorOptions.ignoreErrors) {
  3029. (0, _util.warn)(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
  3030. return;
  3031. }
  3032. throw reason;
  3033. }
  3034. getContentStream() {
  3035. return this.pdfManager.ensure(this, "content").then(content => {
  3036. if (content instanceof _base_stream.BaseStream) {
  3037. return content;
  3038. }
  3039. if (Array.isArray(content)) {
  3040. return new _decode_stream.StreamsSequenceStream(content, this._onSubStreamError.bind(this));
  3041. }
  3042. return new _stream.NullStream();
  3043. });
  3044. }
  3045. get xfaData() {
  3046. return (0, _util.shadow)(this, "xfaData", this.xfaFactory ? {
  3047. bbox: this.xfaFactory.getBoundingBox(this.pageIndex)
  3048. } : null);
  3049. }
  3050. #replaceIdByRef(annotations, deletedAnnotations, existingAnnotations) {
  3051. for (const annotation of annotations) {
  3052. if (annotation.id) {
  3053. const ref = _primitives.Ref.fromString(annotation.id);
  3054. if (!ref) {
  3055. (0, _util.warn)(`A non-linked annotation cannot be modified: ${annotation.id}`);
  3056. continue;
  3057. }
  3058. if (annotation.deleted) {
  3059. deletedAnnotations.put(ref);
  3060. continue;
  3061. }
  3062. existingAnnotations?.put(ref);
  3063. annotation.ref = ref;
  3064. delete annotation.id;
  3065. }
  3066. }
  3067. }
  3068. async saveNewAnnotations(handler, task, annotations, imagePromises) {
  3069. if (this.xfaFactory) {
  3070. throw new Error("XFA: Cannot save new annotations.");
  3071. }
  3072. const partialEvaluator = new _evaluator.PartialEvaluator({
  3073. xref: this.xref,
  3074. handler,
  3075. pageIndex: this.pageIndex,
  3076. idFactory: this._localIdFactory,
  3077. fontCache: this.fontCache,
  3078. builtInCMapCache: this.builtInCMapCache,
  3079. standardFontDataCache: this.standardFontDataCache,
  3080. globalImageCache: this.globalImageCache,
  3081. systemFontCache: this.systemFontCache,
  3082. options: this.evaluatorOptions
  3083. });
  3084. const deletedAnnotations = new _primitives.RefSet();
  3085. const existingAnnotations = new _primitives.RefSet();
  3086. this.#replaceIdByRef(annotations, deletedAnnotations, existingAnnotations);
  3087. const pageDict = this.pageDict;
  3088. const annotationsArray = this.annotations.filter(a => !(a instanceof _primitives.Ref && deletedAnnotations.has(a)));
  3089. const newData = await _annotation.AnnotationFactory.saveNewAnnotations(partialEvaluator, task, annotations, imagePromises);
  3090. for (const {
  3091. ref
  3092. } of newData.annotations) {
  3093. if (ref instanceof _primitives.Ref && !existingAnnotations.has(ref)) {
  3094. annotationsArray.push(ref);
  3095. }
  3096. }
  3097. const savedDict = pageDict.get("Annots");
  3098. pageDict.set("Annots", annotationsArray);
  3099. const buffer = [];
  3100. let transform = null;
  3101. if (this.xref.encrypt) {
  3102. transform = this.xref.encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  3103. }
  3104. await (0, _writer.writeObject)(this.ref, pageDict, buffer, transform);
  3105. if (savedDict) {
  3106. pageDict.set("Annots", savedDict);
  3107. }
  3108. const objects = newData.dependencies;
  3109. objects.push({
  3110. ref: this.ref,
  3111. data: buffer.join("")
  3112. }, ...newData.annotations);
  3113. return objects;
  3114. }
  3115. save(handler, task, annotationStorage) {
  3116. const partialEvaluator = new _evaluator.PartialEvaluator({
  3117. xref: this.xref,
  3118. handler,
  3119. pageIndex: this.pageIndex,
  3120. idFactory: this._localIdFactory,
  3121. fontCache: this.fontCache,
  3122. builtInCMapCache: this.builtInCMapCache,
  3123. standardFontDataCache: this.standardFontDataCache,
  3124. globalImageCache: this.globalImageCache,
  3125. systemFontCache: this.systemFontCache,
  3126. options: this.evaluatorOptions
  3127. });
  3128. return this._parsedAnnotations.then(function (annotations) {
  3129. const newRefsPromises = [];
  3130. for (const annotation of annotations) {
  3131. if (!annotation.mustBePrinted(annotationStorage)) {
  3132. continue;
  3133. }
  3134. newRefsPromises.push(annotation.save(partialEvaluator, task, annotationStorage).catch(function (reason) {
  3135. (0, _util.warn)("save - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  3136. return null;
  3137. }));
  3138. }
  3139. return Promise.all(newRefsPromises).then(function (newRefs) {
  3140. return newRefs.filter(newRef => !!newRef);
  3141. });
  3142. });
  3143. }
  3144. loadResources(keys) {
  3145. if (!this.resourcesPromise) {
  3146. this.resourcesPromise = this.pdfManager.ensure(this, "resources");
  3147. }
  3148. return this.resourcesPromise.then(() => {
  3149. const objectLoader = new _object_loader.ObjectLoader(this.resources, keys, this.xref);
  3150. return objectLoader.load();
  3151. });
  3152. }
  3153. getOperatorList({
  3154. handler,
  3155. sink,
  3156. task,
  3157. intent,
  3158. cacheKey,
  3159. annotationStorage = null
  3160. }) {
  3161. const contentStreamPromise = this.getContentStream();
  3162. const resourcesPromise = this.loadResources(["ColorSpace", "ExtGState", "Font", "Pattern", "Properties", "Shading", "XObject"]);
  3163. const partialEvaluator = new _evaluator.PartialEvaluator({
  3164. xref: this.xref,
  3165. handler,
  3166. pageIndex: this.pageIndex,
  3167. idFactory: this._localIdFactory,
  3168. fontCache: this.fontCache,
  3169. builtInCMapCache: this.builtInCMapCache,
  3170. standardFontDataCache: this.standardFontDataCache,
  3171. globalImageCache: this.globalImageCache,
  3172. systemFontCache: this.systemFontCache,
  3173. options: this.evaluatorOptions
  3174. });
  3175. const newAnnotationsByPage = !this.xfaFactory ? (0, _core_utils.getNewAnnotationsMap)(annotationStorage) : null;
  3176. let deletedAnnotations = null;
  3177. let newAnnotationsPromise = Promise.resolve(null);
  3178. if (newAnnotationsByPage) {
  3179. let imagePromises;
  3180. const newAnnotations = newAnnotationsByPage.get(this.pageIndex);
  3181. if (newAnnotations) {
  3182. const missingBitmaps = new Set();
  3183. for (const {
  3184. bitmapId,
  3185. bitmap
  3186. } of newAnnotations) {
  3187. if (bitmapId && !bitmap && !missingBitmaps.has(bitmapId)) {
  3188. missingBitmaps.add(bitmapId);
  3189. }
  3190. }
  3191. const {
  3192. isOffscreenCanvasSupported
  3193. } = this.evaluatorOptions;
  3194. if (missingBitmaps.size > 0) {
  3195. const annotationWithBitmaps = newAnnotations.slice();
  3196. for (const [key, annotation] of annotationStorage) {
  3197. if (!key.startsWith(_util.AnnotationEditorPrefix)) {
  3198. continue;
  3199. }
  3200. if (annotation.bitmap && missingBitmaps.has(annotation.bitmapId)) {
  3201. annotationWithBitmaps.push(annotation);
  3202. }
  3203. }
  3204. imagePromises = _annotation.AnnotationFactory.generateImages(annotationWithBitmaps, this.xref, isOffscreenCanvasSupported);
  3205. } else {
  3206. imagePromises = _annotation.AnnotationFactory.generateImages(newAnnotations, this.xref, isOffscreenCanvasSupported);
  3207. }
  3208. deletedAnnotations = new _primitives.RefSet();
  3209. this.#replaceIdByRef(newAnnotations, deletedAnnotations, null);
  3210. newAnnotationsPromise = _annotation.AnnotationFactory.printNewAnnotations(partialEvaluator, task, newAnnotations, imagePromises);
  3211. }
  3212. }
  3213. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  3214. const pageListPromise = dataPromises.then(([contentStream]) => {
  3215. const opList = new _operator_list.OperatorList(intent, sink);
  3216. handler.send("StartRenderPage", {
  3217. transparency: partialEvaluator.hasBlendModes(this.resources, this.nonBlendModesSet),
  3218. pageIndex: this.pageIndex,
  3219. cacheKey
  3220. });
  3221. return partialEvaluator.getOperatorList({
  3222. stream: contentStream,
  3223. task,
  3224. resources: this.resources,
  3225. operatorList: opList
  3226. }).then(function () {
  3227. return opList;
  3228. });
  3229. });
  3230. return Promise.all([pageListPromise, this._parsedAnnotations, newAnnotationsPromise]).then(function ([pageOpList, annotations, newAnnotations]) {
  3231. if (newAnnotations) {
  3232. annotations = annotations.filter(a => !(a.ref && deletedAnnotations.has(a.ref)));
  3233. for (let i = 0, ii = newAnnotations.length; i < ii; i++) {
  3234. const newAnnotation = newAnnotations[i];
  3235. if (newAnnotation.refToReplace) {
  3236. const j = annotations.findIndex(a => a.ref && (0, _primitives.isRefsEqual)(a.ref, newAnnotation.refToReplace));
  3237. if (j >= 0) {
  3238. annotations.splice(j, 1, newAnnotation);
  3239. newAnnotations.splice(i--, 1);
  3240. ii--;
  3241. }
  3242. }
  3243. }
  3244. annotations = annotations.concat(newAnnotations);
  3245. }
  3246. if (annotations.length === 0 || intent & _util.RenderingIntentFlag.ANNOTATIONS_DISABLE) {
  3247. pageOpList.flush(true);
  3248. return {
  3249. length: pageOpList.totalLength
  3250. };
  3251. }
  3252. const renderForms = !!(intent & _util.RenderingIntentFlag.ANNOTATIONS_FORMS),
  3253. intentAny = !!(intent & _util.RenderingIntentFlag.ANY),
  3254. intentDisplay = !!(intent & _util.RenderingIntentFlag.DISPLAY),
  3255. intentPrint = !!(intent & _util.RenderingIntentFlag.PRINT);
  3256. const opListPromises = [];
  3257. for (const annotation of annotations) {
  3258. if (intentAny || intentDisplay && annotation.mustBeViewed(annotationStorage, renderForms) || intentPrint && annotation.mustBePrinted(annotationStorage)) {
  3259. opListPromises.push(annotation.getOperatorList(partialEvaluator, task, intent, renderForms, annotationStorage).catch(function (reason) {
  3260. (0, _util.warn)("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  3261. return {
  3262. opList: null,
  3263. separateForm: false,
  3264. separateCanvas: false
  3265. };
  3266. }));
  3267. }
  3268. }
  3269. return Promise.all(opListPromises).then(function (opLists) {
  3270. let form = false,
  3271. canvas = false;
  3272. for (const {
  3273. opList,
  3274. separateForm,
  3275. separateCanvas
  3276. } of opLists) {
  3277. pageOpList.addOpList(opList);
  3278. form ||= separateForm;
  3279. canvas ||= separateCanvas;
  3280. }
  3281. pageOpList.flush(true, {
  3282. form,
  3283. canvas
  3284. });
  3285. return {
  3286. length: pageOpList.totalLength
  3287. };
  3288. });
  3289. });
  3290. }
  3291. extractTextContent({
  3292. handler,
  3293. task,
  3294. includeMarkedContent,
  3295. disableNormalization,
  3296. sink
  3297. }) {
  3298. const contentStreamPromise = this.getContentStream();
  3299. const resourcesPromise = this.loadResources(["ExtGState", "Font", "Properties", "XObject"]);
  3300. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  3301. return dataPromises.then(([contentStream]) => {
  3302. const partialEvaluator = new _evaluator.PartialEvaluator({
  3303. xref: this.xref,
  3304. handler,
  3305. pageIndex: this.pageIndex,
  3306. idFactory: this._localIdFactory,
  3307. fontCache: this.fontCache,
  3308. builtInCMapCache: this.builtInCMapCache,
  3309. standardFontDataCache: this.standardFontDataCache,
  3310. globalImageCache: this.globalImageCache,
  3311. systemFontCache: this.systemFontCache,
  3312. options: this.evaluatorOptions
  3313. });
  3314. return partialEvaluator.getTextContent({
  3315. stream: contentStream,
  3316. task,
  3317. resources: this.resources,
  3318. includeMarkedContent,
  3319. disableNormalization,
  3320. sink,
  3321. viewBox: this.view
  3322. });
  3323. });
  3324. }
  3325. async getStructTree() {
  3326. const structTreeRoot = await this.pdfManager.ensureCatalog("structTreeRoot");
  3327. if (!structTreeRoot) {
  3328. return null;
  3329. }
  3330. const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
  3331. return structTree.serializable;
  3332. }
  3333. _parseStructTree(structTreeRoot) {
  3334. const tree = new _struct_tree.StructTreePage(structTreeRoot, this.pageDict);
  3335. tree.parse();
  3336. return tree;
  3337. }
  3338. async getAnnotationsData(handler, task, intent) {
  3339. const annotations = await this._parsedAnnotations;
  3340. if (annotations.length === 0) {
  3341. return [];
  3342. }
  3343. const annotationsData = [],
  3344. textContentPromises = [];
  3345. let partialEvaluator;
  3346. const intentAny = !!(intent & _util.RenderingIntentFlag.ANY),
  3347. intentDisplay = !!(intent & _util.RenderingIntentFlag.DISPLAY),
  3348. intentPrint = !!(intent & _util.RenderingIntentFlag.PRINT);
  3349. for (const annotation of annotations) {
  3350. const isVisible = intentAny || intentDisplay && annotation.viewable;
  3351. if (isVisible || intentPrint && annotation.printable) {
  3352. annotationsData.push(annotation.data);
  3353. }
  3354. if (annotation.hasTextContent && isVisible) {
  3355. partialEvaluator ||= new _evaluator.PartialEvaluator({
  3356. xref: this.xref,
  3357. handler,
  3358. pageIndex: this.pageIndex,
  3359. idFactory: this._localIdFactory,
  3360. fontCache: this.fontCache,
  3361. builtInCMapCache: this.builtInCMapCache,
  3362. standardFontDataCache: this.standardFontDataCache,
  3363. globalImageCache: this.globalImageCache,
  3364. systemFontCache: this.systemFontCache,
  3365. options: this.evaluatorOptions
  3366. });
  3367. textContentPromises.push(annotation.extractTextContent(partialEvaluator, task, [-Infinity, -Infinity, Infinity, Infinity]).catch(function (reason) {
  3368. (0, _util.warn)(`getAnnotationsData - ignoring textContent during "${task.name}" task: "${reason}".`);
  3369. }));
  3370. }
  3371. }
  3372. await Promise.all(textContentPromises);
  3373. return annotationsData;
  3374. }
  3375. get annotations() {
  3376. const annots = this._getInheritableProperty("Annots");
  3377. return (0, _util.shadow)(this, "annotations", Array.isArray(annots) ? annots : []);
  3378. }
  3379. get _parsedAnnotations() {
  3380. const parsedAnnotations = this.pdfManager.ensure(this, "annotations").then(() => {
  3381. const annotationPromises = [];
  3382. for (const annotationRef of this.annotations) {
  3383. annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this._localIdFactory, false).catch(function (reason) {
  3384. (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
  3385. return null;
  3386. }));
  3387. }
  3388. return Promise.all(annotationPromises).then(function (annotations) {
  3389. if (annotations.length === 0) {
  3390. return annotations;
  3391. }
  3392. const sortedAnnotations = [];
  3393. let popupAnnotations;
  3394. for (const annotation of annotations) {
  3395. if (!annotation) {
  3396. continue;
  3397. }
  3398. if (annotation instanceof _annotation.PopupAnnotation) {
  3399. (popupAnnotations ||= []).push(annotation);
  3400. continue;
  3401. }
  3402. sortedAnnotations.push(annotation);
  3403. }
  3404. if (popupAnnotations) {
  3405. sortedAnnotations.push(...popupAnnotations);
  3406. }
  3407. return sortedAnnotations;
  3408. });
  3409. });
  3410. return (0, _util.shadow)(this, "_parsedAnnotations", parsedAnnotations);
  3411. }
  3412. get jsActions() {
  3413. const actions = (0, _core_utils.collectActions)(this.xref, this.pageDict, _util.PageActionEventType);
  3414. return (0, _util.shadow)(this, "jsActions", actions);
  3415. }
  3416. }
  3417. exports.Page = Page;
  3418. const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
  3419. const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
  3420. const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
  3421. const FINGERPRINT_FIRST_BYTES = 1024;
  3422. const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
  3423. function find(stream, signature, limit = 1024, backwards = false) {
  3424. const signatureLength = signature.length;
  3425. const scanBytes = stream.peekBytes(limit);
  3426. const scanLength = scanBytes.length - signatureLength;
  3427. if (scanLength <= 0) {
  3428. return false;
  3429. }
  3430. if (backwards) {
  3431. const signatureEnd = signatureLength - 1;
  3432. let pos = scanBytes.length - 1;
  3433. while (pos >= signatureEnd) {
  3434. let j = 0;
  3435. while (j < signatureLength && scanBytes[pos - j] === signature[signatureEnd - j]) {
  3436. j++;
  3437. }
  3438. if (j >= signatureLength) {
  3439. stream.pos += pos - signatureEnd;
  3440. return true;
  3441. }
  3442. pos--;
  3443. }
  3444. } else {
  3445. let pos = 0;
  3446. while (pos <= scanLength) {
  3447. let j = 0;
  3448. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  3449. j++;
  3450. }
  3451. if (j >= signatureLength) {
  3452. stream.pos += pos;
  3453. return true;
  3454. }
  3455. pos++;
  3456. }
  3457. }
  3458. return false;
  3459. }
  3460. class PDFDocument {
  3461. constructor(pdfManager, stream) {
  3462. if (stream.length <= 0) {
  3463. throw new _util.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");
  3464. }
  3465. this.pdfManager = pdfManager;
  3466. this.stream = stream;
  3467. this.xref = new _xref.XRef(stream, pdfManager);
  3468. this._pagePromises = new Map();
  3469. this._version = null;
  3470. const idCounters = {
  3471. font: 0
  3472. };
  3473. this._globalIdFactory = class {
  3474. static getDocId() {
  3475. return `g_${pdfManager.docId}`;
  3476. }
  3477. static createFontId() {
  3478. return `f${++idCounters.font}`;
  3479. }
  3480. static createObjId() {
  3481. (0, _util.unreachable)("Abstract method `createObjId` called.");
  3482. }
  3483. static getPageObjId() {
  3484. (0, _util.unreachable)("Abstract method `getPageObjId` called.");
  3485. }
  3486. };
  3487. }
  3488. parse(recoveryMode) {
  3489. this.xref.parse(recoveryMode);
  3490. this.catalog = new _catalog.Catalog(this.pdfManager, this.xref);
  3491. }
  3492. get linearization() {
  3493. let linearization = null;
  3494. try {
  3495. linearization = _parser.Linearization.create(this.stream);
  3496. } catch (err) {
  3497. if (err instanceof _core_utils.MissingDataException) {
  3498. throw err;
  3499. }
  3500. (0, _util.info)(err);
  3501. }
  3502. return (0, _util.shadow)(this, "linearization", linearization);
  3503. }
  3504. get startXRef() {
  3505. const stream = this.stream;
  3506. let startXRef = 0;
  3507. if (this.linearization) {
  3508. stream.reset();
  3509. if (find(stream, ENDOBJ_SIGNATURE)) {
  3510. startXRef = stream.pos + 6 - stream.start;
  3511. }
  3512. } else {
  3513. const step = 1024;
  3514. const startXRefLength = STARTXREF_SIGNATURE.length;
  3515. let found = false,
  3516. pos = stream.end;
  3517. while (!found && pos > 0) {
  3518. pos -= step - startXRefLength;
  3519. if (pos < 0) {
  3520. pos = 0;
  3521. }
  3522. stream.pos = pos;
  3523. found = find(stream, STARTXREF_SIGNATURE, step, true);
  3524. }
  3525. if (found) {
  3526. stream.skip(9);
  3527. let ch;
  3528. do {
  3529. ch = stream.getByte();
  3530. } while ((0, _core_utils.isWhiteSpace)(ch));
  3531. let str = "";
  3532. while (ch >= 0x20 && ch <= 0x39) {
  3533. str += String.fromCharCode(ch);
  3534. ch = stream.getByte();
  3535. }
  3536. startXRef = parseInt(str, 10);
  3537. if (isNaN(startXRef)) {
  3538. startXRef = 0;
  3539. }
  3540. }
  3541. }
  3542. return (0, _util.shadow)(this, "startXRef", startXRef);
  3543. }
  3544. checkHeader() {
  3545. const stream = this.stream;
  3546. stream.reset();
  3547. if (!find(stream, PDF_HEADER_SIGNATURE)) {
  3548. return;
  3549. }
  3550. stream.moveStart();
  3551. stream.skip(PDF_HEADER_SIGNATURE.length);
  3552. let version = "",
  3553. ch;
  3554. while ((ch = stream.getByte()) > 0x20 && version.length < 7) {
  3555. version += String.fromCharCode(ch);
  3556. }
  3557. if (_core_utils.PDF_VERSION_REGEXP.test(version)) {
  3558. this._version = version;
  3559. } else {
  3560. (0, _util.warn)(`Invalid PDF header version: ${version}`);
  3561. }
  3562. }
  3563. parseStartXRef() {
  3564. this.xref.setStartXRef(this.startXRef);
  3565. }
  3566. get numPages() {
  3567. let num = 0;
  3568. if (this.catalog.hasActualNumPages) {
  3569. num = this.catalog.numPages;
  3570. } else if (this.xfaFactory) {
  3571. num = this.xfaFactory.getNumPages();
  3572. } else if (this.linearization) {
  3573. num = this.linearization.numPages;
  3574. } else {
  3575. num = this.catalog.numPages;
  3576. }
  3577. return (0, _util.shadow)(this, "numPages", num);
  3578. }
  3579. _hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
  3580. const RECURSION_LIMIT = 10;
  3581. if (!Array.isArray(fields)) {
  3582. return false;
  3583. }
  3584. return fields.every(field => {
  3585. field = this.xref.fetchIfRef(field);
  3586. if (!(field instanceof _primitives.Dict)) {
  3587. return false;
  3588. }
  3589. if (field.has("Kids")) {
  3590. if (++recursionDepth > RECURSION_LIMIT) {
  3591. (0, _util.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");
  3592. return false;
  3593. }
  3594. return this._hasOnlyDocumentSignatures(field.get("Kids"), recursionDepth);
  3595. }
  3596. const isSignature = (0, _primitives.isName)(field.get("FT"), "Sig");
  3597. const rectangle = field.get("Rect");
  3598. const isInvisible = Array.isArray(rectangle) && rectangle.every(value => value === 0);
  3599. return isSignature && isInvisible;
  3600. });
  3601. }
  3602. get _xfaStreams() {
  3603. const acroForm = this.catalog.acroForm;
  3604. if (!acroForm) {
  3605. return null;
  3606. }
  3607. const xfa = acroForm.get("XFA");
  3608. const entries = {
  3609. "xdp:xdp": "",
  3610. template: "",
  3611. datasets: "",
  3612. config: "",
  3613. connectionSet: "",
  3614. localeSet: "",
  3615. stylesheet: "",
  3616. "/xdp:xdp": ""
  3617. };
  3618. if (xfa instanceof _base_stream.BaseStream && !xfa.isEmpty) {
  3619. entries["xdp:xdp"] = xfa;
  3620. return entries;
  3621. }
  3622. if (!Array.isArray(xfa) || xfa.length === 0) {
  3623. return null;
  3624. }
  3625. for (let i = 0, ii = xfa.length; i < ii; i += 2) {
  3626. let name;
  3627. if (i === 0) {
  3628. name = "xdp:xdp";
  3629. } else if (i === ii - 2) {
  3630. name = "/xdp:xdp";
  3631. } else {
  3632. name = xfa[i];
  3633. }
  3634. if (!entries.hasOwnProperty(name)) {
  3635. continue;
  3636. }
  3637. const data = this.xref.fetchIfRef(xfa[i + 1]);
  3638. if (!(data instanceof _base_stream.BaseStream) || data.isEmpty) {
  3639. continue;
  3640. }
  3641. entries[name] = data;
  3642. }
  3643. return entries;
  3644. }
  3645. get xfaDatasets() {
  3646. const streams = this._xfaStreams;
  3647. if (!streams) {
  3648. return (0, _util.shadow)(this, "xfaDatasets", null);
  3649. }
  3650. for (const key of ["datasets", "xdp:xdp"]) {
  3651. const stream = streams[key];
  3652. if (!stream) {
  3653. continue;
  3654. }
  3655. try {
  3656. const str = (0, _util.stringToUTF8String)(stream.getString());
  3657. const data = {
  3658. [key]: str
  3659. };
  3660. return (0, _util.shadow)(this, "xfaDatasets", new _dataset_reader.DatasetReader(data));
  3661. } catch {
  3662. (0, _util.warn)("XFA - Invalid utf-8 string.");
  3663. break;
  3664. }
  3665. }
  3666. return (0, _util.shadow)(this, "xfaDatasets", null);
  3667. }
  3668. get xfaData() {
  3669. const streams = this._xfaStreams;
  3670. if (!streams) {
  3671. return null;
  3672. }
  3673. const data = Object.create(null);
  3674. for (const [key, stream] of Object.entries(streams)) {
  3675. if (!stream) {
  3676. continue;
  3677. }
  3678. try {
  3679. data[key] = (0, _util.stringToUTF8String)(stream.getString());
  3680. } catch {
  3681. (0, _util.warn)("XFA - Invalid utf-8 string.");
  3682. return null;
  3683. }
  3684. }
  3685. return data;
  3686. }
  3687. get xfaFactory() {
  3688. let data;
  3689. if (this.pdfManager.enableXfa && this.catalog.needsRendering && this.formInfo.hasXfa && !this.formInfo.hasAcroForm) {
  3690. data = this.xfaData;
  3691. }
  3692. return (0, _util.shadow)(this, "xfaFactory", data ? new _factory.XFAFactory(data) : null);
  3693. }
  3694. get isPureXfa() {
  3695. return this.xfaFactory ? this.xfaFactory.isValid() : false;
  3696. }
  3697. get htmlForXfa() {
  3698. return this.xfaFactory ? this.xfaFactory.getPages() : null;
  3699. }
  3700. async loadXfaImages() {
  3701. const xfaImagesDict = await this.pdfManager.ensureCatalog("xfaImages");
  3702. if (!xfaImagesDict) {
  3703. return;
  3704. }
  3705. const keys = xfaImagesDict.getKeys();
  3706. const objectLoader = new _object_loader.ObjectLoader(xfaImagesDict, keys, this.xref);
  3707. await objectLoader.load();
  3708. const xfaImages = new Map();
  3709. for (const key of keys) {
  3710. const stream = xfaImagesDict.get(key);
  3711. if (stream instanceof _base_stream.BaseStream) {
  3712. xfaImages.set(key, stream.getBytes());
  3713. }
  3714. }
  3715. this.xfaFactory.setImages(xfaImages);
  3716. }
  3717. async loadXfaFonts(handler, task) {
  3718. const acroForm = await this.pdfManager.ensureCatalog("acroForm");
  3719. if (!acroForm) {
  3720. return;
  3721. }
  3722. const resources = await acroForm.getAsync("DR");
  3723. if (!(resources instanceof _primitives.Dict)) {
  3724. return;
  3725. }
  3726. const objectLoader = new _object_loader.ObjectLoader(resources, ["Font"], this.xref);
  3727. await objectLoader.load();
  3728. const fontRes = resources.get("Font");
  3729. if (!(fontRes instanceof _primitives.Dict)) {
  3730. return;
  3731. }
  3732. const options = Object.assign(Object.create(null), this.pdfManager.evaluatorOptions);
  3733. options.useSystemFonts = false;
  3734. const partialEvaluator = new _evaluator.PartialEvaluator({
  3735. xref: this.xref,
  3736. handler,
  3737. pageIndex: -1,
  3738. idFactory: this._globalIdFactory,
  3739. fontCache: this.catalog.fontCache,
  3740. builtInCMapCache: this.catalog.builtInCMapCache,
  3741. standardFontDataCache: this.catalog.standardFontDataCache,
  3742. options
  3743. });
  3744. const operatorList = new _operator_list.OperatorList();
  3745. const pdfFonts = [];
  3746. const initialState = {
  3747. get font() {
  3748. return pdfFonts.at(-1);
  3749. },
  3750. set font(font) {
  3751. pdfFonts.push(font);
  3752. },
  3753. clone() {
  3754. return this;
  3755. }
  3756. };
  3757. const fonts = new Map();
  3758. fontRes.forEach((fontName, font) => {
  3759. fonts.set(fontName, font);
  3760. });
  3761. const promises = [];
  3762. for (const [fontName, font] of fonts) {
  3763. const descriptor = font.get("FontDescriptor");
  3764. if (!(descriptor instanceof _primitives.Dict)) {
  3765. continue;
  3766. }
  3767. let fontFamily = descriptor.get("FontFamily");
  3768. fontFamily = fontFamily.replaceAll(/[ ]+(\d)/g, "$1");
  3769. const fontWeight = descriptor.get("FontWeight");
  3770. const italicAngle = -descriptor.get("ItalicAngle");
  3771. const cssFontInfo = {
  3772. fontFamily,
  3773. fontWeight,
  3774. italicAngle
  3775. };
  3776. if (!(0, _core_utils.validateCSSFont)(cssFontInfo)) {
  3777. continue;
  3778. }
  3779. promises.push(partialEvaluator.handleSetFont(resources, [_primitives.Name.get(fontName), 1], null, operatorList, task, initialState, null, cssFontInfo).catch(function (reason) {
  3780. (0, _util.warn)(`loadXfaFonts: "${reason}".`);
  3781. return null;
  3782. }));
  3783. }
  3784. await Promise.all(promises);
  3785. const missingFonts = this.xfaFactory.setFonts(pdfFonts);
  3786. if (!missingFonts) {
  3787. return;
  3788. }
  3789. options.ignoreErrors = true;
  3790. promises.length = 0;
  3791. pdfFonts.length = 0;
  3792. const reallyMissingFonts = new Set();
  3793. for (const missing of missingFonts) {
  3794. if (!(0, _xfa_fonts.getXfaFontName)(`${missing}-Regular`)) {
  3795. reallyMissingFonts.add(missing);
  3796. }
  3797. }
  3798. if (reallyMissingFonts.size) {
  3799. missingFonts.push("PdfJS-Fallback");
  3800. }
  3801. for (const missing of missingFonts) {
  3802. if (reallyMissingFonts.has(missing)) {
  3803. continue;
  3804. }
  3805. for (const fontInfo of [{
  3806. name: "Regular",
  3807. fontWeight: 400,
  3808. italicAngle: 0
  3809. }, {
  3810. name: "Bold",
  3811. fontWeight: 700,
  3812. italicAngle: 0
  3813. }, {
  3814. name: "Italic",
  3815. fontWeight: 400,
  3816. italicAngle: 12
  3817. }, {
  3818. name: "BoldItalic",
  3819. fontWeight: 700,
  3820. italicAngle: 12
  3821. }]) {
  3822. const name = `${missing}-${fontInfo.name}`;
  3823. const dict = (0, _xfa_fonts.getXfaFontDict)(name);
  3824. promises.push(partialEvaluator.handleSetFont(resources, [_primitives.Name.get(name), 1], null, operatorList, task, initialState, dict, {
  3825. fontFamily: missing,
  3826. fontWeight: fontInfo.fontWeight,
  3827. italicAngle: fontInfo.italicAngle
  3828. }).catch(function (reason) {
  3829. (0, _util.warn)(`loadXfaFonts: "${reason}".`);
  3830. return null;
  3831. }));
  3832. }
  3833. }
  3834. await Promise.all(promises);
  3835. this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts);
  3836. }
  3837. async serializeXfaData(annotationStorage) {
  3838. return this.xfaFactory ? this.xfaFactory.serializeData(annotationStorage) : null;
  3839. }
  3840. get version() {
  3841. return this.catalog.version || this._version;
  3842. }
  3843. get formInfo() {
  3844. const formInfo = {
  3845. hasFields: false,
  3846. hasAcroForm: false,
  3847. hasXfa: false,
  3848. hasSignatures: false
  3849. };
  3850. const acroForm = this.catalog.acroForm;
  3851. if (!acroForm) {
  3852. return (0, _util.shadow)(this, "formInfo", formInfo);
  3853. }
  3854. try {
  3855. const fields = acroForm.get("Fields");
  3856. const hasFields = Array.isArray(fields) && fields.length > 0;
  3857. formInfo.hasFields = hasFields;
  3858. const xfa = acroForm.get("XFA");
  3859. formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof _base_stream.BaseStream && !xfa.isEmpty;
  3860. const sigFlags = acroForm.get("SigFlags");
  3861. const hasSignatures = !!(sigFlags & 0x1);
  3862. const hasOnlyDocumentSignatures = hasSignatures && this._hasOnlyDocumentSignatures(fields);
  3863. formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
  3864. formInfo.hasSignatures = hasSignatures;
  3865. } catch (ex) {
  3866. if (ex instanceof _core_utils.MissingDataException) {
  3867. throw ex;
  3868. }
  3869. (0, _util.warn)(`Cannot fetch form information: "${ex}".`);
  3870. }
  3871. return (0, _util.shadow)(this, "formInfo", formInfo);
  3872. }
  3873. get documentInfo() {
  3874. const docInfo = {
  3875. PDFFormatVersion: this.version,
  3876. Language: this.catalog.lang,
  3877. EncryptFilterName: this.xref.encrypt ? this.xref.encrypt.filterName : null,
  3878. IsLinearized: !!this.linearization,
  3879. IsAcroFormPresent: this.formInfo.hasAcroForm,
  3880. IsXFAPresent: this.formInfo.hasXfa,
  3881. IsCollectionPresent: !!this.catalog.collection,
  3882. IsSignaturesPresent: this.formInfo.hasSignatures
  3883. };
  3884. let infoDict;
  3885. try {
  3886. infoDict = this.xref.trailer.get("Info");
  3887. } catch (err) {
  3888. if (err instanceof _core_utils.MissingDataException) {
  3889. throw err;
  3890. }
  3891. (0, _util.info)("The document information dictionary is invalid.");
  3892. }
  3893. if (!(infoDict instanceof _primitives.Dict)) {
  3894. return (0, _util.shadow)(this, "documentInfo", docInfo);
  3895. }
  3896. for (const key of infoDict.getKeys()) {
  3897. const value = infoDict.get(key);
  3898. switch (key) {
  3899. case "Title":
  3900. case "Author":
  3901. case "Subject":
  3902. case "Keywords":
  3903. case "Creator":
  3904. case "Producer":
  3905. case "CreationDate":
  3906. case "ModDate":
  3907. if (typeof value === "string") {
  3908. docInfo[key] = (0, _util.stringToPDFString)(value);
  3909. continue;
  3910. }
  3911. break;
  3912. case "Trapped":
  3913. if (value instanceof _primitives.Name) {
  3914. docInfo[key] = value;
  3915. continue;
  3916. }
  3917. break;
  3918. default:
  3919. let customValue;
  3920. switch (typeof value) {
  3921. case "string":
  3922. customValue = (0, _util.stringToPDFString)(value);
  3923. break;
  3924. case "number":
  3925. case "boolean":
  3926. customValue = value;
  3927. break;
  3928. default:
  3929. if (value instanceof _primitives.Name) {
  3930. customValue = value;
  3931. }
  3932. break;
  3933. }
  3934. if (customValue === undefined) {
  3935. (0, _util.warn)(`Bad value, for custom key "${key}", in Info: ${value}.`);
  3936. continue;
  3937. }
  3938. if (!docInfo.Custom) {
  3939. docInfo.Custom = Object.create(null);
  3940. }
  3941. docInfo.Custom[key] = customValue;
  3942. continue;
  3943. }
  3944. (0, _util.warn)(`Bad value, for key "${key}", in Info: ${value}.`);
  3945. }
  3946. return (0, _util.shadow)(this, "documentInfo", docInfo);
  3947. }
  3948. get fingerprints() {
  3949. function validate(data) {
  3950. return typeof data === "string" && data.length > 0 && data !== EMPTY_FINGERPRINT;
  3951. }
  3952. function hexString(hash) {
  3953. const buf = [];
  3954. for (const num of hash) {
  3955. const hex = num.toString(16);
  3956. buf.push(hex.padStart(2, "0"));
  3957. }
  3958. return buf.join("");
  3959. }
  3960. const idArray = this.xref.trailer.get("ID");
  3961. let hashOriginal, hashModified;
  3962. if (Array.isArray(idArray) && validate(idArray[0])) {
  3963. hashOriginal = (0, _util.stringToBytes)(idArray[0]);
  3964. if (idArray[1] !== idArray[0] && validate(idArray[1])) {
  3965. hashModified = (0, _util.stringToBytes)(idArray[1]);
  3966. }
  3967. } else {
  3968. hashOriginal = (0, _crypto.calculateMD5)(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  3969. }
  3970. return (0, _util.shadow)(this, "fingerprints", [hexString(hashOriginal), hashModified ? hexString(hashModified) : null]);
  3971. }
  3972. async _getLinearizationPage(pageIndex) {
  3973. const {
  3974. catalog,
  3975. linearization,
  3976. xref
  3977. } = this;
  3978. const ref = _primitives.Ref.get(linearization.objectNumberFirst, 0);
  3979. try {
  3980. const obj = await xref.fetchAsync(ref);
  3981. if (obj instanceof _primitives.Dict) {
  3982. let type = obj.getRaw("Type");
  3983. if (type instanceof _primitives.Ref) {
  3984. type = await xref.fetchAsync(type);
  3985. }
  3986. if ((0, _primitives.isName)(type, "Page") || !obj.has("Type") && !obj.has("Kids")) {
  3987. if (!catalog.pageKidsCountCache.has(ref)) {
  3988. catalog.pageKidsCountCache.put(ref, 1);
  3989. }
  3990. if (!catalog.pageIndexCache.has(ref)) {
  3991. catalog.pageIndexCache.put(ref, 0);
  3992. }
  3993. return [obj, ref];
  3994. }
  3995. }
  3996. throw new _util.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.");
  3997. } catch (reason) {
  3998. (0, _util.warn)(`_getLinearizationPage: "${reason.message}".`);
  3999. return catalog.getPageDict(pageIndex);
  4000. }
  4001. }
  4002. getPage(pageIndex) {
  4003. const cachedPromise = this._pagePromises.get(pageIndex);
  4004. if (cachedPromise) {
  4005. return cachedPromise;
  4006. }
  4007. const {
  4008. catalog,
  4009. linearization,
  4010. xfaFactory
  4011. } = this;
  4012. let promise;
  4013. if (xfaFactory) {
  4014. promise = Promise.resolve([_primitives.Dict.empty, null]);
  4015. } else if (linearization?.pageFirst === pageIndex) {
  4016. promise = this._getLinearizationPage(pageIndex);
  4017. } else {
  4018. promise = catalog.getPageDict(pageIndex);
  4019. }
  4020. promise = promise.then(([pageDict, ref]) => {
  4021. return new Page({
  4022. pdfManager: this.pdfManager,
  4023. xref: this.xref,
  4024. pageIndex,
  4025. pageDict,
  4026. ref,
  4027. globalIdFactory: this._globalIdFactory,
  4028. fontCache: catalog.fontCache,
  4029. builtInCMapCache: catalog.builtInCMapCache,
  4030. standardFontDataCache: catalog.standardFontDataCache,
  4031. globalImageCache: catalog.globalImageCache,
  4032. systemFontCache: catalog.systemFontCache,
  4033. nonBlendModesSet: catalog.nonBlendModesSet,
  4034. xfaFactory
  4035. });
  4036. });
  4037. this._pagePromises.set(pageIndex, promise);
  4038. return promise;
  4039. }
  4040. async checkFirstPage(recoveryMode = false) {
  4041. if (recoveryMode) {
  4042. return;
  4043. }
  4044. try {
  4045. await this.getPage(0);
  4046. } catch (reason) {
  4047. if (reason instanceof _core_utils.XRefEntryException) {
  4048. this._pagePromises.delete(0);
  4049. await this.cleanup();
  4050. throw new _core_utils.XRefParseException();
  4051. }
  4052. }
  4053. }
  4054. async checkLastPage(recoveryMode = false) {
  4055. const {
  4056. catalog,
  4057. pdfManager
  4058. } = this;
  4059. catalog.setActualNumPages();
  4060. let numPages;
  4061. try {
  4062. await Promise.all([pdfManager.ensureDoc("xfaFactory"), pdfManager.ensureDoc("linearization"), pdfManager.ensureCatalog("numPages")]);
  4063. if (this.xfaFactory) {
  4064. return;
  4065. } else if (this.linearization) {
  4066. numPages = this.linearization.numPages;
  4067. } else {
  4068. numPages = catalog.numPages;
  4069. }
  4070. if (!Number.isInteger(numPages)) {
  4071. throw new _util.FormatError("Page count is not an integer.");
  4072. } else if (numPages <= 1) {
  4073. return;
  4074. }
  4075. await this.getPage(numPages - 1);
  4076. } catch (reason) {
  4077. this._pagePromises.delete(numPages - 1);
  4078. await this.cleanup();
  4079. if (reason instanceof _core_utils.XRefEntryException && !recoveryMode) {
  4080. throw new _core_utils.XRefParseException();
  4081. }
  4082. (0, _util.warn)(`checkLastPage - invalid /Pages tree /Count: ${numPages}.`);
  4083. let pagesTree;
  4084. try {
  4085. pagesTree = await catalog.getAllPageDicts(recoveryMode);
  4086. } catch (reasonAll) {
  4087. if (reasonAll instanceof _core_utils.XRefEntryException && !recoveryMode) {
  4088. throw new _core_utils.XRefParseException();
  4089. }
  4090. catalog.setActualNumPages(1);
  4091. return;
  4092. }
  4093. for (const [pageIndex, [pageDict, ref]] of pagesTree) {
  4094. let promise;
  4095. if (pageDict instanceof Error) {
  4096. promise = Promise.reject(pageDict);
  4097. promise.catch(() => {});
  4098. } else {
  4099. promise = Promise.resolve(new Page({
  4100. pdfManager,
  4101. xref: this.xref,
  4102. pageIndex,
  4103. pageDict,
  4104. ref,
  4105. globalIdFactory: this._globalIdFactory,
  4106. fontCache: catalog.fontCache,
  4107. builtInCMapCache: catalog.builtInCMapCache,
  4108. standardFontDataCache: catalog.standardFontDataCache,
  4109. globalImageCache: catalog.globalImageCache,
  4110. systemFontCache: catalog.systemFontCache,
  4111. nonBlendModesSet: catalog.nonBlendModesSet,
  4112. xfaFactory: null
  4113. }));
  4114. }
  4115. this._pagePromises.set(pageIndex, promise);
  4116. }
  4117. catalog.setActualNumPages(pagesTree.size);
  4118. }
  4119. }
  4120. fontFallback(id, handler) {
  4121. return this.catalog.fontFallback(id, handler);
  4122. }
  4123. async cleanup(manuallyTriggered = false) {
  4124. return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _cleanup_helper.clearGlobalCaches)();
  4125. }
  4126. _collectFieldObjects(name, fieldRef, promises) {
  4127. const field = this.xref.fetchIfRef(fieldRef);
  4128. if (field.has("T")) {
  4129. const partName = (0, _util.stringToPDFString)(field.get("T"));
  4130. name = name === "" ? partName : `${name}.${partName}`;
  4131. }
  4132. if (!promises.has(name)) {
  4133. promises.set(name, []);
  4134. }
  4135. promises.get(name).push(_annotation.AnnotationFactory.create(this.xref, fieldRef, this.pdfManager, this._localIdFactory, true).then(annotation => annotation?.getFieldObject()).catch(function (reason) {
  4136. (0, _util.warn)(`_collectFieldObjects: "${reason}".`);
  4137. return null;
  4138. }));
  4139. if (field.has("Kids")) {
  4140. const kids = field.get("Kids");
  4141. for (const kid of kids) {
  4142. this._collectFieldObjects(name, kid, promises);
  4143. }
  4144. }
  4145. }
  4146. get fieldObjects() {
  4147. if (!this.formInfo.hasFields) {
  4148. return (0, _util.shadow)(this, "fieldObjects", Promise.resolve(null));
  4149. }
  4150. const allFields = Object.create(null);
  4151. const fieldPromises = new Map();
  4152. for (const fieldRef of this.catalog.acroForm.get("Fields")) {
  4153. this._collectFieldObjects("", fieldRef, fieldPromises);
  4154. }
  4155. const allPromises = [];
  4156. for (const [name, promises] of fieldPromises) {
  4157. allPromises.push(Promise.all(promises).then(fields => {
  4158. fields = fields.filter(field => !!field);
  4159. if (fields.length > 0) {
  4160. allFields[name] = fields;
  4161. }
  4162. }));
  4163. }
  4164. return (0, _util.shadow)(this, "fieldObjects", Promise.all(allPromises).then(() => allFields));
  4165. }
  4166. get hasJSActions() {
  4167. const promise = this.pdfManager.ensureDoc("_parseHasJSActions");
  4168. return (0, _util.shadow)(this, "hasJSActions", promise);
  4169. }
  4170. async _parseHasJSActions() {
  4171. const [catalogJsActions, fieldObjects] = await Promise.all([this.pdfManager.ensureCatalog("jsActions"), this.pdfManager.ensureDoc("fieldObjects")]);
  4172. if (catalogJsActions) {
  4173. return true;
  4174. }
  4175. if (fieldObjects) {
  4176. return Object.values(fieldObjects).some(fieldObject => fieldObject.some(object => object.actions !== null));
  4177. }
  4178. return false;
  4179. }
  4180. get calculationOrderIds() {
  4181. const acroForm = this.catalog.acroForm;
  4182. if (!acroForm?.has("CO")) {
  4183. return (0, _util.shadow)(this, "calculationOrderIds", null);
  4184. }
  4185. const calculationOrder = acroForm.get("CO");
  4186. if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) {
  4187. return (0, _util.shadow)(this, "calculationOrderIds", null);
  4188. }
  4189. const ids = [];
  4190. for (const id of calculationOrder) {
  4191. if (id instanceof _primitives.Ref) {
  4192. ids.push(id.toString());
  4193. }
  4194. }
  4195. if (ids.length === 0) {
  4196. return (0, _util.shadow)(this, "calculationOrderIds", null);
  4197. }
  4198. return (0, _util.shadow)(this, "calculationOrderIds", ids);
  4199. }
  4200. }
  4201. exports.PDFDocument = PDFDocument;
  4202. /***/ }),
  4203. /* 10 */
  4204. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4205. Object.defineProperty(exports, "__esModule", ({
  4206. value: true
  4207. }));
  4208. exports.PopupAnnotation = exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
  4209. exports.getQuadPoints = getQuadPoints;
  4210. var _util = __w_pdfjs_require__(2);
  4211. var _core_utils = __w_pdfjs_require__(3);
  4212. var _default_appearance = __w_pdfjs_require__(11);
  4213. var _primitives = __w_pdfjs_require__(4);
  4214. var _stream = __w_pdfjs_require__(8);
  4215. var _writer = __w_pdfjs_require__(66);
  4216. var _base_stream = __w_pdfjs_require__(5);
  4217. var _bidi = __w_pdfjs_require__(60);
  4218. var _catalog = __w_pdfjs_require__(70);
  4219. var _colorspace = __w_pdfjs_require__(12);
  4220. var _file_spec = __w_pdfjs_require__(73);
  4221. var _jpeg_stream = __w_pdfjs_require__(26);
  4222. var _object_loader = __w_pdfjs_require__(76);
  4223. var _operator_list = __w_pdfjs_require__(64);
  4224. var _factory = __w_pdfjs_require__(77);
  4225. class AnnotationFactory {
  4226. static create(xref, ref, pdfManager, idFactory, collectFields) {
  4227. return Promise.all([pdfManager.ensureCatalog("acroForm"), pdfManager.ensureCatalog("baseUrl"), pdfManager.ensureCatalog("attachments"), pdfManager.ensureDoc("xfaDatasets"), collectFields ? this._getPageIndex(xref, ref, pdfManager) : -1]).then(([acroForm, baseUrl, attachments, xfaDatasets, pageIndex]) => pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory, acroForm, attachments, xfaDatasets, collectFields, pageIndex]));
  4228. }
  4229. static _create(xref, ref, pdfManager, idFactory, acroForm, attachments = null, xfaDatasets, collectFields, pageIndex = -1) {
  4230. const dict = xref.fetchIfRef(ref);
  4231. if (!(dict instanceof _primitives.Dict)) {
  4232. return undefined;
  4233. }
  4234. const id = ref instanceof _primitives.Ref ? ref.toString() : `annot_${idFactory.createObjId()}`;
  4235. let subtype = dict.get("Subtype");
  4236. subtype = subtype instanceof _primitives.Name ? subtype.name : null;
  4237. const acroFormDict = acroForm instanceof _primitives.Dict ? acroForm : _primitives.Dict.empty;
  4238. const parameters = {
  4239. xref,
  4240. ref,
  4241. dict,
  4242. subtype,
  4243. id,
  4244. pdfManager,
  4245. acroForm: acroFormDict,
  4246. attachments,
  4247. xfaDatasets,
  4248. collectFields,
  4249. needAppearances: !collectFields && acroFormDict.get("NeedAppearances") === true,
  4250. pageIndex,
  4251. evaluatorOptions: pdfManager.evaluatorOptions
  4252. };
  4253. switch (subtype) {
  4254. case "Link":
  4255. return new LinkAnnotation(parameters);
  4256. case "Text":
  4257. return new TextAnnotation(parameters);
  4258. case "Widget":
  4259. let fieldType = (0, _core_utils.getInheritableProperty)({
  4260. dict,
  4261. key: "FT"
  4262. });
  4263. fieldType = fieldType instanceof _primitives.Name ? fieldType.name : null;
  4264. switch (fieldType) {
  4265. case "Tx":
  4266. return new TextWidgetAnnotation(parameters);
  4267. case "Btn":
  4268. return new ButtonWidgetAnnotation(parameters);
  4269. case "Ch":
  4270. return new ChoiceWidgetAnnotation(parameters);
  4271. case "Sig":
  4272. return new SignatureWidgetAnnotation(parameters);
  4273. }
  4274. (0, _util.warn)(`Unimplemented widget field type "${fieldType}", ` + "falling back to base field type.");
  4275. return new WidgetAnnotation(parameters);
  4276. case "Popup":
  4277. return new PopupAnnotation(parameters);
  4278. case "FreeText":
  4279. return new FreeTextAnnotation(parameters);
  4280. case "Line":
  4281. return new LineAnnotation(parameters);
  4282. case "Square":
  4283. return new SquareAnnotation(parameters);
  4284. case "Circle":
  4285. return new CircleAnnotation(parameters);
  4286. case "PolyLine":
  4287. return new PolylineAnnotation(parameters);
  4288. case "Polygon":
  4289. return new PolygonAnnotation(parameters);
  4290. case "Caret":
  4291. return new CaretAnnotation(parameters);
  4292. case "Ink":
  4293. return new InkAnnotation(parameters);
  4294. case "Highlight":
  4295. return new HighlightAnnotation(parameters);
  4296. case "Underline":
  4297. return new UnderlineAnnotation(parameters);
  4298. case "Squiggly":
  4299. return new SquigglyAnnotation(parameters);
  4300. case "StrikeOut":
  4301. return new StrikeOutAnnotation(parameters);
  4302. case "Stamp":
  4303. return new StampAnnotation(parameters);
  4304. case "FileAttachment":
  4305. return new FileAttachmentAnnotation(parameters);
  4306. default:
  4307. if (!collectFields) {
  4308. if (!subtype) {
  4309. (0, _util.warn)("Annotation is missing the required /Subtype.");
  4310. } else {
  4311. (0, _util.warn)(`Unimplemented annotation type "${subtype}", ` + "falling back to base annotation.");
  4312. }
  4313. }
  4314. return new Annotation(parameters);
  4315. }
  4316. }
  4317. static async _getPageIndex(xref, ref, pdfManager) {
  4318. try {
  4319. const annotDict = await xref.fetchIfRefAsync(ref);
  4320. if (!(annotDict instanceof _primitives.Dict)) {
  4321. return -1;
  4322. }
  4323. const pageRef = annotDict.getRaw("P");
  4324. if (pageRef instanceof _primitives.Ref) {
  4325. try {
  4326. const pageIndex = await pdfManager.ensureCatalog("getPageIndex", [pageRef]);
  4327. return pageIndex;
  4328. } catch (ex) {
  4329. (0, _util.info)(`_getPageIndex -- not a valid page reference: "${ex}".`);
  4330. }
  4331. }
  4332. if (annotDict.has("Kids")) {
  4333. return -1;
  4334. }
  4335. const numPages = await pdfManager.ensureDoc("numPages");
  4336. for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
  4337. const page = await pdfManager.getPage(pageIndex);
  4338. const annotations = await pdfManager.ensure(page, "annotations");
  4339. for (const annotRef of annotations) {
  4340. if (annotRef instanceof _primitives.Ref && (0, _primitives.isRefsEqual)(annotRef, ref)) {
  4341. return pageIndex;
  4342. }
  4343. }
  4344. }
  4345. } catch (ex) {
  4346. (0, _util.warn)(`_getPageIndex: "${ex}".`);
  4347. }
  4348. return -1;
  4349. }
  4350. static generateImages(annotations, xref, isOffscreenCanvasSupported) {
  4351. if (!isOffscreenCanvasSupported) {
  4352. (0, _util.warn)("generateImages: OffscreenCanvas is not supported, cannot save or print some annotations with images.");
  4353. return null;
  4354. }
  4355. let imagePromises;
  4356. for (const {
  4357. bitmapId,
  4358. bitmap
  4359. } of annotations) {
  4360. if (!bitmap) {
  4361. continue;
  4362. }
  4363. imagePromises ||= new Map();
  4364. imagePromises.set(bitmapId, StampAnnotation.createImage(bitmap, xref));
  4365. }
  4366. return imagePromises;
  4367. }
  4368. static async saveNewAnnotations(evaluator, task, annotations, imagePromises) {
  4369. const xref = evaluator.xref;
  4370. let baseFontRef;
  4371. const dependencies = [];
  4372. const promises = [];
  4373. const {
  4374. isOffscreenCanvasSupported
  4375. } = evaluator.options;
  4376. for (const annotation of annotations) {
  4377. if (annotation.deleted) {
  4378. continue;
  4379. }
  4380. switch (annotation.annotationType) {
  4381. case _util.AnnotationEditorType.FREETEXT:
  4382. if (!baseFontRef) {
  4383. const baseFont = new _primitives.Dict(xref);
  4384. baseFont.set("BaseFont", _primitives.Name.get("Helvetica"));
  4385. baseFont.set("Type", _primitives.Name.get("Font"));
  4386. baseFont.set("Subtype", _primitives.Name.get("Type1"));
  4387. baseFont.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  4388. const buffer = [];
  4389. baseFontRef = xref.getNewTemporaryRef();
  4390. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(baseFontRef.num, baseFontRef.gen) : null;
  4391. await (0, _writer.writeObject)(baseFontRef, baseFont, buffer, transform);
  4392. dependencies.push({
  4393. ref: baseFontRef,
  4394. data: buffer.join("")
  4395. });
  4396. }
  4397. promises.push(FreeTextAnnotation.createNewAnnotation(xref, annotation, dependencies, {
  4398. evaluator,
  4399. task,
  4400. baseFontRef
  4401. }));
  4402. break;
  4403. case _util.AnnotationEditorType.INK:
  4404. promises.push(InkAnnotation.createNewAnnotation(xref, annotation, dependencies));
  4405. break;
  4406. case _util.AnnotationEditorType.STAMP:
  4407. if (!isOffscreenCanvasSupported) {
  4408. break;
  4409. }
  4410. const image = await imagePromises.get(annotation.bitmapId);
  4411. if (image.imageStream) {
  4412. const {
  4413. imageStream,
  4414. smaskStream
  4415. } = image;
  4416. const buffer = [];
  4417. if (smaskStream) {
  4418. const smaskRef = xref.getNewTemporaryRef();
  4419. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(smaskRef.num, smaskRef.gen) : null;
  4420. await (0, _writer.writeObject)(smaskRef, smaskStream, buffer, transform);
  4421. dependencies.push({
  4422. ref: smaskRef,
  4423. data: buffer.join("")
  4424. });
  4425. imageStream.dict.set("SMask", smaskRef);
  4426. buffer.length = 0;
  4427. }
  4428. const imageRef = image.imageRef = xref.getNewTemporaryRef();
  4429. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(imageRef.num, imageRef.gen) : null;
  4430. await (0, _writer.writeObject)(imageRef, imageStream, buffer, transform);
  4431. dependencies.push({
  4432. ref: imageRef,
  4433. data: buffer.join("")
  4434. });
  4435. image.imageStream = image.smaskStream = null;
  4436. }
  4437. promises.push(StampAnnotation.createNewAnnotation(xref, annotation, dependencies, {
  4438. image
  4439. }));
  4440. break;
  4441. }
  4442. }
  4443. return {
  4444. annotations: await Promise.all(promises),
  4445. dependencies
  4446. };
  4447. }
  4448. static async printNewAnnotations(evaluator, task, annotations, imagePromises) {
  4449. if (!annotations) {
  4450. return null;
  4451. }
  4452. const {
  4453. options,
  4454. xref
  4455. } = evaluator;
  4456. const promises = [];
  4457. for (const annotation of annotations) {
  4458. if (annotation.deleted) {
  4459. continue;
  4460. }
  4461. switch (annotation.annotationType) {
  4462. case _util.AnnotationEditorType.FREETEXT:
  4463. promises.push(FreeTextAnnotation.createNewPrintAnnotation(xref, annotation, {
  4464. evaluator,
  4465. task,
  4466. evaluatorOptions: options
  4467. }));
  4468. break;
  4469. case _util.AnnotationEditorType.INK:
  4470. promises.push(InkAnnotation.createNewPrintAnnotation(xref, annotation, {
  4471. evaluatorOptions: options
  4472. }));
  4473. break;
  4474. case _util.AnnotationEditorType.STAMP:
  4475. if (!options.isOffscreenCanvasSupported) {
  4476. break;
  4477. }
  4478. const image = await imagePromises.get(annotation.bitmapId);
  4479. if (image.imageStream) {
  4480. const {
  4481. imageStream,
  4482. smaskStream
  4483. } = image;
  4484. if (smaskStream) {
  4485. imageStream.dict.set("SMask", smaskStream);
  4486. }
  4487. image.imageRef = new _jpeg_stream.JpegStream(imageStream, imageStream.length);
  4488. image.imageStream = image.smaskStream = null;
  4489. }
  4490. promises.push(StampAnnotation.createNewPrintAnnotation(xref, annotation, {
  4491. image,
  4492. evaluatorOptions: options
  4493. }));
  4494. break;
  4495. }
  4496. }
  4497. return Promise.all(promises);
  4498. }
  4499. }
  4500. exports.AnnotationFactory = AnnotationFactory;
  4501. function getRgbColor(color, defaultColor = new Uint8ClampedArray(3)) {
  4502. if (!Array.isArray(color)) {
  4503. return defaultColor;
  4504. }
  4505. const rgbColor = defaultColor || new Uint8ClampedArray(3);
  4506. switch (color.length) {
  4507. case 0:
  4508. return null;
  4509. case 1:
  4510. _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  4511. return rgbColor;
  4512. case 3:
  4513. _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  4514. return rgbColor;
  4515. case 4:
  4516. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  4517. return rgbColor;
  4518. default:
  4519. return defaultColor;
  4520. }
  4521. }
  4522. function getPdfColorArray(color) {
  4523. return Array.from(color, c => c / 255);
  4524. }
  4525. function getQuadPoints(dict, rect) {
  4526. const quadPoints = dict.getArray("QuadPoints");
  4527. if (!Array.isArray(quadPoints) || quadPoints.length === 0 || quadPoints.length % 8 > 0) {
  4528. return null;
  4529. }
  4530. const quadPointsLists = [];
  4531. for (let i = 0, ii = quadPoints.length / 8; i < ii; i++) {
  4532. let minX = Infinity,
  4533. maxX = -Infinity,
  4534. minY = Infinity,
  4535. maxY = -Infinity;
  4536. for (let j = i * 8, jj = i * 8 + 8; j < jj; j += 2) {
  4537. const x = quadPoints[j];
  4538. const y = quadPoints[j + 1];
  4539. minX = Math.min(x, minX);
  4540. maxX = Math.max(x, maxX);
  4541. minY = Math.min(y, minY);
  4542. maxY = Math.max(y, maxY);
  4543. }
  4544. if (rect !== null && (minX < rect[0] || maxX > rect[2] || minY < rect[1] || maxY > rect[3])) {
  4545. return null;
  4546. }
  4547. quadPointsLists.push([{
  4548. x: minX,
  4549. y: maxY
  4550. }, {
  4551. x: maxX,
  4552. y: maxY
  4553. }, {
  4554. x: minX,
  4555. y: minY
  4556. }, {
  4557. x: maxX,
  4558. y: minY
  4559. }]);
  4560. }
  4561. return quadPointsLists;
  4562. }
  4563. function getTransformMatrix(rect, bbox, matrix) {
  4564. const [minX, minY, maxX, maxY] = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
  4565. if (minX === maxX || minY === maxY) {
  4566. return [1, 0, 0, 1, rect[0], rect[1]];
  4567. }
  4568. const xRatio = (rect[2] - rect[0]) / (maxX - minX);
  4569. const yRatio = (rect[3] - rect[1]) / (maxY - minY);
  4570. return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
  4571. }
  4572. class Annotation {
  4573. constructor(params) {
  4574. const {
  4575. dict,
  4576. xref
  4577. } = params;
  4578. this.setTitle(dict.get("T"));
  4579. this.setContents(dict.get("Contents"));
  4580. this.setModificationDate(dict.get("M"));
  4581. this.setFlags(dict.get("F"));
  4582. this.setRectangle(dict.getArray("Rect"));
  4583. this.setColor(dict.getArray("C"));
  4584. this.setBorderStyle(dict);
  4585. this.setAppearance(dict);
  4586. this.setOptionalContent(dict);
  4587. const MK = dict.get("MK");
  4588. this.setBorderAndBackgroundColors(MK);
  4589. this.setRotation(MK, dict);
  4590. this.ref = params.ref instanceof _primitives.Ref ? params.ref : null;
  4591. this._streams = [];
  4592. if (this.appearance) {
  4593. this._streams.push(this.appearance);
  4594. }
  4595. const isLocked = !!(this.flags & _util.AnnotationFlag.LOCKED);
  4596. const isContentLocked = !!(this.flags & _util.AnnotationFlag.LOCKEDCONTENTS);
  4597. this.data = {
  4598. annotationFlags: this.flags,
  4599. borderStyle: this.borderStyle,
  4600. color: this.color,
  4601. backgroundColor: this.backgroundColor,
  4602. borderColor: this.borderColor,
  4603. rotation: this.rotation,
  4604. contentsObj: this._contents,
  4605. hasAppearance: !!this.appearance,
  4606. id: params.id,
  4607. modificationDate: this.modificationDate,
  4608. rect: this.rectangle,
  4609. subtype: params.subtype,
  4610. hasOwnCanvas: false,
  4611. noRotate: !!(this.flags & _util.AnnotationFlag.NOROTATE),
  4612. noHTML: isLocked && isContentLocked
  4613. };
  4614. if (params.collectFields) {
  4615. const kids = dict.get("Kids");
  4616. if (Array.isArray(kids)) {
  4617. const kidIds = [];
  4618. for (const kid of kids) {
  4619. if (kid instanceof _primitives.Ref) {
  4620. kidIds.push(kid.toString());
  4621. }
  4622. }
  4623. if (kidIds.length !== 0) {
  4624. this.data.kidIds = kidIds;
  4625. }
  4626. }
  4627. this.data.actions = (0, _core_utils.collectActions)(xref, dict, _util.AnnotationActionEventType);
  4628. this.data.fieldName = this._constructFieldName(dict);
  4629. this.data.pageIndex = params.pageIndex;
  4630. }
  4631. this._isOffscreenCanvasSupported = params.evaluatorOptions.isOffscreenCanvasSupported;
  4632. this._fallbackFontDict = null;
  4633. this._needAppearances = false;
  4634. }
  4635. _hasFlag(flags, flag) {
  4636. return !!(flags & flag);
  4637. }
  4638. _isViewable(flags) {
  4639. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
  4640. }
  4641. _isPrintable(flags) {
  4642. return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
  4643. }
  4644. mustBeViewed(annotationStorage, _renderForms) {
  4645. const noView = annotationStorage?.get(this.data.id)?.noView;
  4646. if (noView !== undefined) {
  4647. return !noView;
  4648. }
  4649. return this.viewable && !this._hasFlag(this.flags, _util.AnnotationFlag.HIDDEN);
  4650. }
  4651. mustBePrinted(annotationStorage) {
  4652. const noPrint = annotationStorage?.get(this.data.id)?.noPrint;
  4653. if (noPrint !== undefined) {
  4654. return !noPrint;
  4655. }
  4656. return this.printable;
  4657. }
  4658. get viewable() {
  4659. if (this.data.quadPoints === null) {
  4660. return false;
  4661. }
  4662. if (this.flags === 0) {
  4663. return true;
  4664. }
  4665. return this._isViewable(this.flags);
  4666. }
  4667. get printable() {
  4668. if (this.data.quadPoints === null) {
  4669. return false;
  4670. }
  4671. if (this.flags === 0) {
  4672. return false;
  4673. }
  4674. return this._isPrintable(this.flags);
  4675. }
  4676. _parseStringHelper(data) {
  4677. const str = typeof data === "string" ? (0, _util.stringToPDFString)(data) : "";
  4678. const dir = str && (0, _bidi.bidi)(str).dir === "rtl" ? "rtl" : "ltr";
  4679. return {
  4680. str,
  4681. dir
  4682. };
  4683. }
  4684. setDefaultAppearance(params) {
  4685. const defaultAppearance = (0, _core_utils.getInheritableProperty)({
  4686. dict: params.dict,
  4687. key: "DA"
  4688. }) || params.acroForm.get("DA");
  4689. this._defaultAppearance = typeof defaultAppearance === "string" ? defaultAppearance : "";
  4690. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance);
  4691. }
  4692. setTitle(title) {
  4693. this._title = this._parseStringHelper(title);
  4694. }
  4695. setContents(contents) {
  4696. this._contents = this._parseStringHelper(contents);
  4697. }
  4698. setModificationDate(modificationDate) {
  4699. this.modificationDate = typeof modificationDate === "string" ? modificationDate : null;
  4700. }
  4701. setFlags(flags) {
  4702. this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
  4703. }
  4704. hasFlag(flag) {
  4705. return this._hasFlag(this.flags, flag);
  4706. }
  4707. setRectangle(rectangle) {
  4708. this.rectangle = Array.isArray(rectangle) && rectangle.length === 4 ? _util.Util.normalizeRect(rectangle) : [0, 0, 0, 0];
  4709. }
  4710. setColor(color) {
  4711. this.color = getRgbColor(color);
  4712. }
  4713. setLineEndings(lineEndings) {
  4714. this.lineEndings = ["None", "None"];
  4715. if (Array.isArray(lineEndings) && lineEndings.length === 2) {
  4716. for (let i = 0; i < 2; i++) {
  4717. const obj = lineEndings[i];
  4718. if (obj instanceof _primitives.Name) {
  4719. switch (obj.name) {
  4720. case "None":
  4721. continue;
  4722. case "Square":
  4723. case "Circle":
  4724. case "Diamond":
  4725. case "OpenArrow":
  4726. case "ClosedArrow":
  4727. case "Butt":
  4728. case "ROpenArrow":
  4729. case "RClosedArrow":
  4730. case "Slash":
  4731. this.lineEndings[i] = obj.name;
  4732. continue;
  4733. }
  4734. }
  4735. (0, _util.warn)(`Ignoring invalid lineEnding: ${obj}`);
  4736. }
  4737. }
  4738. }
  4739. setRotation(mk, dict) {
  4740. this.rotation = 0;
  4741. let angle = mk instanceof _primitives.Dict ? mk.get("R") || 0 : dict.get("Rotate") || 0;
  4742. if (Number.isInteger(angle) && angle !== 0) {
  4743. angle %= 360;
  4744. if (angle < 0) {
  4745. angle += 360;
  4746. }
  4747. if (angle % 90 === 0) {
  4748. this.rotation = angle;
  4749. }
  4750. }
  4751. }
  4752. setBorderAndBackgroundColors(mk) {
  4753. if (mk instanceof _primitives.Dict) {
  4754. this.borderColor = getRgbColor(mk.getArray("BC"), null);
  4755. this.backgroundColor = getRgbColor(mk.getArray("BG"), null);
  4756. } else {
  4757. this.borderColor = this.backgroundColor = null;
  4758. }
  4759. }
  4760. setBorderStyle(borderStyle) {
  4761. this.borderStyle = new AnnotationBorderStyle();
  4762. if (!(borderStyle instanceof _primitives.Dict)) {
  4763. return;
  4764. }
  4765. if (borderStyle.has("BS")) {
  4766. const dict = borderStyle.get("BS");
  4767. const dictType = dict.get("Type");
  4768. if (!dictType || (0, _primitives.isName)(dictType, "Border")) {
  4769. this.borderStyle.setWidth(dict.get("W"), this.rectangle);
  4770. this.borderStyle.setStyle(dict.get("S"));
  4771. this.borderStyle.setDashArray(dict.getArray("D"));
  4772. }
  4773. } else if (borderStyle.has("Border")) {
  4774. const array = borderStyle.getArray("Border");
  4775. if (Array.isArray(array) && array.length >= 3) {
  4776. this.borderStyle.setHorizontalCornerRadius(array[0]);
  4777. this.borderStyle.setVerticalCornerRadius(array[1]);
  4778. this.borderStyle.setWidth(array[2], this.rectangle);
  4779. if (array.length === 4) {
  4780. this.borderStyle.setDashArray(array[3], true);
  4781. }
  4782. }
  4783. } else {
  4784. this.borderStyle.setWidth(0);
  4785. }
  4786. }
  4787. setAppearance(dict) {
  4788. this.appearance = null;
  4789. const appearanceStates = dict.get("AP");
  4790. if (!(appearanceStates instanceof _primitives.Dict)) {
  4791. return;
  4792. }
  4793. const normalAppearanceState = appearanceStates.get("N");
  4794. if (normalAppearanceState instanceof _base_stream.BaseStream) {
  4795. this.appearance = normalAppearanceState;
  4796. return;
  4797. }
  4798. if (!(normalAppearanceState instanceof _primitives.Dict)) {
  4799. return;
  4800. }
  4801. const as = dict.get("AS");
  4802. if (!(as instanceof _primitives.Name) || !normalAppearanceState.has(as.name)) {
  4803. return;
  4804. }
  4805. const appearance = normalAppearanceState.get(as.name);
  4806. if (appearance instanceof _base_stream.BaseStream) {
  4807. this.appearance = appearance;
  4808. }
  4809. }
  4810. setOptionalContent(dict) {
  4811. this.oc = null;
  4812. const oc = dict.get("OC");
  4813. if (oc instanceof _primitives.Name) {
  4814. (0, _util.warn)("setOptionalContent: Support for /Name-entry is not implemented.");
  4815. } else if (oc instanceof _primitives.Dict) {
  4816. this.oc = oc;
  4817. }
  4818. }
  4819. loadResources(keys, appearance) {
  4820. return appearance.dict.getAsync("Resources").then(resources => {
  4821. if (!resources) {
  4822. return undefined;
  4823. }
  4824. const objectLoader = new _object_loader.ObjectLoader(resources, keys, resources.xref);
  4825. return objectLoader.load().then(function () {
  4826. return resources;
  4827. });
  4828. });
  4829. }
  4830. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  4831. const data = this.data;
  4832. let appearance = this.appearance;
  4833. const isUsingOwnCanvas = !!(this.data.hasOwnCanvas && intent & _util.RenderingIntentFlag.DISPLAY);
  4834. if (!appearance) {
  4835. if (!isUsingOwnCanvas) {
  4836. return {
  4837. opList: new _operator_list.OperatorList(),
  4838. separateForm: false,
  4839. separateCanvas: false
  4840. };
  4841. }
  4842. appearance = new _stream.StringStream("");
  4843. appearance.dict = new _primitives.Dict();
  4844. }
  4845. const appearanceDict = appearance.dict;
  4846. const resources = await this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"], appearance);
  4847. const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
  4848. const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
  4849. const transform = getTransformMatrix(data.rect, bbox, matrix);
  4850. const opList = new _operator_list.OperatorList();
  4851. let optionalContent;
  4852. if (this.oc) {
  4853. optionalContent = await evaluator.parseMarkedContentProps(this.oc, null);
  4854. }
  4855. if (optionalContent !== undefined) {
  4856. opList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  4857. }
  4858. opList.addOp(_util.OPS.beginAnnotation, [data.id, data.rect, transform, matrix, isUsingOwnCanvas]);
  4859. await evaluator.getOperatorList({
  4860. stream: appearance,
  4861. task,
  4862. resources,
  4863. operatorList: opList,
  4864. fallbackFontDict: this._fallbackFontDict
  4865. });
  4866. opList.addOp(_util.OPS.endAnnotation, []);
  4867. if (optionalContent !== undefined) {
  4868. opList.addOp(_util.OPS.endMarkedContent, []);
  4869. }
  4870. this.reset();
  4871. return {
  4872. opList,
  4873. separateForm: false,
  4874. separateCanvas: isUsingOwnCanvas
  4875. };
  4876. }
  4877. async save(evaluator, task, annotationStorage) {
  4878. return null;
  4879. }
  4880. get hasTextContent() {
  4881. return false;
  4882. }
  4883. async extractTextContent(evaluator, task, viewBox) {
  4884. if (!this.appearance) {
  4885. return;
  4886. }
  4887. const resources = await this.loadResources(["ExtGState", "Font", "Properties", "XObject"], this.appearance);
  4888. const text = [];
  4889. const buffer = [];
  4890. let firstPosition = null;
  4891. const sink = {
  4892. desiredSize: Math.Infinity,
  4893. ready: true,
  4894. enqueue(chunk, size) {
  4895. for (const item of chunk.items) {
  4896. if (item.str === undefined) {
  4897. continue;
  4898. }
  4899. firstPosition ||= item.transform.slice(-2);
  4900. buffer.push(item.str);
  4901. if (item.hasEOL) {
  4902. text.push(buffer.join(""));
  4903. buffer.length = 0;
  4904. }
  4905. }
  4906. }
  4907. };
  4908. await evaluator.getTextContent({
  4909. stream: this.appearance,
  4910. task,
  4911. resources,
  4912. includeMarkedContent: true,
  4913. sink,
  4914. viewBox
  4915. });
  4916. this.reset();
  4917. if (buffer.length) {
  4918. text.push(buffer.join(""));
  4919. }
  4920. if (text.length > 1 || text[0]) {
  4921. const appearanceDict = this.appearance.dict;
  4922. const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
  4923. const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
  4924. const rect = this.data.rect;
  4925. const transform = getTransformMatrix(rect, bbox, matrix);
  4926. transform[4] -= rect[0];
  4927. transform[5] -= rect[1];
  4928. firstPosition = _util.Util.applyTransform(firstPosition, transform);
  4929. firstPosition = _util.Util.applyTransform(firstPosition, matrix);
  4930. this.data.textPosition = firstPosition;
  4931. this.data.textContent = text;
  4932. }
  4933. }
  4934. getFieldObject() {
  4935. if (this.data.kidIds) {
  4936. return {
  4937. id: this.data.id,
  4938. actions: this.data.actions,
  4939. name: this.data.fieldName,
  4940. strokeColor: this.data.borderColor,
  4941. fillColor: this.data.backgroundColor,
  4942. type: "",
  4943. kidIds: this.data.kidIds,
  4944. page: this.data.pageIndex,
  4945. rotation: this.rotation
  4946. };
  4947. }
  4948. return null;
  4949. }
  4950. reset() {
  4951. for (const stream of this._streams) {
  4952. stream.reset();
  4953. }
  4954. }
  4955. _constructFieldName(dict) {
  4956. if (!dict.has("T") && !dict.has("Parent")) {
  4957. (0, _util.warn)("Unknown field name, falling back to empty field name.");
  4958. return "";
  4959. }
  4960. if (!dict.has("Parent")) {
  4961. return (0, _util.stringToPDFString)(dict.get("T"));
  4962. }
  4963. const fieldName = [];
  4964. if (dict.has("T")) {
  4965. fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
  4966. }
  4967. let loopDict = dict;
  4968. const visited = new _primitives.RefSet();
  4969. if (dict.objId) {
  4970. visited.put(dict.objId);
  4971. }
  4972. while (loopDict.has("Parent")) {
  4973. loopDict = loopDict.get("Parent");
  4974. if (!(loopDict instanceof _primitives.Dict) || loopDict.objId && visited.has(loopDict.objId)) {
  4975. break;
  4976. }
  4977. if (loopDict.objId) {
  4978. visited.put(loopDict.objId);
  4979. }
  4980. if (loopDict.has("T")) {
  4981. const t = (0, _util.stringToPDFString)(loopDict.get("T"));
  4982. if (!t.startsWith("#")) {
  4983. fieldName.unshift(t);
  4984. }
  4985. }
  4986. }
  4987. return fieldName.join(".");
  4988. }
  4989. }
  4990. exports.Annotation = Annotation;
  4991. class AnnotationBorderStyle {
  4992. constructor() {
  4993. this.width = 1;
  4994. this.style = _util.AnnotationBorderStyleType.SOLID;
  4995. this.dashArray = [3];
  4996. this.horizontalCornerRadius = 0;
  4997. this.verticalCornerRadius = 0;
  4998. }
  4999. setWidth(width, rect = [0, 0, 0, 0]) {
  5000. if (width instanceof _primitives.Name) {
  5001. this.width = 0;
  5002. return;
  5003. }
  5004. if (typeof width === "number") {
  5005. if (width > 0) {
  5006. const maxWidth = (rect[2] - rect[0]) / 2;
  5007. const maxHeight = (rect[3] - rect[1]) / 2;
  5008. if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
  5009. (0, _util.warn)(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`);
  5010. width = 1;
  5011. }
  5012. }
  5013. this.width = width;
  5014. }
  5015. }
  5016. setStyle(style) {
  5017. if (!(style instanceof _primitives.Name)) {
  5018. return;
  5019. }
  5020. switch (style.name) {
  5021. case "S":
  5022. this.style = _util.AnnotationBorderStyleType.SOLID;
  5023. break;
  5024. case "D":
  5025. this.style = _util.AnnotationBorderStyleType.DASHED;
  5026. break;
  5027. case "B":
  5028. this.style = _util.AnnotationBorderStyleType.BEVELED;
  5029. break;
  5030. case "I":
  5031. this.style = _util.AnnotationBorderStyleType.INSET;
  5032. break;
  5033. case "U":
  5034. this.style = _util.AnnotationBorderStyleType.UNDERLINE;
  5035. break;
  5036. default:
  5037. break;
  5038. }
  5039. }
  5040. setDashArray(dashArray, forceStyle = false) {
  5041. if (Array.isArray(dashArray) && dashArray.length > 0) {
  5042. let isValid = true;
  5043. let allZeros = true;
  5044. for (const element of dashArray) {
  5045. const validNumber = +element >= 0;
  5046. if (!validNumber) {
  5047. isValid = false;
  5048. break;
  5049. } else if (element > 0) {
  5050. allZeros = false;
  5051. }
  5052. }
  5053. if (isValid && !allZeros) {
  5054. this.dashArray = dashArray;
  5055. if (forceStyle) {
  5056. this.setStyle(_primitives.Name.get("D"));
  5057. }
  5058. } else {
  5059. this.width = 0;
  5060. }
  5061. } else if (dashArray) {
  5062. this.width = 0;
  5063. }
  5064. }
  5065. setHorizontalCornerRadius(radius) {
  5066. if (Number.isInteger(radius)) {
  5067. this.horizontalCornerRadius = radius;
  5068. }
  5069. }
  5070. setVerticalCornerRadius(radius) {
  5071. if (Number.isInteger(radius)) {
  5072. this.verticalCornerRadius = radius;
  5073. }
  5074. }
  5075. }
  5076. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  5077. class MarkupAnnotation extends Annotation {
  5078. constructor(params) {
  5079. super(params);
  5080. const {
  5081. dict
  5082. } = params;
  5083. if (dict.has("IRT")) {
  5084. const rawIRT = dict.getRaw("IRT");
  5085. this.data.inReplyTo = rawIRT instanceof _primitives.Ref ? rawIRT.toString() : null;
  5086. const rt = dict.get("RT");
  5087. this.data.replyType = rt instanceof _primitives.Name ? rt.name : _util.AnnotationReplyType.REPLY;
  5088. }
  5089. let popupRef = null;
  5090. if (this.data.replyType === _util.AnnotationReplyType.GROUP) {
  5091. const parent = dict.get("IRT");
  5092. this.setTitle(parent.get("T"));
  5093. this.data.titleObj = this._title;
  5094. this.setContents(parent.get("Contents"));
  5095. this.data.contentsObj = this._contents;
  5096. if (!parent.has("CreationDate")) {
  5097. this.data.creationDate = null;
  5098. } else {
  5099. this.setCreationDate(parent.get("CreationDate"));
  5100. this.data.creationDate = this.creationDate;
  5101. }
  5102. if (!parent.has("M")) {
  5103. this.data.modificationDate = null;
  5104. } else {
  5105. this.setModificationDate(parent.get("M"));
  5106. this.data.modificationDate = this.modificationDate;
  5107. }
  5108. popupRef = parent.getRaw("Popup");
  5109. if (!parent.has("C")) {
  5110. this.data.color = null;
  5111. } else {
  5112. this.setColor(parent.getArray("C"));
  5113. this.data.color = this.color;
  5114. }
  5115. } else {
  5116. this.data.titleObj = this._title;
  5117. this.setCreationDate(dict.get("CreationDate"));
  5118. this.data.creationDate = this.creationDate;
  5119. popupRef = dict.getRaw("Popup");
  5120. if (!dict.has("C")) {
  5121. this.data.color = null;
  5122. }
  5123. }
  5124. this.data.popupRef = popupRef instanceof _primitives.Ref ? popupRef.toString() : null;
  5125. if (dict.has("RC")) {
  5126. this.data.richText = _factory.XFAFactory.getRichTextAsHtml(dict.get("RC"));
  5127. }
  5128. }
  5129. setCreationDate(creationDate) {
  5130. this.creationDate = typeof creationDate === "string" ? creationDate : null;
  5131. }
  5132. _setDefaultAppearance({
  5133. xref,
  5134. extra,
  5135. strokeColor,
  5136. fillColor,
  5137. blendMode,
  5138. strokeAlpha,
  5139. fillAlpha,
  5140. pointsCallback
  5141. }) {
  5142. let minX = Number.MAX_VALUE;
  5143. let minY = Number.MAX_VALUE;
  5144. let maxX = Number.MIN_VALUE;
  5145. let maxY = Number.MIN_VALUE;
  5146. const buffer = ["q"];
  5147. if (extra) {
  5148. buffer.push(extra);
  5149. }
  5150. if (strokeColor) {
  5151. buffer.push(`${strokeColor[0]} ${strokeColor[1]} ${strokeColor[2]} RG`);
  5152. }
  5153. if (fillColor) {
  5154. buffer.push(`${fillColor[0]} ${fillColor[1]} ${fillColor[2]} rg`);
  5155. }
  5156. let pointsArray = this.data.quadPoints;
  5157. if (!pointsArray) {
  5158. pointsArray = [[{
  5159. x: this.rectangle[0],
  5160. y: this.rectangle[3]
  5161. }, {
  5162. x: this.rectangle[2],
  5163. y: this.rectangle[3]
  5164. }, {
  5165. x: this.rectangle[0],
  5166. y: this.rectangle[1]
  5167. }, {
  5168. x: this.rectangle[2],
  5169. y: this.rectangle[1]
  5170. }]];
  5171. }
  5172. for (const points of pointsArray) {
  5173. const [mX, MX, mY, MY] = pointsCallback(buffer, points);
  5174. minX = Math.min(minX, mX);
  5175. maxX = Math.max(maxX, MX);
  5176. minY = Math.min(minY, mY);
  5177. maxY = Math.max(maxY, MY);
  5178. }
  5179. buffer.push("Q");
  5180. const formDict = new _primitives.Dict(xref);
  5181. const appearanceStreamDict = new _primitives.Dict(xref);
  5182. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  5183. const appearanceStream = new _stream.StringStream(buffer.join(" "));
  5184. appearanceStream.dict = appearanceStreamDict;
  5185. formDict.set("Fm0", appearanceStream);
  5186. const gsDict = new _primitives.Dict(xref);
  5187. if (blendMode) {
  5188. gsDict.set("BM", _primitives.Name.get(blendMode));
  5189. }
  5190. if (typeof strokeAlpha === "number") {
  5191. gsDict.set("CA", strokeAlpha);
  5192. }
  5193. if (typeof fillAlpha === "number") {
  5194. gsDict.set("ca", fillAlpha);
  5195. }
  5196. const stateDict = new _primitives.Dict(xref);
  5197. stateDict.set("GS0", gsDict);
  5198. const resources = new _primitives.Dict(xref);
  5199. resources.set("ExtGState", stateDict);
  5200. resources.set("XObject", formDict);
  5201. const appearanceDict = new _primitives.Dict(xref);
  5202. appearanceDict.set("Resources", resources);
  5203. const bbox = this.data.rect = [minX, minY, maxX, maxY];
  5204. appearanceDict.set("BBox", bbox);
  5205. this.appearance = new _stream.StringStream("/GS0 gs /Fm0 Do");
  5206. this.appearance.dict = appearanceDict;
  5207. this._streams.push(this.appearance, appearanceStream);
  5208. }
  5209. static async createNewAnnotation(xref, annotation, dependencies, params) {
  5210. const annotationRef = annotation.ref || xref.getNewTemporaryRef();
  5211. const ap = await this.createNewAppearanceStream(annotation, xref, params);
  5212. const buffer = [];
  5213. let annotationDict;
  5214. if (ap) {
  5215. const apRef = xref.getNewTemporaryRef();
  5216. annotationDict = this.createNewDict(annotation, xref, {
  5217. apRef
  5218. });
  5219. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(apRef.num, apRef.gen) : null;
  5220. await (0, _writer.writeObject)(apRef, ap, buffer, transform);
  5221. dependencies.push({
  5222. ref: apRef,
  5223. data: buffer.join("")
  5224. });
  5225. } else {
  5226. annotationDict = this.createNewDict(annotation, xref, {});
  5227. }
  5228. buffer.length = 0;
  5229. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(annotationRef.num, annotationRef.gen) : null;
  5230. await (0, _writer.writeObject)(annotationRef, annotationDict, buffer, transform);
  5231. return {
  5232. ref: annotationRef,
  5233. data: buffer.join("")
  5234. };
  5235. }
  5236. static async createNewPrintAnnotation(xref, annotation, params) {
  5237. const ap = await this.createNewAppearanceStream(annotation, xref, params);
  5238. const annotationDict = this.createNewDict(annotation, xref, {
  5239. ap
  5240. });
  5241. const newAnnotation = new this.prototype.constructor({
  5242. dict: annotationDict,
  5243. xref,
  5244. evaluatorOptions: params.evaluatorOptions
  5245. });
  5246. if (annotation.ref) {
  5247. newAnnotation.ref = newAnnotation.refToReplace = annotation.ref;
  5248. }
  5249. return newAnnotation;
  5250. }
  5251. }
  5252. exports.MarkupAnnotation = MarkupAnnotation;
  5253. class WidgetAnnotation extends Annotation {
  5254. constructor(params) {
  5255. super(params);
  5256. const {
  5257. dict,
  5258. xref
  5259. } = params;
  5260. const data = this.data;
  5261. this._needAppearances = params.needAppearances;
  5262. data.annotationType = _util.AnnotationType.WIDGET;
  5263. if (data.fieldName === undefined) {
  5264. data.fieldName = this._constructFieldName(dict);
  5265. }
  5266. if (data.actions === undefined) {
  5267. data.actions = (0, _core_utils.collectActions)(xref, dict, _util.AnnotationActionEventType);
  5268. }
  5269. let fieldValue = (0, _core_utils.getInheritableProperty)({
  5270. dict,
  5271. key: "V",
  5272. getArray: true
  5273. });
  5274. data.fieldValue = this._decodeFormValue(fieldValue);
  5275. const defaultFieldValue = (0, _core_utils.getInheritableProperty)({
  5276. dict,
  5277. key: "DV",
  5278. getArray: true
  5279. });
  5280. data.defaultFieldValue = this._decodeFormValue(defaultFieldValue);
  5281. if (fieldValue === undefined && params.xfaDatasets) {
  5282. const path = this._title.str;
  5283. if (path) {
  5284. this._hasValueFromXFA = true;
  5285. data.fieldValue = fieldValue = params.xfaDatasets.getValue(path);
  5286. }
  5287. }
  5288. if (fieldValue === undefined && data.defaultFieldValue !== null) {
  5289. data.fieldValue = data.defaultFieldValue;
  5290. }
  5291. data.alternativeText = (0, _util.stringToPDFString)(dict.get("TU") || "");
  5292. this.setDefaultAppearance(params);
  5293. data.hasAppearance ||= this._needAppearances && data.fieldValue !== undefined && data.fieldValue !== null;
  5294. const fieldType = (0, _core_utils.getInheritableProperty)({
  5295. dict,
  5296. key: "FT"
  5297. });
  5298. data.fieldType = fieldType instanceof _primitives.Name ? fieldType.name : null;
  5299. const localResources = (0, _core_utils.getInheritableProperty)({
  5300. dict,
  5301. key: "DR"
  5302. });
  5303. const acroFormResources = params.acroForm.get("DR");
  5304. const appearanceResources = this.appearance?.dict.get("Resources");
  5305. this._fieldResources = {
  5306. localResources,
  5307. acroFormResources,
  5308. appearanceResources,
  5309. mergedResources: _primitives.Dict.merge({
  5310. xref,
  5311. dictArray: [localResources, appearanceResources, acroFormResources],
  5312. mergeSubDicts: true
  5313. })
  5314. };
  5315. data.fieldFlags = (0, _core_utils.getInheritableProperty)({
  5316. dict,
  5317. key: "Ff"
  5318. });
  5319. if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
  5320. data.fieldFlags = 0;
  5321. }
  5322. data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
  5323. data.required = this.hasFieldFlag(_util.AnnotationFieldFlag.REQUIRED);
  5324. data.hidden = this._hasFlag(data.annotationFlags, _util.AnnotationFlag.HIDDEN) || this._hasFlag(data.annotationFlags, _util.AnnotationFlag.NOVIEW);
  5325. }
  5326. _decodeFormValue(formValue) {
  5327. if (Array.isArray(formValue)) {
  5328. return formValue.filter(item => typeof item === "string").map(item => (0, _util.stringToPDFString)(item));
  5329. } else if (formValue instanceof _primitives.Name) {
  5330. return (0, _util.stringToPDFString)(formValue.name);
  5331. } else if (typeof formValue === "string") {
  5332. return (0, _util.stringToPDFString)(formValue);
  5333. }
  5334. return null;
  5335. }
  5336. hasFieldFlag(flag) {
  5337. return !!(this.data.fieldFlags & flag);
  5338. }
  5339. _isViewable(flags) {
  5340. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
  5341. }
  5342. mustBeViewed(annotationStorage, renderForms) {
  5343. if (renderForms) {
  5344. return this.viewable;
  5345. }
  5346. return super.mustBeViewed(annotationStorage, renderForms) && !this._hasFlag(this.flags, _util.AnnotationFlag.NOVIEW);
  5347. }
  5348. getRotationMatrix(annotationStorage) {
  5349. let rotation = annotationStorage?.get(this.data.id)?.rotation;
  5350. if (rotation === undefined) {
  5351. rotation = this.rotation;
  5352. }
  5353. if (rotation === 0) {
  5354. return _util.IDENTITY_MATRIX;
  5355. }
  5356. const width = this.data.rect[2] - this.data.rect[0];
  5357. const height = this.data.rect[3] - this.data.rect[1];
  5358. return (0, _core_utils.getRotationMatrix)(rotation, width, height);
  5359. }
  5360. getBorderAndBackgroundAppearances(annotationStorage) {
  5361. let rotation = annotationStorage?.get(this.data.id)?.rotation;
  5362. if (rotation === undefined) {
  5363. rotation = this.rotation;
  5364. }
  5365. if (!this.backgroundColor && !this.borderColor) {
  5366. return "";
  5367. }
  5368. const width = this.data.rect[2] - this.data.rect[0];
  5369. const height = this.data.rect[3] - this.data.rect[1];
  5370. const rect = rotation === 0 || rotation === 180 ? `0 0 ${width} ${height} re` : `0 0 ${height} ${width} re`;
  5371. let str = "";
  5372. if (this.backgroundColor) {
  5373. str = `${(0, _default_appearance.getPdfColor)(this.backgroundColor, true)} ${rect} f `;
  5374. }
  5375. if (this.borderColor) {
  5376. const borderWidth = this.borderStyle.width || 1;
  5377. str += `${borderWidth} w ${(0, _default_appearance.getPdfColor)(this.borderColor, false)} ${rect} S `;
  5378. }
  5379. return str;
  5380. }
  5381. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  5382. if (renderForms && !(this instanceof SignatureWidgetAnnotation) && !this.data.noHTML && !this.data.hasOwnCanvas) {
  5383. return {
  5384. opList: new _operator_list.OperatorList(),
  5385. separateForm: true,
  5386. separateCanvas: false
  5387. };
  5388. }
  5389. if (!this._hasText) {
  5390. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  5391. }
  5392. const content = await this._getAppearance(evaluator, task, intent, annotationStorage);
  5393. if (this.appearance && content === null) {
  5394. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  5395. }
  5396. const opList = new _operator_list.OperatorList();
  5397. if (!this._defaultAppearance || content === null) {
  5398. return {
  5399. opList,
  5400. separateForm: false,
  5401. separateCanvas: false
  5402. };
  5403. }
  5404. const isUsingOwnCanvas = !!(this.data.hasOwnCanvas && intent & _util.RenderingIntentFlag.DISPLAY);
  5405. const matrix = [1, 0, 0, 1, 0, 0];
  5406. const bbox = [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]];
  5407. const transform = getTransformMatrix(this.data.rect, bbox, matrix);
  5408. let optionalContent;
  5409. if (this.oc) {
  5410. optionalContent = await evaluator.parseMarkedContentProps(this.oc, null);
  5411. }
  5412. if (optionalContent !== undefined) {
  5413. opList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  5414. }
  5415. opList.addOp(_util.OPS.beginAnnotation, [this.data.id, this.data.rect, transform, this.getRotationMatrix(annotationStorage), isUsingOwnCanvas]);
  5416. const stream = new _stream.StringStream(content);
  5417. await evaluator.getOperatorList({
  5418. stream,
  5419. task,
  5420. resources: this._fieldResources.mergedResources,
  5421. operatorList: opList
  5422. });
  5423. opList.addOp(_util.OPS.endAnnotation, []);
  5424. if (optionalContent !== undefined) {
  5425. opList.addOp(_util.OPS.endMarkedContent, []);
  5426. }
  5427. return {
  5428. opList,
  5429. separateForm: false,
  5430. separateCanvas: isUsingOwnCanvas
  5431. };
  5432. }
  5433. _getMKDict(rotation) {
  5434. const mk = new _primitives.Dict(null);
  5435. if (rotation) {
  5436. mk.set("R", rotation);
  5437. }
  5438. if (this.borderColor) {
  5439. mk.set("BC", getPdfColorArray(this.borderColor));
  5440. }
  5441. if (this.backgroundColor) {
  5442. mk.set("BG", getPdfColorArray(this.backgroundColor));
  5443. }
  5444. return mk.size > 0 ? mk : null;
  5445. }
  5446. amendSavedDict(annotationStorage, dict) {}
  5447. async save(evaluator, task, annotationStorage) {
  5448. const storageEntry = annotationStorage?.get(this.data.id);
  5449. let value = storageEntry?.value,
  5450. rotation = storageEntry?.rotation;
  5451. if (value === this.data.fieldValue || value === undefined) {
  5452. if (!this._hasValueFromXFA && rotation === undefined) {
  5453. return null;
  5454. }
  5455. value ||= this.data.fieldValue;
  5456. }
  5457. if (rotation === undefined && !this._hasValueFromXFA && Array.isArray(value) && Array.isArray(this.data.fieldValue) && value.length === this.data.fieldValue.length && value.every((x, i) => x === this.data.fieldValue[i])) {
  5458. return null;
  5459. }
  5460. if (rotation === undefined) {
  5461. rotation = this.rotation;
  5462. }
  5463. let appearance = null;
  5464. if (!this._needAppearances) {
  5465. appearance = await this._getAppearance(evaluator, task, _util.RenderingIntentFlag.SAVE, annotationStorage);
  5466. if (appearance === null) {
  5467. return null;
  5468. }
  5469. } else {}
  5470. let needAppearances = false;
  5471. if (appearance?.needAppearances) {
  5472. needAppearances = true;
  5473. appearance = null;
  5474. }
  5475. const {
  5476. xref
  5477. } = evaluator;
  5478. const originalDict = xref.fetchIfRef(this.ref);
  5479. if (!(originalDict instanceof _primitives.Dict)) {
  5480. return null;
  5481. }
  5482. const dict = new _primitives.Dict(xref);
  5483. for (const key of originalDict.getKeys()) {
  5484. if (key !== "AP") {
  5485. dict.set(key, originalDict.getRaw(key));
  5486. }
  5487. }
  5488. const xfa = {
  5489. path: this.data.fieldName,
  5490. value
  5491. };
  5492. const encoder = val => {
  5493. return (0, _core_utils.isAscii)(val) ? val : (0, _core_utils.stringToUTF16String)(val, true);
  5494. };
  5495. dict.set("V", Array.isArray(value) ? value.map(encoder) : encoder(value));
  5496. this.amendSavedDict(annotationStorage, dict);
  5497. const maybeMK = this._getMKDict(rotation);
  5498. if (maybeMK) {
  5499. dict.set("MK", maybeMK);
  5500. }
  5501. const encrypt = xref.encrypt;
  5502. const originalTransform = encrypt ? encrypt.createCipherTransform(this.ref.num, this.ref.gen) : null;
  5503. const buffer = [];
  5504. const changes = [{
  5505. ref: this.ref,
  5506. data: "",
  5507. xfa,
  5508. needAppearances
  5509. }];
  5510. if (appearance !== null) {
  5511. const newRef = xref.getNewTemporaryRef();
  5512. const AP = new _primitives.Dict(xref);
  5513. dict.set("AP", AP);
  5514. AP.set("N", newRef);
  5515. let newTransform = null;
  5516. if (encrypt) {
  5517. newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
  5518. }
  5519. const resources = this._getSaveFieldResources(xref);
  5520. const appearanceStream = new _stream.StringStream(appearance);
  5521. const appearanceDict = appearanceStream.dict = new _primitives.Dict(xref);
  5522. appearanceDict.set("Subtype", _primitives.Name.get("Form"));
  5523. appearanceDict.set("Resources", resources);
  5524. appearanceDict.set("BBox", [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]]);
  5525. const rotationMatrix = this.getRotationMatrix(annotationStorage);
  5526. if (rotationMatrix !== _util.IDENTITY_MATRIX) {
  5527. appearanceDict.set("Matrix", rotationMatrix);
  5528. }
  5529. await (0, _writer.writeObject)(newRef, appearanceStream, buffer, newTransform);
  5530. changes.push({
  5531. ref: newRef,
  5532. data: buffer.join(""),
  5533. xfa: null,
  5534. needAppearances: false
  5535. });
  5536. buffer.length = 0;
  5537. }
  5538. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  5539. await (0, _writer.writeObject)(this.ref, dict, buffer, originalTransform);
  5540. changes[0].data = buffer.join("");
  5541. return changes;
  5542. }
  5543. async _getAppearance(evaluator, task, intent, annotationStorage) {
  5544. const isPassword = this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD);
  5545. if (isPassword) {
  5546. return null;
  5547. }
  5548. const storageEntry = annotationStorage?.get(this.data.id);
  5549. let value, rotation;
  5550. if (storageEntry) {
  5551. value = storageEntry.formattedValue || storageEntry.value;
  5552. rotation = storageEntry.rotation;
  5553. }
  5554. if (rotation === undefined && value === undefined && !this._needAppearances) {
  5555. if (!this._hasValueFromXFA || this.appearance) {
  5556. return null;
  5557. }
  5558. }
  5559. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  5560. if (value === undefined) {
  5561. value = this.data.fieldValue;
  5562. if (!value) {
  5563. return `/Tx BMC q ${colors}Q EMC`;
  5564. }
  5565. }
  5566. if (Array.isArray(value) && value.length === 1) {
  5567. value = value[0];
  5568. }
  5569. (0, _util.assert)(typeof value === "string", "Expected `value` to be a string.");
  5570. value = value.trim();
  5571. if (this.data.combo) {
  5572. const option = this.data.options.find(({
  5573. exportValue
  5574. }) => value === exportValue);
  5575. value = option?.displayValue || value;
  5576. }
  5577. if (value === "") {
  5578. return `/Tx BMC q ${colors}Q EMC`;
  5579. }
  5580. if (rotation === undefined) {
  5581. rotation = this.rotation;
  5582. }
  5583. let lineCount = -1;
  5584. let lines;
  5585. if (this.data.multiLine) {
  5586. lines = value.split(/\r\n?|\n/).map(line => line.normalize("NFC"));
  5587. lineCount = lines.length;
  5588. } else {
  5589. lines = [value.replace(/\r\n?|\n/, "").normalize("NFC")];
  5590. }
  5591. const defaultPadding = 1;
  5592. const defaultHPadding = 2;
  5593. let totalHeight = this.data.rect[3] - this.data.rect[1];
  5594. let totalWidth = this.data.rect[2] - this.data.rect[0];
  5595. if (rotation === 90 || rotation === 270) {
  5596. [totalWidth, totalHeight] = [totalHeight, totalWidth];
  5597. }
  5598. if (!this._defaultAppearance) {
  5599. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
  5600. }
  5601. let font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
  5602. let defaultAppearance, fontSize, lineHeight;
  5603. const encodedLines = [];
  5604. let encodingError = false;
  5605. for (const line of lines) {
  5606. const encodedString = font.encodeString(line);
  5607. if (encodedString.length > 1) {
  5608. encodingError = true;
  5609. }
  5610. encodedLines.push(encodedString.join(""));
  5611. }
  5612. if (encodingError && intent & _util.RenderingIntentFlag.SAVE) {
  5613. return {
  5614. needAppearances: true
  5615. };
  5616. }
  5617. if (encodingError && this._isOffscreenCanvasSupported) {
  5618. const fontFamily = this.data.comb ? "monospace" : "sans-serif";
  5619. const fakeUnicodeFont = new _default_appearance.FakeUnicodeFont(evaluator.xref, fontFamily);
  5620. const resources = fakeUnicodeFont.createFontResources(lines.join(""));
  5621. const newFont = resources.getRaw("Font");
  5622. if (this._fieldResources.mergedResources.has("Font")) {
  5623. const oldFont = this._fieldResources.mergedResources.get("Font");
  5624. for (const key of newFont.getKeys()) {
  5625. oldFont.set(key, newFont.getRaw(key));
  5626. }
  5627. } else {
  5628. this._fieldResources.mergedResources.set("Font", newFont);
  5629. }
  5630. const fontName = fakeUnicodeFont.fontName.name;
  5631. font = await WidgetAnnotation._getFontData(evaluator, task, {
  5632. fontName,
  5633. fontSize: 0
  5634. }, resources);
  5635. for (let i = 0, ii = encodedLines.length; i < ii; i++) {
  5636. encodedLines[i] = (0, _core_utils.stringToUTF16String)(lines[i]);
  5637. }
  5638. const savedDefaultAppearance = Object.assign(Object.create(null), this.data.defaultAppearanceData);
  5639. this.data.defaultAppearanceData.fontSize = 0;
  5640. this.data.defaultAppearanceData.fontName = fontName;
  5641. [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
  5642. this.data.defaultAppearanceData = savedDefaultAppearance;
  5643. } else {
  5644. if (!this._isOffscreenCanvasSupported) {
  5645. (0, _util.warn)("_getAppearance: OffscreenCanvas is not supported, annotation may not render correctly.");
  5646. }
  5647. [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
  5648. }
  5649. let descent = font.descent;
  5650. if (isNaN(descent)) {
  5651. descent = _util.BASELINE_FACTOR * lineHeight;
  5652. } else {
  5653. descent = Math.max(_util.BASELINE_FACTOR * lineHeight, Math.abs(descent) * fontSize);
  5654. }
  5655. const defaultVPadding = Math.min(Math.floor((totalHeight - fontSize) / 2), defaultPadding);
  5656. const alignment = this.data.textAlignment;
  5657. if (this.data.multiLine) {
  5658. return this._getMultilineAppearance(defaultAppearance, encodedLines, font, fontSize, totalWidth, totalHeight, alignment, defaultHPadding, defaultVPadding, descent, lineHeight, annotationStorage);
  5659. }
  5660. if (this.data.comb) {
  5661. return this._getCombAppearance(defaultAppearance, font, encodedLines[0], fontSize, totalWidth, totalHeight, defaultHPadding, defaultVPadding, descent, lineHeight, annotationStorage);
  5662. }
  5663. const bottomPadding = defaultVPadding + descent;
  5664. if (alignment === 0 || alignment > 2) {
  5665. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 ${(0, _core_utils.numberToString)(defaultHPadding)} ${(0, _core_utils.numberToString)(bottomPadding)} Tm (${(0, _core_utils.escapeString)(encodedLines[0])}) Tj` + " ET Q EMC";
  5666. }
  5667. const prevInfo = {
  5668. shift: 0
  5669. };
  5670. const renderedText = this._renderText(encodedLines[0], font, fontSize, totalWidth, alignment, prevInfo, defaultHPadding, bottomPadding);
  5671. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 0 Tm ${renderedText}` + " ET Q EMC";
  5672. }
  5673. static async _getFontData(evaluator, task, appearanceData, resources) {
  5674. const operatorList = new _operator_list.OperatorList();
  5675. const initialState = {
  5676. font: null,
  5677. clone() {
  5678. return this;
  5679. }
  5680. };
  5681. const {
  5682. fontName,
  5683. fontSize
  5684. } = appearanceData;
  5685. await evaluator.handleSetFont(resources, [fontName && _primitives.Name.get(fontName), fontSize], null, operatorList, task, initialState, null);
  5686. return initialState.font;
  5687. }
  5688. _getTextWidth(text, font) {
  5689. return font.charsToGlyphs(text).reduce((width, glyph) => width + glyph.width, 0) / 1000;
  5690. }
  5691. _computeFontSize(height, width, text, font, lineCount) {
  5692. let {
  5693. fontSize
  5694. } = this.data.defaultAppearanceData;
  5695. let lineHeight = (fontSize || 12) * _util.LINE_FACTOR,
  5696. numberOfLines = Math.round(height / lineHeight);
  5697. if (!fontSize) {
  5698. const roundWithTwoDigits = x => Math.floor(x * 100) / 100;
  5699. if (lineCount === -1) {
  5700. const textWidth = this._getTextWidth(text, font);
  5701. fontSize = roundWithTwoDigits(Math.min(height / _util.LINE_FACTOR, textWidth > width ? width / textWidth : Infinity));
  5702. numberOfLines = 1;
  5703. } else {
  5704. const lines = text.split(/\r\n?|\n/);
  5705. const cachedLines = [];
  5706. for (const line of lines) {
  5707. const encoded = font.encodeString(line).join("");
  5708. const glyphs = font.charsToGlyphs(encoded);
  5709. const positions = font.getCharPositions(encoded);
  5710. cachedLines.push({
  5711. line: encoded,
  5712. glyphs,
  5713. positions
  5714. });
  5715. }
  5716. const isTooBig = fsize => {
  5717. let totalHeight = 0;
  5718. for (const cache of cachedLines) {
  5719. const chunks = this._splitLine(null, font, fsize, width, cache);
  5720. totalHeight += chunks.length * fsize;
  5721. if (totalHeight > height) {
  5722. return true;
  5723. }
  5724. }
  5725. return false;
  5726. };
  5727. numberOfLines = Math.max(numberOfLines, lineCount);
  5728. while (true) {
  5729. lineHeight = height / numberOfLines;
  5730. fontSize = roundWithTwoDigits(lineHeight / _util.LINE_FACTOR);
  5731. if (isTooBig(fontSize)) {
  5732. numberOfLines++;
  5733. continue;
  5734. }
  5735. break;
  5736. }
  5737. }
  5738. const {
  5739. fontName,
  5740. fontColor
  5741. } = this.data.defaultAppearanceData;
  5742. this._defaultAppearance = (0, _default_appearance.createDefaultAppearance)({
  5743. fontSize,
  5744. fontName,
  5745. fontColor
  5746. });
  5747. }
  5748. return [this._defaultAppearance, fontSize, height / numberOfLines];
  5749. }
  5750. _renderText(text, font, fontSize, totalWidth, alignment, prevInfo, hPadding, vPadding) {
  5751. let shift;
  5752. if (alignment === 1) {
  5753. const width = this._getTextWidth(text, font) * fontSize;
  5754. shift = (totalWidth - width) / 2;
  5755. } else if (alignment === 2) {
  5756. const width = this._getTextWidth(text, font) * fontSize;
  5757. shift = totalWidth - width - hPadding;
  5758. } else {
  5759. shift = hPadding;
  5760. }
  5761. const shiftStr = (0, _core_utils.numberToString)(shift - prevInfo.shift);
  5762. prevInfo.shift = shift;
  5763. vPadding = (0, _core_utils.numberToString)(vPadding);
  5764. return `${shiftStr} ${vPadding} Td (${(0, _core_utils.escapeString)(text)}) Tj`;
  5765. }
  5766. _getSaveFieldResources(xref) {
  5767. const {
  5768. localResources,
  5769. appearanceResources,
  5770. acroFormResources
  5771. } = this._fieldResources;
  5772. const fontName = this.data.defaultAppearanceData?.fontName;
  5773. if (!fontName) {
  5774. return localResources || _primitives.Dict.empty;
  5775. }
  5776. for (const resources of [localResources, appearanceResources]) {
  5777. if (resources instanceof _primitives.Dict) {
  5778. const localFont = resources.get("Font");
  5779. if (localFont instanceof _primitives.Dict && localFont.has(fontName)) {
  5780. return resources;
  5781. }
  5782. }
  5783. }
  5784. if (acroFormResources instanceof _primitives.Dict) {
  5785. const acroFormFont = acroFormResources.get("Font");
  5786. if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontName)) {
  5787. const subFontDict = new _primitives.Dict(xref);
  5788. subFontDict.set(fontName, acroFormFont.getRaw(fontName));
  5789. const subResourcesDict = new _primitives.Dict(xref);
  5790. subResourcesDict.set("Font", subFontDict);
  5791. return _primitives.Dict.merge({
  5792. xref,
  5793. dictArray: [subResourcesDict, localResources],
  5794. mergeSubDicts: true
  5795. });
  5796. }
  5797. }
  5798. return localResources || _primitives.Dict.empty;
  5799. }
  5800. getFieldObject() {
  5801. return null;
  5802. }
  5803. }
  5804. class TextWidgetAnnotation extends WidgetAnnotation {
  5805. constructor(params) {
  5806. super(params);
  5807. this.data.hasOwnCanvas = this.data.readOnly && !this.data.noHTML;
  5808. this._hasText = true;
  5809. const dict = params.dict;
  5810. if (typeof this.data.fieldValue !== "string") {
  5811. this.data.fieldValue = "";
  5812. }
  5813. let alignment = (0, _core_utils.getInheritableProperty)({
  5814. dict,
  5815. key: "Q"
  5816. });
  5817. if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
  5818. alignment = null;
  5819. }
  5820. this.data.textAlignment = alignment;
  5821. let maximumLength = (0, _core_utils.getInheritableProperty)({
  5822. dict,
  5823. key: "MaxLen"
  5824. });
  5825. if (!Number.isInteger(maximumLength) || maximumLength < 0) {
  5826. maximumLength = 0;
  5827. }
  5828. this.data.maxLen = maximumLength;
  5829. this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
  5830. this.data.comb = this.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== 0;
  5831. this.data.doNotScroll = this.hasFieldFlag(_util.AnnotationFieldFlag.DONOTSCROLL);
  5832. }
  5833. get hasTextContent() {
  5834. return !!this.appearance && !this._needAppearances;
  5835. }
  5836. _getCombAppearance(defaultAppearance, font, text, fontSize, width, height, hPadding, vPadding, descent, lineHeight, annotationStorage) {
  5837. const combWidth = width / this.data.maxLen;
  5838. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  5839. const buf = [];
  5840. const positions = font.getCharPositions(text);
  5841. for (const [start, end] of positions) {
  5842. buf.push(`(${(0, _core_utils.escapeString)(text.substring(start, end))}) Tj`);
  5843. }
  5844. const renderedComb = buf.join(` ${(0, _core_utils.numberToString)(combWidth)} 0 Td `);
  5845. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 ${(0, _core_utils.numberToString)(hPadding)} ${(0, _core_utils.numberToString)(vPadding + descent)} Tm ${renderedComb}` + " ET Q EMC";
  5846. }
  5847. _getMultilineAppearance(defaultAppearance, lines, font, fontSize, width, height, alignment, hPadding, vPadding, descent, lineHeight, annotationStorage) {
  5848. const buf = [];
  5849. const totalWidth = width - 2 * hPadding;
  5850. const prevInfo = {
  5851. shift: 0
  5852. };
  5853. for (let i = 0, ii = lines.length; i < ii; i++) {
  5854. const line = lines[i];
  5855. const chunks = this._splitLine(line, font, fontSize, totalWidth);
  5856. for (let j = 0, jj = chunks.length; j < jj; j++) {
  5857. const chunk = chunks[j];
  5858. const vShift = i === 0 && j === 0 ? -vPadding - (lineHeight - descent) : -lineHeight;
  5859. buf.push(this._renderText(chunk, font, fontSize, width, alignment, prevInfo, hPadding, vShift));
  5860. }
  5861. }
  5862. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  5863. const renderedText = buf.join("\n");
  5864. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 ${(0, _core_utils.numberToString)(height)} Tm ${renderedText}` + " ET Q EMC";
  5865. }
  5866. _splitLine(line, font, fontSize, width, cache = {}) {
  5867. line = cache.line || line;
  5868. const glyphs = cache.glyphs || font.charsToGlyphs(line);
  5869. if (glyphs.length <= 1) {
  5870. return [line];
  5871. }
  5872. const positions = cache.positions || font.getCharPositions(line);
  5873. const scale = fontSize / 1000;
  5874. const chunks = [];
  5875. let lastSpacePosInStringStart = -1,
  5876. lastSpacePosInStringEnd = -1,
  5877. lastSpacePos = -1,
  5878. startChunk = 0,
  5879. currentWidth = 0;
  5880. for (let i = 0, ii = glyphs.length; i < ii; i++) {
  5881. const [start, end] = positions[i];
  5882. const glyph = glyphs[i];
  5883. const glyphWidth = glyph.width * scale;
  5884. if (glyph.unicode === " ") {
  5885. if (currentWidth + glyphWidth > width) {
  5886. chunks.push(line.substring(startChunk, start));
  5887. startChunk = start;
  5888. currentWidth = glyphWidth;
  5889. lastSpacePosInStringStart = -1;
  5890. lastSpacePos = -1;
  5891. } else {
  5892. currentWidth += glyphWidth;
  5893. lastSpacePosInStringStart = start;
  5894. lastSpacePosInStringEnd = end;
  5895. lastSpacePos = i;
  5896. }
  5897. } else if (currentWidth + glyphWidth > width) {
  5898. if (lastSpacePosInStringStart !== -1) {
  5899. chunks.push(line.substring(startChunk, lastSpacePosInStringEnd));
  5900. startChunk = lastSpacePosInStringEnd;
  5901. i = lastSpacePos + 1;
  5902. lastSpacePosInStringStart = -1;
  5903. currentWidth = 0;
  5904. } else {
  5905. chunks.push(line.substring(startChunk, start));
  5906. startChunk = start;
  5907. currentWidth = glyphWidth;
  5908. }
  5909. } else {
  5910. currentWidth += glyphWidth;
  5911. }
  5912. }
  5913. if (startChunk < line.length) {
  5914. chunks.push(line.substring(startChunk, line.length));
  5915. }
  5916. return chunks;
  5917. }
  5918. getFieldObject() {
  5919. return {
  5920. id: this.data.id,
  5921. value: this.data.fieldValue,
  5922. defaultValue: this.data.defaultFieldValue || "",
  5923. multiline: this.data.multiLine,
  5924. password: this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD),
  5925. charLimit: this.data.maxLen,
  5926. comb: this.data.comb,
  5927. editable: !this.data.readOnly,
  5928. hidden: this.data.hidden,
  5929. name: this.data.fieldName,
  5930. rect: this.data.rect,
  5931. actions: this.data.actions,
  5932. page: this.data.pageIndex,
  5933. strokeColor: this.data.borderColor,
  5934. fillColor: this.data.backgroundColor,
  5935. rotation: this.rotation,
  5936. type: "text"
  5937. };
  5938. }
  5939. }
  5940. class ButtonWidgetAnnotation extends WidgetAnnotation {
  5941. constructor(params) {
  5942. super(params);
  5943. this.checkedAppearance = null;
  5944. this.uncheckedAppearance = null;
  5945. this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  5946. this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  5947. this.data.pushButton = this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  5948. this.data.isTooltipOnly = false;
  5949. if (this.data.checkBox) {
  5950. this._processCheckBox(params);
  5951. } else if (this.data.radioButton) {
  5952. this._processRadioButton(params);
  5953. } else if (this.data.pushButton) {
  5954. this.data.hasOwnCanvas = true;
  5955. this._processPushButton(params);
  5956. } else {
  5957. (0, _util.warn)("Invalid field flags for button widget annotation");
  5958. }
  5959. }
  5960. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  5961. if (this.data.pushButton) {
  5962. return super.getOperatorList(evaluator, task, intent, false, annotationStorage);
  5963. }
  5964. let value = null;
  5965. let rotation = null;
  5966. if (annotationStorage) {
  5967. const storageEntry = annotationStorage.get(this.data.id);
  5968. value = storageEntry ? storageEntry.value : null;
  5969. rotation = storageEntry ? storageEntry.rotation : null;
  5970. }
  5971. if (value === null && this.appearance) {
  5972. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  5973. }
  5974. if (value === null || value === undefined) {
  5975. value = this.data.checkBox ? this.data.fieldValue === this.data.exportValue : this.data.fieldValue === this.data.buttonValue;
  5976. }
  5977. const appearance = value ? this.checkedAppearance : this.uncheckedAppearance;
  5978. if (appearance) {
  5979. const savedAppearance = this.appearance;
  5980. const savedMatrix = appearance.dict.getArray("Matrix") || _util.IDENTITY_MATRIX;
  5981. if (rotation) {
  5982. appearance.dict.set("Matrix", this.getRotationMatrix(annotationStorage));
  5983. }
  5984. this.appearance = appearance;
  5985. const operatorList = super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  5986. this.appearance = savedAppearance;
  5987. appearance.dict.set("Matrix", savedMatrix);
  5988. return operatorList;
  5989. }
  5990. return {
  5991. opList: new _operator_list.OperatorList(),
  5992. separateForm: false,
  5993. separateCanvas: false
  5994. };
  5995. }
  5996. async save(evaluator, task, annotationStorage) {
  5997. if (this.data.checkBox) {
  5998. return this._saveCheckbox(evaluator, task, annotationStorage);
  5999. }
  6000. if (this.data.radioButton) {
  6001. return this._saveRadioButton(evaluator, task, annotationStorage);
  6002. }
  6003. return null;
  6004. }
  6005. async _saveCheckbox(evaluator, task, annotationStorage) {
  6006. if (!annotationStorage) {
  6007. return null;
  6008. }
  6009. const storageEntry = annotationStorage.get(this.data.id);
  6010. let rotation = storageEntry?.rotation,
  6011. value = storageEntry?.value;
  6012. if (rotation === undefined) {
  6013. if (value === undefined) {
  6014. return null;
  6015. }
  6016. const defaultValue = this.data.fieldValue === this.data.exportValue;
  6017. if (defaultValue === value) {
  6018. return null;
  6019. }
  6020. }
  6021. const dict = evaluator.xref.fetchIfRef(this.ref);
  6022. if (!(dict instanceof _primitives.Dict)) {
  6023. return null;
  6024. }
  6025. if (rotation === undefined) {
  6026. rotation = this.rotation;
  6027. }
  6028. if (value === undefined) {
  6029. value = this.data.fieldValue === this.data.exportValue;
  6030. }
  6031. const xfa = {
  6032. path: this.data.fieldName,
  6033. value: value ? this.data.exportValue : ""
  6034. };
  6035. const name = _primitives.Name.get(value ? this.data.exportValue : "Off");
  6036. dict.set("V", name);
  6037. dict.set("AS", name);
  6038. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  6039. const maybeMK = this._getMKDict(rotation);
  6040. if (maybeMK) {
  6041. dict.set("MK", maybeMK);
  6042. }
  6043. const encrypt = evaluator.xref.encrypt;
  6044. let originalTransform = null;
  6045. if (encrypt) {
  6046. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  6047. }
  6048. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  6049. await (0, _writer.writeDict)(dict, buffer, originalTransform);
  6050. buffer.push("\nendobj\n");
  6051. return [{
  6052. ref: this.ref,
  6053. data: buffer.join(""),
  6054. xfa
  6055. }];
  6056. }
  6057. async _saveRadioButton(evaluator, task, annotationStorage) {
  6058. if (!annotationStorage) {
  6059. return null;
  6060. }
  6061. const storageEntry = annotationStorage.get(this.data.id);
  6062. let rotation = storageEntry?.rotation,
  6063. value = storageEntry?.value;
  6064. if (rotation === undefined) {
  6065. if (value === undefined) {
  6066. return null;
  6067. }
  6068. const defaultValue = this.data.fieldValue === this.data.buttonValue;
  6069. if (defaultValue === value) {
  6070. return null;
  6071. }
  6072. }
  6073. const dict = evaluator.xref.fetchIfRef(this.ref);
  6074. if (!(dict instanceof _primitives.Dict)) {
  6075. return null;
  6076. }
  6077. if (value === undefined) {
  6078. value = this.data.fieldValue === this.data.buttonValue;
  6079. }
  6080. if (rotation === undefined) {
  6081. rotation = this.rotation;
  6082. }
  6083. const xfa = {
  6084. path: this.data.fieldName,
  6085. value: value ? this.data.buttonValue : ""
  6086. };
  6087. const name = _primitives.Name.get(value ? this.data.buttonValue : "Off");
  6088. let parentBuffer = null;
  6089. const encrypt = evaluator.xref.encrypt;
  6090. if (value) {
  6091. if (this.parent instanceof _primitives.Ref) {
  6092. const parent = evaluator.xref.fetch(this.parent);
  6093. let parentTransform = null;
  6094. if (encrypt) {
  6095. parentTransform = encrypt.createCipherTransform(this.parent.num, this.parent.gen);
  6096. }
  6097. parent.set("V", name);
  6098. parentBuffer = [`${this.parent.num} ${this.parent.gen} obj\n`];
  6099. await (0, _writer.writeDict)(parent, parentBuffer, parentTransform);
  6100. parentBuffer.push("\nendobj\n");
  6101. } else if (this.parent instanceof _primitives.Dict) {
  6102. this.parent.set("V", name);
  6103. }
  6104. }
  6105. dict.set("AS", name);
  6106. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  6107. const maybeMK = this._getMKDict(rotation);
  6108. if (maybeMK) {
  6109. dict.set("MK", maybeMK);
  6110. }
  6111. let originalTransform = null;
  6112. if (encrypt) {
  6113. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  6114. }
  6115. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  6116. await (0, _writer.writeDict)(dict, buffer, originalTransform);
  6117. buffer.push("\nendobj\n");
  6118. const newRefs = [{
  6119. ref: this.ref,
  6120. data: buffer.join(""),
  6121. xfa
  6122. }];
  6123. if (parentBuffer !== null) {
  6124. newRefs.push({
  6125. ref: this.parent,
  6126. data: parentBuffer.join(""),
  6127. xfa: null
  6128. });
  6129. }
  6130. return newRefs;
  6131. }
  6132. _getDefaultCheckedAppearance(params, type) {
  6133. const width = this.data.rect[2] - this.data.rect[0];
  6134. const height = this.data.rect[3] - this.data.rect[1];
  6135. const bbox = [0, 0, width, height];
  6136. const FONT_RATIO = 0.8;
  6137. const fontSize = Math.min(width, height) * FONT_RATIO;
  6138. let metrics, char;
  6139. if (type === "check") {
  6140. metrics = {
  6141. width: 0.755 * fontSize,
  6142. height: 0.705 * fontSize
  6143. };
  6144. char = "\x33";
  6145. } else if (type === "disc") {
  6146. metrics = {
  6147. width: 0.791 * fontSize,
  6148. height: 0.705 * fontSize
  6149. };
  6150. char = "\x6C";
  6151. } else {
  6152. (0, _util.unreachable)(`_getDefaultCheckedAppearance - unsupported type: ${type}`);
  6153. }
  6154. const xShift = (0, _core_utils.numberToString)((width - metrics.width) / 2);
  6155. const yShift = (0, _core_utils.numberToString)((height - metrics.height) / 2);
  6156. const appearance = `q BT /PdfJsZaDb ${fontSize} Tf 0 g ${xShift} ${yShift} Td (${char}) Tj ET Q`;
  6157. const appearanceStreamDict = new _primitives.Dict(params.xref);
  6158. appearanceStreamDict.set("FormType", 1);
  6159. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  6160. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  6161. appearanceStreamDict.set("BBox", bbox);
  6162. appearanceStreamDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
  6163. appearanceStreamDict.set("Length", appearance.length);
  6164. const resources = new _primitives.Dict(params.xref);
  6165. const font = new _primitives.Dict(params.xref);
  6166. font.set("PdfJsZaDb", this.fallbackFontDict);
  6167. resources.set("Font", font);
  6168. appearanceStreamDict.set("Resources", resources);
  6169. this.checkedAppearance = new _stream.StringStream(appearance);
  6170. this.checkedAppearance.dict = appearanceStreamDict;
  6171. this._streams.push(this.checkedAppearance);
  6172. }
  6173. _processCheckBox(params) {
  6174. const customAppearance = params.dict.get("AP");
  6175. if (!(customAppearance instanceof _primitives.Dict)) {
  6176. return;
  6177. }
  6178. const normalAppearance = customAppearance.get("N");
  6179. if (!(normalAppearance instanceof _primitives.Dict)) {
  6180. return;
  6181. }
  6182. const asValue = this._decodeFormValue(params.dict.get("AS"));
  6183. if (typeof asValue === "string") {
  6184. this.data.fieldValue = asValue;
  6185. }
  6186. const yes = this.data.fieldValue !== null && this.data.fieldValue !== "Off" ? this.data.fieldValue : "Yes";
  6187. const exportValues = normalAppearance.getKeys();
  6188. if (exportValues.length === 0) {
  6189. exportValues.push("Off", yes);
  6190. } else if (exportValues.length === 1) {
  6191. if (exportValues[0] === "Off") {
  6192. exportValues.push(yes);
  6193. } else {
  6194. exportValues.unshift("Off");
  6195. }
  6196. } else if (exportValues.includes(yes)) {
  6197. exportValues.length = 0;
  6198. exportValues.push("Off", yes);
  6199. } else {
  6200. const otherYes = exportValues.find(v => v !== "Off");
  6201. exportValues.length = 0;
  6202. exportValues.push("Off", otherYes);
  6203. }
  6204. if (!exportValues.includes(this.data.fieldValue)) {
  6205. this.data.fieldValue = "Off";
  6206. }
  6207. this.data.exportValue = exportValues[1];
  6208. const checkedAppearance = normalAppearance.get(this.data.exportValue);
  6209. this.checkedAppearance = checkedAppearance instanceof _base_stream.BaseStream ? checkedAppearance : null;
  6210. const uncheckedAppearance = normalAppearance.get("Off");
  6211. this.uncheckedAppearance = uncheckedAppearance instanceof _base_stream.BaseStream ? uncheckedAppearance : null;
  6212. if (this.checkedAppearance) {
  6213. this._streams.push(this.checkedAppearance);
  6214. } else {
  6215. this._getDefaultCheckedAppearance(params, "check");
  6216. }
  6217. if (this.uncheckedAppearance) {
  6218. this._streams.push(this.uncheckedAppearance);
  6219. }
  6220. this._fallbackFontDict = this.fallbackFontDict;
  6221. if (this.data.defaultFieldValue === null) {
  6222. this.data.defaultFieldValue = "Off";
  6223. }
  6224. }
  6225. _processRadioButton(params) {
  6226. this.data.fieldValue = this.data.buttonValue = null;
  6227. const fieldParent = params.dict.get("Parent");
  6228. if (fieldParent instanceof _primitives.Dict) {
  6229. this.parent = params.dict.getRaw("Parent");
  6230. const fieldParentValue = fieldParent.get("V");
  6231. if (fieldParentValue instanceof _primitives.Name) {
  6232. this.data.fieldValue = this._decodeFormValue(fieldParentValue);
  6233. }
  6234. }
  6235. const appearanceStates = params.dict.get("AP");
  6236. if (!(appearanceStates instanceof _primitives.Dict)) {
  6237. return;
  6238. }
  6239. const normalAppearance = appearanceStates.get("N");
  6240. if (!(normalAppearance instanceof _primitives.Dict)) {
  6241. return;
  6242. }
  6243. for (const key of normalAppearance.getKeys()) {
  6244. if (key !== "Off") {
  6245. this.data.buttonValue = this._decodeFormValue(key);
  6246. break;
  6247. }
  6248. }
  6249. const checkedAppearance = normalAppearance.get(this.data.buttonValue);
  6250. this.checkedAppearance = checkedAppearance instanceof _base_stream.BaseStream ? checkedAppearance : null;
  6251. const uncheckedAppearance = normalAppearance.get("Off");
  6252. this.uncheckedAppearance = uncheckedAppearance instanceof _base_stream.BaseStream ? uncheckedAppearance : null;
  6253. if (this.checkedAppearance) {
  6254. this._streams.push(this.checkedAppearance);
  6255. } else {
  6256. this._getDefaultCheckedAppearance(params, "disc");
  6257. }
  6258. if (this.uncheckedAppearance) {
  6259. this._streams.push(this.uncheckedAppearance);
  6260. }
  6261. this._fallbackFontDict = this.fallbackFontDict;
  6262. if (this.data.defaultFieldValue === null) {
  6263. this.data.defaultFieldValue = "Off";
  6264. }
  6265. }
  6266. _processPushButton(params) {
  6267. if (!params.dict.has("A") && !params.dict.has("AA") && !this.data.alternativeText) {
  6268. (0, _util.warn)("Push buttons without action dictionaries are not supported");
  6269. return;
  6270. }
  6271. this.data.isTooltipOnly = !params.dict.has("A") && !params.dict.has("AA");
  6272. _catalog.Catalog.parseDestDictionary({
  6273. destDict: params.dict,
  6274. resultObj: this.data,
  6275. docBaseUrl: params.pdfManager.docBaseUrl,
  6276. docAttachments: params.attachments
  6277. });
  6278. }
  6279. getFieldObject() {
  6280. let type = "button";
  6281. let exportValues;
  6282. if (this.data.checkBox) {
  6283. type = "checkbox";
  6284. exportValues = this.data.exportValue;
  6285. } else if (this.data.radioButton) {
  6286. type = "radiobutton";
  6287. exportValues = this.data.buttonValue;
  6288. }
  6289. return {
  6290. id: this.data.id,
  6291. value: this.data.fieldValue || "Off",
  6292. defaultValue: this.data.defaultFieldValue,
  6293. exportValues,
  6294. editable: !this.data.readOnly,
  6295. name: this.data.fieldName,
  6296. rect: this.data.rect,
  6297. hidden: this.data.hidden,
  6298. actions: this.data.actions,
  6299. page: this.data.pageIndex,
  6300. strokeColor: this.data.borderColor,
  6301. fillColor: this.data.backgroundColor,
  6302. rotation: this.rotation,
  6303. type
  6304. };
  6305. }
  6306. get fallbackFontDict() {
  6307. const dict = new _primitives.Dict();
  6308. dict.set("BaseFont", _primitives.Name.get("ZapfDingbats"));
  6309. dict.set("Type", _primitives.Name.get("FallbackType"));
  6310. dict.set("Subtype", _primitives.Name.get("FallbackType"));
  6311. dict.set("Encoding", _primitives.Name.get("ZapfDingbatsEncoding"));
  6312. return (0, _util.shadow)(this, "fallbackFontDict", dict);
  6313. }
  6314. }
  6315. class ChoiceWidgetAnnotation extends WidgetAnnotation {
  6316. constructor(params) {
  6317. super(params);
  6318. const {
  6319. dict,
  6320. xref
  6321. } = params;
  6322. this.indices = dict.getArray("I");
  6323. this.hasIndices = Array.isArray(this.indices) && this.indices.length > 0;
  6324. this.data.options = [];
  6325. const options = (0, _core_utils.getInheritableProperty)({
  6326. dict,
  6327. key: "Opt"
  6328. });
  6329. if (Array.isArray(options)) {
  6330. for (let i = 0, ii = options.length; i < ii; i++) {
  6331. const option = xref.fetchIfRef(options[i]);
  6332. const isOptionArray = Array.isArray(option);
  6333. this.data.options[i] = {
  6334. exportValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[0]) : option),
  6335. displayValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[1]) : option)
  6336. };
  6337. }
  6338. }
  6339. if (!this.hasIndices) {
  6340. if (typeof this.data.fieldValue === "string") {
  6341. this.data.fieldValue = [this.data.fieldValue];
  6342. } else if (!this.data.fieldValue) {
  6343. this.data.fieldValue = [];
  6344. }
  6345. } else {
  6346. this.data.fieldValue = [];
  6347. const ii = this.data.options.length;
  6348. for (const i of this.indices) {
  6349. if (Number.isInteger(i) && i >= 0 && i < ii) {
  6350. this.data.fieldValue.push(this.data.options[i].exportValue);
  6351. }
  6352. }
  6353. }
  6354. this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
  6355. this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
  6356. this._hasText = true;
  6357. }
  6358. getFieldObject() {
  6359. const type = this.data.combo ? "combobox" : "listbox";
  6360. const value = this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null;
  6361. return {
  6362. id: this.data.id,
  6363. value,
  6364. defaultValue: this.data.defaultFieldValue,
  6365. editable: !this.data.readOnly,
  6366. name: this.data.fieldName,
  6367. rect: this.data.rect,
  6368. numItems: this.data.fieldValue.length,
  6369. multipleSelection: this.data.multiSelect,
  6370. hidden: this.data.hidden,
  6371. actions: this.data.actions,
  6372. items: this.data.options,
  6373. page: this.data.pageIndex,
  6374. strokeColor: this.data.borderColor,
  6375. fillColor: this.data.backgroundColor,
  6376. rotation: this.rotation,
  6377. type
  6378. };
  6379. }
  6380. amendSavedDict(annotationStorage, dict) {
  6381. if (!this.hasIndices) {
  6382. return;
  6383. }
  6384. let values = annotationStorage?.get(this.data.id)?.value;
  6385. if (!Array.isArray(values)) {
  6386. values = [values];
  6387. }
  6388. const indices = [];
  6389. const {
  6390. options
  6391. } = this.data;
  6392. for (let i = 0, j = 0, ii = options.length; i < ii; i++) {
  6393. if (options[i].exportValue === values[j]) {
  6394. indices.push(i);
  6395. j += 1;
  6396. }
  6397. }
  6398. dict.set("I", indices);
  6399. }
  6400. async _getAppearance(evaluator, task, intent, annotationStorage) {
  6401. if (this.data.combo) {
  6402. return super._getAppearance(evaluator, task, intent, annotationStorage);
  6403. }
  6404. let exportedValue, rotation;
  6405. const storageEntry = annotationStorage?.get(this.data.id);
  6406. if (storageEntry) {
  6407. rotation = storageEntry.rotation;
  6408. exportedValue = storageEntry.value;
  6409. }
  6410. if (rotation === undefined && exportedValue === undefined && !this._needAppearances) {
  6411. return null;
  6412. }
  6413. if (exportedValue === undefined) {
  6414. exportedValue = this.data.fieldValue;
  6415. } else if (!Array.isArray(exportedValue)) {
  6416. exportedValue = [exportedValue];
  6417. }
  6418. const defaultPadding = 1;
  6419. const defaultHPadding = 2;
  6420. let totalHeight = this.data.rect[3] - this.data.rect[1];
  6421. let totalWidth = this.data.rect[2] - this.data.rect[0];
  6422. if (rotation === 90 || rotation === 270) {
  6423. [totalWidth, totalHeight] = [totalHeight, totalWidth];
  6424. }
  6425. const lineCount = this.data.options.length;
  6426. const valueIndices = [];
  6427. for (let i = 0; i < lineCount; i++) {
  6428. const {
  6429. exportValue
  6430. } = this.data.options[i];
  6431. if (exportedValue.includes(exportValue)) {
  6432. valueIndices.push(i);
  6433. }
  6434. }
  6435. if (!this._defaultAppearance) {
  6436. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
  6437. }
  6438. const font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
  6439. let defaultAppearance;
  6440. let {
  6441. fontSize
  6442. } = this.data.defaultAppearanceData;
  6443. if (!fontSize) {
  6444. const lineHeight = (totalHeight - defaultPadding) / lineCount;
  6445. let lineWidth = -1;
  6446. let value;
  6447. for (const {
  6448. displayValue
  6449. } of this.data.options) {
  6450. const width = this._getTextWidth(displayValue, font);
  6451. if (width > lineWidth) {
  6452. lineWidth = width;
  6453. value = displayValue;
  6454. }
  6455. }
  6456. [defaultAppearance, fontSize] = this._computeFontSize(lineHeight, totalWidth - 2 * defaultHPadding, value, font, -1);
  6457. } else {
  6458. defaultAppearance = this._defaultAppearance;
  6459. }
  6460. const lineHeight = fontSize * _util.LINE_FACTOR;
  6461. const vPadding = (lineHeight - fontSize) / 2;
  6462. const numberOfVisibleLines = Math.floor(totalHeight / lineHeight);
  6463. let firstIndex = 0;
  6464. if (valueIndices.length > 0) {
  6465. const minIndex = Math.min(...valueIndices);
  6466. const maxIndex = Math.max(...valueIndices);
  6467. firstIndex = Math.max(0, maxIndex - numberOfVisibleLines + 1);
  6468. if (firstIndex > minIndex) {
  6469. firstIndex = minIndex;
  6470. }
  6471. }
  6472. const end = Math.min(firstIndex + numberOfVisibleLines + 1, lineCount);
  6473. const buf = ["/Tx BMC q", `1 1 ${totalWidth} ${totalHeight} re W n`];
  6474. if (valueIndices.length) {
  6475. buf.push("0.600006 0.756866 0.854904 rg");
  6476. for (const index of valueIndices) {
  6477. if (firstIndex <= index && index < end) {
  6478. buf.push(`1 ${totalHeight - (index - firstIndex + 1) * lineHeight} ${totalWidth} ${lineHeight} re f`);
  6479. }
  6480. }
  6481. }
  6482. buf.push("BT", defaultAppearance, `1 0 0 1 0 ${totalHeight} Tm`);
  6483. const prevInfo = {
  6484. shift: 0
  6485. };
  6486. for (let i = firstIndex; i < end; i++) {
  6487. const {
  6488. displayValue
  6489. } = this.data.options[i];
  6490. const vpadding = i === firstIndex ? vPadding : 0;
  6491. buf.push(this._renderText(displayValue, font, fontSize, totalWidth, 0, prevInfo, defaultHPadding, -lineHeight + vpadding));
  6492. }
  6493. buf.push("ET Q EMC");
  6494. return buf.join("\n");
  6495. }
  6496. }
  6497. class SignatureWidgetAnnotation extends WidgetAnnotation {
  6498. constructor(params) {
  6499. super(params);
  6500. this.data.fieldValue = null;
  6501. this.data.hasOwnCanvas = this.data.noRotate;
  6502. }
  6503. getFieldObject() {
  6504. return {
  6505. id: this.data.id,
  6506. value: null,
  6507. page: this.data.pageIndex,
  6508. type: "signature"
  6509. };
  6510. }
  6511. }
  6512. class TextAnnotation extends MarkupAnnotation {
  6513. constructor(params) {
  6514. const DEFAULT_ICON_SIZE = 22;
  6515. super(params);
  6516. this.data.noRotate = true;
  6517. this.data.hasOwnCanvas = this.data.noRotate;
  6518. const {
  6519. dict
  6520. } = params;
  6521. this.data.annotationType = _util.AnnotationType.TEXT;
  6522. if (this.data.hasAppearance) {
  6523. this.data.name = "NoIcon";
  6524. } else {
  6525. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  6526. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  6527. this.data.name = dict.has("Name") ? dict.get("Name").name : "Note";
  6528. }
  6529. if (dict.has("State")) {
  6530. this.data.state = dict.get("State") || null;
  6531. this.data.stateModel = dict.get("StateModel") || null;
  6532. } else {
  6533. this.data.state = null;
  6534. this.data.stateModel = null;
  6535. }
  6536. }
  6537. }
  6538. class LinkAnnotation extends Annotation {
  6539. constructor(params) {
  6540. super(params);
  6541. this.data.annotationType = _util.AnnotationType.LINK;
  6542. const quadPoints = getQuadPoints(params.dict, this.rectangle);
  6543. if (quadPoints) {
  6544. this.data.quadPoints = quadPoints;
  6545. }
  6546. this.data.borderColor ||= this.data.color;
  6547. _catalog.Catalog.parseDestDictionary({
  6548. destDict: params.dict,
  6549. resultObj: this.data,
  6550. docBaseUrl: params.pdfManager.docBaseUrl,
  6551. docAttachments: params.attachments
  6552. });
  6553. }
  6554. }
  6555. class PopupAnnotation extends Annotation {
  6556. constructor(params) {
  6557. super(params);
  6558. const {
  6559. dict
  6560. } = params;
  6561. this.data.annotationType = _util.AnnotationType.POPUP;
  6562. if (this.data.rect[0] === this.data.rect[2] || this.data.rect[1] === this.data.rect[3]) {
  6563. this.data.rect = null;
  6564. }
  6565. let parentItem = dict.get("Parent");
  6566. if (!parentItem) {
  6567. (0, _util.warn)("Popup annotation has a missing or invalid parent annotation.");
  6568. return;
  6569. }
  6570. const parentRect = parentItem.getArray("Rect");
  6571. this.data.parentRect = Array.isArray(parentRect) && parentRect.length === 4 ? _util.Util.normalizeRect(parentRect) : null;
  6572. const rt = parentItem.get("RT");
  6573. if ((0, _primitives.isName)(rt, _util.AnnotationReplyType.GROUP)) {
  6574. parentItem = parentItem.get("IRT");
  6575. }
  6576. if (!parentItem.has("M")) {
  6577. this.data.modificationDate = null;
  6578. } else {
  6579. this.setModificationDate(parentItem.get("M"));
  6580. this.data.modificationDate = this.modificationDate;
  6581. }
  6582. if (!parentItem.has("C")) {
  6583. this.data.color = null;
  6584. } else {
  6585. this.setColor(parentItem.getArray("C"));
  6586. this.data.color = this.color;
  6587. }
  6588. if (!this.viewable) {
  6589. const parentFlags = parentItem.get("F");
  6590. if (this._isViewable(parentFlags)) {
  6591. this.setFlags(parentFlags);
  6592. }
  6593. }
  6594. this.setTitle(parentItem.get("T"));
  6595. this.data.titleObj = this._title;
  6596. this.setContents(parentItem.get("Contents"));
  6597. this.data.contentsObj = this._contents;
  6598. if (parentItem.has("RC")) {
  6599. this.data.richText = _factory.XFAFactory.getRichTextAsHtml(parentItem.get("RC"));
  6600. }
  6601. this.data.open = !!dict.get("Open");
  6602. }
  6603. }
  6604. exports.PopupAnnotation = PopupAnnotation;
  6605. class FreeTextAnnotation extends MarkupAnnotation {
  6606. constructor(params) {
  6607. super(params);
  6608. this.data.hasOwnCanvas = true;
  6609. const {
  6610. evaluatorOptions,
  6611. xref
  6612. } = params;
  6613. this.data.annotationType = _util.AnnotationType.FREETEXT;
  6614. this.setDefaultAppearance(params);
  6615. if (this.appearance) {
  6616. const {
  6617. fontColor,
  6618. fontSize
  6619. } = (0, _default_appearance.parseAppearanceStream)(this.appearance, evaluatorOptions, xref);
  6620. this.data.defaultAppearanceData.fontColor = fontColor;
  6621. this.data.defaultAppearanceData.fontSize = fontSize || 10;
  6622. } else if (this._isOffscreenCanvasSupported) {
  6623. const strokeAlpha = params.dict.get("CA");
  6624. const fakeUnicodeFont = new _default_appearance.FakeUnicodeFont(xref, "sans-serif");
  6625. this.data.defaultAppearanceData.fontSize ||= 10;
  6626. const {
  6627. fontColor,
  6628. fontSize
  6629. } = this.data.defaultAppearanceData;
  6630. this.appearance = fakeUnicodeFont.createAppearance(this._contents.str, this.rectangle, this.rotation, fontSize, fontColor, strokeAlpha);
  6631. this._streams.push(this.appearance, _default_appearance.FakeUnicodeFont.toUnicodeStream);
  6632. } else {
  6633. (0, _util.warn)("FreeTextAnnotation: OffscreenCanvas is not supported, annotation may not render correctly.");
  6634. }
  6635. }
  6636. get hasTextContent() {
  6637. return !!this.appearance;
  6638. }
  6639. static createNewDict(annotation, xref, {
  6640. apRef,
  6641. ap
  6642. }) {
  6643. const {
  6644. color,
  6645. fontSize,
  6646. rect,
  6647. rotation,
  6648. user,
  6649. value
  6650. } = annotation;
  6651. const freetext = new _primitives.Dict(xref);
  6652. freetext.set("Type", _primitives.Name.get("Annot"));
  6653. freetext.set("Subtype", _primitives.Name.get("FreeText"));
  6654. freetext.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  6655. freetext.set("Rect", rect);
  6656. const da = `/Helv ${fontSize} Tf ${(0, _default_appearance.getPdfColor)(color, true)}`;
  6657. freetext.set("DA", da);
  6658. freetext.set("Contents", (0, _core_utils.isAscii)(value) ? value : (0, _core_utils.stringToUTF16String)(value, true));
  6659. freetext.set("F", 4);
  6660. freetext.set("Border", [0, 0, 0]);
  6661. freetext.set("Rotate", rotation);
  6662. if (user) {
  6663. freetext.set("T", (0, _core_utils.isAscii)(user) ? user : (0, _core_utils.stringToUTF16String)(user, true));
  6664. }
  6665. if (apRef || ap) {
  6666. const n = new _primitives.Dict(xref);
  6667. freetext.set("AP", n);
  6668. if (apRef) {
  6669. n.set("N", apRef);
  6670. } else {
  6671. n.set("N", ap);
  6672. }
  6673. }
  6674. return freetext;
  6675. }
  6676. static async createNewAppearanceStream(annotation, xref, params) {
  6677. const {
  6678. baseFontRef,
  6679. evaluator,
  6680. task
  6681. } = params;
  6682. const {
  6683. color,
  6684. fontSize,
  6685. rect,
  6686. rotation,
  6687. value
  6688. } = annotation;
  6689. const resources = new _primitives.Dict(xref);
  6690. const font = new _primitives.Dict(xref);
  6691. if (baseFontRef) {
  6692. font.set("Helv", baseFontRef);
  6693. } else {
  6694. const baseFont = new _primitives.Dict(xref);
  6695. baseFont.set("BaseFont", _primitives.Name.get("Helvetica"));
  6696. baseFont.set("Type", _primitives.Name.get("Font"));
  6697. baseFont.set("Subtype", _primitives.Name.get("Type1"));
  6698. baseFont.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  6699. font.set("Helv", baseFont);
  6700. }
  6701. resources.set("Font", font);
  6702. const helv = await WidgetAnnotation._getFontData(evaluator, task, {
  6703. fontName: "Helv",
  6704. fontSize
  6705. }, resources);
  6706. const [x1, y1, x2, y2] = rect;
  6707. let w = x2 - x1;
  6708. let h = y2 - y1;
  6709. if (rotation % 180 !== 0) {
  6710. [w, h] = [h, w];
  6711. }
  6712. const lines = value.split("\n");
  6713. const scale = fontSize / 1000;
  6714. let totalWidth = -Infinity;
  6715. const encodedLines = [];
  6716. for (let line of lines) {
  6717. const encoded = helv.encodeString(line);
  6718. if (encoded.length > 1) {
  6719. return null;
  6720. }
  6721. line = encoded.join("");
  6722. encodedLines.push(line);
  6723. let lineWidth = 0;
  6724. const glyphs = helv.charsToGlyphs(line);
  6725. for (const glyph of glyphs) {
  6726. lineWidth += glyph.width * scale;
  6727. }
  6728. totalWidth = Math.max(totalWidth, lineWidth);
  6729. }
  6730. let hscale = 1;
  6731. if (totalWidth > w) {
  6732. hscale = w / totalWidth;
  6733. }
  6734. let vscale = 1;
  6735. const lineHeight = _util.LINE_FACTOR * fontSize;
  6736. const lineAscent = (_util.LINE_FACTOR - _util.LINE_DESCENT_FACTOR) * fontSize;
  6737. const totalHeight = lineHeight * lines.length;
  6738. if (totalHeight > h) {
  6739. vscale = h / totalHeight;
  6740. }
  6741. const fscale = Math.min(hscale, vscale);
  6742. const newFontSize = fontSize * fscale;
  6743. let firstPoint, clipBox, matrix;
  6744. switch (rotation) {
  6745. case 0:
  6746. matrix = [1, 0, 0, 1];
  6747. clipBox = [rect[0], rect[1], w, h];
  6748. firstPoint = [rect[0], rect[3] - lineAscent];
  6749. break;
  6750. case 90:
  6751. matrix = [0, 1, -1, 0];
  6752. clipBox = [rect[1], -rect[2], w, h];
  6753. firstPoint = [rect[1], -rect[0] - lineAscent];
  6754. break;
  6755. case 180:
  6756. matrix = [-1, 0, 0, -1];
  6757. clipBox = [-rect[2], -rect[3], w, h];
  6758. firstPoint = [-rect[2], -rect[1] - lineAscent];
  6759. break;
  6760. case 270:
  6761. matrix = [0, -1, 1, 0];
  6762. clipBox = [-rect[3], rect[0], w, h];
  6763. firstPoint = [-rect[3], rect[2] - lineAscent];
  6764. break;
  6765. }
  6766. const buffer = ["q", `${matrix.join(" ")} 0 0 cm`, `${clipBox.join(" ")} re W n`, `BT`, `${(0, _default_appearance.getPdfColor)(color, true)}`, `0 Tc /Helv ${(0, _core_utils.numberToString)(newFontSize)} Tf`];
  6767. buffer.push(`${firstPoint.join(" ")} Td (${(0, _core_utils.escapeString)(encodedLines[0])}) Tj`);
  6768. const vShift = (0, _core_utils.numberToString)(lineHeight);
  6769. for (let i = 1, ii = encodedLines.length; i < ii; i++) {
  6770. const line = encodedLines[i];
  6771. buffer.push(`0 -${vShift} Td (${(0, _core_utils.escapeString)(line)}) Tj`);
  6772. }
  6773. buffer.push("ET", "Q");
  6774. const appearance = buffer.join("\n");
  6775. const appearanceStreamDict = new _primitives.Dict(xref);
  6776. appearanceStreamDict.set("FormType", 1);
  6777. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  6778. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  6779. appearanceStreamDict.set("BBox", rect);
  6780. appearanceStreamDict.set("Resources", resources);
  6781. appearanceStreamDict.set("Matrix", [1, 0, 0, 1, -rect[0], -rect[1]]);
  6782. const ap = new _stream.StringStream(appearance);
  6783. ap.dict = appearanceStreamDict;
  6784. return ap;
  6785. }
  6786. }
  6787. class LineAnnotation extends MarkupAnnotation {
  6788. constructor(params) {
  6789. super(params);
  6790. const {
  6791. dict,
  6792. xref
  6793. } = params;
  6794. this.data.annotationType = _util.AnnotationType.LINE;
  6795. this.data.hasOwnCanvas = this.data.noRotate;
  6796. const lineCoordinates = dict.getArray("L");
  6797. this.data.lineCoordinates = _util.Util.normalizeRect(lineCoordinates);
  6798. this.setLineEndings(dict.getArray("LE"));
  6799. this.data.lineEndings = this.lineEndings;
  6800. if (!this.appearance) {
  6801. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  6802. const strokeAlpha = dict.get("CA");
  6803. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  6804. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  6805. const fillAlpha = fillColor ? strokeAlpha : null;
  6806. const borderWidth = this.borderStyle.width || 1,
  6807. borderAdjust = 2 * borderWidth;
  6808. const bbox = [this.data.lineCoordinates[0] - borderAdjust, this.data.lineCoordinates[1] - borderAdjust, this.data.lineCoordinates[2] + borderAdjust, this.data.lineCoordinates[3] + borderAdjust];
  6809. if (!_util.Util.intersect(this.rectangle, bbox)) {
  6810. this.rectangle = bbox;
  6811. }
  6812. this._setDefaultAppearance({
  6813. xref,
  6814. extra: `${borderWidth} w`,
  6815. strokeColor,
  6816. fillColor,
  6817. strokeAlpha,
  6818. fillAlpha,
  6819. pointsCallback: (buffer, points) => {
  6820. buffer.push(`${lineCoordinates[0]} ${lineCoordinates[1]} m`, `${lineCoordinates[2]} ${lineCoordinates[3]} l`, "S");
  6821. return [points[0].x - borderWidth, points[1].x + borderWidth, points[3].y - borderWidth, points[1].y + borderWidth];
  6822. }
  6823. });
  6824. }
  6825. }
  6826. }
  6827. class SquareAnnotation extends MarkupAnnotation {
  6828. constructor(params) {
  6829. super(params);
  6830. const {
  6831. dict,
  6832. xref
  6833. } = params;
  6834. this.data.annotationType = _util.AnnotationType.SQUARE;
  6835. this.data.hasOwnCanvas = this.data.noRotate;
  6836. if (!this.appearance) {
  6837. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  6838. const strokeAlpha = dict.get("CA");
  6839. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  6840. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  6841. const fillAlpha = fillColor ? strokeAlpha : null;
  6842. if (this.borderStyle.width === 0 && !fillColor) {
  6843. return;
  6844. }
  6845. this._setDefaultAppearance({
  6846. xref,
  6847. extra: `${this.borderStyle.width} w`,
  6848. strokeColor,
  6849. fillColor,
  6850. strokeAlpha,
  6851. fillAlpha,
  6852. pointsCallback: (buffer, points) => {
  6853. const x = points[2].x + this.borderStyle.width / 2;
  6854. const y = points[2].y + this.borderStyle.width / 2;
  6855. const width = points[3].x - points[2].x - this.borderStyle.width;
  6856. const height = points[1].y - points[3].y - this.borderStyle.width;
  6857. buffer.push(`${x} ${y} ${width} ${height} re`);
  6858. if (fillColor) {
  6859. buffer.push("B");
  6860. } else {
  6861. buffer.push("S");
  6862. }
  6863. return [points[0].x, points[1].x, points[3].y, points[1].y];
  6864. }
  6865. });
  6866. }
  6867. }
  6868. }
  6869. class CircleAnnotation extends MarkupAnnotation {
  6870. constructor(params) {
  6871. super(params);
  6872. const {
  6873. dict,
  6874. xref
  6875. } = params;
  6876. this.data.annotationType = _util.AnnotationType.CIRCLE;
  6877. if (!this.appearance) {
  6878. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  6879. const strokeAlpha = dict.get("CA");
  6880. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  6881. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  6882. const fillAlpha = fillColor ? strokeAlpha : null;
  6883. if (this.borderStyle.width === 0 && !fillColor) {
  6884. return;
  6885. }
  6886. const controlPointsDistance = 4 / 3 * Math.tan(Math.PI / (2 * 4));
  6887. this._setDefaultAppearance({
  6888. xref,
  6889. extra: `${this.borderStyle.width} w`,
  6890. strokeColor,
  6891. fillColor,
  6892. strokeAlpha,
  6893. fillAlpha,
  6894. pointsCallback: (buffer, points) => {
  6895. const x0 = points[0].x + this.borderStyle.width / 2;
  6896. const y0 = points[0].y - this.borderStyle.width / 2;
  6897. const x1 = points[3].x - this.borderStyle.width / 2;
  6898. const y1 = points[3].y + this.borderStyle.width / 2;
  6899. const xMid = x0 + (x1 - x0) / 2;
  6900. const yMid = y0 + (y1 - y0) / 2;
  6901. const xOffset = (x1 - x0) / 2 * controlPointsDistance;
  6902. const yOffset = (y1 - y0) / 2 * controlPointsDistance;
  6903. buffer.push(`${xMid} ${y1} m`, `${xMid + xOffset} ${y1} ${x1} ${yMid + yOffset} ${x1} ${yMid} c`, `${x1} ${yMid - yOffset} ${xMid + xOffset} ${y0} ${xMid} ${y0} c`, `${xMid - xOffset} ${y0} ${x0} ${yMid - yOffset} ${x0} ${yMid} c`, `${x0} ${yMid + yOffset} ${xMid - xOffset} ${y1} ${xMid} ${y1} c`, "h");
  6904. if (fillColor) {
  6905. buffer.push("B");
  6906. } else {
  6907. buffer.push("S");
  6908. }
  6909. return [points[0].x, points[1].x, points[3].y, points[1].y];
  6910. }
  6911. });
  6912. }
  6913. }
  6914. }
  6915. class PolylineAnnotation extends MarkupAnnotation {
  6916. constructor(params) {
  6917. super(params);
  6918. const {
  6919. dict,
  6920. xref
  6921. } = params;
  6922. this.data.annotationType = _util.AnnotationType.POLYLINE;
  6923. this.data.hasOwnCanvas = this.data.noRotate;
  6924. this.data.vertices = [];
  6925. if (!(this instanceof PolygonAnnotation)) {
  6926. this.setLineEndings(dict.getArray("LE"));
  6927. this.data.lineEndings = this.lineEndings;
  6928. }
  6929. const rawVertices = dict.getArray("Vertices");
  6930. if (!Array.isArray(rawVertices)) {
  6931. return;
  6932. }
  6933. for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
  6934. this.data.vertices.push({
  6935. x: rawVertices[i],
  6936. y: rawVertices[i + 1]
  6937. });
  6938. }
  6939. if (!this.appearance) {
  6940. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  6941. const strokeAlpha = dict.get("CA");
  6942. const borderWidth = this.borderStyle.width || 1,
  6943. borderAdjust = 2 * borderWidth;
  6944. const bbox = [Infinity, Infinity, -Infinity, -Infinity];
  6945. for (const vertex of this.data.vertices) {
  6946. bbox[0] = Math.min(bbox[0], vertex.x - borderAdjust);
  6947. bbox[1] = Math.min(bbox[1], vertex.y - borderAdjust);
  6948. bbox[2] = Math.max(bbox[2], vertex.x + borderAdjust);
  6949. bbox[3] = Math.max(bbox[3], vertex.y + borderAdjust);
  6950. }
  6951. if (!_util.Util.intersect(this.rectangle, bbox)) {
  6952. this.rectangle = bbox;
  6953. }
  6954. this._setDefaultAppearance({
  6955. xref,
  6956. extra: `${borderWidth} w`,
  6957. strokeColor,
  6958. strokeAlpha,
  6959. pointsCallback: (buffer, points) => {
  6960. const vertices = this.data.vertices;
  6961. for (let i = 0, ii = vertices.length; i < ii; i++) {
  6962. buffer.push(`${vertices[i].x} ${vertices[i].y} ${i === 0 ? "m" : "l"}`);
  6963. }
  6964. buffer.push("S");
  6965. return [points[0].x, points[1].x, points[3].y, points[1].y];
  6966. }
  6967. });
  6968. }
  6969. }
  6970. }
  6971. class PolygonAnnotation extends PolylineAnnotation {
  6972. constructor(params) {
  6973. super(params);
  6974. this.data.annotationType = _util.AnnotationType.POLYGON;
  6975. }
  6976. }
  6977. class CaretAnnotation extends MarkupAnnotation {
  6978. constructor(params) {
  6979. super(params);
  6980. this.data.annotationType = _util.AnnotationType.CARET;
  6981. }
  6982. }
  6983. class InkAnnotation extends MarkupAnnotation {
  6984. constructor(params) {
  6985. super(params);
  6986. this.data.hasOwnCanvas = this.data.noRotate;
  6987. const {
  6988. dict,
  6989. xref
  6990. } = params;
  6991. this.data.annotationType = _util.AnnotationType.INK;
  6992. this.data.inkLists = [];
  6993. const rawInkLists = dict.getArray("InkList");
  6994. if (!Array.isArray(rawInkLists)) {
  6995. return;
  6996. }
  6997. for (let i = 0, ii = rawInkLists.length; i < ii; ++i) {
  6998. this.data.inkLists.push([]);
  6999. for (let j = 0, jj = rawInkLists[i].length; j < jj; j += 2) {
  7000. this.data.inkLists[i].push({
  7001. x: xref.fetchIfRef(rawInkLists[i][j]),
  7002. y: xref.fetchIfRef(rawInkLists[i][j + 1])
  7003. });
  7004. }
  7005. }
  7006. if (!this.appearance) {
  7007. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  7008. const strokeAlpha = dict.get("CA");
  7009. const borderWidth = this.borderStyle.width || 1,
  7010. borderAdjust = 2 * borderWidth;
  7011. const bbox = [Infinity, Infinity, -Infinity, -Infinity];
  7012. for (const inkLists of this.data.inkLists) {
  7013. for (const vertex of inkLists) {
  7014. bbox[0] = Math.min(bbox[0], vertex.x - borderAdjust);
  7015. bbox[1] = Math.min(bbox[1], vertex.y - borderAdjust);
  7016. bbox[2] = Math.max(bbox[2], vertex.x + borderAdjust);
  7017. bbox[3] = Math.max(bbox[3], vertex.y + borderAdjust);
  7018. }
  7019. }
  7020. if (!_util.Util.intersect(this.rectangle, bbox)) {
  7021. this.rectangle = bbox;
  7022. }
  7023. this._setDefaultAppearance({
  7024. xref,
  7025. extra: `${borderWidth} w`,
  7026. strokeColor,
  7027. strokeAlpha,
  7028. pointsCallback: (buffer, points) => {
  7029. for (const inkList of this.data.inkLists) {
  7030. for (let i = 0, ii = inkList.length; i < ii; i++) {
  7031. buffer.push(`${inkList[i].x} ${inkList[i].y} ${i === 0 ? "m" : "l"}`);
  7032. }
  7033. buffer.push("S");
  7034. }
  7035. return [points[0].x, points[1].x, points[3].y, points[1].y];
  7036. }
  7037. });
  7038. }
  7039. }
  7040. static createNewDict(annotation, xref, {
  7041. apRef,
  7042. ap
  7043. }) {
  7044. const {
  7045. color,
  7046. opacity,
  7047. paths,
  7048. rect,
  7049. rotation,
  7050. thickness
  7051. } = annotation;
  7052. const ink = new _primitives.Dict(xref);
  7053. ink.set("Type", _primitives.Name.get("Annot"));
  7054. ink.set("Subtype", _primitives.Name.get("Ink"));
  7055. ink.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  7056. ink.set("Rect", rect);
  7057. ink.set("InkList", paths.map(p => p.points));
  7058. ink.set("F", 4);
  7059. ink.set("Rotate", rotation);
  7060. const bs = new _primitives.Dict(xref);
  7061. ink.set("BS", bs);
  7062. bs.set("W", thickness);
  7063. ink.set("C", Array.from(color, c => c / 255));
  7064. ink.set("CA", opacity);
  7065. const n = new _primitives.Dict(xref);
  7066. ink.set("AP", n);
  7067. if (apRef) {
  7068. n.set("N", apRef);
  7069. } else {
  7070. n.set("N", ap);
  7071. }
  7072. return ink;
  7073. }
  7074. static async createNewAppearanceStream(annotation, xref, params) {
  7075. const {
  7076. color,
  7077. rect,
  7078. paths,
  7079. thickness,
  7080. opacity
  7081. } = annotation;
  7082. const appearanceBuffer = [`${thickness} w 1 J 1 j`, `${(0, _default_appearance.getPdfColor)(color, false)}`];
  7083. if (opacity !== 1) {
  7084. appearanceBuffer.push("/R0 gs");
  7085. }
  7086. const buffer = [];
  7087. for (const {
  7088. bezier
  7089. } of paths) {
  7090. buffer.length = 0;
  7091. buffer.push(`${(0, _core_utils.numberToString)(bezier[0])} ${(0, _core_utils.numberToString)(bezier[1])} m`);
  7092. for (let i = 2, ii = bezier.length; i < ii; i += 6) {
  7093. const curve = bezier.slice(i, i + 6).map(_core_utils.numberToString).join(" ");
  7094. buffer.push(`${curve} c`);
  7095. }
  7096. buffer.push("S");
  7097. appearanceBuffer.push(buffer.join("\n"));
  7098. }
  7099. const appearance = appearanceBuffer.join("\n");
  7100. const appearanceStreamDict = new _primitives.Dict(xref);
  7101. appearanceStreamDict.set("FormType", 1);
  7102. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  7103. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  7104. appearanceStreamDict.set("BBox", rect);
  7105. appearanceStreamDict.set("Length", appearance.length);
  7106. if (opacity !== 1) {
  7107. const resources = new _primitives.Dict(xref);
  7108. const extGState = new _primitives.Dict(xref);
  7109. const r0 = new _primitives.Dict(xref);
  7110. r0.set("CA", opacity);
  7111. r0.set("Type", _primitives.Name.get("ExtGState"));
  7112. extGState.set("R0", r0);
  7113. resources.set("ExtGState", extGState);
  7114. appearanceStreamDict.set("Resources", resources);
  7115. }
  7116. const ap = new _stream.StringStream(appearance);
  7117. ap.dict = appearanceStreamDict;
  7118. return ap;
  7119. }
  7120. }
  7121. class HighlightAnnotation extends MarkupAnnotation {
  7122. constructor(params) {
  7123. super(params);
  7124. const {
  7125. dict,
  7126. xref
  7127. } = params;
  7128. this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
  7129. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  7130. if (quadPoints) {
  7131. const resources = this.appearance?.dict.get("Resources");
  7132. if (!this.appearance || !resources?.has("ExtGState")) {
  7133. if (this.appearance) {
  7134. (0, _util.warn)("HighlightAnnotation - ignoring built-in appearance stream.");
  7135. }
  7136. const fillColor = this.color ? getPdfColorArray(this.color) : [1, 1, 0];
  7137. const fillAlpha = dict.get("CA");
  7138. this._setDefaultAppearance({
  7139. xref,
  7140. fillColor,
  7141. blendMode: "Multiply",
  7142. fillAlpha,
  7143. pointsCallback: (buffer, points) => {
  7144. buffer.push(`${points[0].x} ${points[0].y} m`, `${points[1].x} ${points[1].y} l`, `${points[3].x} ${points[3].y} l`, `${points[2].x} ${points[2].y} l`, "f");
  7145. return [points[0].x, points[1].x, points[3].y, points[1].y];
  7146. }
  7147. });
  7148. }
  7149. } else {
  7150. this.data.popupRef = null;
  7151. }
  7152. }
  7153. }
  7154. class UnderlineAnnotation extends MarkupAnnotation {
  7155. constructor(params) {
  7156. super(params);
  7157. const {
  7158. dict,
  7159. xref
  7160. } = params;
  7161. this.data.annotationType = _util.AnnotationType.UNDERLINE;
  7162. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  7163. if (quadPoints) {
  7164. if (!this.appearance) {
  7165. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  7166. const strokeAlpha = dict.get("CA");
  7167. this._setDefaultAppearance({
  7168. xref,
  7169. extra: "[] 0 d 0.571 w",
  7170. strokeColor,
  7171. strokeAlpha,
  7172. pointsCallback: (buffer, points) => {
  7173. buffer.push(`${points[2].x} ${points[2].y + 1.3} m`, `${points[3].x} ${points[3].y + 1.3} l`, "S");
  7174. return [points[0].x, points[1].x, points[3].y, points[1].y];
  7175. }
  7176. });
  7177. }
  7178. } else {
  7179. this.data.popupRef = null;
  7180. }
  7181. }
  7182. }
  7183. class SquigglyAnnotation extends MarkupAnnotation {
  7184. constructor(params) {
  7185. super(params);
  7186. const {
  7187. dict,
  7188. xref
  7189. } = params;
  7190. this.data.annotationType = _util.AnnotationType.SQUIGGLY;
  7191. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  7192. if (quadPoints) {
  7193. if (!this.appearance) {
  7194. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  7195. const strokeAlpha = dict.get("CA");
  7196. this._setDefaultAppearance({
  7197. xref,
  7198. extra: "[] 0 d 1 w",
  7199. strokeColor,
  7200. strokeAlpha,
  7201. pointsCallback: (buffer, points) => {
  7202. const dy = (points[0].y - points[2].y) / 6;
  7203. let shift = dy;
  7204. let x = points[2].x;
  7205. const y = points[2].y;
  7206. const xEnd = points[3].x;
  7207. buffer.push(`${x} ${y + shift} m`);
  7208. do {
  7209. x += 2;
  7210. shift = shift === 0 ? dy : 0;
  7211. buffer.push(`${x} ${y + shift} l`);
  7212. } while (x < xEnd);
  7213. buffer.push("S");
  7214. return [points[2].x, xEnd, y - 2 * dy, y + 2 * dy];
  7215. }
  7216. });
  7217. }
  7218. } else {
  7219. this.data.popupRef = null;
  7220. }
  7221. }
  7222. }
  7223. class StrikeOutAnnotation extends MarkupAnnotation {
  7224. constructor(params) {
  7225. super(params);
  7226. const {
  7227. dict,
  7228. xref
  7229. } = params;
  7230. this.data.annotationType = _util.AnnotationType.STRIKEOUT;
  7231. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  7232. if (quadPoints) {
  7233. if (!this.appearance) {
  7234. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  7235. const strokeAlpha = dict.get("CA");
  7236. this._setDefaultAppearance({
  7237. xref,
  7238. extra: "[] 0 d 1 w",
  7239. strokeColor,
  7240. strokeAlpha,
  7241. pointsCallback: (buffer, points) => {
  7242. buffer.push(`${(points[0].x + points[2].x) / 2} ` + `${(points[0].y + points[2].y) / 2} m`, `${(points[1].x + points[3].x) / 2} ` + `${(points[1].y + points[3].y) / 2} l`, "S");
  7243. return [points[0].x, points[1].x, points[3].y, points[1].y];
  7244. }
  7245. });
  7246. }
  7247. } else {
  7248. this.data.popupRef = null;
  7249. }
  7250. }
  7251. }
  7252. class StampAnnotation extends MarkupAnnotation {
  7253. constructor(params) {
  7254. super(params);
  7255. this.data.annotationType = _util.AnnotationType.STAMP;
  7256. this.data.hasOwnCanvas = this.data.noRotate;
  7257. }
  7258. static async createImage(bitmap, xref) {
  7259. const {
  7260. width,
  7261. height
  7262. } = bitmap;
  7263. const canvas = new OffscreenCanvas(width, height);
  7264. const ctx = canvas.getContext("2d", {
  7265. alpha: true
  7266. });
  7267. ctx.drawImage(bitmap, 0, 0);
  7268. const data = ctx.getImageData(0, 0, width, height).data;
  7269. const buf32 = new Uint32Array(data.buffer);
  7270. const hasAlpha = buf32.some(_util.FeatureTest.isLittleEndian ? x => x >>> 24 !== 0xff : x => (x & 0xff) !== 0xff);
  7271. if (hasAlpha) {
  7272. ctx.fillStyle = "white";
  7273. ctx.fillRect(0, 0, width, height);
  7274. ctx.drawImage(bitmap, 0, 0);
  7275. }
  7276. const jpegBufferPromise = canvas.convertToBlob({
  7277. type: "image/jpeg",
  7278. quality: 1
  7279. }).then(blob => {
  7280. return blob.arrayBuffer();
  7281. });
  7282. const xobjectName = _primitives.Name.get("XObject");
  7283. const imageName = _primitives.Name.get("Image");
  7284. const image = new _primitives.Dict(xref);
  7285. image.set("Type", xobjectName);
  7286. image.set("Subtype", imageName);
  7287. image.set("BitsPerComponent", 8);
  7288. image.set("ColorSpace", _primitives.Name.get("DeviceRGB"));
  7289. image.set("Filter", _primitives.Name.get("DCTDecode"));
  7290. image.set("BBox", [0, 0, width, height]);
  7291. image.set("Width", width);
  7292. image.set("Height", height);
  7293. let smaskStream = null;
  7294. if (hasAlpha) {
  7295. const alphaBuffer = new Uint8Array(buf32.length);
  7296. if (_util.FeatureTest.isLittleEndian) {
  7297. for (let i = 0, ii = buf32.length; i < ii; i++) {
  7298. alphaBuffer[i] = buf32[i] >>> 24;
  7299. }
  7300. } else {
  7301. for (let i = 0, ii = buf32.length; i < ii; i++) {
  7302. alphaBuffer[i] = buf32[i] & 0xff;
  7303. }
  7304. }
  7305. const smask = new _primitives.Dict(xref);
  7306. smask.set("Type", xobjectName);
  7307. smask.set("Subtype", imageName);
  7308. smask.set("BitsPerComponent", 8);
  7309. smask.set("ColorSpace", _primitives.Name.get("DeviceGray"));
  7310. smask.set("Width", width);
  7311. smask.set("Height", height);
  7312. smaskStream = new _stream.Stream(alphaBuffer, 0, 0, smask);
  7313. }
  7314. const imageStream = new _stream.Stream(await jpegBufferPromise, 0, 0, image);
  7315. return {
  7316. imageStream,
  7317. smaskStream,
  7318. width,
  7319. height
  7320. };
  7321. }
  7322. static createNewDict(annotation, xref, {
  7323. apRef,
  7324. ap
  7325. }) {
  7326. const {
  7327. rect,
  7328. rotation,
  7329. user
  7330. } = annotation;
  7331. const stamp = new _primitives.Dict(xref);
  7332. stamp.set("Type", _primitives.Name.get("Annot"));
  7333. stamp.set("Subtype", _primitives.Name.get("Stamp"));
  7334. stamp.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  7335. stamp.set("Rect", rect);
  7336. stamp.set("F", 4);
  7337. stamp.set("Border", [0, 0, 0]);
  7338. stamp.set("Rotate", rotation);
  7339. if (user) {
  7340. stamp.set("T", (0, _core_utils.isAscii)(user) ? user : (0, _core_utils.stringToUTF16String)(user, true));
  7341. }
  7342. if (apRef || ap) {
  7343. const n = new _primitives.Dict(xref);
  7344. stamp.set("AP", n);
  7345. if (apRef) {
  7346. n.set("N", apRef);
  7347. } else {
  7348. n.set("N", ap);
  7349. }
  7350. }
  7351. return stamp;
  7352. }
  7353. static async createNewAppearanceStream(annotation, xref, params) {
  7354. const {
  7355. rotation
  7356. } = annotation;
  7357. const {
  7358. imageRef,
  7359. width,
  7360. height
  7361. } = params.image;
  7362. const resources = new _primitives.Dict(xref);
  7363. const xobject = new _primitives.Dict(xref);
  7364. resources.set("XObject", xobject);
  7365. xobject.set("Im0", imageRef);
  7366. const appearance = `q ${width} 0 0 ${height} 0 0 cm /Im0 Do Q`;
  7367. const appearanceStreamDict = new _primitives.Dict(xref);
  7368. appearanceStreamDict.set("FormType", 1);
  7369. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  7370. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  7371. appearanceStreamDict.set("BBox", [0, 0, width, height]);
  7372. appearanceStreamDict.set("Resources", resources);
  7373. if (rotation) {
  7374. const matrix = (0, _core_utils.getRotationMatrix)(rotation, width, height);
  7375. appearanceStreamDict.set("Matrix", matrix);
  7376. }
  7377. const ap = new _stream.StringStream(appearance);
  7378. ap.dict = appearanceStreamDict;
  7379. return ap;
  7380. }
  7381. }
  7382. class FileAttachmentAnnotation extends MarkupAnnotation {
  7383. constructor(params) {
  7384. super(params);
  7385. const {
  7386. dict,
  7387. xref
  7388. } = params;
  7389. const file = new _file_spec.FileSpec(dict.get("FS"), xref);
  7390. this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
  7391. this.data.hasOwnCanvas = this.data.noRotate;
  7392. this.data.file = file.serializable;
  7393. const name = dict.get("Name");
  7394. this.data.name = name instanceof _primitives.Name ? (0, _util.stringToPDFString)(name.name) : "PushPin";
  7395. const fillAlpha = dict.get("ca");
  7396. this.data.fillAlpha = typeof fillAlpha === "number" && fillAlpha >= 0 && fillAlpha <= 1 ? fillAlpha : null;
  7397. }
  7398. }
  7399. /***/ }),
  7400. /* 11 */
  7401. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7402. Object.defineProperty(exports, "__esModule", ({
  7403. value: true
  7404. }));
  7405. exports.FakeUnicodeFont = void 0;
  7406. exports.createDefaultAppearance = createDefaultAppearance;
  7407. exports.getPdfColor = getPdfColor;
  7408. exports.parseAppearanceStream = parseAppearanceStream;
  7409. exports.parseDefaultAppearance = parseDefaultAppearance;
  7410. var _primitives = __w_pdfjs_require__(4);
  7411. var _core_utils = __w_pdfjs_require__(3);
  7412. var _util = __w_pdfjs_require__(2);
  7413. var _colorspace = __w_pdfjs_require__(12);
  7414. var _evaluator = __w_pdfjs_require__(13);
  7415. var _image_utils = __w_pdfjs_require__(59);
  7416. var _function = __w_pdfjs_require__(57);
  7417. var _stream = __w_pdfjs_require__(8);
  7418. class DefaultAppearanceEvaluator extends _evaluator.EvaluatorPreprocessor {
  7419. constructor(str) {
  7420. super(new _stream.StringStream(str));
  7421. }
  7422. parse() {
  7423. const operation = {
  7424. fn: 0,
  7425. args: []
  7426. };
  7427. const result = {
  7428. fontSize: 0,
  7429. fontName: "",
  7430. fontColor: new Uint8ClampedArray(3)
  7431. };
  7432. try {
  7433. while (true) {
  7434. operation.args.length = 0;
  7435. if (!this.read(operation)) {
  7436. break;
  7437. }
  7438. if (this.savedStatesDepth !== 0) {
  7439. continue;
  7440. }
  7441. const {
  7442. fn,
  7443. args
  7444. } = operation;
  7445. switch (fn | 0) {
  7446. case _util.OPS.setFont:
  7447. const [fontName, fontSize] = args;
  7448. if (fontName instanceof _primitives.Name) {
  7449. result.fontName = fontName.name;
  7450. }
  7451. if (typeof fontSize === "number" && fontSize > 0) {
  7452. result.fontSize = fontSize;
  7453. }
  7454. break;
  7455. case _util.OPS.setFillRGBColor:
  7456. _colorspace.ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
  7457. break;
  7458. case _util.OPS.setFillGray:
  7459. _colorspace.ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
  7460. break;
  7461. case _util.OPS.setFillCMYKColor:
  7462. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
  7463. break;
  7464. }
  7465. }
  7466. } catch (reason) {
  7467. (0, _util.warn)(`parseDefaultAppearance - ignoring errors: "${reason}".`);
  7468. }
  7469. return result;
  7470. }
  7471. }
  7472. function parseDefaultAppearance(str) {
  7473. return new DefaultAppearanceEvaluator(str).parse();
  7474. }
  7475. class AppearanceStreamEvaluator extends _evaluator.EvaluatorPreprocessor {
  7476. constructor(stream, evaluatorOptions, xref) {
  7477. super(stream);
  7478. this.stream = stream;
  7479. this.evaluatorOptions = evaluatorOptions;
  7480. this.xref = xref;
  7481. this.resources = stream.dict?.get("Resources");
  7482. }
  7483. parse() {
  7484. const operation = {
  7485. fn: 0,
  7486. args: []
  7487. };
  7488. let result = {
  7489. scaleFactor: 1,
  7490. fontSize: 0,
  7491. fontName: "",
  7492. fontColor: new Uint8ClampedArray(3),
  7493. fillColorSpace: _colorspace.ColorSpace.singletons.gray
  7494. };
  7495. let breakLoop = false;
  7496. const stack = [];
  7497. try {
  7498. while (true) {
  7499. operation.args.length = 0;
  7500. if (breakLoop || !this.read(operation)) {
  7501. break;
  7502. }
  7503. const {
  7504. fn,
  7505. args
  7506. } = operation;
  7507. switch (fn | 0) {
  7508. case _util.OPS.save:
  7509. stack.push({
  7510. scaleFactor: result.scaleFactor,
  7511. fontSize: result.fontSize,
  7512. fontName: result.fontName,
  7513. fontColor: result.fontColor.slice(),
  7514. fillColorSpace: result.fillColorSpace
  7515. });
  7516. break;
  7517. case _util.OPS.restore:
  7518. result = stack.pop() || result;
  7519. break;
  7520. case _util.OPS.setTextMatrix:
  7521. result.scaleFactor *= Math.hypot(args[0], args[1]);
  7522. break;
  7523. case _util.OPS.setFont:
  7524. const [fontName, fontSize] = args;
  7525. if (fontName instanceof _primitives.Name) {
  7526. result.fontName = fontName.name;
  7527. }
  7528. if (typeof fontSize === "number" && fontSize > 0) {
  7529. result.fontSize = fontSize * result.scaleFactor;
  7530. }
  7531. break;
  7532. case _util.OPS.setFillColorSpace:
  7533. result.fillColorSpace = _colorspace.ColorSpace.parse({
  7534. cs: args[0],
  7535. xref: this.xref,
  7536. resources: this.resources,
  7537. pdfFunctionFactory: this._pdfFunctionFactory,
  7538. localColorSpaceCache: this._localColorSpaceCache
  7539. });
  7540. break;
  7541. case _util.OPS.setFillColor:
  7542. const cs = result.fillColorSpace;
  7543. cs.getRgbItem(args, 0, result.fontColor, 0);
  7544. break;
  7545. case _util.OPS.setFillRGBColor:
  7546. _colorspace.ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
  7547. break;
  7548. case _util.OPS.setFillGray:
  7549. _colorspace.ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
  7550. break;
  7551. case _util.OPS.setFillCMYKColor:
  7552. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
  7553. break;
  7554. case _util.OPS.showText:
  7555. case _util.OPS.showSpacedText:
  7556. case _util.OPS.nextLineShowText:
  7557. case _util.OPS.nextLineSetSpacingShowText:
  7558. breakLoop = true;
  7559. break;
  7560. }
  7561. }
  7562. } catch (reason) {
  7563. (0, _util.warn)(`parseAppearanceStream - ignoring errors: "${reason}".`);
  7564. }
  7565. this.stream.reset();
  7566. delete result.scaleFactor;
  7567. delete result.fillColorSpace;
  7568. return result;
  7569. }
  7570. get _localColorSpaceCache() {
  7571. return (0, _util.shadow)(this, "_localColorSpaceCache", new _image_utils.LocalColorSpaceCache());
  7572. }
  7573. get _pdfFunctionFactory() {
  7574. const pdfFunctionFactory = new _function.PDFFunctionFactory({
  7575. xref: this.xref,
  7576. isEvalSupported: this.evaluatorOptions.isEvalSupported
  7577. });
  7578. return (0, _util.shadow)(this, "_pdfFunctionFactory", pdfFunctionFactory);
  7579. }
  7580. }
  7581. function parseAppearanceStream(stream, evaluatorOptions, xref) {
  7582. return new AppearanceStreamEvaluator(stream, evaluatorOptions, xref).parse();
  7583. }
  7584. function getPdfColor(color, isFill) {
  7585. if (color[0] === color[1] && color[1] === color[2]) {
  7586. const gray = color[0] / 255;
  7587. return `${(0, _core_utils.numberToString)(gray)} ${isFill ? "g" : "G"}`;
  7588. }
  7589. return Array.from(color, c => (0, _core_utils.numberToString)(c / 255)).join(" ") + ` ${isFill ? "rg" : "RG"}`;
  7590. }
  7591. function createDefaultAppearance({
  7592. fontSize,
  7593. fontName,
  7594. fontColor
  7595. }) {
  7596. return `/${(0, _core_utils.escapePDFName)(fontName)} ${fontSize} Tf ${getPdfColor(fontColor, true)}`;
  7597. }
  7598. class FakeUnicodeFont {
  7599. constructor(xref, fontFamily) {
  7600. this.xref = xref;
  7601. this.widths = null;
  7602. this.firstChar = Infinity;
  7603. this.lastChar = -Infinity;
  7604. this.fontFamily = fontFamily;
  7605. const canvas = new OffscreenCanvas(1, 1);
  7606. this.ctxMeasure = canvas.getContext("2d");
  7607. if (!FakeUnicodeFont._fontNameId) {
  7608. FakeUnicodeFont._fontNameId = 1;
  7609. }
  7610. this.fontName = _primitives.Name.get(`InvalidPDFjsFont_${fontFamily}_${FakeUnicodeFont._fontNameId++}`);
  7611. }
  7612. get toUnicodeRef() {
  7613. if (!FakeUnicodeFont._toUnicodeRef) {
  7614. const toUnicode = `/CIDInit /ProcSet findresource begin
  7615. 12 dict begin
  7616. begincmap
  7617. /CIDSystemInfo
  7618. << /Registry (Adobe)
  7619. /Ordering (UCS) /Supplement 0 >> def
  7620. /CMapName /Adobe-Identity-UCS def
  7621. /CMapType 2 def
  7622. 1 begincodespacerange
  7623. <0000> <FFFF>
  7624. endcodespacerange
  7625. 1 beginbfrange
  7626. <0000> <FFFF> <0000>
  7627. endbfrange
  7628. endcmap CMapName currentdict /CMap defineresource pop end end`;
  7629. const toUnicodeStream = FakeUnicodeFont.toUnicodeStream = new _stream.StringStream(toUnicode);
  7630. const toUnicodeDict = new _primitives.Dict(this.xref);
  7631. toUnicodeStream.dict = toUnicodeDict;
  7632. toUnicodeDict.set("Length", toUnicode.length);
  7633. FakeUnicodeFont._toUnicodeRef = this.xref.getNewPersistentRef(toUnicodeStream);
  7634. }
  7635. return FakeUnicodeFont._toUnicodeRef;
  7636. }
  7637. get fontDescriptorRef() {
  7638. if (!FakeUnicodeFont._fontDescriptorRef) {
  7639. const fontDescriptor = new _primitives.Dict(this.xref);
  7640. fontDescriptor.set("Type", _primitives.Name.get("FontDescriptor"));
  7641. fontDescriptor.set("FontName", this.fontName);
  7642. fontDescriptor.set("FontFamily", "MyriadPro Regular");
  7643. fontDescriptor.set("FontBBox", [0, 0, 0, 0]);
  7644. fontDescriptor.set("FontStretch", _primitives.Name.get("Normal"));
  7645. fontDescriptor.set("FontWeight", 400);
  7646. fontDescriptor.set("ItalicAngle", 0);
  7647. FakeUnicodeFont._fontDescriptorRef = this.xref.getNewPersistentRef(fontDescriptor);
  7648. }
  7649. return FakeUnicodeFont._fontDescriptorRef;
  7650. }
  7651. get descendantFontRef() {
  7652. const descendantFont = new _primitives.Dict(this.xref);
  7653. descendantFont.set("BaseFont", this.fontName);
  7654. descendantFont.set("Type", _primitives.Name.get("Font"));
  7655. descendantFont.set("Subtype", _primitives.Name.get("CIDFontType0"));
  7656. descendantFont.set("CIDToGIDMap", _primitives.Name.get("Identity"));
  7657. descendantFont.set("FirstChar", this.firstChar);
  7658. descendantFont.set("LastChar", this.lastChar);
  7659. descendantFont.set("FontDescriptor", this.fontDescriptorRef);
  7660. descendantFont.set("DW", 1000);
  7661. const widths = [];
  7662. const chars = [...this.widths.entries()].sort();
  7663. let currentChar = null;
  7664. let currentWidths = null;
  7665. for (const [char, width] of chars) {
  7666. if (!currentChar) {
  7667. currentChar = char;
  7668. currentWidths = [width];
  7669. continue;
  7670. }
  7671. if (char === currentChar + currentWidths.length) {
  7672. currentWidths.push(width);
  7673. } else {
  7674. widths.push(currentChar, currentWidths);
  7675. currentChar = char;
  7676. currentWidths = [width];
  7677. }
  7678. }
  7679. if (currentChar) {
  7680. widths.push(currentChar, currentWidths);
  7681. }
  7682. descendantFont.set("W", widths);
  7683. const cidSystemInfo = new _primitives.Dict(this.xref);
  7684. cidSystemInfo.set("Ordering", "Identity");
  7685. cidSystemInfo.set("Registry", "Adobe");
  7686. cidSystemInfo.set("Supplement", 0);
  7687. descendantFont.set("CIDSystemInfo", cidSystemInfo);
  7688. return this.xref.getNewPersistentRef(descendantFont);
  7689. }
  7690. get baseFontRef() {
  7691. const baseFont = new _primitives.Dict(this.xref);
  7692. baseFont.set("BaseFont", this.fontName);
  7693. baseFont.set("Type", _primitives.Name.get("Font"));
  7694. baseFont.set("Subtype", _primitives.Name.get("Type0"));
  7695. baseFont.set("Encoding", _primitives.Name.get("Identity-H"));
  7696. baseFont.set("DescendantFonts", [this.descendantFontRef]);
  7697. baseFont.set("ToUnicode", this.toUnicodeRef);
  7698. return this.xref.getNewPersistentRef(baseFont);
  7699. }
  7700. get resources() {
  7701. const resources = new _primitives.Dict(this.xref);
  7702. const font = new _primitives.Dict(this.xref);
  7703. font.set(this.fontName.name, this.baseFontRef);
  7704. resources.set("Font", font);
  7705. return resources;
  7706. }
  7707. _createContext() {
  7708. this.widths = new Map();
  7709. this.ctxMeasure.font = `1000px ${this.fontFamily}`;
  7710. return this.ctxMeasure;
  7711. }
  7712. createFontResources(text) {
  7713. const ctx = this._createContext();
  7714. for (const line of text.split(/\r\n?|\n/)) {
  7715. for (const char of line.split("")) {
  7716. const code = char.charCodeAt(0);
  7717. if (this.widths.has(code)) {
  7718. continue;
  7719. }
  7720. const metrics = ctx.measureText(char);
  7721. const width = Math.ceil(metrics.width);
  7722. this.widths.set(code, width);
  7723. this.firstChar = Math.min(code, this.firstChar);
  7724. this.lastChar = Math.max(code, this.lastChar);
  7725. }
  7726. }
  7727. return this.resources;
  7728. }
  7729. createAppearance(text, rect, rotation, fontSize, bgColor, strokeAlpha) {
  7730. const ctx = this._createContext();
  7731. const lines = [];
  7732. let maxWidth = -Infinity;
  7733. for (const line of text.split(/\r\n?|\n/)) {
  7734. lines.push(line);
  7735. const lineWidth = ctx.measureText(line).width;
  7736. maxWidth = Math.max(maxWidth, lineWidth);
  7737. for (const char of line.split("")) {
  7738. const code = char.charCodeAt(0);
  7739. let width = this.widths.get(code);
  7740. if (width === undefined) {
  7741. const metrics = ctx.measureText(char);
  7742. width = Math.ceil(metrics.width);
  7743. this.widths.set(code, width);
  7744. this.firstChar = Math.min(code, this.firstChar);
  7745. this.lastChar = Math.max(code, this.lastChar);
  7746. }
  7747. }
  7748. }
  7749. maxWidth *= fontSize / 1000;
  7750. const [x1, y1, x2, y2] = rect;
  7751. let w = x2 - x1;
  7752. let h = y2 - y1;
  7753. if (rotation % 180 !== 0) {
  7754. [w, h] = [h, w];
  7755. }
  7756. let hscale = 1;
  7757. if (maxWidth > w) {
  7758. hscale = w / maxWidth;
  7759. }
  7760. let vscale = 1;
  7761. const lineHeight = _util.LINE_FACTOR * fontSize;
  7762. const lineDescent = _util.LINE_DESCENT_FACTOR * fontSize;
  7763. const maxHeight = lineHeight * lines.length;
  7764. if (maxHeight > h) {
  7765. vscale = h / maxHeight;
  7766. }
  7767. const fscale = Math.min(hscale, vscale);
  7768. const newFontSize = fontSize * fscale;
  7769. const buffer = ["q", `0 0 ${(0, _core_utils.numberToString)(w)} ${(0, _core_utils.numberToString)(h)} re W n`, `BT`, `1 0 0 1 0 ${(0, _core_utils.numberToString)(h + lineDescent)} Tm 0 Tc ${getPdfColor(bgColor, true)}`, `/${this.fontName.name} ${(0, _core_utils.numberToString)(newFontSize)} Tf`];
  7770. const {
  7771. resources
  7772. } = this;
  7773. strokeAlpha = typeof strokeAlpha === "number" && strokeAlpha >= 0 && strokeAlpha <= 1 ? strokeAlpha : 1;
  7774. if (strokeAlpha !== 1) {
  7775. buffer.push("/R0 gs");
  7776. const extGState = new _primitives.Dict(this.xref);
  7777. const r0 = new _primitives.Dict(this.xref);
  7778. r0.set("ca", strokeAlpha);
  7779. r0.set("CA", strokeAlpha);
  7780. r0.set("Type", _primitives.Name.get("ExtGState"));
  7781. extGState.set("R0", r0);
  7782. resources.set("ExtGState", extGState);
  7783. }
  7784. const vShift = (0, _core_utils.numberToString)(lineHeight);
  7785. for (const line of lines) {
  7786. buffer.push(`0 -${vShift} Td <${(0, _core_utils.stringToUTF16HexString)(line)}> Tj`);
  7787. }
  7788. buffer.push("ET", "Q");
  7789. const appearance = buffer.join("\n");
  7790. const appearanceStreamDict = new _primitives.Dict(this.xref);
  7791. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  7792. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  7793. appearanceStreamDict.set("BBox", [0, 0, w, h]);
  7794. appearanceStreamDict.set("Length", appearance.length);
  7795. appearanceStreamDict.set("Resources", resources);
  7796. if (rotation) {
  7797. const matrix = (0, _core_utils.getRotationMatrix)(rotation, w, h);
  7798. appearanceStreamDict.set("Matrix", matrix);
  7799. }
  7800. const ap = new _stream.StringStream(appearance);
  7801. ap.dict = appearanceStreamDict;
  7802. return ap;
  7803. }
  7804. }
  7805. exports.FakeUnicodeFont = FakeUnicodeFont;
  7806. /***/ }),
  7807. /* 12 */
  7808. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7809. Object.defineProperty(exports, "__esModule", ({
  7810. value: true
  7811. }));
  7812. exports.ColorSpace = void 0;
  7813. var _util = __w_pdfjs_require__(2);
  7814. var _primitives = __w_pdfjs_require__(4);
  7815. var _base_stream = __w_pdfjs_require__(5);
  7816. var _core_utils = __w_pdfjs_require__(3);
  7817. function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
  7818. const COMPONENTS = 3;
  7819. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  7820. const xRatio = w1 / w2;
  7821. const yRatio = h1 / h2;
  7822. let newIndex = 0,
  7823. oldIndex;
  7824. const xScaled = new Uint16Array(w2);
  7825. const w1Scanline = w1 * COMPONENTS;
  7826. for (let i = 0; i < w2; i++) {
  7827. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  7828. }
  7829. for (let i = 0; i < h2; i++) {
  7830. const py = Math.floor(i * yRatio) * w1Scanline;
  7831. for (let j = 0; j < w2; j++) {
  7832. oldIndex = py + xScaled[j];
  7833. dest[newIndex++] = src[oldIndex++];
  7834. dest[newIndex++] = src[oldIndex++];
  7835. dest[newIndex++] = src[oldIndex++];
  7836. newIndex += alpha01;
  7837. }
  7838. }
  7839. }
  7840. class ColorSpace {
  7841. constructor(name, numComps) {
  7842. if (this.constructor === ColorSpace) {
  7843. (0, _util.unreachable)("Cannot initialize ColorSpace.");
  7844. }
  7845. this.name = name;
  7846. this.numComps = numComps;
  7847. }
  7848. getRgb(src, srcOffset) {
  7849. const rgb = new Uint8ClampedArray(3);
  7850. this.getRgbItem(src, srcOffset, rgb, 0);
  7851. return rgb;
  7852. }
  7853. getRgbItem(src, srcOffset, dest, destOffset) {
  7854. (0, _util.unreachable)("Should not call ColorSpace.getRgbItem");
  7855. }
  7856. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  7857. (0, _util.unreachable)("Should not call ColorSpace.getRgbBuffer");
  7858. }
  7859. getOutputLength(inputLength, alpha01) {
  7860. (0, _util.unreachable)("Should not call ColorSpace.getOutputLength");
  7861. }
  7862. isPassthrough(bits) {
  7863. return false;
  7864. }
  7865. isDefaultDecode(decodeMap, bpc) {
  7866. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  7867. }
  7868. fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  7869. const count = originalWidth * originalHeight;
  7870. let rgbBuf = null;
  7871. const numComponentColors = 1 << bpc;
  7872. const needsResizing = originalHeight !== height || originalWidth !== width;
  7873. if (this.isPassthrough(bpc)) {
  7874. rgbBuf = comps;
  7875. } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
  7876. const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  7877. for (let i = 0; i < numComponentColors; i++) {
  7878. allColors[i] = i;
  7879. }
  7880. const colorMap = new Uint8ClampedArray(numComponentColors * 3);
  7881. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  7882. if (!needsResizing) {
  7883. let destPos = 0;
  7884. for (let i = 0; i < count; ++i) {
  7885. const key = comps[i] * 3;
  7886. dest[destPos++] = colorMap[key];
  7887. dest[destPos++] = colorMap[key + 1];
  7888. dest[destPos++] = colorMap[key + 2];
  7889. destPos += alpha01;
  7890. }
  7891. } else {
  7892. rgbBuf = new Uint8Array(count * 3);
  7893. let rgbPos = 0;
  7894. for (let i = 0; i < count; ++i) {
  7895. const key = comps[i] * 3;
  7896. rgbBuf[rgbPos++] = colorMap[key];
  7897. rgbBuf[rgbPos++] = colorMap[key + 1];
  7898. rgbBuf[rgbPos++] = colorMap[key + 2];
  7899. }
  7900. }
  7901. } else if (!needsResizing) {
  7902. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  7903. } else {
  7904. rgbBuf = new Uint8ClampedArray(count * 3);
  7905. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  7906. }
  7907. if (rgbBuf) {
  7908. if (needsResizing) {
  7909. resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
  7910. } else {
  7911. let destPos = 0,
  7912. rgbPos = 0;
  7913. for (let i = 0, ii = width * actualHeight; i < ii; i++) {
  7914. dest[destPos++] = rgbBuf[rgbPos++];
  7915. dest[destPos++] = rgbBuf[rgbPos++];
  7916. dest[destPos++] = rgbBuf[rgbPos++];
  7917. destPos += alpha01;
  7918. }
  7919. }
  7920. }
  7921. }
  7922. get usesZeroToOneRange() {
  7923. return (0, _util.shadow)(this, "usesZeroToOneRange", true);
  7924. }
  7925. static _cache(cacheKey, xref, localColorSpaceCache, parsedColorSpace) {
  7926. if (!localColorSpaceCache) {
  7927. throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');
  7928. }
  7929. if (!parsedColorSpace) {
  7930. throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');
  7931. }
  7932. let csName, csRef;
  7933. if (cacheKey instanceof _primitives.Ref) {
  7934. csRef = cacheKey;
  7935. cacheKey = xref.fetch(cacheKey);
  7936. }
  7937. if (cacheKey instanceof _primitives.Name) {
  7938. csName = cacheKey.name;
  7939. }
  7940. if (csName || csRef) {
  7941. localColorSpaceCache.set(csName, csRef, parsedColorSpace);
  7942. }
  7943. }
  7944. static getCached(cacheKey, xref, localColorSpaceCache) {
  7945. if (!localColorSpaceCache) {
  7946. throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');
  7947. }
  7948. if (cacheKey instanceof _primitives.Ref) {
  7949. const localColorSpace = localColorSpaceCache.getByRef(cacheKey);
  7950. if (localColorSpace) {
  7951. return localColorSpace;
  7952. }
  7953. try {
  7954. cacheKey = xref.fetch(cacheKey);
  7955. } catch (ex) {
  7956. if (ex instanceof _core_utils.MissingDataException) {
  7957. throw ex;
  7958. }
  7959. }
  7960. }
  7961. if (cacheKey instanceof _primitives.Name) {
  7962. const localColorSpace = localColorSpaceCache.getByName(cacheKey.name);
  7963. if (localColorSpace) {
  7964. return localColorSpace;
  7965. }
  7966. }
  7967. return null;
  7968. }
  7969. static async parseAsync({
  7970. cs,
  7971. xref,
  7972. resources = null,
  7973. pdfFunctionFactory,
  7974. localColorSpaceCache
  7975. }) {
  7976. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  7977. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  7978. return parsedColorSpace;
  7979. }
  7980. static parse({
  7981. cs,
  7982. xref,
  7983. resources = null,
  7984. pdfFunctionFactory,
  7985. localColorSpaceCache
  7986. }) {
  7987. const cachedColorSpace = this.getCached(cs, xref, localColorSpaceCache);
  7988. if (cachedColorSpace) {
  7989. return cachedColorSpace;
  7990. }
  7991. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  7992. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  7993. return parsedColorSpace;
  7994. }
  7995. static _parse(cs, xref, resources = null, pdfFunctionFactory) {
  7996. cs = xref.fetchIfRef(cs);
  7997. if (cs instanceof _primitives.Name) {
  7998. switch (cs.name) {
  7999. case "G":
  8000. case "DeviceGray":
  8001. return this.singletons.gray;
  8002. case "RGB":
  8003. case "DeviceRGB":
  8004. return this.singletons.rgb;
  8005. case "CMYK":
  8006. case "DeviceCMYK":
  8007. return this.singletons.cmyk;
  8008. case "Pattern":
  8009. return new PatternCS(null);
  8010. default:
  8011. if (resources instanceof _primitives.Dict) {
  8012. const colorSpaces = resources.get("ColorSpace");
  8013. if (colorSpaces instanceof _primitives.Dict) {
  8014. const resourcesCS = colorSpaces.get(cs.name);
  8015. if (resourcesCS) {
  8016. if (resourcesCS instanceof _primitives.Name) {
  8017. return this._parse(resourcesCS, xref, resources, pdfFunctionFactory);
  8018. }
  8019. cs = resourcesCS;
  8020. break;
  8021. }
  8022. }
  8023. }
  8024. throw new _util.FormatError(`Unrecognized ColorSpace: ${cs.name}`);
  8025. }
  8026. }
  8027. if (Array.isArray(cs)) {
  8028. const mode = xref.fetchIfRef(cs[0]).name;
  8029. let params, numComps, baseCS, whitePoint, blackPoint, gamma;
  8030. switch (mode) {
  8031. case "G":
  8032. case "DeviceGray":
  8033. return this.singletons.gray;
  8034. case "RGB":
  8035. case "DeviceRGB":
  8036. return this.singletons.rgb;
  8037. case "CMYK":
  8038. case "DeviceCMYK":
  8039. return this.singletons.cmyk;
  8040. case "CalGray":
  8041. params = xref.fetchIfRef(cs[1]);
  8042. whitePoint = params.getArray("WhitePoint");
  8043. blackPoint = params.getArray("BlackPoint");
  8044. gamma = params.get("Gamma");
  8045. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8046. case "CalRGB":
  8047. params = xref.fetchIfRef(cs[1]);
  8048. whitePoint = params.getArray("WhitePoint");
  8049. blackPoint = params.getArray("BlackPoint");
  8050. gamma = params.getArray("Gamma");
  8051. const matrix = params.getArray("Matrix");
  8052. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8053. case "ICCBased":
  8054. const stream = xref.fetchIfRef(cs[1]);
  8055. const dict = stream.dict;
  8056. numComps = dict.get("N");
  8057. const alt = dict.get("Alternate");
  8058. if (alt) {
  8059. const altCS = this._parse(alt, xref, resources, pdfFunctionFactory);
  8060. if (altCS.numComps === numComps) {
  8061. return altCS;
  8062. }
  8063. (0, _util.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.");
  8064. }
  8065. if (numComps === 1) {
  8066. return this.singletons.gray;
  8067. } else if (numComps === 3) {
  8068. return this.singletons.rgb;
  8069. } else if (numComps === 4) {
  8070. return this.singletons.cmyk;
  8071. }
  8072. break;
  8073. case "Pattern":
  8074. baseCS = cs[1] || null;
  8075. if (baseCS) {
  8076. baseCS = this._parse(baseCS, xref, resources, pdfFunctionFactory);
  8077. }
  8078. return new PatternCS(baseCS);
  8079. case "I":
  8080. case "Indexed":
  8081. baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
  8082. const hiVal = xref.fetchIfRef(cs[2]) + 1;
  8083. const lookup = xref.fetchIfRef(cs[3]);
  8084. return new IndexedCS(baseCS, hiVal, lookup);
  8085. case "Separation":
  8086. case "DeviceN":
  8087. const name = xref.fetchIfRef(cs[1]);
  8088. numComps = Array.isArray(name) ? name.length : 1;
  8089. baseCS = this._parse(cs[2], xref, resources, pdfFunctionFactory);
  8090. const tintFn = pdfFunctionFactory.create(cs[3]);
  8091. return new AlternateCS(numComps, baseCS, tintFn);
  8092. case "Lab":
  8093. params = xref.fetchIfRef(cs[1]);
  8094. whitePoint = params.getArray("WhitePoint");
  8095. blackPoint = params.getArray("BlackPoint");
  8096. const range = params.getArray("Range");
  8097. return new LabCS(whitePoint, blackPoint, range);
  8098. default:
  8099. throw new _util.FormatError(`Unimplemented ColorSpace object: ${mode}`);
  8100. }
  8101. }
  8102. throw new _util.FormatError(`Unrecognized ColorSpace object: ${cs}`);
  8103. }
  8104. static isDefaultDecode(decode, numComps) {
  8105. if (!Array.isArray(decode)) {
  8106. return true;
  8107. }
  8108. if (numComps * 2 !== decode.length) {
  8109. (0, _util.warn)("The decode map is not the correct length");
  8110. return true;
  8111. }
  8112. for (let i = 0, ii = decode.length; i < ii; i += 2) {
  8113. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8114. return false;
  8115. }
  8116. }
  8117. return true;
  8118. }
  8119. static get singletons() {
  8120. return (0, _util.shadow)(this, "singletons", {
  8121. get gray() {
  8122. return (0, _util.shadow)(this, "gray", new DeviceGrayCS());
  8123. },
  8124. get rgb() {
  8125. return (0, _util.shadow)(this, "rgb", new DeviceRgbCS());
  8126. },
  8127. get cmyk() {
  8128. return (0, _util.shadow)(this, "cmyk", new DeviceCmykCS());
  8129. }
  8130. });
  8131. }
  8132. }
  8133. exports.ColorSpace = ColorSpace;
  8134. class AlternateCS extends ColorSpace {
  8135. constructor(numComps, base, tintFn) {
  8136. super("Alternate", numComps);
  8137. this.base = base;
  8138. this.tintFn = tintFn;
  8139. this.tmpBuf = new Float32Array(base.numComps);
  8140. }
  8141. getRgbItem(src, srcOffset, dest, destOffset) {
  8142. const tmpBuf = this.tmpBuf;
  8143. this.tintFn(src, srcOffset, tmpBuf, 0);
  8144. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8145. }
  8146. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8147. const tintFn = this.tintFn;
  8148. const base = this.base;
  8149. const scale = 1 / ((1 << bits) - 1);
  8150. const baseNumComps = base.numComps;
  8151. const usesZeroToOneRange = base.usesZeroToOneRange;
  8152. const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8153. let pos = isPassthrough ? destOffset : 0;
  8154. const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
  8155. const numComps = this.numComps;
  8156. const scaled = new Float32Array(numComps);
  8157. const tinted = new Float32Array(baseNumComps);
  8158. let i, j;
  8159. for (i = 0; i < count; i++) {
  8160. for (j = 0; j < numComps; j++) {
  8161. scaled[j] = src[srcOffset++] * scale;
  8162. }
  8163. tintFn(scaled, 0, tinted, 0);
  8164. if (usesZeroToOneRange) {
  8165. for (j = 0; j < baseNumComps; j++) {
  8166. baseBuf[pos++] = tinted[j] * 255;
  8167. }
  8168. } else {
  8169. base.getRgbItem(tinted, 0, baseBuf, pos);
  8170. pos += baseNumComps;
  8171. }
  8172. }
  8173. if (!isPassthrough) {
  8174. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8175. }
  8176. }
  8177. getOutputLength(inputLength, alpha01) {
  8178. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8179. }
  8180. }
  8181. class PatternCS extends ColorSpace {
  8182. constructor(baseCS) {
  8183. super("Pattern", null);
  8184. this.base = baseCS;
  8185. }
  8186. isDefaultDecode(decodeMap, bpc) {
  8187. (0, _util.unreachable)("Should not call PatternCS.isDefaultDecode");
  8188. }
  8189. }
  8190. class IndexedCS extends ColorSpace {
  8191. constructor(base, highVal, lookup) {
  8192. super("Indexed", 1);
  8193. this.base = base;
  8194. this.highVal = highVal;
  8195. const length = base.numComps * highVal;
  8196. this.lookup = new Uint8Array(length);
  8197. if (lookup instanceof _base_stream.BaseStream) {
  8198. const bytes = lookup.getBytes(length);
  8199. this.lookup.set(bytes);
  8200. } else if (typeof lookup === "string") {
  8201. for (let i = 0; i < length; ++i) {
  8202. this.lookup[i] = lookup.charCodeAt(i) & 0xff;
  8203. }
  8204. } else {
  8205. throw new _util.FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
  8206. }
  8207. }
  8208. getRgbItem(src, srcOffset, dest, destOffset) {
  8209. const numComps = this.base.numComps;
  8210. const start = src[srcOffset] * numComps;
  8211. this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
  8212. }
  8213. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8214. const base = this.base;
  8215. const numComps = base.numComps;
  8216. const outputDelta = base.getOutputLength(numComps, alpha01);
  8217. const lookup = this.lookup;
  8218. for (let i = 0; i < count; ++i) {
  8219. const lookupPos = src[srcOffset++] * numComps;
  8220. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8221. destOffset += outputDelta;
  8222. }
  8223. }
  8224. getOutputLength(inputLength, alpha01) {
  8225. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8226. }
  8227. isDefaultDecode(decodeMap, bpc) {
  8228. if (!Array.isArray(decodeMap)) {
  8229. return true;
  8230. }
  8231. if (decodeMap.length !== 2) {
  8232. (0, _util.warn)("Decode map length is not correct");
  8233. return true;
  8234. }
  8235. if (!Number.isInteger(bpc) || bpc < 1) {
  8236. (0, _util.warn)("Bits per component is not correct");
  8237. return true;
  8238. }
  8239. return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
  8240. }
  8241. }
  8242. class DeviceGrayCS extends ColorSpace {
  8243. constructor() {
  8244. super("DeviceGray", 1);
  8245. }
  8246. getRgbItem(src, srcOffset, dest, destOffset) {
  8247. const c = src[srcOffset] * 255;
  8248. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  8249. }
  8250. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8251. const scale = 255 / ((1 << bits) - 1);
  8252. let j = srcOffset,
  8253. q = destOffset;
  8254. for (let i = 0; i < count; ++i) {
  8255. const c = scale * src[j++];
  8256. dest[q++] = c;
  8257. dest[q++] = c;
  8258. dest[q++] = c;
  8259. q += alpha01;
  8260. }
  8261. }
  8262. getOutputLength(inputLength, alpha01) {
  8263. return inputLength * (3 + alpha01);
  8264. }
  8265. }
  8266. class DeviceRgbCS extends ColorSpace {
  8267. constructor() {
  8268. super("DeviceRGB", 3);
  8269. }
  8270. getRgbItem(src, srcOffset, dest, destOffset) {
  8271. dest[destOffset] = src[srcOffset] * 255;
  8272. dest[destOffset + 1] = src[srcOffset + 1] * 255;
  8273. dest[destOffset + 2] = src[srcOffset + 2] * 255;
  8274. }
  8275. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8276. if (bits === 8 && alpha01 === 0) {
  8277. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  8278. return;
  8279. }
  8280. const scale = 255 / ((1 << bits) - 1);
  8281. let j = srcOffset,
  8282. q = destOffset;
  8283. for (let i = 0; i < count; ++i) {
  8284. dest[q++] = scale * src[j++];
  8285. dest[q++] = scale * src[j++];
  8286. dest[q++] = scale * src[j++];
  8287. q += alpha01;
  8288. }
  8289. }
  8290. getOutputLength(inputLength, alpha01) {
  8291. return inputLength * (3 + alpha01) / 3 | 0;
  8292. }
  8293. isPassthrough(bits) {
  8294. return bits === 8;
  8295. }
  8296. }
  8297. const DeviceCmykCS = function DeviceCmykCSClosure() {
  8298. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  8299. const c = src[srcOffset] * srcScale;
  8300. const m = src[srcOffset + 1] * srcScale;
  8301. const y = src[srcOffset + 2] * srcScale;
  8302. const k = src[srcOffset + 3] * srcScale;
  8303. dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
  8304. dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
  8305. dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
  8306. }
  8307. class DeviceCmykCS extends ColorSpace {
  8308. constructor() {
  8309. super("DeviceCMYK", 4);
  8310. }
  8311. getRgbItem(src, srcOffset, dest, destOffset) {
  8312. convertToRgb(src, srcOffset, 1, dest, destOffset);
  8313. }
  8314. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8315. const scale = 1 / ((1 << bits) - 1);
  8316. for (let i = 0; i < count; i++) {
  8317. convertToRgb(src, srcOffset, scale, dest, destOffset);
  8318. srcOffset += 4;
  8319. destOffset += 3 + alpha01;
  8320. }
  8321. }
  8322. getOutputLength(inputLength, alpha01) {
  8323. return inputLength / 4 * (3 + alpha01) | 0;
  8324. }
  8325. }
  8326. return DeviceCmykCS;
  8327. }();
  8328. const CalGrayCS = function CalGrayCSClosure() {
  8329. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  8330. const A = src[srcOffset] * scale;
  8331. const AG = A ** cs.G;
  8332. const L = cs.YW * AG;
  8333. const val = Math.max(295.8 * L ** 0.3333333333333333 - 40.8, 0);
  8334. dest[destOffset] = val;
  8335. dest[destOffset + 1] = val;
  8336. dest[destOffset + 2] = val;
  8337. }
  8338. class CalGrayCS extends ColorSpace {
  8339. constructor(whitePoint, blackPoint, gamma) {
  8340. super("CalGray", 1);
  8341. if (!whitePoint) {
  8342. throw new _util.FormatError("WhitePoint missing - required for color space CalGray");
  8343. }
  8344. blackPoint ||= [0, 0, 0];
  8345. gamma ||= 1;
  8346. this.XW = whitePoint[0];
  8347. this.YW = whitePoint[1];
  8348. this.ZW = whitePoint[2];
  8349. this.XB = blackPoint[0];
  8350. this.YB = blackPoint[1];
  8351. this.ZB = blackPoint[2];
  8352. this.G = gamma;
  8353. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  8354. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  8355. }
  8356. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  8357. (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
  8358. this.XB = this.YB = this.ZB = 0;
  8359. }
  8360. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  8361. (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
  8362. }
  8363. if (this.G < 1) {
  8364. (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + "falling back to default.");
  8365. this.G = 1;
  8366. }
  8367. }
  8368. getRgbItem(src, srcOffset, dest, destOffset) {
  8369. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  8370. }
  8371. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8372. const scale = 1 / ((1 << bits) - 1);
  8373. for (let i = 0; i < count; ++i) {
  8374. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  8375. srcOffset += 1;
  8376. destOffset += 3 + alpha01;
  8377. }
  8378. }
  8379. getOutputLength(inputLength, alpha01) {
  8380. return inputLength * (3 + alpha01);
  8381. }
  8382. }
  8383. return CalGrayCS;
  8384. }();
  8385. const CalRGBCS = function CalRGBCSClosure() {
  8386. const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
  8387. const BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
  8388. const SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
  8389. const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
  8390. const tempNormalizeMatrix = new Float32Array(3);
  8391. const tempConvertMatrix1 = new Float32Array(3);
  8392. const tempConvertMatrix2 = new Float32Array(3);
  8393. const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
  8394. function matrixProduct(a, b, result) {
  8395. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  8396. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  8397. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  8398. }
  8399. function convertToFlat(sourceWhitePoint, LMS, result) {
  8400. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  8401. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  8402. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  8403. }
  8404. function convertToD65(sourceWhitePoint, LMS, result) {
  8405. const D65X = 0.95047;
  8406. const D65Y = 1;
  8407. const D65Z = 1.08883;
  8408. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  8409. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  8410. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  8411. }
  8412. function sRGBTransferFunction(color) {
  8413. if (color <= 0.0031308) {
  8414. return adjustToRange(0, 1, 12.92 * color);
  8415. }
  8416. if (color >= 0.99554525) {
  8417. return 1;
  8418. }
  8419. return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
  8420. }
  8421. function adjustToRange(min, max, value) {
  8422. return Math.max(min, Math.min(max, value));
  8423. }
  8424. function decodeL(L) {
  8425. if (L < 0) {
  8426. return -decodeL(-L);
  8427. }
  8428. if (L > 8.0) {
  8429. return ((L + 16) / 116) ** 3;
  8430. }
  8431. return L * DECODE_L_CONSTANT;
  8432. }
  8433. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  8434. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  8435. result[0] = XYZ_Flat[0];
  8436. result[1] = XYZ_Flat[1];
  8437. result[2] = XYZ_Flat[2];
  8438. return;
  8439. }
  8440. const zeroDecodeL = decodeL(0);
  8441. const X_DST = zeroDecodeL;
  8442. const X_SRC = decodeL(sourceBlackPoint[0]);
  8443. const Y_DST = zeroDecodeL;
  8444. const Y_SRC = decodeL(sourceBlackPoint[1]);
  8445. const Z_DST = zeroDecodeL;
  8446. const Z_SRC = decodeL(sourceBlackPoint[2]);
  8447. const X_Scale = (1 - X_DST) / (1 - X_SRC);
  8448. const X_Offset = 1 - X_Scale;
  8449. const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  8450. const Y_Offset = 1 - Y_Scale;
  8451. const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  8452. const Z_Offset = 1 - Z_Scale;
  8453. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  8454. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  8455. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  8456. }
  8457. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  8458. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  8459. result[0] = XYZ_In[0];
  8460. result[1] = XYZ_In[1];
  8461. result[2] = XYZ_In[2];
  8462. return;
  8463. }
  8464. const LMS = result;
  8465. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  8466. const LMS_Flat = tempNormalizeMatrix;
  8467. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  8468. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  8469. }
  8470. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  8471. const LMS = result;
  8472. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  8473. const LMS_D65 = tempNormalizeMatrix;
  8474. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  8475. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  8476. }
  8477. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  8478. const A = adjustToRange(0, 1, src[srcOffset] * scale);
  8479. const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  8480. const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  8481. const AGR = A === 1 ? 1 : A ** cs.GR;
  8482. const BGG = B === 1 ? 1 : B ** cs.GG;
  8483. const CGB = C === 1 ? 1 : C ** cs.GB;
  8484. const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  8485. const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  8486. const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  8487. const XYZ = tempConvertMatrix1;
  8488. XYZ[0] = X;
  8489. XYZ[1] = Y;
  8490. XYZ[2] = Z;
  8491. const XYZ_Flat = tempConvertMatrix2;
  8492. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  8493. const XYZ_Black = tempConvertMatrix1;
  8494. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  8495. const XYZ_D65 = tempConvertMatrix2;
  8496. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  8497. const SRGB = tempConvertMatrix1;
  8498. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  8499. dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
  8500. dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
  8501. dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
  8502. }
  8503. class CalRGBCS extends ColorSpace {
  8504. constructor(whitePoint, blackPoint, gamma, matrix) {
  8505. super("CalRGB", 3);
  8506. if (!whitePoint) {
  8507. throw new _util.FormatError("WhitePoint missing - required for color space CalRGB");
  8508. }
  8509. blackPoint ||= new Float32Array(3);
  8510. gamma ||= new Float32Array([1, 1, 1]);
  8511. matrix ||= new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  8512. const XW = whitePoint[0];
  8513. const YW = whitePoint[1];
  8514. const ZW = whitePoint[2];
  8515. this.whitePoint = whitePoint;
  8516. const XB = blackPoint[0];
  8517. const YB = blackPoint[1];
  8518. const ZB = blackPoint[2];
  8519. this.blackPoint = blackPoint;
  8520. this.GR = gamma[0];
  8521. this.GG = gamma[1];
  8522. this.GB = gamma[2];
  8523. this.MXA = matrix[0];
  8524. this.MYA = matrix[1];
  8525. this.MZA = matrix[2];
  8526. this.MXB = matrix[3];
  8527. this.MYB = matrix[4];
  8528. this.MZB = matrix[5];
  8529. this.MXC = matrix[6];
  8530. this.MYC = matrix[7];
  8531. this.MZC = matrix[8];
  8532. if (XW < 0 || ZW < 0 || YW !== 1) {
  8533. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  8534. }
  8535. if (XB < 0 || YB < 0 || ZB < 0) {
  8536. (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
  8537. this.blackPoint = new Float32Array(3);
  8538. }
  8539. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  8540. (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
  8541. this.GR = this.GG = this.GB = 1;
  8542. }
  8543. }
  8544. getRgbItem(src, srcOffset, dest, destOffset) {
  8545. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  8546. }
  8547. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8548. const scale = 1 / ((1 << bits) - 1);
  8549. for (let i = 0; i < count; ++i) {
  8550. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  8551. srcOffset += 3;
  8552. destOffset += 3 + alpha01;
  8553. }
  8554. }
  8555. getOutputLength(inputLength, alpha01) {
  8556. return inputLength * (3 + alpha01) / 3 | 0;
  8557. }
  8558. }
  8559. return CalRGBCS;
  8560. }();
  8561. const LabCS = function LabCSClosure() {
  8562. function fn_g(x) {
  8563. return x >= 6 / 29 ? x ** 3 : 108 / 841 * (x - 4 / 29);
  8564. }
  8565. function decode(value, high1, low2, high2) {
  8566. return low2 + value * (high2 - low2) / high1;
  8567. }
  8568. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  8569. let Ls = src[srcOffset];
  8570. let as = src[srcOffset + 1];
  8571. let bs = src[srcOffset + 2];
  8572. if (maxVal !== false) {
  8573. Ls = decode(Ls, maxVal, 0, 100);
  8574. as = decode(as, maxVal, cs.amin, cs.amax);
  8575. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  8576. }
  8577. if (as > cs.amax) {
  8578. as = cs.amax;
  8579. } else if (as < cs.amin) {
  8580. as = cs.amin;
  8581. }
  8582. if (bs > cs.bmax) {
  8583. bs = cs.bmax;
  8584. } else if (bs < cs.bmin) {
  8585. bs = cs.bmin;
  8586. }
  8587. const M = (Ls + 16) / 116;
  8588. const L = M + as / 500;
  8589. const N = M - bs / 200;
  8590. const X = cs.XW * fn_g(L);
  8591. const Y = cs.YW * fn_g(M);
  8592. const Z = cs.ZW * fn_g(N);
  8593. let r, g, b;
  8594. if (cs.ZW < 1) {
  8595. r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
  8596. g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
  8597. b = X * 0.072 + Y * -0.229 + Z * 1.4057;
  8598. } else {
  8599. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  8600. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  8601. b = X * 0.0557 + Y * -0.204 + Z * 1.057;
  8602. }
  8603. dest[destOffset] = Math.sqrt(r) * 255;
  8604. dest[destOffset + 1] = Math.sqrt(g) * 255;
  8605. dest[destOffset + 2] = Math.sqrt(b) * 255;
  8606. }
  8607. class LabCS extends ColorSpace {
  8608. constructor(whitePoint, blackPoint, range) {
  8609. super("Lab", 3);
  8610. if (!whitePoint) {
  8611. throw new _util.FormatError("WhitePoint missing - required for color space Lab");
  8612. }
  8613. blackPoint ||= [0, 0, 0];
  8614. range ||= [-100, 100, -100, 100];
  8615. this.XW = whitePoint[0];
  8616. this.YW = whitePoint[1];
  8617. this.ZW = whitePoint[2];
  8618. this.amin = range[0];
  8619. this.amax = range[1];
  8620. this.bmin = range[2];
  8621. this.bmax = range[3];
  8622. this.XB = blackPoint[0];
  8623. this.YB = blackPoint[1];
  8624. this.ZB = blackPoint[2];
  8625. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  8626. throw new _util.FormatError("Invalid WhitePoint components, no fallback available");
  8627. }
  8628. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  8629. (0, _util.info)("Invalid BlackPoint, falling back to default");
  8630. this.XB = this.YB = this.ZB = 0;
  8631. }
  8632. if (this.amin > this.amax || this.bmin > this.bmax) {
  8633. (0, _util.info)("Invalid Range, falling back to defaults");
  8634. this.amin = -100;
  8635. this.amax = 100;
  8636. this.bmin = -100;
  8637. this.bmax = 100;
  8638. }
  8639. }
  8640. getRgbItem(src, srcOffset, dest, destOffset) {
  8641. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  8642. }
  8643. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8644. const maxVal = (1 << bits) - 1;
  8645. for (let i = 0; i < count; i++) {
  8646. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  8647. srcOffset += 3;
  8648. destOffset += 3 + alpha01;
  8649. }
  8650. }
  8651. getOutputLength(inputLength, alpha01) {
  8652. return inputLength * (3 + alpha01) / 3 | 0;
  8653. }
  8654. isDefaultDecode(decodeMap, bpc) {
  8655. return true;
  8656. }
  8657. get usesZeroToOneRange() {
  8658. return (0, _util.shadow)(this, "usesZeroToOneRange", false);
  8659. }
  8660. }
  8661. return LabCS;
  8662. }();
  8663. /***/ }),
  8664. /* 13 */
  8665. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8666. Object.defineProperty(exports, "__esModule", ({
  8667. value: true
  8668. }));
  8669. exports.PartialEvaluator = exports.EvaluatorPreprocessor = void 0;
  8670. var _util = __w_pdfjs_require__(2);
  8671. var _cmap = __w_pdfjs_require__(14);
  8672. var _primitives = __w_pdfjs_require__(4);
  8673. var _fonts = __w_pdfjs_require__(34);
  8674. var _encodings = __w_pdfjs_require__(37);
  8675. var _standard_fonts = __w_pdfjs_require__(41);
  8676. var _pattern = __w_pdfjs_require__(50);
  8677. var _xfa_fonts = __w_pdfjs_require__(51);
  8678. var _to_unicode_map = __w_pdfjs_require__(42);
  8679. var _function = __w_pdfjs_require__(57);
  8680. var _parser = __w_pdfjs_require__(16);
  8681. var _image_utils = __w_pdfjs_require__(59);
  8682. var _stream = __w_pdfjs_require__(8);
  8683. var _base_stream = __w_pdfjs_require__(5);
  8684. var _bidi = __w_pdfjs_require__(60);
  8685. var _colorspace = __w_pdfjs_require__(12);
  8686. var _decode_stream = __w_pdfjs_require__(18);
  8687. var _fonts_utils = __w_pdfjs_require__(38);
  8688. var _font_substitutions = __w_pdfjs_require__(61);
  8689. var _glyphlist = __w_pdfjs_require__(39);
  8690. var _core_utils = __w_pdfjs_require__(3);
  8691. var _metrics = __w_pdfjs_require__(45);
  8692. var _unicode = __w_pdfjs_require__(40);
  8693. var _image_resizer = __w_pdfjs_require__(62);
  8694. var _murmurhash = __w_pdfjs_require__(63);
  8695. var _operator_list = __w_pdfjs_require__(64);
  8696. var _image = __w_pdfjs_require__(65);
  8697. const DefaultPartialEvaluatorOptions = Object.freeze({
  8698. maxImageSize: -1,
  8699. disableFontFace: false,
  8700. ignoreErrors: false,
  8701. isEvalSupported: true,
  8702. isOffscreenCanvasSupported: false,
  8703. canvasMaxAreaInBytes: -1,
  8704. fontExtraProperties: false,
  8705. useSystemFonts: true,
  8706. cMapUrl: null,
  8707. standardFontDataUrl: null
  8708. });
  8709. const PatternType = {
  8710. TILING: 1,
  8711. SHADING: 2
  8712. };
  8713. const TEXT_CHUNK_BATCH_SIZE = 10;
  8714. const deferred = Promise.resolve();
  8715. function normalizeBlendMode(value, parsingArray = false) {
  8716. if (Array.isArray(value)) {
  8717. for (const val of value) {
  8718. const maybeBM = normalizeBlendMode(val, true);
  8719. if (maybeBM) {
  8720. return maybeBM;
  8721. }
  8722. }
  8723. (0, _util.warn)(`Unsupported blend mode Array: ${value}`);
  8724. return "source-over";
  8725. }
  8726. if (!(value instanceof _primitives.Name)) {
  8727. if (parsingArray) {
  8728. return null;
  8729. }
  8730. return "source-over";
  8731. }
  8732. switch (value.name) {
  8733. case "Normal":
  8734. case "Compatible":
  8735. return "source-over";
  8736. case "Multiply":
  8737. return "multiply";
  8738. case "Screen":
  8739. return "screen";
  8740. case "Overlay":
  8741. return "overlay";
  8742. case "Darken":
  8743. return "darken";
  8744. case "Lighten":
  8745. return "lighten";
  8746. case "ColorDodge":
  8747. return "color-dodge";
  8748. case "ColorBurn":
  8749. return "color-burn";
  8750. case "HardLight":
  8751. return "hard-light";
  8752. case "SoftLight":
  8753. return "soft-light";
  8754. case "Difference":
  8755. return "difference";
  8756. case "Exclusion":
  8757. return "exclusion";
  8758. case "Hue":
  8759. return "hue";
  8760. case "Saturation":
  8761. return "saturation";
  8762. case "Color":
  8763. return "color";
  8764. case "Luminosity":
  8765. return "luminosity";
  8766. }
  8767. if (parsingArray) {
  8768. return null;
  8769. }
  8770. (0, _util.warn)(`Unsupported blend mode: ${value.name}`);
  8771. return "source-over";
  8772. }
  8773. function incrementCachedImageMaskCount(data) {
  8774. if (data.fn === _util.OPS.paintImageMaskXObject && data.args[0]?.count > 0) {
  8775. data.args[0].count++;
  8776. }
  8777. }
  8778. class TimeSlotManager {
  8779. static TIME_SLOT_DURATION_MS = 20;
  8780. static CHECK_TIME_EVERY = 100;
  8781. constructor() {
  8782. this.reset();
  8783. }
  8784. check() {
  8785. if (++this.checked < TimeSlotManager.CHECK_TIME_EVERY) {
  8786. return false;
  8787. }
  8788. this.checked = 0;
  8789. return this.endTime <= Date.now();
  8790. }
  8791. reset() {
  8792. this.endTime = Date.now() + TimeSlotManager.TIME_SLOT_DURATION_MS;
  8793. this.checked = 0;
  8794. }
  8795. }
  8796. class PartialEvaluator {
  8797. constructor({
  8798. xref,
  8799. handler,
  8800. pageIndex,
  8801. idFactory,
  8802. fontCache,
  8803. builtInCMapCache,
  8804. standardFontDataCache,
  8805. globalImageCache,
  8806. systemFontCache,
  8807. options = null
  8808. }) {
  8809. this.xref = xref;
  8810. this.handler = handler;
  8811. this.pageIndex = pageIndex;
  8812. this.idFactory = idFactory;
  8813. this.fontCache = fontCache;
  8814. this.builtInCMapCache = builtInCMapCache;
  8815. this.standardFontDataCache = standardFontDataCache;
  8816. this.globalImageCache = globalImageCache;
  8817. this.systemFontCache = systemFontCache;
  8818. this.options = options || DefaultPartialEvaluatorOptions;
  8819. this.parsingType3Font = false;
  8820. this._regionalImageCache = new _image_utils.RegionalImageCache();
  8821. this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
  8822. _image_resizer.ImageResizer.setMaxArea(this.options.canvasMaxAreaInBytes);
  8823. }
  8824. get _pdfFunctionFactory() {
  8825. const pdfFunctionFactory = new _function.PDFFunctionFactory({
  8826. xref: this.xref,
  8827. isEvalSupported: this.options.isEvalSupported
  8828. });
  8829. return (0, _util.shadow)(this, "_pdfFunctionFactory", pdfFunctionFactory);
  8830. }
  8831. clone(newOptions = null) {
  8832. const newEvaluator = Object.create(this);
  8833. newEvaluator.options = Object.assign(Object.create(null), this.options, newOptions);
  8834. return newEvaluator;
  8835. }
  8836. hasBlendModes(resources, nonBlendModesSet) {
  8837. if (!(resources instanceof _primitives.Dict)) {
  8838. return false;
  8839. }
  8840. if (resources.objId && nonBlendModesSet.has(resources.objId)) {
  8841. return false;
  8842. }
  8843. const processed = new _primitives.RefSet(nonBlendModesSet);
  8844. if (resources.objId) {
  8845. processed.put(resources.objId);
  8846. }
  8847. const nodes = [resources],
  8848. xref = this.xref;
  8849. while (nodes.length) {
  8850. const node = nodes.shift();
  8851. const graphicStates = node.get("ExtGState");
  8852. if (graphicStates instanceof _primitives.Dict) {
  8853. for (let graphicState of graphicStates.getRawValues()) {
  8854. if (graphicState instanceof _primitives.Ref) {
  8855. if (processed.has(graphicState)) {
  8856. continue;
  8857. }
  8858. try {
  8859. graphicState = xref.fetch(graphicState);
  8860. } catch (ex) {
  8861. processed.put(graphicState);
  8862. (0, _util.info)(`hasBlendModes - ignoring ExtGState: "${ex}".`);
  8863. continue;
  8864. }
  8865. }
  8866. if (!(graphicState instanceof _primitives.Dict)) {
  8867. continue;
  8868. }
  8869. if (graphicState.objId) {
  8870. processed.put(graphicState.objId);
  8871. }
  8872. const bm = graphicState.get("BM");
  8873. if (bm instanceof _primitives.Name) {
  8874. if (bm.name !== "Normal") {
  8875. return true;
  8876. }
  8877. continue;
  8878. }
  8879. if (bm !== undefined && Array.isArray(bm)) {
  8880. for (const element of bm) {
  8881. if (element instanceof _primitives.Name && element.name !== "Normal") {
  8882. return true;
  8883. }
  8884. }
  8885. }
  8886. }
  8887. }
  8888. const xObjects = node.get("XObject");
  8889. if (!(xObjects instanceof _primitives.Dict)) {
  8890. continue;
  8891. }
  8892. for (let xObject of xObjects.getRawValues()) {
  8893. if (xObject instanceof _primitives.Ref) {
  8894. if (processed.has(xObject)) {
  8895. continue;
  8896. }
  8897. try {
  8898. xObject = xref.fetch(xObject);
  8899. } catch (ex) {
  8900. processed.put(xObject);
  8901. (0, _util.info)(`hasBlendModes - ignoring XObject: "${ex}".`);
  8902. continue;
  8903. }
  8904. }
  8905. if (!(xObject instanceof _base_stream.BaseStream)) {
  8906. continue;
  8907. }
  8908. if (xObject.dict.objId) {
  8909. processed.put(xObject.dict.objId);
  8910. }
  8911. const xResources = xObject.dict.get("Resources");
  8912. if (!(xResources instanceof _primitives.Dict)) {
  8913. continue;
  8914. }
  8915. if (xResources.objId && processed.has(xResources.objId)) {
  8916. continue;
  8917. }
  8918. nodes.push(xResources);
  8919. if (xResources.objId) {
  8920. processed.put(xResources.objId);
  8921. }
  8922. }
  8923. }
  8924. for (const ref of processed) {
  8925. nonBlendModesSet.put(ref);
  8926. }
  8927. return false;
  8928. }
  8929. async fetchBuiltInCMap(name) {
  8930. const cachedData = this.builtInCMapCache.get(name);
  8931. if (cachedData) {
  8932. return cachedData;
  8933. }
  8934. let data;
  8935. if (this.options.cMapUrl !== null) {
  8936. const url = `${this.options.cMapUrl}${name}.bcmap`;
  8937. const response = await fetch(url);
  8938. if (!response.ok) {
  8939. throw new Error(`fetchBuiltInCMap: failed to fetch file "${url}" with "${response.statusText}".`);
  8940. }
  8941. data = {
  8942. cMapData: new Uint8Array(await response.arrayBuffer()),
  8943. compressionType: _util.CMapCompressionType.BINARY
  8944. };
  8945. } else {
  8946. data = await this.handler.sendWithPromise("FetchBuiltInCMap", {
  8947. name
  8948. });
  8949. }
  8950. if (data.compressionType !== _util.CMapCompressionType.NONE) {
  8951. this.builtInCMapCache.set(name, data);
  8952. }
  8953. return data;
  8954. }
  8955. async fetchStandardFontData(name) {
  8956. const cachedData = this.standardFontDataCache.get(name);
  8957. if (cachedData) {
  8958. return new _stream.Stream(cachedData);
  8959. }
  8960. if (this.options.useSystemFonts && name !== "Symbol" && name !== "ZapfDingbats") {
  8961. return null;
  8962. }
  8963. const standardFontNameToFileName = (0, _standard_fonts.getFontNameToFileMap)(),
  8964. filename = standardFontNameToFileName[name];
  8965. let data;
  8966. if (this.options.standardFontDataUrl !== null) {
  8967. const url = `${this.options.standardFontDataUrl}${filename}`;
  8968. const response = await fetch(url);
  8969. if (!response.ok) {
  8970. (0, _util.warn)(`fetchStandardFontData: failed to fetch file "${url}" with "${response.statusText}".`);
  8971. } else {
  8972. data = await response.arrayBuffer();
  8973. }
  8974. } else {
  8975. try {
  8976. data = await this.handler.sendWithPromise("FetchStandardFontData", {
  8977. filename
  8978. });
  8979. } catch (e) {
  8980. (0, _util.warn)(`fetchStandardFontData: failed to fetch file "${filename}" with "${e}".`);
  8981. }
  8982. }
  8983. if (!data) {
  8984. return null;
  8985. }
  8986. this.standardFontDataCache.set(name, data);
  8987. return new _stream.Stream(data);
  8988. }
  8989. async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache) {
  8990. const dict = xobj.dict;
  8991. const matrix = dict.getArray("Matrix");
  8992. let bbox = dict.getArray("BBox");
  8993. bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  8994. let optionalContent, groupOptions;
  8995. if (dict.has("OC")) {
  8996. optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
  8997. }
  8998. if (optionalContent !== undefined) {
  8999. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  9000. }
  9001. const group = dict.get("Group");
  9002. if (group) {
  9003. groupOptions = {
  9004. matrix,
  9005. bbox,
  9006. smask,
  9007. isolated: false,
  9008. knockout: false
  9009. };
  9010. const groupSubtype = group.get("S");
  9011. let colorSpace = null;
  9012. if ((0, _primitives.isName)(groupSubtype, "Transparency")) {
  9013. groupOptions.isolated = group.get("I") || false;
  9014. groupOptions.knockout = group.get("K") || false;
  9015. if (group.has("CS")) {
  9016. const cs = group.getRaw("CS");
  9017. const cachedColorSpace = _colorspace.ColorSpace.getCached(cs, this.xref, localColorSpaceCache);
  9018. if (cachedColorSpace) {
  9019. colorSpace = cachedColorSpace;
  9020. } else {
  9021. colorSpace = await this.parseColorSpace({
  9022. cs,
  9023. resources,
  9024. localColorSpaceCache
  9025. });
  9026. }
  9027. }
  9028. }
  9029. if (smask?.backdrop) {
  9030. colorSpace ||= _colorspace.ColorSpace.singletons.rgb;
  9031. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  9032. }
  9033. operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
  9034. }
  9035. const args = group ? [matrix, null] : [matrix, bbox];
  9036. operatorList.addOp(_util.OPS.paintFormXObjectBegin, args);
  9037. return this.getOperatorList({
  9038. stream: xobj,
  9039. task,
  9040. resources: dict.get("Resources") || resources,
  9041. operatorList,
  9042. initialState
  9043. }).then(function () {
  9044. operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
  9045. if (group) {
  9046. operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
  9047. }
  9048. if (optionalContent !== undefined) {
  9049. operatorList.addOp(_util.OPS.endMarkedContent, []);
  9050. }
  9051. });
  9052. }
  9053. _sendImgData(objId, imgData, cacheGlobally = false) {
  9054. const transfers = imgData ? [imgData.bitmap || imgData.data.buffer] : null;
  9055. if (this.parsingType3Font || cacheGlobally) {
  9056. return this.handler.send("commonobj", [objId, "Image", imgData], transfers);
  9057. }
  9058. return this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], transfers);
  9059. }
  9060. async buildPaintImageXObject({
  9061. resources,
  9062. image,
  9063. isInline = false,
  9064. operatorList,
  9065. cacheKey,
  9066. localImageCache,
  9067. localColorSpaceCache
  9068. }) {
  9069. const dict = image.dict;
  9070. const imageRef = dict.objId;
  9071. const w = dict.get("W", "Width");
  9072. const h = dict.get("H", "Height");
  9073. if (!(w && typeof w === "number") || !(h && typeof h === "number")) {
  9074. (0, _util.warn)("Image dimensions are missing, or not numbers.");
  9075. return;
  9076. }
  9077. const maxImageSize = this.options.maxImageSize;
  9078. if (maxImageSize !== -1 && w * h > maxImageSize) {
  9079. const msg = "Image exceeded maximum allowed size and was removed.";
  9080. if (this.options.ignoreErrors) {
  9081. (0, _util.warn)(msg);
  9082. return;
  9083. }
  9084. throw new Error(msg);
  9085. }
  9086. let optionalContent;
  9087. if (dict.has("OC")) {
  9088. optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
  9089. }
  9090. const imageMask = dict.get("IM", "ImageMask") || false;
  9091. let imgData, args;
  9092. if (imageMask) {
  9093. const interpolate = dict.get("I", "Interpolate");
  9094. const bitStrideLength = w + 7 >> 3;
  9095. const imgArray = image.getBytes(bitStrideLength * h);
  9096. const decode = dict.getArray("D", "Decode");
  9097. if (this.parsingType3Font) {
  9098. imgData = _image.PDFImage.createRawMask({
  9099. imgArray,
  9100. width: w,
  9101. height: h,
  9102. imageIsFromDecodeStream: image instanceof _decode_stream.DecodeStream,
  9103. inverseDecode: decode?.[0] > 0,
  9104. interpolate
  9105. });
  9106. imgData.cached = !!cacheKey;
  9107. args = [imgData];
  9108. operatorList.addImageOps(_util.OPS.paintImageMaskXObject, args, optionalContent);
  9109. if (cacheKey) {
  9110. const cacheData = {
  9111. fn: _util.OPS.paintImageMaskXObject,
  9112. args,
  9113. optionalContent
  9114. };
  9115. localImageCache.set(cacheKey, imageRef, cacheData);
  9116. if (imageRef) {
  9117. this._regionalImageCache.set(null, imageRef, cacheData);
  9118. }
  9119. }
  9120. return;
  9121. }
  9122. imgData = await _image.PDFImage.createMask({
  9123. imgArray,
  9124. width: w,
  9125. height: h,
  9126. imageIsFromDecodeStream: image instanceof _decode_stream.DecodeStream,
  9127. inverseDecode: decode?.[0] > 0,
  9128. interpolate,
  9129. isOffscreenCanvasSupported: this.options.isOffscreenCanvasSupported
  9130. });
  9131. if (imgData.isSingleOpaquePixel) {
  9132. operatorList.addImageOps(_util.OPS.paintSolidColorImageMask, [], optionalContent);
  9133. if (cacheKey) {
  9134. const cacheData = {
  9135. fn: _util.OPS.paintSolidColorImageMask,
  9136. args: [],
  9137. optionalContent
  9138. };
  9139. localImageCache.set(cacheKey, imageRef, cacheData);
  9140. if (imageRef) {
  9141. this._regionalImageCache.set(null, imageRef, cacheData);
  9142. }
  9143. }
  9144. return;
  9145. }
  9146. const objId = `mask_${this.idFactory.createObjId()}`;
  9147. operatorList.addDependency(objId);
  9148. this._sendImgData(objId, imgData);
  9149. args = [{
  9150. data: objId,
  9151. width: imgData.width,
  9152. height: imgData.height,
  9153. interpolate: imgData.interpolate,
  9154. count: 1
  9155. }];
  9156. operatorList.addImageOps(_util.OPS.paintImageMaskXObject, args, optionalContent);
  9157. if (cacheKey) {
  9158. const cacheData = {
  9159. fn: _util.OPS.paintImageMaskXObject,
  9160. args,
  9161. optionalContent
  9162. };
  9163. localImageCache.set(cacheKey, imageRef, cacheData);
  9164. if (imageRef) {
  9165. this._regionalImageCache.set(null, imageRef, cacheData);
  9166. }
  9167. }
  9168. return;
  9169. }
  9170. const SMALL_IMAGE_DIMENSIONS = 200;
  9171. if (isInline && !dict.has("SMask") && !dict.has("Mask") && w + h < SMALL_IMAGE_DIMENSIONS) {
  9172. const imageObj = new _image.PDFImage({
  9173. xref: this.xref,
  9174. res: resources,
  9175. image,
  9176. isInline,
  9177. pdfFunctionFactory: this._pdfFunctionFactory,
  9178. localColorSpaceCache
  9179. });
  9180. imgData = await imageObj.createImageData(true, false);
  9181. operatorList.isOffscreenCanvasSupported = this.options.isOffscreenCanvasSupported;
  9182. operatorList.addImageOps(_util.OPS.paintInlineImageXObject, [imgData], optionalContent);
  9183. return;
  9184. }
  9185. let objId = `img_${this.idFactory.createObjId()}`,
  9186. cacheGlobally = false;
  9187. if (this.parsingType3Font) {
  9188. objId = `${this.idFactory.getDocId()}_type3_${objId}`;
  9189. } else if (imageRef) {
  9190. cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
  9191. if (cacheGlobally) {
  9192. objId = `${this.idFactory.getDocId()}_${objId}`;
  9193. }
  9194. }
  9195. operatorList.addDependency(objId);
  9196. args = [objId, w, h];
  9197. _image.PDFImage.buildImage({
  9198. xref: this.xref,
  9199. res: resources,
  9200. image,
  9201. isInline,
  9202. pdfFunctionFactory: this._pdfFunctionFactory,
  9203. localColorSpaceCache
  9204. }).then(async imageObj => {
  9205. imgData = await imageObj.createImageData(false, this.options.isOffscreenCanvasSupported);
  9206. if (cacheKey && imageRef && cacheGlobally) {
  9207. const length = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
  9208. this.globalImageCache.addByteSize(imageRef, length);
  9209. }
  9210. return this._sendImgData(objId, imgData, cacheGlobally);
  9211. }).catch(reason => {
  9212. (0, _util.warn)(`Unable to decode image "${objId}": "${reason}".`);
  9213. return this._sendImgData(objId, null, cacheGlobally);
  9214. });
  9215. operatorList.addImageOps(_util.OPS.paintImageXObject, args, optionalContent);
  9216. if (cacheKey) {
  9217. const cacheData = {
  9218. fn: _util.OPS.paintImageXObject,
  9219. args,
  9220. optionalContent
  9221. };
  9222. localImageCache.set(cacheKey, imageRef, cacheData);
  9223. if (imageRef) {
  9224. this._regionalImageCache.set(null, imageRef, cacheData);
  9225. if (cacheGlobally) {
  9226. (0, _util.assert)(!isInline, "Cannot cache an inline image globally.");
  9227. this.globalImageCache.setData(imageRef, {
  9228. objId,
  9229. fn: _util.OPS.paintImageXObject,
  9230. args,
  9231. optionalContent,
  9232. byteSize: 0
  9233. });
  9234. }
  9235. }
  9236. }
  9237. }
  9238. handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache) {
  9239. const smaskContent = smask.get("G");
  9240. const smaskOptions = {
  9241. subtype: smask.get("S").name,
  9242. backdrop: smask.get("BC")
  9243. };
  9244. const transferObj = smask.get("TR");
  9245. if ((0, _function.isPDFFunction)(transferObj)) {
  9246. const transferFn = this._pdfFunctionFactory.create(transferObj);
  9247. const transferMap = new Uint8Array(256);
  9248. const tmp = new Float32Array(1);
  9249. for (let i = 0; i < 256; i++) {
  9250. tmp[0] = i / 255;
  9251. transferFn(tmp, 0, tmp, 0);
  9252. transferMap[i] = tmp[0] * 255 | 0;
  9253. }
  9254. smaskOptions.transferMap = transferMap;
  9255. }
  9256. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone(), localColorSpaceCache);
  9257. }
  9258. handleTransferFunction(tr) {
  9259. let transferArray;
  9260. if (Array.isArray(tr)) {
  9261. transferArray = tr;
  9262. } else if ((0, _function.isPDFFunction)(tr)) {
  9263. transferArray = [tr];
  9264. } else {
  9265. return null;
  9266. }
  9267. const transferMaps = [];
  9268. let numFns = 0,
  9269. numEffectfulFns = 0;
  9270. for (const entry of transferArray) {
  9271. const transferObj = this.xref.fetchIfRef(entry);
  9272. numFns++;
  9273. if ((0, _primitives.isName)(transferObj, "Identity")) {
  9274. transferMaps.push(null);
  9275. continue;
  9276. } else if (!(0, _function.isPDFFunction)(transferObj)) {
  9277. return null;
  9278. }
  9279. const transferFn = this._pdfFunctionFactory.create(transferObj);
  9280. const transferMap = new Uint8Array(256),
  9281. tmp = new Float32Array(1);
  9282. for (let j = 0; j < 256; j++) {
  9283. tmp[0] = j / 255;
  9284. transferFn(tmp, 0, tmp, 0);
  9285. transferMap[j] = tmp[0] * 255 | 0;
  9286. }
  9287. transferMaps.push(transferMap);
  9288. numEffectfulFns++;
  9289. }
  9290. if (!(numFns === 1 || numFns === 4)) {
  9291. return null;
  9292. }
  9293. if (numEffectfulFns === 0) {
  9294. return null;
  9295. }
  9296. return transferMaps;
  9297. }
  9298. handleTilingType(fn, color, resources, pattern, patternDict, operatorList, task, localTilingPatternCache) {
  9299. const tilingOpList = new _operator_list.OperatorList();
  9300. const patternResources = _primitives.Dict.merge({
  9301. xref: this.xref,
  9302. dictArray: [patternDict.get("Resources"), resources]
  9303. });
  9304. return this.getOperatorList({
  9305. stream: pattern,
  9306. task,
  9307. resources: patternResources,
  9308. operatorList: tilingOpList
  9309. }).then(function () {
  9310. const operatorListIR = tilingOpList.getIR();
  9311. const tilingPatternIR = (0, _pattern.getTilingPatternIR)(operatorListIR, patternDict, color);
  9312. operatorList.addDependencies(tilingOpList.dependencies);
  9313. operatorList.addOp(fn, tilingPatternIR);
  9314. if (patternDict.objId) {
  9315. localTilingPatternCache.set(null, patternDict.objId, {
  9316. operatorListIR,
  9317. dict: patternDict
  9318. });
  9319. }
  9320. }).catch(reason => {
  9321. if (reason instanceof _util.AbortException) {
  9322. return;
  9323. }
  9324. if (this.options.ignoreErrors) {
  9325. (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
  9326. return;
  9327. }
  9328. throw reason;
  9329. });
  9330. }
  9331. handleSetFont(resources, fontArgs, fontRef, operatorList, task, state, fallbackFontDict = null, cssFontInfo = null) {
  9332. const fontName = fontArgs?.[0] instanceof _primitives.Name ? fontArgs[0].name : null;
  9333. return this.loadFont(fontName, fontRef, resources, fallbackFontDict, cssFontInfo).then(translated => {
  9334. if (!translated.font.isType3Font) {
  9335. return translated;
  9336. }
  9337. return translated.loadType3Data(this, resources, task).then(function () {
  9338. operatorList.addDependencies(translated.type3Dependencies);
  9339. return translated;
  9340. }).catch(reason => {
  9341. return new TranslatedFont({
  9342. loadedName: "g_font_error",
  9343. font: new _fonts.ErrorFont(`Type3 font load error: ${reason}`),
  9344. dict: translated.font,
  9345. evaluatorOptions: this.options
  9346. });
  9347. });
  9348. }).then(translated => {
  9349. state.font = translated.font;
  9350. translated.send(this.handler);
  9351. return translated.loadedName;
  9352. });
  9353. }
  9354. handleText(chars, state) {
  9355. const font = state.font;
  9356. const glyphs = font.charsToGlyphs(chars);
  9357. if (font.data) {
  9358. const isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  9359. if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) {
  9360. PartialEvaluator.buildFontPaths(font, glyphs, this.handler, this.options);
  9361. }
  9362. }
  9363. return glyphs;
  9364. }
  9365. ensureStateFont(state) {
  9366. if (state.font) {
  9367. return;
  9368. }
  9369. const reason = new _util.FormatError("Missing setFont (Tf) operator before text rendering operator.");
  9370. if (this.options.ignoreErrors) {
  9371. (0, _util.warn)(`ensureStateFont: "${reason}".`);
  9372. return;
  9373. }
  9374. throw reason;
  9375. }
  9376. async setGState({
  9377. resources,
  9378. gState,
  9379. operatorList,
  9380. cacheKey,
  9381. task,
  9382. stateManager,
  9383. localGStateCache,
  9384. localColorSpaceCache
  9385. }) {
  9386. const gStateRef = gState.objId;
  9387. let isSimpleGState = true;
  9388. const gStateObj = [];
  9389. let promise = Promise.resolve();
  9390. for (const key of gState.getKeys()) {
  9391. const value = gState.get(key);
  9392. switch (key) {
  9393. case "Type":
  9394. break;
  9395. case "LW":
  9396. case "LC":
  9397. case "LJ":
  9398. case "ML":
  9399. case "D":
  9400. case "RI":
  9401. case "FL":
  9402. case "CA":
  9403. case "ca":
  9404. gStateObj.push([key, value]);
  9405. break;
  9406. case "Font":
  9407. isSimpleGState = false;
  9408. promise = promise.then(() => {
  9409. return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  9410. operatorList.addDependency(loadedName);
  9411. gStateObj.push([key, [loadedName, value[1]]]);
  9412. });
  9413. });
  9414. break;
  9415. case "BM":
  9416. gStateObj.push([key, normalizeBlendMode(value)]);
  9417. break;
  9418. case "SMask":
  9419. if ((0, _primitives.isName)(value, "None")) {
  9420. gStateObj.push([key, false]);
  9421. break;
  9422. }
  9423. if (value instanceof _primitives.Dict) {
  9424. isSimpleGState = false;
  9425. promise = promise.then(() => {
  9426. return this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache);
  9427. });
  9428. gStateObj.push([key, true]);
  9429. } else {
  9430. (0, _util.warn)("Unsupported SMask type");
  9431. }
  9432. break;
  9433. case "TR":
  9434. const transferMaps = this.handleTransferFunction(value);
  9435. gStateObj.push([key, transferMaps]);
  9436. break;
  9437. case "OP":
  9438. case "op":
  9439. case "OPM":
  9440. case "BG":
  9441. case "BG2":
  9442. case "UCR":
  9443. case "UCR2":
  9444. case "TR2":
  9445. case "HT":
  9446. case "SM":
  9447. case "SA":
  9448. case "AIS":
  9449. case "TK":
  9450. (0, _util.info)("graphic state operator " + key);
  9451. break;
  9452. default:
  9453. (0, _util.info)("Unknown graphic state operator " + key);
  9454. break;
  9455. }
  9456. }
  9457. return promise.then(function () {
  9458. if (gStateObj.length > 0) {
  9459. operatorList.addOp(_util.OPS.setGState, [gStateObj]);
  9460. }
  9461. if (isSimpleGState) {
  9462. localGStateCache.set(cacheKey, gStateRef, gStateObj);
  9463. }
  9464. });
  9465. }
  9466. loadFont(fontName, font, resources, fallbackFontDict = null, cssFontInfo = null) {
  9467. const errorFont = async () => {
  9468. return new TranslatedFont({
  9469. loadedName: "g_font_error",
  9470. font: new _fonts.ErrorFont(`Font "${fontName}" is not available.`),
  9471. dict: font,
  9472. evaluatorOptions: this.options
  9473. });
  9474. };
  9475. let fontRef;
  9476. if (font) {
  9477. if (font instanceof _primitives.Ref) {
  9478. fontRef = font;
  9479. }
  9480. } else {
  9481. const fontRes = resources.get("Font");
  9482. if (fontRes) {
  9483. fontRef = fontRes.getRaw(fontName);
  9484. }
  9485. }
  9486. if (fontRef) {
  9487. if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) {
  9488. return errorFont();
  9489. }
  9490. if (this.fontCache.has(fontRef)) {
  9491. return this.fontCache.get(fontRef);
  9492. }
  9493. font = this.xref.fetchIfRef(fontRef);
  9494. }
  9495. if (!(font instanceof _primitives.Dict)) {
  9496. if (!this.options.ignoreErrors && !this.parsingType3Font) {
  9497. (0, _util.warn)(`Font "${fontName}" is not available.`);
  9498. return errorFont();
  9499. }
  9500. (0, _util.warn)(`Font "${fontName}" is not available -- attempting to fallback to a default font.`);
  9501. font = fallbackFontDict || PartialEvaluator.fallbackFontDict;
  9502. }
  9503. if (font.cacheKey && this.fontCache.has(font.cacheKey)) {
  9504. return this.fontCache.get(font.cacheKey);
  9505. }
  9506. const fontCapability = new _util.PromiseCapability();
  9507. let preEvaluatedFont;
  9508. try {
  9509. preEvaluatedFont = this.preEvaluateFont(font);
  9510. preEvaluatedFont.cssFontInfo = cssFontInfo;
  9511. } catch (reason) {
  9512. (0, _util.warn)(`loadFont - preEvaluateFont failed: "${reason}".`);
  9513. return errorFont();
  9514. }
  9515. const {
  9516. descriptor,
  9517. hash
  9518. } = preEvaluatedFont;
  9519. const fontRefIsRef = fontRef instanceof _primitives.Ref;
  9520. let fontID;
  9521. if (hash && descriptor instanceof _primitives.Dict) {
  9522. const fontAliases = descriptor.fontAliases ||= Object.create(null);
  9523. if (fontAliases[hash]) {
  9524. const aliasFontRef = fontAliases[hash].aliasRef;
  9525. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  9526. this.fontCache.putAlias(fontRef, aliasFontRef);
  9527. return this.fontCache.get(fontRef);
  9528. }
  9529. } else {
  9530. fontAliases[hash] = {
  9531. fontID: this.idFactory.createFontId()
  9532. };
  9533. }
  9534. if (fontRefIsRef) {
  9535. fontAliases[hash].aliasRef = fontRef;
  9536. }
  9537. fontID = fontAliases[hash].fontID;
  9538. } else {
  9539. fontID = this.idFactory.createFontId();
  9540. }
  9541. (0, _util.assert)(fontID?.startsWith("f"), 'The "fontID" must be (correctly) defined.');
  9542. if (fontRefIsRef) {
  9543. this.fontCache.put(fontRef, fontCapability.promise);
  9544. } else {
  9545. font.cacheKey = `cacheKey_${fontID}`;
  9546. this.fontCache.put(font.cacheKey, fontCapability.promise);
  9547. }
  9548. font.loadedName = `${this.idFactory.getDocId()}_${fontID}`;
  9549. this.translateFont(preEvaluatedFont).then(translatedFont => {
  9550. fontCapability.resolve(new TranslatedFont({
  9551. loadedName: font.loadedName,
  9552. font: translatedFont,
  9553. dict: font,
  9554. evaluatorOptions: this.options
  9555. }));
  9556. }).catch(reason => {
  9557. (0, _util.warn)(`loadFont - translateFont failed: "${reason}".`);
  9558. fontCapability.resolve(new TranslatedFont({
  9559. loadedName: font.loadedName,
  9560. font: new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason),
  9561. dict: font,
  9562. evaluatorOptions: this.options
  9563. }));
  9564. });
  9565. return fontCapability.promise;
  9566. }
  9567. buildPath(operatorList, fn, args, parsingText = false) {
  9568. const lastIndex = operatorList.length - 1;
  9569. if (!args) {
  9570. args = [];
  9571. }
  9572. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
  9573. if (parsingText) {
  9574. (0, _util.warn)(`Encountered path operator "${fn}" inside of a text object.`);
  9575. operatorList.addOp(_util.OPS.save, null);
  9576. }
  9577. let minMax;
  9578. switch (fn) {
  9579. case _util.OPS.rectangle:
  9580. const x = args[0] + args[2];
  9581. const y = args[1] + args[3];
  9582. minMax = [Math.min(args[0], x), Math.max(args[0], x), Math.min(args[1], y), Math.max(args[1], y)];
  9583. break;
  9584. case _util.OPS.moveTo:
  9585. case _util.OPS.lineTo:
  9586. minMax = [args[0], args[0], args[1], args[1]];
  9587. break;
  9588. default:
  9589. minMax = [Infinity, -Infinity, Infinity, -Infinity];
  9590. break;
  9591. }
  9592. operatorList.addOp(_util.OPS.constructPath, [[fn], args, minMax]);
  9593. if (parsingText) {
  9594. operatorList.addOp(_util.OPS.restore, null);
  9595. }
  9596. } else {
  9597. const opArgs = operatorList.argsArray[lastIndex];
  9598. opArgs[0].push(fn);
  9599. opArgs[1].push(...args);
  9600. const minMax = opArgs[2];
  9601. switch (fn) {
  9602. case _util.OPS.rectangle:
  9603. const x = args[0] + args[2];
  9604. const y = args[1] + args[3];
  9605. minMax[0] = Math.min(minMax[0], args[0], x);
  9606. minMax[1] = Math.max(minMax[1], args[0], x);
  9607. minMax[2] = Math.min(minMax[2], args[1], y);
  9608. minMax[3] = Math.max(minMax[3], args[1], y);
  9609. break;
  9610. case _util.OPS.moveTo:
  9611. case _util.OPS.lineTo:
  9612. minMax[0] = Math.min(minMax[0], args[0]);
  9613. minMax[1] = Math.max(minMax[1], args[0]);
  9614. minMax[2] = Math.min(minMax[2], args[1]);
  9615. minMax[3] = Math.max(minMax[3], args[1]);
  9616. break;
  9617. }
  9618. }
  9619. }
  9620. parseColorSpace({
  9621. cs,
  9622. resources,
  9623. localColorSpaceCache
  9624. }) {
  9625. return _colorspace.ColorSpace.parseAsync({
  9626. cs,
  9627. xref: this.xref,
  9628. resources,
  9629. pdfFunctionFactory: this._pdfFunctionFactory,
  9630. localColorSpaceCache
  9631. }).catch(reason => {
  9632. if (reason instanceof _util.AbortException) {
  9633. return null;
  9634. }
  9635. if (this.options.ignoreErrors) {
  9636. (0, _util.warn)(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
  9637. return null;
  9638. }
  9639. throw reason;
  9640. });
  9641. }
  9642. parseShading({
  9643. shading,
  9644. resources,
  9645. localColorSpaceCache,
  9646. localShadingPatternCache
  9647. }) {
  9648. let id = localShadingPatternCache.get(shading);
  9649. if (!id) {
  9650. var shadingFill = _pattern.Pattern.parseShading(shading, this.xref, resources, this._pdfFunctionFactory, localColorSpaceCache);
  9651. const patternIR = shadingFill.getIR();
  9652. id = `pattern_${this.idFactory.createObjId()}`;
  9653. if (this.parsingType3Font) {
  9654. id = `${this.idFactory.getDocId()}_type3_${id}`;
  9655. }
  9656. localShadingPatternCache.set(shading, id);
  9657. if (this.parsingType3Font) {
  9658. this.handler.send("commonobj", [id, "Pattern", patternIR]);
  9659. } else {
  9660. this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]);
  9661. }
  9662. }
  9663. return id;
  9664. }
  9665. handleColorN(operatorList, fn, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache) {
  9666. const patternName = args.pop();
  9667. if (patternName instanceof _primitives.Name) {
  9668. const rawPattern = patterns.getRaw(patternName.name);
  9669. const localTilingPattern = rawPattern instanceof _primitives.Ref && localTilingPatternCache.getByRef(rawPattern);
  9670. if (localTilingPattern) {
  9671. try {
  9672. const color = cs.base ? cs.base.getRgb(args, 0) : null;
  9673. const tilingPatternIR = (0, _pattern.getTilingPatternIR)(localTilingPattern.operatorListIR, localTilingPattern.dict, color);
  9674. operatorList.addOp(fn, tilingPatternIR);
  9675. return undefined;
  9676. } catch {}
  9677. }
  9678. const pattern = this.xref.fetchIfRef(rawPattern);
  9679. if (pattern) {
  9680. const dict = pattern instanceof _base_stream.BaseStream ? pattern.dict : pattern;
  9681. const typeNum = dict.get("PatternType");
  9682. if (typeNum === PatternType.TILING) {
  9683. const color = cs.base ? cs.base.getRgb(args, 0) : null;
  9684. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task, localTilingPatternCache);
  9685. } else if (typeNum === PatternType.SHADING) {
  9686. const shading = dict.get("Shading");
  9687. const matrix = dict.getArray("Matrix");
  9688. const objId = this.parseShading({
  9689. shading,
  9690. resources,
  9691. localColorSpaceCache,
  9692. localShadingPatternCache
  9693. });
  9694. operatorList.addOp(fn, ["Shading", objId, matrix]);
  9695. return undefined;
  9696. }
  9697. throw new _util.FormatError(`Unknown PatternType: ${typeNum}`);
  9698. }
  9699. }
  9700. throw new _util.FormatError(`Unknown PatternName: ${patternName}`);
  9701. }
  9702. _parseVisibilityExpression(array, nestingCounter, currentResult) {
  9703. const MAX_NESTING = 10;
  9704. if (++nestingCounter > MAX_NESTING) {
  9705. (0, _util.warn)("Visibility expression is too deeply nested");
  9706. return;
  9707. }
  9708. const length = array.length;
  9709. const operator = this.xref.fetchIfRef(array[0]);
  9710. if (length < 2 || !(operator instanceof _primitives.Name)) {
  9711. (0, _util.warn)("Invalid visibility expression");
  9712. return;
  9713. }
  9714. switch (operator.name) {
  9715. case "And":
  9716. case "Or":
  9717. case "Not":
  9718. currentResult.push(operator.name);
  9719. break;
  9720. default:
  9721. (0, _util.warn)(`Invalid operator ${operator.name} in visibility expression`);
  9722. return;
  9723. }
  9724. for (let i = 1; i < length; i++) {
  9725. const raw = array[i];
  9726. const object = this.xref.fetchIfRef(raw);
  9727. if (Array.isArray(object)) {
  9728. const nestedResult = [];
  9729. currentResult.push(nestedResult);
  9730. this._parseVisibilityExpression(object, nestingCounter, nestedResult);
  9731. } else if (raw instanceof _primitives.Ref) {
  9732. currentResult.push(raw.toString());
  9733. }
  9734. }
  9735. }
  9736. async parseMarkedContentProps(contentProperties, resources) {
  9737. let optionalContent;
  9738. if (contentProperties instanceof _primitives.Name) {
  9739. const properties = resources.get("Properties");
  9740. optionalContent = properties.get(contentProperties.name);
  9741. } else if (contentProperties instanceof _primitives.Dict) {
  9742. optionalContent = contentProperties;
  9743. } else {
  9744. throw new _util.FormatError("Optional content properties malformed.");
  9745. }
  9746. const optionalContentType = optionalContent.get("Type").name;
  9747. if (optionalContentType === "OCG") {
  9748. return {
  9749. type: optionalContentType,
  9750. id: optionalContent.objId
  9751. };
  9752. } else if (optionalContentType === "OCMD") {
  9753. const expression = optionalContent.get("VE");
  9754. if (Array.isArray(expression)) {
  9755. const result = [];
  9756. this._parseVisibilityExpression(expression, 0, result);
  9757. if (result.length > 0) {
  9758. return {
  9759. type: "OCMD",
  9760. expression: result
  9761. };
  9762. }
  9763. }
  9764. const optionalContentGroups = optionalContent.get("OCGs");
  9765. if (Array.isArray(optionalContentGroups) || optionalContentGroups instanceof _primitives.Dict) {
  9766. const groupIds = [];
  9767. if (Array.isArray(optionalContentGroups)) {
  9768. for (const ocg of optionalContentGroups) {
  9769. groupIds.push(ocg.toString());
  9770. }
  9771. } else {
  9772. groupIds.push(optionalContentGroups.objId);
  9773. }
  9774. return {
  9775. type: optionalContentType,
  9776. ids: groupIds,
  9777. policy: optionalContent.get("P") instanceof _primitives.Name ? optionalContent.get("P").name : null,
  9778. expression: null
  9779. };
  9780. } else if (optionalContentGroups instanceof _primitives.Ref) {
  9781. return {
  9782. type: optionalContentType,
  9783. id: optionalContentGroups.toString()
  9784. };
  9785. }
  9786. }
  9787. return null;
  9788. }
  9789. getOperatorList({
  9790. stream,
  9791. task,
  9792. resources,
  9793. operatorList,
  9794. initialState = null,
  9795. fallbackFontDict = null
  9796. }) {
  9797. resources ||= _primitives.Dict.empty;
  9798. initialState ||= new EvalState();
  9799. if (!operatorList) {
  9800. throw new Error('getOperatorList: missing "operatorList" parameter');
  9801. }
  9802. const self = this;
  9803. const xref = this.xref;
  9804. let parsingText = false;
  9805. const localImageCache = new _image_utils.LocalImageCache();
  9806. const localColorSpaceCache = new _image_utils.LocalColorSpaceCache();
  9807. const localGStateCache = new _image_utils.LocalGStateCache();
  9808. const localTilingPatternCache = new _image_utils.LocalTilingPatternCache();
  9809. const localShadingPatternCache = new Map();
  9810. const xobjs = resources.get("XObject") || _primitives.Dict.empty;
  9811. const patterns = resources.get("Pattern") || _primitives.Dict.empty;
  9812. const stateManager = new StateManager(initialState);
  9813. const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  9814. const timeSlotManager = new TimeSlotManager();
  9815. function closePendingRestoreOPS(argument) {
  9816. for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  9817. operatorList.addOp(_util.OPS.restore, []);
  9818. }
  9819. }
  9820. return new Promise(function promiseBody(resolve, reject) {
  9821. const next = function (promise) {
  9822. Promise.all([promise, operatorList.ready]).then(function () {
  9823. try {
  9824. promiseBody(resolve, reject);
  9825. } catch (ex) {
  9826. reject(ex);
  9827. }
  9828. }, reject);
  9829. };
  9830. task.ensureNotTerminated();
  9831. timeSlotManager.reset();
  9832. const operation = {};
  9833. let stop, i, ii, cs, name, isValidName;
  9834. while (!(stop = timeSlotManager.check())) {
  9835. operation.args = null;
  9836. if (!preprocessor.read(operation)) {
  9837. break;
  9838. }
  9839. let args = operation.args;
  9840. let fn = operation.fn;
  9841. switch (fn | 0) {
  9842. case _util.OPS.paintXObject:
  9843. isValidName = args[0] instanceof _primitives.Name;
  9844. name = args[0].name;
  9845. if (isValidName) {
  9846. const localImage = localImageCache.getByName(name);
  9847. if (localImage) {
  9848. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  9849. incrementCachedImageMaskCount(localImage);
  9850. args = null;
  9851. continue;
  9852. }
  9853. }
  9854. next(new Promise(function (resolveXObject, rejectXObject) {
  9855. if (!isValidName) {
  9856. throw new _util.FormatError("XObject must be referred to by name.");
  9857. }
  9858. let xobj = xobjs.getRaw(name);
  9859. if (xobj instanceof _primitives.Ref) {
  9860. const localImage = localImageCache.getByRef(xobj) || self._regionalImageCache.getByRef(xobj);
  9861. if (localImage) {
  9862. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  9863. incrementCachedImageMaskCount(localImage);
  9864. resolveXObject();
  9865. return;
  9866. }
  9867. const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
  9868. if (globalImage) {
  9869. operatorList.addDependency(globalImage.objId);
  9870. operatorList.addImageOps(globalImage.fn, globalImage.args, globalImage.optionalContent);
  9871. resolveXObject();
  9872. return;
  9873. }
  9874. xobj = xref.fetch(xobj);
  9875. }
  9876. if (!(xobj instanceof _base_stream.BaseStream)) {
  9877. throw new _util.FormatError("XObject should be a stream");
  9878. }
  9879. const type = xobj.dict.get("Subtype");
  9880. if (!(type instanceof _primitives.Name)) {
  9881. throw new _util.FormatError("XObject should have a Name subtype");
  9882. }
  9883. if (type.name === "Form") {
  9884. stateManager.save();
  9885. self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone(), localColorSpaceCache).then(function () {
  9886. stateManager.restore();
  9887. resolveXObject();
  9888. }, rejectXObject);
  9889. return;
  9890. } else if (type.name === "Image") {
  9891. self.buildPaintImageXObject({
  9892. resources,
  9893. image: xobj,
  9894. operatorList,
  9895. cacheKey: name,
  9896. localImageCache,
  9897. localColorSpaceCache
  9898. }).then(resolveXObject, rejectXObject);
  9899. return;
  9900. } else if (type.name === "PS") {
  9901. (0, _util.info)("Ignored XObject subtype PS");
  9902. } else {
  9903. throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
  9904. }
  9905. resolveXObject();
  9906. }).catch(function (reason) {
  9907. if (reason instanceof _util.AbortException) {
  9908. return;
  9909. }
  9910. if (self.options.ignoreErrors) {
  9911. (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
  9912. return;
  9913. }
  9914. throw reason;
  9915. }));
  9916. return;
  9917. case _util.OPS.setFont:
  9918. var fontSize = args[1];
  9919. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state, fallbackFontDict).then(function (loadedName) {
  9920. operatorList.addDependency(loadedName);
  9921. operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
  9922. }));
  9923. return;
  9924. case _util.OPS.beginText:
  9925. parsingText = true;
  9926. break;
  9927. case _util.OPS.endText:
  9928. parsingText = false;
  9929. break;
  9930. case _util.OPS.endInlineImage:
  9931. var cacheKey = args[0].cacheKey;
  9932. if (cacheKey) {
  9933. const localImage = localImageCache.getByName(cacheKey);
  9934. if (localImage) {
  9935. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  9936. incrementCachedImageMaskCount(localImage);
  9937. args = null;
  9938. continue;
  9939. }
  9940. }
  9941. next(self.buildPaintImageXObject({
  9942. resources,
  9943. image: args[0],
  9944. isInline: true,
  9945. operatorList,
  9946. cacheKey,
  9947. localImageCache,
  9948. localColorSpaceCache
  9949. }));
  9950. return;
  9951. case _util.OPS.showText:
  9952. if (!stateManager.state.font) {
  9953. self.ensureStateFont(stateManager.state);
  9954. continue;
  9955. }
  9956. args[0] = self.handleText(args[0], stateManager.state);
  9957. break;
  9958. case _util.OPS.showSpacedText:
  9959. if (!stateManager.state.font) {
  9960. self.ensureStateFont(stateManager.state);
  9961. continue;
  9962. }
  9963. var combinedGlyphs = [];
  9964. var state = stateManager.state;
  9965. for (const arrItem of args[0]) {
  9966. if (typeof arrItem === "string") {
  9967. combinedGlyphs.push(...self.handleText(arrItem, state));
  9968. } else if (typeof arrItem === "number") {
  9969. combinedGlyphs.push(arrItem);
  9970. }
  9971. }
  9972. args[0] = combinedGlyphs;
  9973. fn = _util.OPS.showText;
  9974. break;
  9975. case _util.OPS.nextLineShowText:
  9976. if (!stateManager.state.font) {
  9977. self.ensureStateFont(stateManager.state);
  9978. continue;
  9979. }
  9980. operatorList.addOp(_util.OPS.nextLine);
  9981. args[0] = self.handleText(args[0], stateManager.state);
  9982. fn = _util.OPS.showText;
  9983. break;
  9984. case _util.OPS.nextLineSetSpacingShowText:
  9985. if (!stateManager.state.font) {
  9986. self.ensureStateFont(stateManager.state);
  9987. continue;
  9988. }
  9989. operatorList.addOp(_util.OPS.nextLine);
  9990. operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
  9991. operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
  9992. args[0] = self.handleText(args[0], stateManager.state);
  9993. fn = _util.OPS.showText;
  9994. break;
  9995. case _util.OPS.setTextRenderingMode:
  9996. stateManager.state.textRenderingMode = args[0];
  9997. break;
  9998. case _util.OPS.setFillColorSpace:
  9999. {
  10000. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  10001. if (cachedColorSpace) {
  10002. stateManager.state.fillColorSpace = cachedColorSpace;
  10003. continue;
  10004. }
  10005. next(self.parseColorSpace({
  10006. cs: args[0],
  10007. resources,
  10008. localColorSpaceCache
  10009. }).then(function (colorSpace) {
  10010. if (colorSpace) {
  10011. stateManager.state.fillColorSpace = colorSpace;
  10012. }
  10013. }));
  10014. return;
  10015. }
  10016. case _util.OPS.setStrokeColorSpace:
  10017. {
  10018. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  10019. if (cachedColorSpace) {
  10020. stateManager.state.strokeColorSpace = cachedColorSpace;
  10021. continue;
  10022. }
  10023. next(self.parseColorSpace({
  10024. cs: args[0],
  10025. resources,
  10026. localColorSpaceCache
  10027. }).then(function (colorSpace) {
  10028. if (colorSpace) {
  10029. stateManager.state.strokeColorSpace = colorSpace;
  10030. }
  10031. }));
  10032. return;
  10033. }
  10034. case _util.OPS.setFillColor:
  10035. cs = stateManager.state.fillColorSpace;
  10036. args = cs.getRgb(args, 0);
  10037. fn = _util.OPS.setFillRGBColor;
  10038. break;
  10039. case _util.OPS.setStrokeColor:
  10040. cs = stateManager.state.strokeColorSpace;
  10041. args = cs.getRgb(args, 0);
  10042. fn = _util.OPS.setStrokeRGBColor;
  10043. break;
  10044. case _util.OPS.setFillGray:
  10045. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  10046. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  10047. fn = _util.OPS.setFillRGBColor;
  10048. break;
  10049. case _util.OPS.setStrokeGray:
  10050. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  10051. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  10052. fn = _util.OPS.setStrokeRGBColor;
  10053. break;
  10054. case _util.OPS.setFillCMYKColor:
  10055. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  10056. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  10057. fn = _util.OPS.setFillRGBColor;
  10058. break;
  10059. case _util.OPS.setStrokeCMYKColor:
  10060. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  10061. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  10062. fn = _util.OPS.setStrokeRGBColor;
  10063. break;
  10064. case _util.OPS.setFillRGBColor:
  10065. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
  10066. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  10067. break;
  10068. case _util.OPS.setStrokeRGBColor:
  10069. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
  10070. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  10071. break;
  10072. case _util.OPS.setFillColorN:
  10073. cs = stateManager.state.fillColorSpace;
  10074. if (cs.name === "Pattern") {
  10075. next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache));
  10076. return;
  10077. }
  10078. args = cs.getRgb(args, 0);
  10079. fn = _util.OPS.setFillRGBColor;
  10080. break;
  10081. case _util.OPS.setStrokeColorN:
  10082. cs = stateManager.state.strokeColorSpace;
  10083. if (cs.name === "Pattern") {
  10084. next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache));
  10085. return;
  10086. }
  10087. args = cs.getRgb(args, 0);
  10088. fn = _util.OPS.setStrokeRGBColor;
  10089. break;
  10090. case _util.OPS.shadingFill:
  10091. var shadingRes = resources.get("Shading");
  10092. if (!shadingRes) {
  10093. throw new _util.FormatError("No shading resource found");
  10094. }
  10095. var shading = shadingRes.get(args[0].name);
  10096. if (!shading) {
  10097. throw new _util.FormatError("No shading object found");
  10098. }
  10099. const patternId = self.parseShading({
  10100. shading,
  10101. resources,
  10102. localColorSpaceCache,
  10103. localShadingPatternCache
  10104. });
  10105. args = [patternId];
  10106. fn = _util.OPS.shadingFill;
  10107. break;
  10108. case _util.OPS.setGState:
  10109. isValidName = args[0] instanceof _primitives.Name;
  10110. name = args[0].name;
  10111. if (isValidName) {
  10112. const localGStateObj = localGStateCache.getByName(name);
  10113. if (localGStateObj) {
  10114. if (localGStateObj.length > 0) {
  10115. operatorList.addOp(_util.OPS.setGState, [localGStateObj]);
  10116. }
  10117. args = null;
  10118. continue;
  10119. }
  10120. }
  10121. next(new Promise(function (resolveGState, rejectGState) {
  10122. if (!isValidName) {
  10123. throw new _util.FormatError("GState must be referred to by name.");
  10124. }
  10125. const extGState = resources.get("ExtGState");
  10126. if (!(extGState instanceof _primitives.Dict)) {
  10127. throw new _util.FormatError("ExtGState should be a dictionary.");
  10128. }
  10129. const gState = extGState.get(name);
  10130. if (!(gState instanceof _primitives.Dict)) {
  10131. throw new _util.FormatError("GState should be a dictionary.");
  10132. }
  10133. self.setGState({
  10134. resources,
  10135. gState,
  10136. operatorList,
  10137. cacheKey: name,
  10138. task,
  10139. stateManager,
  10140. localGStateCache,
  10141. localColorSpaceCache
  10142. }).then(resolveGState, rejectGState);
  10143. }).catch(function (reason) {
  10144. if (reason instanceof _util.AbortException) {
  10145. return;
  10146. }
  10147. if (self.options.ignoreErrors) {
  10148. (0, _util.warn)(`getOperatorList - ignoring ExtGState: "${reason}".`);
  10149. return;
  10150. }
  10151. throw reason;
  10152. }));
  10153. return;
  10154. case _util.OPS.moveTo:
  10155. case _util.OPS.lineTo:
  10156. case _util.OPS.curveTo:
  10157. case _util.OPS.curveTo2:
  10158. case _util.OPS.curveTo3:
  10159. case _util.OPS.closePath:
  10160. case _util.OPS.rectangle:
  10161. self.buildPath(operatorList, fn, args, parsingText);
  10162. continue;
  10163. case _util.OPS.markPoint:
  10164. case _util.OPS.markPointProps:
  10165. case _util.OPS.beginCompat:
  10166. case _util.OPS.endCompat:
  10167. continue;
  10168. case _util.OPS.beginMarkedContentProps:
  10169. if (!(args[0] instanceof _primitives.Name)) {
  10170. (0, _util.warn)(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
  10171. continue;
  10172. }
  10173. if (args[0].name === "OC") {
  10174. next(self.parseMarkedContentProps(args[1], resources).then(data => {
  10175. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", data]);
  10176. }).catch(reason => {
  10177. if (reason instanceof _util.AbortException) {
  10178. return;
  10179. }
  10180. if (self.options.ignoreErrors) {
  10181. (0, _util.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`);
  10182. return;
  10183. }
  10184. throw reason;
  10185. }));
  10186. return;
  10187. }
  10188. args = [args[0].name, args[1] instanceof _primitives.Dict ? args[1].get("MCID") : null];
  10189. break;
  10190. case _util.OPS.beginMarkedContent:
  10191. case _util.OPS.endMarkedContent:
  10192. default:
  10193. if (args !== null) {
  10194. for (i = 0, ii = args.length; i < ii; i++) {
  10195. if (args[i] instanceof _primitives.Dict) {
  10196. break;
  10197. }
  10198. }
  10199. if (i < ii) {
  10200. (0, _util.warn)("getOperatorList - ignoring operator: " + fn);
  10201. continue;
  10202. }
  10203. }
  10204. }
  10205. operatorList.addOp(fn, args);
  10206. }
  10207. if (stop) {
  10208. next(deferred);
  10209. return;
  10210. }
  10211. closePendingRestoreOPS();
  10212. resolve();
  10213. }).catch(reason => {
  10214. if (reason instanceof _util.AbortException) {
  10215. return;
  10216. }
  10217. if (this.options.ignoreErrors) {
  10218. (0, _util.warn)(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  10219. closePendingRestoreOPS();
  10220. return;
  10221. }
  10222. throw reason;
  10223. });
  10224. }
  10225. getTextContent({
  10226. stream,
  10227. task,
  10228. resources,
  10229. stateManager = null,
  10230. includeMarkedContent = false,
  10231. sink,
  10232. seenStyles = new Set(),
  10233. viewBox,
  10234. markedContentData = null,
  10235. disableNormalization = false
  10236. }) {
  10237. resources ||= _primitives.Dict.empty;
  10238. stateManager ||= new StateManager(new TextState());
  10239. if (includeMarkedContent) {
  10240. markedContentData ||= {
  10241. level: 0
  10242. };
  10243. }
  10244. const textContent = {
  10245. items: [],
  10246. styles: Object.create(null)
  10247. };
  10248. const textContentItem = {
  10249. initialized: false,
  10250. str: [],
  10251. totalWidth: 0,
  10252. totalHeight: 0,
  10253. width: 0,
  10254. height: 0,
  10255. vertical: false,
  10256. prevTransform: null,
  10257. textAdvanceScale: 0,
  10258. spaceInFlowMin: 0,
  10259. spaceInFlowMax: 0,
  10260. trackingSpaceMin: Infinity,
  10261. negativeSpaceMax: -Infinity,
  10262. notASpace: -Infinity,
  10263. transform: null,
  10264. fontName: null,
  10265. hasEOL: false
  10266. };
  10267. const twoLastChars = [" ", " "];
  10268. let twoLastCharsPos = 0;
  10269. function saveLastChar(char) {
  10270. const nextPos = (twoLastCharsPos + 1) % 2;
  10271. const ret = twoLastChars[twoLastCharsPos] !== " " && twoLastChars[nextPos] === " ";
  10272. twoLastChars[twoLastCharsPos] = char;
  10273. twoLastCharsPos = nextPos;
  10274. return ret;
  10275. }
  10276. function shouldAddWhitepsace() {
  10277. return twoLastChars[twoLastCharsPos] !== " " && twoLastChars[(twoLastCharsPos + 1) % 2] === " ";
  10278. }
  10279. function resetLastChars() {
  10280. twoLastChars[0] = twoLastChars[1] = " ";
  10281. twoLastCharsPos = 0;
  10282. }
  10283. const TRACKING_SPACE_FACTOR = 0.102;
  10284. const NOT_A_SPACE_FACTOR = 0.03;
  10285. const NEGATIVE_SPACE_FACTOR = -0.2;
  10286. const SPACE_IN_FLOW_MIN_FACTOR = 0.102;
  10287. const SPACE_IN_FLOW_MAX_FACTOR = 0.6;
  10288. const VERTICAL_SHIFT_RATIO = 0.25;
  10289. const self = this;
  10290. const xref = this.xref;
  10291. const showSpacedTextBuffer = [];
  10292. let xobjs = null;
  10293. const emptyXObjectCache = new _image_utils.LocalImageCache();
  10294. const emptyGStateCache = new _image_utils.LocalGStateCache();
  10295. const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  10296. let textState;
  10297. function pushWhitespace({
  10298. width = 0,
  10299. height = 0,
  10300. transform = textContentItem.prevTransform,
  10301. fontName = textContentItem.fontName
  10302. }) {
  10303. textContent.items.push({
  10304. str: " ",
  10305. dir: "ltr",
  10306. width,
  10307. height,
  10308. transform,
  10309. fontName,
  10310. hasEOL: false
  10311. });
  10312. }
  10313. function getCurrentTextTransform() {
  10314. const font = textState.font;
  10315. const tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
  10316. if (font.isType3Font && (textState.fontSize <= 1 || font.isCharBBox) && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
  10317. const glyphHeight = font.bbox[3] - font.bbox[1];
  10318. if (glyphHeight > 0) {
  10319. tsm[3] *= glyphHeight * textState.fontMatrix[3];
  10320. }
  10321. }
  10322. return _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
  10323. }
  10324. function ensureTextContentItem() {
  10325. if (textContentItem.initialized) {
  10326. return textContentItem;
  10327. }
  10328. const {
  10329. font,
  10330. loadedName
  10331. } = textState;
  10332. if (!seenStyles.has(loadedName)) {
  10333. seenStyles.add(loadedName);
  10334. textContent.styles[loadedName] = {
  10335. fontFamily: font.fallbackName,
  10336. ascent: font.ascent,
  10337. descent: font.descent,
  10338. vertical: font.vertical
  10339. };
  10340. }
  10341. textContentItem.fontName = loadedName;
  10342. const trm = textContentItem.transform = getCurrentTextTransform();
  10343. if (!font.vertical) {
  10344. textContentItem.width = textContentItem.totalWidth = 0;
  10345. textContentItem.height = textContentItem.totalHeight = Math.hypot(trm[2], trm[3]);
  10346. textContentItem.vertical = false;
  10347. } else {
  10348. textContentItem.width = textContentItem.totalWidth = Math.hypot(trm[0], trm[1]);
  10349. textContentItem.height = textContentItem.totalHeight = 0;
  10350. textContentItem.vertical = true;
  10351. }
  10352. const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
  10353. const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
  10354. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  10355. const {
  10356. fontSize
  10357. } = textState;
  10358. textContentItem.trackingSpaceMin = fontSize * TRACKING_SPACE_FACTOR;
  10359. textContentItem.notASpace = fontSize * NOT_A_SPACE_FACTOR;
  10360. textContentItem.negativeSpaceMax = fontSize * NEGATIVE_SPACE_FACTOR;
  10361. textContentItem.spaceInFlowMin = fontSize * SPACE_IN_FLOW_MIN_FACTOR;
  10362. textContentItem.spaceInFlowMax = fontSize * SPACE_IN_FLOW_MAX_FACTOR;
  10363. textContentItem.hasEOL = false;
  10364. textContentItem.initialized = true;
  10365. return textContentItem;
  10366. }
  10367. function updateAdvanceScale() {
  10368. if (!textContentItem.initialized) {
  10369. return;
  10370. }
  10371. const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
  10372. const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
  10373. const scaleFactor = scaleCtmX * scaleLineX;
  10374. if (scaleFactor === textContentItem.textAdvanceScale) {
  10375. return;
  10376. }
  10377. if (!textContentItem.vertical) {
  10378. textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
  10379. textContentItem.width = 0;
  10380. } else {
  10381. textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
  10382. textContentItem.height = 0;
  10383. }
  10384. textContentItem.textAdvanceScale = scaleFactor;
  10385. }
  10386. function runBidiTransform(textChunk) {
  10387. let text = textChunk.str.join("");
  10388. if (!disableNormalization) {
  10389. text = (0, _util.normalizeUnicode)(text);
  10390. }
  10391. const bidiResult = (0, _bidi.bidi)(text, -1, textChunk.vertical);
  10392. return {
  10393. str: bidiResult.str,
  10394. dir: bidiResult.dir,
  10395. width: Math.abs(textChunk.totalWidth),
  10396. height: Math.abs(textChunk.totalHeight),
  10397. transform: textChunk.transform,
  10398. fontName: textChunk.fontName,
  10399. hasEOL: textChunk.hasEOL
  10400. };
  10401. }
  10402. function handleSetFont(fontName, fontRef) {
  10403. return self.loadFont(fontName, fontRef, resources).then(function (translated) {
  10404. if (!translated.font.isType3Font) {
  10405. return translated;
  10406. }
  10407. return translated.loadType3Data(self, resources, task).catch(function () {}).then(function () {
  10408. return translated;
  10409. });
  10410. }).then(function (translated) {
  10411. textState.loadedName = translated.loadedName;
  10412. textState.font = translated.font;
  10413. textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  10414. });
  10415. }
  10416. function applyInverseRotation(x, y, matrix) {
  10417. const scale = Math.hypot(matrix[0], matrix[1]);
  10418. return [(matrix[0] * x + matrix[1] * y) / scale, (matrix[2] * x + matrix[3] * y) / scale];
  10419. }
  10420. function compareWithLastPosition(glyphWidth) {
  10421. const currentTransform = getCurrentTextTransform();
  10422. let posX = currentTransform[4];
  10423. let posY = currentTransform[5];
  10424. if (textState.font?.vertical) {
  10425. if (posX < viewBox[0] || posX > viewBox[2] || posY + glyphWidth < viewBox[1] || posY > viewBox[3]) {
  10426. return false;
  10427. }
  10428. } else if (posX + glyphWidth < viewBox[0] || posX > viewBox[2] || posY < viewBox[1] || posY > viewBox[3]) {
  10429. return false;
  10430. }
  10431. if (!textState.font || !textContentItem.prevTransform) {
  10432. return true;
  10433. }
  10434. let lastPosX = textContentItem.prevTransform[4];
  10435. let lastPosY = textContentItem.prevTransform[5];
  10436. if (lastPosX === posX && lastPosY === posY) {
  10437. return true;
  10438. }
  10439. let rotate = -1;
  10440. if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) {
  10441. rotate = currentTransform[0] > 0 ? 0 : 180;
  10442. } else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) {
  10443. rotate = currentTransform[1] > 0 ? 90 : 270;
  10444. }
  10445. switch (rotate) {
  10446. case 0:
  10447. break;
  10448. case 90:
  10449. [posX, posY] = [posY, posX];
  10450. [lastPosX, lastPosY] = [lastPosY, lastPosX];
  10451. break;
  10452. case 180:
  10453. [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY];
  10454. break;
  10455. case 270:
  10456. [posX, posY] = [-posY, -posX];
  10457. [lastPosX, lastPosY] = [-lastPosY, -lastPosX];
  10458. break;
  10459. default:
  10460. [posX, posY] = applyInverseRotation(posX, posY, currentTransform);
  10461. [lastPosX, lastPosY] = applyInverseRotation(lastPosX, lastPosY, textContentItem.prevTransform);
  10462. }
  10463. if (textState.font.vertical) {
  10464. const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale;
  10465. const advanceX = posX - lastPosX;
  10466. const textOrientation = Math.sign(textContentItem.height);
  10467. if (advanceY < textOrientation * textContentItem.negativeSpaceMax) {
  10468. if (Math.abs(advanceX) > 0.5 * textContentItem.width) {
  10469. appendEOL();
  10470. return true;
  10471. }
  10472. resetLastChars();
  10473. flushTextContentItem();
  10474. return true;
  10475. }
  10476. if (Math.abs(advanceX) > textContentItem.width) {
  10477. appendEOL();
  10478. return true;
  10479. }
  10480. if (advanceY <= textOrientation * textContentItem.notASpace) {
  10481. resetLastChars();
  10482. }
  10483. if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) {
  10484. if (shouldAddWhitepsace()) {
  10485. resetLastChars();
  10486. flushTextContentItem();
  10487. pushWhitespace({
  10488. height: Math.abs(advanceY)
  10489. });
  10490. } else {
  10491. textContentItem.height += advanceY;
  10492. }
  10493. } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) {
  10494. if (textContentItem.str.length === 0) {
  10495. resetLastChars();
  10496. pushWhitespace({
  10497. height: Math.abs(advanceY)
  10498. });
  10499. } else {
  10500. textContentItem.height += advanceY;
  10501. }
  10502. }
  10503. if (Math.abs(advanceX) > textContentItem.width * VERTICAL_SHIFT_RATIO) {
  10504. flushTextContentItem();
  10505. }
  10506. return true;
  10507. }
  10508. const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale;
  10509. const advanceY = posY - lastPosY;
  10510. const textOrientation = Math.sign(textContentItem.width);
  10511. if (advanceX < textOrientation * textContentItem.negativeSpaceMax) {
  10512. if (Math.abs(advanceY) > 0.5 * textContentItem.height) {
  10513. appendEOL();
  10514. return true;
  10515. }
  10516. resetLastChars();
  10517. flushTextContentItem();
  10518. return true;
  10519. }
  10520. if (Math.abs(advanceY) > textContentItem.height) {
  10521. appendEOL();
  10522. return true;
  10523. }
  10524. if (advanceX <= textOrientation * textContentItem.notASpace) {
  10525. resetLastChars();
  10526. }
  10527. if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) {
  10528. if (shouldAddWhitepsace()) {
  10529. resetLastChars();
  10530. flushTextContentItem();
  10531. pushWhitespace({
  10532. width: Math.abs(advanceX)
  10533. });
  10534. } else {
  10535. textContentItem.width += advanceX;
  10536. }
  10537. } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) {
  10538. if (textContentItem.str.length === 0) {
  10539. resetLastChars();
  10540. pushWhitespace({
  10541. width: Math.abs(advanceX)
  10542. });
  10543. } else {
  10544. textContentItem.width += advanceX;
  10545. }
  10546. }
  10547. if (Math.abs(advanceY) > textContentItem.height * VERTICAL_SHIFT_RATIO) {
  10548. flushTextContentItem();
  10549. }
  10550. return true;
  10551. }
  10552. function buildTextContentItem({
  10553. chars,
  10554. extraSpacing
  10555. }) {
  10556. const font = textState.font;
  10557. if (!chars) {
  10558. const charSpacing = textState.charSpacing + extraSpacing;
  10559. if (charSpacing) {
  10560. if (!font.vertical) {
  10561. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  10562. } else {
  10563. textState.translateTextMatrix(0, -charSpacing);
  10564. }
  10565. }
  10566. return;
  10567. }
  10568. const glyphs = font.charsToGlyphs(chars);
  10569. const scale = textState.fontMatrix[0] * textState.fontSize;
  10570. for (let i = 0, ii = glyphs.length; i < ii; i++) {
  10571. const glyph = glyphs[i];
  10572. const {
  10573. category
  10574. } = glyph;
  10575. if (category.isInvisibleFormatMark) {
  10576. continue;
  10577. }
  10578. let charSpacing = textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
  10579. let glyphWidth = glyph.width;
  10580. if (font.vertical) {
  10581. glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth;
  10582. }
  10583. let scaledDim = glyphWidth * scale;
  10584. if (category.isWhitespace) {
  10585. if (!font.vertical) {
  10586. charSpacing += scaledDim + textState.wordSpacing;
  10587. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  10588. } else {
  10589. charSpacing += -scaledDim + textState.wordSpacing;
  10590. textState.translateTextMatrix(0, -charSpacing);
  10591. }
  10592. saveLastChar(" ");
  10593. continue;
  10594. }
  10595. if (!category.isZeroWidthDiacritic && !compareWithLastPosition(scaledDim)) {
  10596. if (!font.vertical) {
  10597. textState.translateTextMatrix(scaledDim * textState.textHScale, 0);
  10598. } else {
  10599. textState.translateTextMatrix(0, scaledDim);
  10600. }
  10601. continue;
  10602. }
  10603. const textChunk = ensureTextContentItem();
  10604. if (category.isZeroWidthDiacritic) {
  10605. scaledDim = 0;
  10606. }
  10607. if (!font.vertical) {
  10608. scaledDim *= textState.textHScale;
  10609. textState.translateTextMatrix(scaledDim, 0);
  10610. textChunk.width += scaledDim;
  10611. } else {
  10612. textState.translateTextMatrix(0, scaledDim);
  10613. scaledDim = Math.abs(scaledDim);
  10614. textChunk.height += scaledDim;
  10615. }
  10616. if (scaledDim) {
  10617. textChunk.prevTransform = getCurrentTextTransform();
  10618. }
  10619. const glyphUnicode = glyph.unicode;
  10620. if (saveLastChar(glyphUnicode)) {
  10621. textChunk.str.push(" ");
  10622. }
  10623. textChunk.str.push(glyphUnicode);
  10624. if (charSpacing) {
  10625. if (!font.vertical) {
  10626. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  10627. } else {
  10628. textState.translateTextMatrix(0, -charSpacing);
  10629. }
  10630. }
  10631. }
  10632. }
  10633. function appendEOL() {
  10634. resetLastChars();
  10635. if (textContentItem.initialized) {
  10636. textContentItem.hasEOL = true;
  10637. flushTextContentItem();
  10638. } else {
  10639. textContent.items.push({
  10640. str: "",
  10641. dir: "ltr",
  10642. width: 0,
  10643. height: 0,
  10644. transform: getCurrentTextTransform(),
  10645. fontName: textState.loadedName,
  10646. hasEOL: true
  10647. });
  10648. }
  10649. }
  10650. function addFakeSpaces(width, transf, textOrientation) {
  10651. if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) {
  10652. if (textContentItem.initialized) {
  10653. resetLastChars();
  10654. textContentItem.str.push(" ");
  10655. }
  10656. return false;
  10657. }
  10658. const fontName = textContentItem.fontName;
  10659. let height = 0;
  10660. if (textContentItem.vertical) {
  10661. height = width;
  10662. width = 0;
  10663. }
  10664. flushTextContentItem();
  10665. resetLastChars();
  10666. pushWhitespace({
  10667. width: Math.abs(width),
  10668. height: Math.abs(height),
  10669. transform: transf || getCurrentTextTransform(),
  10670. fontName
  10671. });
  10672. return true;
  10673. }
  10674. function flushTextContentItem() {
  10675. if (!textContentItem.initialized || !textContentItem.str) {
  10676. return;
  10677. }
  10678. if (!textContentItem.vertical) {
  10679. textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
  10680. } else {
  10681. textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
  10682. }
  10683. textContent.items.push(runBidiTransform(textContentItem));
  10684. textContentItem.initialized = false;
  10685. textContentItem.str.length = 0;
  10686. }
  10687. function enqueueChunk(batch = false) {
  10688. const length = textContent.items.length;
  10689. if (length === 0) {
  10690. return;
  10691. }
  10692. if (batch && length < TEXT_CHUNK_BATCH_SIZE) {
  10693. return;
  10694. }
  10695. sink.enqueue(textContent, length);
  10696. textContent.items = [];
  10697. textContent.styles = Object.create(null);
  10698. }
  10699. const timeSlotManager = new TimeSlotManager();
  10700. return new Promise(function promiseBody(resolve, reject) {
  10701. const next = function (promise) {
  10702. enqueueChunk(true);
  10703. Promise.all([promise, sink.ready]).then(function () {
  10704. try {
  10705. promiseBody(resolve, reject);
  10706. } catch (ex) {
  10707. reject(ex);
  10708. }
  10709. }, reject);
  10710. };
  10711. task.ensureNotTerminated();
  10712. timeSlotManager.reset();
  10713. const operation = {};
  10714. let stop,
  10715. args = [];
  10716. while (!(stop = timeSlotManager.check())) {
  10717. args.length = 0;
  10718. operation.args = args;
  10719. if (!preprocessor.read(operation)) {
  10720. break;
  10721. }
  10722. const previousState = textState;
  10723. textState = stateManager.state;
  10724. const fn = operation.fn;
  10725. args = operation.args;
  10726. switch (fn | 0) {
  10727. case _util.OPS.setFont:
  10728. var fontNameArg = args[0].name,
  10729. fontSizeArg = args[1];
  10730. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  10731. break;
  10732. }
  10733. flushTextContentItem();
  10734. textState.fontName = fontNameArg;
  10735. textState.fontSize = fontSizeArg;
  10736. next(handleSetFont(fontNameArg, null));
  10737. return;
  10738. case _util.OPS.setTextRise:
  10739. textState.textRise = args[0];
  10740. break;
  10741. case _util.OPS.setHScale:
  10742. textState.textHScale = args[0] / 100;
  10743. break;
  10744. case _util.OPS.setLeading:
  10745. textState.leading = args[0];
  10746. break;
  10747. case _util.OPS.moveText:
  10748. textState.translateTextLineMatrix(args[0], args[1]);
  10749. textState.textMatrix = textState.textLineMatrix.slice();
  10750. break;
  10751. case _util.OPS.setLeadingMoveText:
  10752. textState.leading = -args[1];
  10753. textState.translateTextLineMatrix(args[0], args[1]);
  10754. textState.textMatrix = textState.textLineMatrix.slice();
  10755. break;
  10756. case _util.OPS.nextLine:
  10757. textState.carriageReturn();
  10758. break;
  10759. case _util.OPS.setTextMatrix:
  10760. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  10761. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  10762. updateAdvanceScale();
  10763. break;
  10764. case _util.OPS.setCharSpacing:
  10765. textState.charSpacing = args[0];
  10766. break;
  10767. case _util.OPS.setWordSpacing:
  10768. textState.wordSpacing = args[0];
  10769. break;
  10770. case _util.OPS.beginText:
  10771. textState.textMatrix = _util.IDENTITY_MATRIX.slice();
  10772. textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  10773. break;
  10774. case _util.OPS.showSpacedText:
  10775. if (!stateManager.state.font) {
  10776. self.ensureStateFont(stateManager.state);
  10777. continue;
  10778. }
  10779. const spaceFactor = (textState.font.vertical ? 1 : -1) * textState.fontSize / 1000;
  10780. const elements = args[0];
  10781. for (let i = 0, ii = elements.length; i < ii; i++) {
  10782. const item = elements[i];
  10783. if (typeof item === "string") {
  10784. showSpacedTextBuffer.push(item);
  10785. } else if (typeof item === "number" && item !== 0) {
  10786. const str = showSpacedTextBuffer.join("");
  10787. showSpacedTextBuffer.length = 0;
  10788. buildTextContentItem({
  10789. chars: str,
  10790. extraSpacing: item * spaceFactor
  10791. });
  10792. }
  10793. }
  10794. if (showSpacedTextBuffer.length > 0) {
  10795. const str = showSpacedTextBuffer.join("");
  10796. showSpacedTextBuffer.length = 0;
  10797. buildTextContentItem({
  10798. chars: str,
  10799. extraSpacing: 0
  10800. });
  10801. }
  10802. break;
  10803. case _util.OPS.showText:
  10804. if (!stateManager.state.font) {
  10805. self.ensureStateFont(stateManager.state);
  10806. continue;
  10807. }
  10808. buildTextContentItem({
  10809. chars: args[0],
  10810. extraSpacing: 0
  10811. });
  10812. break;
  10813. case _util.OPS.nextLineShowText:
  10814. if (!stateManager.state.font) {
  10815. self.ensureStateFont(stateManager.state);
  10816. continue;
  10817. }
  10818. textState.carriageReturn();
  10819. buildTextContentItem({
  10820. chars: args[0],
  10821. extraSpacing: 0
  10822. });
  10823. break;
  10824. case _util.OPS.nextLineSetSpacingShowText:
  10825. if (!stateManager.state.font) {
  10826. self.ensureStateFont(stateManager.state);
  10827. continue;
  10828. }
  10829. textState.wordSpacing = args[0];
  10830. textState.charSpacing = args[1];
  10831. textState.carriageReturn();
  10832. buildTextContentItem({
  10833. chars: args[2],
  10834. extraSpacing: 0
  10835. });
  10836. break;
  10837. case _util.OPS.paintXObject:
  10838. flushTextContentItem();
  10839. if (!xobjs) {
  10840. xobjs = resources.get("XObject") || _primitives.Dict.empty;
  10841. }
  10842. var isValidName = args[0] instanceof _primitives.Name;
  10843. var name = args[0].name;
  10844. if (isValidName && emptyXObjectCache.getByName(name)) {
  10845. break;
  10846. }
  10847. next(new Promise(function (resolveXObject, rejectXObject) {
  10848. if (!isValidName) {
  10849. throw new _util.FormatError("XObject must be referred to by name.");
  10850. }
  10851. let xobj = xobjs.getRaw(name);
  10852. if (xobj instanceof _primitives.Ref) {
  10853. if (emptyXObjectCache.getByRef(xobj)) {
  10854. resolveXObject();
  10855. return;
  10856. }
  10857. const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
  10858. if (globalImage) {
  10859. resolveXObject();
  10860. return;
  10861. }
  10862. xobj = xref.fetch(xobj);
  10863. }
  10864. if (!(xobj instanceof _base_stream.BaseStream)) {
  10865. throw new _util.FormatError("XObject should be a stream");
  10866. }
  10867. const type = xobj.dict.get("Subtype");
  10868. if (!(type instanceof _primitives.Name)) {
  10869. throw new _util.FormatError("XObject should have a Name subtype");
  10870. }
  10871. if (type.name !== "Form") {
  10872. emptyXObjectCache.set(name, xobj.dict.objId, true);
  10873. resolveXObject();
  10874. return;
  10875. }
  10876. const currentState = stateManager.state.clone();
  10877. const xObjStateManager = new StateManager(currentState);
  10878. const matrix = xobj.dict.getArray("Matrix");
  10879. if (Array.isArray(matrix) && matrix.length === 6) {
  10880. xObjStateManager.transform(matrix);
  10881. }
  10882. enqueueChunk();
  10883. const sinkWrapper = {
  10884. enqueueInvoked: false,
  10885. enqueue(chunk, size) {
  10886. this.enqueueInvoked = true;
  10887. sink.enqueue(chunk, size);
  10888. },
  10889. get desiredSize() {
  10890. return sink.desiredSize;
  10891. },
  10892. get ready() {
  10893. return sink.ready;
  10894. }
  10895. };
  10896. self.getTextContent({
  10897. stream: xobj,
  10898. task,
  10899. resources: xobj.dict.get("Resources") || resources,
  10900. stateManager: xObjStateManager,
  10901. includeMarkedContent,
  10902. sink: sinkWrapper,
  10903. seenStyles,
  10904. viewBox,
  10905. markedContentData,
  10906. disableNormalization
  10907. }).then(function () {
  10908. if (!sinkWrapper.enqueueInvoked) {
  10909. emptyXObjectCache.set(name, xobj.dict.objId, true);
  10910. }
  10911. resolveXObject();
  10912. }, rejectXObject);
  10913. }).catch(function (reason) {
  10914. if (reason instanceof _util.AbortException) {
  10915. return;
  10916. }
  10917. if (self.options.ignoreErrors) {
  10918. (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
  10919. return;
  10920. }
  10921. throw reason;
  10922. }));
  10923. return;
  10924. case _util.OPS.setGState:
  10925. isValidName = args[0] instanceof _primitives.Name;
  10926. name = args[0].name;
  10927. if (isValidName && emptyGStateCache.getByName(name)) {
  10928. break;
  10929. }
  10930. next(new Promise(function (resolveGState, rejectGState) {
  10931. if (!isValidName) {
  10932. throw new _util.FormatError("GState must be referred to by name.");
  10933. }
  10934. const extGState = resources.get("ExtGState");
  10935. if (!(extGState instanceof _primitives.Dict)) {
  10936. throw new _util.FormatError("ExtGState should be a dictionary.");
  10937. }
  10938. const gState = extGState.get(name);
  10939. if (!(gState instanceof _primitives.Dict)) {
  10940. throw new _util.FormatError("GState should be a dictionary.");
  10941. }
  10942. const gStateFont = gState.get("Font");
  10943. if (!gStateFont) {
  10944. emptyGStateCache.set(name, gState.objId, true);
  10945. resolveGState();
  10946. return;
  10947. }
  10948. flushTextContentItem();
  10949. textState.fontName = null;
  10950. textState.fontSize = gStateFont[1];
  10951. handleSetFont(null, gStateFont[0]).then(resolveGState, rejectGState);
  10952. }).catch(function (reason) {
  10953. if (reason instanceof _util.AbortException) {
  10954. return;
  10955. }
  10956. if (self.options.ignoreErrors) {
  10957. (0, _util.warn)(`getTextContent - ignoring ExtGState: "${reason}".`);
  10958. return;
  10959. }
  10960. throw reason;
  10961. }));
  10962. return;
  10963. case _util.OPS.beginMarkedContent:
  10964. flushTextContentItem();
  10965. if (includeMarkedContent) {
  10966. markedContentData.level++;
  10967. textContent.items.push({
  10968. type: "beginMarkedContent",
  10969. tag: args[0] instanceof _primitives.Name ? args[0].name : null
  10970. });
  10971. }
  10972. break;
  10973. case _util.OPS.beginMarkedContentProps:
  10974. flushTextContentItem();
  10975. if (includeMarkedContent) {
  10976. markedContentData.level++;
  10977. let mcid = null;
  10978. if (args[1] instanceof _primitives.Dict) {
  10979. mcid = args[1].get("MCID");
  10980. }
  10981. textContent.items.push({
  10982. type: "beginMarkedContentProps",
  10983. id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mc${mcid}` : null,
  10984. tag: args[0] instanceof _primitives.Name ? args[0].name : null
  10985. });
  10986. }
  10987. break;
  10988. case _util.OPS.endMarkedContent:
  10989. flushTextContentItem();
  10990. if (includeMarkedContent) {
  10991. if (markedContentData.level === 0) {
  10992. break;
  10993. }
  10994. markedContentData.level--;
  10995. textContent.items.push({
  10996. type: "endMarkedContent"
  10997. });
  10998. }
  10999. break;
  11000. case _util.OPS.restore:
  11001. if (previousState && (previousState.font !== textState.font || previousState.fontSize !== textState.fontSize || previousState.fontName !== textState.fontName)) {
  11002. flushTextContentItem();
  11003. }
  11004. break;
  11005. }
  11006. if (textContent.items.length >= sink.desiredSize) {
  11007. stop = true;
  11008. break;
  11009. }
  11010. }
  11011. if (stop) {
  11012. next(deferred);
  11013. return;
  11014. }
  11015. flushTextContentItem();
  11016. enqueueChunk();
  11017. resolve();
  11018. }).catch(reason => {
  11019. if (reason instanceof _util.AbortException) {
  11020. return;
  11021. }
  11022. if (this.options.ignoreErrors) {
  11023. (0, _util.warn)(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  11024. flushTextContentItem();
  11025. enqueueChunk();
  11026. return;
  11027. }
  11028. throw reason;
  11029. });
  11030. }
  11031. extractDataStructures(dict, baseDict, properties) {
  11032. const xref = this.xref;
  11033. let cidToGidBytes;
  11034. const toUnicodePromise = this.readToUnicode(properties.toUnicode || dict.get("ToUnicode") || baseDict.get("ToUnicode"));
  11035. if (properties.composite) {
  11036. const cidSystemInfo = dict.get("CIDSystemInfo");
  11037. if (cidSystemInfo instanceof _primitives.Dict) {
  11038. properties.cidSystemInfo = {
  11039. registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
  11040. ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
  11041. supplement: cidSystemInfo.get("Supplement")
  11042. };
  11043. }
  11044. try {
  11045. const cidToGidMap = dict.get("CIDToGIDMap");
  11046. if (cidToGidMap instanceof _base_stream.BaseStream) {
  11047. cidToGidBytes = cidToGidMap.getBytes();
  11048. }
  11049. } catch (ex) {
  11050. if (!this.options.ignoreErrors) {
  11051. throw ex;
  11052. }
  11053. (0, _util.warn)(`extractDataStructures - ignoring CIDToGIDMap data: "${ex}".`);
  11054. }
  11055. }
  11056. const differences = [];
  11057. let baseEncodingName = null;
  11058. let encoding;
  11059. if (dict.has("Encoding")) {
  11060. encoding = dict.get("Encoding");
  11061. if (encoding instanceof _primitives.Dict) {
  11062. baseEncodingName = encoding.get("BaseEncoding");
  11063. baseEncodingName = baseEncodingName instanceof _primitives.Name ? baseEncodingName.name : null;
  11064. if (encoding.has("Differences")) {
  11065. const diffEncoding = encoding.get("Differences");
  11066. let index = 0;
  11067. for (const entry of diffEncoding) {
  11068. const data = xref.fetchIfRef(entry);
  11069. if (typeof data === "number") {
  11070. index = data;
  11071. } else if (data instanceof _primitives.Name) {
  11072. differences[index++] = data.name;
  11073. } else {
  11074. throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
  11075. }
  11076. }
  11077. }
  11078. } else if (encoding instanceof _primitives.Name) {
  11079. baseEncodingName = encoding.name;
  11080. } else {
  11081. const msg = "Encoding is not a Name nor a Dict";
  11082. if (!this.options.ignoreErrors) {
  11083. throw new _util.FormatError(msg);
  11084. }
  11085. (0, _util.warn)(msg);
  11086. }
  11087. if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
  11088. baseEncodingName = null;
  11089. }
  11090. }
  11091. const nonEmbeddedFont = !properties.file || properties.isInternalFont,
  11092. isSymbolsFontName = (0, _standard_fonts.getSymbolsFonts)()[properties.name];
  11093. if (baseEncodingName && nonEmbeddedFont && isSymbolsFontName) {
  11094. baseEncodingName = null;
  11095. }
  11096. if (baseEncodingName) {
  11097. properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  11098. } else {
  11099. const isSymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Symbolic);
  11100. const isNonsymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Nonsymbolic);
  11101. encoding = _encodings.StandardEncoding;
  11102. if (properties.type === "TrueType" && !isNonsymbolicFont) {
  11103. encoding = _encodings.WinAnsiEncoding;
  11104. }
  11105. if (isSymbolicFont || isSymbolsFontName) {
  11106. encoding = _encodings.MacRomanEncoding;
  11107. if (nonEmbeddedFont) {
  11108. if (/Symbol/i.test(properties.name)) {
  11109. encoding = _encodings.SymbolSetEncoding;
  11110. } else if (/Dingbats/i.test(properties.name)) {
  11111. encoding = _encodings.ZapfDingbatsEncoding;
  11112. } else if (/Wingdings/i.test(properties.name)) {
  11113. encoding = _encodings.WinAnsiEncoding;
  11114. }
  11115. }
  11116. }
  11117. properties.defaultEncoding = encoding;
  11118. }
  11119. properties.differences = differences;
  11120. properties.baseEncodingName = baseEncodingName;
  11121. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  11122. properties.dict = dict;
  11123. return toUnicodePromise.then(readToUnicode => {
  11124. properties.toUnicode = readToUnicode;
  11125. return this.buildToUnicode(properties);
  11126. }).then(builtToUnicode => {
  11127. properties.toUnicode = builtToUnicode;
  11128. if (cidToGidBytes) {
  11129. properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode);
  11130. }
  11131. return properties;
  11132. });
  11133. }
  11134. _simpleFontToUnicode(properties, forceGlyphs = false) {
  11135. (0, _util.assert)(!properties.composite, "Must be a simple font.");
  11136. const toUnicode = [];
  11137. const encoding = properties.defaultEncoding.slice();
  11138. const baseEncodingName = properties.baseEncodingName;
  11139. const differences = properties.differences;
  11140. for (const charcode in differences) {
  11141. const glyphName = differences[charcode];
  11142. if (glyphName === ".notdef") {
  11143. continue;
  11144. }
  11145. encoding[charcode] = glyphName;
  11146. }
  11147. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  11148. for (const charcode in encoding) {
  11149. let glyphName = encoding[charcode];
  11150. if (glyphName === "") {
  11151. continue;
  11152. }
  11153. let unicode = glyphsUnicodeMap[glyphName];
  11154. if (unicode !== undefined) {
  11155. toUnicode[charcode] = String.fromCharCode(unicode);
  11156. continue;
  11157. }
  11158. let code = 0;
  11159. switch (glyphName[0]) {
  11160. case "G":
  11161. if (glyphName.length === 3) {
  11162. code = parseInt(glyphName.substring(1), 16);
  11163. }
  11164. break;
  11165. case "g":
  11166. if (glyphName.length === 5) {
  11167. code = parseInt(glyphName.substring(1), 16);
  11168. }
  11169. break;
  11170. case "C":
  11171. case "c":
  11172. if (glyphName.length >= 3 && glyphName.length <= 4) {
  11173. const codeStr = glyphName.substring(1);
  11174. if (forceGlyphs) {
  11175. code = parseInt(codeStr, 16);
  11176. break;
  11177. }
  11178. code = +codeStr;
  11179. if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
  11180. return this._simpleFontToUnicode(properties, true);
  11181. }
  11182. }
  11183. break;
  11184. case "u":
  11185. unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  11186. if (unicode !== -1) {
  11187. code = unicode;
  11188. }
  11189. break;
  11190. default:
  11191. switch (glyphName) {
  11192. case "f_h":
  11193. case "f_t":
  11194. case "T_h":
  11195. toUnicode[charcode] = glyphName.replaceAll("_", "");
  11196. continue;
  11197. }
  11198. break;
  11199. }
  11200. if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
  11201. if (baseEncodingName && code === +charcode) {
  11202. const baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  11203. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  11204. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  11205. continue;
  11206. }
  11207. }
  11208. toUnicode[charcode] = String.fromCodePoint(code);
  11209. }
  11210. }
  11211. return toUnicode;
  11212. }
  11213. async buildToUnicode(properties) {
  11214. properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0;
  11215. if (properties.hasIncludedToUnicodeMap) {
  11216. if (!properties.composite && properties.hasEncoding) {
  11217. properties.fallbackToUnicode = this._simpleFontToUnicode(properties);
  11218. }
  11219. return properties.toUnicode;
  11220. }
  11221. if (!properties.composite) {
  11222. return new _to_unicode_map.ToUnicodeMap(this._simpleFontToUnicode(properties));
  11223. }
  11224. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
  11225. const {
  11226. registry,
  11227. ordering
  11228. } = properties.cidSystemInfo;
  11229. const ucs2CMapName = _primitives.Name.get(`${registry}-${ordering}-UCS2`);
  11230. const ucs2CMap = await _cmap.CMapFactory.create({
  11231. encoding: ucs2CMapName,
  11232. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  11233. useCMap: null
  11234. });
  11235. const toUnicode = [],
  11236. buf = [];
  11237. properties.cMap.forEach(function (charcode, cid) {
  11238. if (cid > 0xffff) {
  11239. throw new _util.FormatError("Max size of CID is 65,535");
  11240. }
  11241. const ucs2 = ucs2CMap.lookup(cid);
  11242. if (ucs2) {
  11243. buf.length = 0;
  11244. for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
  11245. buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1));
  11246. }
  11247. toUnicode[charcode] = String.fromCharCode(...buf);
  11248. }
  11249. });
  11250. return new _to_unicode_map.ToUnicodeMap(toUnicode);
  11251. }
  11252. return new _to_unicode_map.IdentityToUnicodeMap(properties.firstChar, properties.lastChar);
  11253. }
  11254. readToUnicode(cmapObj) {
  11255. if (!cmapObj) {
  11256. return Promise.resolve(null);
  11257. }
  11258. if (cmapObj instanceof _primitives.Name) {
  11259. return _cmap.CMapFactory.create({
  11260. encoding: cmapObj,
  11261. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  11262. useCMap: null
  11263. }).then(function (cmap) {
  11264. if (cmap instanceof _cmap.IdentityCMap) {
  11265. return new _to_unicode_map.IdentityToUnicodeMap(0, 0xffff);
  11266. }
  11267. return new _to_unicode_map.ToUnicodeMap(cmap.getMap());
  11268. });
  11269. } else if (cmapObj instanceof _base_stream.BaseStream) {
  11270. return _cmap.CMapFactory.create({
  11271. encoding: cmapObj,
  11272. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  11273. useCMap: null
  11274. }).then(function (cmap) {
  11275. if (cmap instanceof _cmap.IdentityCMap) {
  11276. return new _to_unicode_map.IdentityToUnicodeMap(0, 0xffff);
  11277. }
  11278. const map = new Array(cmap.length);
  11279. cmap.forEach(function (charCode, token) {
  11280. if (typeof token === "number") {
  11281. map[charCode] = String.fromCodePoint(token);
  11282. return;
  11283. }
  11284. const str = [];
  11285. for (let k = 0; k < token.length; k += 2) {
  11286. const w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  11287. if ((w1 & 0xf800) !== 0xd800) {
  11288. str.push(w1);
  11289. continue;
  11290. }
  11291. k += 2;
  11292. const w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  11293. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  11294. }
  11295. map[charCode] = String.fromCodePoint(...str);
  11296. });
  11297. return new _to_unicode_map.ToUnicodeMap(map);
  11298. }, reason => {
  11299. if (reason instanceof _util.AbortException) {
  11300. return null;
  11301. }
  11302. if (this.options.ignoreErrors) {
  11303. (0, _util.warn)(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
  11304. return null;
  11305. }
  11306. throw reason;
  11307. });
  11308. }
  11309. return Promise.resolve(null);
  11310. }
  11311. readCidToGidMap(glyphsData, toUnicode) {
  11312. const result = [];
  11313. for (let j = 0, jj = glyphsData.length; j < jj; j++) {
  11314. const glyphID = glyphsData[j++] << 8 | glyphsData[j];
  11315. const code = j >> 1;
  11316. if (glyphID === 0 && !toUnicode.has(code)) {
  11317. continue;
  11318. }
  11319. result[code] = glyphID;
  11320. }
  11321. return result;
  11322. }
  11323. extractWidths(dict, descriptor, properties) {
  11324. const xref = this.xref;
  11325. let glyphsWidths = [];
  11326. let defaultWidth = 0;
  11327. const glyphsVMetrics = [];
  11328. let defaultVMetrics;
  11329. let i, ii, j, jj, start, code, widths;
  11330. if (properties.composite) {
  11331. defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
  11332. widths = dict.get("W");
  11333. if (widths) {
  11334. for (i = 0, ii = widths.length; i < ii; i++) {
  11335. start = xref.fetchIfRef(widths[i++]);
  11336. code = xref.fetchIfRef(widths[i]);
  11337. if (Array.isArray(code)) {
  11338. for (j = 0, jj = code.length; j < jj; j++) {
  11339. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  11340. }
  11341. } else {
  11342. const width = xref.fetchIfRef(widths[++i]);
  11343. for (j = start; j <= code; j++) {
  11344. glyphsWidths[j] = width;
  11345. }
  11346. }
  11347. }
  11348. }
  11349. if (properties.vertical) {
  11350. let vmetrics = dict.getArray("DW2") || [880, -1000];
  11351. defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
  11352. vmetrics = dict.get("W2");
  11353. if (vmetrics) {
  11354. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  11355. start = xref.fetchIfRef(vmetrics[i++]);
  11356. code = xref.fetchIfRef(vmetrics[i]);
  11357. if (Array.isArray(code)) {
  11358. for (j = 0, jj = code.length; j < jj; j++) {
  11359. glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
  11360. }
  11361. } else {
  11362. const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
  11363. for (j = start; j <= code; j++) {
  11364. glyphsVMetrics[j] = vmetric;
  11365. }
  11366. }
  11367. }
  11368. }
  11369. }
  11370. } else {
  11371. const firstChar = properties.firstChar;
  11372. widths = dict.get("Widths");
  11373. if (widths) {
  11374. j = firstChar;
  11375. for (i = 0, ii = widths.length; i < ii; i++) {
  11376. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  11377. }
  11378. defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
  11379. } else {
  11380. const baseFontName = dict.get("BaseFont");
  11381. if (baseFontName instanceof _primitives.Name) {
  11382. const metrics = this.getBaseFontMetrics(baseFontName.name);
  11383. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  11384. defaultWidth = metrics.defaultWidth;
  11385. }
  11386. }
  11387. }
  11388. let isMonospace = true;
  11389. let firstWidth = defaultWidth;
  11390. for (const glyph in glyphsWidths) {
  11391. const glyphWidth = glyphsWidths[glyph];
  11392. if (!glyphWidth) {
  11393. continue;
  11394. }
  11395. if (!firstWidth) {
  11396. firstWidth = glyphWidth;
  11397. continue;
  11398. }
  11399. if (firstWidth !== glyphWidth) {
  11400. isMonospace = false;
  11401. break;
  11402. }
  11403. }
  11404. if (isMonospace) {
  11405. properties.flags |= _fonts_utils.FontFlags.FixedPitch;
  11406. } else {
  11407. properties.flags &= ~_fonts_utils.FontFlags.FixedPitch;
  11408. }
  11409. properties.defaultWidth = defaultWidth;
  11410. properties.widths = glyphsWidths;
  11411. properties.defaultVMetrics = defaultVMetrics;
  11412. properties.vmetrics = glyphsVMetrics;
  11413. }
  11414. isSerifFont(baseFontName) {
  11415. const fontNameWoStyle = baseFontName.split("-")[0];
  11416. return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || /serif/gi.test(fontNameWoStyle);
  11417. }
  11418. getBaseFontMetrics(name) {
  11419. let defaultWidth = 0;
  11420. let widths = Object.create(null);
  11421. let monospace = false;
  11422. const stdFontMap = (0, _standard_fonts.getStdFontMap)();
  11423. let lookupName = stdFontMap[name] || name;
  11424. const Metrics = (0, _metrics.getMetrics)();
  11425. if (!(lookupName in Metrics)) {
  11426. lookupName = this.isSerifFont(name) ? "Times-Roman" : "Helvetica";
  11427. }
  11428. const glyphWidths = Metrics[lookupName];
  11429. if (typeof glyphWidths === "number") {
  11430. defaultWidth = glyphWidths;
  11431. monospace = true;
  11432. } else {
  11433. widths = glyphWidths();
  11434. }
  11435. return {
  11436. defaultWidth,
  11437. monospace,
  11438. widths
  11439. };
  11440. }
  11441. buildCharCodeToWidth(widthsByGlyphName, properties) {
  11442. const widths = Object.create(null);
  11443. const differences = properties.differences;
  11444. const encoding = properties.defaultEncoding;
  11445. for (let charCode = 0; charCode < 256; charCode++) {
  11446. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  11447. widths[charCode] = widthsByGlyphName[differences[charCode]];
  11448. continue;
  11449. }
  11450. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  11451. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  11452. continue;
  11453. }
  11454. }
  11455. return widths;
  11456. }
  11457. preEvaluateFont(dict) {
  11458. const baseDict = dict;
  11459. let type = dict.get("Subtype");
  11460. if (!(type instanceof _primitives.Name)) {
  11461. throw new _util.FormatError("invalid font Subtype");
  11462. }
  11463. let composite = false;
  11464. let hash, toUnicode;
  11465. if (type.name === "Type0") {
  11466. const df = dict.get("DescendantFonts");
  11467. if (!df) {
  11468. throw new _util.FormatError("Descendant fonts are not specified");
  11469. }
  11470. dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
  11471. if (!(dict instanceof _primitives.Dict)) {
  11472. throw new _util.FormatError("Descendant font is not a dictionary.");
  11473. }
  11474. type = dict.get("Subtype");
  11475. if (!(type instanceof _primitives.Name)) {
  11476. throw new _util.FormatError("invalid font Subtype");
  11477. }
  11478. composite = true;
  11479. }
  11480. const firstChar = dict.get("FirstChar") || 0,
  11481. lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
  11482. const descriptor = dict.get("FontDescriptor");
  11483. if (descriptor) {
  11484. hash = new _murmurhash.MurmurHash3_64();
  11485. const encoding = baseDict.getRaw("Encoding");
  11486. if (encoding instanceof _primitives.Name) {
  11487. hash.update(encoding.name);
  11488. } else if (encoding instanceof _primitives.Ref) {
  11489. hash.update(encoding.toString());
  11490. } else if (encoding instanceof _primitives.Dict) {
  11491. for (const entry of encoding.getRawValues()) {
  11492. if (entry instanceof _primitives.Name) {
  11493. hash.update(entry.name);
  11494. } else if (entry instanceof _primitives.Ref) {
  11495. hash.update(entry.toString());
  11496. } else if (Array.isArray(entry)) {
  11497. const diffLength = entry.length,
  11498. diffBuf = new Array(diffLength);
  11499. for (let j = 0; j < diffLength; j++) {
  11500. const diffEntry = entry[j];
  11501. if (diffEntry instanceof _primitives.Name) {
  11502. diffBuf[j] = diffEntry.name;
  11503. } else if (typeof diffEntry === "number" || diffEntry instanceof _primitives.Ref) {
  11504. diffBuf[j] = diffEntry.toString();
  11505. }
  11506. }
  11507. hash.update(diffBuf.join());
  11508. }
  11509. }
  11510. }
  11511. hash.update(`${firstChar}-${lastChar}`);
  11512. toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
  11513. if (toUnicode instanceof _base_stream.BaseStream) {
  11514. const stream = toUnicode.str || toUnicode;
  11515. const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  11516. hash.update(uint8array);
  11517. } else if (toUnicode instanceof _primitives.Name) {
  11518. hash.update(toUnicode.name);
  11519. }
  11520. const widths = dict.get("Widths") || baseDict.get("Widths");
  11521. if (Array.isArray(widths)) {
  11522. const widthsBuf = [];
  11523. for (const entry of widths) {
  11524. if (typeof entry === "number" || entry instanceof _primitives.Ref) {
  11525. widthsBuf.push(entry.toString());
  11526. }
  11527. }
  11528. hash.update(widthsBuf.join());
  11529. }
  11530. if (composite) {
  11531. hash.update("compositeFont");
  11532. const compositeWidths = dict.get("W") || baseDict.get("W");
  11533. if (Array.isArray(compositeWidths)) {
  11534. const widthsBuf = [];
  11535. for (const entry of compositeWidths) {
  11536. if (typeof entry === "number" || entry instanceof _primitives.Ref) {
  11537. widthsBuf.push(entry.toString());
  11538. } else if (Array.isArray(entry)) {
  11539. const subWidthsBuf = [];
  11540. for (const element of entry) {
  11541. if (typeof element === "number" || element instanceof _primitives.Ref) {
  11542. subWidthsBuf.push(element.toString());
  11543. }
  11544. }
  11545. widthsBuf.push(`[${subWidthsBuf.join()}]`);
  11546. }
  11547. }
  11548. hash.update(widthsBuf.join());
  11549. }
  11550. const cidToGidMap = dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap");
  11551. if (cidToGidMap instanceof _primitives.Name) {
  11552. hash.update(cidToGidMap.name);
  11553. } else if (cidToGidMap instanceof _primitives.Ref) {
  11554. hash.update(cidToGidMap.toString());
  11555. } else if (cidToGidMap instanceof _base_stream.BaseStream) {
  11556. hash.update(cidToGidMap.peekBytes());
  11557. }
  11558. }
  11559. }
  11560. return {
  11561. descriptor,
  11562. dict,
  11563. baseDict,
  11564. composite,
  11565. type: type.name,
  11566. firstChar,
  11567. lastChar,
  11568. toUnicode,
  11569. hash: hash ? hash.hexdigest() : ""
  11570. };
  11571. }
  11572. async translateFont({
  11573. descriptor,
  11574. dict,
  11575. baseDict,
  11576. composite,
  11577. type,
  11578. firstChar,
  11579. lastChar,
  11580. toUnicode,
  11581. cssFontInfo
  11582. }) {
  11583. const isType3Font = type === "Type3";
  11584. let properties;
  11585. if (!descriptor) {
  11586. if (isType3Font) {
  11587. descriptor = new _primitives.Dict(null);
  11588. descriptor.set("FontName", _primitives.Name.get(type));
  11589. descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
  11590. } else {
  11591. let baseFontName = dict.get("BaseFont");
  11592. if (!(baseFontName instanceof _primitives.Name)) {
  11593. throw new _util.FormatError("Base font is not specified");
  11594. }
  11595. baseFontName = baseFontName.name.replaceAll(/[,_]/g, "-");
  11596. const metrics = this.getBaseFontMetrics(baseFontName);
  11597. const fontNameWoStyle = baseFontName.split("-")[0];
  11598. const flags = (this.isSerifFont(fontNameWoStyle) ? _fonts_utils.FontFlags.Serif : 0) | (metrics.monospace ? _fonts_utils.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts_utils.FontFlags.Symbolic : _fonts_utils.FontFlags.Nonsymbolic);
  11599. properties = {
  11600. type,
  11601. name: baseFontName,
  11602. loadedName: baseDict.loadedName,
  11603. systemFontInfo: null,
  11604. widths: metrics.widths,
  11605. defaultWidth: metrics.defaultWidth,
  11606. isSimulatedFlags: true,
  11607. flags,
  11608. firstChar,
  11609. lastChar,
  11610. toUnicode,
  11611. xHeight: 0,
  11612. capHeight: 0,
  11613. italicAngle: 0,
  11614. isType3Font
  11615. };
  11616. const widths = dict.get("Widths");
  11617. const standardFontName = (0, _standard_fonts.getStandardFontName)(baseFontName);
  11618. let file = null;
  11619. if (standardFontName) {
  11620. file = await this.fetchStandardFontData(standardFontName);
  11621. properties.isInternalFont = !!file;
  11622. }
  11623. if (!properties.isInternalFont && this.options.useSystemFonts) {
  11624. properties.systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName);
  11625. }
  11626. return this.extractDataStructures(dict, dict, properties).then(newProperties => {
  11627. if (widths) {
  11628. const glyphWidths = [];
  11629. let j = firstChar;
  11630. for (const width of widths) {
  11631. glyphWidths[j++] = this.xref.fetchIfRef(width);
  11632. }
  11633. newProperties.widths = glyphWidths;
  11634. } else {
  11635. newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
  11636. }
  11637. return new _fonts.Font(baseFontName, file, newProperties);
  11638. });
  11639. }
  11640. }
  11641. let fontName = descriptor.get("FontName");
  11642. let baseFont = dict.get("BaseFont");
  11643. if (typeof fontName === "string") {
  11644. fontName = _primitives.Name.get(fontName);
  11645. }
  11646. if (typeof baseFont === "string") {
  11647. baseFont = _primitives.Name.get(baseFont);
  11648. }
  11649. const fontNameStr = fontName?.name;
  11650. const baseFontStr = baseFont?.name;
  11651. if (!isType3Font && fontNameStr !== baseFontStr) {
  11652. (0, _util.info)(`The FontDescriptor's FontName is "${fontNameStr}" but ` + `should be the same as the Font's BaseFont "${baseFontStr}".`);
  11653. if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !(0, _standard_fonts.isKnownFontName)(fontNameStr) && (0, _standard_fonts.isKnownFontName)(baseFontStr))) {
  11654. fontName = null;
  11655. }
  11656. }
  11657. fontName ||= baseFont;
  11658. if (!(fontName instanceof _primitives.Name)) {
  11659. throw new _util.FormatError("invalid font name");
  11660. }
  11661. let fontFile, subtype, length1, length2, length3;
  11662. try {
  11663. fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
  11664. } catch (ex) {
  11665. if (!this.options.ignoreErrors) {
  11666. throw ex;
  11667. }
  11668. (0, _util.warn)(`translateFont - fetching "${fontName.name}" font file: "${ex}".`);
  11669. fontFile = new _stream.NullStream();
  11670. }
  11671. let isInternalFont = false;
  11672. let glyphScaleFactors = null;
  11673. let systemFontInfo = null;
  11674. if (fontFile) {
  11675. if (fontFile.dict) {
  11676. const subtypeEntry = fontFile.dict.get("Subtype");
  11677. if (subtypeEntry instanceof _primitives.Name) {
  11678. subtype = subtypeEntry.name;
  11679. }
  11680. length1 = fontFile.dict.get("Length1");
  11681. length2 = fontFile.dict.get("Length2");
  11682. length3 = fontFile.dict.get("Length3");
  11683. }
  11684. } else if (cssFontInfo) {
  11685. const standardFontName = (0, _xfa_fonts.getXfaFontName)(fontName.name);
  11686. if (standardFontName) {
  11687. cssFontInfo.fontFamily = `${cssFontInfo.fontFamily}-PdfJS-XFA`;
  11688. cssFontInfo.metrics = standardFontName.metrics || null;
  11689. glyphScaleFactors = standardFontName.factors || null;
  11690. fontFile = await this.fetchStandardFontData(standardFontName.name);
  11691. isInternalFont = !!fontFile;
  11692. baseDict = dict = (0, _xfa_fonts.getXfaFontDict)(fontName.name);
  11693. composite = true;
  11694. }
  11695. } else if (!isType3Font) {
  11696. const standardFontName = (0, _standard_fonts.getStandardFontName)(fontName.name);
  11697. if (standardFontName) {
  11698. fontFile = await this.fetchStandardFontData(standardFontName);
  11699. isInternalFont = !!fontFile;
  11700. }
  11701. if (!isInternalFont && this.options.useSystemFonts) {
  11702. systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName);
  11703. }
  11704. }
  11705. properties = {
  11706. type,
  11707. name: fontName.name,
  11708. subtype,
  11709. file: fontFile,
  11710. length1,
  11711. length2,
  11712. length3,
  11713. isInternalFont,
  11714. loadedName: baseDict.loadedName,
  11715. composite,
  11716. fixedPitch: false,
  11717. fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
  11718. firstChar,
  11719. lastChar,
  11720. toUnicode,
  11721. bbox: descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
  11722. ascent: descriptor.get("Ascent"),
  11723. descent: descriptor.get("Descent"),
  11724. xHeight: descriptor.get("XHeight") || 0,
  11725. capHeight: descriptor.get("CapHeight") || 0,
  11726. flags: descriptor.get("Flags"),
  11727. italicAngle: descriptor.get("ItalicAngle") || 0,
  11728. isType3Font,
  11729. cssFontInfo,
  11730. scaleFactors: glyphScaleFactors,
  11731. systemFontInfo
  11732. };
  11733. if (composite) {
  11734. const cidEncoding = baseDict.get("Encoding");
  11735. if (cidEncoding instanceof _primitives.Name) {
  11736. properties.cidEncoding = cidEncoding.name;
  11737. }
  11738. const cMap = await _cmap.CMapFactory.create({
  11739. encoding: cidEncoding,
  11740. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  11741. useCMap: null
  11742. });
  11743. properties.cMap = cMap;
  11744. properties.vertical = properties.cMap.vertical;
  11745. }
  11746. return this.extractDataStructures(dict, baseDict, properties).then(newProperties => {
  11747. this.extractWidths(dict, descriptor, newProperties);
  11748. return new _fonts.Font(fontName.name, fontFile, newProperties);
  11749. });
  11750. }
  11751. static buildFontPaths(font, glyphs, handler, evaluatorOptions) {
  11752. function buildPath(fontChar) {
  11753. const glyphName = `${font.loadedName}_path_${fontChar}`;
  11754. try {
  11755. if (font.renderer.hasBuiltPath(fontChar)) {
  11756. return;
  11757. }
  11758. handler.send("commonobj", [glyphName, "FontPath", font.renderer.getPathJs(fontChar)]);
  11759. } catch (reason) {
  11760. if (evaluatorOptions.ignoreErrors) {
  11761. (0, _util.warn)(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`);
  11762. return;
  11763. }
  11764. throw reason;
  11765. }
  11766. }
  11767. for (const glyph of glyphs) {
  11768. buildPath(glyph.fontChar);
  11769. const accent = glyph.accent;
  11770. if (accent?.fontChar) {
  11771. buildPath(accent.fontChar);
  11772. }
  11773. }
  11774. }
  11775. static get fallbackFontDict() {
  11776. const dict = new _primitives.Dict();
  11777. dict.set("BaseFont", _primitives.Name.get("Helvetica"));
  11778. dict.set("Type", _primitives.Name.get("FallbackType"));
  11779. dict.set("Subtype", _primitives.Name.get("FallbackType"));
  11780. dict.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  11781. return (0, _util.shadow)(this, "fallbackFontDict", dict);
  11782. }
  11783. }
  11784. exports.PartialEvaluator = PartialEvaluator;
  11785. class TranslatedFont {
  11786. constructor({
  11787. loadedName,
  11788. font,
  11789. dict,
  11790. evaluatorOptions
  11791. }) {
  11792. this.loadedName = loadedName;
  11793. this.font = font;
  11794. this.dict = dict;
  11795. this._evaluatorOptions = evaluatorOptions || DefaultPartialEvaluatorOptions;
  11796. this.type3Loaded = null;
  11797. this.type3Dependencies = font.isType3Font ? new Set() : null;
  11798. this.sent = false;
  11799. }
  11800. send(handler) {
  11801. if (this.sent) {
  11802. return;
  11803. }
  11804. this.sent = true;
  11805. handler.send("commonobj", [this.loadedName, "Font", this.font.exportData(this._evaluatorOptions.fontExtraProperties)]);
  11806. }
  11807. fallback(handler) {
  11808. if (!this.font.data) {
  11809. return;
  11810. }
  11811. this.font.disableFontFace = true;
  11812. PartialEvaluator.buildFontPaths(this.font, this.font.glyphCacheValues, handler, this._evaluatorOptions);
  11813. }
  11814. loadType3Data(evaluator, resources, task) {
  11815. if (this.type3Loaded) {
  11816. return this.type3Loaded;
  11817. }
  11818. if (!this.font.isType3Font) {
  11819. throw new Error("Must be a Type3 font.");
  11820. }
  11821. const type3Evaluator = evaluator.clone({
  11822. ignoreErrors: false
  11823. });
  11824. type3Evaluator.parsingType3Font = true;
  11825. const type3FontRefs = new _primitives.RefSet(evaluator.type3FontRefs);
  11826. if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) {
  11827. type3FontRefs.put(this.dict.objId);
  11828. }
  11829. type3Evaluator.type3FontRefs = type3FontRefs;
  11830. const translatedFont = this.font,
  11831. type3Dependencies = this.type3Dependencies;
  11832. let loadCharProcsPromise = Promise.resolve();
  11833. const charProcs = this.dict.get("CharProcs");
  11834. const fontResources = this.dict.get("Resources") || resources;
  11835. const charProcOperatorList = Object.create(null);
  11836. const fontBBox = _util.Util.normalizeRect(translatedFont.bbox || [0, 0, 0, 0]),
  11837. width = fontBBox[2] - fontBBox[0],
  11838. height = fontBBox[3] - fontBBox[1];
  11839. const fontBBoxSize = Math.hypot(width, height);
  11840. for (const key of charProcs.getKeys()) {
  11841. loadCharProcsPromise = loadCharProcsPromise.then(() => {
  11842. const glyphStream = charProcs.get(key);
  11843. const operatorList = new _operator_list.OperatorList();
  11844. return type3Evaluator.getOperatorList({
  11845. stream: glyphStream,
  11846. task,
  11847. resources: fontResources,
  11848. operatorList
  11849. }).then(() => {
  11850. if (operatorList.fnArray[0] === _util.OPS.setCharWidthAndBounds) {
  11851. this._removeType3ColorOperators(operatorList, fontBBoxSize);
  11852. }
  11853. charProcOperatorList[key] = operatorList.getIR();
  11854. for (const dependency of operatorList.dependencies) {
  11855. type3Dependencies.add(dependency);
  11856. }
  11857. }).catch(function (reason) {
  11858. (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
  11859. const dummyOperatorList = new _operator_list.OperatorList();
  11860. charProcOperatorList[key] = dummyOperatorList.getIR();
  11861. });
  11862. });
  11863. }
  11864. this.type3Loaded = loadCharProcsPromise.then(() => {
  11865. translatedFont.charProcOperatorList = charProcOperatorList;
  11866. if (this._bbox) {
  11867. translatedFont.isCharBBox = true;
  11868. translatedFont.bbox = this._bbox;
  11869. }
  11870. });
  11871. return this.type3Loaded;
  11872. }
  11873. _removeType3ColorOperators(operatorList, fontBBoxSize = NaN) {
  11874. const charBBox = _util.Util.normalizeRect(operatorList.argsArray[0].slice(2)),
  11875. width = charBBox[2] - charBBox[0],
  11876. height = charBBox[3] - charBBox[1];
  11877. const charBBoxSize = Math.hypot(width, height);
  11878. if (width === 0 || height === 0) {
  11879. operatorList.fnArray.splice(0, 1);
  11880. operatorList.argsArray.splice(0, 1);
  11881. } else if (fontBBoxSize === 0 || Math.round(charBBoxSize / fontBBoxSize) >= 10) {
  11882. if (!this._bbox) {
  11883. this._bbox = [Infinity, Infinity, -Infinity, -Infinity];
  11884. }
  11885. this._bbox[0] = Math.min(this._bbox[0], charBBox[0]);
  11886. this._bbox[1] = Math.min(this._bbox[1], charBBox[1]);
  11887. this._bbox[2] = Math.max(this._bbox[2], charBBox[2]);
  11888. this._bbox[3] = Math.max(this._bbox[3], charBBox[3]);
  11889. }
  11890. let i = 0,
  11891. ii = operatorList.length;
  11892. while (i < ii) {
  11893. switch (operatorList.fnArray[i]) {
  11894. case _util.OPS.setCharWidthAndBounds:
  11895. break;
  11896. case _util.OPS.setStrokeColorSpace:
  11897. case _util.OPS.setFillColorSpace:
  11898. case _util.OPS.setStrokeColor:
  11899. case _util.OPS.setStrokeColorN:
  11900. case _util.OPS.setFillColor:
  11901. case _util.OPS.setFillColorN:
  11902. case _util.OPS.setStrokeGray:
  11903. case _util.OPS.setFillGray:
  11904. case _util.OPS.setStrokeRGBColor:
  11905. case _util.OPS.setFillRGBColor:
  11906. case _util.OPS.setStrokeCMYKColor:
  11907. case _util.OPS.setFillCMYKColor:
  11908. case _util.OPS.shadingFill:
  11909. case _util.OPS.setRenderingIntent:
  11910. operatorList.fnArray.splice(i, 1);
  11911. operatorList.argsArray.splice(i, 1);
  11912. ii--;
  11913. continue;
  11914. case _util.OPS.setGState:
  11915. const [gStateObj] = operatorList.argsArray[i];
  11916. let j = 0,
  11917. jj = gStateObj.length;
  11918. while (j < jj) {
  11919. const [gStateKey] = gStateObj[j];
  11920. switch (gStateKey) {
  11921. case "TR":
  11922. case "TR2":
  11923. case "HT":
  11924. case "BG":
  11925. case "BG2":
  11926. case "UCR":
  11927. case "UCR2":
  11928. gStateObj.splice(j, 1);
  11929. jj--;
  11930. continue;
  11931. }
  11932. j++;
  11933. }
  11934. break;
  11935. }
  11936. i++;
  11937. }
  11938. }
  11939. }
  11940. class StateManager {
  11941. constructor(initialState = new EvalState()) {
  11942. this.state = initialState;
  11943. this.stateStack = [];
  11944. }
  11945. save() {
  11946. const old = this.state;
  11947. this.stateStack.push(this.state);
  11948. this.state = old.clone();
  11949. }
  11950. restore() {
  11951. const prev = this.stateStack.pop();
  11952. if (prev) {
  11953. this.state = prev;
  11954. }
  11955. }
  11956. transform(args) {
  11957. this.state.ctm = _util.Util.transform(this.state.ctm, args);
  11958. }
  11959. }
  11960. class TextState {
  11961. constructor() {
  11962. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  11963. this.fontName = null;
  11964. this.fontSize = 0;
  11965. this.loadedName = null;
  11966. this.font = null;
  11967. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  11968. this.textMatrix = _util.IDENTITY_MATRIX.slice();
  11969. this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  11970. this.charSpacing = 0;
  11971. this.wordSpacing = 0;
  11972. this.leading = 0;
  11973. this.textHScale = 1;
  11974. this.textRise = 0;
  11975. }
  11976. setTextMatrix(a, b, c, d, e, f) {
  11977. const m = this.textMatrix;
  11978. m[0] = a;
  11979. m[1] = b;
  11980. m[2] = c;
  11981. m[3] = d;
  11982. m[4] = e;
  11983. m[5] = f;
  11984. }
  11985. setTextLineMatrix(a, b, c, d, e, f) {
  11986. const m = this.textLineMatrix;
  11987. m[0] = a;
  11988. m[1] = b;
  11989. m[2] = c;
  11990. m[3] = d;
  11991. m[4] = e;
  11992. m[5] = f;
  11993. }
  11994. translateTextMatrix(x, y) {
  11995. const m = this.textMatrix;
  11996. m[4] = m[0] * x + m[2] * y + m[4];
  11997. m[5] = m[1] * x + m[3] * y + m[5];
  11998. }
  11999. translateTextLineMatrix(x, y) {
  12000. const m = this.textLineMatrix;
  12001. m[4] = m[0] * x + m[2] * y + m[4];
  12002. m[5] = m[1] * x + m[3] * y + m[5];
  12003. }
  12004. carriageReturn() {
  12005. this.translateTextLineMatrix(0, -this.leading);
  12006. this.textMatrix = this.textLineMatrix.slice();
  12007. }
  12008. clone() {
  12009. const clone = Object.create(this);
  12010. clone.textMatrix = this.textMatrix.slice();
  12011. clone.textLineMatrix = this.textLineMatrix.slice();
  12012. clone.fontMatrix = this.fontMatrix.slice();
  12013. return clone;
  12014. }
  12015. }
  12016. class EvalState {
  12017. constructor() {
  12018. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  12019. this.font = null;
  12020. this.textRenderingMode = _util.TextRenderingMode.FILL;
  12021. this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  12022. this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  12023. }
  12024. clone() {
  12025. return Object.create(this);
  12026. }
  12027. }
  12028. class EvaluatorPreprocessor {
  12029. static get opMap() {
  12030. const getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  12031. t.w = {
  12032. id: _util.OPS.setLineWidth,
  12033. numArgs: 1,
  12034. variableArgs: false
  12035. };
  12036. t.J = {
  12037. id: _util.OPS.setLineCap,
  12038. numArgs: 1,
  12039. variableArgs: false
  12040. };
  12041. t.j = {
  12042. id: _util.OPS.setLineJoin,
  12043. numArgs: 1,
  12044. variableArgs: false
  12045. };
  12046. t.M = {
  12047. id: _util.OPS.setMiterLimit,
  12048. numArgs: 1,
  12049. variableArgs: false
  12050. };
  12051. t.d = {
  12052. id: _util.OPS.setDash,
  12053. numArgs: 2,
  12054. variableArgs: false
  12055. };
  12056. t.ri = {
  12057. id: _util.OPS.setRenderingIntent,
  12058. numArgs: 1,
  12059. variableArgs: false
  12060. };
  12061. t.i = {
  12062. id: _util.OPS.setFlatness,
  12063. numArgs: 1,
  12064. variableArgs: false
  12065. };
  12066. t.gs = {
  12067. id: _util.OPS.setGState,
  12068. numArgs: 1,
  12069. variableArgs: false
  12070. };
  12071. t.q = {
  12072. id: _util.OPS.save,
  12073. numArgs: 0,
  12074. variableArgs: false
  12075. };
  12076. t.Q = {
  12077. id: _util.OPS.restore,
  12078. numArgs: 0,
  12079. variableArgs: false
  12080. };
  12081. t.cm = {
  12082. id: _util.OPS.transform,
  12083. numArgs: 6,
  12084. variableArgs: false
  12085. };
  12086. t.m = {
  12087. id: _util.OPS.moveTo,
  12088. numArgs: 2,
  12089. variableArgs: false
  12090. };
  12091. t.l = {
  12092. id: _util.OPS.lineTo,
  12093. numArgs: 2,
  12094. variableArgs: false
  12095. };
  12096. t.c = {
  12097. id: _util.OPS.curveTo,
  12098. numArgs: 6,
  12099. variableArgs: false
  12100. };
  12101. t.v = {
  12102. id: _util.OPS.curveTo2,
  12103. numArgs: 4,
  12104. variableArgs: false
  12105. };
  12106. t.y = {
  12107. id: _util.OPS.curveTo3,
  12108. numArgs: 4,
  12109. variableArgs: false
  12110. };
  12111. t.h = {
  12112. id: _util.OPS.closePath,
  12113. numArgs: 0,
  12114. variableArgs: false
  12115. };
  12116. t.re = {
  12117. id: _util.OPS.rectangle,
  12118. numArgs: 4,
  12119. variableArgs: false
  12120. };
  12121. t.S = {
  12122. id: _util.OPS.stroke,
  12123. numArgs: 0,
  12124. variableArgs: false
  12125. };
  12126. t.s = {
  12127. id: _util.OPS.closeStroke,
  12128. numArgs: 0,
  12129. variableArgs: false
  12130. };
  12131. t.f = {
  12132. id: _util.OPS.fill,
  12133. numArgs: 0,
  12134. variableArgs: false
  12135. };
  12136. t.F = {
  12137. id: _util.OPS.fill,
  12138. numArgs: 0,
  12139. variableArgs: false
  12140. };
  12141. t["f*"] = {
  12142. id: _util.OPS.eoFill,
  12143. numArgs: 0,
  12144. variableArgs: false
  12145. };
  12146. t.B = {
  12147. id: _util.OPS.fillStroke,
  12148. numArgs: 0,
  12149. variableArgs: false
  12150. };
  12151. t["B*"] = {
  12152. id: _util.OPS.eoFillStroke,
  12153. numArgs: 0,
  12154. variableArgs: false
  12155. };
  12156. t.b = {
  12157. id: _util.OPS.closeFillStroke,
  12158. numArgs: 0,
  12159. variableArgs: false
  12160. };
  12161. t["b*"] = {
  12162. id: _util.OPS.closeEOFillStroke,
  12163. numArgs: 0,
  12164. variableArgs: false
  12165. };
  12166. t.n = {
  12167. id: _util.OPS.endPath,
  12168. numArgs: 0,
  12169. variableArgs: false
  12170. };
  12171. t.W = {
  12172. id: _util.OPS.clip,
  12173. numArgs: 0,
  12174. variableArgs: false
  12175. };
  12176. t["W*"] = {
  12177. id: _util.OPS.eoClip,
  12178. numArgs: 0,
  12179. variableArgs: false
  12180. };
  12181. t.BT = {
  12182. id: _util.OPS.beginText,
  12183. numArgs: 0,
  12184. variableArgs: false
  12185. };
  12186. t.ET = {
  12187. id: _util.OPS.endText,
  12188. numArgs: 0,
  12189. variableArgs: false
  12190. };
  12191. t.Tc = {
  12192. id: _util.OPS.setCharSpacing,
  12193. numArgs: 1,
  12194. variableArgs: false
  12195. };
  12196. t.Tw = {
  12197. id: _util.OPS.setWordSpacing,
  12198. numArgs: 1,
  12199. variableArgs: false
  12200. };
  12201. t.Tz = {
  12202. id: _util.OPS.setHScale,
  12203. numArgs: 1,
  12204. variableArgs: false
  12205. };
  12206. t.TL = {
  12207. id: _util.OPS.setLeading,
  12208. numArgs: 1,
  12209. variableArgs: false
  12210. };
  12211. t.Tf = {
  12212. id: _util.OPS.setFont,
  12213. numArgs: 2,
  12214. variableArgs: false
  12215. };
  12216. t.Tr = {
  12217. id: _util.OPS.setTextRenderingMode,
  12218. numArgs: 1,
  12219. variableArgs: false
  12220. };
  12221. t.Ts = {
  12222. id: _util.OPS.setTextRise,
  12223. numArgs: 1,
  12224. variableArgs: false
  12225. };
  12226. t.Td = {
  12227. id: _util.OPS.moveText,
  12228. numArgs: 2,
  12229. variableArgs: false
  12230. };
  12231. t.TD = {
  12232. id: _util.OPS.setLeadingMoveText,
  12233. numArgs: 2,
  12234. variableArgs: false
  12235. };
  12236. t.Tm = {
  12237. id: _util.OPS.setTextMatrix,
  12238. numArgs: 6,
  12239. variableArgs: false
  12240. };
  12241. t["T*"] = {
  12242. id: _util.OPS.nextLine,
  12243. numArgs: 0,
  12244. variableArgs: false
  12245. };
  12246. t.Tj = {
  12247. id: _util.OPS.showText,
  12248. numArgs: 1,
  12249. variableArgs: false
  12250. };
  12251. t.TJ = {
  12252. id: _util.OPS.showSpacedText,
  12253. numArgs: 1,
  12254. variableArgs: false
  12255. };
  12256. t["'"] = {
  12257. id: _util.OPS.nextLineShowText,
  12258. numArgs: 1,
  12259. variableArgs: false
  12260. };
  12261. t['"'] = {
  12262. id: _util.OPS.nextLineSetSpacingShowText,
  12263. numArgs: 3,
  12264. variableArgs: false
  12265. };
  12266. t.d0 = {
  12267. id: _util.OPS.setCharWidth,
  12268. numArgs: 2,
  12269. variableArgs: false
  12270. };
  12271. t.d1 = {
  12272. id: _util.OPS.setCharWidthAndBounds,
  12273. numArgs: 6,
  12274. variableArgs: false
  12275. };
  12276. t.CS = {
  12277. id: _util.OPS.setStrokeColorSpace,
  12278. numArgs: 1,
  12279. variableArgs: false
  12280. };
  12281. t.cs = {
  12282. id: _util.OPS.setFillColorSpace,
  12283. numArgs: 1,
  12284. variableArgs: false
  12285. };
  12286. t.SC = {
  12287. id: _util.OPS.setStrokeColor,
  12288. numArgs: 4,
  12289. variableArgs: true
  12290. };
  12291. t.SCN = {
  12292. id: _util.OPS.setStrokeColorN,
  12293. numArgs: 33,
  12294. variableArgs: true
  12295. };
  12296. t.sc = {
  12297. id: _util.OPS.setFillColor,
  12298. numArgs: 4,
  12299. variableArgs: true
  12300. };
  12301. t.scn = {
  12302. id: _util.OPS.setFillColorN,
  12303. numArgs: 33,
  12304. variableArgs: true
  12305. };
  12306. t.G = {
  12307. id: _util.OPS.setStrokeGray,
  12308. numArgs: 1,
  12309. variableArgs: false
  12310. };
  12311. t.g = {
  12312. id: _util.OPS.setFillGray,
  12313. numArgs: 1,
  12314. variableArgs: false
  12315. };
  12316. t.RG = {
  12317. id: _util.OPS.setStrokeRGBColor,
  12318. numArgs: 3,
  12319. variableArgs: false
  12320. };
  12321. t.rg = {
  12322. id: _util.OPS.setFillRGBColor,
  12323. numArgs: 3,
  12324. variableArgs: false
  12325. };
  12326. t.K = {
  12327. id: _util.OPS.setStrokeCMYKColor,
  12328. numArgs: 4,
  12329. variableArgs: false
  12330. };
  12331. t.k = {
  12332. id: _util.OPS.setFillCMYKColor,
  12333. numArgs: 4,
  12334. variableArgs: false
  12335. };
  12336. t.sh = {
  12337. id: _util.OPS.shadingFill,
  12338. numArgs: 1,
  12339. variableArgs: false
  12340. };
  12341. t.BI = {
  12342. id: _util.OPS.beginInlineImage,
  12343. numArgs: 0,
  12344. variableArgs: false
  12345. };
  12346. t.ID = {
  12347. id: _util.OPS.beginImageData,
  12348. numArgs: 0,
  12349. variableArgs: false
  12350. };
  12351. t.EI = {
  12352. id: _util.OPS.endInlineImage,
  12353. numArgs: 1,
  12354. variableArgs: false
  12355. };
  12356. t.Do = {
  12357. id: _util.OPS.paintXObject,
  12358. numArgs: 1,
  12359. variableArgs: false
  12360. };
  12361. t.MP = {
  12362. id: _util.OPS.markPoint,
  12363. numArgs: 1,
  12364. variableArgs: false
  12365. };
  12366. t.DP = {
  12367. id: _util.OPS.markPointProps,
  12368. numArgs: 2,
  12369. variableArgs: false
  12370. };
  12371. t.BMC = {
  12372. id: _util.OPS.beginMarkedContent,
  12373. numArgs: 1,
  12374. variableArgs: false
  12375. };
  12376. t.BDC = {
  12377. id: _util.OPS.beginMarkedContentProps,
  12378. numArgs: 2,
  12379. variableArgs: false
  12380. };
  12381. t.EMC = {
  12382. id: _util.OPS.endMarkedContent,
  12383. numArgs: 0,
  12384. variableArgs: false
  12385. };
  12386. t.BX = {
  12387. id: _util.OPS.beginCompat,
  12388. numArgs: 0,
  12389. variableArgs: false
  12390. };
  12391. t.EX = {
  12392. id: _util.OPS.endCompat,
  12393. numArgs: 0,
  12394. variableArgs: false
  12395. };
  12396. t.BM = null;
  12397. t.BD = null;
  12398. t.true = null;
  12399. t.fa = null;
  12400. t.fal = null;
  12401. t.fals = null;
  12402. t.false = null;
  12403. t.nu = null;
  12404. t.nul = null;
  12405. t.null = null;
  12406. });
  12407. return (0, _util.shadow)(this, "opMap", getOPMap());
  12408. }
  12409. static MAX_INVALID_PATH_OPS = 10;
  12410. constructor(stream, xref, stateManager = new StateManager()) {
  12411. this.parser = new _parser.Parser({
  12412. lexer: new _parser.Lexer(stream, EvaluatorPreprocessor.opMap),
  12413. xref
  12414. });
  12415. this.stateManager = stateManager;
  12416. this.nonProcessedArgs = [];
  12417. this._isPathOp = false;
  12418. this._numInvalidPathOPS = 0;
  12419. }
  12420. get savedStatesDepth() {
  12421. return this.stateManager.stateStack.length;
  12422. }
  12423. read(operation) {
  12424. let args = operation.args;
  12425. while (true) {
  12426. const obj = this.parser.getObj();
  12427. if (obj instanceof _primitives.Cmd) {
  12428. const cmd = obj.cmd;
  12429. const opSpec = EvaluatorPreprocessor.opMap[cmd];
  12430. if (!opSpec) {
  12431. (0, _util.warn)(`Unknown command "${cmd}".`);
  12432. continue;
  12433. }
  12434. const fn = opSpec.id;
  12435. const numArgs = opSpec.numArgs;
  12436. let argsLength = args !== null ? args.length : 0;
  12437. if (!this._isPathOp) {
  12438. this._numInvalidPathOPS = 0;
  12439. }
  12440. this._isPathOp = fn >= _util.OPS.moveTo && fn <= _util.OPS.endPath;
  12441. if (!opSpec.variableArgs) {
  12442. if (argsLength !== numArgs) {
  12443. const nonProcessedArgs = this.nonProcessedArgs;
  12444. while (argsLength > numArgs) {
  12445. nonProcessedArgs.push(args.shift());
  12446. argsLength--;
  12447. }
  12448. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  12449. if (args === null) {
  12450. args = [];
  12451. }
  12452. args.unshift(nonProcessedArgs.pop());
  12453. argsLength++;
  12454. }
  12455. }
  12456. if (argsLength < numArgs) {
  12457. const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
  12458. if (this._isPathOp && ++this._numInvalidPathOPS > EvaluatorPreprocessor.MAX_INVALID_PATH_OPS) {
  12459. throw new _util.FormatError(`Invalid ${partialMsg}`);
  12460. }
  12461. (0, _util.warn)(`Skipping ${partialMsg}`);
  12462. if (args !== null) {
  12463. args.length = 0;
  12464. }
  12465. continue;
  12466. }
  12467. } else if (argsLength > numArgs) {
  12468. (0, _util.info)(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
  12469. }
  12470. this.preprocessCommand(fn, args);
  12471. operation.fn = fn;
  12472. operation.args = args;
  12473. return true;
  12474. }
  12475. if (obj === _primitives.EOF) {
  12476. return false;
  12477. }
  12478. if (obj !== null) {
  12479. if (args === null) {
  12480. args = [];
  12481. }
  12482. args.push(obj);
  12483. if (args.length > 33) {
  12484. throw new _util.FormatError("Too many arguments");
  12485. }
  12486. }
  12487. }
  12488. }
  12489. preprocessCommand(fn, args) {
  12490. switch (fn | 0) {
  12491. case _util.OPS.save:
  12492. this.stateManager.save();
  12493. break;
  12494. case _util.OPS.restore:
  12495. this.stateManager.restore();
  12496. break;
  12497. case _util.OPS.transform:
  12498. this.stateManager.transform(args);
  12499. break;
  12500. }
  12501. }
  12502. }
  12503. exports.EvaluatorPreprocessor = EvaluatorPreprocessor;
  12504. /***/ }),
  12505. /* 14 */
  12506. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12507. Object.defineProperty(exports, "__esModule", ({
  12508. value: true
  12509. }));
  12510. exports.IdentityCMap = exports.CMapFactory = exports.CMap = void 0;
  12511. var _util = __w_pdfjs_require__(2);
  12512. var _primitives = __w_pdfjs_require__(4);
  12513. var _base_stream = __w_pdfjs_require__(5);
  12514. var _binary_cmap = __w_pdfjs_require__(15);
  12515. var _parser = __w_pdfjs_require__(16);
  12516. var _core_utils = __w_pdfjs_require__(3);
  12517. var _stream = __w_pdfjs_require__(8);
  12518. const BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
  12519. const MAX_MAP_RANGE = 2 ** 24 - 1;
  12520. class CMap {
  12521. constructor(builtInCMap = false) {
  12522. this.codespaceRanges = [[], [], [], []];
  12523. this.numCodespaceRanges = 0;
  12524. this._map = [];
  12525. this.name = "";
  12526. this.vertical = false;
  12527. this.useCMap = null;
  12528. this.builtInCMap = builtInCMap;
  12529. }
  12530. addCodespaceRange(n, low, high) {
  12531. this.codespaceRanges[n - 1].push(low, high);
  12532. this.numCodespaceRanges++;
  12533. }
  12534. mapCidRange(low, high, dstLow) {
  12535. if (high - low > MAX_MAP_RANGE) {
  12536. throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
  12537. }
  12538. while (low <= high) {
  12539. this._map[low++] = dstLow++;
  12540. }
  12541. }
  12542. mapBfRange(low, high, dstLow) {
  12543. if (high - low > MAX_MAP_RANGE) {
  12544. throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
  12545. }
  12546. const lastByte = dstLow.length - 1;
  12547. while (low <= high) {
  12548. this._map[low++] = dstLow;
  12549. const nextCharCode = dstLow.charCodeAt(lastByte) + 1;
  12550. if (nextCharCode > 0xff) {
  12551. dstLow = dstLow.substring(0, lastByte - 1) + String.fromCharCode(dstLow.charCodeAt(lastByte - 1) + 1) + "\x00";
  12552. continue;
  12553. }
  12554. dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
  12555. }
  12556. }
  12557. mapBfRangeToArray(low, high, array) {
  12558. if (high - low > MAX_MAP_RANGE) {
  12559. throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
  12560. }
  12561. const ii = array.length;
  12562. let i = 0;
  12563. while (low <= high && i < ii) {
  12564. this._map[low] = array[i++];
  12565. ++low;
  12566. }
  12567. }
  12568. mapOne(src, dst) {
  12569. this._map[src] = dst;
  12570. }
  12571. lookup(code) {
  12572. return this._map[code];
  12573. }
  12574. contains(code) {
  12575. return this._map[code] !== undefined;
  12576. }
  12577. forEach(callback) {
  12578. const map = this._map;
  12579. const length = map.length;
  12580. if (length <= 0x10000) {
  12581. for (let i = 0; i < length; i++) {
  12582. if (map[i] !== undefined) {
  12583. callback(i, map[i]);
  12584. }
  12585. }
  12586. } else {
  12587. for (const i in map) {
  12588. callback(i, map[i]);
  12589. }
  12590. }
  12591. }
  12592. charCodeOf(value) {
  12593. const map = this._map;
  12594. if (map.length <= 0x10000) {
  12595. return map.indexOf(value);
  12596. }
  12597. for (const charCode in map) {
  12598. if (map[charCode] === value) {
  12599. return charCode | 0;
  12600. }
  12601. }
  12602. return -1;
  12603. }
  12604. getMap() {
  12605. return this._map;
  12606. }
  12607. readCharCode(str, offset, out) {
  12608. let c = 0;
  12609. const codespaceRanges = this.codespaceRanges;
  12610. for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
  12611. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  12612. const codespaceRange = codespaceRanges[n];
  12613. for (let k = 0, kk = codespaceRange.length; k < kk;) {
  12614. const low = codespaceRange[k++];
  12615. const high = codespaceRange[k++];
  12616. if (c >= low && c <= high) {
  12617. out.charcode = c;
  12618. out.length = n + 1;
  12619. return;
  12620. }
  12621. }
  12622. }
  12623. out.charcode = 0;
  12624. out.length = 1;
  12625. }
  12626. getCharCodeLength(charCode) {
  12627. const codespaceRanges = this.codespaceRanges;
  12628. for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
  12629. const codespaceRange = codespaceRanges[n];
  12630. for (let k = 0, kk = codespaceRange.length; k < kk;) {
  12631. const low = codespaceRange[k++];
  12632. const high = codespaceRange[k++];
  12633. if (charCode >= low && charCode <= high) {
  12634. return n + 1;
  12635. }
  12636. }
  12637. }
  12638. return 1;
  12639. }
  12640. get length() {
  12641. return this._map.length;
  12642. }
  12643. get isIdentityCMap() {
  12644. if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
  12645. return false;
  12646. }
  12647. if (this._map.length !== 0x10000) {
  12648. return false;
  12649. }
  12650. for (let i = 0; i < 0x10000; i++) {
  12651. if (this._map[i] !== i) {
  12652. return false;
  12653. }
  12654. }
  12655. return true;
  12656. }
  12657. }
  12658. exports.CMap = CMap;
  12659. class IdentityCMap extends CMap {
  12660. constructor(vertical, n) {
  12661. super();
  12662. this.vertical = vertical;
  12663. this.addCodespaceRange(n, 0, 0xffff);
  12664. }
  12665. mapCidRange(low, high, dstLow) {
  12666. (0, _util.unreachable)("should not call mapCidRange");
  12667. }
  12668. mapBfRange(low, high, dstLow) {
  12669. (0, _util.unreachable)("should not call mapBfRange");
  12670. }
  12671. mapBfRangeToArray(low, high, array) {
  12672. (0, _util.unreachable)("should not call mapBfRangeToArray");
  12673. }
  12674. mapOne(src, dst) {
  12675. (0, _util.unreachable)("should not call mapCidOne");
  12676. }
  12677. lookup(code) {
  12678. return Number.isInteger(code) && code <= 0xffff ? code : undefined;
  12679. }
  12680. contains(code) {
  12681. return Number.isInteger(code) && code <= 0xffff;
  12682. }
  12683. forEach(callback) {
  12684. for (let i = 0; i <= 0xffff; i++) {
  12685. callback(i, i);
  12686. }
  12687. }
  12688. charCodeOf(value) {
  12689. return Number.isInteger(value) && value <= 0xffff ? value : -1;
  12690. }
  12691. getMap() {
  12692. const map = new Array(0x10000);
  12693. for (let i = 0; i <= 0xffff; i++) {
  12694. map[i] = i;
  12695. }
  12696. return map;
  12697. }
  12698. get length() {
  12699. return 0x10000;
  12700. }
  12701. get isIdentityCMap() {
  12702. (0, _util.unreachable)("should not access .isIdentityCMap");
  12703. }
  12704. }
  12705. exports.IdentityCMap = IdentityCMap;
  12706. function strToInt(str) {
  12707. let a = 0;
  12708. for (let i = 0; i < str.length; i++) {
  12709. a = a << 8 | str.charCodeAt(i);
  12710. }
  12711. return a >>> 0;
  12712. }
  12713. function expectString(obj) {
  12714. if (typeof obj !== "string") {
  12715. throw new _util.FormatError("Malformed CMap: expected string.");
  12716. }
  12717. }
  12718. function expectInt(obj) {
  12719. if (!Number.isInteger(obj)) {
  12720. throw new _util.FormatError("Malformed CMap: expected int.");
  12721. }
  12722. }
  12723. function parseBfChar(cMap, lexer) {
  12724. while (true) {
  12725. let obj = lexer.getObj();
  12726. if (obj === _primitives.EOF) {
  12727. break;
  12728. }
  12729. if ((0, _primitives.isCmd)(obj, "endbfchar")) {
  12730. return;
  12731. }
  12732. expectString(obj);
  12733. const src = strToInt(obj);
  12734. obj = lexer.getObj();
  12735. expectString(obj);
  12736. const dst = obj;
  12737. cMap.mapOne(src, dst);
  12738. }
  12739. }
  12740. function parseBfRange(cMap, lexer) {
  12741. while (true) {
  12742. let obj = lexer.getObj();
  12743. if (obj === _primitives.EOF) {
  12744. break;
  12745. }
  12746. if ((0, _primitives.isCmd)(obj, "endbfrange")) {
  12747. return;
  12748. }
  12749. expectString(obj);
  12750. const low = strToInt(obj);
  12751. obj = lexer.getObj();
  12752. expectString(obj);
  12753. const high = strToInt(obj);
  12754. obj = lexer.getObj();
  12755. if (Number.isInteger(obj) || typeof obj === "string") {
  12756. const dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
  12757. cMap.mapBfRange(low, high, dstLow);
  12758. } else if ((0, _primitives.isCmd)(obj, "[")) {
  12759. obj = lexer.getObj();
  12760. const array = [];
  12761. while (!(0, _primitives.isCmd)(obj, "]") && obj !== _primitives.EOF) {
  12762. array.push(obj);
  12763. obj = lexer.getObj();
  12764. }
  12765. cMap.mapBfRangeToArray(low, high, array);
  12766. } else {
  12767. break;
  12768. }
  12769. }
  12770. throw new _util.FormatError("Invalid bf range.");
  12771. }
  12772. function parseCidChar(cMap, lexer) {
  12773. while (true) {
  12774. let obj = lexer.getObj();
  12775. if (obj === _primitives.EOF) {
  12776. break;
  12777. }
  12778. if ((0, _primitives.isCmd)(obj, "endcidchar")) {
  12779. return;
  12780. }
  12781. expectString(obj);
  12782. const src = strToInt(obj);
  12783. obj = lexer.getObj();
  12784. expectInt(obj);
  12785. const dst = obj;
  12786. cMap.mapOne(src, dst);
  12787. }
  12788. }
  12789. function parseCidRange(cMap, lexer) {
  12790. while (true) {
  12791. let obj = lexer.getObj();
  12792. if (obj === _primitives.EOF) {
  12793. break;
  12794. }
  12795. if ((0, _primitives.isCmd)(obj, "endcidrange")) {
  12796. return;
  12797. }
  12798. expectString(obj);
  12799. const low = strToInt(obj);
  12800. obj = lexer.getObj();
  12801. expectString(obj);
  12802. const high = strToInt(obj);
  12803. obj = lexer.getObj();
  12804. expectInt(obj);
  12805. const dstLow = obj;
  12806. cMap.mapCidRange(low, high, dstLow);
  12807. }
  12808. }
  12809. function parseCodespaceRange(cMap, lexer) {
  12810. while (true) {
  12811. let obj = lexer.getObj();
  12812. if (obj === _primitives.EOF) {
  12813. break;
  12814. }
  12815. if ((0, _primitives.isCmd)(obj, "endcodespacerange")) {
  12816. return;
  12817. }
  12818. if (typeof obj !== "string") {
  12819. break;
  12820. }
  12821. const low = strToInt(obj);
  12822. obj = lexer.getObj();
  12823. if (typeof obj !== "string") {
  12824. break;
  12825. }
  12826. const high = strToInt(obj);
  12827. cMap.addCodespaceRange(obj.length, low, high);
  12828. }
  12829. throw new _util.FormatError("Invalid codespace range.");
  12830. }
  12831. function parseWMode(cMap, lexer) {
  12832. const obj = lexer.getObj();
  12833. if (Number.isInteger(obj)) {
  12834. cMap.vertical = !!obj;
  12835. }
  12836. }
  12837. function parseCMapName(cMap, lexer) {
  12838. const obj = lexer.getObj();
  12839. if (obj instanceof _primitives.Name) {
  12840. cMap.name = obj.name;
  12841. }
  12842. }
  12843. async function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  12844. let previous, embeddedUseCMap;
  12845. objLoop: while (true) {
  12846. try {
  12847. const obj = lexer.getObj();
  12848. if (obj === _primitives.EOF) {
  12849. break;
  12850. } else if (obj instanceof _primitives.Name) {
  12851. if (obj.name === "WMode") {
  12852. parseWMode(cMap, lexer);
  12853. } else if (obj.name === "CMapName") {
  12854. parseCMapName(cMap, lexer);
  12855. }
  12856. previous = obj;
  12857. } else if (obj instanceof _primitives.Cmd) {
  12858. switch (obj.cmd) {
  12859. case "endcmap":
  12860. break objLoop;
  12861. case "usecmap":
  12862. if (previous instanceof _primitives.Name) {
  12863. embeddedUseCMap = previous.name;
  12864. }
  12865. break;
  12866. case "begincodespacerange":
  12867. parseCodespaceRange(cMap, lexer);
  12868. break;
  12869. case "beginbfchar":
  12870. parseBfChar(cMap, lexer);
  12871. break;
  12872. case "begincidchar":
  12873. parseCidChar(cMap, lexer);
  12874. break;
  12875. case "beginbfrange":
  12876. parseBfRange(cMap, lexer);
  12877. break;
  12878. case "begincidrange":
  12879. parseCidRange(cMap, lexer);
  12880. break;
  12881. }
  12882. }
  12883. } catch (ex) {
  12884. if (ex instanceof _core_utils.MissingDataException) {
  12885. throw ex;
  12886. }
  12887. (0, _util.warn)("Invalid cMap data: " + ex);
  12888. continue;
  12889. }
  12890. }
  12891. if (!useCMap && embeddedUseCMap) {
  12892. useCMap = embeddedUseCMap;
  12893. }
  12894. if (useCMap) {
  12895. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  12896. }
  12897. return cMap;
  12898. }
  12899. async function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  12900. cMap.useCMap = await createBuiltInCMap(useCMap, fetchBuiltInCMap);
  12901. if (cMap.numCodespaceRanges === 0) {
  12902. const useCodespaceRanges = cMap.useCMap.codespaceRanges;
  12903. for (let i = 0; i < useCodespaceRanges.length; i++) {
  12904. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  12905. }
  12906. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  12907. }
  12908. cMap.useCMap.forEach(function (key, value) {
  12909. if (!cMap.contains(key)) {
  12910. cMap.mapOne(key, cMap.useCMap.lookup(key));
  12911. }
  12912. });
  12913. return cMap;
  12914. }
  12915. async function createBuiltInCMap(name, fetchBuiltInCMap) {
  12916. if (name === "Identity-H") {
  12917. return new IdentityCMap(false, 2);
  12918. } else if (name === "Identity-V") {
  12919. return new IdentityCMap(true, 2);
  12920. }
  12921. if (!BUILT_IN_CMAPS.includes(name)) {
  12922. throw new Error("Unknown CMap name: " + name);
  12923. }
  12924. if (!fetchBuiltInCMap) {
  12925. throw new Error("Built-in CMap parameters are not provided.");
  12926. }
  12927. const {
  12928. cMapData,
  12929. compressionType
  12930. } = await fetchBuiltInCMap(name);
  12931. const cMap = new CMap(true);
  12932. if (compressionType === _util.CMapCompressionType.BINARY) {
  12933. return new _binary_cmap.BinaryCMapReader().process(cMapData, cMap, useCMap => {
  12934. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  12935. });
  12936. }
  12937. if (compressionType === _util.CMapCompressionType.NONE) {
  12938. const lexer = new _parser.Lexer(new _stream.Stream(cMapData));
  12939. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  12940. }
  12941. throw new Error(`Invalid CMap "compressionType" value: ${compressionType}`);
  12942. }
  12943. class CMapFactory {
  12944. static async create({
  12945. encoding,
  12946. fetchBuiltInCMap,
  12947. useCMap
  12948. }) {
  12949. if (encoding instanceof _primitives.Name) {
  12950. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  12951. } else if (encoding instanceof _base_stream.BaseStream) {
  12952. const parsedCMap = await parseCMap(new CMap(), new _parser.Lexer(encoding), fetchBuiltInCMap, useCMap);
  12953. if (parsedCMap.isIdentityCMap) {
  12954. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  12955. }
  12956. return parsedCMap;
  12957. }
  12958. throw new Error("Encoding required.");
  12959. }
  12960. }
  12961. exports.CMapFactory = CMapFactory;
  12962. /***/ }),
  12963. /* 15 */
  12964. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12965. Object.defineProperty(exports, "__esModule", ({
  12966. value: true
  12967. }));
  12968. exports.BinaryCMapReader = void 0;
  12969. var _util = __w_pdfjs_require__(2);
  12970. function hexToInt(a, size) {
  12971. let n = 0;
  12972. for (let i = 0; i <= size; i++) {
  12973. n = n << 8 | a[i];
  12974. }
  12975. return n >>> 0;
  12976. }
  12977. function hexToStr(a, size) {
  12978. if (size === 1) {
  12979. return String.fromCharCode(a[0], a[1]);
  12980. }
  12981. if (size === 3) {
  12982. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  12983. }
  12984. return String.fromCharCode(...a.subarray(0, size + 1));
  12985. }
  12986. function addHex(a, b, size) {
  12987. let c = 0;
  12988. for (let i = size; i >= 0; i--) {
  12989. c += a[i] + b[i];
  12990. a[i] = c & 255;
  12991. c >>= 8;
  12992. }
  12993. }
  12994. function incHex(a, size) {
  12995. let c = 1;
  12996. for (let i = size; i >= 0 && c > 0; i--) {
  12997. c += a[i];
  12998. a[i] = c & 255;
  12999. c >>= 8;
  13000. }
  13001. }
  13002. const MAX_NUM_SIZE = 16;
  13003. const MAX_ENCODED_NUM_SIZE = 19;
  13004. class BinaryCMapStream {
  13005. constructor(data) {
  13006. this.buffer = data;
  13007. this.pos = 0;
  13008. this.end = data.length;
  13009. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  13010. }
  13011. readByte() {
  13012. if (this.pos >= this.end) {
  13013. return -1;
  13014. }
  13015. return this.buffer[this.pos++];
  13016. }
  13017. readNumber() {
  13018. let n = 0;
  13019. let last;
  13020. do {
  13021. const b = this.readByte();
  13022. if (b < 0) {
  13023. throw new _util.FormatError("unexpected EOF in bcmap");
  13024. }
  13025. last = !(b & 0x80);
  13026. n = n << 7 | b & 0x7f;
  13027. } while (!last);
  13028. return n;
  13029. }
  13030. readSigned() {
  13031. const n = this.readNumber();
  13032. return n & 1 ? ~(n >>> 1) : n >>> 1;
  13033. }
  13034. readHex(num, size) {
  13035. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  13036. this.pos += size + 1;
  13037. }
  13038. readHexNumber(num, size) {
  13039. let last;
  13040. const stack = this.tmpBuf;
  13041. let sp = 0;
  13042. do {
  13043. const b = this.readByte();
  13044. if (b < 0) {
  13045. throw new _util.FormatError("unexpected EOF in bcmap");
  13046. }
  13047. last = !(b & 0x80);
  13048. stack[sp++] = b & 0x7f;
  13049. } while (!last);
  13050. let i = size,
  13051. buffer = 0,
  13052. bufferSize = 0;
  13053. while (i >= 0) {
  13054. while (bufferSize < 8 && stack.length > 0) {
  13055. buffer |= stack[--sp] << bufferSize;
  13056. bufferSize += 7;
  13057. }
  13058. num[i] = buffer & 255;
  13059. i--;
  13060. buffer >>= 8;
  13061. bufferSize -= 8;
  13062. }
  13063. }
  13064. readHexSigned(num, size) {
  13065. this.readHexNumber(num, size);
  13066. const sign = num[size] & 1 ? 255 : 0;
  13067. let c = 0;
  13068. for (let i = 0; i <= size; i++) {
  13069. c = (c & 1) << 8 | num[i];
  13070. num[i] = c >> 1 ^ sign;
  13071. }
  13072. }
  13073. readString() {
  13074. const len = this.readNumber(),
  13075. buf = new Array(len);
  13076. for (let i = 0; i < len; i++) {
  13077. buf[i] = this.readNumber();
  13078. }
  13079. return String.fromCharCode(...buf);
  13080. }
  13081. }
  13082. class BinaryCMapReader {
  13083. async process(data, cMap, extend) {
  13084. const stream = new BinaryCMapStream(data);
  13085. const header = stream.readByte();
  13086. cMap.vertical = !!(header & 1);
  13087. let useCMap = null;
  13088. const start = new Uint8Array(MAX_NUM_SIZE);
  13089. const end = new Uint8Array(MAX_NUM_SIZE);
  13090. const char = new Uint8Array(MAX_NUM_SIZE);
  13091. const charCode = new Uint8Array(MAX_NUM_SIZE);
  13092. const tmp = new Uint8Array(MAX_NUM_SIZE);
  13093. let code;
  13094. let b;
  13095. while ((b = stream.readByte()) >= 0) {
  13096. const type = b >> 5;
  13097. if (type === 7) {
  13098. switch (b & 0x1f) {
  13099. case 0:
  13100. stream.readString();
  13101. break;
  13102. case 1:
  13103. useCMap = stream.readString();
  13104. break;
  13105. }
  13106. continue;
  13107. }
  13108. const sequence = !!(b & 0x10);
  13109. const dataSize = b & 15;
  13110. if (dataSize + 1 > MAX_NUM_SIZE) {
  13111. throw new Error("BinaryCMapReader.process: Invalid dataSize.");
  13112. }
  13113. const ucs2DataSize = 1;
  13114. const subitemsCount = stream.readNumber();
  13115. switch (type) {
  13116. case 0:
  13117. stream.readHex(start, dataSize);
  13118. stream.readHexNumber(end, dataSize);
  13119. addHex(end, start, dataSize);
  13120. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  13121. for (let i = 1; i < subitemsCount; i++) {
  13122. incHex(end, dataSize);
  13123. stream.readHexNumber(start, dataSize);
  13124. addHex(start, end, dataSize);
  13125. stream.readHexNumber(end, dataSize);
  13126. addHex(end, start, dataSize);
  13127. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  13128. }
  13129. break;
  13130. case 1:
  13131. stream.readHex(start, dataSize);
  13132. stream.readHexNumber(end, dataSize);
  13133. addHex(end, start, dataSize);
  13134. stream.readNumber();
  13135. for (let i = 1; i < subitemsCount; i++) {
  13136. incHex(end, dataSize);
  13137. stream.readHexNumber(start, dataSize);
  13138. addHex(start, end, dataSize);
  13139. stream.readHexNumber(end, dataSize);
  13140. addHex(end, start, dataSize);
  13141. stream.readNumber();
  13142. }
  13143. break;
  13144. case 2:
  13145. stream.readHex(char, dataSize);
  13146. code = stream.readNumber();
  13147. cMap.mapOne(hexToInt(char, dataSize), code);
  13148. for (let i = 1; i < subitemsCount; i++) {
  13149. incHex(char, dataSize);
  13150. if (!sequence) {
  13151. stream.readHexNumber(tmp, dataSize);
  13152. addHex(char, tmp, dataSize);
  13153. }
  13154. code = stream.readSigned() + (code + 1);
  13155. cMap.mapOne(hexToInt(char, dataSize), code);
  13156. }
  13157. break;
  13158. case 3:
  13159. stream.readHex(start, dataSize);
  13160. stream.readHexNumber(end, dataSize);
  13161. addHex(end, start, dataSize);
  13162. code = stream.readNumber();
  13163. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  13164. for (let i = 1; i < subitemsCount; i++) {
  13165. incHex(end, dataSize);
  13166. if (!sequence) {
  13167. stream.readHexNumber(start, dataSize);
  13168. addHex(start, end, dataSize);
  13169. } else {
  13170. start.set(end);
  13171. }
  13172. stream.readHexNumber(end, dataSize);
  13173. addHex(end, start, dataSize);
  13174. code = stream.readNumber();
  13175. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  13176. }
  13177. break;
  13178. case 4:
  13179. stream.readHex(char, ucs2DataSize);
  13180. stream.readHex(charCode, dataSize);
  13181. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  13182. for (let i = 1; i < subitemsCount; i++) {
  13183. incHex(char, ucs2DataSize);
  13184. if (!sequence) {
  13185. stream.readHexNumber(tmp, ucs2DataSize);
  13186. addHex(char, tmp, ucs2DataSize);
  13187. }
  13188. incHex(charCode, dataSize);
  13189. stream.readHexSigned(tmp, dataSize);
  13190. addHex(charCode, tmp, dataSize);
  13191. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  13192. }
  13193. break;
  13194. case 5:
  13195. stream.readHex(start, ucs2DataSize);
  13196. stream.readHexNumber(end, ucs2DataSize);
  13197. addHex(end, start, ucs2DataSize);
  13198. stream.readHex(charCode, dataSize);
  13199. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  13200. for (let i = 1; i < subitemsCount; i++) {
  13201. incHex(end, ucs2DataSize);
  13202. if (!sequence) {
  13203. stream.readHexNumber(start, ucs2DataSize);
  13204. addHex(start, end, ucs2DataSize);
  13205. } else {
  13206. start.set(end);
  13207. }
  13208. stream.readHexNumber(end, ucs2DataSize);
  13209. addHex(end, start, ucs2DataSize);
  13210. stream.readHex(charCode, dataSize);
  13211. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  13212. }
  13213. break;
  13214. default:
  13215. throw new Error(`BinaryCMapReader.process - unknown type: ${type}`);
  13216. }
  13217. }
  13218. if (useCMap) {
  13219. return extend(useCMap);
  13220. }
  13221. return cMap;
  13222. }
  13223. }
  13224. exports.BinaryCMapReader = BinaryCMapReader;
  13225. /***/ }),
  13226. /* 16 */
  13227. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13228. Object.defineProperty(exports, "__esModule", ({
  13229. value: true
  13230. }));
  13231. exports.Parser = exports.Linearization = exports.Lexer = void 0;
  13232. var _util = __w_pdfjs_require__(2);
  13233. var _primitives = __w_pdfjs_require__(4);
  13234. var _core_utils = __w_pdfjs_require__(3);
  13235. var _stream = __w_pdfjs_require__(8);
  13236. var _ascii_85_stream = __w_pdfjs_require__(17);
  13237. var _ascii_hex_stream = __w_pdfjs_require__(19);
  13238. var _ccitt_stream = __w_pdfjs_require__(20);
  13239. var _flate_stream = __w_pdfjs_require__(22);
  13240. var _jbig2_stream = __w_pdfjs_require__(23);
  13241. var _jpeg_stream = __w_pdfjs_require__(26);
  13242. var _jpx_stream = __w_pdfjs_require__(29);
  13243. var _lzw_stream = __w_pdfjs_require__(31);
  13244. var _predictor_stream = __w_pdfjs_require__(32);
  13245. var _run_length_stream = __w_pdfjs_require__(33);
  13246. const MAX_LENGTH_TO_CACHE = 1000;
  13247. function getInlineImageCacheKey(bytes) {
  13248. const strBuf = [],
  13249. ii = bytes.length;
  13250. let i = 0;
  13251. while (i < ii - 1) {
  13252. strBuf.push(bytes[i++] << 8 | bytes[i++]);
  13253. }
  13254. if (i < ii) {
  13255. strBuf.push(bytes[i]);
  13256. }
  13257. return ii + "_" + String.fromCharCode.apply(null, strBuf);
  13258. }
  13259. class Parser {
  13260. constructor({
  13261. lexer,
  13262. xref,
  13263. allowStreams = false,
  13264. recoveryMode = false
  13265. }) {
  13266. this.lexer = lexer;
  13267. this.xref = xref;
  13268. this.allowStreams = allowStreams;
  13269. this.recoveryMode = recoveryMode;
  13270. this.imageCache = Object.create(null);
  13271. this._imageId = 0;
  13272. this.refill();
  13273. }
  13274. refill() {
  13275. this.buf1 = this.lexer.getObj();
  13276. this.buf2 = this.lexer.getObj();
  13277. }
  13278. shift() {
  13279. if (this.buf2 instanceof _primitives.Cmd && this.buf2.cmd === "ID") {
  13280. this.buf1 = this.buf2;
  13281. this.buf2 = null;
  13282. } else {
  13283. this.buf1 = this.buf2;
  13284. this.buf2 = this.lexer.getObj();
  13285. }
  13286. }
  13287. tryShift() {
  13288. try {
  13289. this.shift();
  13290. return true;
  13291. } catch (e) {
  13292. if (e instanceof _core_utils.MissingDataException) {
  13293. throw e;
  13294. }
  13295. return false;
  13296. }
  13297. }
  13298. getObj(cipherTransform = null) {
  13299. const buf1 = this.buf1;
  13300. this.shift();
  13301. if (buf1 instanceof _primitives.Cmd) {
  13302. switch (buf1.cmd) {
  13303. case "BI":
  13304. return this.makeInlineImage(cipherTransform);
  13305. case "[":
  13306. const array = [];
  13307. while (!(0, _primitives.isCmd)(this.buf1, "]") && this.buf1 !== _primitives.EOF) {
  13308. array.push(this.getObj(cipherTransform));
  13309. }
  13310. if (this.buf1 === _primitives.EOF) {
  13311. if (this.recoveryMode) {
  13312. return array;
  13313. }
  13314. throw new _core_utils.ParserEOFException("End of file inside array.");
  13315. }
  13316. this.shift();
  13317. return array;
  13318. case "<<":
  13319. const dict = new _primitives.Dict(this.xref);
  13320. while (!(0, _primitives.isCmd)(this.buf1, ">>") && this.buf1 !== _primitives.EOF) {
  13321. if (!(this.buf1 instanceof _primitives.Name)) {
  13322. (0, _util.info)("Malformed dictionary: key must be a name object");
  13323. this.shift();
  13324. continue;
  13325. }
  13326. const key = this.buf1.name;
  13327. this.shift();
  13328. if (this.buf1 === _primitives.EOF) {
  13329. break;
  13330. }
  13331. dict.set(key, this.getObj(cipherTransform));
  13332. }
  13333. if (this.buf1 === _primitives.EOF) {
  13334. if (this.recoveryMode) {
  13335. return dict;
  13336. }
  13337. throw new _core_utils.ParserEOFException("End of file inside dictionary.");
  13338. }
  13339. if ((0, _primitives.isCmd)(this.buf2, "stream")) {
  13340. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  13341. }
  13342. this.shift();
  13343. return dict;
  13344. default:
  13345. return buf1;
  13346. }
  13347. }
  13348. if (Number.isInteger(buf1)) {
  13349. if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, "R")) {
  13350. const ref = _primitives.Ref.get(buf1, this.buf1);
  13351. this.shift();
  13352. this.shift();
  13353. return ref;
  13354. }
  13355. return buf1;
  13356. }
  13357. if (typeof buf1 === "string") {
  13358. if (cipherTransform) {
  13359. return cipherTransform.decryptString(buf1);
  13360. }
  13361. return buf1;
  13362. }
  13363. return buf1;
  13364. }
  13365. findDefaultInlineStreamEnd(stream) {
  13366. const E = 0x45,
  13367. I = 0x49,
  13368. SPACE = 0x20,
  13369. LF = 0xa,
  13370. CR = 0xd,
  13371. NUL = 0x0;
  13372. const {
  13373. knownCommands
  13374. } = this.lexer,
  13375. startPos = stream.pos,
  13376. n = 15;
  13377. let state = 0,
  13378. ch,
  13379. maybeEIPos;
  13380. while ((ch = stream.getByte()) !== -1) {
  13381. if (state === 0) {
  13382. state = ch === E ? 1 : 0;
  13383. } else if (state === 1) {
  13384. state = ch === I ? 2 : 0;
  13385. } else {
  13386. if (ch === SPACE || ch === LF || ch === CR) {
  13387. maybeEIPos = stream.pos;
  13388. const followingBytes = stream.peekBytes(n);
  13389. const ii = followingBytes.length;
  13390. if (ii === 0) {
  13391. break;
  13392. }
  13393. for (let i = 0; i < ii; i++) {
  13394. ch = followingBytes[i];
  13395. if (ch === NUL && followingBytes[i + 1] !== NUL) {
  13396. continue;
  13397. }
  13398. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7f)) {
  13399. state = 0;
  13400. break;
  13401. }
  13402. }
  13403. if (state !== 2) {
  13404. continue;
  13405. }
  13406. if (!knownCommands) {
  13407. (0, _util.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");
  13408. continue;
  13409. }
  13410. const tmpLexer = new Lexer(new _stream.Stream(followingBytes.slice()), knownCommands);
  13411. tmpLexer._hexStringWarn = () => {};
  13412. let numArgs = 0;
  13413. while (true) {
  13414. const nextObj = tmpLexer.getObj();
  13415. if (nextObj === _primitives.EOF) {
  13416. state = 0;
  13417. break;
  13418. }
  13419. if (nextObj instanceof _primitives.Cmd) {
  13420. const knownCommand = knownCommands[nextObj.cmd];
  13421. if (!knownCommand) {
  13422. state = 0;
  13423. break;
  13424. } else if (knownCommand.variableArgs ? numArgs <= knownCommand.numArgs : numArgs === knownCommand.numArgs) {
  13425. break;
  13426. }
  13427. numArgs = 0;
  13428. continue;
  13429. }
  13430. numArgs++;
  13431. }
  13432. if (state === 2) {
  13433. break;
  13434. }
  13435. } else {
  13436. state = 0;
  13437. }
  13438. }
  13439. }
  13440. if (ch === -1) {
  13441. (0, _util.warn)("findDefaultInlineStreamEnd: " + "Reached the end of the stream without finding a valid EI marker");
  13442. if (maybeEIPos) {
  13443. (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
  13444. stream.skip(-(stream.pos - maybeEIPos));
  13445. }
  13446. }
  13447. let endOffset = 4;
  13448. stream.skip(-endOffset);
  13449. ch = stream.peekByte();
  13450. stream.skip(endOffset);
  13451. if (!(0, _core_utils.isWhiteSpace)(ch)) {
  13452. endOffset--;
  13453. }
  13454. return stream.pos - endOffset - startPos;
  13455. }
  13456. findDCTDecodeInlineStreamEnd(stream) {
  13457. const startPos = stream.pos;
  13458. let foundEOI = false,
  13459. b,
  13460. markerLength;
  13461. while ((b = stream.getByte()) !== -1) {
  13462. if (b !== 0xff) {
  13463. continue;
  13464. }
  13465. switch (stream.getByte()) {
  13466. case 0x00:
  13467. break;
  13468. case 0xff:
  13469. stream.skip(-1);
  13470. break;
  13471. case 0xd9:
  13472. foundEOI = true;
  13473. break;
  13474. case 0xc0:
  13475. case 0xc1:
  13476. case 0xc2:
  13477. case 0xc3:
  13478. case 0xc5:
  13479. case 0xc6:
  13480. case 0xc7:
  13481. case 0xc9:
  13482. case 0xca:
  13483. case 0xcb:
  13484. case 0xcd:
  13485. case 0xce:
  13486. case 0xcf:
  13487. case 0xc4:
  13488. case 0xcc:
  13489. case 0xda:
  13490. case 0xdb:
  13491. case 0xdc:
  13492. case 0xdd:
  13493. case 0xde:
  13494. case 0xdf:
  13495. case 0xe0:
  13496. case 0xe1:
  13497. case 0xe2:
  13498. case 0xe3:
  13499. case 0xe4:
  13500. case 0xe5:
  13501. case 0xe6:
  13502. case 0xe7:
  13503. case 0xe8:
  13504. case 0xe9:
  13505. case 0xea:
  13506. case 0xeb:
  13507. case 0xec:
  13508. case 0xed:
  13509. case 0xee:
  13510. case 0xef:
  13511. case 0xfe:
  13512. markerLength = stream.getUint16();
  13513. if (markerLength > 2) {
  13514. stream.skip(markerLength - 2);
  13515. } else {
  13516. stream.skip(-2);
  13517. }
  13518. break;
  13519. }
  13520. if (foundEOI) {
  13521. break;
  13522. }
  13523. }
  13524. const length = stream.pos - startPos;
  13525. if (b === -1) {
  13526. (0, _util.warn)("Inline DCTDecode image stream: " + "EOI marker not found, searching for /EI/ instead.");
  13527. stream.skip(-length);
  13528. return this.findDefaultInlineStreamEnd(stream);
  13529. }
  13530. this.inlineStreamSkipEI(stream);
  13531. return length;
  13532. }
  13533. findASCII85DecodeInlineStreamEnd(stream) {
  13534. const TILDE = 0x7e,
  13535. GT = 0x3e;
  13536. const startPos = stream.pos;
  13537. let ch;
  13538. while ((ch = stream.getByte()) !== -1) {
  13539. if (ch === TILDE) {
  13540. const tildePos = stream.pos;
  13541. ch = stream.peekByte();
  13542. while ((0, _core_utils.isWhiteSpace)(ch)) {
  13543. stream.skip();
  13544. ch = stream.peekByte();
  13545. }
  13546. if (ch === GT) {
  13547. stream.skip();
  13548. break;
  13549. }
  13550. if (stream.pos > tildePos) {
  13551. const maybeEI = stream.peekBytes(2);
  13552. if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
  13553. break;
  13554. }
  13555. }
  13556. }
  13557. }
  13558. const length = stream.pos - startPos;
  13559. if (ch === -1) {
  13560. (0, _util.warn)("Inline ASCII85Decode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  13561. stream.skip(-length);
  13562. return this.findDefaultInlineStreamEnd(stream);
  13563. }
  13564. this.inlineStreamSkipEI(stream);
  13565. return length;
  13566. }
  13567. findASCIIHexDecodeInlineStreamEnd(stream) {
  13568. const GT = 0x3e;
  13569. const startPos = stream.pos;
  13570. let ch;
  13571. while ((ch = stream.getByte()) !== -1) {
  13572. if (ch === GT) {
  13573. break;
  13574. }
  13575. }
  13576. const length = stream.pos - startPos;
  13577. if (ch === -1) {
  13578. (0, _util.warn)("Inline ASCIIHexDecode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  13579. stream.skip(-length);
  13580. return this.findDefaultInlineStreamEnd(stream);
  13581. }
  13582. this.inlineStreamSkipEI(stream);
  13583. return length;
  13584. }
  13585. inlineStreamSkipEI(stream) {
  13586. const E = 0x45,
  13587. I = 0x49;
  13588. let state = 0,
  13589. ch;
  13590. while ((ch = stream.getByte()) !== -1) {
  13591. if (state === 0) {
  13592. state = ch === E ? 1 : 0;
  13593. } else if (state === 1) {
  13594. state = ch === I ? 2 : 0;
  13595. } else if (state === 2) {
  13596. break;
  13597. }
  13598. }
  13599. }
  13600. makeInlineImage(cipherTransform) {
  13601. const lexer = this.lexer;
  13602. const stream = lexer.stream;
  13603. const dictMap = Object.create(null);
  13604. let dictLength;
  13605. while (!(0, _primitives.isCmd)(this.buf1, "ID") && this.buf1 !== _primitives.EOF) {
  13606. if (!(this.buf1 instanceof _primitives.Name)) {
  13607. throw new _util.FormatError("Dictionary key must be a name object");
  13608. }
  13609. const key = this.buf1.name;
  13610. this.shift();
  13611. if (this.buf1 === _primitives.EOF) {
  13612. break;
  13613. }
  13614. dictMap[key] = this.getObj(cipherTransform);
  13615. }
  13616. if (lexer.beginInlineImagePos !== -1) {
  13617. dictLength = stream.pos - lexer.beginInlineImagePos;
  13618. }
  13619. const filter = this.xref.fetchIfRef(dictMap.F || dictMap.Filter);
  13620. let filterName;
  13621. if (filter instanceof _primitives.Name) {
  13622. filterName = filter.name;
  13623. } else if (Array.isArray(filter)) {
  13624. const filterZero = this.xref.fetchIfRef(filter[0]);
  13625. if (filterZero instanceof _primitives.Name) {
  13626. filterName = filterZero.name;
  13627. }
  13628. }
  13629. const startPos = stream.pos;
  13630. let length;
  13631. switch (filterName) {
  13632. case "DCT":
  13633. case "DCTDecode":
  13634. length = this.findDCTDecodeInlineStreamEnd(stream);
  13635. break;
  13636. case "A85":
  13637. case "ASCII85Decode":
  13638. length = this.findASCII85DecodeInlineStreamEnd(stream);
  13639. break;
  13640. case "AHx":
  13641. case "ASCIIHexDecode":
  13642. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  13643. break;
  13644. default:
  13645. length = this.findDefaultInlineStreamEnd(stream);
  13646. }
  13647. let cacheKey;
  13648. if (length < MAX_LENGTH_TO_CACHE && dictLength > 0) {
  13649. const initialStreamPos = stream.pos;
  13650. stream.pos = lexer.beginInlineImagePos;
  13651. cacheKey = getInlineImageCacheKey(stream.getBytes(dictLength + length));
  13652. stream.pos = initialStreamPos;
  13653. const cacheEntry = this.imageCache[cacheKey];
  13654. if (cacheEntry !== undefined) {
  13655. this.buf2 = _primitives.Cmd.get("EI");
  13656. this.shift();
  13657. cacheEntry.reset();
  13658. return cacheEntry;
  13659. }
  13660. }
  13661. const dict = new _primitives.Dict(this.xref);
  13662. for (const key in dictMap) {
  13663. dict.set(key, dictMap[key]);
  13664. }
  13665. let imageStream = stream.makeSubStream(startPos, length, dict);
  13666. if (cipherTransform) {
  13667. imageStream = cipherTransform.createStream(imageStream, length);
  13668. }
  13669. imageStream = this.filter(imageStream, dict, length);
  13670. imageStream.dict = dict;
  13671. if (cacheKey !== undefined) {
  13672. imageStream.cacheKey = `inline_img_${++this._imageId}`;
  13673. this.imageCache[cacheKey] = imageStream;
  13674. }
  13675. this.buf2 = _primitives.Cmd.get("EI");
  13676. this.shift();
  13677. return imageStream;
  13678. }
  13679. _findStreamLength(startPos, signature) {
  13680. const {
  13681. stream
  13682. } = this.lexer;
  13683. stream.pos = startPos;
  13684. const SCAN_BLOCK_LENGTH = 2048;
  13685. const signatureLength = signature.length;
  13686. while (stream.pos < stream.end) {
  13687. const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  13688. const scanLength = scanBytes.length - signatureLength;
  13689. if (scanLength <= 0) {
  13690. break;
  13691. }
  13692. let pos = 0;
  13693. while (pos < scanLength) {
  13694. let j = 0;
  13695. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  13696. j++;
  13697. }
  13698. if (j >= signatureLength) {
  13699. stream.pos += pos;
  13700. return stream.pos - startPos;
  13701. }
  13702. pos++;
  13703. }
  13704. stream.pos += scanLength;
  13705. }
  13706. return -1;
  13707. }
  13708. makeStream(dict, cipherTransform) {
  13709. const lexer = this.lexer;
  13710. let stream = lexer.stream;
  13711. lexer.skipToNextLine();
  13712. const startPos = stream.pos - 1;
  13713. let length = dict.get("Length");
  13714. if (!Number.isInteger(length)) {
  13715. (0, _util.info)(`Bad length "${length && length.toString()}" in stream.`);
  13716. length = 0;
  13717. }
  13718. stream.pos = startPos + length;
  13719. lexer.nextChar();
  13720. if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, "endstream")) {
  13721. this.shift();
  13722. } else {
  13723. const ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d]);
  13724. let actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
  13725. if (actualLength < 0) {
  13726. const MAX_TRUNCATION = 1;
  13727. for (let i = 1; i <= MAX_TRUNCATION; i++) {
  13728. const end = ENDSTREAM_SIGNATURE.length - i;
  13729. const TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
  13730. const maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
  13731. if (maybeLength >= 0) {
  13732. const lastByte = stream.peekBytes(end + 1)[end];
  13733. if (!(0, _core_utils.isWhiteSpace)(lastByte)) {
  13734. break;
  13735. }
  13736. (0, _util.info)(`Found "${(0, _util.bytesToString)(TRUNCATED_SIGNATURE)}" when ` + "searching for endstream command.");
  13737. actualLength = maybeLength;
  13738. break;
  13739. }
  13740. }
  13741. if (actualLength < 0) {
  13742. throw new _util.FormatError("Missing endstream command.");
  13743. }
  13744. }
  13745. length = actualLength;
  13746. lexer.nextChar();
  13747. this.shift();
  13748. this.shift();
  13749. }
  13750. this.shift();
  13751. stream = stream.makeSubStream(startPos, length, dict);
  13752. if (cipherTransform) {
  13753. stream = cipherTransform.createStream(stream, length);
  13754. }
  13755. stream = this.filter(stream, dict, length);
  13756. stream.dict = dict;
  13757. return stream;
  13758. }
  13759. filter(stream, dict, length) {
  13760. let filter = dict.get("F", "Filter");
  13761. let params = dict.get("DP", "DecodeParms");
  13762. if (filter instanceof _primitives.Name) {
  13763. if (Array.isArray(params)) {
  13764. (0, _util.warn)("/DecodeParms should not be an Array, when /Filter is a Name.");
  13765. }
  13766. return this.makeFilter(stream, filter.name, length, params);
  13767. }
  13768. let maybeLength = length;
  13769. if (Array.isArray(filter)) {
  13770. const filterArray = filter;
  13771. const paramsArray = params;
  13772. for (let i = 0, ii = filterArray.length; i < ii; ++i) {
  13773. filter = this.xref.fetchIfRef(filterArray[i]);
  13774. if (!(filter instanceof _primitives.Name)) {
  13775. throw new _util.FormatError(`Bad filter name "${filter}"`);
  13776. }
  13777. params = null;
  13778. if (Array.isArray(paramsArray) && i in paramsArray) {
  13779. params = this.xref.fetchIfRef(paramsArray[i]);
  13780. }
  13781. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  13782. maybeLength = null;
  13783. }
  13784. }
  13785. return stream;
  13786. }
  13787. makeFilter(stream, name, maybeLength, params) {
  13788. if (maybeLength === 0) {
  13789. (0, _util.warn)(`Empty "${name}" stream.`);
  13790. return new _stream.NullStream();
  13791. }
  13792. try {
  13793. switch (name) {
  13794. case "Fl":
  13795. case "FlateDecode":
  13796. if (params) {
  13797. return new _predictor_stream.PredictorStream(new _flate_stream.FlateStream(stream, maybeLength), maybeLength, params);
  13798. }
  13799. return new _flate_stream.FlateStream(stream, maybeLength);
  13800. case "LZW":
  13801. case "LZWDecode":
  13802. let earlyChange = 1;
  13803. if (params) {
  13804. if (params.has("EarlyChange")) {
  13805. earlyChange = params.get("EarlyChange");
  13806. }
  13807. return new _predictor_stream.PredictorStream(new _lzw_stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  13808. }
  13809. return new _lzw_stream.LZWStream(stream, maybeLength, earlyChange);
  13810. case "DCT":
  13811. case "DCTDecode":
  13812. return new _jpeg_stream.JpegStream(stream, maybeLength, params);
  13813. case "JPX":
  13814. case "JPXDecode":
  13815. return new _jpx_stream.JpxStream(stream, maybeLength, params);
  13816. case "A85":
  13817. case "ASCII85Decode":
  13818. return new _ascii_85_stream.Ascii85Stream(stream, maybeLength);
  13819. case "AHx":
  13820. case "ASCIIHexDecode":
  13821. return new _ascii_hex_stream.AsciiHexStream(stream, maybeLength);
  13822. case "CCF":
  13823. case "CCITTFaxDecode":
  13824. return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
  13825. case "RL":
  13826. case "RunLengthDecode":
  13827. return new _run_length_stream.RunLengthStream(stream, maybeLength);
  13828. case "JBIG2Decode":
  13829. return new _jbig2_stream.Jbig2Stream(stream, maybeLength, params);
  13830. }
  13831. (0, _util.warn)(`Filter "${name}" is not supported.`);
  13832. return stream;
  13833. } catch (ex) {
  13834. if (ex instanceof _core_utils.MissingDataException) {
  13835. throw ex;
  13836. }
  13837. (0, _util.warn)(`Invalid stream: "${ex}"`);
  13838. return new _stream.NullStream();
  13839. }
  13840. }
  13841. }
  13842. exports.Parser = Parser;
  13843. const specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  13844. function toHexDigit(ch) {
  13845. if (ch >= 0x30 && ch <= 0x39) {
  13846. return ch & 0x0f;
  13847. }
  13848. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  13849. return (ch & 0x0f) + 9;
  13850. }
  13851. return -1;
  13852. }
  13853. class Lexer {
  13854. constructor(stream, knownCommands = null) {
  13855. this.stream = stream;
  13856. this.nextChar();
  13857. this.strBuf = [];
  13858. this.knownCommands = knownCommands;
  13859. this._hexStringNumWarn = 0;
  13860. this.beginInlineImagePos = -1;
  13861. }
  13862. nextChar() {
  13863. return this.currentChar = this.stream.getByte();
  13864. }
  13865. peekChar() {
  13866. return this.stream.peekByte();
  13867. }
  13868. getNumber() {
  13869. let ch = this.currentChar;
  13870. let eNotation = false;
  13871. let divideBy = 0;
  13872. let sign = 1;
  13873. if (ch === 0x2d) {
  13874. sign = -1;
  13875. ch = this.nextChar();
  13876. if (ch === 0x2d) {
  13877. ch = this.nextChar();
  13878. }
  13879. } else if (ch === 0x2b) {
  13880. ch = this.nextChar();
  13881. }
  13882. if (ch === 0x0a || ch === 0x0d) {
  13883. do {
  13884. ch = this.nextChar();
  13885. } while (ch === 0x0a || ch === 0x0d);
  13886. }
  13887. if (ch === 0x2e) {
  13888. divideBy = 10;
  13889. ch = this.nextChar();
  13890. }
  13891. if (ch < 0x30 || ch > 0x39) {
  13892. const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
  13893. if ((0, _core_utils.isWhiteSpace)(ch) || ch === -1) {
  13894. (0, _util.info)(`Lexer.getNumber - "${msg}".`);
  13895. return 0;
  13896. }
  13897. throw new _util.FormatError(msg);
  13898. }
  13899. let baseValue = ch - 0x30;
  13900. let powerValue = 0;
  13901. let powerValueSign = 1;
  13902. while ((ch = this.nextChar()) >= 0) {
  13903. if (ch >= 0x30 && ch <= 0x39) {
  13904. const currentDigit = ch - 0x30;
  13905. if (eNotation) {
  13906. powerValue = powerValue * 10 + currentDigit;
  13907. } else {
  13908. if (divideBy !== 0) {
  13909. divideBy *= 10;
  13910. }
  13911. baseValue = baseValue * 10 + currentDigit;
  13912. }
  13913. } else if (ch === 0x2e) {
  13914. if (divideBy === 0) {
  13915. divideBy = 1;
  13916. } else {
  13917. break;
  13918. }
  13919. } else if (ch === 0x2d) {
  13920. (0, _util.warn)("Badly formatted number: minus sign in the middle");
  13921. } else if (ch === 0x45 || ch === 0x65) {
  13922. ch = this.peekChar();
  13923. if (ch === 0x2b || ch === 0x2d) {
  13924. powerValueSign = ch === 0x2d ? -1 : 1;
  13925. this.nextChar();
  13926. } else if (ch < 0x30 || ch > 0x39) {
  13927. break;
  13928. }
  13929. eNotation = true;
  13930. } else {
  13931. break;
  13932. }
  13933. }
  13934. if (divideBy !== 0) {
  13935. baseValue /= divideBy;
  13936. }
  13937. if (eNotation) {
  13938. baseValue *= 10 ** (powerValueSign * powerValue);
  13939. }
  13940. return sign * baseValue;
  13941. }
  13942. getString() {
  13943. let numParen = 1;
  13944. let done = false;
  13945. const strBuf = this.strBuf;
  13946. strBuf.length = 0;
  13947. let ch = this.nextChar();
  13948. while (true) {
  13949. let charBuffered = false;
  13950. switch (ch | 0) {
  13951. case -1:
  13952. (0, _util.warn)("Unterminated string");
  13953. done = true;
  13954. break;
  13955. case 0x28:
  13956. ++numParen;
  13957. strBuf.push("(");
  13958. break;
  13959. case 0x29:
  13960. if (--numParen === 0) {
  13961. this.nextChar();
  13962. done = true;
  13963. } else {
  13964. strBuf.push(")");
  13965. }
  13966. break;
  13967. case 0x5c:
  13968. ch = this.nextChar();
  13969. switch (ch) {
  13970. case -1:
  13971. (0, _util.warn)("Unterminated string");
  13972. done = true;
  13973. break;
  13974. case 0x6e:
  13975. strBuf.push("\n");
  13976. break;
  13977. case 0x72:
  13978. strBuf.push("\r");
  13979. break;
  13980. case 0x74:
  13981. strBuf.push("\t");
  13982. break;
  13983. case 0x62:
  13984. strBuf.push("\b");
  13985. break;
  13986. case 0x66:
  13987. strBuf.push("\f");
  13988. break;
  13989. case 0x5c:
  13990. case 0x28:
  13991. case 0x29:
  13992. strBuf.push(String.fromCharCode(ch));
  13993. break;
  13994. case 0x30:
  13995. case 0x31:
  13996. case 0x32:
  13997. case 0x33:
  13998. case 0x34:
  13999. case 0x35:
  14000. case 0x36:
  14001. case 0x37:
  14002. let x = ch & 0x0f;
  14003. ch = this.nextChar();
  14004. charBuffered = true;
  14005. if (ch >= 0x30 && ch <= 0x37) {
  14006. x = (x << 3) + (ch & 0x0f);
  14007. ch = this.nextChar();
  14008. if (ch >= 0x30 && ch <= 0x37) {
  14009. charBuffered = false;
  14010. x = (x << 3) + (ch & 0x0f);
  14011. }
  14012. }
  14013. strBuf.push(String.fromCharCode(x));
  14014. break;
  14015. case 0x0d:
  14016. if (this.peekChar() === 0x0a) {
  14017. this.nextChar();
  14018. }
  14019. break;
  14020. case 0x0a:
  14021. break;
  14022. default:
  14023. strBuf.push(String.fromCharCode(ch));
  14024. break;
  14025. }
  14026. break;
  14027. default:
  14028. strBuf.push(String.fromCharCode(ch));
  14029. break;
  14030. }
  14031. if (done) {
  14032. break;
  14033. }
  14034. if (!charBuffered) {
  14035. ch = this.nextChar();
  14036. }
  14037. }
  14038. return strBuf.join("");
  14039. }
  14040. getName() {
  14041. let ch, previousCh;
  14042. const strBuf = this.strBuf;
  14043. strBuf.length = 0;
  14044. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  14045. if (ch === 0x23) {
  14046. ch = this.nextChar();
  14047. if (specialChars[ch]) {
  14048. (0, _util.warn)("Lexer_getName: " + "NUMBER SIGN (#) should be followed by a hexadecimal number.");
  14049. strBuf.push("#");
  14050. break;
  14051. }
  14052. const x = toHexDigit(ch);
  14053. if (x !== -1) {
  14054. previousCh = ch;
  14055. ch = this.nextChar();
  14056. const x2 = toHexDigit(ch);
  14057. if (x2 === -1) {
  14058. (0, _util.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(ch)}) ` + "in hexadecimal number.");
  14059. strBuf.push("#", String.fromCharCode(previousCh));
  14060. if (specialChars[ch]) {
  14061. break;
  14062. }
  14063. strBuf.push(String.fromCharCode(ch));
  14064. continue;
  14065. }
  14066. strBuf.push(String.fromCharCode(x << 4 | x2));
  14067. } else {
  14068. strBuf.push("#", String.fromCharCode(ch));
  14069. }
  14070. } else {
  14071. strBuf.push(String.fromCharCode(ch));
  14072. }
  14073. }
  14074. if (strBuf.length > 127) {
  14075. (0, _util.warn)(`Name token is longer than allowed by the spec: ${strBuf.length}`);
  14076. }
  14077. return _primitives.Name.get(strBuf.join(""));
  14078. }
  14079. _hexStringWarn(ch) {
  14080. const MAX_HEX_STRING_NUM_WARN = 5;
  14081. if (this._hexStringNumWarn++ === MAX_HEX_STRING_NUM_WARN) {
  14082. (0, _util.warn)("getHexString - ignoring additional invalid characters.");
  14083. return;
  14084. }
  14085. if (this._hexStringNumWarn > MAX_HEX_STRING_NUM_WARN) {
  14086. return;
  14087. }
  14088. (0, _util.warn)(`getHexString - ignoring invalid character: ${ch}`);
  14089. }
  14090. getHexString() {
  14091. const strBuf = this.strBuf;
  14092. strBuf.length = 0;
  14093. let ch = this.currentChar;
  14094. let isFirstHex = true;
  14095. let firstDigit, secondDigit;
  14096. this._hexStringNumWarn = 0;
  14097. while (true) {
  14098. if (ch < 0) {
  14099. (0, _util.warn)("Unterminated hex string");
  14100. break;
  14101. } else if (ch === 0x3e) {
  14102. this.nextChar();
  14103. break;
  14104. } else if (specialChars[ch] === 1) {
  14105. ch = this.nextChar();
  14106. continue;
  14107. } else {
  14108. if (isFirstHex) {
  14109. firstDigit = toHexDigit(ch);
  14110. if (firstDigit === -1) {
  14111. this._hexStringWarn(ch);
  14112. ch = this.nextChar();
  14113. continue;
  14114. }
  14115. } else {
  14116. secondDigit = toHexDigit(ch);
  14117. if (secondDigit === -1) {
  14118. this._hexStringWarn(ch);
  14119. ch = this.nextChar();
  14120. continue;
  14121. }
  14122. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  14123. }
  14124. isFirstHex = !isFirstHex;
  14125. ch = this.nextChar();
  14126. }
  14127. }
  14128. return strBuf.join("");
  14129. }
  14130. getObj() {
  14131. let comment = false;
  14132. let ch = this.currentChar;
  14133. while (true) {
  14134. if (ch < 0) {
  14135. return _primitives.EOF;
  14136. }
  14137. if (comment) {
  14138. if (ch === 0x0a || ch === 0x0d) {
  14139. comment = false;
  14140. }
  14141. } else if (ch === 0x25) {
  14142. comment = true;
  14143. } else if (specialChars[ch] !== 1) {
  14144. break;
  14145. }
  14146. ch = this.nextChar();
  14147. }
  14148. switch (ch | 0) {
  14149. case 0x30:
  14150. case 0x31:
  14151. case 0x32:
  14152. case 0x33:
  14153. case 0x34:
  14154. case 0x35:
  14155. case 0x36:
  14156. case 0x37:
  14157. case 0x38:
  14158. case 0x39:
  14159. case 0x2b:
  14160. case 0x2d:
  14161. case 0x2e:
  14162. return this.getNumber();
  14163. case 0x28:
  14164. return this.getString();
  14165. case 0x2f:
  14166. return this.getName();
  14167. case 0x5b:
  14168. this.nextChar();
  14169. return _primitives.Cmd.get("[");
  14170. case 0x5d:
  14171. this.nextChar();
  14172. return _primitives.Cmd.get("]");
  14173. case 0x3c:
  14174. ch = this.nextChar();
  14175. if (ch === 0x3c) {
  14176. this.nextChar();
  14177. return _primitives.Cmd.get("<<");
  14178. }
  14179. return this.getHexString();
  14180. case 0x3e:
  14181. ch = this.nextChar();
  14182. if (ch === 0x3e) {
  14183. this.nextChar();
  14184. return _primitives.Cmd.get(">>");
  14185. }
  14186. return _primitives.Cmd.get(">");
  14187. case 0x7b:
  14188. this.nextChar();
  14189. return _primitives.Cmd.get("{");
  14190. case 0x7d:
  14191. this.nextChar();
  14192. return _primitives.Cmd.get("}");
  14193. case 0x29:
  14194. this.nextChar();
  14195. throw new _util.FormatError(`Illegal character: ${ch}`);
  14196. }
  14197. let str = String.fromCharCode(ch);
  14198. if (ch < 0x20 || ch > 0x7f) {
  14199. const nextCh = this.peekChar();
  14200. if (nextCh >= 0x20 && nextCh <= 0x7f) {
  14201. this.nextChar();
  14202. return _primitives.Cmd.get(str);
  14203. }
  14204. }
  14205. const knownCommands = this.knownCommands;
  14206. let knownCommandFound = knownCommands?.[str] !== undefined;
  14207. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  14208. const possibleCommand = str + String.fromCharCode(ch);
  14209. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  14210. break;
  14211. }
  14212. if (str.length === 128) {
  14213. throw new _util.FormatError(`Command token too long: ${str.length}`);
  14214. }
  14215. str = possibleCommand;
  14216. knownCommandFound = knownCommands?.[str] !== undefined;
  14217. }
  14218. if (str === "true") {
  14219. return true;
  14220. }
  14221. if (str === "false") {
  14222. return false;
  14223. }
  14224. if (str === "null") {
  14225. return null;
  14226. }
  14227. if (str === "BI") {
  14228. this.beginInlineImagePos = this.stream.pos;
  14229. }
  14230. return _primitives.Cmd.get(str);
  14231. }
  14232. skipToNextLine() {
  14233. let ch = this.currentChar;
  14234. while (ch >= 0) {
  14235. if (ch === 0x0d) {
  14236. ch = this.nextChar();
  14237. if (ch === 0x0a) {
  14238. this.nextChar();
  14239. }
  14240. break;
  14241. } else if (ch === 0x0a) {
  14242. this.nextChar();
  14243. break;
  14244. }
  14245. ch = this.nextChar();
  14246. }
  14247. }
  14248. }
  14249. exports.Lexer = Lexer;
  14250. class Linearization {
  14251. static create(stream) {
  14252. function getInt(linDict, name, allowZeroValue = false) {
  14253. const obj = linDict.get(name);
  14254. if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  14255. return obj;
  14256. }
  14257. throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
  14258. }
  14259. function getHints(linDict) {
  14260. const hints = linDict.get("H");
  14261. let hintsLength;
  14262. if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  14263. for (let index = 0; index < hintsLength; index++) {
  14264. const hint = hints[index];
  14265. if (!(Number.isInteger(hint) && hint > 0)) {
  14266. throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
  14267. }
  14268. }
  14269. return hints;
  14270. }
  14271. throw new Error("Hint array in the linearization dictionary is invalid.");
  14272. }
  14273. const parser = new Parser({
  14274. lexer: new Lexer(stream),
  14275. xref: null
  14276. });
  14277. const obj1 = parser.getObj();
  14278. const obj2 = parser.getObj();
  14279. const obj3 = parser.getObj();
  14280. const linDict = parser.getObj();
  14281. let obj, length;
  14282. if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && linDict instanceof _primitives.Dict && typeof (obj = linDict.get("Linearized")) === "number" && obj > 0)) {
  14283. return null;
  14284. } else if ((length = getInt(linDict, "L")) !== stream.length) {
  14285. throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
  14286. }
  14287. return {
  14288. length,
  14289. hints: getHints(linDict),
  14290. objectNumberFirst: getInt(linDict, "O"),
  14291. endFirst: getInt(linDict, "E"),
  14292. numPages: getInt(linDict, "N"),
  14293. mainXRefEntriesOffset: getInt(linDict, "T"),
  14294. pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
  14295. };
  14296. }
  14297. }
  14298. exports.Linearization = Linearization;
  14299. /***/ }),
  14300. /* 17 */
  14301. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14302. Object.defineProperty(exports, "__esModule", ({
  14303. value: true
  14304. }));
  14305. exports.Ascii85Stream = void 0;
  14306. var _decode_stream = __w_pdfjs_require__(18);
  14307. var _core_utils = __w_pdfjs_require__(3);
  14308. class Ascii85Stream extends _decode_stream.DecodeStream {
  14309. constructor(str, maybeLength) {
  14310. if (maybeLength) {
  14311. maybeLength *= 0.8;
  14312. }
  14313. super(maybeLength);
  14314. this.str = str;
  14315. this.dict = str.dict;
  14316. this.input = new Uint8Array(5);
  14317. }
  14318. readBlock() {
  14319. const TILDA_CHAR = 0x7e;
  14320. const Z_LOWER_CHAR = 0x7a;
  14321. const EOF = -1;
  14322. const str = this.str;
  14323. let c = str.getByte();
  14324. while ((0, _core_utils.isWhiteSpace)(c)) {
  14325. c = str.getByte();
  14326. }
  14327. if (c === EOF || c === TILDA_CHAR) {
  14328. this.eof = true;
  14329. return;
  14330. }
  14331. const bufferLength = this.bufferLength;
  14332. let buffer, i;
  14333. if (c === Z_LOWER_CHAR) {
  14334. buffer = this.ensureBuffer(bufferLength + 4);
  14335. for (i = 0; i < 4; ++i) {
  14336. buffer[bufferLength + i] = 0;
  14337. }
  14338. this.bufferLength += 4;
  14339. } else {
  14340. const input = this.input;
  14341. input[0] = c;
  14342. for (i = 1; i < 5; ++i) {
  14343. c = str.getByte();
  14344. while ((0, _core_utils.isWhiteSpace)(c)) {
  14345. c = str.getByte();
  14346. }
  14347. input[i] = c;
  14348. if (c === EOF || c === TILDA_CHAR) {
  14349. break;
  14350. }
  14351. }
  14352. buffer = this.ensureBuffer(bufferLength + i - 1);
  14353. this.bufferLength += i - 1;
  14354. if (i < 5) {
  14355. for (; i < 5; ++i) {
  14356. input[i] = 0x21 + 84;
  14357. }
  14358. this.eof = true;
  14359. }
  14360. let t = 0;
  14361. for (i = 0; i < 5; ++i) {
  14362. t = t * 85 + (input[i] - 0x21);
  14363. }
  14364. for (i = 3; i >= 0; --i) {
  14365. buffer[bufferLength + i] = t & 0xff;
  14366. t >>= 8;
  14367. }
  14368. }
  14369. }
  14370. }
  14371. exports.Ascii85Stream = Ascii85Stream;
  14372. /***/ }),
  14373. /* 18 */
  14374. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14375. Object.defineProperty(exports, "__esModule", ({
  14376. value: true
  14377. }));
  14378. exports.StreamsSequenceStream = exports.DecodeStream = void 0;
  14379. var _base_stream = __w_pdfjs_require__(5);
  14380. var _stream = __w_pdfjs_require__(8);
  14381. const emptyBuffer = new Uint8Array(0);
  14382. class DecodeStream extends _base_stream.BaseStream {
  14383. constructor(maybeMinBufferLength) {
  14384. super();
  14385. this._rawMinBufferLength = maybeMinBufferLength || 0;
  14386. this.pos = 0;
  14387. this.bufferLength = 0;
  14388. this.eof = false;
  14389. this.buffer = emptyBuffer;
  14390. this.minBufferLength = 512;
  14391. if (maybeMinBufferLength) {
  14392. while (this.minBufferLength < maybeMinBufferLength) {
  14393. this.minBufferLength *= 2;
  14394. }
  14395. }
  14396. }
  14397. get isEmpty() {
  14398. while (!this.eof && this.bufferLength === 0) {
  14399. this.readBlock();
  14400. }
  14401. return this.bufferLength === 0;
  14402. }
  14403. ensureBuffer(requested) {
  14404. const buffer = this.buffer;
  14405. if (requested <= buffer.byteLength) {
  14406. return buffer;
  14407. }
  14408. let size = this.minBufferLength;
  14409. while (size < requested) {
  14410. size *= 2;
  14411. }
  14412. const buffer2 = new Uint8Array(size);
  14413. buffer2.set(buffer);
  14414. return this.buffer = buffer2;
  14415. }
  14416. getByte() {
  14417. const pos = this.pos;
  14418. while (this.bufferLength <= pos) {
  14419. if (this.eof) {
  14420. return -1;
  14421. }
  14422. this.readBlock();
  14423. }
  14424. return this.buffer[this.pos++];
  14425. }
  14426. getBytes(length) {
  14427. const pos = this.pos;
  14428. let end;
  14429. if (length) {
  14430. this.ensureBuffer(pos + length);
  14431. end = pos + length;
  14432. while (!this.eof && this.bufferLength < end) {
  14433. this.readBlock();
  14434. }
  14435. const bufEnd = this.bufferLength;
  14436. if (end > bufEnd) {
  14437. end = bufEnd;
  14438. }
  14439. } else {
  14440. while (!this.eof) {
  14441. this.readBlock();
  14442. }
  14443. end = this.bufferLength;
  14444. }
  14445. this.pos = end;
  14446. return this.buffer.subarray(pos, end);
  14447. }
  14448. reset() {
  14449. this.pos = 0;
  14450. }
  14451. makeSubStream(start, length, dict = null) {
  14452. if (length === undefined) {
  14453. while (!this.eof) {
  14454. this.readBlock();
  14455. }
  14456. } else {
  14457. const end = start + length;
  14458. while (this.bufferLength <= end && !this.eof) {
  14459. this.readBlock();
  14460. }
  14461. }
  14462. return new _stream.Stream(this.buffer, start, length, dict);
  14463. }
  14464. getBaseStreams() {
  14465. return this.str ? this.str.getBaseStreams() : null;
  14466. }
  14467. }
  14468. exports.DecodeStream = DecodeStream;
  14469. class StreamsSequenceStream extends DecodeStream {
  14470. constructor(streams, onError = null) {
  14471. let maybeLength = 0;
  14472. for (const stream of streams) {
  14473. maybeLength += stream instanceof DecodeStream ? stream._rawMinBufferLength : stream.length;
  14474. }
  14475. super(maybeLength);
  14476. this.streams = streams;
  14477. this._onError = onError;
  14478. }
  14479. readBlock() {
  14480. const streams = this.streams;
  14481. if (streams.length === 0) {
  14482. this.eof = true;
  14483. return;
  14484. }
  14485. const stream = streams.shift();
  14486. let chunk;
  14487. try {
  14488. chunk = stream.getBytes();
  14489. } catch (reason) {
  14490. if (this._onError) {
  14491. this._onError(reason, stream.dict?.objId);
  14492. return;
  14493. }
  14494. throw reason;
  14495. }
  14496. const bufferLength = this.bufferLength;
  14497. const newLength = bufferLength + chunk.length;
  14498. const buffer = this.ensureBuffer(newLength);
  14499. buffer.set(chunk, bufferLength);
  14500. this.bufferLength = newLength;
  14501. }
  14502. getBaseStreams() {
  14503. const baseStreamsBuf = [];
  14504. for (const stream of this.streams) {
  14505. const baseStreams = stream.getBaseStreams();
  14506. if (baseStreams) {
  14507. baseStreamsBuf.push(...baseStreams);
  14508. }
  14509. }
  14510. return baseStreamsBuf.length > 0 ? baseStreamsBuf : null;
  14511. }
  14512. }
  14513. exports.StreamsSequenceStream = StreamsSequenceStream;
  14514. /***/ }),
  14515. /* 19 */
  14516. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14517. Object.defineProperty(exports, "__esModule", ({
  14518. value: true
  14519. }));
  14520. exports.AsciiHexStream = void 0;
  14521. var _decode_stream = __w_pdfjs_require__(18);
  14522. class AsciiHexStream extends _decode_stream.DecodeStream {
  14523. constructor(str, maybeLength) {
  14524. if (maybeLength) {
  14525. maybeLength *= 0.5;
  14526. }
  14527. super(maybeLength);
  14528. this.str = str;
  14529. this.dict = str.dict;
  14530. this.firstDigit = -1;
  14531. }
  14532. readBlock() {
  14533. const UPSTREAM_BLOCK_SIZE = 8000;
  14534. const bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  14535. if (!bytes.length) {
  14536. this.eof = true;
  14537. return;
  14538. }
  14539. const maxDecodeLength = bytes.length + 1 >> 1;
  14540. const buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  14541. let bufferLength = this.bufferLength;
  14542. let firstDigit = this.firstDigit;
  14543. for (const ch of bytes) {
  14544. let digit;
  14545. if (ch >= 0x30 && ch <= 0x39) {
  14546. digit = ch & 0x0f;
  14547. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  14548. digit = (ch & 0x0f) + 9;
  14549. } else if (ch === 0x3e) {
  14550. this.eof = true;
  14551. break;
  14552. } else {
  14553. continue;
  14554. }
  14555. if (firstDigit < 0) {
  14556. firstDigit = digit;
  14557. } else {
  14558. buffer[bufferLength++] = firstDigit << 4 | digit;
  14559. firstDigit = -1;
  14560. }
  14561. }
  14562. if (firstDigit >= 0 && this.eof) {
  14563. buffer[bufferLength++] = firstDigit << 4;
  14564. firstDigit = -1;
  14565. }
  14566. this.firstDigit = firstDigit;
  14567. this.bufferLength = bufferLength;
  14568. }
  14569. }
  14570. exports.AsciiHexStream = AsciiHexStream;
  14571. /***/ }),
  14572. /* 20 */
  14573. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14574. Object.defineProperty(exports, "__esModule", ({
  14575. value: true
  14576. }));
  14577. exports.CCITTFaxStream = void 0;
  14578. var _ccitt = __w_pdfjs_require__(21);
  14579. var _decode_stream = __w_pdfjs_require__(18);
  14580. var _primitives = __w_pdfjs_require__(4);
  14581. class CCITTFaxStream extends _decode_stream.DecodeStream {
  14582. constructor(str, maybeLength, params) {
  14583. super(maybeLength);
  14584. this.str = str;
  14585. this.dict = str.dict;
  14586. if (!(params instanceof _primitives.Dict)) {
  14587. params = _primitives.Dict.empty;
  14588. }
  14589. const source = {
  14590. next() {
  14591. return str.getByte();
  14592. }
  14593. };
  14594. this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
  14595. K: params.get("K"),
  14596. EndOfLine: params.get("EndOfLine"),
  14597. EncodedByteAlign: params.get("EncodedByteAlign"),
  14598. Columns: params.get("Columns"),
  14599. Rows: params.get("Rows"),
  14600. EndOfBlock: params.get("EndOfBlock"),
  14601. BlackIs1: params.get("BlackIs1")
  14602. });
  14603. }
  14604. readBlock() {
  14605. while (!this.eof) {
  14606. const c = this.ccittFaxDecoder.readNextChar();
  14607. if (c === -1) {
  14608. this.eof = true;
  14609. return;
  14610. }
  14611. this.ensureBuffer(this.bufferLength + 1);
  14612. this.buffer[this.bufferLength++] = c;
  14613. }
  14614. }
  14615. }
  14616. exports.CCITTFaxStream = CCITTFaxStream;
  14617. /***/ }),
  14618. /* 21 */
  14619. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14620. Object.defineProperty(exports, "__esModule", ({
  14621. value: true
  14622. }));
  14623. exports.CCITTFaxDecoder = void 0;
  14624. var _util = __w_pdfjs_require__(2);
  14625. const ccittEOL = -2;
  14626. const ccittEOF = -1;
  14627. const twoDimPass = 0;
  14628. const twoDimHoriz = 1;
  14629. const twoDimVert0 = 2;
  14630. const twoDimVertR1 = 3;
  14631. const twoDimVertL1 = 4;
  14632. const twoDimVertR2 = 5;
  14633. const twoDimVertL2 = 6;
  14634. const twoDimVertR3 = 7;
  14635. const twoDimVertL3 = 8;
  14636. const twoDimTable = [[-1, -1], [-1, -1], [7, twoDimVertL3], [7, twoDimVertR3], [6, twoDimVertL2], [6, twoDimVertL2], [6, twoDimVertR2], [6, twoDimVertR2], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0]];
  14637. const whiteTable1 = [[-1, -1], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [12, 1984], [12, 2048], [12, 2112], [12, 2176], [12, 2240], [12, 2304], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [12, 2368], [12, 2432], [12, 2496], [12, 2560]];
  14638. const whiteTable2 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [8, 29], [8, 29], [8, 30], [8, 30], [8, 45], [8, 45], [8, 46], [8, 46], [7, 22], [7, 22], [7, 22], [7, 22], [7, 23], [7, 23], [7, 23], [7, 23], [8, 47], [8, 47], [8, 48], [8, 48], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [7, 20], [7, 20], [7, 20], [7, 20], [8, 33], [8, 33], [8, 34], [8, 34], [8, 35], [8, 35], [8, 36], [8, 36], [8, 37], [8, 37], [8, 38], [8, 38], [7, 19], [7, 19], [7, 19], [7, 19], [8, 31], [8, 31], [8, 32], [8, 32], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [8, 53], [8, 53], [8, 54], [8, 54], [7, 26], [7, 26], [7, 26], [7, 26], [8, 39], [8, 39], [8, 40], [8, 40], [8, 41], [8, 41], [8, 42], [8, 42], [8, 43], [8, 43], [8, 44], [8, 44], [7, 21], [7, 21], [7, 21], [7, 21], [7, 28], [7, 28], [7, 28], [7, 28], [8, 61], [8, 61], [8, 62], [8, 62], [8, 63], [8, 63], [8, 0], [8, 0], [8, 320], [8, 320], [8, 384], [8, 384], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [7, 27], [7, 27], [7, 27], [7, 27], [8, 59], [8, 59], [8, 60], [8, 60], [9, 1472], [9, 1536], [9, 1600], [9, 1728], [7, 18], [7, 18], [7, 18], [7, 18], [7, 24], [7, 24], [7, 24], [7, 24], [8, 49], [8, 49], [8, 50], [8, 50], [8, 51], [8, 51], [8, 52], [8, 52], [7, 25], [7, 25], [7, 25], [7, 25], [8, 55], [8, 55], [8, 56], [8, 56], [8, 57], [8, 57], [8, 58], [8, 58], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [8, 448], [8, 448], [8, 512], [8, 512], [9, 704], [9, 768], [8, 640], [8, 640], [8, 576], [8, 576], [9, 832], [9, 896], [9, 960], [9, 1024], [9, 1088], [9, 1152], [9, 1216], [9, 1280], [9, 1344], [9, 1408], [7, 256], [7, 256], [7, 256], [7, 256], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7]];
  14639. const blackTable1 = [[-1, -1], [-1, -1], [12, ccittEOL], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [11, 1792], [11, 1792], [12, 1984], [12, 1984], [12, 2048], [12, 2048], [12, 2112], [12, 2112], [12, 2176], [12, 2176], [12, 2240], [12, 2240], [12, 2304], [12, 2304], [11, 1856], [11, 1856], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [11, 1920], [11, 1920], [12, 2368], [12, 2368], [12, 2432], [12, 2432], [12, 2496], [12, 2496], [12, 2560], [12, 2560], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [12, 52], [12, 52], [13, 640], [13, 704], [13, 768], [13, 832], [12, 55], [12, 55], [12, 56], [12, 56], [13, 1280], [13, 1344], [13, 1408], [13, 1472], [12, 59], [12, 59], [12, 60], [12, 60], [13, 1536], [13, 1600], [11, 24], [11, 24], [11, 24], [11, 24], [11, 25], [11, 25], [11, 25], [11, 25], [13, 1664], [13, 1728], [12, 320], [12, 320], [12, 384], [12, 384], [12, 448], [12, 448], [13, 512], [13, 576], [12, 53], [12, 53], [12, 54], [12, 54], [13, 896], [13, 960], [13, 1024], [13, 1088], [13, 1152], [13, 1216], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64]];
  14640. const blackTable2 = [[8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [11, 23], [11, 23], [12, 50], [12, 51], [12, 44], [12, 45], [12, 46], [12, 47], [12, 57], [12, 58], [12, 61], [12, 256], [10, 16], [10, 16], [10, 16], [10, 16], [10, 17], [10, 17], [10, 17], [10, 17], [12, 48], [12, 49], [12, 62], [12, 63], [12, 30], [12, 31], [12, 32], [12, 33], [12, 40], [12, 41], [11, 22], [11, 22], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [12, 128], [12, 192], [12, 26], [12, 27], [12, 28], [12, 29], [11, 19], [11, 19], [11, 20], [11, 20], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [11, 21], [11, 21], [12, 42], [12, 43], [10, 0], [10, 0], [10, 0], [10, 0], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12]];
  14641. const blackTable3 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [6, 9], [6, 8], [5, 7], [5, 7], [4, 6], [4, 6], [4, 6], [4, 6], [4, 5], [4, 5], [4, 5], [4, 5], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]];
  14642. class CCITTFaxDecoder {
  14643. constructor(source, options = {}) {
  14644. if (!source || typeof source.next !== "function") {
  14645. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  14646. }
  14647. this.source = source;
  14648. this.eof = false;
  14649. this.encoding = options.K || 0;
  14650. this.eoline = options.EndOfLine || false;
  14651. this.byteAlign = options.EncodedByteAlign || false;
  14652. this.columns = options.Columns || 1728;
  14653. this.rows = options.Rows || 0;
  14654. this.eoblock = options.EndOfBlock ?? true;
  14655. this.black = options.BlackIs1 || false;
  14656. this.codingLine = new Uint32Array(this.columns + 1);
  14657. this.refLine = new Uint32Array(this.columns + 2);
  14658. this.codingLine[0] = this.columns;
  14659. this.codingPos = 0;
  14660. this.row = 0;
  14661. this.nextLine2D = this.encoding < 0;
  14662. this.inputBits = 0;
  14663. this.inputBuf = 0;
  14664. this.outputBits = 0;
  14665. this.rowsDone = false;
  14666. let code1;
  14667. while ((code1 = this._lookBits(12)) === 0) {
  14668. this._eatBits(1);
  14669. }
  14670. if (code1 === 1) {
  14671. this._eatBits(12);
  14672. }
  14673. if (this.encoding > 0) {
  14674. this.nextLine2D = !this._lookBits(1);
  14675. this._eatBits(1);
  14676. }
  14677. }
  14678. readNextChar() {
  14679. if (this.eof) {
  14680. return -1;
  14681. }
  14682. const refLine = this.refLine;
  14683. const codingLine = this.codingLine;
  14684. const columns = this.columns;
  14685. let refPos, blackPixels, bits, i;
  14686. if (this.outputBits === 0) {
  14687. if (this.rowsDone) {
  14688. this.eof = true;
  14689. }
  14690. if (this.eof) {
  14691. return -1;
  14692. }
  14693. this.err = false;
  14694. let code1, code2, code3;
  14695. if (this.nextLine2D) {
  14696. for (i = 0; codingLine[i] < columns; ++i) {
  14697. refLine[i] = codingLine[i];
  14698. }
  14699. refLine[i++] = columns;
  14700. refLine[i] = columns;
  14701. codingLine[0] = 0;
  14702. this.codingPos = 0;
  14703. refPos = 0;
  14704. blackPixels = 0;
  14705. while (codingLine[this.codingPos] < columns) {
  14706. code1 = this._getTwoDimCode();
  14707. switch (code1) {
  14708. case twoDimPass:
  14709. this._addPixels(refLine[refPos + 1], blackPixels);
  14710. if (refLine[refPos + 1] < columns) {
  14711. refPos += 2;
  14712. }
  14713. break;
  14714. case twoDimHoriz:
  14715. code1 = code2 = 0;
  14716. if (blackPixels) {
  14717. do {
  14718. code1 += code3 = this._getBlackCode();
  14719. } while (code3 >= 64);
  14720. do {
  14721. code2 += code3 = this._getWhiteCode();
  14722. } while (code3 >= 64);
  14723. } else {
  14724. do {
  14725. code1 += code3 = this._getWhiteCode();
  14726. } while (code3 >= 64);
  14727. do {
  14728. code2 += code3 = this._getBlackCode();
  14729. } while (code3 >= 64);
  14730. }
  14731. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  14732. if (codingLine[this.codingPos] < columns) {
  14733. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  14734. }
  14735. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14736. refPos += 2;
  14737. }
  14738. break;
  14739. case twoDimVertR3:
  14740. this._addPixels(refLine[refPos] + 3, blackPixels);
  14741. blackPixels ^= 1;
  14742. if (codingLine[this.codingPos] < columns) {
  14743. ++refPos;
  14744. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14745. refPos += 2;
  14746. }
  14747. }
  14748. break;
  14749. case twoDimVertR2:
  14750. this._addPixels(refLine[refPos] + 2, blackPixels);
  14751. blackPixels ^= 1;
  14752. if (codingLine[this.codingPos] < columns) {
  14753. ++refPos;
  14754. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14755. refPos += 2;
  14756. }
  14757. }
  14758. break;
  14759. case twoDimVertR1:
  14760. this._addPixels(refLine[refPos] + 1, blackPixels);
  14761. blackPixels ^= 1;
  14762. if (codingLine[this.codingPos] < columns) {
  14763. ++refPos;
  14764. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14765. refPos += 2;
  14766. }
  14767. }
  14768. break;
  14769. case twoDimVert0:
  14770. this._addPixels(refLine[refPos], blackPixels);
  14771. blackPixels ^= 1;
  14772. if (codingLine[this.codingPos] < columns) {
  14773. ++refPos;
  14774. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14775. refPos += 2;
  14776. }
  14777. }
  14778. break;
  14779. case twoDimVertL3:
  14780. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  14781. blackPixels ^= 1;
  14782. if (codingLine[this.codingPos] < columns) {
  14783. if (refPos > 0) {
  14784. --refPos;
  14785. } else {
  14786. ++refPos;
  14787. }
  14788. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14789. refPos += 2;
  14790. }
  14791. }
  14792. break;
  14793. case twoDimVertL2:
  14794. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  14795. blackPixels ^= 1;
  14796. if (codingLine[this.codingPos] < columns) {
  14797. if (refPos > 0) {
  14798. --refPos;
  14799. } else {
  14800. ++refPos;
  14801. }
  14802. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14803. refPos += 2;
  14804. }
  14805. }
  14806. break;
  14807. case twoDimVertL1:
  14808. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  14809. blackPixels ^= 1;
  14810. if (codingLine[this.codingPos] < columns) {
  14811. if (refPos > 0) {
  14812. --refPos;
  14813. } else {
  14814. ++refPos;
  14815. }
  14816. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  14817. refPos += 2;
  14818. }
  14819. }
  14820. break;
  14821. case ccittEOF:
  14822. this._addPixels(columns, 0);
  14823. this.eof = true;
  14824. break;
  14825. default:
  14826. (0, _util.info)("bad 2d code");
  14827. this._addPixels(columns, 0);
  14828. this.err = true;
  14829. }
  14830. }
  14831. } else {
  14832. codingLine[0] = 0;
  14833. this.codingPos = 0;
  14834. blackPixels = 0;
  14835. while (codingLine[this.codingPos] < columns) {
  14836. code1 = 0;
  14837. if (blackPixels) {
  14838. do {
  14839. code1 += code3 = this._getBlackCode();
  14840. } while (code3 >= 64);
  14841. } else {
  14842. do {
  14843. code1 += code3 = this._getWhiteCode();
  14844. } while (code3 >= 64);
  14845. }
  14846. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  14847. blackPixels ^= 1;
  14848. }
  14849. }
  14850. let gotEOL = false;
  14851. if (this.byteAlign) {
  14852. this.inputBits &= ~7;
  14853. }
  14854. if (!this.eoblock && this.row === this.rows - 1) {
  14855. this.rowsDone = true;
  14856. } else {
  14857. code1 = this._lookBits(12);
  14858. if (this.eoline) {
  14859. while (code1 !== ccittEOF && code1 !== 1) {
  14860. this._eatBits(1);
  14861. code1 = this._lookBits(12);
  14862. }
  14863. } else {
  14864. while (code1 === 0) {
  14865. this._eatBits(1);
  14866. code1 = this._lookBits(12);
  14867. }
  14868. }
  14869. if (code1 === 1) {
  14870. this._eatBits(12);
  14871. gotEOL = true;
  14872. } else if (code1 === ccittEOF) {
  14873. this.eof = true;
  14874. }
  14875. }
  14876. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  14877. this.nextLine2D = !this._lookBits(1);
  14878. this._eatBits(1);
  14879. }
  14880. if (this.eoblock && gotEOL && this.byteAlign) {
  14881. code1 = this._lookBits(12);
  14882. if (code1 === 1) {
  14883. this._eatBits(12);
  14884. if (this.encoding > 0) {
  14885. this._lookBits(1);
  14886. this._eatBits(1);
  14887. }
  14888. if (this.encoding >= 0) {
  14889. for (i = 0; i < 4; ++i) {
  14890. code1 = this._lookBits(12);
  14891. if (code1 !== 1) {
  14892. (0, _util.info)("bad rtc code: " + code1);
  14893. }
  14894. this._eatBits(12);
  14895. if (this.encoding > 0) {
  14896. this._lookBits(1);
  14897. this._eatBits(1);
  14898. }
  14899. }
  14900. }
  14901. this.eof = true;
  14902. }
  14903. } else if (this.err && this.eoline) {
  14904. while (true) {
  14905. code1 = this._lookBits(13);
  14906. if (code1 === ccittEOF) {
  14907. this.eof = true;
  14908. return -1;
  14909. }
  14910. if (code1 >> 1 === 1) {
  14911. break;
  14912. }
  14913. this._eatBits(1);
  14914. }
  14915. this._eatBits(12);
  14916. if (this.encoding > 0) {
  14917. this._eatBits(1);
  14918. this.nextLine2D = !(code1 & 1);
  14919. }
  14920. }
  14921. this.outputBits = codingLine[0] > 0 ? codingLine[this.codingPos = 0] : codingLine[this.codingPos = 1];
  14922. this.row++;
  14923. }
  14924. let c;
  14925. if (this.outputBits >= 8) {
  14926. c = this.codingPos & 1 ? 0 : 0xff;
  14927. this.outputBits -= 8;
  14928. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  14929. this.codingPos++;
  14930. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  14931. }
  14932. } else {
  14933. bits = 8;
  14934. c = 0;
  14935. do {
  14936. if (typeof this.outputBits !== "number") {
  14937. throw new _util.FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');
  14938. }
  14939. if (this.outputBits > bits) {
  14940. c <<= bits;
  14941. if (!(this.codingPos & 1)) {
  14942. c |= 0xff >> 8 - bits;
  14943. }
  14944. this.outputBits -= bits;
  14945. bits = 0;
  14946. } else {
  14947. c <<= this.outputBits;
  14948. if (!(this.codingPos & 1)) {
  14949. c |= 0xff >> 8 - this.outputBits;
  14950. }
  14951. bits -= this.outputBits;
  14952. this.outputBits = 0;
  14953. if (codingLine[this.codingPos] < columns) {
  14954. this.codingPos++;
  14955. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  14956. } else if (bits > 0) {
  14957. c <<= bits;
  14958. bits = 0;
  14959. }
  14960. }
  14961. } while (bits);
  14962. }
  14963. if (this.black) {
  14964. c ^= 0xff;
  14965. }
  14966. return c;
  14967. }
  14968. _addPixels(a1, blackPixels) {
  14969. const codingLine = this.codingLine;
  14970. let codingPos = this.codingPos;
  14971. if (a1 > codingLine[codingPos]) {
  14972. if (a1 > this.columns) {
  14973. (0, _util.info)("row is wrong length");
  14974. this.err = true;
  14975. a1 = this.columns;
  14976. }
  14977. if (codingPos & 1 ^ blackPixels) {
  14978. ++codingPos;
  14979. }
  14980. codingLine[codingPos] = a1;
  14981. }
  14982. this.codingPos = codingPos;
  14983. }
  14984. _addPixelsNeg(a1, blackPixels) {
  14985. const codingLine = this.codingLine;
  14986. let codingPos = this.codingPos;
  14987. if (a1 > codingLine[codingPos]) {
  14988. if (a1 > this.columns) {
  14989. (0, _util.info)("row is wrong length");
  14990. this.err = true;
  14991. a1 = this.columns;
  14992. }
  14993. if (codingPos & 1 ^ blackPixels) {
  14994. ++codingPos;
  14995. }
  14996. codingLine[codingPos] = a1;
  14997. } else if (a1 < codingLine[codingPos]) {
  14998. if (a1 < 0) {
  14999. (0, _util.info)("invalid code");
  15000. this.err = true;
  15001. a1 = 0;
  15002. }
  15003. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  15004. --codingPos;
  15005. }
  15006. codingLine[codingPos] = a1;
  15007. }
  15008. this.codingPos = codingPos;
  15009. }
  15010. _findTableCode(start, end, table, limit) {
  15011. const limitValue = limit || 0;
  15012. for (let i = start; i <= end; ++i) {
  15013. let code = this._lookBits(i);
  15014. if (code === ccittEOF) {
  15015. return [true, 1, false];
  15016. }
  15017. if (i < end) {
  15018. code <<= end - i;
  15019. }
  15020. if (!limitValue || code >= limitValue) {
  15021. const p = table[code - limitValue];
  15022. if (p[0] === i) {
  15023. this._eatBits(i);
  15024. return [true, p[1], true];
  15025. }
  15026. }
  15027. }
  15028. return [false, 0, false];
  15029. }
  15030. _getTwoDimCode() {
  15031. let code = 0;
  15032. let p;
  15033. if (this.eoblock) {
  15034. code = this._lookBits(7);
  15035. p = twoDimTable[code];
  15036. if (p?.[0] > 0) {
  15037. this._eatBits(p[0]);
  15038. return p[1];
  15039. }
  15040. } else {
  15041. const result = this._findTableCode(1, 7, twoDimTable);
  15042. if (result[0] && result[2]) {
  15043. return result[1];
  15044. }
  15045. }
  15046. (0, _util.info)("Bad two dim code");
  15047. return ccittEOF;
  15048. }
  15049. _getWhiteCode() {
  15050. let code = 0;
  15051. let p;
  15052. if (this.eoblock) {
  15053. code = this._lookBits(12);
  15054. if (code === ccittEOF) {
  15055. return 1;
  15056. }
  15057. p = code >> 5 === 0 ? whiteTable1[code] : whiteTable2[code >> 3];
  15058. if (p[0] > 0) {
  15059. this._eatBits(p[0]);
  15060. return p[1];
  15061. }
  15062. } else {
  15063. let result = this._findTableCode(1, 9, whiteTable2);
  15064. if (result[0]) {
  15065. return result[1];
  15066. }
  15067. result = this._findTableCode(11, 12, whiteTable1);
  15068. if (result[0]) {
  15069. return result[1];
  15070. }
  15071. }
  15072. (0, _util.info)("bad white code");
  15073. this._eatBits(1);
  15074. return 1;
  15075. }
  15076. _getBlackCode() {
  15077. let code, p;
  15078. if (this.eoblock) {
  15079. code = this._lookBits(13);
  15080. if (code === ccittEOF) {
  15081. return 1;
  15082. }
  15083. if (code >> 7 === 0) {
  15084. p = blackTable1[code];
  15085. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  15086. p = blackTable2[(code >> 1) - 64];
  15087. } else {
  15088. p = blackTable3[code >> 7];
  15089. }
  15090. if (p[0] > 0) {
  15091. this._eatBits(p[0]);
  15092. return p[1];
  15093. }
  15094. } else {
  15095. let result = this._findTableCode(2, 6, blackTable3);
  15096. if (result[0]) {
  15097. return result[1];
  15098. }
  15099. result = this._findTableCode(7, 12, blackTable2, 64);
  15100. if (result[0]) {
  15101. return result[1];
  15102. }
  15103. result = this._findTableCode(10, 13, blackTable1);
  15104. if (result[0]) {
  15105. return result[1];
  15106. }
  15107. }
  15108. (0, _util.info)("bad black code");
  15109. this._eatBits(1);
  15110. return 1;
  15111. }
  15112. _lookBits(n) {
  15113. let c;
  15114. while (this.inputBits < n) {
  15115. if ((c = this.source.next()) === -1) {
  15116. if (this.inputBits === 0) {
  15117. return ccittEOF;
  15118. }
  15119. return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
  15120. }
  15121. this.inputBuf = this.inputBuf << 8 | c;
  15122. this.inputBits += 8;
  15123. }
  15124. return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
  15125. }
  15126. _eatBits(n) {
  15127. if ((this.inputBits -= n) < 0) {
  15128. this.inputBits = 0;
  15129. }
  15130. }
  15131. }
  15132. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  15133. /***/ }),
  15134. /* 22 */
  15135. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15136. Object.defineProperty(exports, "__esModule", ({
  15137. value: true
  15138. }));
  15139. exports.FlateStream = void 0;
  15140. var _decode_stream = __w_pdfjs_require__(18);
  15141. var _util = __w_pdfjs_require__(2);
  15142. const codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  15143. const lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);
  15144. const distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);
  15145. const fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8, 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8, 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8, 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4, 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4, 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4, 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc, 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec, 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc, 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2, 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2, 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2, 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca, 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea, 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da, 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6, 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6, 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6, 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce, 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee, 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de, 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe, 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1, 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1, 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1, 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9, 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9, 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9, 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5, 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5, 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5, 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd, 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed, 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd, 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3, 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3, 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3, 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb, 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb, 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db, 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7, 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7, 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7, 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf, 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef, 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df, 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];
  15146. const fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000]), 5];
  15147. class FlateStream extends _decode_stream.DecodeStream {
  15148. constructor(str, maybeLength) {
  15149. super(maybeLength);
  15150. this.str = str;
  15151. this.dict = str.dict;
  15152. const cmf = str.getByte();
  15153. const flg = str.getByte();
  15154. if (cmf === -1 || flg === -1) {
  15155. throw new _util.FormatError(`Invalid header in flate stream: ${cmf}, ${flg}`);
  15156. }
  15157. if ((cmf & 0x0f) !== 0x08) {
  15158. throw new _util.FormatError(`Unknown compression method in flate stream: ${cmf}, ${flg}`);
  15159. }
  15160. if (((cmf << 8) + flg) % 31 !== 0) {
  15161. throw new _util.FormatError(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);
  15162. }
  15163. if (flg & 0x20) {
  15164. throw new _util.FormatError(`FDICT bit set in flate stream: ${cmf}, ${flg}`);
  15165. }
  15166. this.codeSize = 0;
  15167. this.codeBuf = 0;
  15168. }
  15169. getBits(bits) {
  15170. const str = this.str;
  15171. let codeSize = this.codeSize;
  15172. let codeBuf = this.codeBuf;
  15173. let b;
  15174. while (codeSize < bits) {
  15175. if ((b = str.getByte()) === -1) {
  15176. throw new _util.FormatError("Bad encoding in flate stream");
  15177. }
  15178. codeBuf |= b << codeSize;
  15179. codeSize += 8;
  15180. }
  15181. b = codeBuf & (1 << bits) - 1;
  15182. this.codeBuf = codeBuf >> bits;
  15183. this.codeSize = codeSize -= bits;
  15184. return b;
  15185. }
  15186. getCode(table) {
  15187. const str = this.str;
  15188. const codes = table[0];
  15189. const maxLen = table[1];
  15190. let codeSize = this.codeSize;
  15191. let codeBuf = this.codeBuf;
  15192. let b;
  15193. while (codeSize < maxLen) {
  15194. if ((b = str.getByte()) === -1) {
  15195. break;
  15196. }
  15197. codeBuf |= b << codeSize;
  15198. codeSize += 8;
  15199. }
  15200. const code = codes[codeBuf & (1 << maxLen) - 1];
  15201. const codeLen = code >> 16;
  15202. const codeVal = code & 0xffff;
  15203. if (codeLen < 1 || codeSize < codeLen) {
  15204. throw new _util.FormatError("Bad encoding in flate stream");
  15205. }
  15206. this.codeBuf = codeBuf >> codeLen;
  15207. this.codeSize = codeSize - codeLen;
  15208. return codeVal;
  15209. }
  15210. generateHuffmanTable(lengths) {
  15211. const n = lengths.length;
  15212. let maxLen = 0;
  15213. let i;
  15214. for (i = 0; i < n; ++i) {
  15215. if (lengths[i] > maxLen) {
  15216. maxLen = lengths[i];
  15217. }
  15218. }
  15219. const size = 1 << maxLen;
  15220. const codes = new Int32Array(size);
  15221. for (let len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  15222. for (let val = 0; val < n; ++val) {
  15223. if (lengths[val] === len) {
  15224. let code2 = 0;
  15225. let t = code;
  15226. for (i = 0; i < len; ++i) {
  15227. code2 = code2 << 1 | t & 1;
  15228. t >>= 1;
  15229. }
  15230. for (i = code2; i < size; i += skip) {
  15231. codes[i] = len << 16 | val;
  15232. }
  15233. ++code;
  15234. }
  15235. }
  15236. }
  15237. return [codes, maxLen];
  15238. }
  15239. readBlock() {
  15240. let buffer, len;
  15241. const str = this.str;
  15242. let hdr = this.getBits(3);
  15243. if (hdr & 1) {
  15244. this.eof = true;
  15245. }
  15246. hdr >>= 1;
  15247. if (hdr === 0) {
  15248. let b;
  15249. if ((b = str.getByte()) === -1) {
  15250. throw new _util.FormatError("Bad block header in flate stream");
  15251. }
  15252. let blockLen = b;
  15253. if ((b = str.getByte()) === -1) {
  15254. throw new _util.FormatError("Bad block header in flate stream");
  15255. }
  15256. blockLen |= b << 8;
  15257. if ((b = str.getByte()) === -1) {
  15258. throw new _util.FormatError("Bad block header in flate stream");
  15259. }
  15260. let check = b;
  15261. if ((b = str.getByte()) === -1) {
  15262. throw new _util.FormatError("Bad block header in flate stream");
  15263. }
  15264. check |= b << 8;
  15265. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  15266. throw new _util.FormatError("Bad uncompressed block length in flate stream");
  15267. }
  15268. this.codeBuf = 0;
  15269. this.codeSize = 0;
  15270. const bufferLength = this.bufferLength,
  15271. end = bufferLength + blockLen;
  15272. buffer = this.ensureBuffer(end);
  15273. this.bufferLength = end;
  15274. if (blockLen === 0) {
  15275. if (str.peekByte() === -1) {
  15276. this.eof = true;
  15277. }
  15278. } else {
  15279. const block = str.getBytes(blockLen);
  15280. buffer.set(block, bufferLength);
  15281. if (block.length < blockLen) {
  15282. this.eof = true;
  15283. }
  15284. }
  15285. return;
  15286. }
  15287. let litCodeTable;
  15288. let distCodeTable;
  15289. if (hdr === 1) {
  15290. litCodeTable = fixedLitCodeTab;
  15291. distCodeTable = fixedDistCodeTab;
  15292. } else if (hdr === 2) {
  15293. const numLitCodes = this.getBits(5) + 257;
  15294. const numDistCodes = this.getBits(5) + 1;
  15295. const numCodeLenCodes = this.getBits(4) + 4;
  15296. const codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  15297. let i;
  15298. for (i = 0; i < numCodeLenCodes; ++i) {
  15299. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  15300. }
  15301. const codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  15302. len = 0;
  15303. i = 0;
  15304. const codes = numLitCodes + numDistCodes;
  15305. const codeLengths = new Uint8Array(codes);
  15306. let bitsLength, bitsOffset, what;
  15307. while (i < codes) {
  15308. const code = this.getCode(codeLenCodeTab);
  15309. if (code === 16) {
  15310. bitsLength = 2;
  15311. bitsOffset = 3;
  15312. what = len;
  15313. } else if (code === 17) {
  15314. bitsLength = 3;
  15315. bitsOffset = 3;
  15316. what = len = 0;
  15317. } else if (code === 18) {
  15318. bitsLength = 7;
  15319. bitsOffset = 11;
  15320. what = len = 0;
  15321. } else {
  15322. codeLengths[i++] = len = code;
  15323. continue;
  15324. }
  15325. let repeatLength = this.getBits(bitsLength) + bitsOffset;
  15326. while (repeatLength-- > 0) {
  15327. codeLengths[i++] = what;
  15328. }
  15329. }
  15330. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  15331. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  15332. } else {
  15333. throw new _util.FormatError("Unknown block type in flate stream");
  15334. }
  15335. buffer = this.buffer;
  15336. let limit = buffer ? buffer.length : 0;
  15337. let pos = this.bufferLength;
  15338. while (true) {
  15339. let code1 = this.getCode(litCodeTable);
  15340. if (code1 < 256) {
  15341. if (pos + 1 >= limit) {
  15342. buffer = this.ensureBuffer(pos + 1);
  15343. limit = buffer.length;
  15344. }
  15345. buffer[pos++] = code1;
  15346. continue;
  15347. }
  15348. if (code1 === 256) {
  15349. this.bufferLength = pos;
  15350. return;
  15351. }
  15352. code1 -= 257;
  15353. code1 = lengthDecode[code1];
  15354. let code2 = code1 >> 16;
  15355. if (code2 > 0) {
  15356. code2 = this.getBits(code2);
  15357. }
  15358. len = (code1 & 0xffff) + code2;
  15359. code1 = this.getCode(distCodeTable);
  15360. code1 = distDecode[code1];
  15361. code2 = code1 >> 16;
  15362. if (code2 > 0) {
  15363. code2 = this.getBits(code2);
  15364. }
  15365. const dist = (code1 & 0xffff) + code2;
  15366. if (pos + len >= limit) {
  15367. buffer = this.ensureBuffer(pos + len);
  15368. limit = buffer.length;
  15369. }
  15370. for (let k = 0; k < len; ++k, ++pos) {
  15371. buffer[pos] = buffer[pos - dist];
  15372. }
  15373. }
  15374. }
  15375. }
  15376. exports.FlateStream = FlateStream;
  15377. /***/ }),
  15378. /* 23 */
  15379. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15380. Object.defineProperty(exports, "__esModule", ({
  15381. value: true
  15382. }));
  15383. exports.Jbig2Stream = void 0;
  15384. var _base_stream = __w_pdfjs_require__(5);
  15385. var _decode_stream = __w_pdfjs_require__(18);
  15386. var _primitives = __w_pdfjs_require__(4);
  15387. var _jbig = __w_pdfjs_require__(24);
  15388. var _util = __w_pdfjs_require__(2);
  15389. class Jbig2Stream extends _decode_stream.DecodeStream {
  15390. constructor(stream, maybeLength, params) {
  15391. super(maybeLength);
  15392. this.stream = stream;
  15393. this.dict = stream.dict;
  15394. this.maybeLength = maybeLength;
  15395. this.params = params;
  15396. }
  15397. get bytes() {
  15398. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  15399. }
  15400. ensureBuffer(requested) {}
  15401. readBlock() {
  15402. if (this.eof) {
  15403. return;
  15404. }
  15405. const jbig2Image = new _jbig.Jbig2Image();
  15406. const chunks = [];
  15407. if (this.params instanceof _primitives.Dict) {
  15408. const globalsStream = this.params.get("JBIG2Globals");
  15409. if (globalsStream instanceof _base_stream.BaseStream) {
  15410. const globals = globalsStream.getBytes();
  15411. chunks.push({
  15412. data: globals,
  15413. start: 0,
  15414. end: globals.length
  15415. });
  15416. }
  15417. }
  15418. chunks.push({
  15419. data: this.bytes,
  15420. start: 0,
  15421. end: this.bytes.length
  15422. });
  15423. const data = jbig2Image.parseChunks(chunks);
  15424. const dataLength = data.length;
  15425. for (let i = 0; i < dataLength; i++) {
  15426. data[i] ^= 0xff;
  15427. }
  15428. this.buffer = data;
  15429. this.bufferLength = dataLength;
  15430. this.eof = true;
  15431. }
  15432. }
  15433. exports.Jbig2Stream = Jbig2Stream;
  15434. /***/ }),
  15435. /* 24 */
  15436. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15437. Object.defineProperty(exports, "__esModule", ({
  15438. value: true
  15439. }));
  15440. exports.Jbig2Image = void 0;
  15441. var _util = __w_pdfjs_require__(2);
  15442. var _core_utils = __w_pdfjs_require__(3);
  15443. var _arithmetic_decoder = __w_pdfjs_require__(25);
  15444. var _ccitt = __w_pdfjs_require__(21);
  15445. class Jbig2Error extends _util.BaseException {
  15446. constructor(msg) {
  15447. super(`JBIG2 error: ${msg}`, "Jbig2Error");
  15448. }
  15449. }
  15450. class ContextCache {
  15451. getContexts(id) {
  15452. if (id in this) {
  15453. return this[id];
  15454. }
  15455. return this[id] = new Int8Array(1 << 16);
  15456. }
  15457. }
  15458. class DecodingContext {
  15459. constructor(data, start, end) {
  15460. this.data = data;
  15461. this.start = start;
  15462. this.end = end;
  15463. }
  15464. get decoder() {
  15465. const decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  15466. return (0, _util.shadow)(this, "decoder", decoder);
  15467. }
  15468. get contextCache() {
  15469. const cache = new ContextCache();
  15470. return (0, _util.shadow)(this, "contextCache", cache);
  15471. }
  15472. }
  15473. const MAX_INT_32 = 2 ** 31 - 1;
  15474. const MIN_INT_32 = -(2 ** 31);
  15475. function decodeInteger(contextCache, procedure, decoder) {
  15476. const contexts = contextCache.getContexts(procedure);
  15477. let prev = 1;
  15478. function readBits(length) {
  15479. let v = 0;
  15480. for (let i = 0; i < length; i++) {
  15481. const bit = decoder.readBit(contexts, prev);
  15482. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  15483. v = v << 1 | bit;
  15484. }
  15485. return v >>> 0;
  15486. }
  15487. const sign = readBits(1);
  15488. const value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  15489. let signedValue;
  15490. if (sign === 0) {
  15491. signedValue = value;
  15492. } else if (value > 0) {
  15493. signedValue = -value;
  15494. }
  15495. if (signedValue >= MIN_INT_32 && signedValue <= MAX_INT_32) {
  15496. return signedValue;
  15497. }
  15498. return null;
  15499. }
  15500. function decodeIAID(contextCache, decoder, codeLength) {
  15501. const contexts = contextCache.getContexts("IAID");
  15502. let prev = 1;
  15503. for (let i = 0; i < codeLength; i++) {
  15504. const bit = decoder.readBit(contexts, prev);
  15505. prev = prev << 1 | bit;
  15506. }
  15507. if (codeLength < 31) {
  15508. return prev & (1 << codeLength) - 1;
  15509. }
  15510. return prev & 0x7fffffff;
  15511. }
  15512. const SegmentTypes = ["SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "PatternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension"];
  15513. const CodingTemplates = [[{
  15514. x: -1,
  15515. y: -2
  15516. }, {
  15517. x: 0,
  15518. y: -2
  15519. }, {
  15520. x: 1,
  15521. y: -2
  15522. }, {
  15523. x: -2,
  15524. y: -1
  15525. }, {
  15526. x: -1,
  15527. y: -1
  15528. }, {
  15529. x: 0,
  15530. y: -1
  15531. }, {
  15532. x: 1,
  15533. y: -1
  15534. }, {
  15535. x: 2,
  15536. y: -1
  15537. }, {
  15538. x: -4,
  15539. y: 0
  15540. }, {
  15541. x: -3,
  15542. y: 0
  15543. }, {
  15544. x: -2,
  15545. y: 0
  15546. }, {
  15547. x: -1,
  15548. y: 0
  15549. }], [{
  15550. x: -1,
  15551. y: -2
  15552. }, {
  15553. x: 0,
  15554. y: -2
  15555. }, {
  15556. x: 1,
  15557. y: -2
  15558. }, {
  15559. x: 2,
  15560. y: -2
  15561. }, {
  15562. x: -2,
  15563. y: -1
  15564. }, {
  15565. x: -1,
  15566. y: -1
  15567. }, {
  15568. x: 0,
  15569. y: -1
  15570. }, {
  15571. x: 1,
  15572. y: -1
  15573. }, {
  15574. x: 2,
  15575. y: -1
  15576. }, {
  15577. x: -3,
  15578. y: 0
  15579. }, {
  15580. x: -2,
  15581. y: 0
  15582. }, {
  15583. x: -1,
  15584. y: 0
  15585. }], [{
  15586. x: -1,
  15587. y: -2
  15588. }, {
  15589. x: 0,
  15590. y: -2
  15591. }, {
  15592. x: 1,
  15593. y: -2
  15594. }, {
  15595. x: -2,
  15596. y: -1
  15597. }, {
  15598. x: -1,
  15599. y: -1
  15600. }, {
  15601. x: 0,
  15602. y: -1
  15603. }, {
  15604. x: 1,
  15605. y: -1
  15606. }, {
  15607. x: -2,
  15608. y: 0
  15609. }, {
  15610. x: -1,
  15611. y: 0
  15612. }], [{
  15613. x: -3,
  15614. y: -1
  15615. }, {
  15616. x: -2,
  15617. y: -1
  15618. }, {
  15619. x: -1,
  15620. y: -1
  15621. }, {
  15622. x: 0,
  15623. y: -1
  15624. }, {
  15625. x: 1,
  15626. y: -1
  15627. }, {
  15628. x: -4,
  15629. y: 0
  15630. }, {
  15631. x: -3,
  15632. y: 0
  15633. }, {
  15634. x: -2,
  15635. y: 0
  15636. }, {
  15637. x: -1,
  15638. y: 0
  15639. }]];
  15640. const RefinementTemplates = [{
  15641. coding: [{
  15642. x: 0,
  15643. y: -1
  15644. }, {
  15645. x: 1,
  15646. y: -1
  15647. }, {
  15648. x: -1,
  15649. y: 0
  15650. }],
  15651. reference: [{
  15652. x: 0,
  15653. y: -1
  15654. }, {
  15655. x: 1,
  15656. y: -1
  15657. }, {
  15658. x: -1,
  15659. y: 0
  15660. }, {
  15661. x: 0,
  15662. y: 0
  15663. }, {
  15664. x: 1,
  15665. y: 0
  15666. }, {
  15667. x: -1,
  15668. y: 1
  15669. }, {
  15670. x: 0,
  15671. y: 1
  15672. }, {
  15673. x: 1,
  15674. y: 1
  15675. }]
  15676. }, {
  15677. coding: [{
  15678. x: -1,
  15679. y: -1
  15680. }, {
  15681. x: 0,
  15682. y: -1
  15683. }, {
  15684. x: 1,
  15685. y: -1
  15686. }, {
  15687. x: -1,
  15688. y: 0
  15689. }],
  15690. reference: [{
  15691. x: 0,
  15692. y: -1
  15693. }, {
  15694. x: -1,
  15695. y: 0
  15696. }, {
  15697. x: 0,
  15698. y: 0
  15699. }, {
  15700. x: 1,
  15701. y: 0
  15702. }, {
  15703. x: 0,
  15704. y: 1
  15705. }, {
  15706. x: 1,
  15707. y: 1
  15708. }]
  15709. }];
  15710. const ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
  15711. const RefinementReusedContexts = [0x0020, 0x0008];
  15712. function decodeBitmapTemplate0(width, height, decodingContext) {
  15713. const decoder = decodingContext.decoder;
  15714. const contexts = decodingContext.contextCache.getContexts("GB");
  15715. const bitmap = [];
  15716. let contextLabel, i, j, pixel, row, row1, row2;
  15717. const OLD_PIXEL_MASK = 0x7bf7;
  15718. for (i = 0; i < height; i++) {
  15719. row = bitmap[i] = new Uint8Array(width);
  15720. row1 = i < 1 ? row : bitmap[i - 1];
  15721. row2 = i < 2 ? row : bitmap[i - 2];
  15722. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  15723. for (j = 0; j < width; j++) {
  15724. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  15725. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  15726. }
  15727. }
  15728. return bitmap;
  15729. }
  15730. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  15731. if (mmr) {
  15732. const input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  15733. return decodeMMRBitmap(input, width, height, false);
  15734. }
  15735. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  15736. return decodeBitmapTemplate0(width, height, decodingContext);
  15737. }
  15738. const useskip = !!skip;
  15739. const template = CodingTemplates[templateIndex].concat(at);
  15740. template.sort(function (a, b) {
  15741. return a.y - b.y || a.x - b.x;
  15742. });
  15743. const templateLength = template.length;
  15744. const templateX = new Int8Array(templateLength);
  15745. const templateY = new Int8Array(templateLength);
  15746. const changingTemplateEntries = [];
  15747. let reuseMask = 0,
  15748. minX = 0,
  15749. maxX = 0,
  15750. minY = 0;
  15751. let c, k;
  15752. for (k = 0; k < templateLength; k++) {
  15753. templateX[k] = template[k].x;
  15754. templateY[k] = template[k].y;
  15755. minX = Math.min(minX, template[k].x);
  15756. maxX = Math.max(maxX, template[k].x);
  15757. minY = Math.min(minY, template[k].y);
  15758. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  15759. reuseMask |= 1 << templateLength - 1 - k;
  15760. } else {
  15761. changingTemplateEntries.push(k);
  15762. }
  15763. }
  15764. const changingEntriesLength = changingTemplateEntries.length;
  15765. const changingTemplateX = new Int8Array(changingEntriesLength);
  15766. const changingTemplateY = new Int8Array(changingEntriesLength);
  15767. const changingTemplateBit = new Uint16Array(changingEntriesLength);
  15768. for (c = 0; c < changingEntriesLength; c++) {
  15769. k = changingTemplateEntries[c];
  15770. changingTemplateX[c] = template[k].x;
  15771. changingTemplateY[c] = template[k].y;
  15772. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  15773. }
  15774. const sbb_left = -minX;
  15775. const sbb_top = -minY;
  15776. const sbb_right = width - maxX;
  15777. const pseudoPixelContext = ReusedContexts[templateIndex];
  15778. let row = new Uint8Array(width);
  15779. const bitmap = [];
  15780. const decoder = decodingContext.decoder;
  15781. const contexts = decodingContext.contextCache.getContexts("GB");
  15782. let ltp = 0,
  15783. j,
  15784. i0,
  15785. j0,
  15786. contextLabel = 0,
  15787. bit,
  15788. shift;
  15789. for (let i = 0; i < height; i++) {
  15790. if (prediction) {
  15791. const sltp = decoder.readBit(contexts, pseudoPixelContext);
  15792. ltp ^= sltp;
  15793. if (ltp) {
  15794. bitmap.push(row);
  15795. continue;
  15796. }
  15797. }
  15798. row = new Uint8Array(row);
  15799. bitmap.push(row);
  15800. for (j = 0; j < width; j++) {
  15801. if (useskip && skip[i][j]) {
  15802. row[j] = 0;
  15803. continue;
  15804. }
  15805. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  15806. contextLabel = contextLabel << 1 & reuseMask;
  15807. for (k = 0; k < changingEntriesLength; k++) {
  15808. i0 = i + changingTemplateY[k];
  15809. j0 = j + changingTemplateX[k];
  15810. bit = bitmap[i0][j0];
  15811. if (bit) {
  15812. bit = changingTemplateBit[k];
  15813. contextLabel |= bit;
  15814. }
  15815. }
  15816. } else {
  15817. contextLabel = 0;
  15818. shift = templateLength - 1;
  15819. for (k = 0; k < templateLength; k++, shift--) {
  15820. j0 = j + templateX[k];
  15821. if (j0 >= 0 && j0 < width) {
  15822. i0 = i + templateY[k];
  15823. if (i0 >= 0) {
  15824. bit = bitmap[i0][j0];
  15825. if (bit) {
  15826. contextLabel |= bit << shift;
  15827. }
  15828. }
  15829. }
  15830. }
  15831. }
  15832. const pixel = decoder.readBit(contexts, contextLabel);
  15833. row[j] = pixel;
  15834. }
  15835. }
  15836. return bitmap;
  15837. }
  15838. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  15839. let codingTemplate = RefinementTemplates[templateIndex].coding;
  15840. if (templateIndex === 0) {
  15841. codingTemplate = codingTemplate.concat([at[0]]);
  15842. }
  15843. const codingTemplateLength = codingTemplate.length;
  15844. const codingTemplateX = new Int32Array(codingTemplateLength);
  15845. const codingTemplateY = new Int32Array(codingTemplateLength);
  15846. let k;
  15847. for (k = 0; k < codingTemplateLength; k++) {
  15848. codingTemplateX[k] = codingTemplate[k].x;
  15849. codingTemplateY[k] = codingTemplate[k].y;
  15850. }
  15851. let referenceTemplate = RefinementTemplates[templateIndex].reference;
  15852. if (templateIndex === 0) {
  15853. referenceTemplate = referenceTemplate.concat([at[1]]);
  15854. }
  15855. const referenceTemplateLength = referenceTemplate.length;
  15856. const referenceTemplateX = new Int32Array(referenceTemplateLength);
  15857. const referenceTemplateY = new Int32Array(referenceTemplateLength);
  15858. for (k = 0; k < referenceTemplateLength; k++) {
  15859. referenceTemplateX[k] = referenceTemplate[k].x;
  15860. referenceTemplateY[k] = referenceTemplate[k].y;
  15861. }
  15862. const referenceWidth = referenceBitmap[0].length;
  15863. const referenceHeight = referenceBitmap.length;
  15864. const pseudoPixelContext = RefinementReusedContexts[templateIndex];
  15865. const bitmap = [];
  15866. const decoder = decodingContext.decoder;
  15867. const contexts = decodingContext.contextCache.getContexts("GR");
  15868. let ltp = 0;
  15869. for (let i = 0; i < height; i++) {
  15870. if (prediction) {
  15871. const sltp = decoder.readBit(contexts, pseudoPixelContext);
  15872. ltp ^= sltp;
  15873. if (ltp) {
  15874. throw new Jbig2Error("prediction is not supported");
  15875. }
  15876. }
  15877. const row = new Uint8Array(width);
  15878. bitmap.push(row);
  15879. for (let j = 0; j < width; j++) {
  15880. let i0, j0;
  15881. let contextLabel = 0;
  15882. for (k = 0; k < codingTemplateLength; k++) {
  15883. i0 = i + codingTemplateY[k];
  15884. j0 = j + codingTemplateX[k];
  15885. if (i0 < 0 || j0 < 0 || j0 >= width) {
  15886. contextLabel <<= 1;
  15887. } else {
  15888. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  15889. }
  15890. }
  15891. for (k = 0; k < referenceTemplateLength; k++) {
  15892. i0 = i + referenceTemplateY[k] - offsetY;
  15893. j0 = j + referenceTemplateX[k] - offsetX;
  15894. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  15895. contextLabel <<= 1;
  15896. } else {
  15897. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  15898. }
  15899. }
  15900. const pixel = decoder.readBit(contexts, contextLabel);
  15901. row[j] = pixel;
  15902. }
  15903. }
  15904. return bitmap;
  15905. }
  15906. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
  15907. if (huffman && refinement) {
  15908. throw new Jbig2Error("symbol refinement with Huffman is not supported");
  15909. }
  15910. const newSymbols = [];
  15911. let currentHeight = 0;
  15912. let symbolCodeLength = (0, _core_utils.log2)(symbols.length + numberOfNewSymbols);
  15913. const decoder = decodingContext.decoder;
  15914. const contextCache = decodingContext.contextCache;
  15915. let tableB1, symbolWidths;
  15916. if (huffman) {
  15917. tableB1 = getStandardTable(1);
  15918. symbolWidths = [];
  15919. symbolCodeLength = Math.max(symbolCodeLength, 1);
  15920. }
  15921. while (newSymbols.length < numberOfNewSymbols) {
  15922. const deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, "IADH", decoder);
  15923. currentHeight += deltaHeight;
  15924. let currentWidth = 0,
  15925. totalWidth = 0;
  15926. const firstSymbol = huffman ? symbolWidths.length : 0;
  15927. while (true) {
  15928. const deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, "IADW", decoder);
  15929. if (deltaWidth === null) {
  15930. break;
  15931. }
  15932. currentWidth += deltaWidth;
  15933. totalWidth += currentWidth;
  15934. let bitmap;
  15935. if (refinement) {
  15936. const numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
  15937. if (numberOfInstances > 1) {
  15938. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
  15939. } else {
  15940. const symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  15941. const rdx = decodeInteger(contextCache, "IARDX", decoder);
  15942. const rdy = decodeInteger(contextCache, "IARDY", decoder);
  15943. const symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  15944. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  15945. }
  15946. newSymbols.push(bitmap);
  15947. } else if (huffman) {
  15948. symbolWidths.push(currentWidth);
  15949. } else {
  15950. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  15951. newSymbols.push(bitmap);
  15952. }
  15953. }
  15954. if (huffman && !refinement) {
  15955. const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
  15956. huffmanInput.byteAlign();
  15957. let collectiveBitmap;
  15958. if (bitmapSize === 0) {
  15959. collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
  15960. } else {
  15961. const originalEnd = huffmanInput.end;
  15962. const bitmapEnd = huffmanInput.position + bitmapSize;
  15963. huffmanInput.end = bitmapEnd;
  15964. collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
  15965. huffmanInput.end = originalEnd;
  15966. huffmanInput.position = bitmapEnd;
  15967. }
  15968. const numberOfSymbolsDecoded = symbolWidths.length;
  15969. if (firstSymbol === numberOfSymbolsDecoded - 1) {
  15970. newSymbols.push(collectiveBitmap);
  15971. } else {
  15972. let i,
  15973. y,
  15974. xMin = 0,
  15975. xMax,
  15976. bitmapWidth,
  15977. symbolBitmap;
  15978. for (i = firstSymbol; i < numberOfSymbolsDecoded; i++) {
  15979. bitmapWidth = symbolWidths[i];
  15980. xMax = xMin + bitmapWidth;
  15981. symbolBitmap = [];
  15982. for (y = 0; y < currentHeight; y++) {
  15983. symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  15984. }
  15985. newSymbols.push(symbolBitmap);
  15986. xMin = xMax;
  15987. }
  15988. }
  15989. }
  15990. }
  15991. const exportedSymbols = [],
  15992. flags = [];
  15993. let currentFlag = false,
  15994. i,
  15995. ii;
  15996. const totalSymbolsLength = symbols.length + numberOfNewSymbols;
  15997. while (flags.length < totalSymbolsLength) {
  15998. let runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, "IAEX", decoder);
  15999. while (runLength--) {
  16000. flags.push(currentFlag);
  16001. }
  16002. currentFlag = !currentFlag;
  16003. }
  16004. for (i = 0, ii = symbols.length; i < ii; i++) {
  16005. if (flags[i]) {
  16006. exportedSymbols.push(symbols[i]);
  16007. }
  16008. }
  16009. for (let j = 0; j < numberOfNewSymbols; i++, j++) {
  16010. if (flags[i]) {
  16011. exportedSymbols.push(newSymbols[j]);
  16012. }
  16013. }
  16014. return exportedSymbols;
  16015. }
  16016. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
  16017. if (huffman && refinement) {
  16018. throw new Jbig2Error("refinement with Huffman is not supported");
  16019. }
  16020. const bitmap = [];
  16021. let i, row;
  16022. for (i = 0; i < height; i++) {
  16023. row = new Uint8Array(width);
  16024. if (defaultPixelValue) {
  16025. for (let j = 0; j < width; j++) {
  16026. row[j] = defaultPixelValue;
  16027. }
  16028. }
  16029. bitmap.push(row);
  16030. }
  16031. const decoder = decodingContext.decoder;
  16032. const contextCache = decodingContext.contextCache;
  16033. let stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, "IADT", decoder);
  16034. let firstS = 0;
  16035. i = 0;
  16036. while (i < numberOfSymbolInstances) {
  16037. const deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, "IADT", decoder);
  16038. stripT += deltaT;
  16039. const deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, "IAFS", decoder);
  16040. firstS += deltaFirstS;
  16041. let currentS = firstS;
  16042. do {
  16043. let currentT = 0;
  16044. if (stripSize > 1) {
  16045. currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, "IAIT", decoder);
  16046. }
  16047. const t = stripSize * stripT + currentT;
  16048. const symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
  16049. const applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, "IARI", decoder));
  16050. let symbolBitmap = inputSymbols[symbolId];
  16051. let symbolWidth = symbolBitmap[0].length;
  16052. let symbolHeight = symbolBitmap.length;
  16053. if (applyRefinement) {
  16054. const rdw = decodeInteger(contextCache, "IARDW", decoder);
  16055. const rdh = decodeInteger(contextCache, "IARDH", decoder);
  16056. const rdx = decodeInteger(contextCache, "IARDX", decoder);
  16057. const rdy = decodeInteger(contextCache, "IARDY", decoder);
  16058. symbolWidth += rdw;
  16059. symbolHeight += rdh;
  16060. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  16061. }
  16062. const offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  16063. const offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  16064. let s2, t2, symbolRow;
  16065. if (transposed) {
  16066. for (s2 = 0; s2 < symbolHeight; s2++) {
  16067. row = bitmap[offsetS + s2];
  16068. if (!row) {
  16069. continue;
  16070. }
  16071. symbolRow = symbolBitmap[s2];
  16072. const maxWidth = Math.min(width - offsetT, symbolWidth);
  16073. switch (combinationOperator) {
  16074. case 0:
  16075. for (t2 = 0; t2 < maxWidth; t2++) {
  16076. row[offsetT + t2] |= symbolRow[t2];
  16077. }
  16078. break;
  16079. case 2:
  16080. for (t2 = 0; t2 < maxWidth; t2++) {
  16081. row[offsetT + t2] ^= symbolRow[t2];
  16082. }
  16083. break;
  16084. default:
  16085. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  16086. }
  16087. }
  16088. currentS += symbolHeight - 1;
  16089. } else {
  16090. for (t2 = 0; t2 < symbolHeight; t2++) {
  16091. row = bitmap[offsetT + t2];
  16092. if (!row) {
  16093. continue;
  16094. }
  16095. symbolRow = symbolBitmap[t2];
  16096. switch (combinationOperator) {
  16097. case 0:
  16098. for (s2 = 0; s2 < symbolWidth; s2++) {
  16099. row[offsetS + s2] |= symbolRow[s2];
  16100. }
  16101. break;
  16102. case 2:
  16103. for (s2 = 0; s2 < symbolWidth; s2++) {
  16104. row[offsetS + s2] ^= symbolRow[s2];
  16105. }
  16106. break;
  16107. default:
  16108. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  16109. }
  16110. }
  16111. currentS += symbolWidth - 1;
  16112. }
  16113. i++;
  16114. const deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, "IADS", decoder);
  16115. if (deltaS === null) {
  16116. break;
  16117. }
  16118. currentS += deltaS + dsOffset;
  16119. } while (true);
  16120. }
  16121. return bitmap;
  16122. }
  16123. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  16124. const at = [];
  16125. if (!mmr) {
  16126. at.push({
  16127. x: -patternWidth,
  16128. y: 0
  16129. });
  16130. if (template === 0) {
  16131. at.push({
  16132. x: -3,
  16133. y: -1
  16134. }, {
  16135. x: 2,
  16136. y: -2
  16137. }, {
  16138. x: -2,
  16139. y: -2
  16140. });
  16141. }
  16142. }
  16143. const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  16144. const collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  16145. const patterns = [];
  16146. for (let i = 0; i <= maxPatternIndex; i++) {
  16147. const patternBitmap = [];
  16148. const xMin = patternWidth * i;
  16149. const xMax = xMin + patternWidth;
  16150. for (let y = 0; y < patternHeight; y++) {
  16151. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  16152. }
  16153. patterns.push(patternBitmap);
  16154. }
  16155. return patterns;
  16156. }
  16157. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  16158. const skip = null;
  16159. if (enableSkip) {
  16160. throw new Jbig2Error("skip is not supported");
  16161. }
  16162. if (combinationOperator !== 0) {
  16163. throw new Jbig2Error(`operator "${combinationOperator}" is not supported in halftone region`);
  16164. }
  16165. const regionBitmap = [];
  16166. let i, j, row;
  16167. for (i = 0; i < regionHeight; i++) {
  16168. row = new Uint8Array(regionWidth);
  16169. if (defaultPixelValue) {
  16170. for (j = 0; j < regionWidth; j++) {
  16171. row[j] = defaultPixelValue;
  16172. }
  16173. }
  16174. regionBitmap.push(row);
  16175. }
  16176. const numberOfPatterns = patterns.length;
  16177. const pattern0 = patterns[0];
  16178. const patternWidth = pattern0[0].length,
  16179. patternHeight = pattern0.length;
  16180. const bitsPerValue = (0, _core_utils.log2)(numberOfPatterns);
  16181. const at = [];
  16182. if (!mmr) {
  16183. at.push({
  16184. x: template <= 1 ? 3 : 2,
  16185. y: -1
  16186. });
  16187. if (template === 0) {
  16188. at.push({
  16189. x: -3,
  16190. y: -1
  16191. }, {
  16192. x: 2,
  16193. y: -2
  16194. }, {
  16195. x: -2,
  16196. y: -2
  16197. });
  16198. }
  16199. }
  16200. const grayScaleBitPlanes = [];
  16201. let mmrInput, bitmap;
  16202. if (mmr) {
  16203. mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  16204. }
  16205. for (i = bitsPerValue - 1; i >= 0; i--) {
  16206. if (mmr) {
  16207. bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
  16208. } else {
  16209. bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  16210. }
  16211. grayScaleBitPlanes[i] = bitmap;
  16212. }
  16213. let mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
  16214. for (mg = 0; mg < gridHeight; mg++) {
  16215. for (ng = 0; ng < gridWidth; ng++) {
  16216. bit = 0;
  16217. patternIndex = 0;
  16218. for (j = bitsPerValue - 1; j >= 0; j--) {
  16219. bit ^= grayScaleBitPlanes[j][mg][ng];
  16220. patternIndex |= bit << j;
  16221. }
  16222. patternBitmap = patterns[patternIndex];
  16223. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  16224. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  16225. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  16226. for (i = 0; i < patternHeight; i++) {
  16227. regionRow = regionBitmap[y + i];
  16228. patternRow = patternBitmap[i];
  16229. for (j = 0; j < patternWidth; j++) {
  16230. regionRow[x + j] |= patternRow[j];
  16231. }
  16232. }
  16233. } else {
  16234. let regionX, regionY;
  16235. for (i = 0; i < patternHeight; i++) {
  16236. regionY = y + i;
  16237. if (regionY < 0 || regionY >= regionHeight) {
  16238. continue;
  16239. }
  16240. regionRow = regionBitmap[regionY];
  16241. patternRow = patternBitmap[i];
  16242. for (j = 0; j < patternWidth; j++) {
  16243. regionX = x + j;
  16244. if (regionX >= 0 && regionX < regionWidth) {
  16245. regionRow[regionX] |= patternRow[j];
  16246. }
  16247. }
  16248. }
  16249. }
  16250. }
  16251. }
  16252. return regionBitmap;
  16253. }
  16254. function readSegmentHeader(data, start) {
  16255. const segmentHeader = {};
  16256. segmentHeader.number = (0, _core_utils.readUint32)(data, start);
  16257. const flags = data[start + 4];
  16258. const segmentType = flags & 0x3f;
  16259. if (!SegmentTypes[segmentType]) {
  16260. throw new Jbig2Error("invalid segment type: " + segmentType);
  16261. }
  16262. segmentHeader.type = segmentType;
  16263. segmentHeader.typeName = SegmentTypes[segmentType];
  16264. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  16265. const pageAssociationFieldSize = !!(flags & 0x40);
  16266. const referredFlags = data[start + 5];
  16267. let referredToCount = referredFlags >> 5 & 7;
  16268. const retainBits = [referredFlags & 31];
  16269. let position = start + 6;
  16270. if (referredFlags === 7) {
  16271. referredToCount = (0, _core_utils.readUint32)(data, position - 1) & 0x1fffffff;
  16272. position += 3;
  16273. let bytes = referredToCount + 7 >> 3;
  16274. retainBits[0] = data[position++];
  16275. while (--bytes > 0) {
  16276. retainBits.push(data[position++]);
  16277. }
  16278. } else if (referredFlags === 5 || referredFlags === 6) {
  16279. throw new Jbig2Error("invalid referred-to flags");
  16280. }
  16281. segmentHeader.retainBits = retainBits;
  16282. let referredToSegmentNumberSize = 4;
  16283. if (segmentHeader.number <= 256) {
  16284. referredToSegmentNumberSize = 1;
  16285. } else if (segmentHeader.number <= 65536) {
  16286. referredToSegmentNumberSize = 2;
  16287. }
  16288. const referredTo = [];
  16289. let i, ii;
  16290. for (i = 0; i < referredToCount; i++) {
  16291. let number;
  16292. if (referredToSegmentNumberSize === 1) {
  16293. number = data[position];
  16294. } else if (referredToSegmentNumberSize === 2) {
  16295. number = (0, _core_utils.readUint16)(data, position);
  16296. } else {
  16297. number = (0, _core_utils.readUint32)(data, position);
  16298. }
  16299. referredTo.push(number);
  16300. position += referredToSegmentNumberSize;
  16301. }
  16302. segmentHeader.referredTo = referredTo;
  16303. if (!pageAssociationFieldSize) {
  16304. segmentHeader.pageAssociation = data[position++];
  16305. } else {
  16306. segmentHeader.pageAssociation = (0, _core_utils.readUint32)(data, position);
  16307. position += 4;
  16308. }
  16309. segmentHeader.length = (0, _core_utils.readUint32)(data, position);
  16310. position += 4;
  16311. if (segmentHeader.length === 0xffffffff) {
  16312. if (segmentType === 38) {
  16313. const genericRegionInfo = readRegionSegmentInformation(data, position);
  16314. const genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  16315. const genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  16316. const searchPatternLength = 6;
  16317. const searchPattern = new Uint8Array(searchPatternLength);
  16318. if (!genericRegionMmr) {
  16319. searchPattern[0] = 0xff;
  16320. searchPattern[1] = 0xac;
  16321. }
  16322. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xff;
  16323. searchPattern[3] = genericRegionInfo.height >> 16 & 0xff;
  16324. searchPattern[4] = genericRegionInfo.height >> 8 & 0xff;
  16325. searchPattern[5] = genericRegionInfo.height & 0xff;
  16326. for (i = position, ii = data.length; i < ii; i++) {
  16327. let j = 0;
  16328. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  16329. j++;
  16330. }
  16331. if (j === searchPatternLength) {
  16332. segmentHeader.length = i + searchPatternLength;
  16333. break;
  16334. }
  16335. }
  16336. if (segmentHeader.length === 0xffffffff) {
  16337. throw new Jbig2Error("segment end was not found");
  16338. }
  16339. } else {
  16340. throw new Jbig2Error("invalid unknown segment length");
  16341. }
  16342. }
  16343. segmentHeader.headerEnd = position;
  16344. return segmentHeader;
  16345. }
  16346. function readSegments(header, data, start, end) {
  16347. const segments = [];
  16348. let position = start;
  16349. while (position < end) {
  16350. const segmentHeader = readSegmentHeader(data, position);
  16351. position = segmentHeader.headerEnd;
  16352. const segment = {
  16353. header: segmentHeader,
  16354. data
  16355. };
  16356. if (!header.randomAccess) {
  16357. segment.start = position;
  16358. position += segmentHeader.length;
  16359. segment.end = position;
  16360. }
  16361. segments.push(segment);
  16362. if (segmentHeader.type === 51) {
  16363. break;
  16364. }
  16365. }
  16366. if (header.randomAccess) {
  16367. for (let i = 0, ii = segments.length; i < ii; i++) {
  16368. segments[i].start = position;
  16369. position += segments[i].header.length;
  16370. segments[i].end = position;
  16371. }
  16372. }
  16373. return segments;
  16374. }
  16375. function readRegionSegmentInformation(data, start) {
  16376. return {
  16377. width: (0, _core_utils.readUint32)(data, start),
  16378. height: (0, _core_utils.readUint32)(data, start + 4),
  16379. x: (0, _core_utils.readUint32)(data, start + 8),
  16380. y: (0, _core_utils.readUint32)(data, start + 12),
  16381. combinationOperator: data[start + 16] & 7
  16382. };
  16383. }
  16384. const RegionSegmentInformationFieldLength = 17;
  16385. function processSegment(segment, visitor) {
  16386. const header = segment.header;
  16387. const data = segment.data,
  16388. end = segment.end;
  16389. let position = segment.start;
  16390. let args, at, i, atLength;
  16391. switch (header.type) {
  16392. case 0:
  16393. const dictionary = {};
  16394. const dictionaryFlags = (0, _core_utils.readUint16)(data, position);
  16395. dictionary.huffman = !!(dictionaryFlags & 1);
  16396. dictionary.refinement = !!(dictionaryFlags & 2);
  16397. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  16398. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  16399. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  16400. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  16401. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  16402. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  16403. dictionary.template = dictionaryFlags >> 10 & 3;
  16404. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  16405. position += 2;
  16406. if (!dictionary.huffman) {
  16407. atLength = dictionary.template === 0 ? 4 : 1;
  16408. at = [];
  16409. for (i = 0; i < atLength; i++) {
  16410. at.push({
  16411. x: (0, _core_utils.readInt8)(data, position),
  16412. y: (0, _core_utils.readInt8)(data, position + 1)
  16413. });
  16414. position += 2;
  16415. }
  16416. dictionary.at = at;
  16417. }
  16418. if (dictionary.refinement && !dictionary.refinementTemplate) {
  16419. at = [];
  16420. for (i = 0; i < 2; i++) {
  16421. at.push({
  16422. x: (0, _core_utils.readInt8)(data, position),
  16423. y: (0, _core_utils.readInt8)(data, position + 1)
  16424. });
  16425. position += 2;
  16426. }
  16427. dictionary.refinementAt = at;
  16428. }
  16429. dictionary.numberOfExportedSymbols = (0, _core_utils.readUint32)(data, position);
  16430. position += 4;
  16431. dictionary.numberOfNewSymbols = (0, _core_utils.readUint32)(data, position);
  16432. position += 4;
  16433. args = [dictionary, header.number, header.referredTo, data, position, end];
  16434. break;
  16435. case 6:
  16436. case 7:
  16437. const textRegion = {};
  16438. textRegion.info = readRegionSegmentInformation(data, position);
  16439. position += RegionSegmentInformationFieldLength;
  16440. const textRegionSegmentFlags = (0, _core_utils.readUint16)(data, position);
  16441. position += 2;
  16442. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  16443. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  16444. textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
  16445. textRegion.stripSize = 1 << textRegion.logStripSize;
  16446. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  16447. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  16448. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  16449. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  16450. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  16451. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  16452. if (textRegion.huffman) {
  16453. const textRegionHuffmanFlags = (0, _core_utils.readUint16)(data, position);
  16454. position += 2;
  16455. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  16456. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  16457. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  16458. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  16459. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  16460. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  16461. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  16462. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
  16463. }
  16464. if (textRegion.refinement && !textRegion.refinementTemplate) {
  16465. at = [];
  16466. for (i = 0; i < 2; i++) {
  16467. at.push({
  16468. x: (0, _core_utils.readInt8)(data, position),
  16469. y: (0, _core_utils.readInt8)(data, position + 1)
  16470. });
  16471. position += 2;
  16472. }
  16473. textRegion.refinementAt = at;
  16474. }
  16475. textRegion.numberOfSymbolInstances = (0, _core_utils.readUint32)(data, position);
  16476. position += 4;
  16477. args = [textRegion, header.referredTo, data, position, end];
  16478. break;
  16479. case 16:
  16480. const patternDictionary = {};
  16481. const patternDictionaryFlags = data[position++];
  16482. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  16483. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  16484. patternDictionary.patternWidth = data[position++];
  16485. patternDictionary.patternHeight = data[position++];
  16486. patternDictionary.maxPatternIndex = (0, _core_utils.readUint32)(data, position);
  16487. position += 4;
  16488. args = [patternDictionary, header.number, data, position, end];
  16489. break;
  16490. case 22:
  16491. case 23:
  16492. const halftoneRegion = {};
  16493. halftoneRegion.info = readRegionSegmentInformation(data, position);
  16494. position += RegionSegmentInformationFieldLength;
  16495. const halftoneRegionFlags = data[position++];
  16496. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  16497. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  16498. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  16499. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  16500. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  16501. halftoneRegion.gridWidth = (0, _core_utils.readUint32)(data, position);
  16502. position += 4;
  16503. halftoneRegion.gridHeight = (0, _core_utils.readUint32)(data, position);
  16504. position += 4;
  16505. halftoneRegion.gridOffsetX = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  16506. position += 4;
  16507. halftoneRegion.gridOffsetY = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  16508. position += 4;
  16509. halftoneRegion.gridVectorX = (0, _core_utils.readUint16)(data, position);
  16510. position += 2;
  16511. halftoneRegion.gridVectorY = (0, _core_utils.readUint16)(data, position);
  16512. position += 2;
  16513. args = [halftoneRegion, header.referredTo, data, position, end];
  16514. break;
  16515. case 38:
  16516. case 39:
  16517. const genericRegion = {};
  16518. genericRegion.info = readRegionSegmentInformation(data, position);
  16519. position += RegionSegmentInformationFieldLength;
  16520. const genericRegionSegmentFlags = data[position++];
  16521. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  16522. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  16523. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  16524. if (!genericRegion.mmr) {
  16525. atLength = genericRegion.template === 0 ? 4 : 1;
  16526. at = [];
  16527. for (i = 0; i < atLength; i++) {
  16528. at.push({
  16529. x: (0, _core_utils.readInt8)(data, position),
  16530. y: (0, _core_utils.readInt8)(data, position + 1)
  16531. });
  16532. position += 2;
  16533. }
  16534. genericRegion.at = at;
  16535. }
  16536. args = [genericRegion, data, position, end];
  16537. break;
  16538. case 48:
  16539. const pageInfo = {
  16540. width: (0, _core_utils.readUint32)(data, position),
  16541. height: (0, _core_utils.readUint32)(data, position + 4),
  16542. resolutionX: (0, _core_utils.readUint32)(data, position + 8),
  16543. resolutionY: (0, _core_utils.readUint32)(data, position + 12)
  16544. };
  16545. if (pageInfo.height === 0xffffffff) {
  16546. delete pageInfo.height;
  16547. }
  16548. const pageSegmentFlags = data[position + 16];
  16549. (0, _core_utils.readUint16)(data, position + 17);
  16550. pageInfo.lossless = !!(pageSegmentFlags & 1);
  16551. pageInfo.refinement = !!(pageSegmentFlags & 2);
  16552. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  16553. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  16554. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  16555. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  16556. args = [pageInfo];
  16557. break;
  16558. case 49:
  16559. break;
  16560. case 50:
  16561. break;
  16562. case 51:
  16563. break;
  16564. case 53:
  16565. args = [header.number, data, position, end];
  16566. break;
  16567. case 62:
  16568. break;
  16569. default:
  16570. throw new Jbig2Error(`segment type ${header.typeName}(${header.type}) is not implemented`);
  16571. }
  16572. const callbackName = "on" + header.typeName;
  16573. if (callbackName in visitor) {
  16574. visitor[callbackName].apply(visitor, args);
  16575. }
  16576. }
  16577. function processSegments(segments, visitor) {
  16578. for (let i = 0, ii = segments.length; i < ii; i++) {
  16579. processSegment(segments[i], visitor);
  16580. }
  16581. }
  16582. function parseJbig2Chunks(chunks) {
  16583. const visitor = new SimpleSegmentVisitor();
  16584. for (let i = 0, ii = chunks.length; i < ii; i++) {
  16585. const chunk = chunks[i];
  16586. const segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  16587. processSegments(segments, visitor);
  16588. }
  16589. return visitor.buffer;
  16590. }
  16591. function parseJbig2(data) {
  16592. throw new Error("Not implemented: parseJbig2");
  16593. }
  16594. class SimpleSegmentVisitor {
  16595. onPageInformation(info) {
  16596. this.currentPageInfo = info;
  16597. const rowSize = info.width + 7 >> 3;
  16598. const buffer = new Uint8ClampedArray(rowSize * info.height);
  16599. if (info.defaultPixelValue) {
  16600. buffer.fill(0xff);
  16601. }
  16602. this.buffer = buffer;
  16603. }
  16604. drawBitmap(regionInfo, bitmap) {
  16605. const pageInfo = this.currentPageInfo;
  16606. const width = regionInfo.width,
  16607. height = regionInfo.height;
  16608. const rowSize = pageInfo.width + 7 >> 3;
  16609. const combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  16610. const buffer = this.buffer;
  16611. const mask0 = 128 >> (regionInfo.x & 7);
  16612. let offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  16613. let i, j, mask, offset;
  16614. switch (combinationOperator) {
  16615. case 0:
  16616. for (i = 0; i < height; i++) {
  16617. mask = mask0;
  16618. offset = offset0;
  16619. for (j = 0; j < width; j++) {
  16620. if (bitmap[i][j]) {
  16621. buffer[offset] |= mask;
  16622. }
  16623. mask >>= 1;
  16624. if (!mask) {
  16625. mask = 128;
  16626. offset++;
  16627. }
  16628. }
  16629. offset0 += rowSize;
  16630. }
  16631. break;
  16632. case 2:
  16633. for (i = 0; i < height; i++) {
  16634. mask = mask0;
  16635. offset = offset0;
  16636. for (j = 0; j < width; j++) {
  16637. if (bitmap[i][j]) {
  16638. buffer[offset] ^= mask;
  16639. }
  16640. mask >>= 1;
  16641. if (!mask) {
  16642. mask = 128;
  16643. offset++;
  16644. }
  16645. }
  16646. offset0 += rowSize;
  16647. }
  16648. break;
  16649. default:
  16650. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  16651. }
  16652. }
  16653. onImmediateGenericRegion(region, data, start, end) {
  16654. const regionInfo = region.info;
  16655. const decodingContext = new DecodingContext(data, start, end);
  16656. const bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  16657. this.drawBitmap(regionInfo, bitmap);
  16658. }
  16659. onImmediateLosslessGenericRegion() {
  16660. this.onImmediateGenericRegion(...arguments);
  16661. }
  16662. onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  16663. let huffmanTables, huffmanInput;
  16664. if (dictionary.huffman) {
  16665. huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
  16666. huffmanInput = new Reader(data, start, end);
  16667. }
  16668. let symbols = this.symbols;
  16669. if (!symbols) {
  16670. this.symbols = symbols = {};
  16671. }
  16672. const inputSymbols = [];
  16673. for (const referredSegment of referredSegments) {
  16674. const referredSymbols = symbols[referredSegment];
  16675. if (referredSymbols) {
  16676. inputSymbols.push(...referredSymbols);
  16677. }
  16678. }
  16679. const decodingContext = new DecodingContext(data, start, end);
  16680. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
  16681. }
  16682. onImmediateTextRegion(region, referredSegments, data, start, end) {
  16683. const regionInfo = region.info;
  16684. let huffmanTables, huffmanInput;
  16685. const symbols = this.symbols;
  16686. const inputSymbols = [];
  16687. for (const referredSegment of referredSegments) {
  16688. const referredSymbols = symbols[referredSegment];
  16689. if (referredSymbols) {
  16690. inputSymbols.push(...referredSymbols);
  16691. }
  16692. }
  16693. const symbolCodeLength = (0, _core_utils.log2)(inputSymbols.length);
  16694. if (region.huffman) {
  16695. huffmanInput = new Reader(data, start, end);
  16696. huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
  16697. }
  16698. const decodingContext = new DecodingContext(data, start, end);
  16699. const bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext, region.logStripSize, huffmanInput);
  16700. this.drawBitmap(regionInfo, bitmap);
  16701. }
  16702. onImmediateLosslessTextRegion() {
  16703. this.onImmediateTextRegion(...arguments);
  16704. }
  16705. onPatternDictionary(dictionary, currentSegment, data, start, end) {
  16706. let patterns = this.patterns;
  16707. if (!patterns) {
  16708. this.patterns = patterns = {};
  16709. }
  16710. const decodingContext = new DecodingContext(data, start, end);
  16711. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  16712. }
  16713. onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  16714. const patterns = this.patterns[referredSegments[0]];
  16715. const regionInfo = region.info;
  16716. const decodingContext = new DecodingContext(data, start, end);
  16717. const bitmap = decodeHalftoneRegion(region.mmr, patterns, region.template, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.enableSkip, region.combinationOperator, region.gridWidth, region.gridHeight, region.gridOffsetX, region.gridOffsetY, region.gridVectorX, region.gridVectorY, decodingContext);
  16718. this.drawBitmap(regionInfo, bitmap);
  16719. }
  16720. onImmediateLosslessHalftoneRegion() {
  16721. this.onImmediateHalftoneRegion(...arguments);
  16722. }
  16723. onTables(currentSegment, data, start, end) {
  16724. let customTables = this.customTables;
  16725. if (!customTables) {
  16726. this.customTables = customTables = {};
  16727. }
  16728. customTables[currentSegment] = decodeTablesSegment(data, start, end);
  16729. }
  16730. }
  16731. class HuffmanLine {
  16732. constructor(lineData) {
  16733. if (lineData.length === 2) {
  16734. this.isOOB = true;
  16735. this.rangeLow = 0;
  16736. this.prefixLength = lineData[0];
  16737. this.rangeLength = 0;
  16738. this.prefixCode = lineData[1];
  16739. this.isLowerRange = false;
  16740. } else {
  16741. this.isOOB = false;
  16742. this.rangeLow = lineData[0];
  16743. this.prefixLength = lineData[1];
  16744. this.rangeLength = lineData[2];
  16745. this.prefixCode = lineData[3];
  16746. this.isLowerRange = lineData[4] === "lower";
  16747. }
  16748. }
  16749. }
  16750. class HuffmanTreeNode {
  16751. constructor(line) {
  16752. this.children = [];
  16753. if (line) {
  16754. this.isLeaf = true;
  16755. this.rangeLength = line.rangeLength;
  16756. this.rangeLow = line.rangeLow;
  16757. this.isLowerRange = line.isLowerRange;
  16758. this.isOOB = line.isOOB;
  16759. } else {
  16760. this.isLeaf = false;
  16761. }
  16762. }
  16763. buildTree(line, shift) {
  16764. const bit = line.prefixCode >> shift & 1;
  16765. if (shift <= 0) {
  16766. this.children[bit] = new HuffmanTreeNode(line);
  16767. } else {
  16768. let node = this.children[bit];
  16769. if (!node) {
  16770. this.children[bit] = node = new HuffmanTreeNode(null);
  16771. }
  16772. node.buildTree(line, shift - 1);
  16773. }
  16774. }
  16775. decodeNode(reader) {
  16776. if (this.isLeaf) {
  16777. if (this.isOOB) {
  16778. return null;
  16779. }
  16780. const htOffset = reader.readBits(this.rangeLength);
  16781. return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
  16782. }
  16783. const node = this.children[reader.readBit()];
  16784. if (!node) {
  16785. throw new Jbig2Error("invalid Huffman data");
  16786. }
  16787. return node.decodeNode(reader);
  16788. }
  16789. }
  16790. class HuffmanTable {
  16791. constructor(lines, prefixCodesDone) {
  16792. if (!prefixCodesDone) {
  16793. this.assignPrefixCodes(lines);
  16794. }
  16795. this.rootNode = new HuffmanTreeNode(null);
  16796. for (let i = 0, ii = lines.length; i < ii; i++) {
  16797. const line = lines[i];
  16798. if (line.prefixLength > 0) {
  16799. this.rootNode.buildTree(line, line.prefixLength - 1);
  16800. }
  16801. }
  16802. }
  16803. decode(reader) {
  16804. return this.rootNode.decodeNode(reader);
  16805. }
  16806. assignPrefixCodes(lines) {
  16807. const linesLength = lines.length;
  16808. let prefixLengthMax = 0;
  16809. for (let i = 0; i < linesLength; i++) {
  16810. prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
  16811. }
  16812. const histogram = new Uint32Array(prefixLengthMax + 1);
  16813. for (let i = 0; i < linesLength; i++) {
  16814. histogram[lines[i].prefixLength]++;
  16815. }
  16816. let currentLength = 1,
  16817. firstCode = 0,
  16818. currentCode,
  16819. currentTemp,
  16820. line;
  16821. histogram[0] = 0;
  16822. while (currentLength <= prefixLengthMax) {
  16823. firstCode = firstCode + histogram[currentLength - 1] << 1;
  16824. currentCode = firstCode;
  16825. currentTemp = 0;
  16826. while (currentTemp < linesLength) {
  16827. line = lines[currentTemp];
  16828. if (line.prefixLength === currentLength) {
  16829. line.prefixCode = currentCode;
  16830. currentCode++;
  16831. }
  16832. currentTemp++;
  16833. }
  16834. currentLength++;
  16835. }
  16836. }
  16837. }
  16838. function decodeTablesSegment(data, start, end) {
  16839. const flags = data[start];
  16840. const lowestValue = (0, _core_utils.readUint32)(data, start + 1) & 0xffffffff;
  16841. const highestValue = (0, _core_utils.readUint32)(data, start + 5) & 0xffffffff;
  16842. const reader = new Reader(data, start + 9, end);
  16843. const prefixSizeBits = (flags >> 1 & 7) + 1;
  16844. const rangeSizeBits = (flags >> 4 & 7) + 1;
  16845. const lines = [];
  16846. let prefixLength,
  16847. rangeLength,
  16848. currentRangeLow = lowestValue;
  16849. do {
  16850. prefixLength = reader.readBits(prefixSizeBits);
  16851. rangeLength = reader.readBits(rangeSizeBits);
  16852. lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
  16853. currentRangeLow += 1 << rangeLength;
  16854. } while (currentRangeLow < highestValue);
  16855. prefixLength = reader.readBits(prefixSizeBits);
  16856. lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"]));
  16857. prefixLength = reader.readBits(prefixSizeBits);
  16858. lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
  16859. if (flags & 1) {
  16860. prefixLength = reader.readBits(prefixSizeBits);
  16861. lines.push(new HuffmanLine([prefixLength, 0]));
  16862. }
  16863. return new HuffmanTable(lines, false);
  16864. }
  16865. const standardTablesCache = {};
  16866. function getStandardTable(number) {
  16867. let table = standardTablesCache[number];
  16868. if (table) {
  16869. return table;
  16870. }
  16871. let lines;
  16872. switch (number) {
  16873. case 1:
  16874. lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
  16875. break;
  16876. case 2:
  16877. lines = [[0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [75, 6, 32, 0x3e], [6, 0x3f]];
  16878. break;
  16879. case 3:
  16880. lines = [[-256, 8, 8, 0xfe], [0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [-257, 8, 32, 0xff, "lower"], [75, 7, 32, 0x7e], [6, 0x3e]];
  16881. break;
  16882. case 4:
  16883. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [76, 5, 32, 0x1f]];
  16884. break;
  16885. case 5:
  16886. lines = [[-255, 7, 8, 0x7e], [1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [-256, 7, 32, 0x7f, "lower"], [76, 6, 32, 0x3e]];
  16887. break;
  16888. case 6:
  16889. lines = [[-2048, 5, 10, 0x1c], [-1024, 4, 9, 0x8], [-512, 4, 8, 0x9], [-256, 4, 7, 0xa], [-128, 5, 6, 0x1d], [-64, 5, 5, 0x1e], [-32, 4, 5, 0xb], [0, 2, 7, 0x0], [128, 3, 7, 0x2], [256, 3, 8, 0x3], [512, 4, 9, 0xc], [1024, 4, 10, 0xd], [-2049, 6, 32, 0x3e, "lower"], [2048, 6, 32, 0x3f]];
  16890. break;
  16891. case 7:
  16892. lines = [[-1024, 4, 9, 0x8], [-512, 3, 8, 0x0], [-256, 4, 7, 0x9], [-128, 5, 6, 0x1a], [-64, 5, 5, 0x1b], [-32, 4, 5, 0xa], [0, 4, 5, 0xb], [32, 5, 5, 0x1c], [64, 5, 6, 0x1d], [128, 4, 7, 0xc], [256, 3, 8, 0x1], [512, 3, 9, 0x2], [1024, 3, 10, 0x3], [-1025, 5, 32, 0x1e, "lower"], [2048, 5, 32, 0x1f]];
  16893. break;
  16894. case 8:
  16895. lines = [[-15, 8, 3, 0xfc], [-7, 9, 1, 0x1fc], [-5, 8, 1, 0xfd], [-3, 9, 0, 0x1fd], [-2, 7, 0, 0x7c], [-1, 4, 0, 0xa], [0, 2, 1, 0x0], [2, 5, 0, 0x1a], [3, 6, 0, 0x3a], [4, 3, 4, 0x4], [20, 6, 1, 0x3b], [22, 4, 4, 0xb], [38, 4, 5, 0xc], [70, 5, 6, 0x1b], [134, 5, 7, 0x1c], [262, 6, 7, 0x3c], [390, 7, 8, 0x7d], [646, 6, 10, 0x3d], [-16, 9, 32, 0x1fe, "lower"], [1670, 9, 32, 0x1ff], [2, 0x1]];
  16896. break;
  16897. case 9:
  16898. lines = [[-31, 8, 4, 0xfc], [-15, 9, 2, 0x1fc], [-11, 8, 2, 0xfd], [-7, 9, 1, 0x1fd], [-5, 7, 1, 0x7c], [-3, 4, 1, 0xa], [-1, 3, 1, 0x2], [1, 3, 1, 0x3], [3, 5, 1, 0x1a], [5, 6, 1, 0x3a], [7, 3, 5, 0x4], [39, 6, 2, 0x3b], [43, 4, 5, 0xb], [75, 4, 6, 0xc], [139, 5, 7, 0x1b], [267, 5, 8, 0x1c], [523, 6, 8, 0x3c], [779, 7, 9, 0x7d], [1291, 6, 11, 0x3d], [-32, 9, 32, 0x1fe, "lower"], [3339, 9, 32, 0x1ff], [2, 0x0]];
  16899. break;
  16900. case 10:
  16901. lines = [[-21, 7, 4, 0x7a], [-5, 8, 0, 0xfc], [-4, 7, 0, 0x7b], [-3, 5, 0, 0x18], [-2, 2, 2, 0x0], [2, 5, 0, 0x19], [3, 6, 0, 0x36], [4, 7, 0, 0x7c], [5, 8, 0, 0xfd], [6, 2, 6, 0x1], [70, 5, 5, 0x1a], [102, 6, 5, 0x37], [134, 6, 6, 0x38], [198, 6, 7, 0x39], [326, 6, 8, 0x3a], [582, 6, 9, 0x3b], [1094, 6, 10, 0x3c], [2118, 7, 11, 0x7d], [-22, 8, 32, 0xfe, "lower"], [4166, 8, 32, 0xff], [2, 0x2]];
  16902. break;
  16903. case 11:
  16904. lines = [[1, 1, 0, 0x0], [2, 2, 1, 0x2], [4, 4, 0, 0xc], [5, 4, 1, 0xd], [7, 5, 1, 0x1c], [9, 5, 2, 0x1d], [13, 6, 2, 0x3c], [17, 7, 2, 0x7a], [21, 7, 3, 0x7b], [29, 7, 4, 0x7c], [45, 7, 5, 0x7d], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
  16905. break;
  16906. case 12:
  16907. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 1, 0x6], [5, 5, 0, 0x1c], [6, 5, 1, 0x1d], [8, 6, 1, 0x3c], [10, 7, 0, 0x7a], [11, 7, 1, 0x7b], [13, 7, 2, 0x7c], [17, 7, 3, 0x7d], [25, 7, 4, 0x7e], [41, 8, 5, 0xfe], [73, 8, 32, 0xff]];
  16908. break;
  16909. case 13:
  16910. lines = [[1, 1, 0, 0x0], [2, 3, 0, 0x4], [3, 4, 0, 0xc], [4, 5, 0, 0x1c], [5, 4, 1, 0xd], [7, 3, 3, 0x5], [15, 6, 1, 0x3a], [17, 6, 2, 0x3b], [21, 6, 3, 0x3c], [29, 6, 4, 0x3d], [45, 6, 5, 0x3e], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
  16911. break;
  16912. case 14:
  16913. lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
  16914. break;
  16915. case 15:
  16916. lines = [[-24, 7, 4, 0x7c], [-8, 6, 2, 0x3c], [-4, 5, 1, 0x1c], [-2, 4, 0, 0xc], [-1, 3, 0, 0x4], [0, 1, 0, 0x0], [1, 3, 0, 0x5], [2, 4, 0, 0xd], [3, 5, 1, 0x1d], [5, 6, 2, 0x3d], [9, 7, 4, 0x7d], [-25, 7, 32, 0x7e, "lower"], [25, 7, 32, 0x7f]];
  16917. break;
  16918. default:
  16919. throw new Jbig2Error(`standard table B.${number} does not exist`);
  16920. }
  16921. for (let i = 0, ii = lines.length; i < ii; i++) {
  16922. lines[i] = new HuffmanLine(lines[i]);
  16923. }
  16924. table = new HuffmanTable(lines, true);
  16925. standardTablesCache[number] = table;
  16926. return table;
  16927. }
  16928. class Reader {
  16929. constructor(data, start, end) {
  16930. this.data = data;
  16931. this.start = start;
  16932. this.end = end;
  16933. this.position = start;
  16934. this.shift = -1;
  16935. this.currentByte = 0;
  16936. }
  16937. readBit() {
  16938. if (this.shift < 0) {
  16939. if (this.position >= this.end) {
  16940. throw new Jbig2Error("end of data while reading bit");
  16941. }
  16942. this.currentByte = this.data[this.position++];
  16943. this.shift = 7;
  16944. }
  16945. const bit = this.currentByte >> this.shift & 1;
  16946. this.shift--;
  16947. return bit;
  16948. }
  16949. readBits(numBits) {
  16950. let result = 0,
  16951. i;
  16952. for (i = numBits - 1; i >= 0; i--) {
  16953. result |= this.readBit() << i;
  16954. }
  16955. return result;
  16956. }
  16957. byteAlign() {
  16958. this.shift = -1;
  16959. }
  16960. next() {
  16961. if (this.position >= this.end) {
  16962. return -1;
  16963. }
  16964. return this.data[this.position++];
  16965. }
  16966. }
  16967. function getCustomHuffmanTable(index, referredTo, customTables) {
  16968. let currentIndex = 0;
  16969. for (let i = 0, ii = referredTo.length; i < ii; i++) {
  16970. const table = customTables[referredTo[i]];
  16971. if (table) {
  16972. if (index === currentIndex) {
  16973. return table;
  16974. }
  16975. currentIndex++;
  16976. }
  16977. }
  16978. throw new Jbig2Error("can't find custom Huffman table");
  16979. }
  16980. function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
  16981. const codes = [];
  16982. for (let i = 0; i <= 34; i++) {
  16983. const codeLength = reader.readBits(4);
  16984. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  16985. }
  16986. const runCodesTable = new HuffmanTable(codes, false);
  16987. codes.length = 0;
  16988. for (let i = 0; i < numberOfSymbols;) {
  16989. const codeLength = runCodesTable.decode(reader);
  16990. if (codeLength >= 32) {
  16991. let repeatedLength, numberOfRepeats, j;
  16992. switch (codeLength) {
  16993. case 32:
  16994. if (i === 0) {
  16995. throw new Jbig2Error("no previous value in symbol ID table");
  16996. }
  16997. numberOfRepeats = reader.readBits(2) + 3;
  16998. repeatedLength = codes[i - 1].prefixLength;
  16999. break;
  17000. case 33:
  17001. numberOfRepeats = reader.readBits(3) + 3;
  17002. repeatedLength = 0;
  17003. break;
  17004. case 34:
  17005. numberOfRepeats = reader.readBits(7) + 11;
  17006. repeatedLength = 0;
  17007. break;
  17008. default:
  17009. throw new Jbig2Error("invalid code length in symbol ID table");
  17010. }
  17011. for (j = 0; j < numberOfRepeats; j++) {
  17012. codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
  17013. i++;
  17014. }
  17015. } else {
  17016. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  17017. i++;
  17018. }
  17019. }
  17020. reader.byteAlign();
  17021. const symbolIDTable = new HuffmanTable(codes, false);
  17022. let customIndex = 0,
  17023. tableFirstS,
  17024. tableDeltaS,
  17025. tableDeltaT;
  17026. switch (textRegion.huffmanFS) {
  17027. case 0:
  17028. case 1:
  17029. tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
  17030. break;
  17031. case 3:
  17032. tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17033. customIndex++;
  17034. break;
  17035. default:
  17036. throw new Jbig2Error("invalid Huffman FS selector");
  17037. }
  17038. switch (textRegion.huffmanDS) {
  17039. case 0:
  17040. case 1:
  17041. case 2:
  17042. tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
  17043. break;
  17044. case 3:
  17045. tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17046. customIndex++;
  17047. break;
  17048. default:
  17049. throw new Jbig2Error("invalid Huffman DS selector");
  17050. }
  17051. switch (textRegion.huffmanDT) {
  17052. case 0:
  17053. case 1:
  17054. case 2:
  17055. tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
  17056. break;
  17057. case 3:
  17058. tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17059. customIndex++;
  17060. break;
  17061. default:
  17062. throw new Jbig2Error("invalid Huffman DT selector");
  17063. }
  17064. if (textRegion.refinement) {
  17065. throw new Jbig2Error("refinement with Huffman is not supported");
  17066. }
  17067. return {
  17068. symbolIDTable,
  17069. tableFirstS,
  17070. tableDeltaS,
  17071. tableDeltaT
  17072. };
  17073. }
  17074. function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
  17075. let customIndex = 0,
  17076. tableDeltaHeight,
  17077. tableDeltaWidth;
  17078. switch (dictionary.huffmanDHSelector) {
  17079. case 0:
  17080. case 1:
  17081. tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
  17082. break;
  17083. case 3:
  17084. tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17085. customIndex++;
  17086. break;
  17087. default:
  17088. throw new Jbig2Error("invalid Huffman DH selector");
  17089. }
  17090. switch (dictionary.huffmanDWSelector) {
  17091. case 0:
  17092. case 1:
  17093. tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
  17094. break;
  17095. case 3:
  17096. tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17097. customIndex++;
  17098. break;
  17099. default:
  17100. throw new Jbig2Error("invalid Huffman DW selector");
  17101. }
  17102. let tableBitmapSize, tableAggregateInstances;
  17103. if (dictionary.bitmapSizeSelector) {
  17104. tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17105. customIndex++;
  17106. } else {
  17107. tableBitmapSize = getStandardTable(1);
  17108. }
  17109. if (dictionary.aggregationInstancesSelector) {
  17110. tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
  17111. } else {
  17112. tableAggregateInstances = getStandardTable(1);
  17113. }
  17114. return {
  17115. tableDeltaHeight,
  17116. tableDeltaWidth,
  17117. tableBitmapSize,
  17118. tableAggregateInstances
  17119. };
  17120. }
  17121. function readUncompressedBitmap(reader, width, height) {
  17122. const bitmap = [];
  17123. for (let y = 0; y < height; y++) {
  17124. const row = new Uint8Array(width);
  17125. bitmap.push(row);
  17126. for (let x = 0; x < width; x++) {
  17127. row[x] = reader.readBit();
  17128. }
  17129. reader.byteAlign();
  17130. }
  17131. return bitmap;
  17132. }
  17133. function decodeMMRBitmap(input, width, height, endOfBlock) {
  17134. const params = {
  17135. K: -1,
  17136. Columns: width,
  17137. Rows: height,
  17138. BlackIs1: true,
  17139. EndOfBlock: endOfBlock
  17140. };
  17141. const decoder = new _ccitt.CCITTFaxDecoder(input, params);
  17142. const bitmap = [];
  17143. let currentByte,
  17144. eof = false;
  17145. for (let y = 0; y < height; y++) {
  17146. const row = new Uint8Array(width);
  17147. bitmap.push(row);
  17148. let shift = -1;
  17149. for (let x = 0; x < width; x++) {
  17150. if (shift < 0) {
  17151. currentByte = decoder.readNextChar();
  17152. if (currentByte === -1) {
  17153. currentByte = 0;
  17154. eof = true;
  17155. }
  17156. shift = 7;
  17157. }
  17158. row[x] = currentByte >> shift & 1;
  17159. shift--;
  17160. }
  17161. }
  17162. if (endOfBlock && !eof) {
  17163. const lookForEOFLimit = 5;
  17164. for (let i = 0; i < lookForEOFLimit; i++) {
  17165. if (decoder.readNextChar() === -1) {
  17166. break;
  17167. }
  17168. }
  17169. }
  17170. return bitmap;
  17171. }
  17172. class Jbig2Image {
  17173. parseChunks(chunks) {
  17174. return parseJbig2Chunks(chunks);
  17175. }
  17176. parse(data) {
  17177. throw new Error("Not implemented: Jbig2Image.parse");
  17178. }
  17179. }
  17180. exports.Jbig2Image = Jbig2Image;
  17181. /***/ }),
  17182. /* 25 */
  17183. /***/ ((__unused_webpack_module, exports) => {
  17184. Object.defineProperty(exports, "__esModule", ({
  17185. value: true
  17186. }));
  17187. exports.ArithmeticDecoder = void 0;
  17188. const QeTable = [{
  17189. qe: 0x5601,
  17190. nmps: 1,
  17191. nlps: 1,
  17192. switchFlag: 1
  17193. }, {
  17194. qe: 0x3401,
  17195. nmps: 2,
  17196. nlps: 6,
  17197. switchFlag: 0
  17198. }, {
  17199. qe: 0x1801,
  17200. nmps: 3,
  17201. nlps: 9,
  17202. switchFlag: 0
  17203. }, {
  17204. qe: 0x0ac1,
  17205. nmps: 4,
  17206. nlps: 12,
  17207. switchFlag: 0
  17208. }, {
  17209. qe: 0x0521,
  17210. nmps: 5,
  17211. nlps: 29,
  17212. switchFlag: 0
  17213. }, {
  17214. qe: 0x0221,
  17215. nmps: 38,
  17216. nlps: 33,
  17217. switchFlag: 0
  17218. }, {
  17219. qe: 0x5601,
  17220. nmps: 7,
  17221. nlps: 6,
  17222. switchFlag: 1
  17223. }, {
  17224. qe: 0x5401,
  17225. nmps: 8,
  17226. nlps: 14,
  17227. switchFlag: 0
  17228. }, {
  17229. qe: 0x4801,
  17230. nmps: 9,
  17231. nlps: 14,
  17232. switchFlag: 0
  17233. }, {
  17234. qe: 0x3801,
  17235. nmps: 10,
  17236. nlps: 14,
  17237. switchFlag: 0
  17238. }, {
  17239. qe: 0x3001,
  17240. nmps: 11,
  17241. nlps: 17,
  17242. switchFlag: 0
  17243. }, {
  17244. qe: 0x2401,
  17245. nmps: 12,
  17246. nlps: 18,
  17247. switchFlag: 0
  17248. }, {
  17249. qe: 0x1c01,
  17250. nmps: 13,
  17251. nlps: 20,
  17252. switchFlag: 0
  17253. }, {
  17254. qe: 0x1601,
  17255. nmps: 29,
  17256. nlps: 21,
  17257. switchFlag: 0
  17258. }, {
  17259. qe: 0x5601,
  17260. nmps: 15,
  17261. nlps: 14,
  17262. switchFlag: 1
  17263. }, {
  17264. qe: 0x5401,
  17265. nmps: 16,
  17266. nlps: 14,
  17267. switchFlag: 0
  17268. }, {
  17269. qe: 0x5101,
  17270. nmps: 17,
  17271. nlps: 15,
  17272. switchFlag: 0
  17273. }, {
  17274. qe: 0x4801,
  17275. nmps: 18,
  17276. nlps: 16,
  17277. switchFlag: 0
  17278. }, {
  17279. qe: 0x3801,
  17280. nmps: 19,
  17281. nlps: 17,
  17282. switchFlag: 0
  17283. }, {
  17284. qe: 0x3401,
  17285. nmps: 20,
  17286. nlps: 18,
  17287. switchFlag: 0
  17288. }, {
  17289. qe: 0x3001,
  17290. nmps: 21,
  17291. nlps: 19,
  17292. switchFlag: 0
  17293. }, {
  17294. qe: 0x2801,
  17295. nmps: 22,
  17296. nlps: 19,
  17297. switchFlag: 0
  17298. }, {
  17299. qe: 0x2401,
  17300. nmps: 23,
  17301. nlps: 20,
  17302. switchFlag: 0
  17303. }, {
  17304. qe: 0x2201,
  17305. nmps: 24,
  17306. nlps: 21,
  17307. switchFlag: 0
  17308. }, {
  17309. qe: 0x1c01,
  17310. nmps: 25,
  17311. nlps: 22,
  17312. switchFlag: 0
  17313. }, {
  17314. qe: 0x1801,
  17315. nmps: 26,
  17316. nlps: 23,
  17317. switchFlag: 0
  17318. }, {
  17319. qe: 0x1601,
  17320. nmps: 27,
  17321. nlps: 24,
  17322. switchFlag: 0
  17323. }, {
  17324. qe: 0x1401,
  17325. nmps: 28,
  17326. nlps: 25,
  17327. switchFlag: 0
  17328. }, {
  17329. qe: 0x1201,
  17330. nmps: 29,
  17331. nlps: 26,
  17332. switchFlag: 0
  17333. }, {
  17334. qe: 0x1101,
  17335. nmps: 30,
  17336. nlps: 27,
  17337. switchFlag: 0
  17338. }, {
  17339. qe: 0x0ac1,
  17340. nmps: 31,
  17341. nlps: 28,
  17342. switchFlag: 0
  17343. }, {
  17344. qe: 0x09c1,
  17345. nmps: 32,
  17346. nlps: 29,
  17347. switchFlag: 0
  17348. }, {
  17349. qe: 0x08a1,
  17350. nmps: 33,
  17351. nlps: 30,
  17352. switchFlag: 0
  17353. }, {
  17354. qe: 0x0521,
  17355. nmps: 34,
  17356. nlps: 31,
  17357. switchFlag: 0
  17358. }, {
  17359. qe: 0x0441,
  17360. nmps: 35,
  17361. nlps: 32,
  17362. switchFlag: 0
  17363. }, {
  17364. qe: 0x02a1,
  17365. nmps: 36,
  17366. nlps: 33,
  17367. switchFlag: 0
  17368. }, {
  17369. qe: 0x0221,
  17370. nmps: 37,
  17371. nlps: 34,
  17372. switchFlag: 0
  17373. }, {
  17374. qe: 0x0141,
  17375. nmps: 38,
  17376. nlps: 35,
  17377. switchFlag: 0
  17378. }, {
  17379. qe: 0x0111,
  17380. nmps: 39,
  17381. nlps: 36,
  17382. switchFlag: 0
  17383. }, {
  17384. qe: 0x0085,
  17385. nmps: 40,
  17386. nlps: 37,
  17387. switchFlag: 0
  17388. }, {
  17389. qe: 0x0049,
  17390. nmps: 41,
  17391. nlps: 38,
  17392. switchFlag: 0
  17393. }, {
  17394. qe: 0x0025,
  17395. nmps: 42,
  17396. nlps: 39,
  17397. switchFlag: 0
  17398. }, {
  17399. qe: 0x0015,
  17400. nmps: 43,
  17401. nlps: 40,
  17402. switchFlag: 0
  17403. }, {
  17404. qe: 0x0009,
  17405. nmps: 44,
  17406. nlps: 41,
  17407. switchFlag: 0
  17408. }, {
  17409. qe: 0x0005,
  17410. nmps: 45,
  17411. nlps: 42,
  17412. switchFlag: 0
  17413. }, {
  17414. qe: 0x0001,
  17415. nmps: 45,
  17416. nlps: 43,
  17417. switchFlag: 0
  17418. }, {
  17419. qe: 0x5601,
  17420. nmps: 46,
  17421. nlps: 46,
  17422. switchFlag: 0
  17423. }];
  17424. class ArithmeticDecoder {
  17425. constructor(data, start, end) {
  17426. this.data = data;
  17427. this.bp = start;
  17428. this.dataEnd = end;
  17429. this.chigh = data[start];
  17430. this.clow = 0;
  17431. this.byteIn();
  17432. this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
  17433. this.clow = this.clow << 7 & 0xffff;
  17434. this.ct -= 7;
  17435. this.a = 0x8000;
  17436. }
  17437. byteIn() {
  17438. const data = this.data;
  17439. let bp = this.bp;
  17440. if (data[bp] === 0xff) {
  17441. if (data[bp + 1] > 0x8f) {
  17442. this.clow += 0xff00;
  17443. this.ct = 8;
  17444. } else {
  17445. bp++;
  17446. this.clow += data[bp] << 9;
  17447. this.ct = 7;
  17448. this.bp = bp;
  17449. }
  17450. } else {
  17451. bp++;
  17452. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
  17453. this.ct = 8;
  17454. this.bp = bp;
  17455. }
  17456. if (this.clow > 0xffff) {
  17457. this.chigh += this.clow >> 16;
  17458. this.clow &= 0xffff;
  17459. }
  17460. }
  17461. readBit(contexts, pos) {
  17462. let cx_index = contexts[pos] >> 1,
  17463. cx_mps = contexts[pos] & 1;
  17464. const qeTableIcx = QeTable[cx_index];
  17465. const qeIcx = qeTableIcx.qe;
  17466. let d;
  17467. let a = this.a - qeIcx;
  17468. if (this.chigh < qeIcx) {
  17469. if (a < qeIcx) {
  17470. a = qeIcx;
  17471. d = cx_mps;
  17472. cx_index = qeTableIcx.nmps;
  17473. } else {
  17474. a = qeIcx;
  17475. d = 1 ^ cx_mps;
  17476. if (qeTableIcx.switchFlag === 1) {
  17477. cx_mps = d;
  17478. }
  17479. cx_index = qeTableIcx.nlps;
  17480. }
  17481. } else {
  17482. this.chigh -= qeIcx;
  17483. if ((a & 0x8000) !== 0) {
  17484. this.a = a;
  17485. return cx_mps;
  17486. }
  17487. if (a < qeIcx) {
  17488. d = 1 ^ cx_mps;
  17489. if (qeTableIcx.switchFlag === 1) {
  17490. cx_mps = d;
  17491. }
  17492. cx_index = qeTableIcx.nlps;
  17493. } else {
  17494. d = cx_mps;
  17495. cx_index = qeTableIcx.nmps;
  17496. }
  17497. }
  17498. do {
  17499. if (this.ct === 0) {
  17500. this.byteIn();
  17501. }
  17502. a <<= 1;
  17503. this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
  17504. this.clow = this.clow << 1 & 0xffff;
  17505. this.ct--;
  17506. } while ((a & 0x8000) === 0);
  17507. this.a = a;
  17508. contexts[pos] = cx_index << 1 | cx_mps;
  17509. return d;
  17510. }
  17511. }
  17512. exports.ArithmeticDecoder = ArithmeticDecoder;
  17513. /***/ }),
  17514. /* 26 */
  17515. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17516. Object.defineProperty(exports, "__esModule", ({
  17517. value: true
  17518. }));
  17519. exports.JpegStream = void 0;
  17520. var _decode_stream = __w_pdfjs_require__(18);
  17521. var _primitives = __w_pdfjs_require__(4);
  17522. var _jpg = __w_pdfjs_require__(27);
  17523. var _util = __w_pdfjs_require__(2);
  17524. class JpegStream extends _decode_stream.DecodeStream {
  17525. constructor(stream, maybeLength, params) {
  17526. let ch;
  17527. while ((ch = stream.getByte()) !== -1) {
  17528. if (ch === 0xff) {
  17529. stream.skip(-1);
  17530. break;
  17531. }
  17532. }
  17533. super(maybeLength);
  17534. this.stream = stream;
  17535. this.dict = stream.dict;
  17536. this.maybeLength = maybeLength;
  17537. this.params = params;
  17538. }
  17539. get bytes() {
  17540. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  17541. }
  17542. ensureBuffer(requested) {}
  17543. readBlock() {
  17544. if (this.eof) {
  17545. return;
  17546. }
  17547. const jpegOptions = {
  17548. decodeTransform: undefined,
  17549. colorTransform: undefined
  17550. };
  17551. const decodeArr = this.dict.getArray("D", "Decode");
  17552. if ((this.forceRGBA || this.forceRGB) && Array.isArray(decodeArr)) {
  17553. const bitsPerComponent = this.dict.get("BPC", "BitsPerComponent") || 8;
  17554. const decodeArrLength = decodeArr.length;
  17555. const transform = new Int32Array(decodeArrLength);
  17556. let transformNeeded = false;
  17557. const maxValue = (1 << bitsPerComponent) - 1;
  17558. for (let i = 0; i < decodeArrLength; i += 2) {
  17559. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  17560. transform[i + 1] = decodeArr[i] * maxValue | 0;
  17561. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  17562. transformNeeded = true;
  17563. }
  17564. }
  17565. if (transformNeeded) {
  17566. jpegOptions.decodeTransform = transform;
  17567. }
  17568. }
  17569. if (this.params instanceof _primitives.Dict) {
  17570. const colorTransform = this.params.get("ColorTransform");
  17571. if (Number.isInteger(colorTransform)) {
  17572. jpegOptions.colorTransform = colorTransform;
  17573. }
  17574. }
  17575. const jpegImage = new _jpg.JpegImage(jpegOptions);
  17576. jpegImage.parse(this.bytes);
  17577. const data = jpegImage.getData({
  17578. width: this.drawWidth,
  17579. height: this.drawHeight,
  17580. forceRGBA: this.forceRGBA,
  17581. forceRGB: this.forceRGB,
  17582. isSourcePDF: true
  17583. });
  17584. this.buffer = data;
  17585. this.bufferLength = data.length;
  17586. this.eof = true;
  17587. }
  17588. }
  17589. exports.JpegStream = JpegStream;
  17590. /***/ }),
  17591. /* 27 */
  17592. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17593. Object.defineProperty(exports, "__esModule", ({
  17594. value: true
  17595. }));
  17596. exports.JpegImage = void 0;
  17597. var _util = __w_pdfjs_require__(2);
  17598. var _image_utils = __w_pdfjs_require__(28);
  17599. var _core_utils = __w_pdfjs_require__(3);
  17600. class JpegError extends _util.BaseException {
  17601. constructor(msg) {
  17602. super(`JPEG error: ${msg}`, "JpegError");
  17603. }
  17604. }
  17605. class DNLMarkerError extends _util.BaseException {
  17606. constructor(message, scanLines) {
  17607. super(message, "DNLMarkerError");
  17608. this.scanLines = scanLines;
  17609. }
  17610. }
  17611. class EOIMarkerError extends _util.BaseException {
  17612. constructor(msg) {
  17613. super(msg, "EOIMarkerError");
  17614. }
  17615. }
  17616. const dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]);
  17617. const dctCos1 = 4017;
  17618. const dctSin1 = 799;
  17619. const dctCos3 = 3406;
  17620. const dctSin3 = 2276;
  17621. const dctCos6 = 1567;
  17622. const dctSin6 = 3784;
  17623. const dctSqrt2 = 5793;
  17624. const dctSqrt1d2 = 2896;
  17625. function buildHuffmanTable(codeLengths, values) {
  17626. let k = 0,
  17627. i,
  17628. j,
  17629. length = 16;
  17630. while (length > 0 && !codeLengths[length - 1]) {
  17631. length--;
  17632. }
  17633. const code = [{
  17634. children: [],
  17635. index: 0
  17636. }];
  17637. let p = code[0],
  17638. q;
  17639. for (i = 0; i < length; i++) {
  17640. for (j = 0; j < codeLengths[i]; j++) {
  17641. p = code.pop();
  17642. p.children[p.index] = values[k];
  17643. while (p.index > 0) {
  17644. p = code.pop();
  17645. }
  17646. p.index++;
  17647. code.push(p);
  17648. while (code.length <= i) {
  17649. code.push(q = {
  17650. children: [],
  17651. index: 0
  17652. });
  17653. p.children[p.index] = q.children;
  17654. p = q;
  17655. }
  17656. k++;
  17657. }
  17658. if (i + 1 < length) {
  17659. code.push(q = {
  17660. children: [],
  17661. index: 0
  17662. });
  17663. p.children[p.index] = q.children;
  17664. p = q;
  17665. }
  17666. }
  17667. return code[0].children;
  17668. }
  17669. function getBlockBufferOffset(component, row, col) {
  17670. return 64 * ((component.blocksPerLine + 1) * row + col);
  17671. }
  17672. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive, parseDNLMarker = false) {
  17673. const mcusPerLine = frame.mcusPerLine;
  17674. const progressive = frame.progressive;
  17675. const startOffset = offset;
  17676. let bitsData = 0,
  17677. bitsCount = 0;
  17678. function readBit() {
  17679. if (bitsCount > 0) {
  17680. bitsCount--;
  17681. return bitsData >> bitsCount & 1;
  17682. }
  17683. bitsData = data[offset++];
  17684. if (bitsData === 0xff) {
  17685. const nextByte = data[offset++];
  17686. if (nextByte) {
  17687. if (nextByte === 0xdc && parseDNLMarker) {
  17688. offset += 2;
  17689. const scanLines = (0, _core_utils.readUint16)(data, offset);
  17690. offset += 2;
  17691. if (scanLines > 0 && scanLines !== frame.scanLines) {
  17692. throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
  17693. }
  17694. } else if (nextByte === 0xd9) {
  17695. if (parseDNLMarker) {
  17696. const maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
  17697. if (maybeScanLines > 0 && Math.round(frame.scanLines / maybeScanLines) >= 5) {
  17698. throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
  17699. }
  17700. }
  17701. throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
  17702. }
  17703. throw new JpegError(`unexpected marker ${(bitsData << 8 | nextByte).toString(16)}`);
  17704. }
  17705. }
  17706. bitsCount = 7;
  17707. return bitsData >>> 7;
  17708. }
  17709. function decodeHuffman(tree) {
  17710. let node = tree;
  17711. while (true) {
  17712. node = node[readBit()];
  17713. switch (typeof node) {
  17714. case "number":
  17715. return node;
  17716. case "object":
  17717. continue;
  17718. }
  17719. throw new JpegError("invalid huffman sequence");
  17720. }
  17721. }
  17722. function receive(length) {
  17723. let n = 0;
  17724. while (length > 0) {
  17725. n = n << 1 | readBit();
  17726. length--;
  17727. }
  17728. return n;
  17729. }
  17730. function receiveAndExtend(length) {
  17731. if (length === 1) {
  17732. return readBit() === 1 ? 1 : -1;
  17733. }
  17734. const n = receive(length);
  17735. if (n >= 1 << length - 1) {
  17736. return n;
  17737. }
  17738. return n + (-1 << length) + 1;
  17739. }
  17740. function decodeBaseline(component, blockOffset) {
  17741. const t = decodeHuffman(component.huffmanTableDC);
  17742. const diff = t === 0 ? 0 : receiveAndExtend(t);
  17743. component.blockData[blockOffset] = component.pred += diff;
  17744. let k = 1;
  17745. while (k < 64) {
  17746. const rs = decodeHuffman(component.huffmanTableAC);
  17747. const s = rs & 15,
  17748. r = rs >> 4;
  17749. if (s === 0) {
  17750. if (r < 15) {
  17751. break;
  17752. }
  17753. k += 16;
  17754. continue;
  17755. }
  17756. k += r;
  17757. const z = dctZigZag[k];
  17758. component.blockData[blockOffset + z] = receiveAndExtend(s);
  17759. k++;
  17760. }
  17761. }
  17762. function decodeDCFirst(component, blockOffset) {
  17763. const t = decodeHuffman(component.huffmanTableDC);
  17764. const diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  17765. component.blockData[blockOffset] = component.pred += diff;
  17766. }
  17767. function decodeDCSuccessive(component, blockOffset) {
  17768. component.blockData[blockOffset] |= readBit() << successive;
  17769. }
  17770. let eobrun = 0;
  17771. function decodeACFirst(component, blockOffset) {
  17772. if (eobrun > 0) {
  17773. eobrun--;
  17774. return;
  17775. }
  17776. let k = spectralStart;
  17777. const e = spectralEnd;
  17778. while (k <= e) {
  17779. const rs = decodeHuffman(component.huffmanTableAC);
  17780. const s = rs & 15,
  17781. r = rs >> 4;
  17782. if (s === 0) {
  17783. if (r < 15) {
  17784. eobrun = receive(r) + (1 << r) - 1;
  17785. break;
  17786. }
  17787. k += 16;
  17788. continue;
  17789. }
  17790. k += r;
  17791. const z = dctZigZag[k];
  17792. component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
  17793. k++;
  17794. }
  17795. }
  17796. let successiveACState = 0,
  17797. successiveACNextValue;
  17798. function decodeACSuccessive(component, blockOffset) {
  17799. let k = spectralStart;
  17800. const e = spectralEnd;
  17801. let r = 0;
  17802. let s;
  17803. let rs;
  17804. while (k <= e) {
  17805. const offsetZ = blockOffset + dctZigZag[k];
  17806. const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
  17807. switch (successiveACState) {
  17808. case 0:
  17809. rs = decodeHuffman(component.huffmanTableAC);
  17810. s = rs & 15;
  17811. r = rs >> 4;
  17812. if (s === 0) {
  17813. if (r < 15) {
  17814. eobrun = receive(r) + (1 << r);
  17815. successiveACState = 4;
  17816. } else {
  17817. r = 16;
  17818. successiveACState = 1;
  17819. }
  17820. } else {
  17821. if (s !== 1) {
  17822. throw new JpegError("invalid ACn encoding");
  17823. }
  17824. successiveACNextValue = receiveAndExtend(s);
  17825. successiveACState = r ? 2 : 3;
  17826. }
  17827. continue;
  17828. case 1:
  17829. case 2:
  17830. if (component.blockData[offsetZ]) {
  17831. component.blockData[offsetZ] += sign * (readBit() << successive);
  17832. } else {
  17833. r--;
  17834. if (r === 0) {
  17835. successiveACState = successiveACState === 2 ? 3 : 0;
  17836. }
  17837. }
  17838. break;
  17839. case 3:
  17840. if (component.blockData[offsetZ]) {
  17841. component.blockData[offsetZ] += sign * (readBit() << successive);
  17842. } else {
  17843. component.blockData[offsetZ] = successiveACNextValue << successive;
  17844. successiveACState = 0;
  17845. }
  17846. break;
  17847. case 4:
  17848. if (component.blockData[offsetZ]) {
  17849. component.blockData[offsetZ] += sign * (readBit() << successive);
  17850. }
  17851. break;
  17852. }
  17853. k++;
  17854. }
  17855. if (successiveACState === 4) {
  17856. eobrun--;
  17857. if (eobrun === 0) {
  17858. successiveACState = 0;
  17859. }
  17860. }
  17861. }
  17862. let blockRow = 0;
  17863. function decodeMcu(component, decode, mcu, row, col) {
  17864. const mcuRow = mcu / mcusPerLine | 0;
  17865. const mcuCol = mcu % mcusPerLine;
  17866. blockRow = mcuRow * component.v + row;
  17867. const blockCol = mcuCol * component.h + col;
  17868. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  17869. decode(component, blockOffset);
  17870. }
  17871. function decodeBlock(component, decode, mcu) {
  17872. blockRow = mcu / component.blocksPerLine | 0;
  17873. const blockCol = mcu % component.blocksPerLine;
  17874. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  17875. decode(component, blockOffset);
  17876. }
  17877. const componentsLength = components.length;
  17878. let component, i, j, k, n;
  17879. let decodeFn;
  17880. if (progressive) {
  17881. if (spectralStart === 0) {
  17882. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  17883. } else {
  17884. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  17885. }
  17886. } else {
  17887. decodeFn = decodeBaseline;
  17888. }
  17889. let mcu = 0,
  17890. fileMarker;
  17891. const mcuExpected = componentsLength === 1 ? components[0].blocksPerLine * components[0].blocksPerColumn : mcusPerLine * frame.mcusPerColumn;
  17892. let h, v;
  17893. while (mcu <= mcuExpected) {
  17894. const mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  17895. if (mcuToRead > 0) {
  17896. for (i = 0; i < componentsLength; i++) {
  17897. components[i].pred = 0;
  17898. }
  17899. eobrun = 0;
  17900. if (componentsLength === 1) {
  17901. component = components[0];
  17902. for (n = 0; n < mcuToRead; n++) {
  17903. decodeBlock(component, decodeFn, mcu);
  17904. mcu++;
  17905. }
  17906. } else {
  17907. for (n = 0; n < mcuToRead; n++) {
  17908. for (i = 0; i < componentsLength; i++) {
  17909. component = components[i];
  17910. h = component.h;
  17911. v = component.v;
  17912. for (j = 0; j < v; j++) {
  17913. for (k = 0; k < h; k++) {
  17914. decodeMcu(component, decodeFn, mcu, j, k);
  17915. }
  17916. }
  17917. }
  17918. mcu++;
  17919. }
  17920. }
  17921. }
  17922. bitsCount = 0;
  17923. fileMarker = findNextFileMarker(data, offset);
  17924. if (!fileMarker) {
  17925. break;
  17926. }
  17927. if (fileMarker.invalid) {
  17928. const partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
  17929. (0, _util.warn)(`decodeScan - ${partialMsg} MCU data, current marker is: ${fileMarker.invalid}`);
  17930. offset = fileMarker.offset;
  17931. }
  17932. if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
  17933. offset += 2;
  17934. } else {
  17935. break;
  17936. }
  17937. }
  17938. return offset - startOffset;
  17939. }
  17940. function quantizeAndInverse(component, blockBufferOffset, p) {
  17941. const qt = component.quantizationTable,
  17942. blockData = component.blockData;
  17943. let v0, v1, v2, v3, v4, v5, v6, v7;
  17944. let p0, p1, p2, p3, p4, p5, p6, p7;
  17945. let t;
  17946. if (!qt) {
  17947. throw new JpegError("missing required Quantization Table.");
  17948. }
  17949. for (let row = 0; row < 64; row += 8) {
  17950. p0 = blockData[blockBufferOffset + row];
  17951. p1 = blockData[blockBufferOffset + row + 1];
  17952. p2 = blockData[blockBufferOffset + row + 2];
  17953. p3 = blockData[blockBufferOffset + row + 3];
  17954. p4 = blockData[blockBufferOffset + row + 4];
  17955. p5 = blockData[blockBufferOffset + row + 5];
  17956. p6 = blockData[blockBufferOffset + row + 6];
  17957. p7 = blockData[blockBufferOffset + row + 7];
  17958. p0 *= qt[row];
  17959. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  17960. t = dctSqrt2 * p0 + 512 >> 10;
  17961. p[row] = t;
  17962. p[row + 1] = t;
  17963. p[row + 2] = t;
  17964. p[row + 3] = t;
  17965. p[row + 4] = t;
  17966. p[row + 5] = t;
  17967. p[row + 6] = t;
  17968. p[row + 7] = t;
  17969. continue;
  17970. }
  17971. p1 *= qt[row + 1];
  17972. p2 *= qt[row + 2];
  17973. p3 *= qt[row + 3];
  17974. p4 *= qt[row + 4];
  17975. p5 *= qt[row + 5];
  17976. p6 *= qt[row + 6];
  17977. p7 *= qt[row + 7];
  17978. v0 = dctSqrt2 * p0 + 128 >> 8;
  17979. v1 = dctSqrt2 * p4 + 128 >> 8;
  17980. v2 = p2;
  17981. v3 = p6;
  17982. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  17983. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  17984. v5 = p3 << 4;
  17985. v6 = p5 << 4;
  17986. v0 = v0 + v1 + 1 >> 1;
  17987. v1 = v0 - v1;
  17988. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  17989. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  17990. v3 = t;
  17991. v4 = v4 + v6 + 1 >> 1;
  17992. v6 = v4 - v6;
  17993. v7 = v7 + v5 + 1 >> 1;
  17994. v5 = v7 - v5;
  17995. v0 = v0 + v3 + 1 >> 1;
  17996. v3 = v0 - v3;
  17997. v1 = v1 + v2 + 1 >> 1;
  17998. v2 = v1 - v2;
  17999. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  18000. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  18001. v7 = t;
  18002. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  18003. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  18004. v6 = t;
  18005. p[row] = v0 + v7;
  18006. p[row + 7] = v0 - v7;
  18007. p[row + 1] = v1 + v6;
  18008. p[row + 6] = v1 - v6;
  18009. p[row + 2] = v2 + v5;
  18010. p[row + 5] = v2 - v5;
  18011. p[row + 3] = v3 + v4;
  18012. p[row + 4] = v3 - v4;
  18013. }
  18014. for (let col = 0; col < 8; ++col) {
  18015. p0 = p[col];
  18016. p1 = p[col + 8];
  18017. p2 = p[col + 16];
  18018. p3 = p[col + 24];
  18019. p4 = p[col + 32];
  18020. p5 = p[col + 40];
  18021. p6 = p[col + 48];
  18022. p7 = p[col + 56];
  18023. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  18024. t = dctSqrt2 * p0 + 8192 >> 14;
  18025. if (t < -2040) {
  18026. t = 0;
  18027. } else if (t >= 2024) {
  18028. t = 255;
  18029. } else {
  18030. t = t + 2056 >> 4;
  18031. }
  18032. blockData[blockBufferOffset + col] = t;
  18033. blockData[blockBufferOffset + col + 8] = t;
  18034. blockData[blockBufferOffset + col + 16] = t;
  18035. blockData[blockBufferOffset + col + 24] = t;
  18036. blockData[blockBufferOffset + col + 32] = t;
  18037. blockData[blockBufferOffset + col + 40] = t;
  18038. blockData[blockBufferOffset + col + 48] = t;
  18039. blockData[blockBufferOffset + col + 56] = t;
  18040. continue;
  18041. }
  18042. v0 = dctSqrt2 * p0 + 2048 >> 12;
  18043. v1 = dctSqrt2 * p4 + 2048 >> 12;
  18044. v2 = p2;
  18045. v3 = p6;
  18046. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  18047. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  18048. v5 = p3;
  18049. v6 = p5;
  18050. v0 = (v0 + v1 + 1 >> 1) + 4112;
  18051. v1 = v0 - v1;
  18052. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  18053. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  18054. v3 = t;
  18055. v4 = v4 + v6 + 1 >> 1;
  18056. v6 = v4 - v6;
  18057. v7 = v7 + v5 + 1 >> 1;
  18058. v5 = v7 - v5;
  18059. v0 = v0 + v3 + 1 >> 1;
  18060. v3 = v0 - v3;
  18061. v1 = v1 + v2 + 1 >> 1;
  18062. v2 = v1 - v2;
  18063. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  18064. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  18065. v7 = t;
  18066. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  18067. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  18068. v6 = t;
  18069. p0 = v0 + v7;
  18070. p7 = v0 - v7;
  18071. p1 = v1 + v6;
  18072. p6 = v1 - v6;
  18073. p2 = v2 + v5;
  18074. p5 = v2 - v5;
  18075. p3 = v3 + v4;
  18076. p4 = v3 - v4;
  18077. if (p0 < 16) {
  18078. p0 = 0;
  18079. } else if (p0 >= 4080) {
  18080. p0 = 255;
  18081. } else {
  18082. p0 >>= 4;
  18083. }
  18084. if (p1 < 16) {
  18085. p1 = 0;
  18086. } else if (p1 >= 4080) {
  18087. p1 = 255;
  18088. } else {
  18089. p1 >>= 4;
  18090. }
  18091. if (p2 < 16) {
  18092. p2 = 0;
  18093. } else if (p2 >= 4080) {
  18094. p2 = 255;
  18095. } else {
  18096. p2 >>= 4;
  18097. }
  18098. if (p3 < 16) {
  18099. p3 = 0;
  18100. } else if (p3 >= 4080) {
  18101. p3 = 255;
  18102. } else {
  18103. p3 >>= 4;
  18104. }
  18105. if (p4 < 16) {
  18106. p4 = 0;
  18107. } else if (p4 >= 4080) {
  18108. p4 = 255;
  18109. } else {
  18110. p4 >>= 4;
  18111. }
  18112. if (p5 < 16) {
  18113. p5 = 0;
  18114. } else if (p5 >= 4080) {
  18115. p5 = 255;
  18116. } else {
  18117. p5 >>= 4;
  18118. }
  18119. if (p6 < 16) {
  18120. p6 = 0;
  18121. } else if (p6 >= 4080) {
  18122. p6 = 255;
  18123. } else {
  18124. p6 >>= 4;
  18125. }
  18126. if (p7 < 16) {
  18127. p7 = 0;
  18128. } else if (p7 >= 4080) {
  18129. p7 = 255;
  18130. } else {
  18131. p7 >>= 4;
  18132. }
  18133. blockData[blockBufferOffset + col] = p0;
  18134. blockData[blockBufferOffset + col + 8] = p1;
  18135. blockData[blockBufferOffset + col + 16] = p2;
  18136. blockData[blockBufferOffset + col + 24] = p3;
  18137. blockData[blockBufferOffset + col + 32] = p4;
  18138. blockData[blockBufferOffset + col + 40] = p5;
  18139. blockData[blockBufferOffset + col + 48] = p6;
  18140. blockData[blockBufferOffset + col + 56] = p7;
  18141. }
  18142. }
  18143. function buildComponentData(frame, component) {
  18144. const blocksPerLine = component.blocksPerLine;
  18145. const blocksPerColumn = component.blocksPerColumn;
  18146. const computationBuffer = new Int16Array(64);
  18147. for (let blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  18148. for (let blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  18149. const offset = getBlockBufferOffset(component, blockRow, blockCol);
  18150. quantizeAndInverse(component, offset, computationBuffer);
  18151. }
  18152. }
  18153. return component.blockData;
  18154. }
  18155. function findNextFileMarker(data, currentPos, startPos = currentPos) {
  18156. const maxPos = data.length - 1;
  18157. let newPos = startPos < currentPos ? startPos : currentPos;
  18158. if (currentPos >= maxPos) {
  18159. return null;
  18160. }
  18161. const currentMarker = (0, _core_utils.readUint16)(data, currentPos);
  18162. if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
  18163. return {
  18164. invalid: null,
  18165. marker: currentMarker,
  18166. offset: currentPos
  18167. };
  18168. }
  18169. let newMarker = (0, _core_utils.readUint16)(data, newPos);
  18170. while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
  18171. if (++newPos >= maxPos) {
  18172. return null;
  18173. }
  18174. newMarker = (0, _core_utils.readUint16)(data, newPos);
  18175. }
  18176. return {
  18177. invalid: currentMarker.toString(16),
  18178. marker: newMarker,
  18179. offset: newPos
  18180. };
  18181. }
  18182. class JpegImage {
  18183. constructor({
  18184. decodeTransform = null,
  18185. colorTransform = -1
  18186. } = {}) {
  18187. this._decodeTransform = decodeTransform;
  18188. this._colorTransform = colorTransform;
  18189. }
  18190. parse(data, {
  18191. dnlScanLines = null
  18192. } = {}) {
  18193. function readDataBlock() {
  18194. const length = (0, _core_utils.readUint16)(data, offset);
  18195. offset += 2;
  18196. let endOffset = offset + length - 2;
  18197. const fileMarker = findNextFileMarker(data, endOffset, offset);
  18198. if (fileMarker?.invalid) {
  18199. (0, _util.warn)("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
  18200. endOffset = fileMarker.offset;
  18201. }
  18202. const array = data.subarray(offset, endOffset);
  18203. offset += array.length;
  18204. return array;
  18205. }
  18206. function prepareComponents(frame) {
  18207. const mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  18208. const mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  18209. for (const component of frame.components) {
  18210. const blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  18211. const blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  18212. const blocksPerLineForMcu = mcusPerLine * component.h;
  18213. const blocksPerColumnForMcu = mcusPerColumn * component.v;
  18214. const blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  18215. component.blockData = new Int16Array(blocksBufferSize);
  18216. component.blocksPerLine = blocksPerLine;
  18217. component.blocksPerColumn = blocksPerColumn;
  18218. }
  18219. frame.mcusPerLine = mcusPerLine;
  18220. frame.mcusPerColumn = mcusPerColumn;
  18221. }
  18222. let offset = 0;
  18223. let jfif = null;
  18224. let adobe = null;
  18225. let frame, resetInterval;
  18226. let numSOSMarkers = 0;
  18227. const quantizationTables = [];
  18228. const huffmanTablesAC = [],
  18229. huffmanTablesDC = [];
  18230. let fileMarker = (0, _core_utils.readUint16)(data, offset);
  18231. offset += 2;
  18232. if (fileMarker !== 0xffd8) {
  18233. throw new JpegError("SOI not found");
  18234. }
  18235. fileMarker = (0, _core_utils.readUint16)(data, offset);
  18236. offset += 2;
  18237. markerLoop: while (fileMarker !== 0xffd9) {
  18238. let i, j, l;
  18239. switch (fileMarker) {
  18240. case 0xffe0:
  18241. case 0xffe1:
  18242. case 0xffe2:
  18243. case 0xffe3:
  18244. case 0xffe4:
  18245. case 0xffe5:
  18246. case 0xffe6:
  18247. case 0xffe7:
  18248. case 0xffe8:
  18249. case 0xffe9:
  18250. case 0xffea:
  18251. case 0xffeb:
  18252. case 0xffec:
  18253. case 0xffed:
  18254. case 0xffee:
  18255. case 0xffef:
  18256. case 0xfffe:
  18257. const appData = readDataBlock();
  18258. if (fileMarker === 0xffe0) {
  18259. if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  18260. jfif = {
  18261. version: {
  18262. major: appData[5],
  18263. minor: appData[6]
  18264. },
  18265. densityUnits: appData[7],
  18266. xDensity: appData[8] << 8 | appData[9],
  18267. yDensity: appData[10] << 8 | appData[11],
  18268. thumbWidth: appData[12],
  18269. thumbHeight: appData[13],
  18270. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  18271. };
  18272. }
  18273. }
  18274. if (fileMarker === 0xffee) {
  18275. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
  18276. adobe = {
  18277. version: appData[5] << 8 | appData[6],
  18278. flags0: appData[7] << 8 | appData[8],
  18279. flags1: appData[9] << 8 | appData[10],
  18280. transformCode: appData[11]
  18281. };
  18282. }
  18283. }
  18284. break;
  18285. case 0xffdb:
  18286. const quantizationTablesLength = (0, _core_utils.readUint16)(data, offset);
  18287. offset += 2;
  18288. const quantizationTablesEnd = quantizationTablesLength + offset - 2;
  18289. let z;
  18290. while (offset < quantizationTablesEnd) {
  18291. const quantizationTableSpec = data[offset++];
  18292. const tableData = new Uint16Array(64);
  18293. if (quantizationTableSpec >> 4 === 0) {
  18294. for (j = 0; j < 64; j++) {
  18295. z = dctZigZag[j];
  18296. tableData[z] = data[offset++];
  18297. }
  18298. } else if (quantizationTableSpec >> 4 === 1) {
  18299. for (j = 0; j < 64; j++) {
  18300. z = dctZigZag[j];
  18301. tableData[z] = (0, _core_utils.readUint16)(data, offset);
  18302. offset += 2;
  18303. }
  18304. } else {
  18305. throw new JpegError("DQT - invalid table spec");
  18306. }
  18307. quantizationTables[quantizationTableSpec & 15] = tableData;
  18308. }
  18309. break;
  18310. case 0xffc0:
  18311. case 0xffc1:
  18312. case 0xffc2:
  18313. if (frame) {
  18314. throw new JpegError("Only single frame JPEGs supported");
  18315. }
  18316. offset += 2;
  18317. frame = {};
  18318. frame.extended = fileMarker === 0xffc1;
  18319. frame.progressive = fileMarker === 0xffc2;
  18320. frame.precision = data[offset++];
  18321. const sofScanLines = (0, _core_utils.readUint16)(data, offset);
  18322. offset += 2;
  18323. frame.scanLines = dnlScanLines || sofScanLines;
  18324. frame.samplesPerLine = (0, _core_utils.readUint16)(data, offset);
  18325. offset += 2;
  18326. frame.components = [];
  18327. frame.componentIds = {};
  18328. const componentsCount = data[offset++];
  18329. let maxH = 0,
  18330. maxV = 0;
  18331. for (i = 0; i < componentsCount; i++) {
  18332. const componentId = data[offset];
  18333. const h = data[offset + 1] >> 4;
  18334. const v = data[offset + 1] & 15;
  18335. if (maxH < h) {
  18336. maxH = h;
  18337. }
  18338. if (maxV < v) {
  18339. maxV = v;
  18340. }
  18341. const qId = data[offset + 2];
  18342. l = frame.components.push({
  18343. h,
  18344. v,
  18345. quantizationId: qId,
  18346. quantizationTable: null
  18347. });
  18348. frame.componentIds[componentId] = l - 1;
  18349. offset += 3;
  18350. }
  18351. frame.maxH = maxH;
  18352. frame.maxV = maxV;
  18353. prepareComponents(frame);
  18354. break;
  18355. case 0xffc4:
  18356. const huffmanLength = (0, _core_utils.readUint16)(data, offset);
  18357. offset += 2;
  18358. for (i = 2; i < huffmanLength;) {
  18359. const huffmanTableSpec = data[offset++];
  18360. const codeLengths = new Uint8Array(16);
  18361. let codeLengthSum = 0;
  18362. for (j = 0; j < 16; j++, offset++) {
  18363. codeLengthSum += codeLengths[j] = data[offset];
  18364. }
  18365. const huffmanValues = new Uint8Array(codeLengthSum);
  18366. for (j = 0; j < codeLengthSum; j++, offset++) {
  18367. huffmanValues[j] = data[offset];
  18368. }
  18369. i += 17 + codeLengthSum;
  18370. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  18371. }
  18372. break;
  18373. case 0xffdd:
  18374. offset += 2;
  18375. resetInterval = (0, _core_utils.readUint16)(data, offset);
  18376. offset += 2;
  18377. break;
  18378. case 0xffda:
  18379. const parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
  18380. offset += 2;
  18381. const selectorsCount = data[offset++],
  18382. components = [];
  18383. for (i = 0; i < selectorsCount; i++) {
  18384. const index = data[offset++];
  18385. const componentIndex = frame.componentIds[index];
  18386. const component = frame.components[componentIndex];
  18387. component.index = index;
  18388. const tableSpec = data[offset++];
  18389. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  18390. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  18391. components.push(component);
  18392. }
  18393. const spectralStart = data[offset++],
  18394. spectralEnd = data[offset++],
  18395. successiveApproximation = data[offset++];
  18396. try {
  18397. const processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
  18398. offset += processed;
  18399. } catch (ex) {
  18400. if (ex instanceof DNLMarkerError) {
  18401. (0, _util.warn)(`${ex.message} -- attempting to re-parse the JPEG image.`);
  18402. return this.parse(data, {
  18403. dnlScanLines: ex.scanLines
  18404. });
  18405. } else if (ex instanceof EOIMarkerError) {
  18406. (0, _util.warn)(`${ex.message} -- ignoring the rest of the image data.`);
  18407. break markerLoop;
  18408. }
  18409. throw ex;
  18410. }
  18411. break;
  18412. case 0xffdc:
  18413. offset += 4;
  18414. break;
  18415. case 0xffff:
  18416. if (data[offset] !== 0xff) {
  18417. offset--;
  18418. }
  18419. break;
  18420. default:
  18421. const nextFileMarker = findNextFileMarker(data, offset - 2, offset - 3);
  18422. if (nextFileMarker?.invalid) {
  18423. (0, _util.warn)("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
  18424. offset = nextFileMarker.offset;
  18425. break;
  18426. }
  18427. if (!nextFileMarker || offset >= data.length - 1) {
  18428. (0, _util.warn)("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
  18429. break markerLoop;
  18430. }
  18431. throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
  18432. }
  18433. fileMarker = (0, _core_utils.readUint16)(data, offset);
  18434. offset += 2;
  18435. }
  18436. this.width = frame.samplesPerLine;
  18437. this.height = frame.scanLines;
  18438. this.jfif = jfif;
  18439. this.adobe = adobe;
  18440. this.components = [];
  18441. for (const component of frame.components) {
  18442. const quantizationTable = quantizationTables[component.quantizationId];
  18443. if (quantizationTable) {
  18444. component.quantizationTable = quantizationTable;
  18445. }
  18446. this.components.push({
  18447. index: component.index,
  18448. output: buildComponentData(frame, component),
  18449. scaleX: component.h / frame.maxH,
  18450. scaleY: component.v / frame.maxV,
  18451. blocksPerLine: component.blocksPerLine,
  18452. blocksPerColumn: component.blocksPerColumn
  18453. });
  18454. }
  18455. this.numComponents = this.components.length;
  18456. return undefined;
  18457. }
  18458. _getLinearizedBlockData(width, height, isSourcePDF = false) {
  18459. const scaleX = this.width / width,
  18460. scaleY = this.height / height;
  18461. let component, componentScaleX, componentScaleY, blocksPerScanline;
  18462. let x, y, i, j, k;
  18463. let index;
  18464. let offset = 0;
  18465. let output;
  18466. const numComponents = this.components.length;
  18467. const dataLength = width * height * numComponents;
  18468. const data = new Uint8ClampedArray(dataLength);
  18469. const xScaleBlockOffset = new Uint32Array(width);
  18470. const mask3LSB = 0xfffffff8;
  18471. let lastComponentScaleX;
  18472. for (i = 0; i < numComponents; i++) {
  18473. component = this.components[i];
  18474. componentScaleX = component.scaleX * scaleX;
  18475. componentScaleY = component.scaleY * scaleY;
  18476. offset = i;
  18477. output = component.output;
  18478. blocksPerScanline = component.blocksPerLine + 1 << 3;
  18479. if (componentScaleX !== lastComponentScaleX) {
  18480. for (x = 0; x < width; x++) {
  18481. j = 0 | x * componentScaleX;
  18482. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  18483. }
  18484. lastComponentScaleX = componentScaleX;
  18485. }
  18486. for (y = 0; y < height; y++) {
  18487. j = 0 | y * componentScaleY;
  18488. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  18489. for (x = 0; x < width; x++) {
  18490. data[offset] = output[index + xScaleBlockOffset[x]];
  18491. offset += numComponents;
  18492. }
  18493. }
  18494. }
  18495. let transform = this._decodeTransform;
  18496. if (!isSourcePDF && numComponents === 4 && !transform) {
  18497. transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
  18498. }
  18499. if (transform) {
  18500. for (i = 0; i < dataLength;) {
  18501. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  18502. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  18503. }
  18504. }
  18505. }
  18506. return data;
  18507. }
  18508. get _isColorConversionNeeded() {
  18509. if (this.adobe) {
  18510. return !!this.adobe.transformCode;
  18511. }
  18512. if (this.numComponents === 3) {
  18513. if (this._colorTransform === 0) {
  18514. return false;
  18515. } else if (this.components[0].index === 0x52 && this.components[1].index === 0x47 && this.components[2].index === 0x42) {
  18516. return false;
  18517. }
  18518. return true;
  18519. }
  18520. if (this._colorTransform === 1) {
  18521. return true;
  18522. }
  18523. return false;
  18524. }
  18525. _convertYccToRgb(data) {
  18526. let Y, Cb, Cr;
  18527. for (let i = 0, length = data.length; i < length; i += 3) {
  18528. Y = data[i];
  18529. Cb = data[i + 1];
  18530. Cr = data[i + 2];
  18531. data[i] = Y - 179.456 + 1.402 * Cr;
  18532. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  18533. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  18534. }
  18535. return data;
  18536. }
  18537. _convertYccToRgba(data, out) {
  18538. for (let i = 0, j = 0, length = data.length; i < length; i += 3, j += 4) {
  18539. const Y = data[i];
  18540. const Cb = data[i + 1];
  18541. const Cr = data[i + 2];
  18542. out[j] = Y - 179.456 + 1.402 * Cr;
  18543. out[j + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  18544. out[j + 2] = Y - 226.816 + 1.772 * Cb;
  18545. out[j + 3] = 255;
  18546. }
  18547. return out;
  18548. }
  18549. _convertYcckToRgb(data) {
  18550. let Y, Cb, Cr, k;
  18551. let offset = 0;
  18552. for (let i = 0, length = data.length; i < length; i += 4) {
  18553. Y = data[i];
  18554. Cb = data[i + 1];
  18555. Cr = data[i + 2];
  18556. k = data[i + 3];
  18557. data[offset++] = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  18558. data[offset++] = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  18559. data[offset++] = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  18560. }
  18561. return data.subarray(0, offset);
  18562. }
  18563. _convertYcckToRgba(data) {
  18564. for (let i = 0, length = data.length; i < length; i += 4) {
  18565. const Y = data[i];
  18566. const Cb = data[i + 1];
  18567. const Cr = data[i + 2];
  18568. const k = data[i + 3];
  18569. data[i] = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  18570. data[i + 1] = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  18571. data[i + 2] = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  18572. data[i + 3] = 255;
  18573. }
  18574. return data;
  18575. }
  18576. _convertYcckToCmyk(data) {
  18577. let Y, Cb, Cr;
  18578. for (let i = 0, length = data.length; i < length; i += 4) {
  18579. Y = data[i];
  18580. Cb = data[i + 1];
  18581. Cr = data[i + 2];
  18582. data[i] = 434.456 - Y - 1.402 * Cr;
  18583. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  18584. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  18585. }
  18586. return data;
  18587. }
  18588. _convertCmykToRgb(data) {
  18589. let c, m, y, k;
  18590. let offset = 0;
  18591. for (let i = 0, length = data.length; i < length; i += 4) {
  18592. c = data[i];
  18593. m = data[i + 1];
  18594. y = data[i + 2];
  18595. k = data[i + 3];
  18596. data[offset++] = 255 + c * (-0.00006747147073602441 * c + 0.0008379262121013727 * m + 0.0002894718188643294 * y + 0.003264231057537806 * k - 1.1185611867203937) + m * (0.000026374107616089405 * m - 0.00008626949158638572 * y - 0.0002748769067499491 * k - 0.02155688794978967) + y * (-0.00003878099212869363 * y - 0.0003267808279485286 * k + 0.0686742238595345) - k * (0.0003361971776183937 * k + 0.7430659151342254);
  18597. data[offset++] = 255 + c * (0.00013596372813588848 * c + 0.000924537132573585 * m + 0.00010567359618683593 * y + 0.0004791864687436512 * k - 0.3109689587515875) + m * (-0.00023545346108370344 * m + 0.0002702845253534714 * y + 0.0020200308977307156 * k - 0.7488052167015494) + y * (0.00006834815998235662 * y + 0.00015168452363460973 * k - 0.09751927774728933) - k * (0.0003189131175883281 * k + 0.7364883807733168);
  18598. data[offset++] = 255 + c * (0.000013598650411385307 * c + 0.00012423956175490851 * m + 0.0004751985097583589 * y - 0.0000036729317476630422 * k - 0.05562186980264034) + m * (0.00016141380598724676 * m + 0.0009692239130725186 * y + 0.0007782692450036253 * k - 0.44015232367526463) + y * (5.068882914068769e-7 * y + 0.0017778369011375071 * k - 0.7591454649749609) - k * (0.0003435319965105553 * k + 0.7063770186160144);
  18599. }
  18600. return data.subarray(0, offset);
  18601. }
  18602. _convertCmykToRgba(data) {
  18603. for (let i = 0, length = data.length; i < length; i += 4) {
  18604. const c = data[i];
  18605. const m = data[i + 1];
  18606. const y = data[i + 2];
  18607. const k = data[i + 3];
  18608. data[i] = 255 + c * (-0.00006747147073602441 * c + 0.0008379262121013727 * m + 0.0002894718188643294 * y + 0.003264231057537806 * k - 1.1185611867203937) + m * (0.000026374107616089405 * m - 0.00008626949158638572 * y - 0.0002748769067499491 * k - 0.02155688794978967) + y * (-0.00003878099212869363 * y - 0.0003267808279485286 * k + 0.0686742238595345) - k * (0.0003361971776183937 * k + 0.7430659151342254);
  18609. data[i + 1] = 255 + c * (0.00013596372813588848 * c + 0.000924537132573585 * m + 0.00010567359618683593 * y + 0.0004791864687436512 * k - 0.3109689587515875) + m * (-0.00023545346108370344 * m + 0.0002702845253534714 * y + 0.0020200308977307156 * k - 0.7488052167015494) + y * (0.00006834815998235662 * y + 0.00015168452363460973 * k - 0.09751927774728933) - k * (0.0003189131175883281 * k + 0.7364883807733168);
  18610. data[i + 2] = 255 + c * (0.000013598650411385307 * c + 0.00012423956175490851 * m + 0.0004751985097583589 * y - 0.0000036729317476630422 * k - 0.05562186980264034) + m * (0.00016141380598724676 * m + 0.0009692239130725186 * y + 0.0007782692450036253 * k - 0.44015232367526463) + y * (5.068882914068769e-7 * y + 0.0017778369011375071 * k - 0.7591454649749609) - k * (0.0003435319965105553 * k + 0.7063770186160144);
  18611. data[i + 3] = 255;
  18612. }
  18613. return data;
  18614. }
  18615. getData({
  18616. width,
  18617. height,
  18618. forceRGBA = false,
  18619. forceRGB = false,
  18620. isSourcePDF = false
  18621. }) {
  18622. if (this.numComponents > 4) {
  18623. throw new JpegError("Unsupported color mode");
  18624. }
  18625. const data = this._getLinearizedBlockData(width, height, isSourcePDF);
  18626. if (this.numComponents === 1 && (forceRGBA || forceRGB)) {
  18627. const len = data.length * (forceRGBA ? 4 : 3);
  18628. const rgbaData = new Uint8ClampedArray(len);
  18629. let offset = 0;
  18630. if (forceRGBA) {
  18631. (0, _image_utils.grayToRGBA)(data, new Uint32Array(rgbaData.buffer));
  18632. } else {
  18633. for (const grayColor of data) {
  18634. rgbaData[offset++] = grayColor;
  18635. rgbaData[offset++] = grayColor;
  18636. rgbaData[offset++] = grayColor;
  18637. }
  18638. }
  18639. return rgbaData;
  18640. } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
  18641. if (forceRGBA) {
  18642. const rgbaData = new Uint8ClampedArray(data.length / 3 * 4);
  18643. return this._convertYccToRgba(data, rgbaData);
  18644. }
  18645. return this._convertYccToRgb(data);
  18646. } else if (this.numComponents === 4) {
  18647. if (this._isColorConversionNeeded) {
  18648. if (forceRGBA) {
  18649. return this._convertYcckToRgba(data);
  18650. }
  18651. if (forceRGB) {
  18652. return this._convertYcckToRgb(data);
  18653. }
  18654. return this._convertYcckToCmyk(data);
  18655. } else if (forceRGBA) {
  18656. return this._convertCmykToRgba(data);
  18657. } else if (forceRGB) {
  18658. return this._convertCmykToRgb(data);
  18659. }
  18660. }
  18661. return data;
  18662. }
  18663. }
  18664. exports.JpegImage = JpegImage;
  18665. /***/ }),
  18666. /* 28 */
  18667. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18668. Object.defineProperty(exports, "__esModule", ({
  18669. value: true
  18670. }));
  18671. exports.convertBlackAndWhiteToRGBA = convertBlackAndWhiteToRGBA;
  18672. exports.convertToRGBA = convertToRGBA;
  18673. exports.grayToRGBA = grayToRGBA;
  18674. var _util = __w_pdfjs_require__(2);
  18675. function convertToRGBA(params) {
  18676. switch (params.kind) {
  18677. case _util.ImageKind.GRAYSCALE_1BPP:
  18678. return convertBlackAndWhiteToRGBA(params);
  18679. case _util.ImageKind.RGB_24BPP:
  18680. return convertRGBToRGBA(params);
  18681. }
  18682. return null;
  18683. }
  18684. function convertBlackAndWhiteToRGBA({
  18685. src,
  18686. srcPos = 0,
  18687. dest,
  18688. width,
  18689. height,
  18690. nonBlackColor = 0xffffffff,
  18691. inverseDecode = false
  18692. }) {
  18693. const black = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  18694. const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
  18695. const widthInSource = width >> 3;
  18696. const widthRemainder = width & 7;
  18697. const srcLength = src.length;
  18698. dest = new Uint32Array(dest.buffer);
  18699. let destPos = 0;
  18700. for (let i = 0; i < height; i++) {
  18701. for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
  18702. const elem = srcPos < srcLength ? src[srcPos] : 255;
  18703. dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
  18704. dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
  18705. dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
  18706. dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
  18707. dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
  18708. dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
  18709. dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
  18710. dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
  18711. }
  18712. if (widthRemainder === 0) {
  18713. continue;
  18714. }
  18715. const elem = srcPos < srcLength ? src[srcPos++] : 255;
  18716. for (let j = 0; j < widthRemainder; j++) {
  18717. dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
  18718. }
  18719. }
  18720. return {
  18721. srcPos,
  18722. destPos
  18723. };
  18724. }
  18725. function convertRGBToRGBA({
  18726. src,
  18727. srcPos = 0,
  18728. dest,
  18729. destPos = 0,
  18730. width,
  18731. height
  18732. }) {
  18733. let i = 0;
  18734. const len32 = src.length >> 2;
  18735. const src32 = new Uint32Array(src.buffer, srcPos, len32);
  18736. if (_util.FeatureTest.isLittleEndian) {
  18737. for (; i < len32 - 2; i += 3, destPos += 4) {
  18738. const s1 = src32[i];
  18739. const s2 = src32[i + 1];
  18740. const s3 = src32[i + 2];
  18741. dest[destPos] = s1 | 0xff000000;
  18742. dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 0xff000000;
  18743. dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 0xff000000;
  18744. dest[destPos + 3] = s3 >>> 8 | 0xff000000;
  18745. }
  18746. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  18747. dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 0xff000000;
  18748. }
  18749. } else {
  18750. for (; i < len32 - 2; i += 3, destPos += 4) {
  18751. const s1 = src32[i];
  18752. const s2 = src32[i + 1];
  18753. const s3 = src32[i + 2];
  18754. dest[destPos] = s1 | 0xff;
  18755. dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 0xff;
  18756. dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 0xff;
  18757. dest[destPos + 3] = s3 << 8 | 0xff;
  18758. }
  18759. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  18760. dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 0xff;
  18761. }
  18762. }
  18763. return {
  18764. srcPos,
  18765. destPos
  18766. };
  18767. }
  18768. function grayToRGBA(src, dest) {
  18769. if (_util.FeatureTest.isLittleEndian) {
  18770. for (let i = 0, ii = src.length; i < ii; i++) {
  18771. dest[i] = src[i] * 0x10101 | 0xff000000;
  18772. }
  18773. } else {
  18774. for (let i = 0, ii = src.length; i < ii; i++) {
  18775. dest[i] = src[i] * 0x1010100 | 0x000000ff;
  18776. }
  18777. }
  18778. }
  18779. /***/ }),
  18780. /* 29 */
  18781. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18782. Object.defineProperty(exports, "__esModule", ({
  18783. value: true
  18784. }));
  18785. exports.JpxStream = void 0;
  18786. var _decode_stream = __w_pdfjs_require__(18);
  18787. var _jpx = __w_pdfjs_require__(30);
  18788. var _util = __w_pdfjs_require__(2);
  18789. class JpxStream extends _decode_stream.DecodeStream {
  18790. constructor(stream, maybeLength, params) {
  18791. super(maybeLength);
  18792. this.stream = stream;
  18793. this.dict = stream.dict;
  18794. this.maybeLength = maybeLength;
  18795. this.params = params;
  18796. }
  18797. get bytes() {
  18798. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  18799. }
  18800. ensureBuffer(requested) {}
  18801. readBlock() {
  18802. if (this.eof) {
  18803. return;
  18804. }
  18805. const jpxImage = new _jpx.JpxImage();
  18806. jpxImage.parse(this.bytes);
  18807. const width = jpxImage.width;
  18808. const height = jpxImage.height;
  18809. const componentsCount = jpxImage.componentsCount;
  18810. const tileCount = jpxImage.tiles.length;
  18811. if (tileCount === 1) {
  18812. this.buffer = jpxImage.tiles[0].items;
  18813. } else {
  18814. const data = new Uint8ClampedArray(width * height * componentsCount);
  18815. for (let k = 0; k < tileCount; k++) {
  18816. const tileComponents = jpxImage.tiles[k];
  18817. const tileWidth = tileComponents.width;
  18818. const tileHeight = tileComponents.height;
  18819. const tileLeft = tileComponents.left;
  18820. const tileTop = tileComponents.top;
  18821. const src = tileComponents.items;
  18822. let srcPosition = 0;
  18823. let dataPosition = (width * tileTop + tileLeft) * componentsCount;
  18824. const imgRowSize = width * componentsCount;
  18825. const tileRowSize = tileWidth * componentsCount;
  18826. for (let j = 0; j < tileHeight; j++) {
  18827. const rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  18828. data.set(rowBytes, dataPosition);
  18829. srcPosition += tileRowSize;
  18830. dataPosition += imgRowSize;
  18831. }
  18832. }
  18833. this.buffer = data;
  18834. }
  18835. this.bufferLength = this.buffer.length;
  18836. this.eof = true;
  18837. }
  18838. }
  18839. exports.JpxStream = JpxStream;
  18840. /***/ }),
  18841. /* 30 */
  18842. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18843. Object.defineProperty(exports, "__esModule", ({
  18844. value: true
  18845. }));
  18846. exports.JpxImage = void 0;
  18847. var _util = __w_pdfjs_require__(2);
  18848. var _core_utils = __w_pdfjs_require__(3);
  18849. var _arithmetic_decoder = __w_pdfjs_require__(25);
  18850. class JpxError extends _util.BaseException {
  18851. constructor(msg) {
  18852. super(`JPX error: ${msg}`, "JpxError");
  18853. }
  18854. }
  18855. const SubbandsGainLog2 = {
  18856. LL: 0,
  18857. LH: 1,
  18858. HL: 1,
  18859. HH: 2
  18860. };
  18861. class JpxImage {
  18862. constructor() {
  18863. this.failOnCorruptedImage = false;
  18864. }
  18865. parse(data) {
  18866. const head = (0, _core_utils.readUint16)(data, 0);
  18867. if (head === 0xff4f) {
  18868. this.parseCodestream(data, 0, data.length);
  18869. return;
  18870. }
  18871. const length = data.length;
  18872. let position = 0;
  18873. while (position < length) {
  18874. let headerSize = 8;
  18875. let lbox = (0, _core_utils.readUint32)(data, position);
  18876. const tbox = (0, _core_utils.readUint32)(data, position + 4);
  18877. position += headerSize;
  18878. if (lbox === 1) {
  18879. lbox = (0, _core_utils.readUint32)(data, position) * 4294967296 + (0, _core_utils.readUint32)(data, position + 4);
  18880. position += 8;
  18881. headerSize += 8;
  18882. }
  18883. if (lbox === 0) {
  18884. lbox = length - position + headerSize;
  18885. }
  18886. if (lbox < headerSize) {
  18887. throw new JpxError("Invalid box field size");
  18888. }
  18889. const dataLength = lbox - headerSize;
  18890. let jumpDataLength = true;
  18891. switch (tbox) {
  18892. case 0x6a703268:
  18893. jumpDataLength = false;
  18894. break;
  18895. case 0x636f6c72:
  18896. const method = data[position];
  18897. if (method === 1) {
  18898. const colorspace = (0, _core_utils.readUint32)(data, position + 3);
  18899. switch (colorspace) {
  18900. case 16:
  18901. case 17:
  18902. case 18:
  18903. break;
  18904. default:
  18905. (0, _util.warn)("Unknown colorspace " + colorspace);
  18906. break;
  18907. }
  18908. } else if (method === 2) {
  18909. (0, _util.info)("ICC profile not supported");
  18910. }
  18911. break;
  18912. case 0x6a703263:
  18913. this.parseCodestream(data, position, position + dataLength);
  18914. break;
  18915. case 0x6a502020:
  18916. if ((0, _core_utils.readUint32)(data, position) !== 0x0d0a870a) {
  18917. (0, _util.warn)("Invalid JP2 signature");
  18918. }
  18919. break;
  18920. case 0x6a501a1a:
  18921. case 0x66747970:
  18922. case 0x72726571:
  18923. case 0x72657320:
  18924. case 0x69686472:
  18925. break;
  18926. default:
  18927. const headerType = String.fromCharCode(tbox >> 24 & 0xff, tbox >> 16 & 0xff, tbox >> 8 & 0xff, tbox & 0xff);
  18928. (0, _util.warn)(`Unsupported header type ${tbox} (${headerType}).`);
  18929. break;
  18930. }
  18931. if (jumpDataLength) {
  18932. position += dataLength;
  18933. }
  18934. }
  18935. }
  18936. parseImageProperties(stream) {
  18937. let newByte = stream.getByte();
  18938. while (newByte >= 0) {
  18939. const oldByte = newByte;
  18940. newByte = stream.getByte();
  18941. const code = oldByte << 8 | newByte;
  18942. if (code === 0xff51) {
  18943. stream.skip(4);
  18944. const Xsiz = stream.getInt32() >>> 0;
  18945. const Ysiz = stream.getInt32() >>> 0;
  18946. const XOsiz = stream.getInt32() >>> 0;
  18947. const YOsiz = stream.getInt32() >>> 0;
  18948. stream.skip(16);
  18949. const Csiz = stream.getUint16();
  18950. this.width = Xsiz - XOsiz;
  18951. this.height = Ysiz - YOsiz;
  18952. this.componentsCount = Csiz;
  18953. this.bitsPerComponent = 8;
  18954. return;
  18955. }
  18956. }
  18957. throw new JpxError("No size marker found in JPX stream");
  18958. }
  18959. parseCodestream(data, start, end) {
  18960. const context = {};
  18961. let doNotRecover = false;
  18962. try {
  18963. let position = start;
  18964. while (position + 1 < end) {
  18965. const code = (0, _core_utils.readUint16)(data, position);
  18966. position += 2;
  18967. let length = 0,
  18968. j,
  18969. sqcd,
  18970. spqcds,
  18971. spqcdSize,
  18972. scalarExpounded,
  18973. tile;
  18974. switch (code) {
  18975. case 0xff4f:
  18976. context.mainHeader = true;
  18977. break;
  18978. case 0xffd9:
  18979. break;
  18980. case 0xff51:
  18981. length = (0, _core_utils.readUint16)(data, position);
  18982. const siz = {};
  18983. siz.Xsiz = (0, _core_utils.readUint32)(data, position + 4);
  18984. siz.Ysiz = (0, _core_utils.readUint32)(data, position + 8);
  18985. siz.XOsiz = (0, _core_utils.readUint32)(data, position + 12);
  18986. siz.YOsiz = (0, _core_utils.readUint32)(data, position + 16);
  18987. siz.XTsiz = (0, _core_utils.readUint32)(data, position + 20);
  18988. siz.YTsiz = (0, _core_utils.readUint32)(data, position + 24);
  18989. siz.XTOsiz = (0, _core_utils.readUint32)(data, position + 28);
  18990. siz.YTOsiz = (0, _core_utils.readUint32)(data, position + 32);
  18991. const componentsCount = (0, _core_utils.readUint16)(data, position + 36);
  18992. siz.Csiz = componentsCount;
  18993. const components = [];
  18994. j = position + 38;
  18995. for (let i = 0; i < componentsCount; i++) {
  18996. const component = {
  18997. precision: (data[j] & 0x7f) + 1,
  18998. isSigned: !!(data[j] & 0x80),
  18999. XRsiz: data[j + 1],
  19000. YRsiz: data[j + 2]
  19001. };
  19002. j += 3;
  19003. calculateComponentDimensions(component, siz);
  19004. components.push(component);
  19005. }
  19006. context.SIZ = siz;
  19007. context.components = components;
  19008. calculateTileGrids(context, components);
  19009. context.QCC = [];
  19010. context.COC = [];
  19011. break;
  19012. case 0xff5c:
  19013. length = (0, _core_utils.readUint16)(data, position);
  19014. const qcd = {};
  19015. j = position + 2;
  19016. sqcd = data[j++];
  19017. switch (sqcd & 0x1f) {
  19018. case 0:
  19019. spqcdSize = 8;
  19020. scalarExpounded = true;
  19021. break;
  19022. case 1:
  19023. spqcdSize = 16;
  19024. scalarExpounded = false;
  19025. break;
  19026. case 2:
  19027. spqcdSize = 16;
  19028. scalarExpounded = true;
  19029. break;
  19030. default:
  19031. throw new Error("Invalid SQcd value " + sqcd);
  19032. }
  19033. qcd.noQuantization = spqcdSize === 8;
  19034. qcd.scalarExpounded = scalarExpounded;
  19035. qcd.guardBits = sqcd >> 5;
  19036. spqcds = [];
  19037. while (j < length + position) {
  19038. const spqcd = {};
  19039. if (spqcdSize === 8) {
  19040. spqcd.epsilon = data[j++] >> 3;
  19041. spqcd.mu = 0;
  19042. } else {
  19043. spqcd.epsilon = data[j] >> 3;
  19044. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  19045. j += 2;
  19046. }
  19047. spqcds.push(spqcd);
  19048. }
  19049. qcd.SPqcds = spqcds;
  19050. if (context.mainHeader) {
  19051. context.QCD = qcd;
  19052. } else {
  19053. context.currentTile.QCD = qcd;
  19054. context.currentTile.QCC = [];
  19055. }
  19056. break;
  19057. case 0xff5d:
  19058. length = (0, _core_utils.readUint16)(data, position);
  19059. const qcc = {};
  19060. j = position + 2;
  19061. let cqcc;
  19062. if (context.SIZ.Csiz < 257) {
  19063. cqcc = data[j++];
  19064. } else {
  19065. cqcc = (0, _core_utils.readUint16)(data, j);
  19066. j += 2;
  19067. }
  19068. sqcd = data[j++];
  19069. switch (sqcd & 0x1f) {
  19070. case 0:
  19071. spqcdSize = 8;
  19072. scalarExpounded = true;
  19073. break;
  19074. case 1:
  19075. spqcdSize = 16;
  19076. scalarExpounded = false;
  19077. break;
  19078. case 2:
  19079. spqcdSize = 16;
  19080. scalarExpounded = true;
  19081. break;
  19082. default:
  19083. throw new Error("Invalid SQcd value " + sqcd);
  19084. }
  19085. qcc.noQuantization = spqcdSize === 8;
  19086. qcc.scalarExpounded = scalarExpounded;
  19087. qcc.guardBits = sqcd >> 5;
  19088. spqcds = [];
  19089. while (j < length + position) {
  19090. const spqcd = {};
  19091. if (spqcdSize === 8) {
  19092. spqcd.epsilon = data[j++] >> 3;
  19093. spqcd.mu = 0;
  19094. } else {
  19095. spqcd.epsilon = data[j] >> 3;
  19096. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  19097. j += 2;
  19098. }
  19099. spqcds.push(spqcd);
  19100. }
  19101. qcc.SPqcds = spqcds;
  19102. if (context.mainHeader) {
  19103. context.QCC[cqcc] = qcc;
  19104. } else {
  19105. context.currentTile.QCC[cqcc] = qcc;
  19106. }
  19107. break;
  19108. case 0xff52:
  19109. length = (0, _core_utils.readUint16)(data, position);
  19110. const cod = {};
  19111. j = position + 2;
  19112. const scod = data[j++];
  19113. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  19114. cod.sopMarkerUsed = !!(scod & 2);
  19115. cod.ephMarkerUsed = !!(scod & 4);
  19116. cod.progressionOrder = data[j++];
  19117. cod.layersCount = (0, _core_utils.readUint16)(data, j);
  19118. j += 2;
  19119. cod.multipleComponentTransform = data[j++];
  19120. cod.decompositionLevelsCount = data[j++];
  19121. cod.xcb = (data[j++] & 0xf) + 2;
  19122. cod.ycb = (data[j++] & 0xf) + 2;
  19123. const blockStyle = data[j++];
  19124. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  19125. cod.resetContextProbabilities = !!(blockStyle & 2);
  19126. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  19127. cod.verticallyStripe = !!(blockStyle & 8);
  19128. cod.predictableTermination = !!(blockStyle & 16);
  19129. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  19130. cod.reversibleTransformation = data[j++];
  19131. if (cod.entropyCoderWithCustomPrecincts) {
  19132. const precinctsSizes = [];
  19133. while (j < length + position) {
  19134. const precinctsSize = data[j++];
  19135. precinctsSizes.push({
  19136. PPx: precinctsSize & 0xf,
  19137. PPy: precinctsSize >> 4
  19138. });
  19139. }
  19140. cod.precinctsSizes = precinctsSizes;
  19141. }
  19142. const unsupported = [];
  19143. if (cod.selectiveArithmeticCodingBypass) {
  19144. unsupported.push("selectiveArithmeticCodingBypass");
  19145. }
  19146. if (cod.terminationOnEachCodingPass) {
  19147. unsupported.push("terminationOnEachCodingPass");
  19148. }
  19149. if (cod.verticallyStripe) {
  19150. unsupported.push("verticallyStripe");
  19151. }
  19152. if (cod.predictableTermination) {
  19153. unsupported.push("predictableTermination");
  19154. }
  19155. if (unsupported.length > 0) {
  19156. doNotRecover = true;
  19157. (0, _util.warn)(`JPX: Unsupported COD options (${unsupported.join(", ")}).`);
  19158. }
  19159. if (context.mainHeader) {
  19160. context.COD = cod;
  19161. } else {
  19162. context.currentTile.COD = cod;
  19163. context.currentTile.COC = [];
  19164. }
  19165. break;
  19166. case 0xff90:
  19167. length = (0, _core_utils.readUint16)(data, position);
  19168. tile = {};
  19169. tile.index = (0, _core_utils.readUint16)(data, position + 2);
  19170. tile.length = (0, _core_utils.readUint32)(data, position + 4);
  19171. tile.dataEnd = tile.length + position - 2;
  19172. tile.partIndex = data[position + 8];
  19173. tile.partsCount = data[position + 9];
  19174. context.mainHeader = false;
  19175. if (tile.partIndex === 0) {
  19176. tile.COD = context.COD;
  19177. tile.COC = context.COC.slice(0);
  19178. tile.QCD = context.QCD;
  19179. tile.QCC = context.QCC.slice(0);
  19180. }
  19181. context.currentTile = tile;
  19182. break;
  19183. case 0xff93:
  19184. tile = context.currentTile;
  19185. if (tile.partIndex === 0) {
  19186. initializeTile(context, tile.index);
  19187. buildPackets(context);
  19188. }
  19189. length = tile.dataEnd - position;
  19190. parseTilePackets(context, data, position, length);
  19191. break;
  19192. case 0xff53:
  19193. (0, _util.warn)("JPX: Codestream code 0xFF53 (COC) is not implemented.");
  19194. case 0xff55:
  19195. case 0xff57:
  19196. case 0xff58:
  19197. case 0xff64:
  19198. length = (0, _core_utils.readUint16)(data, position);
  19199. break;
  19200. default:
  19201. throw new Error("Unknown codestream code: " + code.toString(16));
  19202. }
  19203. position += length;
  19204. }
  19205. } catch (e) {
  19206. if (doNotRecover || this.failOnCorruptedImage) {
  19207. throw new JpxError(e.message);
  19208. } else {
  19209. (0, _util.warn)(`JPX: Trying to recover from: "${e.message}".`);
  19210. }
  19211. }
  19212. this.tiles = transformComponents(context);
  19213. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  19214. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  19215. this.componentsCount = context.SIZ.Csiz;
  19216. }
  19217. }
  19218. exports.JpxImage = JpxImage;
  19219. function calculateComponentDimensions(component, siz) {
  19220. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  19221. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  19222. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  19223. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  19224. component.width = component.x1 - component.x0;
  19225. component.height = component.y1 - component.y0;
  19226. }
  19227. function calculateTileGrids(context, components) {
  19228. const siz = context.SIZ;
  19229. const tiles = [];
  19230. let tile;
  19231. const numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  19232. const numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  19233. for (let q = 0; q < numYtiles; q++) {
  19234. for (let p = 0; p < numXtiles; p++) {
  19235. tile = {};
  19236. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  19237. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  19238. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  19239. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  19240. tile.width = tile.tx1 - tile.tx0;
  19241. tile.height = tile.ty1 - tile.ty0;
  19242. tile.components = [];
  19243. tiles.push(tile);
  19244. }
  19245. }
  19246. context.tiles = tiles;
  19247. const componentsCount = siz.Csiz;
  19248. for (let i = 0, ii = componentsCount; i < ii; i++) {
  19249. const component = components[i];
  19250. for (let j = 0, jj = tiles.length; j < jj; j++) {
  19251. const tileComponent = {};
  19252. tile = tiles[j];
  19253. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  19254. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  19255. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  19256. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  19257. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  19258. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  19259. tile.components[i] = tileComponent;
  19260. }
  19261. }
  19262. }
  19263. function getBlocksDimensions(context, component, r) {
  19264. const codOrCoc = component.codingStyleParameters;
  19265. const result = {};
  19266. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  19267. result.PPx = 15;
  19268. result.PPy = 15;
  19269. } else {
  19270. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  19271. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  19272. }
  19273. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  19274. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  19275. return result;
  19276. }
  19277. function buildPrecincts(context, resolution, dimensions) {
  19278. const precinctWidth = 1 << dimensions.PPx;
  19279. const precinctHeight = 1 << dimensions.PPy;
  19280. const isZeroRes = resolution.resLevel === 0;
  19281. const precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  19282. const precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  19283. const numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  19284. const numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  19285. const numprecincts = numprecinctswide * numprecinctshigh;
  19286. resolution.precinctParameters = {
  19287. precinctWidth,
  19288. precinctHeight,
  19289. numprecinctswide,
  19290. numprecinctshigh,
  19291. numprecincts,
  19292. precinctWidthInSubband,
  19293. precinctHeightInSubband
  19294. };
  19295. }
  19296. function buildCodeblocks(context, subband, dimensions) {
  19297. const xcb_ = dimensions.xcb_;
  19298. const ycb_ = dimensions.ycb_;
  19299. const codeblockWidth = 1 << xcb_;
  19300. const codeblockHeight = 1 << ycb_;
  19301. const cbx0 = subband.tbx0 >> xcb_;
  19302. const cby0 = subband.tby0 >> ycb_;
  19303. const cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  19304. const cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  19305. const precinctParameters = subband.resolution.precinctParameters;
  19306. const codeblocks = [];
  19307. const precincts = [];
  19308. let i, j, codeblock, precinctNumber;
  19309. for (j = cby0; j < cby1; j++) {
  19310. for (i = cbx0; i < cbx1; i++) {
  19311. codeblock = {
  19312. cbx: i,
  19313. cby: j,
  19314. tbx0: codeblockWidth * i,
  19315. tby0: codeblockHeight * j,
  19316. tbx1: codeblockWidth * (i + 1),
  19317. tby1: codeblockHeight * (j + 1)
  19318. };
  19319. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  19320. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  19321. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  19322. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  19323. const pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  19324. const pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  19325. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  19326. codeblock.precinctNumber = precinctNumber;
  19327. codeblock.subbandType = subband.type;
  19328. codeblock.Lblock = 3;
  19329. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  19330. continue;
  19331. }
  19332. codeblocks.push(codeblock);
  19333. let precinct = precincts[precinctNumber];
  19334. if (precinct !== undefined) {
  19335. if (i < precinct.cbxMin) {
  19336. precinct.cbxMin = i;
  19337. } else if (i > precinct.cbxMax) {
  19338. precinct.cbxMax = i;
  19339. }
  19340. if (j < precinct.cbyMin) {
  19341. precinct.cbxMin = j;
  19342. } else if (j > precinct.cbyMax) {
  19343. precinct.cbyMax = j;
  19344. }
  19345. } else {
  19346. precincts[precinctNumber] = precinct = {
  19347. cbxMin: i,
  19348. cbyMin: j,
  19349. cbxMax: i,
  19350. cbyMax: j
  19351. };
  19352. }
  19353. codeblock.precinct = precinct;
  19354. }
  19355. }
  19356. subband.codeblockParameters = {
  19357. codeblockWidth: xcb_,
  19358. codeblockHeight: ycb_,
  19359. numcodeblockwide: cbx1 - cbx0 + 1,
  19360. numcodeblockhigh: cby1 - cby0 + 1
  19361. };
  19362. subband.codeblocks = codeblocks;
  19363. subband.precincts = precincts;
  19364. }
  19365. function createPacket(resolution, precinctNumber, layerNumber) {
  19366. const precinctCodeblocks = [];
  19367. const subbands = resolution.subbands;
  19368. for (let i = 0, ii = subbands.length; i < ii; i++) {
  19369. const subband = subbands[i];
  19370. const codeblocks = subband.codeblocks;
  19371. for (let j = 0, jj = codeblocks.length; j < jj; j++) {
  19372. const codeblock = codeblocks[j];
  19373. if (codeblock.precinctNumber !== precinctNumber) {
  19374. continue;
  19375. }
  19376. precinctCodeblocks.push(codeblock);
  19377. }
  19378. }
  19379. return {
  19380. layerNumber,
  19381. codeblocks: precinctCodeblocks
  19382. };
  19383. }
  19384. function LayerResolutionComponentPositionIterator(context) {
  19385. const siz = context.SIZ;
  19386. const tileIndex = context.currentTile.index;
  19387. const tile = context.tiles[tileIndex];
  19388. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  19389. const componentsCount = siz.Csiz;
  19390. let maxDecompositionLevelsCount = 0;
  19391. for (let q = 0; q < componentsCount; q++) {
  19392. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  19393. }
  19394. let l = 0,
  19395. r = 0,
  19396. i = 0,
  19397. k = 0;
  19398. this.nextPacket = function JpxImage_nextPacket() {
  19399. for (; l < layersCount; l++) {
  19400. for (; r <= maxDecompositionLevelsCount; r++) {
  19401. for (; i < componentsCount; i++) {
  19402. const component = tile.components[i];
  19403. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  19404. continue;
  19405. }
  19406. const resolution = component.resolutions[r];
  19407. const numprecincts = resolution.precinctParameters.numprecincts;
  19408. for (; k < numprecincts;) {
  19409. const packet = createPacket(resolution, k, l);
  19410. k++;
  19411. return packet;
  19412. }
  19413. k = 0;
  19414. }
  19415. i = 0;
  19416. }
  19417. r = 0;
  19418. }
  19419. throw new JpxError("Out of packets");
  19420. };
  19421. }
  19422. function ResolutionLayerComponentPositionIterator(context) {
  19423. const siz = context.SIZ;
  19424. const tileIndex = context.currentTile.index;
  19425. const tile = context.tiles[tileIndex];
  19426. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  19427. const componentsCount = siz.Csiz;
  19428. let maxDecompositionLevelsCount = 0;
  19429. for (let q = 0; q < componentsCount; q++) {
  19430. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  19431. }
  19432. let r = 0,
  19433. l = 0,
  19434. i = 0,
  19435. k = 0;
  19436. this.nextPacket = function JpxImage_nextPacket() {
  19437. for (; r <= maxDecompositionLevelsCount; r++) {
  19438. for (; l < layersCount; l++) {
  19439. for (; i < componentsCount; i++) {
  19440. const component = tile.components[i];
  19441. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  19442. continue;
  19443. }
  19444. const resolution = component.resolutions[r];
  19445. const numprecincts = resolution.precinctParameters.numprecincts;
  19446. for (; k < numprecincts;) {
  19447. const packet = createPacket(resolution, k, l);
  19448. k++;
  19449. return packet;
  19450. }
  19451. k = 0;
  19452. }
  19453. i = 0;
  19454. }
  19455. l = 0;
  19456. }
  19457. throw new JpxError("Out of packets");
  19458. };
  19459. }
  19460. function ResolutionPositionComponentLayerIterator(context) {
  19461. const siz = context.SIZ;
  19462. const tileIndex = context.currentTile.index;
  19463. const tile = context.tiles[tileIndex];
  19464. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  19465. const componentsCount = siz.Csiz;
  19466. let l, r, c, p;
  19467. let maxDecompositionLevelsCount = 0;
  19468. for (c = 0; c < componentsCount; c++) {
  19469. const component = tile.components[c];
  19470. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  19471. }
  19472. const maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  19473. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  19474. let maxNumPrecincts = 0;
  19475. for (c = 0; c < componentsCount; ++c) {
  19476. const resolutions = tile.components[c].resolutions;
  19477. if (r < resolutions.length) {
  19478. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  19479. }
  19480. }
  19481. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  19482. }
  19483. l = 0;
  19484. r = 0;
  19485. c = 0;
  19486. p = 0;
  19487. this.nextPacket = function JpxImage_nextPacket() {
  19488. for (; r <= maxDecompositionLevelsCount; r++) {
  19489. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  19490. for (; c < componentsCount; c++) {
  19491. const component = tile.components[c];
  19492. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  19493. continue;
  19494. }
  19495. const resolution = component.resolutions[r];
  19496. const numprecincts = resolution.precinctParameters.numprecincts;
  19497. if (p >= numprecincts) {
  19498. continue;
  19499. }
  19500. for (; l < layersCount;) {
  19501. const packet = createPacket(resolution, p, l);
  19502. l++;
  19503. return packet;
  19504. }
  19505. l = 0;
  19506. }
  19507. c = 0;
  19508. }
  19509. p = 0;
  19510. }
  19511. throw new JpxError("Out of packets");
  19512. };
  19513. }
  19514. function PositionComponentResolutionLayerIterator(context) {
  19515. const siz = context.SIZ;
  19516. const tileIndex = context.currentTile.index;
  19517. const tile = context.tiles[tileIndex];
  19518. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  19519. const componentsCount = siz.Csiz;
  19520. const precinctsSizes = getPrecinctSizesInImageScale(tile);
  19521. const precinctsIterationSizes = precinctsSizes;
  19522. let l = 0,
  19523. r = 0,
  19524. c = 0,
  19525. px = 0,
  19526. py = 0;
  19527. this.nextPacket = function JpxImage_nextPacket() {
  19528. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  19529. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  19530. for (; c < componentsCount; c++) {
  19531. const component = tile.components[c];
  19532. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  19533. for (; r <= decompositionLevelsCount; r++) {
  19534. const resolution = component.resolutions[r];
  19535. const sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  19536. const k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  19537. if (k === null) {
  19538. continue;
  19539. }
  19540. for (; l < layersCount;) {
  19541. const packet = createPacket(resolution, k, l);
  19542. l++;
  19543. return packet;
  19544. }
  19545. l = 0;
  19546. }
  19547. r = 0;
  19548. }
  19549. c = 0;
  19550. }
  19551. px = 0;
  19552. }
  19553. throw new JpxError("Out of packets");
  19554. };
  19555. }
  19556. function ComponentPositionResolutionLayerIterator(context) {
  19557. const siz = context.SIZ;
  19558. const tileIndex = context.currentTile.index;
  19559. const tile = context.tiles[tileIndex];
  19560. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  19561. const componentsCount = siz.Csiz;
  19562. const precinctsSizes = getPrecinctSizesInImageScale(tile);
  19563. let l = 0,
  19564. r = 0,
  19565. c = 0,
  19566. px = 0,
  19567. py = 0;
  19568. this.nextPacket = function JpxImage_nextPacket() {
  19569. for (; c < componentsCount; ++c) {
  19570. const component = tile.components[c];
  19571. const precinctsIterationSizes = precinctsSizes.components[c];
  19572. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  19573. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  19574. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  19575. for (; r <= decompositionLevelsCount; r++) {
  19576. const resolution = component.resolutions[r];
  19577. const sizeInImageScale = precinctsIterationSizes.resolutions[r];
  19578. const k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  19579. if (k === null) {
  19580. continue;
  19581. }
  19582. for (; l < layersCount;) {
  19583. const packet = createPacket(resolution, k, l);
  19584. l++;
  19585. return packet;
  19586. }
  19587. l = 0;
  19588. }
  19589. r = 0;
  19590. }
  19591. px = 0;
  19592. }
  19593. py = 0;
  19594. }
  19595. throw new JpxError("Out of packets");
  19596. };
  19597. }
  19598. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  19599. const posX = pxIndex * precinctIterationSizes.minWidth;
  19600. const posY = pyIndex * precinctIterationSizes.minHeight;
  19601. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  19602. return null;
  19603. }
  19604. const startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  19605. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  19606. }
  19607. function getPrecinctSizesInImageScale(tile) {
  19608. const componentsCount = tile.components.length;
  19609. let minWidth = Number.MAX_VALUE;
  19610. let minHeight = Number.MAX_VALUE;
  19611. let maxNumWide = 0;
  19612. let maxNumHigh = 0;
  19613. const sizePerComponent = new Array(componentsCount);
  19614. for (let c = 0; c < componentsCount; c++) {
  19615. const component = tile.components[c];
  19616. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  19617. const sizePerResolution = new Array(decompositionLevelsCount + 1);
  19618. let minWidthCurrentComponent = Number.MAX_VALUE;
  19619. let minHeightCurrentComponent = Number.MAX_VALUE;
  19620. let maxNumWideCurrentComponent = 0;
  19621. let maxNumHighCurrentComponent = 0;
  19622. let scale = 1;
  19623. for (let r = decompositionLevelsCount; r >= 0; --r) {
  19624. const resolution = component.resolutions[r];
  19625. const widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  19626. const heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  19627. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  19628. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  19629. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  19630. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  19631. sizePerResolution[r] = {
  19632. width: widthCurrentResolution,
  19633. height: heightCurrentResolution
  19634. };
  19635. scale <<= 1;
  19636. }
  19637. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  19638. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  19639. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  19640. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  19641. sizePerComponent[c] = {
  19642. resolutions: sizePerResolution,
  19643. minWidth: minWidthCurrentComponent,
  19644. minHeight: minHeightCurrentComponent,
  19645. maxNumWide: maxNumWideCurrentComponent,
  19646. maxNumHigh: maxNumHighCurrentComponent
  19647. };
  19648. }
  19649. return {
  19650. components: sizePerComponent,
  19651. minWidth,
  19652. minHeight,
  19653. maxNumWide,
  19654. maxNumHigh
  19655. };
  19656. }
  19657. function buildPackets(context) {
  19658. const siz = context.SIZ;
  19659. const tileIndex = context.currentTile.index;
  19660. const tile = context.tiles[tileIndex];
  19661. const componentsCount = siz.Csiz;
  19662. for (let c = 0; c < componentsCount; c++) {
  19663. const component = tile.components[c];
  19664. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  19665. const resolutions = [];
  19666. const subbands = [];
  19667. for (let r = 0; r <= decompositionLevelsCount; r++) {
  19668. const blocksDimensions = getBlocksDimensions(context, component, r);
  19669. const resolution = {};
  19670. const scale = 1 << decompositionLevelsCount - r;
  19671. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  19672. resolution.try0 = Math.ceil(component.tcy0 / scale);
  19673. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  19674. resolution.try1 = Math.ceil(component.tcy1 / scale);
  19675. resolution.resLevel = r;
  19676. buildPrecincts(context, resolution, blocksDimensions);
  19677. resolutions.push(resolution);
  19678. let subband;
  19679. if (r === 0) {
  19680. subband = {};
  19681. subband.type = "LL";
  19682. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  19683. subband.tby0 = Math.ceil(component.tcy0 / scale);
  19684. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  19685. subband.tby1 = Math.ceil(component.tcy1 / scale);
  19686. subband.resolution = resolution;
  19687. buildCodeblocks(context, subband, blocksDimensions);
  19688. subbands.push(subband);
  19689. resolution.subbands = [subband];
  19690. } else {
  19691. const bscale = 1 << decompositionLevelsCount - r + 1;
  19692. const resolutionSubbands = [];
  19693. subband = {};
  19694. subband.type = "HL";
  19695. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  19696. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  19697. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  19698. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  19699. subband.resolution = resolution;
  19700. buildCodeblocks(context, subband, blocksDimensions);
  19701. subbands.push(subband);
  19702. resolutionSubbands.push(subband);
  19703. subband = {};
  19704. subband.type = "LH";
  19705. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  19706. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  19707. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  19708. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  19709. subband.resolution = resolution;
  19710. buildCodeblocks(context, subband, blocksDimensions);
  19711. subbands.push(subband);
  19712. resolutionSubbands.push(subband);
  19713. subband = {};
  19714. subband.type = "HH";
  19715. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  19716. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  19717. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  19718. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  19719. subband.resolution = resolution;
  19720. buildCodeblocks(context, subband, blocksDimensions);
  19721. subbands.push(subband);
  19722. resolutionSubbands.push(subband);
  19723. resolution.subbands = resolutionSubbands;
  19724. }
  19725. }
  19726. component.resolutions = resolutions;
  19727. component.subbands = subbands;
  19728. }
  19729. const progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  19730. switch (progressionOrder) {
  19731. case 0:
  19732. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  19733. break;
  19734. case 1:
  19735. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  19736. break;
  19737. case 2:
  19738. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  19739. break;
  19740. case 3:
  19741. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  19742. break;
  19743. case 4:
  19744. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  19745. break;
  19746. default:
  19747. throw new JpxError(`Unsupported progression order ${progressionOrder}`);
  19748. }
  19749. }
  19750. function parseTilePackets(context, data, offset, dataLength) {
  19751. let position = 0;
  19752. let buffer,
  19753. bufferSize = 0,
  19754. skipNextBit = false;
  19755. function readBits(count) {
  19756. while (bufferSize < count) {
  19757. const b = data[offset + position];
  19758. position++;
  19759. if (skipNextBit) {
  19760. buffer = buffer << 7 | b;
  19761. bufferSize += 7;
  19762. skipNextBit = false;
  19763. } else {
  19764. buffer = buffer << 8 | b;
  19765. bufferSize += 8;
  19766. }
  19767. if (b === 0xff) {
  19768. skipNextBit = true;
  19769. }
  19770. }
  19771. bufferSize -= count;
  19772. return buffer >>> bufferSize & (1 << count) - 1;
  19773. }
  19774. function skipMarkerIfEqual(value) {
  19775. if (data[offset + position - 1] === 0xff && data[offset + position] === value) {
  19776. skipBytes(1);
  19777. return true;
  19778. } else if (data[offset + position] === 0xff && data[offset + position + 1] === value) {
  19779. skipBytes(2);
  19780. return true;
  19781. }
  19782. return false;
  19783. }
  19784. function skipBytes(count) {
  19785. position += count;
  19786. }
  19787. function alignToByte() {
  19788. bufferSize = 0;
  19789. if (skipNextBit) {
  19790. position++;
  19791. skipNextBit = false;
  19792. }
  19793. }
  19794. function readCodingpasses() {
  19795. if (readBits(1) === 0) {
  19796. return 1;
  19797. }
  19798. if (readBits(1) === 0) {
  19799. return 2;
  19800. }
  19801. let value = readBits(2);
  19802. if (value < 3) {
  19803. return value + 3;
  19804. }
  19805. value = readBits(5);
  19806. if (value < 31) {
  19807. return value + 6;
  19808. }
  19809. value = readBits(7);
  19810. return value + 37;
  19811. }
  19812. const tileIndex = context.currentTile.index;
  19813. const tile = context.tiles[tileIndex];
  19814. const sopMarkerUsed = context.COD.sopMarkerUsed;
  19815. const ephMarkerUsed = context.COD.ephMarkerUsed;
  19816. const packetsIterator = tile.packetsIterator;
  19817. while (position < dataLength) {
  19818. alignToByte();
  19819. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  19820. skipBytes(4);
  19821. }
  19822. const packet = packetsIterator.nextPacket();
  19823. if (!readBits(1)) {
  19824. continue;
  19825. }
  19826. const layerNumber = packet.layerNumber,
  19827. queue = [];
  19828. let codeblock;
  19829. for (let i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  19830. codeblock = packet.codeblocks[i];
  19831. let precinct = codeblock.precinct;
  19832. const codeblockColumn = codeblock.cbx - precinct.cbxMin;
  19833. const codeblockRow = codeblock.cby - precinct.cbyMin;
  19834. let codeblockIncluded = false;
  19835. let firstTimeInclusion = false;
  19836. let valueReady, zeroBitPlanesTree;
  19837. if (codeblock.included !== undefined) {
  19838. codeblockIncluded = !!readBits(1);
  19839. } else {
  19840. precinct = codeblock.precinct;
  19841. let inclusionTree;
  19842. if (precinct.inclusionTree !== undefined) {
  19843. inclusionTree = precinct.inclusionTree;
  19844. } else {
  19845. const width = precinct.cbxMax - precinct.cbxMin + 1;
  19846. const height = precinct.cbyMax - precinct.cbyMin + 1;
  19847. inclusionTree = new InclusionTree(width, height, layerNumber);
  19848. zeroBitPlanesTree = new TagTree(width, height);
  19849. precinct.inclusionTree = inclusionTree;
  19850. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  19851. for (let l = 0; l < layerNumber; l++) {
  19852. if (readBits(1) !== 0) {
  19853. throw new JpxError("Invalid tag tree");
  19854. }
  19855. }
  19856. }
  19857. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  19858. while (true) {
  19859. if (readBits(1)) {
  19860. valueReady = !inclusionTree.nextLevel();
  19861. if (valueReady) {
  19862. codeblock.included = true;
  19863. codeblockIncluded = firstTimeInclusion = true;
  19864. break;
  19865. }
  19866. } else {
  19867. inclusionTree.incrementValue(layerNumber);
  19868. break;
  19869. }
  19870. }
  19871. }
  19872. }
  19873. if (!codeblockIncluded) {
  19874. continue;
  19875. }
  19876. if (firstTimeInclusion) {
  19877. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  19878. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  19879. while (true) {
  19880. if (readBits(1)) {
  19881. valueReady = !zeroBitPlanesTree.nextLevel();
  19882. if (valueReady) {
  19883. break;
  19884. }
  19885. } else {
  19886. zeroBitPlanesTree.incrementValue();
  19887. }
  19888. }
  19889. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  19890. }
  19891. const codingpasses = readCodingpasses();
  19892. while (readBits(1)) {
  19893. codeblock.Lblock++;
  19894. }
  19895. const codingpassesLog2 = (0, _core_utils.log2)(codingpasses);
  19896. const bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  19897. const codedDataLength = readBits(bits);
  19898. queue.push({
  19899. codeblock,
  19900. codingpasses,
  19901. dataLength: codedDataLength
  19902. });
  19903. }
  19904. alignToByte();
  19905. if (ephMarkerUsed) {
  19906. skipMarkerIfEqual(0x92);
  19907. }
  19908. while (queue.length > 0) {
  19909. const packetItem = queue.shift();
  19910. codeblock = packetItem.codeblock;
  19911. if (codeblock.data === undefined) {
  19912. codeblock.data = [];
  19913. }
  19914. codeblock.data.push({
  19915. data,
  19916. start: offset + position,
  19917. end: offset + position + packetItem.dataLength,
  19918. codingpasses: packetItem.codingpasses
  19919. });
  19920. position += packetItem.dataLength;
  19921. }
  19922. }
  19923. return position;
  19924. }
  19925. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed, resetContextProbabilities) {
  19926. const x0 = subband.tbx0;
  19927. const y0 = subband.tby0;
  19928. const width = subband.tbx1 - subband.tbx0;
  19929. const codeblocks = subband.codeblocks;
  19930. const right = subband.type.charAt(0) === "H" ? 1 : 0;
  19931. const bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
  19932. for (let i = 0, ii = codeblocks.length; i < ii; ++i) {
  19933. const codeblock = codeblocks[i];
  19934. const blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  19935. const blockHeight = codeblock.tby1_ - codeblock.tby0_;
  19936. if (blockWidth === 0 || blockHeight === 0) {
  19937. continue;
  19938. }
  19939. if (codeblock.data === undefined) {
  19940. continue;
  19941. }
  19942. const bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  19943. let currentCodingpassType = 2;
  19944. const data = codeblock.data;
  19945. let totalLength = 0,
  19946. codingpasses = 0;
  19947. let j, jj, dataItem;
  19948. for (j = 0, jj = data.length; j < jj; j++) {
  19949. dataItem = data[j];
  19950. totalLength += dataItem.end - dataItem.start;
  19951. codingpasses += dataItem.codingpasses;
  19952. }
  19953. const encodedData = new Uint8Array(totalLength);
  19954. let position = 0;
  19955. for (j = 0, jj = data.length; j < jj; j++) {
  19956. dataItem = data[j];
  19957. const chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  19958. encodedData.set(chunk, position);
  19959. position += chunk.length;
  19960. }
  19961. const decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  19962. bitModel.setDecoder(decoder);
  19963. for (j = 0; j < codingpasses; j++) {
  19964. switch (currentCodingpassType) {
  19965. case 0:
  19966. bitModel.runSignificancePropagationPass();
  19967. break;
  19968. case 1:
  19969. bitModel.runMagnitudeRefinementPass();
  19970. break;
  19971. case 2:
  19972. bitModel.runCleanupPass();
  19973. if (segmentationSymbolUsed) {
  19974. bitModel.checkSegmentationSymbol();
  19975. }
  19976. break;
  19977. }
  19978. if (resetContextProbabilities) {
  19979. bitModel.reset();
  19980. }
  19981. currentCodingpassType = (currentCodingpassType + 1) % 3;
  19982. }
  19983. let offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  19984. const sign = bitModel.coefficentsSign;
  19985. const magnitude = bitModel.coefficentsMagnitude;
  19986. const bitsDecoded = bitModel.bitsDecoded;
  19987. const magnitudeCorrection = reversible ? 0 : 0.5;
  19988. let k, n, nb;
  19989. position = 0;
  19990. const interleave = subband.type !== "LL";
  19991. for (j = 0; j < blockHeight; j++) {
  19992. const row = offset / width | 0;
  19993. const levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  19994. for (k = 0; k < blockWidth; k++) {
  19995. n = magnitude[position];
  19996. if (n !== 0) {
  19997. n = (n + magnitudeCorrection) * delta;
  19998. if (sign[position] !== 0) {
  19999. n = -n;
  20000. }
  20001. nb = bitsDecoded[position];
  20002. const pos = interleave ? levelOffset + (offset << 1) : offset;
  20003. coefficients[pos] = reversible && nb >= mb ? n : n * (1 << mb - nb);
  20004. }
  20005. offset++;
  20006. position++;
  20007. }
  20008. offset += width - blockWidth;
  20009. }
  20010. }
  20011. }
  20012. function transformTile(context, tile, c) {
  20013. const component = tile.components[c];
  20014. const codingStyleParameters = component.codingStyleParameters;
  20015. const quantizationParameters = component.quantizationParameters;
  20016. const decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  20017. const spqcds = quantizationParameters.SPqcds;
  20018. const scalarExpounded = quantizationParameters.scalarExpounded;
  20019. const guardBits = quantizationParameters.guardBits;
  20020. const segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  20021. const resetContextProbabilities = codingStyleParameters.resetContextProbabilities;
  20022. const precision = context.components[c].precision;
  20023. const reversible = codingStyleParameters.reversibleTransformation;
  20024. const transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  20025. const subbandCoefficients = [];
  20026. let b = 0;
  20027. for (let i = 0; i <= decompositionLevelsCount; i++) {
  20028. const resolution = component.resolutions[i];
  20029. const width = resolution.trx1 - resolution.trx0;
  20030. const height = resolution.try1 - resolution.try0;
  20031. const coefficients = new Float32Array(width * height);
  20032. for (let j = 0, jj = resolution.subbands.length; j < jj; j++) {
  20033. let mu, epsilon;
  20034. if (!scalarExpounded) {
  20035. mu = spqcds[0].mu;
  20036. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  20037. } else {
  20038. mu = spqcds[b].mu;
  20039. epsilon = spqcds[b].epsilon;
  20040. b++;
  20041. }
  20042. const subband = resolution.subbands[j];
  20043. const gainLog2 = SubbandsGainLog2[subband.type];
  20044. const delta = reversible ? 1 : 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
  20045. const mb = guardBits + epsilon - 1;
  20046. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed, resetContextProbabilities);
  20047. }
  20048. subbandCoefficients.push({
  20049. width,
  20050. height,
  20051. items: coefficients
  20052. });
  20053. }
  20054. const result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  20055. return {
  20056. left: component.tcx0,
  20057. top: component.tcy0,
  20058. width: result.width,
  20059. height: result.height,
  20060. items: result.items
  20061. };
  20062. }
  20063. function transformComponents(context) {
  20064. const siz = context.SIZ;
  20065. const components = context.components;
  20066. const componentsCount = siz.Csiz;
  20067. const resultImages = [];
  20068. for (let i = 0, ii = context.tiles.length; i < ii; i++) {
  20069. const tile = context.tiles[i];
  20070. const transformedTiles = [];
  20071. for (let c = 0; c < componentsCount; c++) {
  20072. transformedTiles[c] = transformTile(context, tile, c);
  20073. }
  20074. const tile0 = transformedTiles[0];
  20075. const out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  20076. const result = {
  20077. left: tile0.left,
  20078. top: tile0.top,
  20079. width: tile0.width,
  20080. height: tile0.height,
  20081. items: out
  20082. };
  20083. let shift, offset;
  20084. let pos = 0,
  20085. j,
  20086. jj,
  20087. y0,
  20088. y1,
  20089. y2;
  20090. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  20091. const fourComponents = componentsCount === 4;
  20092. const y0items = transformedTiles[0].items;
  20093. const y1items = transformedTiles[1].items;
  20094. const y2items = transformedTiles[2].items;
  20095. const y3items = fourComponents ? transformedTiles[3].items : null;
  20096. shift = components[0].precision - 8;
  20097. offset = (128 << shift) + 0.5;
  20098. const component0 = tile.components[0];
  20099. const alpha01 = componentsCount - 3;
  20100. jj = y0items.length;
  20101. if (!component0.codingStyleParameters.reversibleTransformation) {
  20102. for (j = 0; j < jj; j++, pos += alpha01) {
  20103. y0 = y0items[j] + offset;
  20104. y1 = y1items[j];
  20105. y2 = y2items[j];
  20106. out[pos++] = y0 + 1.402 * y2 >> shift;
  20107. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  20108. out[pos++] = y0 + 1.772 * y1 >> shift;
  20109. }
  20110. } else {
  20111. for (j = 0; j < jj; j++, pos += alpha01) {
  20112. y0 = y0items[j] + offset;
  20113. y1 = y1items[j];
  20114. y2 = y2items[j];
  20115. const g = y0 - (y2 + y1 >> 2);
  20116. out[pos++] = g + y2 >> shift;
  20117. out[pos++] = g >> shift;
  20118. out[pos++] = g + y1 >> shift;
  20119. }
  20120. }
  20121. if (fourComponents) {
  20122. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  20123. out[pos] = y3items[j] + offset >> shift;
  20124. }
  20125. }
  20126. } else {
  20127. for (let c = 0; c < componentsCount; c++) {
  20128. const items = transformedTiles[c].items;
  20129. shift = components[c].precision - 8;
  20130. offset = (128 << shift) + 0.5;
  20131. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  20132. out[pos] = items[j] + offset >> shift;
  20133. pos += componentsCount;
  20134. }
  20135. }
  20136. }
  20137. resultImages.push(result);
  20138. }
  20139. return resultImages;
  20140. }
  20141. function initializeTile(context, tileIndex) {
  20142. const siz = context.SIZ;
  20143. const componentsCount = siz.Csiz;
  20144. const tile = context.tiles[tileIndex];
  20145. for (let c = 0; c < componentsCount; c++) {
  20146. const component = tile.components[c];
  20147. const qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  20148. component.quantizationParameters = qcdOrQcc;
  20149. const codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  20150. component.codingStyleParameters = codOrCoc;
  20151. }
  20152. tile.codingStyleDefaultParameters = context.currentTile.COD;
  20153. }
  20154. class TagTree {
  20155. constructor(width, height) {
  20156. const levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  20157. this.levels = [];
  20158. for (let i = 0; i < levelsLength; i++) {
  20159. const level = {
  20160. width,
  20161. height,
  20162. items: []
  20163. };
  20164. this.levels.push(level);
  20165. width = Math.ceil(width / 2);
  20166. height = Math.ceil(height / 2);
  20167. }
  20168. }
  20169. reset(i, j) {
  20170. let currentLevel = 0,
  20171. value = 0,
  20172. level;
  20173. while (currentLevel < this.levels.length) {
  20174. level = this.levels[currentLevel];
  20175. const index = i + j * level.width;
  20176. if (level.items[index] !== undefined) {
  20177. value = level.items[index];
  20178. break;
  20179. }
  20180. level.index = index;
  20181. i >>= 1;
  20182. j >>= 1;
  20183. currentLevel++;
  20184. }
  20185. currentLevel--;
  20186. level = this.levels[currentLevel];
  20187. level.items[level.index] = value;
  20188. this.currentLevel = currentLevel;
  20189. delete this.value;
  20190. }
  20191. incrementValue() {
  20192. const level = this.levels[this.currentLevel];
  20193. level.items[level.index]++;
  20194. }
  20195. nextLevel() {
  20196. let currentLevel = this.currentLevel;
  20197. let level = this.levels[currentLevel];
  20198. const value = level.items[level.index];
  20199. currentLevel--;
  20200. if (currentLevel < 0) {
  20201. this.value = value;
  20202. return false;
  20203. }
  20204. this.currentLevel = currentLevel;
  20205. level = this.levels[currentLevel];
  20206. level.items[level.index] = value;
  20207. return true;
  20208. }
  20209. }
  20210. class InclusionTree {
  20211. constructor(width, height, defaultValue) {
  20212. const levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  20213. this.levels = [];
  20214. for (let i = 0; i < levelsLength; i++) {
  20215. const items = new Uint8Array(width * height);
  20216. for (let j = 0, jj = items.length; j < jj; j++) {
  20217. items[j] = defaultValue;
  20218. }
  20219. const level = {
  20220. width,
  20221. height,
  20222. items
  20223. };
  20224. this.levels.push(level);
  20225. width = Math.ceil(width / 2);
  20226. height = Math.ceil(height / 2);
  20227. }
  20228. }
  20229. reset(i, j, stopValue) {
  20230. let currentLevel = 0;
  20231. while (currentLevel < this.levels.length) {
  20232. const level = this.levels[currentLevel];
  20233. const index = i + j * level.width;
  20234. level.index = index;
  20235. const value = level.items[index];
  20236. if (value === 0xff) {
  20237. break;
  20238. }
  20239. if (value > stopValue) {
  20240. this.currentLevel = currentLevel;
  20241. this.propagateValues();
  20242. return false;
  20243. }
  20244. i >>= 1;
  20245. j >>= 1;
  20246. currentLevel++;
  20247. }
  20248. this.currentLevel = currentLevel - 1;
  20249. return true;
  20250. }
  20251. incrementValue(stopValue) {
  20252. const level = this.levels[this.currentLevel];
  20253. level.items[level.index] = stopValue + 1;
  20254. this.propagateValues();
  20255. }
  20256. propagateValues() {
  20257. let levelIndex = this.currentLevel;
  20258. let level = this.levels[levelIndex];
  20259. const currentValue = level.items[level.index];
  20260. while (--levelIndex >= 0) {
  20261. level = this.levels[levelIndex];
  20262. level.items[level.index] = currentValue;
  20263. }
  20264. }
  20265. nextLevel() {
  20266. let currentLevel = this.currentLevel;
  20267. let level = this.levels[currentLevel];
  20268. const value = level.items[level.index];
  20269. level.items[level.index] = 0xff;
  20270. currentLevel--;
  20271. if (currentLevel < 0) {
  20272. return false;
  20273. }
  20274. this.currentLevel = currentLevel;
  20275. level = this.levels[currentLevel];
  20276. level.items[level.index] = value;
  20277. return true;
  20278. }
  20279. }
  20280. class BitModel {
  20281. static UNIFORM_CONTEXT = 17;
  20282. static RUNLENGTH_CONTEXT = 18;
  20283. static LLAndLHContextsLabel = new Uint8Array([0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8]);
  20284. static HLContextLabel = new Uint8Array([0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8]);
  20285. static HHContextLabel = new Uint8Array([0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8]);
  20286. constructor(width, height, subband, zeroBitPlanes, mb) {
  20287. this.width = width;
  20288. this.height = height;
  20289. let contextLabelTable;
  20290. if (subband === "HH") {
  20291. contextLabelTable = BitModel.HHContextLabel;
  20292. } else if (subband === "HL") {
  20293. contextLabelTable = BitModel.HLContextLabel;
  20294. } else {
  20295. contextLabelTable = BitModel.LLAndLHContextsLabel;
  20296. }
  20297. this.contextLabelTable = contextLabelTable;
  20298. const coefficientCount = width * height;
  20299. this.neighborsSignificance = new Uint8Array(coefficientCount);
  20300. this.coefficentsSign = new Uint8Array(coefficientCount);
  20301. let coefficentsMagnitude;
  20302. if (mb > 14) {
  20303. coefficentsMagnitude = new Uint32Array(coefficientCount);
  20304. } else if (mb > 6) {
  20305. coefficentsMagnitude = new Uint16Array(coefficientCount);
  20306. } else {
  20307. coefficentsMagnitude = new Uint8Array(coefficientCount);
  20308. }
  20309. this.coefficentsMagnitude = coefficentsMagnitude;
  20310. this.processingFlags = new Uint8Array(coefficientCount);
  20311. const bitsDecoded = new Uint8Array(coefficientCount);
  20312. if (zeroBitPlanes !== 0) {
  20313. for (let i = 0; i < coefficientCount; i++) {
  20314. bitsDecoded[i] = zeroBitPlanes;
  20315. }
  20316. }
  20317. this.bitsDecoded = bitsDecoded;
  20318. this.reset();
  20319. }
  20320. setDecoder(decoder) {
  20321. this.decoder = decoder;
  20322. }
  20323. reset() {
  20324. this.contexts = new Int8Array(19);
  20325. this.contexts[0] = 4 << 1 | 0;
  20326. this.contexts[BitModel.UNIFORM_CONTEXT] = 46 << 1 | 0;
  20327. this.contexts[BitModel.RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  20328. }
  20329. setNeighborsSignificance(row, column, index) {
  20330. const neighborsSignificance = this.neighborsSignificance;
  20331. const width = this.width,
  20332. height = this.height;
  20333. const left = column > 0;
  20334. const right = column + 1 < width;
  20335. let i;
  20336. if (row > 0) {
  20337. i = index - width;
  20338. if (left) {
  20339. neighborsSignificance[i - 1] += 0x10;
  20340. }
  20341. if (right) {
  20342. neighborsSignificance[i + 1] += 0x10;
  20343. }
  20344. neighborsSignificance[i] += 0x04;
  20345. }
  20346. if (row + 1 < height) {
  20347. i = index + width;
  20348. if (left) {
  20349. neighborsSignificance[i - 1] += 0x10;
  20350. }
  20351. if (right) {
  20352. neighborsSignificance[i + 1] += 0x10;
  20353. }
  20354. neighborsSignificance[i] += 0x04;
  20355. }
  20356. if (left) {
  20357. neighborsSignificance[index - 1] += 0x01;
  20358. }
  20359. if (right) {
  20360. neighborsSignificance[index + 1] += 0x01;
  20361. }
  20362. neighborsSignificance[index] |= 0x80;
  20363. }
  20364. runSignificancePropagationPass() {
  20365. const decoder = this.decoder;
  20366. const width = this.width,
  20367. height = this.height;
  20368. const coefficentsMagnitude = this.coefficentsMagnitude;
  20369. const coefficentsSign = this.coefficentsSign;
  20370. const neighborsSignificance = this.neighborsSignificance;
  20371. const processingFlags = this.processingFlags;
  20372. const contexts = this.contexts;
  20373. const labels = this.contextLabelTable;
  20374. const bitsDecoded = this.bitsDecoded;
  20375. const processedInverseMask = ~1;
  20376. const processedMask = 1;
  20377. const firstMagnitudeBitMask = 2;
  20378. for (let i0 = 0; i0 < height; i0 += 4) {
  20379. for (let j = 0; j < width; j++) {
  20380. let index = i0 * width + j;
  20381. for (let i1 = 0; i1 < 4; i1++, index += width) {
  20382. const i = i0 + i1;
  20383. if (i >= height) {
  20384. break;
  20385. }
  20386. processingFlags[index] &= processedInverseMask;
  20387. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  20388. continue;
  20389. }
  20390. const contextLabel = labels[neighborsSignificance[index]];
  20391. const decision = decoder.readBit(contexts, contextLabel);
  20392. if (decision) {
  20393. const sign = this.decodeSignBit(i, j, index);
  20394. coefficentsSign[index] = sign;
  20395. coefficentsMagnitude[index] = 1;
  20396. this.setNeighborsSignificance(i, j, index);
  20397. processingFlags[index] |= firstMagnitudeBitMask;
  20398. }
  20399. bitsDecoded[index]++;
  20400. processingFlags[index] |= processedMask;
  20401. }
  20402. }
  20403. }
  20404. }
  20405. decodeSignBit(row, column, index) {
  20406. const width = this.width,
  20407. height = this.height;
  20408. const coefficentsMagnitude = this.coefficentsMagnitude;
  20409. const coefficentsSign = this.coefficentsSign;
  20410. let contribution, sign0, sign1, significance1;
  20411. let contextLabel, decoded;
  20412. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  20413. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  20414. sign1 = coefficentsSign[index + 1];
  20415. if (significance1) {
  20416. sign0 = coefficentsSign[index - 1];
  20417. contribution = 1 - sign1 - sign0;
  20418. } else {
  20419. contribution = 1 - sign1 - sign1;
  20420. }
  20421. } else if (significance1) {
  20422. sign0 = coefficentsSign[index - 1];
  20423. contribution = 1 - sign0 - sign0;
  20424. } else {
  20425. contribution = 0;
  20426. }
  20427. const horizontalContribution = 3 * contribution;
  20428. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  20429. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  20430. sign1 = coefficentsSign[index + width];
  20431. if (significance1) {
  20432. sign0 = coefficentsSign[index - width];
  20433. contribution = 1 - sign1 - sign0 + horizontalContribution;
  20434. } else {
  20435. contribution = 1 - sign1 - sign1 + horizontalContribution;
  20436. }
  20437. } else if (significance1) {
  20438. sign0 = coefficentsSign[index - width];
  20439. contribution = 1 - sign0 - sign0 + horizontalContribution;
  20440. } else {
  20441. contribution = horizontalContribution;
  20442. }
  20443. if (contribution >= 0) {
  20444. contextLabel = 9 + contribution;
  20445. decoded = this.decoder.readBit(this.contexts, contextLabel);
  20446. } else {
  20447. contextLabel = 9 - contribution;
  20448. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  20449. }
  20450. return decoded;
  20451. }
  20452. runMagnitudeRefinementPass() {
  20453. const decoder = this.decoder;
  20454. const width = this.width,
  20455. height = this.height;
  20456. const coefficentsMagnitude = this.coefficentsMagnitude;
  20457. const neighborsSignificance = this.neighborsSignificance;
  20458. const contexts = this.contexts;
  20459. const bitsDecoded = this.bitsDecoded;
  20460. const processingFlags = this.processingFlags;
  20461. const processedMask = 1;
  20462. const firstMagnitudeBitMask = 2;
  20463. const length = width * height;
  20464. const width4 = width * 4;
  20465. for (let index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  20466. indexNext = Math.min(length, index0 + width4);
  20467. for (let j = 0; j < width; j++) {
  20468. for (let index = index0 + j; index < indexNext; index += width) {
  20469. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  20470. continue;
  20471. }
  20472. let contextLabel = 16;
  20473. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  20474. processingFlags[index] ^= firstMagnitudeBitMask;
  20475. const significance = neighborsSignificance[index] & 127;
  20476. contextLabel = significance === 0 ? 15 : 14;
  20477. }
  20478. const bit = decoder.readBit(contexts, contextLabel);
  20479. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  20480. bitsDecoded[index]++;
  20481. processingFlags[index] |= processedMask;
  20482. }
  20483. }
  20484. }
  20485. }
  20486. runCleanupPass() {
  20487. const decoder = this.decoder;
  20488. const width = this.width,
  20489. height = this.height;
  20490. const neighborsSignificance = this.neighborsSignificance;
  20491. const coefficentsMagnitude = this.coefficentsMagnitude;
  20492. const coefficentsSign = this.coefficentsSign;
  20493. const contexts = this.contexts;
  20494. const labels = this.contextLabelTable;
  20495. const bitsDecoded = this.bitsDecoded;
  20496. const processingFlags = this.processingFlags;
  20497. const processedMask = 1;
  20498. const firstMagnitudeBitMask = 2;
  20499. const oneRowDown = width;
  20500. const twoRowsDown = width * 2;
  20501. const threeRowsDown = width * 3;
  20502. let iNext;
  20503. for (let i0 = 0; i0 < height; i0 = iNext) {
  20504. iNext = Math.min(i0 + 4, height);
  20505. const indexBase = i0 * width;
  20506. const checkAllEmpty = i0 + 3 < height;
  20507. for (let j = 0; j < width; j++) {
  20508. const index0 = indexBase + j;
  20509. const allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  20510. let i1 = 0,
  20511. index = index0;
  20512. let i = i0,
  20513. sign;
  20514. if (allEmpty) {
  20515. const hasSignificantCoefficent = decoder.readBit(contexts, BitModel.RUNLENGTH_CONTEXT);
  20516. if (!hasSignificantCoefficent) {
  20517. bitsDecoded[index0]++;
  20518. bitsDecoded[index0 + oneRowDown]++;
  20519. bitsDecoded[index0 + twoRowsDown]++;
  20520. bitsDecoded[index0 + threeRowsDown]++;
  20521. continue;
  20522. }
  20523. i1 = decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT);
  20524. if (i1 !== 0) {
  20525. i = i0 + i1;
  20526. index += i1 * width;
  20527. }
  20528. sign = this.decodeSignBit(i, j, index);
  20529. coefficentsSign[index] = sign;
  20530. coefficentsMagnitude[index] = 1;
  20531. this.setNeighborsSignificance(i, j, index);
  20532. processingFlags[index] |= firstMagnitudeBitMask;
  20533. index = index0;
  20534. for (let i2 = i0; i2 <= i; i2++, index += width) {
  20535. bitsDecoded[index]++;
  20536. }
  20537. i1++;
  20538. }
  20539. for (i = i0 + i1; i < iNext; i++, index += width) {
  20540. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  20541. continue;
  20542. }
  20543. const contextLabel = labels[neighborsSignificance[index]];
  20544. const decision = decoder.readBit(contexts, contextLabel);
  20545. if (decision === 1) {
  20546. sign = this.decodeSignBit(i, j, index);
  20547. coefficentsSign[index] = sign;
  20548. coefficentsMagnitude[index] = 1;
  20549. this.setNeighborsSignificance(i, j, index);
  20550. processingFlags[index] |= firstMagnitudeBitMask;
  20551. }
  20552. bitsDecoded[index]++;
  20553. }
  20554. }
  20555. }
  20556. }
  20557. checkSegmentationSymbol() {
  20558. const decoder = this.decoder;
  20559. const contexts = this.contexts;
  20560. const symbol = decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT);
  20561. if (symbol !== 0xa) {
  20562. throw new JpxError("Invalid segmentation symbol");
  20563. }
  20564. }
  20565. }
  20566. class Transform {
  20567. constructor() {
  20568. if (this.constructor === Transform) {
  20569. (0, _util.unreachable)("Cannot initialize Transform.");
  20570. }
  20571. }
  20572. calculate(subbands, u0, v0) {
  20573. let ll = subbands[0];
  20574. for (let i = 1, ii = subbands.length; i < ii; i++) {
  20575. ll = this.iterate(ll, subbands[i], u0, v0);
  20576. }
  20577. return ll;
  20578. }
  20579. extend(buffer, offset, size) {
  20580. let i1 = offset - 1,
  20581. j1 = offset + 1;
  20582. let i2 = offset + size - 2,
  20583. j2 = offset + size;
  20584. buffer[i1--] = buffer[j1++];
  20585. buffer[j2++] = buffer[i2--];
  20586. buffer[i1--] = buffer[j1++];
  20587. buffer[j2++] = buffer[i2--];
  20588. buffer[i1--] = buffer[j1++];
  20589. buffer[j2++] = buffer[i2--];
  20590. buffer[i1] = buffer[j1];
  20591. buffer[j2] = buffer[i2];
  20592. }
  20593. filter(x, offset, length) {
  20594. (0, _util.unreachable)("Abstract method `filter` called");
  20595. }
  20596. iterate(ll, hl_lh_hh, u0, v0) {
  20597. const llWidth = ll.width,
  20598. llHeight = ll.height;
  20599. let llItems = ll.items;
  20600. const width = hl_lh_hh.width;
  20601. const height = hl_lh_hh.height;
  20602. const items = hl_lh_hh.items;
  20603. let i, j, k, l, u, v;
  20604. for (k = 0, i = 0; i < llHeight; i++) {
  20605. l = i * 2 * width;
  20606. for (j = 0; j < llWidth; j++, k++, l += 2) {
  20607. items[l] = llItems[k];
  20608. }
  20609. }
  20610. llItems = ll.items = null;
  20611. const bufferPadding = 4;
  20612. const rowBuffer = new Float32Array(width + 2 * bufferPadding);
  20613. if (width === 1) {
  20614. if ((u0 & 1) !== 0) {
  20615. for (v = 0, k = 0; v < height; v++, k += width) {
  20616. items[k] *= 0.5;
  20617. }
  20618. }
  20619. } else {
  20620. for (v = 0, k = 0; v < height; v++, k += width) {
  20621. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  20622. this.extend(rowBuffer, bufferPadding, width);
  20623. this.filter(rowBuffer, bufferPadding, width);
  20624. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  20625. }
  20626. }
  20627. let numBuffers = 16;
  20628. const colBuffers = [];
  20629. for (i = 0; i < numBuffers; i++) {
  20630. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  20631. }
  20632. let b,
  20633. currentBuffer = 0;
  20634. ll = bufferPadding + height;
  20635. if (height === 1) {
  20636. if ((v0 & 1) !== 0) {
  20637. for (u = 0; u < width; u++) {
  20638. items[u] *= 0.5;
  20639. }
  20640. }
  20641. } else {
  20642. for (u = 0; u < width; u++) {
  20643. if (currentBuffer === 0) {
  20644. numBuffers = Math.min(width - u, numBuffers);
  20645. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  20646. for (b = 0; b < numBuffers; b++) {
  20647. colBuffers[b][l] = items[k + b];
  20648. }
  20649. }
  20650. currentBuffer = numBuffers;
  20651. }
  20652. currentBuffer--;
  20653. const buffer = colBuffers[currentBuffer];
  20654. this.extend(buffer, bufferPadding, height);
  20655. this.filter(buffer, bufferPadding, height);
  20656. if (currentBuffer === 0) {
  20657. k = u - numBuffers + 1;
  20658. for (l = bufferPadding; l < ll; k += width, l++) {
  20659. for (b = 0; b < numBuffers; b++) {
  20660. items[k + b] = colBuffers[b][l];
  20661. }
  20662. }
  20663. }
  20664. }
  20665. }
  20666. return {
  20667. width,
  20668. height,
  20669. items
  20670. };
  20671. }
  20672. }
  20673. class IrreversibleTransform extends Transform {
  20674. filter(x, offset, length) {
  20675. const len = length >> 1;
  20676. offset |= 0;
  20677. let j, n, current, next;
  20678. const alpha = -1.586134342059924;
  20679. const beta = -0.052980118572961;
  20680. const gamma = 0.882911075530934;
  20681. const delta = 0.443506852043971;
  20682. const K = 1.230174104914001;
  20683. const K_ = 1 / K;
  20684. j = offset - 3;
  20685. for (n = len + 4; n--; j += 2) {
  20686. x[j] *= K_;
  20687. }
  20688. j = offset - 2;
  20689. current = delta * x[j - 1];
  20690. for (n = len + 3; n--; j += 2) {
  20691. next = delta * x[j + 1];
  20692. x[j] = K * x[j] - current - next;
  20693. if (n--) {
  20694. j += 2;
  20695. current = delta * x[j + 1];
  20696. x[j] = K * x[j] - current - next;
  20697. } else {
  20698. break;
  20699. }
  20700. }
  20701. j = offset - 1;
  20702. current = gamma * x[j - 1];
  20703. for (n = len + 2; n--; j += 2) {
  20704. next = gamma * x[j + 1];
  20705. x[j] -= current + next;
  20706. if (n--) {
  20707. j += 2;
  20708. current = gamma * x[j + 1];
  20709. x[j] -= current + next;
  20710. } else {
  20711. break;
  20712. }
  20713. }
  20714. j = offset;
  20715. current = beta * x[j - 1];
  20716. for (n = len + 1; n--; j += 2) {
  20717. next = beta * x[j + 1];
  20718. x[j] -= current + next;
  20719. if (n--) {
  20720. j += 2;
  20721. current = beta * x[j + 1];
  20722. x[j] -= current + next;
  20723. } else {
  20724. break;
  20725. }
  20726. }
  20727. if (len !== 0) {
  20728. j = offset + 1;
  20729. current = alpha * x[j - 1];
  20730. for (n = len; n--; j += 2) {
  20731. next = alpha * x[j + 1];
  20732. x[j] -= current + next;
  20733. if (n--) {
  20734. j += 2;
  20735. current = alpha * x[j + 1];
  20736. x[j] -= current + next;
  20737. } else {
  20738. break;
  20739. }
  20740. }
  20741. }
  20742. }
  20743. }
  20744. class ReversibleTransform extends Transform {
  20745. filter(x, offset, length) {
  20746. const len = length >> 1;
  20747. offset |= 0;
  20748. let j, n;
  20749. for (j = offset, n = len + 1; n--; j += 2) {
  20750. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  20751. }
  20752. for (j = offset + 1, n = len; n--; j += 2) {
  20753. x[j] += x[j - 1] + x[j + 1] >> 1;
  20754. }
  20755. }
  20756. }
  20757. /***/ }),
  20758. /* 31 */
  20759. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20760. Object.defineProperty(exports, "__esModule", ({
  20761. value: true
  20762. }));
  20763. exports.LZWStream = void 0;
  20764. var _decode_stream = __w_pdfjs_require__(18);
  20765. class LZWStream extends _decode_stream.DecodeStream {
  20766. constructor(str, maybeLength, earlyChange) {
  20767. super(maybeLength);
  20768. this.str = str;
  20769. this.dict = str.dict;
  20770. this.cachedData = 0;
  20771. this.bitsCached = 0;
  20772. const maxLzwDictionarySize = 4096;
  20773. const lzwState = {
  20774. earlyChange,
  20775. codeLength: 9,
  20776. nextCode: 258,
  20777. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  20778. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  20779. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  20780. currentSequence: new Uint8Array(maxLzwDictionarySize),
  20781. currentSequenceLength: 0
  20782. };
  20783. for (let i = 0; i < 256; ++i) {
  20784. lzwState.dictionaryValues[i] = i;
  20785. lzwState.dictionaryLengths[i] = 1;
  20786. }
  20787. this.lzwState = lzwState;
  20788. }
  20789. readBits(n) {
  20790. let bitsCached = this.bitsCached;
  20791. let cachedData = this.cachedData;
  20792. while (bitsCached < n) {
  20793. const c = this.str.getByte();
  20794. if (c === -1) {
  20795. this.eof = true;
  20796. return null;
  20797. }
  20798. cachedData = cachedData << 8 | c;
  20799. bitsCached += 8;
  20800. }
  20801. this.bitsCached = bitsCached -= n;
  20802. this.cachedData = cachedData;
  20803. this.lastCode = null;
  20804. return cachedData >>> bitsCached & (1 << n) - 1;
  20805. }
  20806. readBlock() {
  20807. const blockSize = 512,
  20808. decodedSizeDelta = blockSize;
  20809. let estimatedDecodedSize = blockSize * 2;
  20810. let i, j, q;
  20811. const lzwState = this.lzwState;
  20812. if (!lzwState) {
  20813. return;
  20814. }
  20815. const earlyChange = lzwState.earlyChange;
  20816. let nextCode = lzwState.nextCode;
  20817. const dictionaryValues = lzwState.dictionaryValues;
  20818. const dictionaryLengths = lzwState.dictionaryLengths;
  20819. const dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  20820. let codeLength = lzwState.codeLength;
  20821. let prevCode = lzwState.prevCode;
  20822. const currentSequence = lzwState.currentSequence;
  20823. let currentSequenceLength = lzwState.currentSequenceLength;
  20824. let decodedLength = 0;
  20825. let currentBufferLength = this.bufferLength;
  20826. let buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  20827. for (i = 0; i < blockSize; i++) {
  20828. const code = this.readBits(codeLength);
  20829. const hasPrev = currentSequenceLength > 0;
  20830. if (code < 256) {
  20831. currentSequence[0] = code;
  20832. currentSequenceLength = 1;
  20833. } else if (code >= 258) {
  20834. if (code < nextCode) {
  20835. currentSequenceLength = dictionaryLengths[code];
  20836. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  20837. currentSequence[j] = dictionaryValues[q];
  20838. q = dictionaryPrevCodes[q];
  20839. }
  20840. } else {
  20841. currentSequence[currentSequenceLength++] = currentSequence[0];
  20842. }
  20843. } else if (code === 256) {
  20844. codeLength = 9;
  20845. nextCode = 258;
  20846. currentSequenceLength = 0;
  20847. continue;
  20848. } else {
  20849. this.eof = true;
  20850. delete this.lzwState;
  20851. break;
  20852. }
  20853. if (hasPrev) {
  20854. dictionaryPrevCodes[nextCode] = prevCode;
  20855. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  20856. dictionaryValues[nextCode] = currentSequence[0];
  20857. nextCode++;
  20858. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  20859. }
  20860. prevCode = code;
  20861. decodedLength += currentSequenceLength;
  20862. if (estimatedDecodedSize < decodedLength) {
  20863. do {
  20864. estimatedDecodedSize += decodedSizeDelta;
  20865. } while (estimatedDecodedSize < decodedLength);
  20866. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  20867. }
  20868. for (j = 0; j < currentSequenceLength; j++) {
  20869. buffer[currentBufferLength++] = currentSequence[j];
  20870. }
  20871. }
  20872. lzwState.nextCode = nextCode;
  20873. lzwState.codeLength = codeLength;
  20874. lzwState.prevCode = prevCode;
  20875. lzwState.currentSequenceLength = currentSequenceLength;
  20876. this.bufferLength = currentBufferLength;
  20877. }
  20878. }
  20879. exports.LZWStream = LZWStream;
  20880. /***/ }),
  20881. /* 32 */
  20882. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20883. Object.defineProperty(exports, "__esModule", ({
  20884. value: true
  20885. }));
  20886. exports.PredictorStream = void 0;
  20887. var _decode_stream = __w_pdfjs_require__(18);
  20888. var _primitives = __w_pdfjs_require__(4);
  20889. var _util = __w_pdfjs_require__(2);
  20890. class PredictorStream extends _decode_stream.DecodeStream {
  20891. constructor(str, maybeLength, params) {
  20892. super(maybeLength);
  20893. if (!(params instanceof _primitives.Dict)) {
  20894. return str;
  20895. }
  20896. const predictor = this.predictor = params.get("Predictor") || 1;
  20897. if (predictor <= 1) {
  20898. return str;
  20899. }
  20900. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  20901. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  20902. }
  20903. this.readBlock = predictor === 2 ? this.readBlockTiff : this.readBlockPng;
  20904. this.str = str;
  20905. this.dict = str.dict;
  20906. const colors = this.colors = params.get("Colors") || 1;
  20907. const bits = this.bits = params.get("BPC", "BitsPerComponent") || 8;
  20908. const columns = this.columns = params.get("Columns") || 1;
  20909. this.pixBytes = colors * bits + 7 >> 3;
  20910. this.rowBytes = columns * colors * bits + 7 >> 3;
  20911. return this;
  20912. }
  20913. readBlockTiff() {
  20914. const rowBytes = this.rowBytes;
  20915. const bufferLength = this.bufferLength;
  20916. const buffer = this.ensureBuffer(bufferLength + rowBytes);
  20917. const bits = this.bits;
  20918. const colors = this.colors;
  20919. const rawBytes = this.str.getBytes(rowBytes);
  20920. this.eof = !rawBytes.length;
  20921. if (this.eof) {
  20922. return;
  20923. }
  20924. let inbuf = 0,
  20925. outbuf = 0;
  20926. let inbits = 0,
  20927. outbits = 0;
  20928. let pos = bufferLength;
  20929. let i;
  20930. if (bits === 1 && colors === 1) {
  20931. for (i = 0; i < rowBytes; ++i) {
  20932. let c = rawBytes[i] ^ inbuf;
  20933. c ^= c >> 1;
  20934. c ^= c >> 2;
  20935. c ^= c >> 4;
  20936. inbuf = (c & 1) << 7;
  20937. buffer[pos++] = c;
  20938. }
  20939. } else if (bits === 8) {
  20940. for (i = 0; i < colors; ++i) {
  20941. buffer[pos++] = rawBytes[i];
  20942. }
  20943. for (; i < rowBytes; ++i) {
  20944. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  20945. pos++;
  20946. }
  20947. } else if (bits === 16) {
  20948. const bytesPerPixel = colors * 2;
  20949. for (i = 0; i < bytesPerPixel; ++i) {
  20950. buffer[pos++] = rawBytes[i];
  20951. }
  20952. for (; i < rowBytes; i += 2) {
  20953. const sum = ((rawBytes[i] & 0xff) << 8) + (rawBytes[i + 1] & 0xff) + ((buffer[pos - bytesPerPixel] & 0xff) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xff);
  20954. buffer[pos++] = sum >> 8 & 0xff;
  20955. buffer[pos++] = sum & 0xff;
  20956. }
  20957. } else {
  20958. const compArray = new Uint8Array(colors + 1);
  20959. const bitMask = (1 << bits) - 1;
  20960. let j = 0,
  20961. k = bufferLength;
  20962. const columns = this.columns;
  20963. for (i = 0; i < columns; ++i) {
  20964. for (let kk = 0; kk < colors; ++kk) {
  20965. if (inbits < bits) {
  20966. inbuf = inbuf << 8 | rawBytes[j++] & 0xff;
  20967. inbits += 8;
  20968. }
  20969. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  20970. inbits -= bits;
  20971. outbuf = outbuf << bits | compArray[kk];
  20972. outbits += bits;
  20973. if (outbits >= 8) {
  20974. buffer[k++] = outbuf >> outbits - 8 & 0xff;
  20975. outbits -= 8;
  20976. }
  20977. }
  20978. }
  20979. if (outbits > 0) {
  20980. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  20981. }
  20982. }
  20983. this.bufferLength += rowBytes;
  20984. }
  20985. readBlockPng() {
  20986. const rowBytes = this.rowBytes;
  20987. const pixBytes = this.pixBytes;
  20988. const predictor = this.str.getByte();
  20989. const rawBytes = this.str.getBytes(rowBytes);
  20990. this.eof = !rawBytes.length;
  20991. if (this.eof) {
  20992. return;
  20993. }
  20994. const bufferLength = this.bufferLength;
  20995. const buffer = this.ensureBuffer(bufferLength + rowBytes);
  20996. let prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  20997. if (prevRow.length === 0) {
  20998. prevRow = new Uint8Array(rowBytes);
  20999. }
  21000. let i,
  21001. j = bufferLength,
  21002. up,
  21003. c;
  21004. switch (predictor) {
  21005. case 0:
  21006. for (i = 0; i < rowBytes; ++i) {
  21007. buffer[j++] = rawBytes[i];
  21008. }
  21009. break;
  21010. case 1:
  21011. for (i = 0; i < pixBytes; ++i) {
  21012. buffer[j++] = rawBytes[i];
  21013. }
  21014. for (; i < rowBytes; ++i) {
  21015. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xff;
  21016. j++;
  21017. }
  21018. break;
  21019. case 2:
  21020. for (i = 0; i < rowBytes; ++i) {
  21021. buffer[j++] = prevRow[i] + rawBytes[i] & 0xff;
  21022. }
  21023. break;
  21024. case 3:
  21025. for (i = 0; i < pixBytes; ++i) {
  21026. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  21027. }
  21028. for (; i < rowBytes; ++i) {
  21029. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xff;
  21030. j++;
  21031. }
  21032. break;
  21033. case 4:
  21034. for (i = 0; i < pixBytes; ++i) {
  21035. up = prevRow[i];
  21036. c = rawBytes[i];
  21037. buffer[j++] = up + c;
  21038. }
  21039. for (; i < rowBytes; ++i) {
  21040. up = prevRow[i];
  21041. const upLeft = prevRow[i - pixBytes];
  21042. const left = buffer[j - pixBytes];
  21043. const p = left + up - upLeft;
  21044. let pa = p - left;
  21045. if (pa < 0) {
  21046. pa = -pa;
  21047. }
  21048. let pb = p - up;
  21049. if (pb < 0) {
  21050. pb = -pb;
  21051. }
  21052. let pc = p - upLeft;
  21053. if (pc < 0) {
  21054. pc = -pc;
  21055. }
  21056. c = rawBytes[i];
  21057. if (pa <= pb && pa <= pc) {
  21058. buffer[j++] = left + c;
  21059. } else if (pb <= pc) {
  21060. buffer[j++] = up + c;
  21061. } else {
  21062. buffer[j++] = upLeft + c;
  21063. }
  21064. }
  21065. break;
  21066. default:
  21067. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  21068. }
  21069. this.bufferLength += rowBytes;
  21070. }
  21071. }
  21072. exports.PredictorStream = PredictorStream;
  21073. /***/ }),
  21074. /* 33 */
  21075. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21076. Object.defineProperty(exports, "__esModule", ({
  21077. value: true
  21078. }));
  21079. exports.RunLengthStream = void 0;
  21080. var _decode_stream = __w_pdfjs_require__(18);
  21081. class RunLengthStream extends _decode_stream.DecodeStream {
  21082. constructor(str, maybeLength) {
  21083. super(maybeLength);
  21084. this.str = str;
  21085. this.dict = str.dict;
  21086. }
  21087. readBlock() {
  21088. const repeatHeader = this.str.getBytes(2);
  21089. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  21090. this.eof = true;
  21091. return;
  21092. }
  21093. let buffer;
  21094. let bufferLength = this.bufferLength;
  21095. let n = repeatHeader[0];
  21096. if (n < 128) {
  21097. buffer = this.ensureBuffer(bufferLength + n + 1);
  21098. buffer[bufferLength++] = repeatHeader[1];
  21099. if (n > 0) {
  21100. const source = this.str.getBytes(n);
  21101. buffer.set(source, bufferLength);
  21102. bufferLength += n;
  21103. }
  21104. } else {
  21105. n = 257 - n;
  21106. const b = repeatHeader[1];
  21107. buffer = this.ensureBuffer(bufferLength + n + 1);
  21108. for (let i = 0; i < n; i++) {
  21109. buffer[bufferLength++] = b;
  21110. }
  21111. }
  21112. this.bufferLength = bufferLength;
  21113. }
  21114. }
  21115. exports.RunLengthStream = RunLengthStream;
  21116. /***/ }),
  21117. /* 34 */
  21118. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21119. Object.defineProperty(exports, "__esModule", ({
  21120. value: true
  21121. }));
  21122. exports.Font = exports.ErrorFont = void 0;
  21123. var _util = __w_pdfjs_require__(2);
  21124. var _cff_parser = __w_pdfjs_require__(35);
  21125. var _fonts_utils = __w_pdfjs_require__(38);
  21126. var _unicode = __w_pdfjs_require__(40);
  21127. var _glyphlist = __w_pdfjs_require__(39);
  21128. var _encodings = __w_pdfjs_require__(37);
  21129. var _standard_fonts = __w_pdfjs_require__(41);
  21130. var _to_unicode_map = __w_pdfjs_require__(42);
  21131. var _cff_font = __w_pdfjs_require__(43);
  21132. var _font_renderer = __w_pdfjs_require__(44);
  21133. var _metrics = __w_pdfjs_require__(45);
  21134. var _glyf = __w_pdfjs_require__(46);
  21135. var _cmap = __w_pdfjs_require__(14);
  21136. var _opentype_file_builder = __w_pdfjs_require__(47);
  21137. var _core_utils = __w_pdfjs_require__(3);
  21138. var _stream = __w_pdfjs_require__(8);
  21139. var _type1_font = __w_pdfjs_require__(48);
  21140. const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
  21141. const PDF_GLYPH_SPACE_UNITS = 1000;
  21142. const EXPORT_DATA_PROPERTIES = ["ascent", "bbox", "black", "bold", "charProcOperatorList", "composite", "cssFontInfo", "data", "defaultVMetrics", "defaultWidth", "descent", "fallbackName", "fontMatrix", "isInvalidPDFjsFont", "isType3Font", "italic", "loadedName", "mimetype", "missingFile", "name", "remeasure", "subtype", "systemFontInfo", "type", "vertical"];
  21143. const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "defaultEncoding", "differences", "isMonospace", "isSerifFont", "isSymbolicFont", "seacMap", "toFontChar", "toUnicode", "vmetrics", "widths"];
  21144. function adjustWidths(properties) {
  21145. if (!properties.fontMatrix) {
  21146. return;
  21147. }
  21148. if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
  21149. return;
  21150. }
  21151. const scale = 0.001 / properties.fontMatrix[0];
  21152. const glyphsWidths = properties.widths;
  21153. for (const glyph in glyphsWidths) {
  21154. glyphsWidths[glyph] *= scale;
  21155. }
  21156. properties.defaultWidth *= scale;
  21157. }
  21158. function adjustTrueTypeToUnicode(properties, isSymbolicFont, nameRecords) {
  21159. if (properties.isInternalFont) {
  21160. return;
  21161. }
  21162. if (properties.hasIncludedToUnicodeMap) {
  21163. return;
  21164. }
  21165. if (properties.hasEncoding) {
  21166. return;
  21167. }
  21168. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  21169. return;
  21170. }
  21171. if (!isSymbolicFont) {
  21172. return;
  21173. }
  21174. if (nameRecords.length === 0) {
  21175. return;
  21176. }
  21177. if (properties.defaultEncoding === _encodings.WinAnsiEncoding) {
  21178. return;
  21179. }
  21180. for (const r of nameRecords) {
  21181. if (!isWinNameRecord(r)) {
  21182. return;
  21183. }
  21184. }
  21185. const encoding = _encodings.WinAnsiEncoding;
  21186. const toUnicode = [],
  21187. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  21188. for (const charCode in encoding) {
  21189. const glyphName = encoding[charCode];
  21190. if (glyphName === "") {
  21191. continue;
  21192. }
  21193. const unicode = glyphsUnicodeMap[glyphName];
  21194. if (unicode === undefined) {
  21195. continue;
  21196. }
  21197. toUnicode[charCode] = String.fromCharCode(unicode);
  21198. }
  21199. if (toUnicode.length > 0) {
  21200. properties.toUnicode.amend(toUnicode);
  21201. }
  21202. }
  21203. function adjustType1ToUnicode(properties, builtInEncoding) {
  21204. if (properties.isInternalFont) {
  21205. return;
  21206. }
  21207. if (properties.hasIncludedToUnicodeMap) {
  21208. return;
  21209. }
  21210. if (builtInEncoding === properties.defaultEncoding) {
  21211. return;
  21212. }
  21213. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  21214. return;
  21215. }
  21216. const toUnicode = [],
  21217. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  21218. for (const charCode in builtInEncoding) {
  21219. if (properties.hasEncoding) {
  21220. if (properties.baseEncodingName || properties.differences[charCode] !== undefined) {
  21221. continue;
  21222. }
  21223. }
  21224. const glyphName = builtInEncoding[charCode];
  21225. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  21226. if (unicode !== -1) {
  21227. toUnicode[charCode] = String.fromCharCode(unicode);
  21228. }
  21229. }
  21230. if (toUnicode.length > 0) {
  21231. properties.toUnicode.amend(toUnicode);
  21232. }
  21233. }
  21234. function amendFallbackToUnicode(properties) {
  21235. if (!properties.fallbackToUnicode) {
  21236. return;
  21237. }
  21238. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  21239. return;
  21240. }
  21241. const toUnicode = [];
  21242. for (const charCode in properties.fallbackToUnicode) {
  21243. if (properties.toUnicode.has(charCode)) {
  21244. continue;
  21245. }
  21246. toUnicode[charCode] = properties.fallbackToUnicode[charCode];
  21247. }
  21248. if (toUnicode.length > 0) {
  21249. properties.toUnicode.amend(toUnicode);
  21250. }
  21251. }
  21252. class Glyph {
  21253. constructor(originalCharCode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  21254. this.originalCharCode = originalCharCode;
  21255. this.fontChar = fontChar;
  21256. this.unicode = unicode;
  21257. this.accent = accent;
  21258. this.width = width;
  21259. this.vmetric = vmetric;
  21260. this.operatorListId = operatorListId;
  21261. this.isSpace = isSpace;
  21262. this.isInFont = isInFont;
  21263. }
  21264. get category() {
  21265. return (0, _util.shadow)(this, "category", (0, _unicode.getCharUnicodeCategory)(this.unicode), true);
  21266. }
  21267. }
  21268. function int16(b0, b1) {
  21269. return (b0 << 8) + b1;
  21270. }
  21271. function writeSignedInt16(bytes, index, value) {
  21272. bytes[index + 1] = value;
  21273. bytes[index] = value >>> 8;
  21274. }
  21275. function signedInt16(b0, b1) {
  21276. const value = (b0 << 8) + b1;
  21277. return value & 1 << 15 ? value - 0x10000 : value;
  21278. }
  21279. function int32(b0, b1, b2, b3) {
  21280. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  21281. }
  21282. function string16(value) {
  21283. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  21284. }
  21285. function safeString16(value) {
  21286. if (value > 0x7fff) {
  21287. value = 0x7fff;
  21288. } else if (value < -0x8000) {
  21289. value = -0x8000;
  21290. }
  21291. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  21292. }
  21293. function isTrueTypeFile(file) {
  21294. const header = file.peekBytes(4);
  21295. return (0, _core_utils.readUint32)(header, 0) === 0x00010000 || (0, _util.bytesToString)(header) === "true";
  21296. }
  21297. function isTrueTypeCollectionFile(file) {
  21298. const header = file.peekBytes(4);
  21299. return (0, _util.bytesToString)(header) === "ttcf";
  21300. }
  21301. function isOpenTypeFile(file) {
  21302. const header = file.peekBytes(4);
  21303. return (0, _util.bytesToString)(header) === "OTTO";
  21304. }
  21305. function isType1File(file) {
  21306. const header = file.peekBytes(2);
  21307. if (header[0] === 0x25 && header[1] === 0x21) {
  21308. return true;
  21309. }
  21310. if (header[0] === 0x80 && header[1] === 0x01) {
  21311. return true;
  21312. }
  21313. return false;
  21314. }
  21315. function isCFFFile(file) {
  21316. const header = file.peekBytes(4);
  21317. if (header[0] >= 1 && header[3] >= 1 && header[3] <= 4) {
  21318. return true;
  21319. }
  21320. return false;
  21321. }
  21322. function getFontFileType(file, {
  21323. type,
  21324. subtype,
  21325. composite
  21326. }) {
  21327. let fileType, fileSubtype;
  21328. if (isTrueTypeFile(file) || isTrueTypeCollectionFile(file)) {
  21329. fileType = composite ? "CIDFontType2" : "TrueType";
  21330. } else if (isOpenTypeFile(file)) {
  21331. fileType = composite ? "CIDFontType2" : "OpenType";
  21332. } else if (isType1File(file)) {
  21333. if (composite) {
  21334. fileType = "CIDFontType0";
  21335. } else {
  21336. fileType = type === "MMType1" ? "MMType1" : "Type1";
  21337. }
  21338. } else if (isCFFFile(file)) {
  21339. if (composite) {
  21340. fileType = "CIDFontType0";
  21341. fileSubtype = "CIDFontType0C";
  21342. } else {
  21343. fileType = type === "MMType1" ? "MMType1" : "Type1";
  21344. fileSubtype = "Type1C";
  21345. }
  21346. } else {
  21347. (0, _util.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");
  21348. fileType = type;
  21349. fileSubtype = subtype;
  21350. }
  21351. return [fileType, fileSubtype];
  21352. }
  21353. function applyStandardFontGlyphMap(map, glyphMap) {
  21354. for (const charCode in glyphMap) {
  21355. map[+charCode] = glyphMap[charCode];
  21356. }
  21357. }
  21358. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  21359. const toFontChar = [];
  21360. let unicode;
  21361. for (let i = 0, ii = encoding.length; i < ii; i++) {
  21362. unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
  21363. if (unicode !== -1) {
  21364. toFontChar[i] = unicode;
  21365. }
  21366. }
  21367. for (const charCode in differences) {
  21368. unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
  21369. if (unicode !== -1) {
  21370. toFontChar[+charCode] = unicode;
  21371. }
  21372. }
  21373. return toFontChar;
  21374. }
  21375. function isMacNameRecord(r) {
  21376. return r.platform === 1 && r.encoding === 0 && r.language === 0;
  21377. }
  21378. function isWinNameRecord(r) {
  21379. return r.platform === 3 && r.encoding === 1 && r.language === 0x409;
  21380. }
  21381. function convertCidString(charCode, cid, shouldThrow = false) {
  21382. switch (cid.length) {
  21383. case 1:
  21384. return cid.charCodeAt(0);
  21385. case 2:
  21386. return cid.charCodeAt(0) << 8 | cid.charCodeAt(1);
  21387. }
  21388. const msg = `Unsupported CID string (charCode ${charCode}): "${cid}".`;
  21389. if (shouldThrow) {
  21390. throw new _util.FormatError(msg);
  21391. }
  21392. (0, _util.warn)(msg);
  21393. return cid;
  21394. }
  21395. function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) {
  21396. const newMap = Object.create(null);
  21397. const toUnicodeExtraMap = new Map();
  21398. const toFontChar = [];
  21399. const usedGlyphIds = new Set();
  21400. let privateUseAreaIndex = 0;
  21401. const privateUseOffetStart = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  21402. let nextAvailableFontCharCode = privateUseOffetStart;
  21403. let privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  21404. const isInPrivateArea = code => PRIVATE_USE_AREAS[0][0] <= code && code <= PRIVATE_USE_AREAS[0][1] || PRIVATE_USE_AREAS[1][0] <= code && code <= PRIVATE_USE_AREAS[1][1];
  21405. for (let originalCharCode in charCodeToGlyphId) {
  21406. originalCharCode |= 0;
  21407. let glyphId = charCodeToGlyphId[originalCharCode];
  21408. if (!hasGlyph(glyphId)) {
  21409. continue;
  21410. }
  21411. if (nextAvailableFontCharCode > privateUseOffetEnd) {
  21412. privateUseAreaIndex++;
  21413. if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) {
  21414. (0, _util.warn)("Ran out of space in font private use area.");
  21415. break;
  21416. }
  21417. nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  21418. privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  21419. }
  21420. const fontCharCode = nextAvailableFontCharCode++;
  21421. if (glyphId === 0) {
  21422. glyphId = newGlyphZeroId;
  21423. }
  21424. let unicode = toUnicode.get(originalCharCode);
  21425. if (typeof unicode === "string") {
  21426. unicode = unicode.codePointAt(0);
  21427. }
  21428. if (unicode && !isInPrivateArea(unicode) && !usedGlyphIds.has(glyphId)) {
  21429. toUnicodeExtraMap.set(unicode, glyphId);
  21430. usedGlyphIds.add(glyphId);
  21431. }
  21432. newMap[fontCharCode] = glyphId;
  21433. toFontChar[originalCharCode] = fontCharCode;
  21434. }
  21435. return {
  21436. toFontChar,
  21437. charCodeToGlyphId: newMap,
  21438. toUnicodeExtraMap,
  21439. nextAvailableFontCharCode
  21440. };
  21441. }
  21442. function getRanges(glyphs, toUnicodeExtraMap, numGlyphs) {
  21443. const codes = [];
  21444. for (const charCode in glyphs) {
  21445. if (glyphs[charCode] >= numGlyphs) {
  21446. continue;
  21447. }
  21448. codes.push({
  21449. fontCharCode: charCode | 0,
  21450. glyphId: glyphs[charCode]
  21451. });
  21452. }
  21453. if (toUnicodeExtraMap) {
  21454. for (const [unicode, glyphId] of toUnicodeExtraMap) {
  21455. if (glyphId >= numGlyphs) {
  21456. continue;
  21457. }
  21458. codes.push({
  21459. fontCharCode: unicode,
  21460. glyphId
  21461. });
  21462. }
  21463. }
  21464. if (codes.length === 0) {
  21465. codes.push({
  21466. fontCharCode: 0,
  21467. glyphId: 0
  21468. });
  21469. }
  21470. codes.sort(function fontGetRangesSort(a, b) {
  21471. return a.fontCharCode - b.fontCharCode;
  21472. });
  21473. const ranges = [];
  21474. const length = codes.length;
  21475. for (let n = 0; n < length;) {
  21476. const start = codes[n].fontCharCode;
  21477. const codeIndices = [codes[n].glyphId];
  21478. ++n;
  21479. let end = start;
  21480. while (n < length && end + 1 === codes[n].fontCharCode) {
  21481. codeIndices.push(codes[n].glyphId);
  21482. ++end;
  21483. ++n;
  21484. if (end === 0xffff) {
  21485. break;
  21486. }
  21487. }
  21488. ranges.push([start, end, codeIndices]);
  21489. }
  21490. return ranges;
  21491. }
  21492. function createCmapTable(glyphs, toUnicodeExtraMap, numGlyphs) {
  21493. const ranges = getRanges(glyphs, toUnicodeExtraMap, numGlyphs);
  21494. const numTables = ranges.at(-1)[1] > 0xffff ? 2 : 1;
  21495. let cmap = "\x00\x00" + string16(numTables) + "\x00\x03" + "\x00\x01" + (0, _util.string32)(4 + numTables * 8);
  21496. let i, ii, j, jj;
  21497. for (i = ranges.length - 1; i >= 0; --i) {
  21498. if (ranges[i][0] <= 0xffff) {
  21499. break;
  21500. }
  21501. }
  21502. const bmpLength = i + 1;
  21503. if (ranges[i][0] < 0xffff && ranges[i][1] === 0xffff) {
  21504. ranges[i][1] = 0xfffe;
  21505. }
  21506. const trailingRangesCount = ranges[i][1] < 0xffff ? 1 : 0;
  21507. const segCount = bmpLength + trailingRangesCount;
  21508. const searchParams = _opentype_file_builder.OpenTypeFileBuilder.getSearchParams(segCount, 2);
  21509. let startCount = "";
  21510. let endCount = "";
  21511. let idDeltas = "";
  21512. let idRangeOffsets = "";
  21513. let glyphsIds = "";
  21514. let bias = 0;
  21515. let range, start, end, codes;
  21516. for (i = 0, ii = bmpLength; i < ii; i++) {
  21517. range = ranges[i];
  21518. start = range[0];
  21519. end = range[1];
  21520. startCount += string16(start);
  21521. endCount += string16(end);
  21522. codes = range[2];
  21523. let contiguous = true;
  21524. for (j = 1, jj = codes.length; j < jj; ++j) {
  21525. if (codes[j] !== codes[j - 1] + 1) {
  21526. contiguous = false;
  21527. break;
  21528. }
  21529. }
  21530. if (!contiguous) {
  21531. const offset = (segCount - i) * 2 + bias * 2;
  21532. bias += end - start + 1;
  21533. idDeltas += string16(0);
  21534. idRangeOffsets += string16(offset);
  21535. for (j = 0, jj = codes.length; j < jj; ++j) {
  21536. glyphsIds += string16(codes[j]);
  21537. }
  21538. } else {
  21539. const startCode = codes[0];
  21540. idDeltas += string16(startCode - start & 0xffff);
  21541. idRangeOffsets += string16(0);
  21542. }
  21543. }
  21544. if (trailingRangesCount > 0) {
  21545. endCount += "\xFF\xFF";
  21546. startCount += "\xFF\xFF";
  21547. idDeltas += "\x00\x01";
  21548. idRangeOffsets += "\x00\x00";
  21549. }
  21550. const format314 = "\x00\x00" + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + "\x00\x00" + startCount + idDeltas + idRangeOffsets + glyphsIds;
  21551. let format31012 = "";
  21552. let header31012 = "";
  21553. if (numTables > 1) {
  21554. cmap += "\x00\x03" + "\x00\x0A" + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
  21555. format31012 = "";
  21556. for (i = 0, ii = ranges.length; i < ii; i++) {
  21557. range = ranges[i];
  21558. start = range[0];
  21559. codes = range[2];
  21560. let code = codes[0];
  21561. for (j = 1, jj = codes.length; j < jj; ++j) {
  21562. if (codes[j] !== codes[j - 1] + 1) {
  21563. end = range[0] + j - 1;
  21564. format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
  21565. start = end + 1;
  21566. code = codes[j];
  21567. }
  21568. }
  21569. format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
  21570. }
  21571. header31012 = "\x00\x0C" + "\x00\x00" + (0, _util.string32)(format31012.length + 16) + "\x00\x00\x00\x00" + (0, _util.string32)(format31012.length / 12);
  21572. }
  21573. return cmap + "\x00\x04" + string16(format314.length + 4) + format314 + header31012 + format31012;
  21574. }
  21575. function validateOS2Table(os2, file) {
  21576. file.pos = (file.start || 0) + os2.offset;
  21577. const version = file.getUint16();
  21578. file.skip(60);
  21579. const selection = file.getUint16();
  21580. if (version < 4 && selection & 0x0300) {
  21581. return false;
  21582. }
  21583. const firstChar = file.getUint16();
  21584. const lastChar = file.getUint16();
  21585. if (firstChar > lastChar) {
  21586. return false;
  21587. }
  21588. file.skip(6);
  21589. const usWinAscent = file.getUint16();
  21590. if (usWinAscent === 0) {
  21591. return false;
  21592. }
  21593. os2.data[8] = os2.data[9] = 0;
  21594. return true;
  21595. }
  21596. function createOS2Table(properties, charstrings, override) {
  21597. override ||= {
  21598. unitsPerEm: 0,
  21599. yMax: 0,
  21600. yMin: 0,
  21601. ascent: 0,
  21602. descent: 0
  21603. };
  21604. let ulUnicodeRange1 = 0;
  21605. let ulUnicodeRange2 = 0;
  21606. let ulUnicodeRange3 = 0;
  21607. let ulUnicodeRange4 = 0;
  21608. let firstCharIndex = null;
  21609. let lastCharIndex = 0;
  21610. let position = -1;
  21611. if (charstrings) {
  21612. for (let code in charstrings) {
  21613. code |= 0;
  21614. if (firstCharIndex > code || !firstCharIndex) {
  21615. firstCharIndex = code;
  21616. }
  21617. if (lastCharIndex < code) {
  21618. lastCharIndex = code;
  21619. }
  21620. position = (0, _unicode.getUnicodeRangeFor)(code, position);
  21621. if (position < 32) {
  21622. ulUnicodeRange1 |= 1 << position;
  21623. } else if (position < 64) {
  21624. ulUnicodeRange2 |= 1 << position - 32;
  21625. } else if (position < 96) {
  21626. ulUnicodeRange3 |= 1 << position - 64;
  21627. } else if (position < 123) {
  21628. ulUnicodeRange4 |= 1 << position - 96;
  21629. } else {
  21630. throw new _util.FormatError("Unicode ranges Bits > 123 are reserved for internal usage");
  21631. }
  21632. }
  21633. if (lastCharIndex > 0xffff) {
  21634. lastCharIndex = 0xffff;
  21635. }
  21636. } else {
  21637. firstCharIndex = 0;
  21638. lastCharIndex = 255;
  21639. }
  21640. const bbox = properties.bbox || [0, 0, 0, 0];
  21641. const unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  21642. const scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  21643. const typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  21644. let typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  21645. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  21646. typoDescent = -typoDescent;
  21647. }
  21648. const winAscent = override.yMax || typoAscent;
  21649. const winDescent = -override.yMin || -typoDescent;
  21650. return "\x00\x03" + "\x02\x24" + "\x01\xF4" + "\x00\x05" + "\x00\x00" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x00\x8C" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x01\xDF" + "\x00\x31" + "\x01\x02" + "\x00\x00" + "\x00\x00\x06" + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + "\x00\x00\x00\x00\x00\x00" + (0, _util.string32)(ulUnicodeRange1) + (0, _util.string32)(ulUnicodeRange2) + (0, _util.string32)(ulUnicodeRange3) + (0, _util.string32)(ulUnicodeRange4) + "\x2A\x32\x31\x2A" + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + "\x00\x64" + string16(winAscent) + string16(winDescent) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + "\x00\x03";
  21651. }
  21652. function createPostTable(properties) {
  21653. const angle = Math.floor(properties.italicAngle * 2 ** 16);
  21654. return "\x00\x03\x00\x00" + (0, _util.string32)(angle) + "\x00\x00" + "\x00\x00" + (0, _util.string32)(properties.fixedPitch ? 1 : 0) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00";
  21655. }
  21656. function createPostscriptName(name) {
  21657. return name.replaceAll(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
  21658. }
  21659. function createNameTable(name, proto) {
  21660. if (!proto) {
  21661. proto = [[], []];
  21662. }
  21663. const strings = [proto[0][0] || "Original licence", proto[0][1] || name, proto[0][2] || "Unknown", proto[0][3] || "uniqueID", proto[0][4] || name, proto[0][5] || "Version 0.11", proto[0][6] || createPostscriptName(name), proto[0][7] || "Unknown", proto[0][8] || "Unknown", proto[0][9] || "Unknown"];
  21664. const stringsUnicode = [];
  21665. let i, ii, j, jj, str;
  21666. for (i = 0, ii = strings.length; i < ii; i++) {
  21667. str = proto[1][i] || strings[i];
  21668. const strBufUnicode = [];
  21669. for (j = 0, jj = str.length; j < jj; j++) {
  21670. strBufUnicode.push(string16(str.charCodeAt(j)));
  21671. }
  21672. stringsUnicode.push(strBufUnicode.join(""));
  21673. }
  21674. const names = [strings, stringsUnicode];
  21675. const platforms = ["\x00\x01", "\x00\x03"];
  21676. const encodings = ["\x00\x00", "\x00\x01"];
  21677. const languages = ["\x00\x00", "\x04\x09"];
  21678. const namesRecordCount = strings.length * platforms.length;
  21679. let nameTable = "\x00\x00" + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  21680. let strOffset = 0;
  21681. for (i = 0, ii = platforms.length; i < ii; i++) {
  21682. const strs = names[i];
  21683. for (j = 0, jj = strs.length; j < jj; j++) {
  21684. str = strs[j];
  21685. const nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  21686. nameTable += nameRecord;
  21687. strOffset += str.length;
  21688. }
  21689. }
  21690. nameTable += strings.join("") + stringsUnicode.join("");
  21691. return nameTable;
  21692. }
  21693. class Font {
  21694. constructor(name, file, properties) {
  21695. this.name = name;
  21696. this.psName = null;
  21697. this.mimetype = null;
  21698. this.disableFontFace = false;
  21699. this.loadedName = properties.loadedName;
  21700. this.isType3Font = properties.isType3Font;
  21701. this.missingFile = false;
  21702. this.cssFontInfo = properties.cssFontInfo;
  21703. this._charsCache = Object.create(null);
  21704. this._glyphCache = Object.create(null);
  21705. let isSerifFont = !!(properties.flags & _fonts_utils.FontFlags.Serif);
  21706. if (!isSerifFont && !properties.isSimulatedFlags) {
  21707. const baseName = name.replaceAll(/[,_]/g, "-").split("-")[0],
  21708. serifFonts = (0, _standard_fonts.getSerifFonts)();
  21709. for (const namePart of baseName.split("+")) {
  21710. if (serifFonts[namePart]) {
  21711. isSerifFont = true;
  21712. break;
  21713. }
  21714. }
  21715. }
  21716. this.isSerifFont = isSerifFont;
  21717. this.isSymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Symbolic);
  21718. this.isMonospace = !!(properties.flags & _fonts_utils.FontFlags.FixedPitch);
  21719. let {
  21720. type,
  21721. subtype
  21722. } = properties;
  21723. this.type = type;
  21724. this.subtype = subtype;
  21725. this.systemFontInfo = properties.systemFontInfo;
  21726. const matches = name.match(/^InvalidPDFjsFont_(.*)_\d+$/);
  21727. this.isInvalidPDFjsFont = !!matches;
  21728. if (this.isInvalidPDFjsFont) {
  21729. this.fallbackName = matches[1];
  21730. } else if (this.isMonospace) {
  21731. this.fallbackName = "monospace";
  21732. } else if (this.isSerifFont) {
  21733. this.fallbackName = "serif";
  21734. } else {
  21735. this.fallbackName = "sans-serif";
  21736. }
  21737. if (this.systemFontInfo?.guessFallback) {
  21738. this.systemFontInfo.guessFallback = false;
  21739. this.systemFontInfo.css += `,${this.fallbackName}`;
  21740. }
  21741. this.differences = properties.differences;
  21742. this.widths = properties.widths;
  21743. this.defaultWidth = properties.defaultWidth;
  21744. this.composite = properties.composite;
  21745. this.cMap = properties.cMap;
  21746. this.capHeight = properties.capHeight / PDF_GLYPH_SPACE_UNITS;
  21747. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  21748. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  21749. this.lineHeight = this.ascent - this.descent;
  21750. this.fontMatrix = properties.fontMatrix;
  21751. this.bbox = properties.bbox;
  21752. this.defaultEncoding = properties.defaultEncoding;
  21753. this.toUnicode = properties.toUnicode;
  21754. this.toFontChar = [];
  21755. if (properties.type === "Type3") {
  21756. for (let charCode = 0; charCode < 256; charCode++) {
  21757. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  21758. }
  21759. return;
  21760. }
  21761. this.cidEncoding = properties.cidEncoding || "";
  21762. this.vertical = !!properties.vertical;
  21763. if (this.vertical) {
  21764. this.vmetrics = properties.vmetrics;
  21765. this.defaultVMetrics = properties.defaultVMetrics;
  21766. }
  21767. if (!file || file.isEmpty) {
  21768. if (file) {
  21769. (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ")");
  21770. }
  21771. this.fallbackToSystemFont(properties);
  21772. return;
  21773. }
  21774. [type, subtype] = getFontFileType(file, properties);
  21775. if (type !== this.type || subtype !== this.subtype) {
  21776. (0, _util.info)("Inconsistent font file Type/SubType, expected: " + `${this.type}/${this.subtype} but found: ${type}/${subtype}.`);
  21777. }
  21778. let data;
  21779. try {
  21780. switch (type) {
  21781. case "MMType1":
  21782. (0, _util.info)("MMType1 font (" + name + "), falling back to Type1.");
  21783. case "Type1":
  21784. case "CIDFontType0":
  21785. this.mimetype = "font/opentype";
  21786. const cff = subtype === "Type1C" || subtype === "CIDFontType0C" ? new _cff_font.CFFFont(file, properties) : new _type1_font.Type1Font(name, file, properties);
  21787. adjustWidths(properties);
  21788. data = this.convert(name, cff, properties);
  21789. break;
  21790. case "OpenType":
  21791. case "TrueType":
  21792. case "CIDFontType2":
  21793. this.mimetype = "font/opentype";
  21794. data = this.checkAndRepair(name, file, properties);
  21795. if (this.isOpenType) {
  21796. adjustWidths(properties);
  21797. type = "OpenType";
  21798. }
  21799. break;
  21800. default:
  21801. throw new _util.FormatError(`Font ${type} is not supported`);
  21802. }
  21803. } catch (e) {
  21804. (0, _util.warn)(e);
  21805. this.fallbackToSystemFont(properties);
  21806. return;
  21807. }
  21808. amendFallbackToUnicode(properties);
  21809. this.data = data;
  21810. this.type = type;
  21811. this.subtype = subtype;
  21812. this.fontMatrix = properties.fontMatrix;
  21813. this.widths = properties.widths;
  21814. this.defaultWidth = properties.defaultWidth;
  21815. this.toUnicode = properties.toUnicode;
  21816. this.seacMap = properties.seacMap;
  21817. }
  21818. get renderer() {
  21819. const renderer = _font_renderer.FontRendererFactory.create(this, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  21820. return (0, _util.shadow)(this, "renderer", renderer);
  21821. }
  21822. exportData(extraProperties = false) {
  21823. const exportDataProperties = extraProperties ? [...EXPORT_DATA_PROPERTIES, ...EXPORT_DATA_EXTRA_PROPERTIES] : EXPORT_DATA_PROPERTIES;
  21824. const data = Object.create(null);
  21825. let property, value;
  21826. for (property of exportDataProperties) {
  21827. value = this[property];
  21828. if (value !== undefined) {
  21829. data[property] = value;
  21830. }
  21831. }
  21832. return data;
  21833. }
  21834. fallbackToSystemFont(properties) {
  21835. this.missingFile = true;
  21836. const {
  21837. name,
  21838. type
  21839. } = this;
  21840. let fontName = (0, _fonts_utils.normalizeFontName)(name);
  21841. const stdFontMap = (0, _standard_fonts.getStdFontMap)(),
  21842. nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
  21843. const isStandardFont = !!stdFontMap[fontName];
  21844. const isMappedToStandardFont = !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  21845. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  21846. const fontBasicMetricsMap = (0, _metrics.getFontBasicMetrics)();
  21847. const metrics = fontBasicMetricsMap[fontName];
  21848. if (metrics) {
  21849. if (isNaN(this.ascent)) {
  21850. this.ascent = metrics.ascent / PDF_GLYPH_SPACE_UNITS;
  21851. }
  21852. if (isNaN(this.descent)) {
  21853. this.descent = metrics.descent / PDF_GLYPH_SPACE_UNITS;
  21854. }
  21855. if (isNaN(this.capHeight)) {
  21856. this.capHeight = metrics.capHeight / PDF_GLYPH_SPACE_UNITS;
  21857. }
  21858. }
  21859. this.bold = /bold/gi.test(fontName);
  21860. this.italic = /oblique|italic/gi.test(fontName);
  21861. this.black = /Black/g.test(name);
  21862. const isNarrow = /Narrow/g.test(name);
  21863. this.remeasure = (!isStandardFont || isNarrow) && Object.keys(this.widths).length > 0;
  21864. if ((isStandardFont || isMappedToStandardFont) && type === "CIDFontType2" && this.cidEncoding.startsWith("Identity-")) {
  21865. const cidToGidMap = properties.cidToGidMap;
  21866. const map = [];
  21867. applyStandardFontGlyphMap(map, (0, _standard_fonts.getGlyphMapForStandardFonts)());
  21868. if (/Arial-?Black/i.test(name)) {
  21869. applyStandardFontGlyphMap(map, (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)());
  21870. } else if (/Calibri/i.test(name)) {
  21871. applyStandardFontGlyphMap(map, (0, _standard_fonts.getSupplementalGlyphMapForCalibri)());
  21872. }
  21873. if (cidToGidMap) {
  21874. for (const charCode in map) {
  21875. const cid = map[charCode];
  21876. if (cidToGidMap[cid] !== undefined) {
  21877. map[+charCode] = cidToGidMap[cid];
  21878. }
  21879. }
  21880. if (cidToGidMap.length !== this.toUnicode.length && properties.hasIncludedToUnicodeMap && this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  21881. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  21882. const cid = map[charCode];
  21883. if (cidToGidMap[cid] === undefined) {
  21884. map[+charCode] = unicodeCharCode;
  21885. }
  21886. });
  21887. }
  21888. }
  21889. if (!(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  21890. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  21891. map[+charCode] = unicodeCharCode;
  21892. });
  21893. }
  21894. this.toFontChar = map;
  21895. this.toUnicode = new _to_unicode_map.ToUnicodeMap(map);
  21896. } else if (/Symbol/i.test(fontName)) {
  21897. this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  21898. } else if (/Dingbats/i.test(fontName)) {
  21899. this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), this.differences);
  21900. } else if (isStandardFont) {
  21901. const map = buildToFontChar(this.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  21902. if (type === "CIDFontType2" && !this.cidEncoding.startsWith("Identity-") && !(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  21903. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  21904. map[+charCode] = unicodeCharCode;
  21905. });
  21906. }
  21907. this.toFontChar = map;
  21908. } else {
  21909. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  21910. const map = [];
  21911. this.toUnicode.forEach((charCode, unicodeCharCode) => {
  21912. if (!this.composite) {
  21913. const glyphName = this.differences[charCode] || this.defaultEncoding[charCode];
  21914. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  21915. if (unicode !== -1) {
  21916. unicodeCharCode = unicode;
  21917. }
  21918. }
  21919. map[+charCode] = unicodeCharCode;
  21920. });
  21921. if (this.composite && this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  21922. if (/Tahoma|Verdana/i.test(name)) {
  21923. applyStandardFontGlyphMap(map, (0, _standard_fonts.getGlyphMapForStandardFonts)());
  21924. }
  21925. }
  21926. this.toFontChar = map;
  21927. }
  21928. amendFallbackToUnicode(properties);
  21929. this.loadedName = fontName.split("-")[0];
  21930. }
  21931. checkAndRepair(name, font, properties) {
  21932. const VALID_TABLES = ["OS/2", "cmap", "head", "hhea", "hmtx", "maxp", "name", "post", "loca", "glyf", "fpgm", "prep", "cvt ", "CFF "];
  21933. function readTables(file, numTables) {
  21934. const tables = Object.create(null);
  21935. tables["OS/2"] = null;
  21936. tables.cmap = null;
  21937. tables.head = null;
  21938. tables.hhea = null;
  21939. tables.hmtx = null;
  21940. tables.maxp = null;
  21941. tables.name = null;
  21942. tables.post = null;
  21943. for (let i = 0; i < numTables; i++) {
  21944. const table = readTableEntry(file);
  21945. if (!VALID_TABLES.includes(table.tag)) {
  21946. continue;
  21947. }
  21948. if (table.length === 0) {
  21949. continue;
  21950. }
  21951. tables[table.tag] = table;
  21952. }
  21953. return tables;
  21954. }
  21955. function readTableEntry(file) {
  21956. const tag = file.getString(4);
  21957. const checksum = file.getInt32() >>> 0;
  21958. const offset = file.getInt32() >>> 0;
  21959. const length = file.getInt32() >>> 0;
  21960. const previousPosition = file.pos;
  21961. file.pos = file.start || 0;
  21962. file.skip(offset);
  21963. const data = file.getBytes(length);
  21964. file.pos = previousPosition;
  21965. if (tag === "head") {
  21966. data[8] = data[9] = data[10] = data[11] = 0;
  21967. data[17] |= 0x20;
  21968. }
  21969. return {
  21970. tag,
  21971. checksum,
  21972. length,
  21973. offset,
  21974. data
  21975. };
  21976. }
  21977. function readOpenTypeHeader(ttf) {
  21978. return {
  21979. version: ttf.getString(4),
  21980. numTables: ttf.getUint16(),
  21981. searchRange: ttf.getUint16(),
  21982. entrySelector: ttf.getUint16(),
  21983. rangeShift: ttf.getUint16()
  21984. };
  21985. }
  21986. function readTrueTypeCollectionHeader(ttc) {
  21987. const ttcTag = ttc.getString(4);
  21988. (0, _util.assert)(ttcTag === "ttcf", "Must be a TrueType Collection font.");
  21989. const majorVersion = ttc.getUint16();
  21990. const minorVersion = ttc.getUint16();
  21991. const numFonts = ttc.getInt32() >>> 0;
  21992. const offsetTable = [];
  21993. for (let i = 0; i < numFonts; i++) {
  21994. offsetTable.push(ttc.getInt32() >>> 0);
  21995. }
  21996. const header = {
  21997. ttcTag,
  21998. majorVersion,
  21999. minorVersion,
  22000. numFonts,
  22001. offsetTable
  22002. };
  22003. switch (majorVersion) {
  22004. case 1:
  22005. return header;
  22006. case 2:
  22007. header.dsigTag = ttc.getInt32() >>> 0;
  22008. header.dsigLength = ttc.getInt32() >>> 0;
  22009. header.dsigOffset = ttc.getInt32() >>> 0;
  22010. return header;
  22011. }
  22012. throw new _util.FormatError(`Invalid TrueType Collection majorVersion: ${majorVersion}.`);
  22013. }
  22014. function readTrueTypeCollectionData(ttc, fontName) {
  22015. const {
  22016. numFonts,
  22017. offsetTable
  22018. } = readTrueTypeCollectionHeader(ttc);
  22019. const fontNameParts = fontName.split("+");
  22020. let fallbackData;
  22021. for (let i = 0; i < numFonts; i++) {
  22022. ttc.pos = (ttc.start || 0) + offsetTable[i];
  22023. const potentialHeader = readOpenTypeHeader(ttc);
  22024. const potentialTables = readTables(ttc, potentialHeader.numTables);
  22025. if (!potentialTables.name) {
  22026. throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
  22027. }
  22028. const [nameTable] = readNameTable(potentialTables.name);
  22029. for (let j = 0, jj = nameTable.length; j < jj; j++) {
  22030. for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
  22031. const nameEntry = nameTable[j][k]?.replaceAll(/\s/g, "");
  22032. if (!nameEntry) {
  22033. continue;
  22034. }
  22035. if (nameEntry === fontName) {
  22036. return {
  22037. header: potentialHeader,
  22038. tables: potentialTables
  22039. };
  22040. }
  22041. if (fontNameParts.length < 2) {
  22042. continue;
  22043. }
  22044. for (const part of fontNameParts) {
  22045. if (nameEntry === part) {
  22046. fallbackData = {
  22047. name: part,
  22048. header: potentialHeader,
  22049. tables: potentialTables
  22050. };
  22051. }
  22052. }
  22053. }
  22054. }
  22055. }
  22056. if (fallbackData) {
  22057. (0, _util.warn)(`TrueType Collection does not contain "${fontName}" font, ` + `falling back to "${fallbackData.name}" font instead.`);
  22058. return {
  22059. header: fallbackData.header,
  22060. tables: fallbackData.tables
  22061. };
  22062. }
  22063. throw new _util.FormatError(`TrueType Collection does not contain "${fontName}" font.`);
  22064. }
  22065. function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
  22066. if (!cmap) {
  22067. (0, _util.warn)("No cmap table available.");
  22068. return {
  22069. platformId: -1,
  22070. encodingId: -1,
  22071. mappings: [],
  22072. hasShortCmap: false
  22073. };
  22074. }
  22075. let segment;
  22076. let start = (file.start || 0) + cmap.offset;
  22077. file.pos = start;
  22078. file.skip(2);
  22079. const numTables = file.getUint16();
  22080. let potentialTable;
  22081. let canBreak = false;
  22082. for (let i = 0; i < numTables; i++) {
  22083. const platformId = file.getUint16();
  22084. const encodingId = file.getUint16();
  22085. const offset = file.getInt32() >>> 0;
  22086. let useTable = false;
  22087. if (potentialTable?.platformId === platformId && potentialTable?.encodingId === encodingId) {
  22088. continue;
  22089. }
  22090. if (platformId === 0 && (encodingId === 0 || encodingId === 1 || encodingId === 3)) {
  22091. useTable = true;
  22092. } else if (platformId === 1 && encodingId === 0) {
  22093. useTable = true;
  22094. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  22095. useTable = true;
  22096. if (!isSymbolicFont) {
  22097. canBreak = true;
  22098. }
  22099. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  22100. useTable = true;
  22101. let correctlySorted = true;
  22102. if (i < numTables - 1) {
  22103. const nextBytes = file.peekBytes(2),
  22104. nextPlatformId = int16(nextBytes[0], nextBytes[1]);
  22105. if (nextPlatformId < platformId) {
  22106. correctlySorted = false;
  22107. }
  22108. }
  22109. if (correctlySorted) {
  22110. canBreak = true;
  22111. }
  22112. }
  22113. if (useTable) {
  22114. potentialTable = {
  22115. platformId,
  22116. encodingId,
  22117. offset
  22118. };
  22119. }
  22120. if (canBreak) {
  22121. break;
  22122. }
  22123. }
  22124. if (potentialTable) {
  22125. file.pos = start + potentialTable.offset;
  22126. }
  22127. if (!potentialTable || file.peekByte() === -1) {
  22128. (0, _util.warn)("Could not find a preferred cmap table.");
  22129. return {
  22130. platformId: -1,
  22131. encodingId: -1,
  22132. mappings: [],
  22133. hasShortCmap: false
  22134. };
  22135. }
  22136. const format = file.getUint16();
  22137. let hasShortCmap = false;
  22138. const mappings = [];
  22139. let j, glyphId;
  22140. if (format === 0) {
  22141. file.skip(2 + 2);
  22142. for (j = 0; j < 256; j++) {
  22143. const index = file.getByte();
  22144. if (!index) {
  22145. continue;
  22146. }
  22147. mappings.push({
  22148. charCode: j,
  22149. glyphId: index
  22150. });
  22151. }
  22152. hasShortCmap = true;
  22153. } else if (format === 2) {
  22154. file.skip(2 + 2);
  22155. const subHeaderKeys = [];
  22156. let maxSubHeaderKey = 0;
  22157. for (let i = 0; i < 256; i++) {
  22158. const subHeaderKey = file.getUint16() >> 3;
  22159. subHeaderKeys.push(subHeaderKey);
  22160. maxSubHeaderKey = Math.max(subHeaderKey, maxSubHeaderKey);
  22161. }
  22162. const subHeaders = [];
  22163. for (let i = 0; i <= maxSubHeaderKey; i++) {
  22164. subHeaders.push({
  22165. firstCode: file.getUint16(),
  22166. entryCount: file.getUint16(),
  22167. idDelta: signedInt16(file.getByte(), file.getByte()),
  22168. idRangePos: file.pos + file.getUint16()
  22169. });
  22170. }
  22171. for (let i = 0; i < 256; i++) {
  22172. if (subHeaderKeys[i] === 0) {
  22173. file.pos = subHeaders[0].idRangePos + 2 * i;
  22174. glyphId = file.getUint16();
  22175. mappings.push({
  22176. charCode: i,
  22177. glyphId
  22178. });
  22179. } else {
  22180. const s = subHeaders[subHeaderKeys[i]];
  22181. for (j = 0; j < s.entryCount; j++) {
  22182. const charCode = (i << 8) + j + s.firstCode;
  22183. file.pos = s.idRangePos + 2 * j;
  22184. glyphId = file.getUint16();
  22185. if (glyphId !== 0) {
  22186. glyphId = (glyphId + s.idDelta) % 65536;
  22187. }
  22188. mappings.push({
  22189. charCode,
  22190. glyphId
  22191. });
  22192. }
  22193. }
  22194. }
  22195. } else if (format === 4) {
  22196. file.skip(2 + 2);
  22197. const segCount = file.getUint16() >> 1;
  22198. file.skip(6);
  22199. const segments = [];
  22200. let segIndex;
  22201. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22202. segments.push({
  22203. end: file.getUint16()
  22204. });
  22205. }
  22206. file.skip(2);
  22207. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22208. segments[segIndex].start = file.getUint16();
  22209. }
  22210. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22211. segments[segIndex].delta = file.getUint16();
  22212. }
  22213. let offsetsCount = 0,
  22214. offsetIndex;
  22215. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22216. segment = segments[segIndex];
  22217. const rangeOffset = file.getUint16();
  22218. if (!rangeOffset) {
  22219. segment.offsetIndex = -1;
  22220. continue;
  22221. }
  22222. offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  22223. segment.offsetIndex = offsetIndex;
  22224. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  22225. }
  22226. const offsets = [];
  22227. for (j = 0; j < offsetsCount; j++) {
  22228. offsets.push(file.getUint16());
  22229. }
  22230. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22231. segment = segments[segIndex];
  22232. start = segment.start;
  22233. const end = segment.end;
  22234. const delta = segment.delta;
  22235. offsetIndex = segment.offsetIndex;
  22236. for (j = start; j <= end; j++) {
  22237. if (j === 0xffff) {
  22238. continue;
  22239. }
  22240. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  22241. glyphId = glyphId + delta & 0xffff;
  22242. mappings.push({
  22243. charCode: j,
  22244. glyphId
  22245. });
  22246. }
  22247. }
  22248. } else if (format === 6) {
  22249. file.skip(2 + 2);
  22250. const firstCode = file.getUint16();
  22251. const entryCount = file.getUint16();
  22252. for (j = 0; j < entryCount; j++) {
  22253. glyphId = file.getUint16();
  22254. const charCode = firstCode + j;
  22255. mappings.push({
  22256. charCode,
  22257. glyphId
  22258. });
  22259. }
  22260. } else if (format === 12) {
  22261. file.skip(2 + 4 + 4);
  22262. const nGroups = file.getInt32() >>> 0;
  22263. for (j = 0; j < nGroups; j++) {
  22264. const startCharCode = file.getInt32() >>> 0;
  22265. const endCharCode = file.getInt32() >>> 0;
  22266. let glyphCode = file.getInt32() >>> 0;
  22267. for (let charCode = startCharCode; charCode <= endCharCode; charCode++) {
  22268. mappings.push({
  22269. charCode,
  22270. glyphId: glyphCode++
  22271. });
  22272. }
  22273. }
  22274. } else {
  22275. (0, _util.warn)("cmap table has unsupported format: " + format);
  22276. return {
  22277. platformId: -1,
  22278. encodingId: -1,
  22279. mappings: [],
  22280. hasShortCmap: false
  22281. };
  22282. }
  22283. mappings.sort(function (a, b) {
  22284. return a.charCode - b.charCode;
  22285. });
  22286. for (let i = 1; i < mappings.length; i++) {
  22287. if (mappings[i - 1].charCode === mappings[i].charCode) {
  22288. mappings.splice(i, 1);
  22289. i--;
  22290. }
  22291. }
  22292. return {
  22293. platformId: potentialTable.platformId,
  22294. encodingId: potentialTable.encodingId,
  22295. mappings,
  22296. hasShortCmap
  22297. };
  22298. }
  22299. function sanitizeMetrics(file, header, metrics, headTable, numGlyphs, dupFirstEntry) {
  22300. if (!header) {
  22301. if (metrics) {
  22302. metrics.data = null;
  22303. }
  22304. return;
  22305. }
  22306. file.pos = (file.start || 0) + header.offset;
  22307. file.pos += 4;
  22308. file.pos += 2;
  22309. file.pos += 2;
  22310. file.pos += 2;
  22311. file.pos += 2;
  22312. file.pos += 2;
  22313. file.pos += 2;
  22314. file.pos += 2;
  22315. file.pos += 2;
  22316. file.pos += 2;
  22317. const caretOffset = file.getUint16();
  22318. file.pos += 8;
  22319. file.pos += 2;
  22320. let numOfMetrics = file.getUint16();
  22321. if (caretOffset !== 0) {
  22322. const macStyle = int16(headTable.data[44], headTable.data[45]);
  22323. if (!(macStyle & 2)) {
  22324. header.data[22] = 0;
  22325. header.data[23] = 0;
  22326. }
  22327. }
  22328. if (numOfMetrics > numGlyphs) {
  22329. (0, _util.info)(`The numOfMetrics (${numOfMetrics}) should not be ` + `greater than the numGlyphs (${numGlyphs}).`);
  22330. numOfMetrics = numGlyphs;
  22331. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  22332. header.data[35] = numOfMetrics & 0x00ff;
  22333. }
  22334. const numOfSidebearings = numGlyphs - numOfMetrics;
  22335. const numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  22336. if (numMissing > 0) {
  22337. const entries = new Uint8Array(metrics.length + numMissing * 2);
  22338. entries.set(metrics.data);
  22339. if (dupFirstEntry) {
  22340. entries[metrics.length] = metrics.data[2];
  22341. entries[metrics.length + 1] = metrics.data[3];
  22342. }
  22343. metrics.data = entries;
  22344. }
  22345. }
  22346. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  22347. const glyphProfile = {
  22348. length: 0,
  22349. sizeOfInstructions: 0
  22350. };
  22351. if (sourceStart < 0 || sourceStart >= source.length || sourceEnd > source.length || sourceEnd - sourceStart <= 12) {
  22352. return glyphProfile;
  22353. }
  22354. const glyf = source.subarray(sourceStart, sourceEnd);
  22355. const xMin = signedInt16(glyf[2], glyf[3]);
  22356. const yMin = signedInt16(glyf[4], glyf[5]);
  22357. const xMax = signedInt16(glyf[6], glyf[7]);
  22358. const yMax = signedInt16(glyf[8], glyf[9]);
  22359. if (xMin > xMax) {
  22360. writeSignedInt16(glyf, 2, xMax);
  22361. writeSignedInt16(glyf, 6, xMin);
  22362. }
  22363. if (yMin > yMax) {
  22364. writeSignedInt16(glyf, 4, yMax);
  22365. writeSignedInt16(glyf, 8, yMin);
  22366. }
  22367. const contoursCount = signedInt16(glyf[0], glyf[1]);
  22368. if (contoursCount < 0) {
  22369. if (contoursCount < -1) {
  22370. return glyphProfile;
  22371. }
  22372. dest.set(glyf, destStart);
  22373. glyphProfile.length = glyf.length;
  22374. return glyphProfile;
  22375. }
  22376. let i,
  22377. j = 10,
  22378. flagsCount = 0;
  22379. for (i = 0; i < contoursCount; i++) {
  22380. const endPoint = glyf[j] << 8 | glyf[j + 1];
  22381. flagsCount = endPoint + 1;
  22382. j += 2;
  22383. }
  22384. const instructionsStart = j;
  22385. const instructionsLength = glyf[j] << 8 | glyf[j + 1];
  22386. glyphProfile.sizeOfInstructions = instructionsLength;
  22387. j += 2 + instructionsLength;
  22388. const instructionsEnd = j;
  22389. let coordinatesLength = 0;
  22390. for (i = 0; i < flagsCount; i++) {
  22391. const flag = glyf[j++];
  22392. if (flag & 0xc0) {
  22393. glyf[j - 1] = flag & 0x3f;
  22394. }
  22395. let xLength = 2;
  22396. if (flag & 2) {
  22397. xLength = 1;
  22398. } else if (flag & 16) {
  22399. xLength = 0;
  22400. }
  22401. let yLength = 2;
  22402. if (flag & 4) {
  22403. yLength = 1;
  22404. } else if (flag & 32) {
  22405. yLength = 0;
  22406. }
  22407. const xyLength = xLength + yLength;
  22408. coordinatesLength += xyLength;
  22409. if (flag & 8) {
  22410. const repeat = glyf[j++];
  22411. if (repeat === 0) {
  22412. glyf[j - 1] ^= 8;
  22413. }
  22414. i += repeat;
  22415. coordinatesLength += repeat * xyLength;
  22416. }
  22417. }
  22418. if (coordinatesLength === 0) {
  22419. return glyphProfile;
  22420. }
  22421. let glyphDataLength = j + coordinatesLength;
  22422. if (glyphDataLength > glyf.length) {
  22423. return glyphProfile;
  22424. }
  22425. if (!hintsValid && instructionsLength > 0) {
  22426. dest.set(glyf.subarray(0, instructionsStart), destStart);
  22427. dest.set([0, 0], destStart + instructionsStart);
  22428. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  22429. glyphDataLength -= instructionsLength;
  22430. if (glyf.length - glyphDataLength > 3) {
  22431. glyphDataLength = glyphDataLength + 3 & ~3;
  22432. }
  22433. glyphProfile.length = glyphDataLength;
  22434. return glyphProfile;
  22435. }
  22436. if (glyf.length - glyphDataLength > 3) {
  22437. glyphDataLength = glyphDataLength + 3 & ~3;
  22438. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  22439. glyphProfile.length = glyphDataLength;
  22440. return glyphProfile;
  22441. }
  22442. dest.set(glyf, destStart);
  22443. glyphProfile.length = glyf.length;
  22444. return glyphProfile;
  22445. }
  22446. function sanitizeHead(head, numGlyphs, locaLength) {
  22447. const data = head.data;
  22448. const version = int32(data[0], data[1], data[2], data[3]);
  22449. if (version >> 16 !== 1) {
  22450. (0, _util.info)("Attempting to fix invalid version in head table: " + version);
  22451. data[0] = 0;
  22452. data[1] = 1;
  22453. data[2] = 0;
  22454. data[3] = 0;
  22455. }
  22456. const indexToLocFormat = int16(data[50], data[51]);
  22457. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  22458. (0, _util.info)("Attempting to fix invalid indexToLocFormat in head table: " + indexToLocFormat);
  22459. const numGlyphsPlusOne = numGlyphs + 1;
  22460. if (locaLength === numGlyphsPlusOne << 1) {
  22461. data[50] = 0;
  22462. data[51] = 0;
  22463. } else if (locaLength === numGlyphsPlusOne << 2) {
  22464. data[50] = 0;
  22465. data[51] = 1;
  22466. } else {
  22467. throw new _util.FormatError("Could not fix indexToLocFormat: " + indexToLocFormat);
  22468. }
  22469. }
  22470. }
  22471. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
  22472. let itemSize, itemDecode, itemEncode;
  22473. if (isGlyphLocationsLong) {
  22474. itemSize = 4;
  22475. itemDecode = function fontItemDecodeLong(data, offset) {
  22476. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  22477. };
  22478. itemEncode = function fontItemEncodeLong(data, offset, value) {
  22479. data[offset] = value >>> 24 & 0xff;
  22480. data[offset + 1] = value >> 16 & 0xff;
  22481. data[offset + 2] = value >> 8 & 0xff;
  22482. data[offset + 3] = value & 0xff;
  22483. };
  22484. } else {
  22485. itemSize = 2;
  22486. itemDecode = function fontItemDecode(data, offset) {
  22487. return data[offset] << 9 | data[offset + 1] << 1;
  22488. };
  22489. itemEncode = function fontItemEncode(data, offset, value) {
  22490. data[offset] = value >> 9 & 0xff;
  22491. data[offset + 1] = value >> 1 & 0xff;
  22492. };
  22493. }
  22494. const numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs;
  22495. const locaDataSize = itemSize * (1 + numGlyphsOut);
  22496. const locaData = new Uint8Array(locaDataSize);
  22497. locaData.set(loca.data.subarray(0, locaDataSize));
  22498. loca.data = locaData;
  22499. const oldGlyfData = glyf.data;
  22500. const oldGlyfDataLength = oldGlyfData.length;
  22501. const newGlyfData = new Uint8Array(oldGlyfDataLength);
  22502. let i, j;
  22503. const locaEntries = [];
  22504. for (i = 0, j = 0; i < numGlyphs + 1; i++, j += itemSize) {
  22505. let offset = itemDecode(locaData, j);
  22506. if (offset > oldGlyfDataLength) {
  22507. offset = oldGlyfDataLength;
  22508. }
  22509. locaEntries.push({
  22510. index: i,
  22511. offset,
  22512. endOffset: 0
  22513. });
  22514. }
  22515. locaEntries.sort((a, b) => {
  22516. return a.offset - b.offset;
  22517. });
  22518. for (i = 0; i < numGlyphs; i++) {
  22519. locaEntries[i].endOffset = locaEntries[i + 1].offset;
  22520. }
  22521. locaEntries.sort((a, b) => {
  22522. return a.index - b.index;
  22523. });
  22524. for (i = 0; i < numGlyphs; i++) {
  22525. const {
  22526. offset,
  22527. endOffset
  22528. } = locaEntries[i];
  22529. if (offset !== 0 || endOffset !== 0) {
  22530. break;
  22531. }
  22532. const nextOffset = locaEntries[i + 1].offset;
  22533. if (nextOffset === 0) {
  22534. continue;
  22535. }
  22536. locaEntries[i].endOffset = nextOffset;
  22537. break;
  22538. }
  22539. const missingGlyphs = Object.create(null);
  22540. let writeOffset = 0;
  22541. itemEncode(locaData, 0, writeOffset);
  22542. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  22543. const glyphProfile = sanitizeGlyph(oldGlyfData, locaEntries[i].offset, locaEntries[i].endOffset, newGlyfData, writeOffset, hintsValid);
  22544. const newLength = glyphProfile.length;
  22545. if (newLength === 0) {
  22546. missingGlyphs[i] = true;
  22547. }
  22548. if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
  22549. maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
  22550. }
  22551. writeOffset += newLength;
  22552. itemEncode(locaData, j, writeOffset);
  22553. }
  22554. if (writeOffset === 0) {
  22555. const simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
  22556. for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
  22557. itemEncode(locaData, j, simpleGlyph.length);
  22558. }
  22559. glyf.data = simpleGlyph;
  22560. } else if (dupFirstEntry) {
  22561. const firstEntryLength = itemDecode(locaData, itemSize);
  22562. if (newGlyfData.length > firstEntryLength + writeOffset) {
  22563. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  22564. } else {
  22565. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  22566. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  22567. }
  22568. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  22569. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  22570. } else {
  22571. glyf.data = newGlyfData.subarray(0, writeOffset);
  22572. }
  22573. return {
  22574. missingGlyphs,
  22575. maxSizeOfInstructions
  22576. };
  22577. }
  22578. function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
  22579. const start = (font.start || 0) + post.offset;
  22580. font.pos = start;
  22581. const length = post.length,
  22582. end = start + length;
  22583. const version = font.getInt32();
  22584. font.skip(28);
  22585. let glyphNames;
  22586. let valid = true;
  22587. let i;
  22588. switch (version) {
  22589. case 0x00010000:
  22590. glyphNames = _fonts_utils.MacStandardGlyphOrdering;
  22591. break;
  22592. case 0x00020000:
  22593. const numGlyphs = font.getUint16();
  22594. if (numGlyphs !== maxpNumGlyphs) {
  22595. valid = false;
  22596. break;
  22597. }
  22598. const glyphNameIndexes = [];
  22599. for (i = 0; i < numGlyphs; ++i) {
  22600. const index = font.getUint16();
  22601. if (index >= 32768) {
  22602. valid = false;
  22603. break;
  22604. }
  22605. glyphNameIndexes.push(index);
  22606. }
  22607. if (!valid) {
  22608. break;
  22609. }
  22610. const customNames = [],
  22611. strBuf = [];
  22612. while (font.pos < end) {
  22613. const stringLength = font.getByte();
  22614. strBuf.length = stringLength;
  22615. for (i = 0; i < stringLength; ++i) {
  22616. strBuf[i] = String.fromCharCode(font.getByte());
  22617. }
  22618. customNames.push(strBuf.join(""));
  22619. }
  22620. glyphNames = [];
  22621. for (i = 0; i < numGlyphs; ++i) {
  22622. const j = glyphNameIndexes[i];
  22623. if (j < 258) {
  22624. glyphNames.push(_fonts_utils.MacStandardGlyphOrdering[j]);
  22625. continue;
  22626. }
  22627. glyphNames.push(customNames[j - 258]);
  22628. }
  22629. break;
  22630. case 0x00030000:
  22631. break;
  22632. default:
  22633. (0, _util.warn)("Unknown/unsupported post table version " + version);
  22634. valid = false;
  22635. if (propertiesObj.defaultEncoding) {
  22636. glyphNames = propertiesObj.defaultEncoding;
  22637. }
  22638. break;
  22639. }
  22640. propertiesObj.glyphNames = glyphNames;
  22641. return valid;
  22642. }
  22643. function readNameTable(nameTable) {
  22644. const start = (font.start || 0) + nameTable.offset;
  22645. font.pos = start;
  22646. const names = [[], []],
  22647. records = [];
  22648. const length = nameTable.length,
  22649. end = start + length;
  22650. const format = font.getUint16();
  22651. const FORMAT_0_HEADER_LENGTH = 6;
  22652. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  22653. return [names, records];
  22654. }
  22655. const numRecords = font.getUint16();
  22656. const stringsStart = font.getUint16();
  22657. const NAME_RECORD_LENGTH = 12;
  22658. let i, ii;
  22659. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  22660. const r = {
  22661. platform: font.getUint16(),
  22662. encoding: font.getUint16(),
  22663. language: font.getUint16(),
  22664. name: font.getUint16(),
  22665. length: font.getUint16(),
  22666. offset: font.getUint16()
  22667. };
  22668. if (isMacNameRecord(r) || isWinNameRecord(r)) {
  22669. records.push(r);
  22670. }
  22671. }
  22672. for (i = 0, ii = records.length; i < ii; i++) {
  22673. const record = records[i];
  22674. if (record.length <= 0) {
  22675. continue;
  22676. }
  22677. const pos = start + stringsStart + record.offset;
  22678. if (pos + record.length > end) {
  22679. continue;
  22680. }
  22681. font.pos = pos;
  22682. const nameIndex = record.name;
  22683. if (record.encoding) {
  22684. let str = "";
  22685. for (let j = 0, jj = record.length; j < jj; j += 2) {
  22686. str += String.fromCharCode(font.getUint16());
  22687. }
  22688. names[1][nameIndex] = str;
  22689. } else {
  22690. names[0][nameIndex] = font.getString(record.length);
  22691. }
  22692. }
  22693. return [names, records];
  22694. }
  22695. const TTOpsStackDeltas = [0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1, 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1, 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2, 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1, -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];
  22696. function sanitizeTTProgram(table, ttContext) {
  22697. let data = table.data;
  22698. let i = 0,
  22699. j,
  22700. n,
  22701. b,
  22702. funcId,
  22703. pc,
  22704. lastEndf = 0,
  22705. lastDeff = 0;
  22706. const stack = [];
  22707. const callstack = [];
  22708. const functionsCalled = [];
  22709. let tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  22710. let inFDEF = false,
  22711. ifLevel = 0,
  22712. inELSE = 0;
  22713. for (let ii = data.length; i < ii;) {
  22714. const op = data[i++];
  22715. if (op === 0x40) {
  22716. n = data[i++];
  22717. if (inFDEF || inELSE) {
  22718. i += n;
  22719. } else {
  22720. for (j = 0; j < n; j++) {
  22721. stack.push(data[i++]);
  22722. }
  22723. }
  22724. } else if (op === 0x41) {
  22725. n = data[i++];
  22726. if (inFDEF || inELSE) {
  22727. i += n * 2;
  22728. } else {
  22729. for (j = 0; j < n; j++) {
  22730. b = data[i++];
  22731. stack.push(b << 8 | data[i++]);
  22732. }
  22733. }
  22734. } else if ((op & 0xf8) === 0xb0) {
  22735. n = op - 0xb0 + 1;
  22736. if (inFDEF || inELSE) {
  22737. i += n;
  22738. } else {
  22739. for (j = 0; j < n; j++) {
  22740. stack.push(data[i++]);
  22741. }
  22742. }
  22743. } else if ((op & 0xf8) === 0xb8) {
  22744. n = op - 0xb8 + 1;
  22745. if (inFDEF || inELSE) {
  22746. i += n * 2;
  22747. } else {
  22748. for (j = 0; j < n; j++) {
  22749. b = data[i++];
  22750. stack.push(b << 8 | data[i++]);
  22751. }
  22752. }
  22753. } else if (op === 0x2b && !tooComplexToFollowFunctions) {
  22754. if (!inFDEF && !inELSE) {
  22755. funcId = stack.at(-1);
  22756. if (isNaN(funcId)) {
  22757. (0, _util.info)("TT: CALL empty stack (or invalid entry).");
  22758. } else {
  22759. ttContext.functionsUsed[funcId] = true;
  22760. if (funcId in ttContext.functionsStackDeltas) {
  22761. const newStackLength = stack.length + ttContext.functionsStackDeltas[funcId];
  22762. if (newStackLength < 0) {
  22763. (0, _util.warn)("TT: CALL invalid functions stack delta.");
  22764. ttContext.hintsValid = false;
  22765. return;
  22766. }
  22767. stack.length = newStackLength;
  22768. } else if (funcId in ttContext.functionsDefined && !functionsCalled.includes(funcId)) {
  22769. callstack.push({
  22770. data,
  22771. i,
  22772. stackTop: stack.length - 1
  22773. });
  22774. functionsCalled.push(funcId);
  22775. pc = ttContext.functionsDefined[funcId];
  22776. if (!pc) {
  22777. (0, _util.warn)("TT: CALL non-existent function");
  22778. ttContext.hintsValid = false;
  22779. return;
  22780. }
  22781. data = pc.data;
  22782. i = pc.i;
  22783. }
  22784. }
  22785. }
  22786. } else if (op === 0x2c && !tooComplexToFollowFunctions) {
  22787. if (inFDEF || inELSE) {
  22788. (0, _util.warn)("TT: nested FDEFs not allowed");
  22789. tooComplexToFollowFunctions = true;
  22790. }
  22791. inFDEF = true;
  22792. lastDeff = i;
  22793. funcId = stack.pop();
  22794. ttContext.functionsDefined[funcId] = {
  22795. data,
  22796. i
  22797. };
  22798. } else if (op === 0x2d) {
  22799. if (inFDEF) {
  22800. inFDEF = false;
  22801. lastEndf = i;
  22802. } else {
  22803. pc = callstack.pop();
  22804. if (!pc) {
  22805. (0, _util.warn)("TT: ENDF bad stack");
  22806. ttContext.hintsValid = false;
  22807. return;
  22808. }
  22809. funcId = functionsCalled.pop();
  22810. data = pc.data;
  22811. i = pc.i;
  22812. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  22813. }
  22814. } else if (op === 0x89) {
  22815. if (inFDEF || inELSE) {
  22816. (0, _util.warn)("TT: nested IDEFs not allowed");
  22817. tooComplexToFollowFunctions = true;
  22818. }
  22819. inFDEF = true;
  22820. lastDeff = i;
  22821. } else if (op === 0x58) {
  22822. ++ifLevel;
  22823. } else if (op === 0x1b) {
  22824. inELSE = ifLevel;
  22825. } else if (op === 0x59) {
  22826. if (inELSE === ifLevel) {
  22827. inELSE = 0;
  22828. }
  22829. --ifLevel;
  22830. } else if (op === 0x1c) {
  22831. if (!inFDEF && !inELSE) {
  22832. const offset = stack.at(-1);
  22833. if (offset > 0) {
  22834. i += offset - 1;
  22835. }
  22836. }
  22837. }
  22838. if (!inFDEF && !inELSE) {
  22839. let stackDelta = 0;
  22840. if (op <= 0x8e) {
  22841. stackDelta = TTOpsStackDeltas[op];
  22842. } else if (op >= 0xc0 && op <= 0xdf) {
  22843. stackDelta = -1;
  22844. } else if (op >= 0xe0) {
  22845. stackDelta = -2;
  22846. }
  22847. if (op >= 0x71 && op <= 0x75) {
  22848. n = stack.pop();
  22849. if (!isNaN(n)) {
  22850. stackDelta = -n * 2;
  22851. }
  22852. }
  22853. while (stackDelta < 0 && stack.length > 0) {
  22854. stack.pop();
  22855. stackDelta++;
  22856. }
  22857. while (stackDelta > 0) {
  22858. stack.push(NaN);
  22859. stackDelta--;
  22860. }
  22861. }
  22862. }
  22863. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  22864. const content = [data];
  22865. if (i > data.length) {
  22866. content.push(new Uint8Array(i - data.length));
  22867. }
  22868. if (lastDeff > lastEndf) {
  22869. (0, _util.warn)("TT: complementing a missing function tail");
  22870. content.push(new Uint8Array([0x22, 0x2d]));
  22871. }
  22872. foldTTTable(table, content);
  22873. }
  22874. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  22875. if (ttContext.tooComplexToFollowFunctions) {
  22876. return;
  22877. }
  22878. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  22879. (0, _util.warn)("TT: more functions defined than expected");
  22880. ttContext.hintsValid = false;
  22881. return;
  22882. }
  22883. for (let j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  22884. if (j > maxFunctionDefs) {
  22885. (0, _util.warn)("TT: invalid function id: " + j);
  22886. ttContext.hintsValid = false;
  22887. return;
  22888. }
  22889. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  22890. (0, _util.warn)("TT: undefined function: " + j);
  22891. ttContext.hintsValid = false;
  22892. return;
  22893. }
  22894. }
  22895. }
  22896. function foldTTTable(table, content) {
  22897. if (content.length > 1) {
  22898. let newLength = 0;
  22899. let j, jj;
  22900. for (j = 0, jj = content.length; j < jj; j++) {
  22901. newLength += content[j].length;
  22902. }
  22903. newLength = newLength + 3 & ~3;
  22904. const result = new Uint8Array(newLength);
  22905. let pos = 0;
  22906. for (j = 0, jj = content.length; j < jj; j++) {
  22907. result.set(content[j], pos);
  22908. pos += content[j].length;
  22909. }
  22910. table.data = result;
  22911. table.length = newLength;
  22912. }
  22913. }
  22914. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  22915. const ttContext = {
  22916. functionsDefined: [],
  22917. functionsUsed: [],
  22918. functionsStackDeltas: [],
  22919. tooComplexToFollowFunctions: false,
  22920. hintsValid: true
  22921. };
  22922. if (fpgm) {
  22923. sanitizeTTProgram(fpgm, ttContext);
  22924. }
  22925. if (prep) {
  22926. sanitizeTTProgram(prep, ttContext);
  22927. }
  22928. if (fpgm) {
  22929. checkInvalidFunctions(ttContext, maxFunctionDefs);
  22930. }
  22931. if (cvt && cvt.length & 1) {
  22932. const cvtData = new Uint8Array(cvt.length + 1);
  22933. cvtData.set(cvt.data);
  22934. cvt.data = cvtData;
  22935. }
  22936. return ttContext.hintsValid;
  22937. }
  22938. font = new _stream.Stream(new Uint8Array(font.getBytes()));
  22939. let header, tables;
  22940. if (isTrueTypeCollectionFile(font)) {
  22941. const ttcData = readTrueTypeCollectionData(font, this.name);
  22942. header = ttcData.header;
  22943. tables = ttcData.tables;
  22944. } else {
  22945. header = readOpenTypeHeader(font);
  22946. tables = readTables(font, header.numTables);
  22947. }
  22948. let cff, cffFile;
  22949. const isTrueType = !tables["CFF "];
  22950. if (!isTrueType) {
  22951. const isComposite = properties.composite && (properties.cidToGidMap?.length > 0 || !(properties.cMap instanceof _cmap.IdentityCMap));
  22952. if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
  22953. cffFile = new _stream.Stream(tables["CFF "].data);
  22954. cff = new _cff_font.CFFFont(cffFile, properties);
  22955. adjustWidths(properties);
  22956. return this.convert(name, cff, properties);
  22957. }
  22958. delete tables.glyf;
  22959. delete tables.loca;
  22960. delete tables.fpgm;
  22961. delete tables.prep;
  22962. delete tables["cvt "];
  22963. this.isOpenType = true;
  22964. } else {
  22965. if (!tables.loca) {
  22966. throw new _util.FormatError('Required "loca" table is not found');
  22967. }
  22968. if (!tables.glyf) {
  22969. (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
  22970. tables.glyf = {
  22971. tag: "glyf",
  22972. data: new Uint8Array(0)
  22973. };
  22974. }
  22975. this.isOpenType = false;
  22976. }
  22977. if (!tables.maxp) {
  22978. throw new _util.FormatError('Required "maxp" table is not found');
  22979. }
  22980. font.pos = (font.start || 0) + tables.maxp.offset;
  22981. const version = font.getInt32();
  22982. const numGlyphs = font.getUint16();
  22983. if (properties.scaleFactors?.length === numGlyphs && isTrueType) {
  22984. const {
  22985. scaleFactors
  22986. } = properties;
  22987. const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
  22988. const glyphs = new _glyf.GlyfTable({
  22989. glyfTable: tables.glyf.data,
  22990. isGlyphLocationsLong,
  22991. locaTable: tables.loca.data,
  22992. numGlyphs
  22993. });
  22994. glyphs.scale(scaleFactors);
  22995. const {
  22996. glyf,
  22997. loca,
  22998. isLocationLong
  22999. } = glyphs.write();
  23000. tables.glyf.data = glyf;
  23001. tables.loca.data = loca;
  23002. if (isLocationLong !== !!isGlyphLocationsLong) {
  23003. tables.head.data[50] = 0;
  23004. tables.head.data[51] = isLocationLong ? 1 : 0;
  23005. }
  23006. const metrics = tables.hmtx.data;
  23007. for (let i = 0; i < numGlyphs; i++) {
  23008. const j = 4 * i;
  23009. const advanceWidth = Math.round(scaleFactors[i] * int16(metrics[j], metrics[j + 1]));
  23010. metrics[j] = advanceWidth >> 8 & 0xff;
  23011. metrics[j + 1] = advanceWidth & 0xff;
  23012. const lsb = Math.round(scaleFactors[i] * signedInt16(metrics[j + 2], metrics[j + 3]));
  23013. writeSignedInt16(metrics, j + 2, lsb);
  23014. }
  23015. }
  23016. let numGlyphsOut = numGlyphs + 1;
  23017. let dupFirstEntry = true;
  23018. if (numGlyphsOut > 0xffff) {
  23019. dupFirstEntry = false;
  23020. numGlyphsOut = numGlyphs;
  23021. (0, _util.warn)("Not enough space in glyfs to duplicate first glyph.");
  23022. }
  23023. let maxFunctionDefs = 0;
  23024. let maxSizeOfInstructions = 0;
  23025. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  23026. font.pos += 8;
  23027. const maxZones = font.getUint16();
  23028. if (maxZones > 2) {
  23029. tables.maxp.data[14] = 0;
  23030. tables.maxp.data[15] = 2;
  23031. }
  23032. font.pos += 4;
  23033. maxFunctionDefs = font.getUint16();
  23034. font.pos += 4;
  23035. maxSizeOfInstructions = font.getUint16();
  23036. }
  23037. tables.maxp.data[4] = numGlyphsOut >> 8;
  23038. tables.maxp.data[5] = numGlyphsOut & 255;
  23039. const hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
  23040. if (!hintsValid) {
  23041. delete tables.fpgm;
  23042. delete tables.prep;
  23043. delete tables["cvt "];
  23044. }
  23045. sanitizeMetrics(font, tables.hhea, tables.hmtx, tables.head, numGlyphsOut, dupFirstEntry);
  23046. if (!tables.head) {
  23047. throw new _util.FormatError('Required "head" table is not found');
  23048. }
  23049. sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
  23050. let missingGlyphs = Object.create(null);
  23051. if (isTrueType) {
  23052. const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
  23053. const glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
  23054. missingGlyphs = glyphsInfo.missingGlyphs;
  23055. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  23056. tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
  23057. tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
  23058. }
  23059. }
  23060. if (!tables.hhea) {
  23061. throw new _util.FormatError('Required "hhea" table is not found');
  23062. }
  23063. if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
  23064. tables.hhea.data[10] = 0xff;
  23065. tables.hhea.data[11] = 0xff;
  23066. }
  23067. const metricsOverride = {
  23068. unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
  23069. yMax: signedInt16(tables.head.data[42], tables.head.data[43]),
  23070. yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
  23071. ascent: signedInt16(tables.hhea.data[4], tables.hhea.data[5]),
  23072. descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7]),
  23073. lineGap: signedInt16(tables.hhea.data[8], tables.hhea.data[9])
  23074. };
  23075. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  23076. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  23077. this.lineGap = metricsOverride.lineGap / metricsOverride.unitsPerEm;
  23078. if (this.cssFontInfo?.lineHeight) {
  23079. this.lineHeight = this.cssFontInfo.metrics.lineHeight;
  23080. this.lineGap = this.cssFontInfo.metrics.lineGap;
  23081. } else {
  23082. this.lineHeight = this.ascent - this.descent + this.lineGap;
  23083. }
  23084. if (tables.post) {
  23085. readPostScriptTable(tables.post, properties, numGlyphs);
  23086. }
  23087. tables.post = {
  23088. tag: "post",
  23089. data: createPostTable(properties)
  23090. };
  23091. const charCodeToGlyphId = [];
  23092. function hasGlyph(glyphId) {
  23093. return !missingGlyphs[glyphId];
  23094. }
  23095. if (properties.composite) {
  23096. const cidToGidMap = properties.cidToGidMap || [];
  23097. const isCidToGidMapEmpty = cidToGidMap.length === 0;
  23098. properties.cMap.forEach(function (charCode, cid) {
  23099. if (typeof cid === "string") {
  23100. cid = convertCidString(charCode, cid, true);
  23101. }
  23102. if (cid > 0xffff) {
  23103. throw new _util.FormatError("Max size of CID is 65,535");
  23104. }
  23105. let glyphId = -1;
  23106. if (isCidToGidMapEmpty) {
  23107. glyphId = cid;
  23108. } else if (cidToGidMap[cid] !== undefined) {
  23109. glyphId = cidToGidMap[cid];
  23110. }
  23111. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
  23112. charCodeToGlyphId[charCode] = glyphId;
  23113. }
  23114. });
  23115. } else {
  23116. const cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
  23117. const cmapPlatformId = cmapTable.platformId;
  23118. const cmapEncodingId = cmapTable.encodingId;
  23119. const cmapMappings = cmapTable.mappings;
  23120. let baseEncoding = [],
  23121. forcePostTable = false;
  23122. if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
  23123. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  23124. }
  23125. if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
  23126. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  23127. for (let charCode = 0; charCode < 256; charCode++) {
  23128. let glyphName;
  23129. if (this.differences[charCode] !== undefined) {
  23130. glyphName = this.differences[charCode];
  23131. } else if (baseEncoding.length && baseEncoding[charCode] !== "") {
  23132. glyphName = baseEncoding[charCode];
  23133. } else {
  23134. glyphName = _encodings.StandardEncoding[charCode];
  23135. }
  23136. if (!glyphName) {
  23137. continue;
  23138. }
  23139. const standardGlyphName = (0, _fonts_utils.recoverGlyphName)(glyphName, glyphsUnicodeMap);
  23140. let unicodeOrCharCode;
  23141. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  23142. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  23143. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  23144. unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
  23145. }
  23146. if (unicodeOrCharCode === undefined) {
  23147. if (!properties.glyphNames && properties.hasIncludedToUnicodeMap && !(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  23148. const unicode = this.toUnicode.get(charCode);
  23149. if (unicode) {
  23150. unicodeOrCharCode = unicode.codePointAt(0);
  23151. }
  23152. }
  23153. if (unicodeOrCharCode === undefined) {
  23154. continue;
  23155. }
  23156. }
  23157. for (const mapping of cmapMappings) {
  23158. if (mapping.charCode !== unicodeOrCharCode) {
  23159. continue;
  23160. }
  23161. charCodeToGlyphId[charCode] = mapping.glyphId;
  23162. break;
  23163. }
  23164. }
  23165. } else if (cmapPlatformId === 0) {
  23166. for (const mapping of cmapMappings) {
  23167. charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
  23168. }
  23169. forcePostTable = true;
  23170. } else {
  23171. for (const mapping of cmapMappings) {
  23172. let charCode = mapping.charCode;
  23173. if (cmapPlatformId === 3 && charCode >= 0xf000 && charCode <= 0xf0ff) {
  23174. charCode &= 0xff;
  23175. }
  23176. charCodeToGlyphId[charCode] = mapping.glyphId;
  23177. }
  23178. }
  23179. if (properties.glyphNames && (baseEncoding.length || this.differences.length)) {
  23180. for (let i = 0; i < 256; ++i) {
  23181. if (!forcePostTable && charCodeToGlyphId[i] !== undefined) {
  23182. continue;
  23183. }
  23184. const glyphName = this.differences[i] || baseEncoding[i];
  23185. if (!glyphName) {
  23186. continue;
  23187. }
  23188. const glyphId = properties.glyphNames.indexOf(glyphName);
  23189. if (glyphId > 0 && hasGlyph(glyphId)) {
  23190. charCodeToGlyphId[i] = glyphId;
  23191. }
  23192. }
  23193. }
  23194. }
  23195. if (charCodeToGlyphId.length === 0) {
  23196. charCodeToGlyphId[0] = 0;
  23197. }
  23198. let glyphZeroId = numGlyphsOut - 1;
  23199. if (!dupFirstEntry) {
  23200. glyphZeroId = 0;
  23201. }
  23202. if (!properties.cssFontInfo) {
  23203. const newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId, this.toUnicode);
  23204. this.toFontChar = newMapping.toFontChar;
  23205. tables.cmap = {
  23206. tag: "cmap",
  23207. data: createCmapTable(newMapping.charCodeToGlyphId, newMapping.toUnicodeExtraMap, numGlyphsOut)
  23208. };
  23209. if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
  23210. tables["OS/2"] = {
  23211. tag: "OS/2",
  23212. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  23213. };
  23214. }
  23215. }
  23216. if (!isTrueType) {
  23217. try {
  23218. cffFile = new _stream.Stream(tables["CFF "].data);
  23219. const parser = new _cff_parser.CFFParser(cffFile, properties, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  23220. cff = parser.parse();
  23221. cff.duplicateFirstGlyph();
  23222. const compiler = new _cff_parser.CFFCompiler(cff);
  23223. tables["CFF "].data = compiler.compile();
  23224. } catch {
  23225. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  23226. }
  23227. }
  23228. if (!tables.name) {
  23229. tables.name = {
  23230. tag: "name",
  23231. data: createNameTable(this.name)
  23232. };
  23233. } else {
  23234. const [namePrototype, nameRecords] = readNameTable(tables.name);
  23235. tables.name.data = createNameTable(name, namePrototype);
  23236. this.psName = namePrototype[0][6] || null;
  23237. if (!properties.composite) {
  23238. adjustTrueTypeToUnicode(properties, this.isSymbolicFont, nameRecords);
  23239. }
  23240. }
  23241. const builder = new _opentype_file_builder.OpenTypeFileBuilder(header.version);
  23242. for (const tableTag in tables) {
  23243. builder.addTable(tableTag, tables[tableTag].data);
  23244. }
  23245. return builder.toArray();
  23246. }
  23247. convert(fontName, font, properties) {
  23248. properties.fixedPitch = false;
  23249. if (properties.builtInEncoding) {
  23250. adjustType1ToUnicode(properties, properties.builtInEncoding);
  23251. }
  23252. let glyphZeroId = 1;
  23253. if (font instanceof _cff_font.CFFFont) {
  23254. glyphZeroId = font.numGlyphs - 1;
  23255. }
  23256. const mapping = font.getGlyphMapping(properties);
  23257. let newMapping = null;
  23258. let newCharCodeToGlyphId = mapping;
  23259. let toUnicodeExtraMap = null;
  23260. if (!properties.cssFontInfo) {
  23261. newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId, this.toUnicode);
  23262. this.toFontChar = newMapping.toFontChar;
  23263. newCharCodeToGlyphId = newMapping.charCodeToGlyphId;
  23264. toUnicodeExtraMap = newMapping.toUnicodeExtraMap;
  23265. }
  23266. const numGlyphs = font.numGlyphs;
  23267. function getCharCodes(charCodeToGlyphId, glyphId) {
  23268. let charCodes = null;
  23269. for (const charCode in charCodeToGlyphId) {
  23270. if (glyphId === charCodeToGlyphId[charCode]) {
  23271. (charCodes ||= []).push(charCode | 0);
  23272. }
  23273. }
  23274. return charCodes;
  23275. }
  23276. function createCharCode(charCodeToGlyphId, glyphId) {
  23277. for (const charCode in charCodeToGlyphId) {
  23278. if (glyphId === charCodeToGlyphId[charCode]) {
  23279. return charCode | 0;
  23280. }
  23281. }
  23282. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  23283. return newMapping.nextAvailableFontCharCode++;
  23284. }
  23285. const seacs = font.seacs;
  23286. if (newMapping && _fonts_utils.SEAC_ANALYSIS_ENABLED && seacs?.length) {
  23287. const matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  23288. const charset = font.getCharset();
  23289. const seacMap = Object.create(null);
  23290. for (let glyphId in seacs) {
  23291. glyphId |= 0;
  23292. const seac = seacs[glyphId];
  23293. const baseGlyphName = _encodings.StandardEncoding[seac[2]];
  23294. const accentGlyphName = _encodings.StandardEncoding[seac[3]];
  23295. const baseGlyphId = charset.indexOf(baseGlyphName);
  23296. const accentGlyphId = charset.indexOf(accentGlyphName);
  23297. if (baseGlyphId < 0 || accentGlyphId < 0) {
  23298. continue;
  23299. }
  23300. const accentOffset = {
  23301. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  23302. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  23303. };
  23304. const charCodes = getCharCodes(mapping, glyphId);
  23305. if (!charCodes) {
  23306. continue;
  23307. }
  23308. for (const charCode of charCodes) {
  23309. const charCodeToGlyphId = newMapping.charCodeToGlyphId;
  23310. const baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  23311. const accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  23312. seacMap[charCode] = {
  23313. baseFontCharCode,
  23314. accentFontCharCode,
  23315. accentOffset
  23316. };
  23317. }
  23318. }
  23319. properties.seacMap = seacMap;
  23320. }
  23321. const unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  23322. const builder = new _opentype_file_builder.OpenTypeFileBuilder("\x4F\x54\x54\x4F");
  23323. builder.addTable("CFF ", font.data);
  23324. builder.addTable("OS/2", createOS2Table(properties, newCharCodeToGlyphId));
  23325. builder.addTable("cmap", createCmapTable(newCharCodeToGlyphId, toUnicodeExtraMap, numGlyphs));
  23326. builder.addTable("head", "\x00\x01\x00\x00" + "\x00\x00\x10\x00" + "\x00\x00\x00\x00" + "\x5F\x0F\x3C\xF5" + "\x00\x00" + safeString16(unitsPerEm) + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00" + safeString16(properties.descent) + "\x0F\xFF" + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + "\x00\x11" + "\x00\x00" + "\x00\x00" + "\x00\x00");
  23327. builder.addTable("hhea", "\x00\x01\x00\x00" + safeString16(properties.ascent) + safeString16(properties.descent) + "\x00\x00" + "\xFF\xFF" + "\x00\x00" + "\x00\x00" + "\x00\x00" + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + string16(numGlyphs));
  23328. builder.addTable("hmtx", function fontFieldsHmtx() {
  23329. const charstrings = font.charstrings;
  23330. const cffWidths = font.cff ? font.cff.widths : null;
  23331. let hmtx = "\x00\x00\x00\x00";
  23332. for (let i = 1, ii = numGlyphs; i < ii; i++) {
  23333. let width = 0;
  23334. if (charstrings) {
  23335. const charstring = charstrings[i - 1];
  23336. width = "width" in charstring ? charstring.width : 0;
  23337. } else if (cffWidths) {
  23338. width = Math.ceil(cffWidths[i] || 0);
  23339. }
  23340. hmtx += string16(width) + string16(0);
  23341. }
  23342. return hmtx;
  23343. }());
  23344. builder.addTable("maxp", "\x00\x00\x50\x00" + string16(numGlyphs));
  23345. builder.addTable("name", createNameTable(fontName));
  23346. builder.addTable("post", createPostTable(properties));
  23347. return builder.toArray();
  23348. }
  23349. get spaceWidth() {
  23350. const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
  23351. let width;
  23352. for (const glyphName of possibleSpaceReplacements) {
  23353. if (glyphName in this.widths) {
  23354. width = this.widths[glyphName];
  23355. break;
  23356. }
  23357. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  23358. const glyphUnicode = glyphsUnicodeMap[glyphName];
  23359. let charcode = 0;
  23360. if (this.composite && this.cMap.contains(glyphUnicode)) {
  23361. charcode = this.cMap.lookup(glyphUnicode);
  23362. if (typeof charcode === "string") {
  23363. charcode = convertCidString(glyphUnicode, charcode);
  23364. }
  23365. }
  23366. if (!charcode && this.toUnicode) {
  23367. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  23368. }
  23369. if (charcode <= 0) {
  23370. charcode = glyphUnicode;
  23371. }
  23372. width = this.widths[charcode];
  23373. if (width) {
  23374. break;
  23375. }
  23376. }
  23377. return (0, _util.shadow)(this, "spaceWidth", width || this.defaultWidth);
  23378. }
  23379. _charToGlyph(charcode, isSpace = false) {
  23380. let glyph = this._glyphCache[charcode];
  23381. if (glyph?.isSpace === isSpace) {
  23382. return glyph;
  23383. }
  23384. let fontCharCode, width, operatorListId;
  23385. let widthCode = charcode;
  23386. if (this.cMap?.contains(charcode)) {
  23387. widthCode = this.cMap.lookup(charcode);
  23388. if (typeof widthCode === "string") {
  23389. widthCode = convertCidString(charcode, widthCode);
  23390. }
  23391. }
  23392. width = this.widths[widthCode];
  23393. if (typeof width !== "number") {
  23394. width = this.defaultWidth;
  23395. }
  23396. const vmetric = this.vmetrics?.[widthCode];
  23397. let unicode = this.toUnicode.get(charcode) || charcode;
  23398. if (typeof unicode === "number") {
  23399. unicode = String.fromCharCode(unicode);
  23400. }
  23401. let isInFont = this.toFontChar[charcode] !== undefined;
  23402. fontCharCode = this.toFontChar[charcode] || charcode;
  23403. if (this.missingFile) {
  23404. const glyphName = this.differences[charcode] || this.defaultEncoding[charcode];
  23405. if ((glyphName === ".notdef" || glyphName === "") && this.type === "Type1") {
  23406. fontCharCode = 0x20;
  23407. }
  23408. fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
  23409. }
  23410. if (this.isType3Font) {
  23411. operatorListId = fontCharCode;
  23412. }
  23413. let accent = null;
  23414. if (this.seacMap?.[charcode]) {
  23415. isInFont = true;
  23416. const seac = this.seacMap[charcode];
  23417. fontCharCode = seac.baseFontCharCode;
  23418. accent = {
  23419. fontChar: String.fromCodePoint(seac.accentFontCharCode),
  23420. offset: seac.accentOffset
  23421. };
  23422. }
  23423. let fontChar = "";
  23424. if (typeof fontCharCode === "number") {
  23425. if (fontCharCode <= 0x10ffff) {
  23426. fontChar = String.fromCodePoint(fontCharCode);
  23427. } else {
  23428. (0, _util.warn)(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
  23429. }
  23430. }
  23431. glyph = new Glyph(charcode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  23432. return this._glyphCache[charcode] = glyph;
  23433. }
  23434. charsToGlyphs(chars) {
  23435. let glyphs = this._charsCache[chars];
  23436. if (glyphs) {
  23437. return glyphs;
  23438. }
  23439. glyphs = [];
  23440. if (this.cMap) {
  23441. const c = Object.create(null),
  23442. ii = chars.length;
  23443. let i = 0;
  23444. while (i < ii) {
  23445. this.cMap.readCharCode(chars, i, c);
  23446. const {
  23447. charcode,
  23448. length
  23449. } = c;
  23450. i += length;
  23451. const glyph = this._charToGlyph(charcode, length === 1 && chars.charCodeAt(i - 1) === 0x20);
  23452. glyphs.push(glyph);
  23453. }
  23454. } else {
  23455. for (let i = 0, ii = chars.length; i < ii; ++i) {
  23456. const charcode = chars.charCodeAt(i);
  23457. const glyph = this._charToGlyph(charcode, charcode === 0x20);
  23458. glyphs.push(glyph);
  23459. }
  23460. }
  23461. return this._charsCache[chars] = glyphs;
  23462. }
  23463. getCharPositions(chars) {
  23464. const positions = [];
  23465. if (this.cMap) {
  23466. const c = Object.create(null);
  23467. let i = 0;
  23468. while (i < chars.length) {
  23469. this.cMap.readCharCode(chars, i, c);
  23470. const length = c.length;
  23471. positions.push([i, i + length]);
  23472. i += length;
  23473. }
  23474. } else {
  23475. for (let i = 0, ii = chars.length; i < ii; ++i) {
  23476. positions.push([i, i + 1]);
  23477. }
  23478. }
  23479. return positions;
  23480. }
  23481. get glyphCacheValues() {
  23482. return Object.values(this._glyphCache);
  23483. }
  23484. encodeString(str) {
  23485. const buffers = [];
  23486. const currentBuf = [];
  23487. const hasCurrentBufErrors = () => buffers.length % 2 === 1;
  23488. const getCharCode = this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap ? unicode => this.toUnicode.charCodeOf(unicode) : unicode => this.toUnicode.charCodeOf(String.fromCodePoint(unicode));
  23489. for (let i = 0, ii = str.length; i < ii; i++) {
  23490. const unicode = str.codePointAt(i);
  23491. if (unicode > 0xd7ff && (unicode < 0xe000 || unicode > 0xfffd)) {
  23492. i++;
  23493. }
  23494. if (this.toUnicode) {
  23495. const charCode = getCharCode(unicode);
  23496. if (charCode !== -1) {
  23497. if (hasCurrentBufErrors()) {
  23498. buffers.push(currentBuf.join(""));
  23499. currentBuf.length = 0;
  23500. }
  23501. const charCodeLength = this.cMap ? this.cMap.getCharCodeLength(charCode) : 1;
  23502. for (let j = charCodeLength - 1; j >= 0; j--) {
  23503. currentBuf.push(String.fromCharCode(charCode >> 8 * j & 0xff));
  23504. }
  23505. continue;
  23506. }
  23507. }
  23508. if (!hasCurrentBufErrors()) {
  23509. buffers.push(currentBuf.join(""));
  23510. currentBuf.length = 0;
  23511. }
  23512. currentBuf.push(String.fromCodePoint(unicode));
  23513. }
  23514. buffers.push(currentBuf.join(""));
  23515. return buffers;
  23516. }
  23517. }
  23518. exports.Font = Font;
  23519. class ErrorFont {
  23520. constructor(error) {
  23521. this.error = error;
  23522. this.loadedName = "g_font_error";
  23523. this.missingFile = true;
  23524. }
  23525. charsToGlyphs() {
  23526. return [];
  23527. }
  23528. encodeString(chars) {
  23529. return [chars];
  23530. }
  23531. exportData(extraProperties = false) {
  23532. return {
  23533. error: this.error
  23534. };
  23535. }
  23536. }
  23537. exports.ErrorFont = ErrorFont;
  23538. /***/ }),
  23539. /* 35 */
  23540. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  23541. Object.defineProperty(exports, "__esModule", ({
  23542. value: true
  23543. }));
  23544. exports.CFFTopDict = exports.CFFStrings = exports.CFFStandardStrings = exports.CFFPrivateDict = exports.CFFParser = exports.CFFIndex = exports.CFFHeader = exports.CFFFDSelect = exports.CFFCompiler = exports.CFFCharset = exports.CFF = void 0;
  23545. var _util = __w_pdfjs_require__(2);
  23546. var _charsets = __w_pdfjs_require__(36);
  23547. var _encodings = __w_pdfjs_require__(37);
  23548. const MAX_SUBR_NESTING = 10;
  23549. const CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
  23550. exports.CFFStandardStrings = CFFStandardStrings;
  23551. const NUM_STANDARD_CFF_STRINGS = 391;
  23552. const CharstringValidationData = [null, {
  23553. id: "hstem",
  23554. min: 2,
  23555. stackClearing: true,
  23556. stem: true
  23557. }, null, {
  23558. id: "vstem",
  23559. min: 2,
  23560. stackClearing: true,
  23561. stem: true
  23562. }, {
  23563. id: "vmoveto",
  23564. min: 1,
  23565. stackClearing: true
  23566. }, {
  23567. id: "rlineto",
  23568. min: 2,
  23569. resetStack: true
  23570. }, {
  23571. id: "hlineto",
  23572. min: 1,
  23573. resetStack: true
  23574. }, {
  23575. id: "vlineto",
  23576. min: 1,
  23577. resetStack: true
  23578. }, {
  23579. id: "rrcurveto",
  23580. min: 6,
  23581. resetStack: true
  23582. }, null, {
  23583. id: "callsubr",
  23584. min: 1,
  23585. undefStack: true
  23586. }, {
  23587. id: "return",
  23588. min: 0,
  23589. undefStack: true
  23590. }, null, null, {
  23591. id: "endchar",
  23592. min: 0,
  23593. stackClearing: true
  23594. }, null, null, null, {
  23595. id: "hstemhm",
  23596. min: 2,
  23597. stackClearing: true,
  23598. stem: true
  23599. }, {
  23600. id: "hintmask",
  23601. min: 0,
  23602. stackClearing: true
  23603. }, {
  23604. id: "cntrmask",
  23605. min: 0,
  23606. stackClearing: true
  23607. }, {
  23608. id: "rmoveto",
  23609. min: 2,
  23610. stackClearing: true
  23611. }, {
  23612. id: "hmoveto",
  23613. min: 1,
  23614. stackClearing: true
  23615. }, {
  23616. id: "vstemhm",
  23617. min: 2,
  23618. stackClearing: true,
  23619. stem: true
  23620. }, {
  23621. id: "rcurveline",
  23622. min: 8,
  23623. resetStack: true
  23624. }, {
  23625. id: "rlinecurve",
  23626. min: 8,
  23627. resetStack: true
  23628. }, {
  23629. id: "vvcurveto",
  23630. min: 4,
  23631. resetStack: true
  23632. }, {
  23633. id: "hhcurveto",
  23634. min: 4,
  23635. resetStack: true
  23636. }, null, {
  23637. id: "callgsubr",
  23638. min: 1,
  23639. undefStack: true
  23640. }, {
  23641. id: "vhcurveto",
  23642. min: 4,
  23643. resetStack: true
  23644. }, {
  23645. id: "hvcurveto",
  23646. min: 4,
  23647. resetStack: true
  23648. }];
  23649. const CharstringValidationData12 = [null, null, null, {
  23650. id: "and",
  23651. min: 2,
  23652. stackDelta: -1
  23653. }, {
  23654. id: "or",
  23655. min: 2,
  23656. stackDelta: -1
  23657. }, {
  23658. id: "not",
  23659. min: 1,
  23660. stackDelta: 0
  23661. }, null, null, null, {
  23662. id: "abs",
  23663. min: 1,
  23664. stackDelta: 0
  23665. }, {
  23666. id: "add",
  23667. min: 2,
  23668. stackDelta: -1,
  23669. stackFn(stack, index) {
  23670. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23671. }
  23672. }, {
  23673. id: "sub",
  23674. min: 2,
  23675. stackDelta: -1,
  23676. stackFn(stack, index) {
  23677. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23678. }
  23679. }, {
  23680. id: "div",
  23681. min: 2,
  23682. stackDelta: -1,
  23683. stackFn(stack, index) {
  23684. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23685. }
  23686. }, null, {
  23687. id: "neg",
  23688. min: 1,
  23689. stackDelta: 0,
  23690. stackFn(stack, index) {
  23691. stack[index - 1] = -stack[index - 1];
  23692. }
  23693. }, {
  23694. id: "eq",
  23695. min: 2,
  23696. stackDelta: -1
  23697. }, null, null, {
  23698. id: "drop",
  23699. min: 1,
  23700. stackDelta: -1
  23701. }, null, {
  23702. id: "put",
  23703. min: 2,
  23704. stackDelta: -2
  23705. }, {
  23706. id: "get",
  23707. min: 1,
  23708. stackDelta: 0
  23709. }, {
  23710. id: "ifelse",
  23711. min: 4,
  23712. stackDelta: -3
  23713. }, {
  23714. id: "random",
  23715. min: 0,
  23716. stackDelta: 1
  23717. }, {
  23718. id: "mul",
  23719. min: 2,
  23720. stackDelta: -1,
  23721. stackFn(stack, index) {
  23722. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23723. }
  23724. }, null, {
  23725. id: "sqrt",
  23726. min: 1,
  23727. stackDelta: 0
  23728. }, {
  23729. id: "dup",
  23730. min: 1,
  23731. stackDelta: 1
  23732. }, {
  23733. id: "exch",
  23734. min: 2,
  23735. stackDelta: 0
  23736. }, {
  23737. id: "index",
  23738. min: 2,
  23739. stackDelta: 0
  23740. }, {
  23741. id: "roll",
  23742. min: 3,
  23743. stackDelta: -2
  23744. }, null, null, null, {
  23745. id: "hflex",
  23746. min: 7,
  23747. resetStack: true
  23748. }, {
  23749. id: "flex",
  23750. min: 13,
  23751. resetStack: true
  23752. }, {
  23753. id: "hflex1",
  23754. min: 9,
  23755. resetStack: true
  23756. }, {
  23757. id: "flex1",
  23758. min: 11,
  23759. resetStack: true
  23760. }];
  23761. class CFFParser {
  23762. constructor(file, properties, seacAnalysisEnabled) {
  23763. this.bytes = file.getBytes();
  23764. this.properties = properties;
  23765. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23766. }
  23767. parse() {
  23768. const properties = this.properties;
  23769. const cff = new CFF();
  23770. this.cff = cff;
  23771. const header = this.parseHeader();
  23772. const nameIndex = this.parseIndex(header.endPos);
  23773. const topDictIndex = this.parseIndex(nameIndex.endPos);
  23774. const stringIndex = this.parseIndex(topDictIndex.endPos);
  23775. const globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23776. const topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23777. const topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23778. cff.header = header.obj;
  23779. cff.names = this.parseNameIndex(nameIndex.obj);
  23780. cff.strings = this.parseStringIndex(stringIndex.obj);
  23781. cff.topDict = topDict;
  23782. cff.globalSubrIndex = globalSubrIndex.obj;
  23783. this.parsePrivateDict(cff.topDict);
  23784. cff.isCIDFont = topDict.hasName("ROS");
  23785. const charStringOffset = topDict.getByName("CharStrings");
  23786. const charStringIndex = this.parseIndex(charStringOffset).obj;
  23787. const fontMatrix = topDict.getByName("FontMatrix");
  23788. if (fontMatrix) {
  23789. properties.fontMatrix = fontMatrix;
  23790. }
  23791. const fontBBox = topDict.getByName("FontBBox");
  23792. if (fontBBox) {
  23793. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23794. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23795. properties.ascentScaled = true;
  23796. }
  23797. let charset, encoding;
  23798. if (cff.isCIDFont) {
  23799. const fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
  23800. for (let i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23801. const dictRaw = fdArrayIndex.get(i);
  23802. const fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23803. this.parsePrivateDict(fontDict);
  23804. cff.fdArray.push(fontDict);
  23805. }
  23806. encoding = null;
  23807. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
  23808. cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
  23809. } else {
  23810. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
  23811. encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
  23812. }
  23813. cff.charset = charset;
  23814. cff.encoding = encoding;
  23815. const charStringsAndSeacs = this.parseCharStrings({
  23816. charStrings: charStringIndex,
  23817. localSubrIndex: topDict.privateDict.subrsIndex,
  23818. globalSubrIndex: globalSubrIndex.obj,
  23819. fdSelect: cff.fdSelect,
  23820. fdArray: cff.fdArray,
  23821. privateDict: topDict.privateDict
  23822. });
  23823. cff.charStrings = charStringsAndSeacs.charStrings;
  23824. cff.seacs = charStringsAndSeacs.seacs;
  23825. cff.widths = charStringsAndSeacs.widths;
  23826. return cff;
  23827. }
  23828. parseHeader() {
  23829. let bytes = this.bytes;
  23830. const bytesLength = bytes.length;
  23831. let offset = 0;
  23832. while (offset < bytesLength && bytes[offset] !== 1) {
  23833. ++offset;
  23834. }
  23835. if (offset >= bytesLength) {
  23836. throw new _util.FormatError("Invalid CFF header");
  23837. }
  23838. if (offset !== 0) {
  23839. (0, _util.info)("cff data is shifted");
  23840. bytes = bytes.subarray(offset);
  23841. this.bytes = bytes;
  23842. }
  23843. const major = bytes[0];
  23844. const minor = bytes[1];
  23845. const hdrSize = bytes[2];
  23846. const offSize = bytes[3];
  23847. const header = new CFFHeader(major, minor, hdrSize, offSize);
  23848. return {
  23849. obj: header,
  23850. endPos: hdrSize
  23851. };
  23852. }
  23853. parseDict(dict) {
  23854. let pos = 0;
  23855. function parseOperand() {
  23856. let value = dict[pos++];
  23857. if (value === 30) {
  23858. return parseFloatOperand();
  23859. } else if (value === 28) {
  23860. value = dict[pos++];
  23861. value = (value << 24 | dict[pos++] << 16) >> 16;
  23862. return value;
  23863. } else if (value === 29) {
  23864. value = dict[pos++];
  23865. value = value << 8 | dict[pos++];
  23866. value = value << 8 | dict[pos++];
  23867. value = value << 8 | dict[pos++];
  23868. return value;
  23869. } else if (value >= 32 && value <= 246) {
  23870. return value - 139;
  23871. } else if (value >= 247 && value <= 250) {
  23872. return (value - 247) * 256 + dict[pos++] + 108;
  23873. } else if (value >= 251 && value <= 254) {
  23874. return -((value - 251) * 256) - dict[pos++] - 108;
  23875. }
  23876. (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23877. return NaN;
  23878. }
  23879. function parseFloatOperand() {
  23880. let str = "";
  23881. const eof = 15;
  23882. const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
  23883. const length = dict.length;
  23884. while (pos < length) {
  23885. const b = dict[pos++];
  23886. const b1 = b >> 4;
  23887. const b2 = b & 15;
  23888. if (b1 === eof) {
  23889. break;
  23890. }
  23891. str += lookup[b1];
  23892. if (b2 === eof) {
  23893. break;
  23894. }
  23895. str += lookup[b2];
  23896. }
  23897. return parseFloat(str);
  23898. }
  23899. let operands = [];
  23900. const entries = [];
  23901. pos = 0;
  23902. const end = dict.length;
  23903. while (pos < end) {
  23904. let b = dict[pos];
  23905. if (b <= 21) {
  23906. if (b === 12) {
  23907. b = b << 8 | dict[++pos];
  23908. }
  23909. entries.push([b, operands]);
  23910. operands = [];
  23911. ++pos;
  23912. } else {
  23913. operands.push(parseOperand());
  23914. }
  23915. }
  23916. return entries;
  23917. }
  23918. parseIndex(pos) {
  23919. const cffIndex = new CFFIndex();
  23920. const bytes = this.bytes;
  23921. const count = bytes[pos++] << 8 | bytes[pos++];
  23922. const offsets = [];
  23923. let end = pos;
  23924. let i, ii;
  23925. if (count !== 0) {
  23926. const offsetSize = bytes[pos++];
  23927. const startPos = pos + (count + 1) * offsetSize - 1;
  23928. for (i = 0, ii = count + 1; i < ii; ++i) {
  23929. let offset = 0;
  23930. for (let j = 0; j < offsetSize; ++j) {
  23931. offset <<= 8;
  23932. offset += bytes[pos++];
  23933. }
  23934. offsets.push(startPos + offset);
  23935. }
  23936. end = offsets[count];
  23937. }
  23938. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23939. const offsetStart = offsets[i];
  23940. const offsetEnd = offsets[i + 1];
  23941. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23942. }
  23943. return {
  23944. obj: cffIndex,
  23945. endPos: end
  23946. };
  23947. }
  23948. parseNameIndex(index) {
  23949. const names = [];
  23950. for (let i = 0, ii = index.count; i < ii; ++i) {
  23951. const name = index.get(i);
  23952. names.push((0, _util.bytesToString)(name));
  23953. }
  23954. return names;
  23955. }
  23956. parseStringIndex(index) {
  23957. const strings = new CFFStrings();
  23958. for (let i = 0, ii = index.count; i < ii; ++i) {
  23959. const data = index.get(i);
  23960. strings.add((0, _util.bytesToString)(data));
  23961. }
  23962. return strings;
  23963. }
  23964. createDict(Type, dict, strings) {
  23965. const cffDict = new Type(strings);
  23966. for (const [key, value] of dict) {
  23967. cffDict.setByKey(key, value);
  23968. }
  23969. return cffDict;
  23970. }
  23971. parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23972. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  23973. return false;
  23974. }
  23975. let stackSize = state.stackSize;
  23976. const stack = state.stack;
  23977. let length = data.length;
  23978. for (let j = 0; j < length;) {
  23979. const value = data[j++];
  23980. let validationCommand = null;
  23981. if (value === 12) {
  23982. const q = data[j++];
  23983. if (q === 0) {
  23984. data[j - 2] = 139;
  23985. data[j - 1] = 22;
  23986. stackSize = 0;
  23987. } else {
  23988. validationCommand = CharstringValidationData12[q];
  23989. }
  23990. } else if (value === 28) {
  23991. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23992. j += 2;
  23993. stackSize++;
  23994. } else if (value === 14) {
  23995. if (stackSize >= 4) {
  23996. stackSize -= 4;
  23997. if (this.seacAnalysisEnabled) {
  23998. state.seac = stack.slice(stackSize, stackSize + 4);
  23999. return false;
  24000. }
  24001. }
  24002. validationCommand = CharstringValidationData[value];
  24003. } else if (value >= 32 && value <= 246) {
  24004. stack[stackSize] = value - 139;
  24005. stackSize++;
  24006. } else if (value >= 247 && value <= 254) {
  24007. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  24008. j++;
  24009. stackSize++;
  24010. } else if (value === 255) {
  24011. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  24012. j += 4;
  24013. stackSize++;
  24014. } else if (value === 19 || value === 20) {
  24015. state.hints += stackSize >> 1;
  24016. if (state.hints === 0) {
  24017. data.copyWithin(j - 1, j, -1);
  24018. j -= 1;
  24019. length -= 1;
  24020. continue;
  24021. }
  24022. j += state.hints + 7 >> 3;
  24023. stackSize %= 2;
  24024. validationCommand = CharstringValidationData[value];
  24025. } else if (value === 10 || value === 29) {
  24026. const subrsIndex = value === 10 ? localSubrIndex : globalSubrIndex;
  24027. if (!subrsIndex) {
  24028. validationCommand = CharstringValidationData[value];
  24029. (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
  24030. return false;
  24031. }
  24032. let bias = 32768;
  24033. if (subrsIndex.count < 1240) {
  24034. bias = 107;
  24035. } else if (subrsIndex.count < 33900) {
  24036. bias = 1131;
  24037. }
  24038. const subrNumber = stack[--stackSize] + bias;
  24039. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  24040. validationCommand = CharstringValidationData[value];
  24041. (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
  24042. return false;
  24043. }
  24044. state.stackSize = stackSize;
  24045. state.callDepth++;
  24046. const valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  24047. if (!valid) {
  24048. return false;
  24049. }
  24050. state.callDepth--;
  24051. stackSize = state.stackSize;
  24052. continue;
  24053. } else if (value === 11) {
  24054. state.stackSize = stackSize;
  24055. return true;
  24056. } else if (value === 0 && j === data.length) {
  24057. data[j - 1] = 14;
  24058. validationCommand = CharstringValidationData[14];
  24059. } else if (value === 9) {
  24060. data.copyWithin(j - 1, j, -1);
  24061. j -= 1;
  24062. length -= 1;
  24063. continue;
  24064. } else {
  24065. validationCommand = CharstringValidationData[value];
  24066. }
  24067. if (validationCommand) {
  24068. if (validationCommand.stem) {
  24069. state.hints += stackSize >> 1;
  24070. if (value === 3 || value === 23) {
  24071. state.hasVStems = true;
  24072. } else if (state.hasVStems && (value === 1 || value === 18)) {
  24073. (0, _util.warn)("CFF stem hints are in wrong order");
  24074. data[j - 1] = value === 1 ? 3 : 23;
  24075. }
  24076. }
  24077. if ("min" in validationCommand) {
  24078. if (!state.undefStack && stackSize < validationCommand.min) {
  24079. (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
  24080. if (stackSize === 0) {
  24081. data[j - 1] = 14;
  24082. return true;
  24083. }
  24084. return false;
  24085. }
  24086. }
  24087. if (state.firstStackClearing && validationCommand.stackClearing) {
  24088. state.firstStackClearing = false;
  24089. stackSize -= validationCommand.min;
  24090. if (stackSize >= 2 && validationCommand.stem) {
  24091. stackSize %= 2;
  24092. } else if (stackSize > 1) {
  24093. (0, _util.warn)("Found too many parameters for stack-clearing command");
  24094. }
  24095. if (stackSize > 0) {
  24096. state.width = stack[stackSize - 1];
  24097. }
  24098. }
  24099. if ("stackDelta" in validationCommand) {
  24100. if ("stackFn" in validationCommand) {
  24101. validationCommand.stackFn(stack, stackSize);
  24102. }
  24103. stackSize += validationCommand.stackDelta;
  24104. } else if (validationCommand.stackClearing) {
  24105. stackSize = 0;
  24106. } else if (validationCommand.resetStack) {
  24107. stackSize = 0;
  24108. state.undefStack = false;
  24109. } else if (validationCommand.undefStack) {
  24110. stackSize = 0;
  24111. state.undefStack = true;
  24112. state.firstStackClearing = false;
  24113. }
  24114. }
  24115. }
  24116. if (length < data.length) {
  24117. data.fill(14, length);
  24118. }
  24119. state.stackSize = stackSize;
  24120. return true;
  24121. }
  24122. parseCharStrings({
  24123. charStrings,
  24124. localSubrIndex,
  24125. globalSubrIndex,
  24126. fdSelect,
  24127. fdArray,
  24128. privateDict
  24129. }) {
  24130. const seacs = [];
  24131. const widths = [];
  24132. const count = charStrings.count;
  24133. for (let i = 0; i < count; i++) {
  24134. const charstring = charStrings.get(i);
  24135. const state = {
  24136. callDepth: 0,
  24137. stackSize: 0,
  24138. stack: [],
  24139. undefStack: true,
  24140. hints: 0,
  24141. firstStackClearing: true,
  24142. seac: null,
  24143. width: null,
  24144. hasVStems: false
  24145. };
  24146. let valid = true;
  24147. let localSubrToUse = null;
  24148. let privateDictToUse = privateDict;
  24149. if (fdSelect && fdArray.length) {
  24150. const fdIndex = fdSelect.getFDIndex(i);
  24151. if (fdIndex === -1) {
  24152. (0, _util.warn)("Glyph index is not in fd select.");
  24153. valid = false;
  24154. }
  24155. if (fdIndex >= fdArray.length) {
  24156. (0, _util.warn)("Invalid fd index for glyph index.");
  24157. valid = false;
  24158. }
  24159. if (valid) {
  24160. privateDictToUse = fdArray[fdIndex].privateDict;
  24161. localSubrToUse = privateDictToUse.subrsIndex;
  24162. }
  24163. } else if (localSubrIndex) {
  24164. localSubrToUse = localSubrIndex;
  24165. }
  24166. if (valid) {
  24167. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  24168. }
  24169. if (state.width !== null) {
  24170. const nominalWidth = privateDictToUse.getByName("nominalWidthX");
  24171. widths[i] = nominalWidth + state.width;
  24172. } else {
  24173. const defaultWidth = privateDictToUse.getByName("defaultWidthX");
  24174. widths[i] = defaultWidth;
  24175. }
  24176. if (state.seac !== null) {
  24177. seacs[i] = state.seac;
  24178. }
  24179. if (!valid) {
  24180. charStrings.set(i, new Uint8Array([14]));
  24181. }
  24182. }
  24183. return {
  24184. charStrings,
  24185. seacs,
  24186. widths
  24187. };
  24188. }
  24189. emptyPrivateDictionary(parentDict) {
  24190. const privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  24191. parentDict.setByKey(18, [0, 0]);
  24192. parentDict.privateDict = privateDict;
  24193. }
  24194. parsePrivateDict(parentDict) {
  24195. if (!parentDict.hasName("Private")) {
  24196. this.emptyPrivateDictionary(parentDict);
  24197. return;
  24198. }
  24199. const privateOffset = parentDict.getByName("Private");
  24200. if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
  24201. parentDict.removeByName("Private");
  24202. return;
  24203. }
  24204. const size = privateOffset[0];
  24205. const offset = privateOffset[1];
  24206. if (size === 0 || offset >= this.bytes.length) {
  24207. this.emptyPrivateDictionary(parentDict);
  24208. return;
  24209. }
  24210. const privateDictEnd = offset + size;
  24211. const dictData = this.bytes.subarray(offset, privateDictEnd);
  24212. const dict = this.parseDict(dictData);
  24213. const privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  24214. parentDict.privateDict = privateDict;
  24215. if (privateDict.getByName("ExpansionFactor") === 0) {
  24216. privateDict.setByName("ExpansionFactor", 0.06);
  24217. }
  24218. if (!privateDict.getByName("Subrs")) {
  24219. return;
  24220. }
  24221. const subrsOffset = privateDict.getByName("Subrs");
  24222. const relativeOffset = offset + subrsOffset;
  24223. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  24224. this.emptyPrivateDictionary(parentDict);
  24225. return;
  24226. }
  24227. const subrsIndex = this.parseIndex(relativeOffset);
  24228. privateDict.subrsIndex = subrsIndex.obj;
  24229. }
  24230. parseCharsets(pos, length, strings, cid) {
  24231. if (pos === 0) {
  24232. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
  24233. } else if (pos === 1) {
  24234. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);
  24235. } else if (pos === 2) {
  24236. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
  24237. }
  24238. const bytes = this.bytes;
  24239. const start = pos;
  24240. const format = bytes[pos++];
  24241. const charset = [cid ? 0 : ".notdef"];
  24242. let id, count, i;
  24243. length -= 1;
  24244. switch (format) {
  24245. case 0:
  24246. for (i = 0; i < length; i++) {
  24247. id = bytes[pos++] << 8 | bytes[pos++];
  24248. charset.push(cid ? id : strings.get(id));
  24249. }
  24250. break;
  24251. case 1:
  24252. while (charset.length <= length) {
  24253. id = bytes[pos++] << 8 | bytes[pos++];
  24254. count = bytes[pos++];
  24255. for (i = 0; i <= count; i++) {
  24256. charset.push(cid ? id++ : strings.get(id++));
  24257. }
  24258. }
  24259. break;
  24260. case 2:
  24261. while (charset.length <= length) {
  24262. id = bytes[pos++] << 8 | bytes[pos++];
  24263. count = bytes[pos++] << 8 | bytes[pos++];
  24264. for (i = 0; i <= count; i++) {
  24265. charset.push(cid ? id++ : strings.get(id++));
  24266. }
  24267. }
  24268. break;
  24269. default:
  24270. throw new _util.FormatError("Unknown charset format");
  24271. }
  24272. const end = pos;
  24273. const raw = bytes.subarray(start, end);
  24274. return new CFFCharset(false, format, charset, raw);
  24275. }
  24276. parseEncoding(pos, properties, strings, charset) {
  24277. const encoding = Object.create(null);
  24278. const bytes = this.bytes;
  24279. let predefined = false;
  24280. let format, i, ii;
  24281. let raw = null;
  24282. function readSupplement() {
  24283. const supplementsCount = bytes[pos++];
  24284. for (i = 0; i < supplementsCount; i++) {
  24285. const code = bytes[pos++];
  24286. const sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  24287. encoding[code] = charset.indexOf(strings.get(sid));
  24288. }
  24289. }
  24290. if (pos === 0 || pos === 1) {
  24291. predefined = true;
  24292. format = pos;
  24293. const baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
  24294. for (i = 0, ii = charset.length; i < ii; i++) {
  24295. const index = baseEncoding.indexOf(charset[i]);
  24296. if (index !== -1) {
  24297. encoding[index] = i;
  24298. }
  24299. }
  24300. } else {
  24301. const dataStart = pos;
  24302. format = bytes[pos++];
  24303. switch (format & 0x7f) {
  24304. case 0:
  24305. const glyphsCount = bytes[pos++];
  24306. for (i = 1; i <= glyphsCount; i++) {
  24307. encoding[bytes[pos++]] = i;
  24308. }
  24309. break;
  24310. case 1:
  24311. const rangesCount = bytes[pos++];
  24312. let gid = 1;
  24313. for (i = 0; i < rangesCount; i++) {
  24314. const start = bytes[pos++];
  24315. const left = bytes[pos++];
  24316. for (let j = start; j <= start + left; j++) {
  24317. encoding[j] = gid++;
  24318. }
  24319. }
  24320. break;
  24321. default:
  24322. throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
  24323. }
  24324. const dataEnd = pos;
  24325. if (format & 0x80) {
  24326. bytes[dataStart] &= 0x7f;
  24327. readSupplement();
  24328. }
  24329. raw = bytes.subarray(dataStart, dataEnd);
  24330. }
  24331. format &= 0x7f;
  24332. return new CFFEncoding(predefined, format, encoding, raw);
  24333. }
  24334. parseFDSelect(pos, length) {
  24335. const bytes = this.bytes;
  24336. const format = bytes[pos++];
  24337. const fdSelect = [];
  24338. let i;
  24339. switch (format) {
  24340. case 0:
  24341. for (i = 0; i < length; ++i) {
  24342. const id = bytes[pos++];
  24343. fdSelect.push(id);
  24344. }
  24345. break;
  24346. case 3:
  24347. const rangesCount = bytes[pos++] << 8 | bytes[pos++];
  24348. for (i = 0; i < rangesCount; ++i) {
  24349. let first = bytes[pos++] << 8 | bytes[pos++];
  24350. if (i === 0 && first !== 0) {
  24351. (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
  24352. first = 0;
  24353. }
  24354. const fdIndex = bytes[pos++];
  24355. const next = bytes[pos] << 8 | bytes[pos + 1];
  24356. for (let j = first; j < next; ++j) {
  24357. fdSelect.push(fdIndex);
  24358. }
  24359. }
  24360. pos += 2;
  24361. break;
  24362. default:
  24363. throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
  24364. }
  24365. if (fdSelect.length !== length) {
  24366. throw new _util.FormatError("parseFDSelect: Invalid font data.");
  24367. }
  24368. return new CFFFDSelect(format, fdSelect);
  24369. }
  24370. }
  24371. exports.CFFParser = CFFParser;
  24372. class CFF {
  24373. constructor() {
  24374. this.header = null;
  24375. this.names = [];
  24376. this.topDict = null;
  24377. this.strings = new CFFStrings();
  24378. this.globalSubrIndex = null;
  24379. this.encoding = null;
  24380. this.charset = null;
  24381. this.charStrings = null;
  24382. this.fdArray = [];
  24383. this.fdSelect = null;
  24384. this.isCIDFont = false;
  24385. }
  24386. duplicateFirstGlyph() {
  24387. if (this.charStrings.count >= 65535) {
  24388. (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
  24389. return;
  24390. }
  24391. const glyphZero = this.charStrings.get(0);
  24392. this.charStrings.add(glyphZero);
  24393. if (this.isCIDFont) {
  24394. this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
  24395. }
  24396. }
  24397. hasGlyphId(id) {
  24398. if (id < 0 || id >= this.charStrings.count) {
  24399. return false;
  24400. }
  24401. const glyph = this.charStrings.get(id);
  24402. return glyph.length > 0;
  24403. }
  24404. }
  24405. exports.CFF = CFF;
  24406. class CFFHeader {
  24407. constructor(major, minor, hdrSize, offSize) {
  24408. this.major = major;
  24409. this.minor = minor;
  24410. this.hdrSize = hdrSize;
  24411. this.offSize = offSize;
  24412. }
  24413. }
  24414. exports.CFFHeader = CFFHeader;
  24415. class CFFStrings {
  24416. constructor() {
  24417. this.strings = [];
  24418. }
  24419. get(index) {
  24420. if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
  24421. return CFFStandardStrings[index];
  24422. }
  24423. if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
  24424. return this.strings[index - NUM_STANDARD_CFF_STRINGS];
  24425. }
  24426. return CFFStandardStrings[0];
  24427. }
  24428. getSID(str) {
  24429. let index = CFFStandardStrings.indexOf(str);
  24430. if (index !== -1) {
  24431. return index;
  24432. }
  24433. index = this.strings.indexOf(str);
  24434. if (index !== -1) {
  24435. return index + NUM_STANDARD_CFF_STRINGS;
  24436. }
  24437. return -1;
  24438. }
  24439. add(value) {
  24440. this.strings.push(value);
  24441. }
  24442. get count() {
  24443. return this.strings.length;
  24444. }
  24445. }
  24446. exports.CFFStrings = CFFStrings;
  24447. class CFFIndex {
  24448. constructor() {
  24449. this.objects = [];
  24450. this.length = 0;
  24451. }
  24452. add(data) {
  24453. this.length += data.length;
  24454. this.objects.push(data);
  24455. }
  24456. set(index, data) {
  24457. this.length += data.length - this.objects[index].length;
  24458. this.objects[index] = data;
  24459. }
  24460. get(index) {
  24461. return this.objects[index];
  24462. }
  24463. get count() {
  24464. return this.objects.length;
  24465. }
  24466. }
  24467. exports.CFFIndex = CFFIndex;
  24468. class CFFDict {
  24469. constructor(tables, strings) {
  24470. this.keyToNameMap = tables.keyToNameMap;
  24471. this.nameToKeyMap = tables.nameToKeyMap;
  24472. this.defaults = tables.defaults;
  24473. this.types = tables.types;
  24474. this.opcodes = tables.opcodes;
  24475. this.order = tables.order;
  24476. this.strings = strings;
  24477. this.values = Object.create(null);
  24478. }
  24479. setByKey(key, value) {
  24480. if (!(key in this.keyToNameMap)) {
  24481. return false;
  24482. }
  24483. if (value.length === 0) {
  24484. return true;
  24485. }
  24486. for (const val of value) {
  24487. if (isNaN(val)) {
  24488. (0, _util.warn)(`Invalid CFFDict value: "${value}" for key "${key}".`);
  24489. return true;
  24490. }
  24491. }
  24492. const type = this.types[key];
  24493. if (type === "num" || type === "sid" || type === "offset") {
  24494. value = value[0];
  24495. }
  24496. this.values[key] = value;
  24497. return true;
  24498. }
  24499. setByName(name, value) {
  24500. if (!(name in this.nameToKeyMap)) {
  24501. throw new _util.FormatError(`Invalid dictionary name "${name}"`);
  24502. }
  24503. this.values[this.nameToKeyMap[name]] = value;
  24504. }
  24505. hasName(name) {
  24506. return this.nameToKeyMap[name] in this.values;
  24507. }
  24508. getByName(name) {
  24509. if (!(name in this.nameToKeyMap)) {
  24510. throw new _util.FormatError(`Invalid dictionary name ${name}"`);
  24511. }
  24512. const key = this.nameToKeyMap[name];
  24513. if (!(key in this.values)) {
  24514. return this.defaults[key];
  24515. }
  24516. return this.values[key];
  24517. }
  24518. removeByName(name) {
  24519. delete this.values[this.nameToKeyMap[name]];
  24520. }
  24521. static createTables(layout) {
  24522. const tables = {
  24523. keyToNameMap: {},
  24524. nameToKeyMap: {},
  24525. defaults: {},
  24526. types: {},
  24527. opcodes: {},
  24528. order: []
  24529. };
  24530. for (const entry of layout) {
  24531. const key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24532. tables.keyToNameMap[key] = entry[1];
  24533. tables.nameToKeyMap[entry[1]] = key;
  24534. tables.types[key] = entry[2];
  24535. tables.defaults[key] = entry[3];
  24536. tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
  24537. tables.order.push(key);
  24538. }
  24539. return tables;
  24540. }
  24541. }
  24542. const CFFTopDictLayout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
  24543. class CFFTopDict extends CFFDict {
  24544. static get tables() {
  24545. return (0, _util.shadow)(this, "tables", this.createTables(CFFTopDictLayout));
  24546. }
  24547. constructor(strings) {
  24548. super(CFFTopDict.tables, strings);
  24549. this.privateDict = null;
  24550. }
  24551. }
  24552. exports.CFFTopDict = CFFTopDict;
  24553. const CFFPrivateDictLayout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
  24554. class CFFPrivateDict extends CFFDict {
  24555. static get tables() {
  24556. return (0, _util.shadow)(this, "tables", this.createTables(CFFPrivateDictLayout));
  24557. }
  24558. constructor(strings) {
  24559. super(CFFPrivateDict.tables, strings);
  24560. this.subrsIndex = null;
  24561. }
  24562. }
  24563. exports.CFFPrivateDict = CFFPrivateDict;
  24564. const CFFCharsetPredefinedTypes = {
  24565. ISO_ADOBE: 0,
  24566. EXPERT: 1,
  24567. EXPERT_SUBSET: 2
  24568. };
  24569. class CFFCharset {
  24570. constructor(predefined, format, charset, raw) {
  24571. this.predefined = predefined;
  24572. this.format = format;
  24573. this.charset = charset;
  24574. this.raw = raw;
  24575. }
  24576. }
  24577. exports.CFFCharset = CFFCharset;
  24578. class CFFEncoding {
  24579. constructor(predefined, format, encoding, raw) {
  24580. this.predefined = predefined;
  24581. this.format = format;
  24582. this.encoding = encoding;
  24583. this.raw = raw;
  24584. }
  24585. }
  24586. class CFFFDSelect {
  24587. constructor(format, fdSelect) {
  24588. this.format = format;
  24589. this.fdSelect = fdSelect;
  24590. }
  24591. getFDIndex(glyphIndex) {
  24592. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24593. return -1;
  24594. }
  24595. return this.fdSelect[glyphIndex];
  24596. }
  24597. }
  24598. exports.CFFFDSelect = CFFFDSelect;
  24599. class CFFOffsetTracker {
  24600. constructor() {
  24601. this.offsets = Object.create(null);
  24602. }
  24603. isTracking(key) {
  24604. return key in this.offsets;
  24605. }
  24606. track(key, location) {
  24607. if (key in this.offsets) {
  24608. throw new _util.FormatError(`Already tracking location of ${key}`);
  24609. }
  24610. this.offsets[key] = location;
  24611. }
  24612. offset(value) {
  24613. for (const key in this.offsets) {
  24614. this.offsets[key] += value;
  24615. }
  24616. }
  24617. setEntryLocation(key, values, output) {
  24618. if (!(key in this.offsets)) {
  24619. throw new _util.FormatError(`Not tracking location of ${key}`);
  24620. }
  24621. const data = output.data;
  24622. const dataOffset = this.offsets[key];
  24623. const size = 5;
  24624. for (let i = 0, ii = values.length; i < ii; ++i) {
  24625. const offset0 = i * size + dataOffset;
  24626. const offset1 = offset0 + 1;
  24627. const offset2 = offset0 + 2;
  24628. const offset3 = offset0 + 3;
  24629. const offset4 = offset0 + 4;
  24630. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24631. throw new _util.FormatError("writing to an offset that is not empty");
  24632. }
  24633. const value = values[i];
  24634. data[offset0] = 0x1d;
  24635. data[offset1] = value >> 24 & 0xff;
  24636. data[offset2] = value >> 16 & 0xff;
  24637. data[offset3] = value >> 8 & 0xff;
  24638. data[offset4] = value & 0xff;
  24639. }
  24640. }
  24641. }
  24642. class CFFCompiler {
  24643. constructor(cff) {
  24644. this.cff = cff;
  24645. }
  24646. compile() {
  24647. const cff = this.cff;
  24648. const output = {
  24649. data: [],
  24650. length: 0,
  24651. add(data) {
  24652. try {
  24653. this.data.push(...data);
  24654. } catch {
  24655. this.data = this.data.concat(data);
  24656. }
  24657. this.length = this.data.length;
  24658. }
  24659. };
  24660. const header = this.compileHeader(cff.header);
  24661. output.add(header);
  24662. const nameIndex = this.compileNameIndex(cff.names);
  24663. output.add(nameIndex);
  24664. if (cff.isCIDFont) {
  24665. if (cff.topDict.hasName("FontMatrix")) {
  24666. const base = cff.topDict.getByName("FontMatrix");
  24667. cff.topDict.removeByName("FontMatrix");
  24668. for (const subDict of cff.fdArray) {
  24669. let matrix = base.slice(0);
  24670. if (subDict.hasName("FontMatrix")) {
  24671. matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
  24672. }
  24673. subDict.setByName("FontMatrix", matrix);
  24674. }
  24675. }
  24676. }
  24677. const xuid = cff.topDict.getByName("XUID");
  24678. if (xuid?.length > 16) {
  24679. cff.topDict.removeByName("XUID");
  24680. }
  24681. cff.topDict.setByName("charset", 0);
  24682. let compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24683. output.add(compiled.output);
  24684. const topDictTracker = compiled.trackers[0];
  24685. const stringIndex = this.compileStringIndex(cff.strings.strings);
  24686. output.add(stringIndex);
  24687. const globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24688. output.add(globalSubrIndex);
  24689. if (cff.encoding && cff.topDict.hasName("Encoding")) {
  24690. if (cff.encoding.predefined) {
  24691. topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
  24692. } else {
  24693. const encoding = this.compileEncoding(cff.encoding);
  24694. topDictTracker.setEntryLocation("Encoding", [output.length], output);
  24695. output.add(encoding);
  24696. }
  24697. }
  24698. const charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
  24699. topDictTracker.setEntryLocation("charset", [output.length], output);
  24700. output.add(charset);
  24701. const charStrings = this.compileCharStrings(cff.charStrings);
  24702. topDictTracker.setEntryLocation("CharStrings", [output.length], output);
  24703. output.add(charStrings);
  24704. if (cff.isCIDFont) {
  24705. topDictTracker.setEntryLocation("FDSelect", [output.length], output);
  24706. const fdSelect = this.compileFDSelect(cff.fdSelect);
  24707. output.add(fdSelect);
  24708. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24709. topDictTracker.setEntryLocation("FDArray", [output.length], output);
  24710. output.add(compiled.output);
  24711. const fontDictTrackers = compiled.trackers;
  24712. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24713. }
  24714. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24715. output.add([0]);
  24716. return output.data;
  24717. }
  24718. encodeNumber(value) {
  24719. if (Number.isInteger(value)) {
  24720. return this.encodeInteger(value);
  24721. }
  24722. return this.encodeFloat(value);
  24723. }
  24724. static get EncodeFloatRegExp() {
  24725. return (0, _util.shadow)(this, "EncodeFloatRegExp", /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/);
  24726. }
  24727. encodeFloat(num) {
  24728. let value = num.toString();
  24729. const m = CFFCompiler.EncodeFloatRegExp.exec(value);
  24730. if (m) {
  24731. const epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
  24732. value = (Math.round(num * epsilon) / epsilon).toString();
  24733. }
  24734. let nibbles = "";
  24735. let i, ii;
  24736. for (i = 0, ii = value.length; i < ii; ++i) {
  24737. const a = value[i];
  24738. if (a === "e") {
  24739. nibbles += value[++i] === "-" ? "c" : "b";
  24740. } else if (a === ".") {
  24741. nibbles += "a";
  24742. } else if (a === "-") {
  24743. nibbles += "e";
  24744. } else {
  24745. nibbles += a;
  24746. }
  24747. }
  24748. nibbles += nibbles.length & 1 ? "f" : "ff";
  24749. const out = [30];
  24750. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24751. out.push(parseInt(nibbles.substring(i, i + 2), 16));
  24752. }
  24753. return out;
  24754. }
  24755. encodeInteger(value) {
  24756. let code;
  24757. if (value >= -107 && value <= 107) {
  24758. code = [value + 139];
  24759. } else if (value >= 108 && value <= 1131) {
  24760. value -= 108;
  24761. code = [(value >> 8) + 247, value & 0xff];
  24762. } else if (value >= -1131 && value <= -108) {
  24763. value = -value - 108;
  24764. code = [(value >> 8) + 251, value & 0xff];
  24765. } else if (value >= -32768 && value <= 32767) {
  24766. code = [0x1c, value >> 8 & 0xff, value & 0xff];
  24767. } else {
  24768. code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
  24769. }
  24770. return code;
  24771. }
  24772. compileHeader(header) {
  24773. return [header.major, header.minor, 4, header.offSize];
  24774. }
  24775. compileNameIndex(names) {
  24776. const nameIndex = new CFFIndex();
  24777. for (const name of names) {
  24778. const length = Math.min(name.length, 127);
  24779. let sanitizedName = new Array(length);
  24780. for (let j = 0; j < length; j++) {
  24781. let char = name[j];
  24782. if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
  24783. char = "_";
  24784. }
  24785. sanitizedName[j] = char;
  24786. }
  24787. sanitizedName = sanitizedName.join("");
  24788. if (sanitizedName === "") {
  24789. sanitizedName = "Bad_Font_Name";
  24790. }
  24791. nameIndex.add((0, _util.stringToBytes)(sanitizedName));
  24792. }
  24793. return this.compileIndex(nameIndex);
  24794. }
  24795. compileTopDicts(dicts, length, removeCidKeys) {
  24796. const fontDictTrackers = [];
  24797. let fdArrayIndex = new CFFIndex();
  24798. for (const fontDict of dicts) {
  24799. if (removeCidKeys) {
  24800. fontDict.removeByName("CIDFontVersion");
  24801. fontDict.removeByName("CIDFontRevision");
  24802. fontDict.removeByName("CIDFontType");
  24803. fontDict.removeByName("CIDCount");
  24804. fontDict.removeByName("UIDBase");
  24805. }
  24806. const fontDictTracker = new CFFOffsetTracker();
  24807. const fontDictData = this.compileDict(fontDict, fontDictTracker);
  24808. fontDictTrackers.push(fontDictTracker);
  24809. fdArrayIndex.add(fontDictData);
  24810. fontDictTracker.offset(length);
  24811. }
  24812. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24813. return {
  24814. trackers: fontDictTrackers,
  24815. output: fdArrayIndex
  24816. };
  24817. }
  24818. compilePrivateDicts(dicts, trackers, output) {
  24819. for (let i = 0, ii = dicts.length; i < ii; ++i) {
  24820. const fontDict = dicts[i];
  24821. const privateDict = fontDict.privateDict;
  24822. if (!privateDict || !fontDict.hasName("Private")) {
  24823. throw new _util.FormatError("There must be a private dictionary.");
  24824. }
  24825. const privateDictTracker = new CFFOffsetTracker();
  24826. const privateDictData = this.compileDict(privateDict, privateDictTracker);
  24827. let outputLength = output.length;
  24828. privateDictTracker.offset(outputLength);
  24829. if (!privateDictData.length) {
  24830. outputLength = 0;
  24831. }
  24832. trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
  24833. output.add(privateDictData);
  24834. if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
  24835. const subrs = this.compileIndex(privateDict.subrsIndex);
  24836. privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
  24837. output.add(subrs);
  24838. }
  24839. }
  24840. }
  24841. compileDict(dict, offsetTracker) {
  24842. const out = [];
  24843. for (const key of dict.order) {
  24844. if (!(key in dict.values)) {
  24845. continue;
  24846. }
  24847. let values = dict.values[key];
  24848. let types = dict.types[key];
  24849. if (!Array.isArray(types)) {
  24850. types = [types];
  24851. }
  24852. if (!Array.isArray(values)) {
  24853. values = [values];
  24854. }
  24855. if (values.length === 0) {
  24856. continue;
  24857. }
  24858. for (let j = 0, jj = types.length; j < jj; ++j) {
  24859. const type = types[j];
  24860. const value = values[j];
  24861. switch (type) {
  24862. case "num":
  24863. case "sid":
  24864. out.push(...this.encodeNumber(value));
  24865. break;
  24866. case "offset":
  24867. const name = dict.keyToNameMap[key];
  24868. if (!offsetTracker.isTracking(name)) {
  24869. offsetTracker.track(name, out.length);
  24870. }
  24871. out.push(0x1d, 0, 0, 0, 0);
  24872. break;
  24873. case "array":
  24874. case "delta":
  24875. out.push(...this.encodeNumber(value));
  24876. for (let k = 1, kk = values.length; k < kk; ++k) {
  24877. out.push(...this.encodeNumber(values[k]));
  24878. }
  24879. break;
  24880. default:
  24881. throw new _util.FormatError(`Unknown data type of ${type}`);
  24882. }
  24883. }
  24884. out.push(...dict.opcodes[key]);
  24885. }
  24886. return out;
  24887. }
  24888. compileStringIndex(strings) {
  24889. const stringIndex = new CFFIndex();
  24890. for (const string of strings) {
  24891. stringIndex.add((0, _util.stringToBytes)(string));
  24892. }
  24893. return this.compileIndex(stringIndex);
  24894. }
  24895. compileCharStrings(charStrings) {
  24896. const charStringsIndex = new CFFIndex();
  24897. for (let i = 0; i < charStrings.count; i++) {
  24898. const glyph = charStrings.get(i);
  24899. if (glyph.length === 0) {
  24900. charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
  24901. continue;
  24902. }
  24903. charStringsIndex.add(glyph);
  24904. }
  24905. return this.compileIndex(charStringsIndex);
  24906. }
  24907. compileCharset(charset, numGlyphs, strings, isCIDFont) {
  24908. let out;
  24909. const numGlyphsLessNotDef = numGlyphs - 1;
  24910. if (isCIDFont) {
  24911. out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
  24912. } else {
  24913. const length = 1 + numGlyphsLessNotDef * 2;
  24914. out = new Uint8Array(length);
  24915. out[0] = 0;
  24916. let charsetIndex = 0;
  24917. const numCharsets = charset.charset.length;
  24918. let warned = false;
  24919. for (let i = 1; i < out.length; i += 2) {
  24920. let sid = 0;
  24921. if (charsetIndex < numCharsets) {
  24922. const name = charset.charset[charsetIndex++];
  24923. sid = strings.getSID(name);
  24924. if (sid === -1) {
  24925. sid = 0;
  24926. if (!warned) {
  24927. warned = true;
  24928. (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
  24929. }
  24930. }
  24931. }
  24932. out[i] = sid >> 8 & 0xff;
  24933. out[i + 1] = sid & 0xff;
  24934. }
  24935. }
  24936. return this.compileTypedArray(out);
  24937. }
  24938. compileEncoding(encoding) {
  24939. return this.compileTypedArray(encoding.raw);
  24940. }
  24941. compileFDSelect(fdSelect) {
  24942. const format = fdSelect.format;
  24943. let out, i;
  24944. switch (format) {
  24945. case 0:
  24946. out = new Uint8Array(1 + fdSelect.fdSelect.length);
  24947. out[0] = format;
  24948. for (i = 0; i < fdSelect.fdSelect.length; i++) {
  24949. out[i + 1] = fdSelect.fdSelect[i];
  24950. }
  24951. break;
  24952. case 3:
  24953. const start = 0;
  24954. let lastFD = fdSelect.fdSelect[0];
  24955. const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
  24956. for (i = 1; i < fdSelect.fdSelect.length; i++) {
  24957. const currentFD = fdSelect.fdSelect[i];
  24958. if (currentFD !== lastFD) {
  24959. ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
  24960. lastFD = currentFD;
  24961. }
  24962. }
  24963. const numRanges = (ranges.length - 3) / 3;
  24964. ranges[1] = numRanges >> 8 & 0xff;
  24965. ranges[2] = numRanges & 0xff;
  24966. ranges.push(i >> 8 & 0xff, i & 0xff);
  24967. out = new Uint8Array(ranges);
  24968. break;
  24969. }
  24970. return this.compileTypedArray(out);
  24971. }
  24972. compileTypedArray(data) {
  24973. return Array.from(data);
  24974. }
  24975. compileIndex(index, trackers = []) {
  24976. const objects = index.objects;
  24977. const count = objects.length;
  24978. if (count === 0) {
  24979. return [0, 0];
  24980. }
  24981. const data = [count >> 8 & 0xff, count & 0xff];
  24982. let lastOffset = 1,
  24983. i;
  24984. for (i = 0; i < count; ++i) {
  24985. lastOffset += objects[i].length;
  24986. }
  24987. let offsetSize;
  24988. if (lastOffset < 0x100) {
  24989. offsetSize = 1;
  24990. } else if (lastOffset < 0x10000) {
  24991. offsetSize = 2;
  24992. } else if (lastOffset < 0x1000000) {
  24993. offsetSize = 3;
  24994. } else {
  24995. offsetSize = 4;
  24996. }
  24997. data.push(offsetSize);
  24998. let relativeOffset = 1;
  24999. for (i = 0; i < count + 1; i++) {
  25000. if (offsetSize === 1) {
  25001. data.push(relativeOffset & 0xff);
  25002. } else if (offsetSize === 2) {
  25003. data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25004. } else if (offsetSize === 3) {
  25005. data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25006. } else {
  25007. data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25008. }
  25009. if (objects[i]) {
  25010. relativeOffset += objects[i].length;
  25011. }
  25012. }
  25013. for (i = 0; i < count; i++) {
  25014. if (trackers[i]) {
  25015. trackers[i].offset(data.length);
  25016. }
  25017. data.push(...objects[i]);
  25018. }
  25019. return data;
  25020. }
  25021. }
  25022. exports.CFFCompiler = CFFCompiler;
  25023. /***/ }),
  25024. /* 36 */
  25025. /***/ ((__unused_webpack_module, exports) => {
  25026. Object.defineProperty(exports, "__esModule", ({
  25027. value: true
  25028. }));
  25029. exports.ISOAdobeCharset = exports.ExpertSubsetCharset = exports.ExpertCharset = void 0;
  25030. const ISOAdobeCharset = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron"];
  25031. exports.ISOAdobeCharset = ISOAdobeCharset;
  25032. const ExpertCharset = [".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
  25033. exports.ExpertCharset = ExpertCharset;
  25034. const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperior", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior"];
  25035. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  25036. /***/ }),
  25037. /* 37 */
  25038. /***/ ((__unused_webpack_module, exports) => {
  25039. Object.defineProperty(exports, "__esModule", ({
  25040. value: true
  25041. }));
  25042. exports.ZapfDingbatsEncoding = exports.WinAnsiEncoding = exports.SymbolSetEncoding = exports.StandardEncoding = exports.MacRomanEncoding = exports.ExpertEncoding = void 0;
  25043. exports.getEncoding = getEncoding;
  25044. const ExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "", "", "", "isuperior", "", "", "lsuperior", "msuperior", "nsuperior", "osuperior", "", "", "rsuperior", "ssuperior", "tsuperior", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdownsmall", "centoldstyle", "Lslashsmall", "", "", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "", "Dotaccentsmall", "", "", "Macronsmall", "", "", "figuredash", "hypheninferior", "", "", "Ogoneksmall", "Ringsmall", "Cedillasmall", "", "", "", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
  25045. exports.ExpertEncoding = ExpertEncoding;
  25046. const MacExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "", "threequartersemdash", "", "questionsmall", "", "", "", "", "Ethsmall", "", "", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "", "", "", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hypheninferior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "asuperior", "centsuperior", "", "", "", "", "Aacutesmall", "Agravesmall", "Acircumflexsmall", "Adieresissmall", "Atildesmall", "Aringsmall", "Ccedillasmall", "Eacutesmall", "Egravesmall", "Ecircumflexsmall", "Edieresissmall", "Iacutesmall", "Igravesmall", "Icircumflexsmall", "Idieresissmall", "Ntildesmall", "Oacutesmall", "Ogravesmall", "Ocircumflexsmall", "Odieresissmall", "Otildesmall", "Uacutesmall", "Ugravesmall", "Ucircumflexsmall", "Udieresissmall", "", "eightsuperior", "fourinferior", "threeinferior", "sixinferior", "eightinferior", "seveninferior", "Scaronsmall", "", "centinferior", "twoinferior", "", "Dieresissmall", "", "Caronsmall", "osuperior", "fiveinferior", "", "commainferior", "periodinferior", "Yacutesmall", "", "dollarinferior", "", "", "Thornsmall", "", "nineinferior", "zeroinferior", "Zcaronsmall", "AEsmall", "Oslashsmall", "questiondownsmall", "oneinferior", "Lslashsmall", "", "", "", "", "", "", "Cedillasmall", "", "", "", "", "", "OEsmall", "figuredash", "hyphensuperior", "", "", "", "", "exclamdownsmall", "", "Ydieresissmall", "", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "ninesuperior", "zerosuperior", "", "esuperior", "rsuperior", "tsuperior", "", "", "isuperior", "ssuperior", "dsuperior", "", "", "", "", "", "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", "", "", "", ""];
  25047. const MacRomanEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "space", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron"];
  25048. exports.MacRomanEncoding = MacRomanEncoding;
  25049. const StandardEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "", "endash", "dagger", "daggerdbl", "periodcentered", "", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "", "questiondown", "", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "", "ring", "cedilla", "", "hungarumlaut", "ogonek", "caron", "emdash", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "AE", "", "ordfeminine", "", "", "", "", "Lslash", "Oslash", "OE", "ordmasculine", "", "", "", "", "", "ae", "", "", "", "dotlessi", "", "", "lslash", "oslash", "oe", "germandbls", "", "", "", ""];
  25050. exports.StandardEncoding = StandardEncoding;
  25051. const WinAnsiEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", "sterling", "currency", "yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered", "macron", "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu", "paragraph", "periodcentered", "cedilla", "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis"];
  25052. exports.WinAnsiEncoding = WinAnsiEncoding;
  25053. const SymbolSetEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "congruent", "Alpha", "Beta", "Chi", "Delta", "Epsilon", "Phi", "Gamma", "Eta", "Iota", "theta1", "Kappa", "Lambda", "Mu", "Nu", "Omicron", "Pi", "Theta", "Rho", "Sigma", "Tau", "Upsilon", "sigma1", "Omega", "Xi", "Psi", "Zeta", "bracketleft", "therefore", "bracketright", "perpendicular", "underscore", "radicalex", "alpha", "beta", "chi", "delta", "epsilon", "phi", "gamma", "eta", "iota", "phi1", "kappa", "lambda", "mu", "nu", "omicron", "pi", "theta", "rho", "sigma", "tau", "upsilon", "omega1", "omega", "xi", "psi", "zeta", "braceleft", "bar", "braceright", "similar", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Euro", "Upsilon1", "minute", "lessequal", "fraction", "infinity", "florin", "club", "diamond", "heart", "spade", "arrowboth", "arrowleft", "arrowup", "arrowright", "arrowdown", "degree", "plusminus", "second", "greaterequal", "multiply", "proportional", "partialdiff", "bullet", "divide", "notequal", "equivalence", "approxequal", "ellipsis", "arrowvertex", "arrowhorizex", "carriagereturn", "aleph", "Ifraktur", "Rfraktur", "weierstrass", "circlemultiply", "circleplus", "emptyset", "intersection", "union", "propersuperset", "reflexsuperset", "notsubset", "propersubset", "reflexsubset", "element", "notelement", "angle", "gradient", "registerserif", "copyrightserif", "trademarkserif", "product", "radical", "dotmath", "logicalnot", "logicaland", "logicalor", "arrowdblboth", "arrowdblleft", "arrowdblup", "arrowdblright", "arrowdbldown", "lozenge", "angleleft", "registersans", "copyrightsans", "trademarksans", "summation", "parenlefttp", "parenleftex", "parenleftbt", "bracketlefttp", "bracketleftex", "bracketleftbt", "bracelefttp", "braceleftmid", "braceleftbt", "braceex", "", "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", ""];
  25054. exports.SymbolSetEncoding = SymbolSetEncoding;
  25055. const ZapfDingbatsEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34", "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", "a84", "a97", "a98", "a99", "a100", "", "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85", "a206", "a86", "a87", "a88", "a95", "a96", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a101", "a102", "a103", "a104", "a106", "a107", "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147", "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170", "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182", "", "a201", "a183", "a184", "a197", "a185", "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", ""];
  25056. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  25057. function getEncoding(encodingName) {
  25058. switch (encodingName) {
  25059. case "WinAnsiEncoding":
  25060. return WinAnsiEncoding;
  25061. case "StandardEncoding":
  25062. return StandardEncoding;
  25063. case "MacRomanEncoding":
  25064. return MacRomanEncoding;
  25065. case "SymbolSetEncoding":
  25066. return SymbolSetEncoding;
  25067. case "ZapfDingbatsEncoding":
  25068. return ZapfDingbatsEncoding;
  25069. case "ExpertEncoding":
  25070. return ExpertEncoding;
  25071. case "MacExpertEncoding":
  25072. return MacExpertEncoding;
  25073. default:
  25074. return null;
  25075. }
  25076. }
  25077. /***/ }),
  25078. /* 38 */
  25079. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  25080. Object.defineProperty(exports, "__esModule", ({
  25081. value: true
  25082. }));
  25083. exports.SEAC_ANALYSIS_ENABLED = exports.MacStandardGlyphOrdering = exports.FontFlags = void 0;
  25084. exports.normalizeFontName = normalizeFontName;
  25085. exports.recoverGlyphName = recoverGlyphName;
  25086. exports.type1FontGlyphMapping = type1FontGlyphMapping;
  25087. var _encodings = __w_pdfjs_require__(37);
  25088. var _glyphlist = __w_pdfjs_require__(39);
  25089. var _unicode = __w_pdfjs_require__(40);
  25090. var _util = __w_pdfjs_require__(2);
  25091. const SEAC_ANALYSIS_ENABLED = true;
  25092. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  25093. const FontFlags = {
  25094. FixedPitch: 1,
  25095. Serif: 2,
  25096. Symbolic: 4,
  25097. Script: 8,
  25098. Nonsymbolic: 32,
  25099. Italic: 64,
  25100. AllCap: 65536,
  25101. SmallCap: 131072,
  25102. ForceBold: 262144
  25103. };
  25104. exports.FontFlags = FontFlags;
  25105. const MacStandardGlyphOrdering = [".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat"];
  25106. exports.MacStandardGlyphOrdering = MacStandardGlyphOrdering;
  25107. function recoverGlyphName(name, glyphsUnicodeMap) {
  25108. if (glyphsUnicodeMap[name] !== undefined) {
  25109. return name;
  25110. }
  25111. const unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
  25112. if (unicode !== -1) {
  25113. for (const key in glyphsUnicodeMap) {
  25114. if (glyphsUnicodeMap[key] === unicode) {
  25115. return key;
  25116. }
  25117. }
  25118. }
  25119. (0, _util.info)("Unable to recover a standard glyph name for: " + name);
  25120. return name;
  25121. }
  25122. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  25123. const charCodeToGlyphId = Object.create(null);
  25124. let glyphId, charCode, baseEncoding;
  25125. const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  25126. if (properties.isInternalFont) {
  25127. baseEncoding = builtInEncoding;
  25128. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  25129. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  25130. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  25131. }
  25132. } else if (properties.baseEncodingName) {
  25133. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  25134. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  25135. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  25136. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  25137. }
  25138. } else if (isSymbolicFont) {
  25139. for (charCode in builtInEncoding) {
  25140. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  25141. }
  25142. } else {
  25143. baseEncoding = _encodings.StandardEncoding;
  25144. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  25145. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  25146. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  25147. }
  25148. }
  25149. const differences = properties.differences;
  25150. let glyphsUnicodeMap;
  25151. if (differences) {
  25152. for (charCode in differences) {
  25153. const glyphName = differences[charCode];
  25154. glyphId = glyphNames.indexOf(glyphName);
  25155. if (glyphId === -1) {
  25156. if (!glyphsUnicodeMap) {
  25157. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  25158. }
  25159. const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  25160. if (standardGlyphName !== glyphName) {
  25161. glyphId = glyphNames.indexOf(standardGlyphName);
  25162. }
  25163. }
  25164. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  25165. }
  25166. }
  25167. return charCodeToGlyphId;
  25168. }
  25169. function normalizeFontName(name) {
  25170. return name.replaceAll(/[,_]/g, "-").replaceAll(/\s/g, "");
  25171. }
  25172. /***/ }),
  25173. /* 39 */
  25174. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  25175. Object.defineProperty(exports, "__esModule", ({
  25176. value: true
  25177. }));
  25178. exports.getGlyphsUnicode = exports.getDingbatsGlyphsUnicode = void 0;
  25179. var _core_utils = __w_pdfjs_require__(3);
  25180. const getGlyphsUnicode = (0, _core_utils.getLookupTableFactory)(function (t) {
  25181. t.A = 0x0041;
  25182. t.AE = 0x00c6;
  25183. t.AEacute = 0x01fc;
  25184. t.AEmacron = 0x01e2;
  25185. t.AEsmall = 0xf7e6;
  25186. t.Aacute = 0x00c1;
  25187. t.Aacutesmall = 0xf7e1;
  25188. t.Abreve = 0x0102;
  25189. t.Abreveacute = 0x1eae;
  25190. t.Abrevecyrillic = 0x04d0;
  25191. t.Abrevedotbelow = 0x1eb6;
  25192. t.Abrevegrave = 0x1eb0;
  25193. t.Abrevehookabove = 0x1eb2;
  25194. t.Abrevetilde = 0x1eb4;
  25195. t.Acaron = 0x01cd;
  25196. t.Acircle = 0x24b6;
  25197. t.Acircumflex = 0x00c2;
  25198. t.Acircumflexacute = 0x1ea4;
  25199. t.Acircumflexdotbelow = 0x1eac;
  25200. t.Acircumflexgrave = 0x1ea6;
  25201. t.Acircumflexhookabove = 0x1ea8;
  25202. t.Acircumflexsmall = 0xf7e2;
  25203. t.Acircumflextilde = 0x1eaa;
  25204. t.Acute = 0xf6c9;
  25205. t.Acutesmall = 0xf7b4;
  25206. t.Acyrillic = 0x0410;
  25207. t.Adblgrave = 0x0200;
  25208. t.Adieresis = 0x00c4;
  25209. t.Adieresiscyrillic = 0x04d2;
  25210. t.Adieresismacron = 0x01de;
  25211. t.Adieresissmall = 0xf7e4;
  25212. t.Adotbelow = 0x1ea0;
  25213. t.Adotmacron = 0x01e0;
  25214. t.Agrave = 0x00c0;
  25215. t.Agravesmall = 0xf7e0;
  25216. t.Ahookabove = 0x1ea2;
  25217. t.Aiecyrillic = 0x04d4;
  25218. t.Ainvertedbreve = 0x0202;
  25219. t.Alpha = 0x0391;
  25220. t.Alphatonos = 0x0386;
  25221. t.Amacron = 0x0100;
  25222. t.Amonospace = 0xff21;
  25223. t.Aogonek = 0x0104;
  25224. t.Aring = 0x00c5;
  25225. t.Aringacute = 0x01fa;
  25226. t.Aringbelow = 0x1e00;
  25227. t.Aringsmall = 0xf7e5;
  25228. t.Asmall = 0xf761;
  25229. t.Atilde = 0x00c3;
  25230. t.Atildesmall = 0xf7e3;
  25231. t.Aybarmenian = 0x0531;
  25232. t.B = 0x0042;
  25233. t.Bcircle = 0x24b7;
  25234. t.Bdotaccent = 0x1e02;
  25235. t.Bdotbelow = 0x1e04;
  25236. t.Becyrillic = 0x0411;
  25237. t.Benarmenian = 0x0532;
  25238. t.Beta = 0x0392;
  25239. t.Bhook = 0x0181;
  25240. t.Blinebelow = 0x1e06;
  25241. t.Bmonospace = 0xff22;
  25242. t.Brevesmall = 0xf6f4;
  25243. t.Bsmall = 0xf762;
  25244. t.Btopbar = 0x0182;
  25245. t.C = 0x0043;
  25246. t.Caarmenian = 0x053e;
  25247. t.Cacute = 0x0106;
  25248. t.Caron = 0xf6ca;
  25249. t.Caronsmall = 0xf6f5;
  25250. t.Ccaron = 0x010c;
  25251. t.Ccedilla = 0x00c7;
  25252. t.Ccedillaacute = 0x1e08;
  25253. t.Ccedillasmall = 0xf7e7;
  25254. t.Ccircle = 0x24b8;
  25255. t.Ccircumflex = 0x0108;
  25256. t.Cdot = 0x010a;
  25257. t.Cdotaccent = 0x010a;
  25258. t.Cedillasmall = 0xf7b8;
  25259. t.Chaarmenian = 0x0549;
  25260. t.Cheabkhasiancyrillic = 0x04bc;
  25261. t.Checyrillic = 0x0427;
  25262. t.Chedescenderabkhasiancyrillic = 0x04be;
  25263. t.Chedescendercyrillic = 0x04b6;
  25264. t.Chedieresiscyrillic = 0x04f4;
  25265. t.Cheharmenian = 0x0543;
  25266. t.Chekhakassiancyrillic = 0x04cb;
  25267. t.Cheverticalstrokecyrillic = 0x04b8;
  25268. t.Chi = 0x03a7;
  25269. t.Chook = 0x0187;
  25270. t.Circumflexsmall = 0xf6f6;
  25271. t.Cmonospace = 0xff23;
  25272. t.Coarmenian = 0x0551;
  25273. t.Csmall = 0xf763;
  25274. t.D = 0x0044;
  25275. t.DZ = 0x01f1;
  25276. t.DZcaron = 0x01c4;
  25277. t.Daarmenian = 0x0534;
  25278. t.Dafrican = 0x0189;
  25279. t.Dcaron = 0x010e;
  25280. t.Dcedilla = 0x1e10;
  25281. t.Dcircle = 0x24b9;
  25282. t.Dcircumflexbelow = 0x1e12;
  25283. t.Dcroat = 0x0110;
  25284. t.Ddotaccent = 0x1e0a;
  25285. t.Ddotbelow = 0x1e0c;
  25286. t.Decyrillic = 0x0414;
  25287. t.Deicoptic = 0x03ee;
  25288. t.Delta = 0x2206;
  25289. t.Deltagreek = 0x0394;
  25290. t.Dhook = 0x018a;
  25291. t.Dieresis = 0xf6cb;
  25292. t.DieresisAcute = 0xf6cc;
  25293. t.DieresisGrave = 0xf6cd;
  25294. t.Dieresissmall = 0xf7a8;
  25295. t.Digammagreek = 0x03dc;
  25296. t.Djecyrillic = 0x0402;
  25297. t.Dlinebelow = 0x1e0e;
  25298. t.Dmonospace = 0xff24;
  25299. t.Dotaccentsmall = 0xf6f7;
  25300. t.Dslash = 0x0110;
  25301. t.Dsmall = 0xf764;
  25302. t.Dtopbar = 0x018b;
  25303. t.Dz = 0x01f2;
  25304. t.Dzcaron = 0x01c5;
  25305. t.Dzeabkhasiancyrillic = 0x04e0;
  25306. t.Dzecyrillic = 0x0405;
  25307. t.Dzhecyrillic = 0x040f;
  25308. t.E = 0x0045;
  25309. t.Eacute = 0x00c9;
  25310. t.Eacutesmall = 0xf7e9;
  25311. t.Ebreve = 0x0114;
  25312. t.Ecaron = 0x011a;
  25313. t.Ecedillabreve = 0x1e1c;
  25314. t.Echarmenian = 0x0535;
  25315. t.Ecircle = 0x24ba;
  25316. t.Ecircumflex = 0x00ca;
  25317. t.Ecircumflexacute = 0x1ebe;
  25318. t.Ecircumflexbelow = 0x1e18;
  25319. t.Ecircumflexdotbelow = 0x1ec6;
  25320. t.Ecircumflexgrave = 0x1ec0;
  25321. t.Ecircumflexhookabove = 0x1ec2;
  25322. t.Ecircumflexsmall = 0xf7ea;
  25323. t.Ecircumflextilde = 0x1ec4;
  25324. t.Ecyrillic = 0x0404;
  25325. t.Edblgrave = 0x0204;
  25326. t.Edieresis = 0x00cb;
  25327. t.Edieresissmall = 0xf7eb;
  25328. t.Edot = 0x0116;
  25329. t.Edotaccent = 0x0116;
  25330. t.Edotbelow = 0x1eb8;
  25331. t.Efcyrillic = 0x0424;
  25332. t.Egrave = 0x00c8;
  25333. t.Egravesmall = 0xf7e8;
  25334. t.Eharmenian = 0x0537;
  25335. t.Ehookabove = 0x1eba;
  25336. t.Eightroman = 0x2167;
  25337. t.Einvertedbreve = 0x0206;
  25338. t.Eiotifiedcyrillic = 0x0464;
  25339. t.Elcyrillic = 0x041b;
  25340. t.Elevenroman = 0x216a;
  25341. t.Emacron = 0x0112;
  25342. t.Emacronacute = 0x1e16;
  25343. t.Emacrongrave = 0x1e14;
  25344. t.Emcyrillic = 0x041c;
  25345. t.Emonospace = 0xff25;
  25346. t.Encyrillic = 0x041d;
  25347. t.Endescendercyrillic = 0x04a2;
  25348. t.Eng = 0x014a;
  25349. t.Enghecyrillic = 0x04a4;
  25350. t.Enhookcyrillic = 0x04c7;
  25351. t.Eogonek = 0x0118;
  25352. t.Eopen = 0x0190;
  25353. t.Epsilon = 0x0395;
  25354. t.Epsilontonos = 0x0388;
  25355. t.Ercyrillic = 0x0420;
  25356. t.Ereversed = 0x018e;
  25357. t.Ereversedcyrillic = 0x042d;
  25358. t.Escyrillic = 0x0421;
  25359. t.Esdescendercyrillic = 0x04aa;
  25360. t.Esh = 0x01a9;
  25361. t.Esmall = 0xf765;
  25362. t.Eta = 0x0397;
  25363. t.Etarmenian = 0x0538;
  25364. t.Etatonos = 0x0389;
  25365. t.Eth = 0x00d0;
  25366. t.Ethsmall = 0xf7f0;
  25367. t.Etilde = 0x1ebc;
  25368. t.Etildebelow = 0x1e1a;
  25369. t.Euro = 0x20ac;
  25370. t.Ezh = 0x01b7;
  25371. t.Ezhcaron = 0x01ee;
  25372. t.Ezhreversed = 0x01b8;
  25373. t.F = 0x0046;
  25374. t.Fcircle = 0x24bb;
  25375. t.Fdotaccent = 0x1e1e;
  25376. t.Feharmenian = 0x0556;
  25377. t.Feicoptic = 0x03e4;
  25378. t.Fhook = 0x0191;
  25379. t.Fitacyrillic = 0x0472;
  25380. t.Fiveroman = 0x2164;
  25381. t.Fmonospace = 0xff26;
  25382. t.Fourroman = 0x2163;
  25383. t.Fsmall = 0xf766;
  25384. t.G = 0x0047;
  25385. t.GBsquare = 0x3387;
  25386. t.Gacute = 0x01f4;
  25387. t.Gamma = 0x0393;
  25388. t.Gammaafrican = 0x0194;
  25389. t.Gangiacoptic = 0x03ea;
  25390. t.Gbreve = 0x011e;
  25391. t.Gcaron = 0x01e6;
  25392. t.Gcedilla = 0x0122;
  25393. t.Gcircle = 0x24bc;
  25394. t.Gcircumflex = 0x011c;
  25395. t.Gcommaaccent = 0x0122;
  25396. t.Gdot = 0x0120;
  25397. t.Gdotaccent = 0x0120;
  25398. t.Gecyrillic = 0x0413;
  25399. t.Ghadarmenian = 0x0542;
  25400. t.Ghemiddlehookcyrillic = 0x0494;
  25401. t.Ghestrokecyrillic = 0x0492;
  25402. t.Gheupturncyrillic = 0x0490;
  25403. t.Ghook = 0x0193;
  25404. t.Gimarmenian = 0x0533;
  25405. t.Gjecyrillic = 0x0403;
  25406. t.Gmacron = 0x1e20;
  25407. t.Gmonospace = 0xff27;
  25408. t.Grave = 0xf6ce;
  25409. t.Gravesmall = 0xf760;
  25410. t.Gsmall = 0xf767;
  25411. t.Gsmallhook = 0x029b;
  25412. t.Gstroke = 0x01e4;
  25413. t.H = 0x0048;
  25414. t.H18533 = 0x25cf;
  25415. t.H18543 = 0x25aa;
  25416. t.H18551 = 0x25ab;
  25417. t.H22073 = 0x25a1;
  25418. t.HPsquare = 0x33cb;
  25419. t.Haabkhasiancyrillic = 0x04a8;
  25420. t.Hadescendercyrillic = 0x04b2;
  25421. t.Hardsigncyrillic = 0x042a;
  25422. t.Hbar = 0x0126;
  25423. t.Hbrevebelow = 0x1e2a;
  25424. t.Hcedilla = 0x1e28;
  25425. t.Hcircle = 0x24bd;
  25426. t.Hcircumflex = 0x0124;
  25427. t.Hdieresis = 0x1e26;
  25428. t.Hdotaccent = 0x1e22;
  25429. t.Hdotbelow = 0x1e24;
  25430. t.Hmonospace = 0xff28;
  25431. t.Hoarmenian = 0x0540;
  25432. t.Horicoptic = 0x03e8;
  25433. t.Hsmall = 0xf768;
  25434. t.Hungarumlaut = 0xf6cf;
  25435. t.Hungarumlautsmall = 0xf6f8;
  25436. t.Hzsquare = 0x3390;
  25437. t.I = 0x0049;
  25438. t.IAcyrillic = 0x042f;
  25439. t.IJ = 0x0132;
  25440. t.IUcyrillic = 0x042e;
  25441. t.Iacute = 0x00cd;
  25442. t.Iacutesmall = 0xf7ed;
  25443. t.Ibreve = 0x012c;
  25444. t.Icaron = 0x01cf;
  25445. t.Icircle = 0x24be;
  25446. t.Icircumflex = 0x00ce;
  25447. t.Icircumflexsmall = 0xf7ee;
  25448. t.Icyrillic = 0x0406;
  25449. t.Idblgrave = 0x0208;
  25450. t.Idieresis = 0x00cf;
  25451. t.Idieresisacute = 0x1e2e;
  25452. t.Idieresiscyrillic = 0x04e4;
  25453. t.Idieresissmall = 0xf7ef;
  25454. t.Idot = 0x0130;
  25455. t.Idotaccent = 0x0130;
  25456. t.Idotbelow = 0x1eca;
  25457. t.Iebrevecyrillic = 0x04d6;
  25458. t.Iecyrillic = 0x0415;
  25459. t.Ifraktur = 0x2111;
  25460. t.Igrave = 0x00cc;
  25461. t.Igravesmall = 0xf7ec;
  25462. t.Ihookabove = 0x1ec8;
  25463. t.Iicyrillic = 0x0418;
  25464. t.Iinvertedbreve = 0x020a;
  25465. t.Iishortcyrillic = 0x0419;
  25466. t.Imacron = 0x012a;
  25467. t.Imacroncyrillic = 0x04e2;
  25468. t.Imonospace = 0xff29;
  25469. t.Iniarmenian = 0x053b;
  25470. t.Iocyrillic = 0x0401;
  25471. t.Iogonek = 0x012e;
  25472. t.Iota = 0x0399;
  25473. t.Iotaafrican = 0x0196;
  25474. t.Iotadieresis = 0x03aa;
  25475. t.Iotatonos = 0x038a;
  25476. t.Ismall = 0xf769;
  25477. t.Istroke = 0x0197;
  25478. t.Itilde = 0x0128;
  25479. t.Itildebelow = 0x1e2c;
  25480. t.Izhitsacyrillic = 0x0474;
  25481. t.Izhitsadblgravecyrillic = 0x0476;
  25482. t.J = 0x004a;
  25483. t.Jaarmenian = 0x0541;
  25484. t.Jcircle = 0x24bf;
  25485. t.Jcircumflex = 0x0134;
  25486. t.Jecyrillic = 0x0408;
  25487. t.Jheharmenian = 0x054b;
  25488. t.Jmonospace = 0xff2a;
  25489. t.Jsmall = 0xf76a;
  25490. t.K = 0x004b;
  25491. t.KBsquare = 0x3385;
  25492. t.KKsquare = 0x33cd;
  25493. t.Kabashkircyrillic = 0x04a0;
  25494. t.Kacute = 0x1e30;
  25495. t.Kacyrillic = 0x041a;
  25496. t.Kadescendercyrillic = 0x049a;
  25497. t.Kahookcyrillic = 0x04c3;
  25498. t.Kappa = 0x039a;
  25499. t.Kastrokecyrillic = 0x049e;
  25500. t.Kaverticalstrokecyrillic = 0x049c;
  25501. t.Kcaron = 0x01e8;
  25502. t.Kcedilla = 0x0136;
  25503. t.Kcircle = 0x24c0;
  25504. t.Kcommaaccent = 0x0136;
  25505. t.Kdotbelow = 0x1e32;
  25506. t.Keharmenian = 0x0554;
  25507. t.Kenarmenian = 0x053f;
  25508. t.Khacyrillic = 0x0425;
  25509. t.Kheicoptic = 0x03e6;
  25510. t.Khook = 0x0198;
  25511. t.Kjecyrillic = 0x040c;
  25512. t.Klinebelow = 0x1e34;
  25513. t.Kmonospace = 0xff2b;
  25514. t.Koppacyrillic = 0x0480;
  25515. t.Koppagreek = 0x03de;
  25516. t.Ksicyrillic = 0x046e;
  25517. t.Ksmall = 0xf76b;
  25518. t.L = 0x004c;
  25519. t.LJ = 0x01c7;
  25520. t.LL = 0xf6bf;
  25521. t.Lacute = 0x0139;
  25522. t.Lambda = 0x039b;
  25523. t.Lcaron = 0x013d;
  25524. t.Lcedilla = 0x013b;
  25525. t.Lcircle = 0x24c1;
  25526. t.Lcircumflexbelow = 0x1e3c;
  25527. t.Lcommaaccent = 0x013b;
  25528. t.Ldot = 0x013f;
  25529. t.Ldotaccent = 0x013f;
  25530. t.Ldotbelow = 0x1e36;
  25531. t.Ldotbelowmacron = 0x1e38;
  25532. t.Liwnarmenian = 0x053c;
  25533. t.Lj = 0x01c8;
  25534. t.Ljecyrillic = 0x0409;
  25535. t.Llinebelow = 0x1e3a;
  25536. t.Lmonospace = 0xff2c;
  25537. t.Lslash = 0x0141;
  25538. t.Lslashsmall = 0xf6f9;
  25539. t.Lsmall = 0xf76c;
  25540. t.M = 0x004d;
  25541. t.MBsquare = 0x3386;
  25542. t.Macron = 0xf6d0;
  25543. t.Macronsmall = 0xf7af;
  25544. t.Macute = 0x1e3e;
  25545. t.Mcircle = 0x24c2;
  25546. t.Mdotaccent = 0x1e40;
  25547. t.Mdotbelow = 0x1e42;
  25548. t.Menarmenian = 0x0544;
  25549. t.Mmonospace = 0xff2d;
  25550. t.Msmall = 0xf76d;
  25551. t.Mturned = 0x019c;
  25552. t.Mu = 0x039c;
  25553. t.N = 0x004e;
  25554. t.NJ = 0x01ca;
  25555. t.Nacute = 0x0143;
  25556. t.Ncaron = 0x0147;
  25557. t.Ncedilla = 0x0145;
  25558. t.Ncircle = 0x24c3;
  25559. t.Ncircumflexbelow = 0x1e4a;
  25560. t.Ncommaaccent = 0x0145;
  25561. t.Ndotaccent = 0x1e44;
  25562. t.Ndotbelow = 0x1e46;
  25563. t.Nhookleft = 0x019d;
  25564. t.Nineroman = 0x2168;
  25565. t.Nj = 0x01cb;
  25566. t.Njecyrillic = 0x040a;
  25567. t.Nlinebelow = 0x1e48;
  25568. t.Nmonospace = 0xff2e;
  25569. t.Nowarmenian = 0x0546;
  25570. t.Nsmall = 0xf76e;
  25571. t.Ntilde = 0x00d1;
  25572. t.Ntildesmall = 0xf7f1;
  25573. t.Nu = 0x039d;
  25574. t.O = 0x004f;
  25575. t.OE = 0x0152;
  25576. t.OEsmall = 0xf6fa;
  25577. t.Oacute = 0x00d3;
  25578. t.Oacutesmall = 0xf7f3;
  25579. t.Obarredcyrillic = 0x04e8;
  25580. t.Obarreddieresiscyrillic = 0x04ea;
  25581. t.Obreve = 0x014e;
  25582. t.Ocaron = 0x01d1;
  25583. t.Ocenteredtilde = 0x019f;
  25584. t.Ocircle = 0x24c4;
  25585. t.Ocircumflex = 0x00d4;
  25586. t.Ocircumflexacute = 0x1ed0;
  25587. t.Ocircumflexdotbelow = 0x1ed8;
  25588. t.Ocircumflexgrave = 0x1ed2;
  25589. t.Ocircumflexhookabove = 0x1ed4;
  25590. t.Ocircumflexsmall = 0xf7f4;
  25591. t.Ocircumflextilde = 0x1ed6;
  25592. t.Ocyrillic = 0x041e;
  25593. t.Odblacute = 0x0150;
  25594. t.Odblgrave = 0x020c;
  25595. t.Odieresis = 0x00d6;
  25596. t.Odieresiscyrillic = 0x04e6;
  25597. t.Odieresissmall = 0xf7f6;
  25598. t.Odotbelow = 0x1ecc;
  25599. t.Ogoneksmall = 0xf6fb;
  25600. t.Ograve = 0x00d2;
  25601. t.Ogravesmall = 0xf7f2;
  25602. t.Oharmenian = 0x0555;
  25603. t.Ohm = 0x2126;
  25604. t.Ohookabove = 0x1ece;
  25605. t.Ohorn = 0x01a0;
  25606. t.Ohornacute = 0x1eda;
  25607. t.Ohorndotbelow = 0x1ee2;
  25608. t.Ohorngrave = 0x1edc;
  25609. t.Ohornhookabove = 0x1ede;
  25610. t.Ohorntilde = 0x1ee0;
  25611. t.Ohungarumlaut = 0x0150;
  25612. t.Oi = 0x01a2;
  25613. t.Oinvertedbreve = 0x020e;
  25614. t.Omacron = 0x014c;
  25615. t.Omacronacute = 0x1e52;
  25616. t.Omacrongrave = 0x1e50;
  25617. t.Omega = 0x2126;
  25618. t.Omegacyrillic = 0x0460;
  25619. t.Omegagreek = 0x03a9;
  25620. t.Omegaroundcyrillic = 0x047a;
  25621. t.Omegatitlocyrillic = 0x047c;
  25622. t.Omegatonos = 0x038f;
  25623. t.Omicron = 0x039f;
  25624. t.Omicrontonos = 0x038c;
  25625. t.Omonospace = 0xff2f;
  25626. t.Oneroman = 0x2160;
  25627. t.Oogonek = 0x01ea;
  25628. t.Oogonekmacron = 0x01ec;
  25629. t.Oopen = 0x0186;
  25630. t.Oslash = 0x00d8;
  25631. t.Oslashacute = 0x01fe;
  25632. t.Oslashsmall = 0xf7f8;
  25633. t.Osmall = 0xf76f;
  25634. t.Ostrokeacute = 0x01fe;
  25635. t.Otcyrillic = 0x047e;
  25636. t.Otilde = 0x00d5;
  25637. t.Otildeacute = 0x1e4c;
  25638. t.Otildedieresis = 0x1e4e;
  25639. t.Otildesmall = 0xf7f5;
  25640. t.P = 0x0050;
  25641. t.Pacute = 0x1e54;
  25642. t.Pcircle = 0x24c5;
  25643. t.Pdotaccent = 0x1e56;
  25644. t.Pecyrillic = 0x041f;
  25645. t.Peharmenian = 0x054a;
  25646. t.Pemiddlehookcyrillic = 0x04a6;
  25647. t.Phi = 0x03a6;
  25648. t.Phook = 0x01a4;
  25649. t.Pi = 0x03a0;
  25650. t.Piwrarmenian = 0x0553;
  25651. t.Pmonospace = 0xff30;
  25652. t.Psi = 0x03a8;
  25653. t.Psicyrillic = 0x0470;
  25654. t.Psmall = 0xf770;
  25655. t.Q = 0x0051;
  25656. t.Qcircle = 0x24c6;
  25657. t.Qmonospace = 0xff31;
  25658. t.Qsmall = 0xf771;
  25659. t.R = 0x0052;
  25660. t.Raarmenian = 0x054c;
  25661. t.Racute = 0x0154;
  25662. t.Rcaron = 0x0158;
  25663. t.Rcedilla = 0x0156;
  25664. t.Rcircle = 0x24c7;
  25665. t.Rcommaaccent = 0x0156;
  25666. t.Rdblgrave = 0x0210;
  25667. t.Rdotaccent = 0x1e58;
  25668. t.Rdotbelow = 0x1e5a;
  25669. t.Rdotbelowmacron = 0x1e5c;
  25670. t.Reharmenian = 0x0550;
  25671. t.Rfraktur = 0x211c;
  25672. t.Rho = 0x03a1;
  25673. t.Ringsmall = 0xf6fc;
  25674. t.Rinvertedbreve = 0x0212;
  25675. t.Rlinebelow = 0x1e5e;
  25676. t.Rmonospace = 0xff32;
  25677. t.Rsmall = 0xf772;
  25678. t.Rsmallinverted = 0x0281;
  25679. t.Rsmallinvertedsuperior = 0x02b6;
  25680. t.S = 0x0053;
  25681. t.SF010000 = 0x250c;
  25682. t.SF020000 = 0x2514;
  25683. t.SF030000 = 0x2510;
  25684. t.SF040000 = 0x2518;
  25685. t.SF050000 = 0x253c;
  25686. t.SF060000 = 0x252c;
  25687. t.SF070000 = 0x2534;
  25688. t.SF080000 = 0x251c;
  25689. t.SF090000 = 0x2524;
  25690. t.SF100000 = 0x2500;
  25691. t.SF110000 = 0x2502;
  25692. t.SF190000 = 0x2561;
  25693. t.SF200000 = 0x2562;
  25694. t.SF210000 = 0x2556;
  25695. t.SF220000 = 0x2555;
  25696. t.SF230000 = 0x2563;
  25697. t.SF240000 = 0x2551;
  25698. t.SF250000 = 0x2557;
  25699. t.SF260000 = 0x255d;
  25700. t.SF270000 = 0x255c;
  25701. t.SF280000 = 0x255b;
  25702. t.SF360000 = 0x255e;
  25703. t.SF370000 = 0x255f;
  25704. t.SF380000 = 0x255a;
  25705. t.SF390000 = 0x2554;
  25706. t.SF400000 = 0x2569;
  25707. t.SF410000 = 0x2566;
  25708. t.SF420000 = 0x2560;
  25709. t.SF430000 = 0x2550;
  25710. t.SF440000 = 0x256c;
  25711. t.SF450000 = 0x2567;
  25712. t.SF460000 = 0x2568;
  25713. t.SF470000 = 0x2564;
  25714. t.SF480000 = 0x2565;
  25715. t.SF490000 = 0x2559;
  25716. t.SF500000 = 0x2558;
  25717. t.SF510000 = 0x2552;
  25718. t.SF520000 = 0x2553;
  25719. t.SF530000 = 0x256b;
  25720. t.SF540000 = 0x256a;
  25721. t.Sacute = 0x015a;
  25722. t.Sacutedotaccent = 0x1e64;
  25723. t.Sampigreek = 0x03e0;
  25724. t.Scaron = 0x0160;
  25725. t.Scarondotaccent = 0x1e66;
  25726. t.Scaronsmall = 0xf6fd;
  25727. t.Scedilla = 0x015e;
  25728. t.Schwa = 0x018f;
  25729. t.Schwacyrillic = 0x04d8;
  25730. t.Schwadieresiscyrillic = 0x04da;
  25731. t.Scircle = 0x24c8;
  25732. t.Scircumflex = 0x015c;
  25733. t.Scommaaccent = 0x0218;
  25734. t.Sdotaccent = 0x1e60;
  25735. t.Sdotbelow = 0x1e62;
  25736. t.Sdotbelowdotaccent = 0x1e68;
  25737. t.Seharmenian = 0x054d;
  25738. t.Sevenroman = 0x2166;
  25739. t.Shaarmenian = 0x0547;
  25740. t.Shacyrillic = 0x0428;
  25741. t.Shchacyrillic = 0x0429;
  25742. t.Sheicoptic = 0x03e2;
  25743. t.Shhacyrillic = 0x04ba;
  25744. t.Shimacoptic = 0x03ec;
  25745. t.Sigma = 0x03a3;
  25746. t.Sixroman = 0x2165;
  25747. t.Smonospace = 0xff33;
  25748. t.Softsigncyrillic = 0x042c;
  25749. t.Ssmall = 0xf773;
  25750. t.Stigmagreek = 0x03da;
  25751. t.T = 0x0054;
  25752. t.Tau = 0x03a4;
  25753. t.Tbar = 0x0166;
  25754. t.Tcaron = 0x0164;
  25755. t.Tcedilla = 0x0162;
  25756. t.Tcircle = 0x24c9;
  25757. t.Tcircumflexbelow = 0x1e70;
  25758. t.Tcommaaccent = 0x0162;
  25759. t.Tdotaccent = 0x1e6a;
  25760. t.Tdotbelow = 0x1e6c;
  25761. t.Tecyrillic = 0x0422;
  25762. t.Tedescendercyrillic = 0x04ac;
  25763. t.Tenroman = 0x2169;
  25764. t.Tetsecyrillic = 0x04b4;
  25765. t.Theta = 0x0398;
  25766. t.Thook = 0x01ac;
  25767. t.Thorn = 0x00de;
  25768. t.Thornsmall = 0xf7fe;
  25769. t.Threeroman = 0x2162;
  25770. t.Tildesmall = 0xf6fe;
  25771. t.Tiwnarmenian = 0x054f;
  25772. t.Tlinebelow = 0x1e6e;
  25773. t.Tmonospace = 0xff34;
  25774. t.Toarmenian = 0x0539;
  25775. t.Tonefive = 0x01bc;
  25776. t.Tonesix = 0x0184;
  25777. t.Tonetwo = 0x01a7;
  25778. t.Tretroflexhook = 0x01ae;
  25779. t.Tsecyrillic = 0x0426;
  25780. t.Tshecyrillic = 0x040b;
  25781. t.Tsmall = 0xf774;
  25782. t.Twelveroman = 0x216b;
  25783. t.Tworoman = 0x2161;
  25784. t.U = 0x0055;
  25785. t.Uacute = 0x00da;
  25786. t.Uacutesmall = 0xf7fa;
  25787. t.Ubreve = 0x016c;
  25788. t.Ucaron = 0x01d3;
  25789. t.Ucircle = 0x24ca;
  25790. t.Ucircumflex = 0x00db;
  25791. t.Ucircumflexbelow = 0x1e76;
  25792. t.Ucircumflexsmall = 0xf7fb;
  25793. t.Ucyrillic = 0x0423;
  25794. t.Udblacute = 0x0170;
  25795. t.Udblgrave = 0x0214;
  25796. t.Udieresis = 0x00dc;
  25797. t.Udieresisacute = 0x01d7;
  25798. t.Udieresisbelow = 0x1e72;
  25799. t.Udieresiscaron = 0x01d9;
  25800. t.Udieresiscyrillic = 0x04f0;
  25801. t.Udieresisgrave = 0x01db;
  25802. t.Udieresismacron = 0x01d5;
  25803. t.Udieresissmall = 0xf7fc;
  25804. t.Udotbelow = 0x1ee4;
  25805. t.Ugrave = 0x00d9;
  25806. t.Ugravesmall = 0xf7f9;
  25807. t.Uhookabove = 0x1ee6;
  25808. t.Uhorn = 0x01af;
  25809. t.Uhornacute = 0x1ee8;
  25810. t.Uhorndotbelow = 0x1ef0;
  25811. t.Uhorngrave = 0x1eea;
  25812. t.Uhornhookabove = 0x1eec;
  25813. t.Uhorntilde = 0x1eee;
  25814. t.Uhungarumlaut = 0x0170;
  25815. t.Uhungarumlautcyrillic = 0x04f2;
  25816. t.Uinvertedbreve = 0x0216;
  25817. t.Ukcyrillic = 0x0478;
  25818. t.Umacron = 0x016a;
  25819. t.Umacroncyrillic = 0x04ee;
  25820. t.Umacrondieresis = 0x1e7a;
  25821. t.Umonospace = 0xff35;
  25822. t.Uogonek = 0x0172;
  25823. t.Upsilon = 0x03a5;
  25824. t.Upsilon1 = 0x03d2;
  25825. t.Upsilonacutehooksymbolgreek = 0x03d3;
  25826. t.Upsilonafrican = 0x01b1;
  25827. t.Upsilondieresis = 0x03ab;
  25828. t.Upsilondieresishooksymbolgreek = 0x03d4;
  25829. t.Upsilonhooksymbol = 0x03d2;
  25830. t.Upsilontonos = 0x038e;
  25831. t.Uring = 0x016e;
  25832. t.Ushortcyrillic = 0x040e;
  25833. t.Usmall = 0xf775;
  25834. t.Ustraightcyrillic = 0x04ae;
  25835. t.Ustraightstrokecyrillic = 0x04b0;
  25836. t.Utilde = 0x0168;
  25837. t.Utildeacute = 0x1e78;
  25838. t.Utildebelow = 0x1e74;
  25839. t.V = 0x0056;
  25840. t.Vcircle = 0x24cb;
  25841. t.Vdotbelow = 0x1e7e;
  25842. t.Vecyrillic = 0x0412;
  25843. t.Vewarmenian = 0x054e;
  25844. t.Vhook = 0x01b2;
  25845. t.Vmonospace = 0xff36;
  25846. t.Voarmenian = 0x0548;
  25847. t.Vsmall = 0xf776;
  25848. t.Vtilde = 0x1e7c;
  25849. t.W = 0x0057;
  25850. t.Wacute = 0x1e82;
  25851. t.Wcircle = 0x24cc;
  25852. t.Wcircumflex = 0x0174;
  25853. t.Wdieresis = 0x1e84;
  25854. t.Wdotaccent = 0x1e86;
  25855. t.Wdotbelow = 0x1e88;
  25856. t.Wgrave = 0x1e80;
  25857. t.Wmonospace = 0xff37;
  25858. t.Wsmall = 0xf777;
  25859. t.X = 0x0058;
  25860. t.Xcircle = 0x24cd;
  25861. t.Xdieresis = 0x1e8c;
  25862. t.Xdotaccent = 0x1e8a;
  25863. t.Xeharmenian = 0x053d;
  25864. t.Xi = 0x039e;
  25865. t.Xmonospace = 0xff38;
  25866. t.Xsmall = 0xf778;
  25867. t.Y = 0x0059;
  25868. t.Yacute = 0x00dd;
  25869. t.Yacutesmall = 0xf7fd;
  25870. t.Yatcyrillic = 0x0462;
  25871. t.Ycircle = 0x24ce;
  25872. t.Ycircumflex = 0x0176;
  25873. t.Ydieresis = 0x0178;
  25874. t.Ydieresissmall = 0xf7ff;
  25875. t.Ydotaccent = 0x1e8e;
  25876. t.Ydotbelow = 0x1ef4;
  25877. t.Yericyrillic = 0x042b;
  25878. t.Yerudieresiscyrillic = 0x04f8;
  25879. t.Ygrave = 0x1ef2;
  25880. t.Yhook = 0x01b3;
  25881. t.Yhookabove = 0x1ef6;
  25882. t.Yiarmenian = 0x0545;
  25883. t.Yicyrillic = 0x0407;
  25884. t.Yiwnarmenian = 0x0552;
  25885. t.Ymonospace = 0xff39;
  25886. t.Ysmall = 0xf779;
  25887. t.Ytilde = 0x1ef8;
  25888. t.Yusbigcyrillic = 0x046a;
  25889. t.Yusbigiotifiedcyrillic = 0x046c;
  25890. t.Yuslittlecyrillic = 0x0466;
  25891. t.Yuslittleiotifiedcyrillic = 0x0468;
  25892. t.Z = 0x005a;
  25893. t.Zaarmenian = 0x0536;
  25894. t.Zacute = 0x0179;
  25895. t.Zcaron = 0x017d;
  25896. t.Zcaronsmall = 0xf6ff;
  25897. t.Zcircle = 0x24cf;
  25898. t.Zcircumflex = 0x1e90;
  25899. t.Zdot = 0x017b;
  25900. t.Zdotaccent = 0x017b;
  25901. t.Zdotbelow = 0x1e92;
  25902. t.Zecyrillic = 0x0417;
  25903. t.Zedescendercyrillic = 0x0498;
  25904. t.Zedieresiscyrillic = 0x04de;
  25905. t.Zeta = 0x0396;
  25906. t.Zhearmenian = 0x053a;
  25907. t.Zhebrevecyrillic = 0x04c1;
  25908. t.Zhecyrillic = 0x0416;
  25909. t.Zhedescendercyrillic = 0x0496;
  25910. t.Zhedieresiscyrillic = 0x04dc;
  25911. t.Zlinebelow = 0x1e94;
  25912. t.Zmonospace = 0xff3a;
  25913. t.Zsmall = 0xf77a;
  25914. t.Zstroke = 0x01b5;
  25915. t.a = 0x0061;
  25916. t.aabengali = 0x0986;
  25917. t.aacute = 0x00e1;
  25918. t.aadeva = 0x0906;
  25919. t.aagujarati = 0x0a86;
  25920. t.aagurmukhi = 0x0a06;
  25921. t.aamatragurmukhi = 0x0a3e;
  25922. t.aarusquare = 0x3303;
  25923. t.aavowelsignbengali = 0x09be;
  25924. t.aavowelsigndeva = 0x093e;
  25925. t.aavowelsigngujarati = 0x0abe;
  25926. t.abbreviationmarkarmenian = 0x055f;
  25927. t.abbreviationsigndeva = 0x0970;
  25928. t.abengali = 0x0985;
  25929. t.abopomofo = 0x311a;
  25930. t.abreve = 0x0103;
  25931. t.abreveacute = 0x1eaf;
  25932. t.abrevecyrillic = 0x04d1;
  25933. t.abrevedotbelow = 0x1eb7;
  25934. t.abrevegrave = 0x1eb1;
  25935. t.abrevehookabove = 0x1eb3;
  25936. t.abrevetilde = 0x1eb5;
  25937. t.acaron = 0x01ce;
  25938. t.acircle = 0x24d0;
  25939. t.acircumflex = 0x00e2;
  25940. t.acircumflexacute = 0x1ea5;
  25941. t.acircumflexdotbelow = 0x1ead;
  25942. t.acircumflexgrave = 0x1ea7;
  25943. t.acircumflexhookabove = 0x1ea9;
  25944. t.acircumflextilde = 0x1eab;
  25945. t.acute = 0x00b4;
  25946. t.acutebelowcmb = 0x0317;
  25947. t.acutecmb = 0x0301;
  25948. t.acutecomb = 0x0301;
  25949. t.acutedeva = 0x0954;
  25950. t.acutelowmod = 0x02cf;
  25951. t.acutetonecmb = 0x0341;
  25952. t.acyrillic = 0x0430;
  25953. t.adblgrave = 0x0201;
  25954. t.addakgurmukhi = 0x0a71;
  25955. t.adeva = 0x0905;
  25956. t.adieresis = 0x00e4;
  25957. t.adieresiscyrillic = 0x04d3;
  25958. t.adieresismacron = 0x01df;
  25959. t.adotbelow = 0x1ea1;
  25960. t.adotmacron = 0x01e1;
  25961. t.ae = 0x00e6;
  25962. t.aeacute = 0x01fd;
  25963. t.aekorean = 0x3150;
  25964. t.aemacron = 0x01e3;
  25965. t.afii00208 = 0x2015;
  25966. t.afii08941 = 0x20a4;
  25967. t.afii10017 = 0x0410;
  25968. t.afii10018 = 0x0411;
  25969. t.afii10019 = 0x0412;
  25970. t.afii10020 = 0x0413;
  25971. t.afii10021 = 0x0414;
  25972. t.afii10022 = 0x0415;
  25973. t.afii10023 = 0x0401;
  25974. t.afii10024 = 0x0416;
  25975. t.afii10025 = 0x0417;
  25976. t.afii10026 = 0x0418;
  25977. t.afii10027 = 0x0419;
  25978. t.afii10028 = 0x041a;
  25979. t.afii10029 = 0x041b;
  25980. t.afii10030 = 0x041c;
  25981. t.afii10031 = 0x041d;
  25982. t.afii10032 = 0x041e;
  25983. t.afii10033 = 0x041f;
  25984. t.afii10034 = 0x0420;
  25985. t.afii10035 = 0x0421;
  25986. t.afii10036 = 0x0422;
  25987. t.afii10037 = 0x0423;
  25988. t.afii10038 = 0x0424;
  25989. t.afii10039 = 0x0425;
  25990. t.afii10040 = 0x0426;
  25991. t.afii10041 = 0x0427;
  25992. t.afii10042 = 0x0428;
  25993. t.afii10043 = 0x0429;
  25994. t.afii10044 = 0x042a;
  25995. t.afii10045 = 0x042b;
  25996. t.afii10046 = 0x042c;
  25997. t.afii10047 = 0x042d;
  25998. t.afii10048 = 0x042e;
  25999. t.afii10049 = 0x042f;
  26000. t.afii10050 = 0x0490;
  26001. t.afii10051 = 0x0402;
  26002. t.afii10052 = 0x0403;
  26003. t.afii10053 = 0x0404;
  26004. t.afii10054 = 0x0405;
  26005. t.afii10055 = 0x0406;
  26006. t.afii10056 = 0x0407;
  26007. t.afii10057 = 0x0408;
  26008. t.afii10058 = 0x0409;
  26009. t.afii10059 = 0x040a;
  26010. t.afii10060 = 0x040b;
  26011. t.afii10061 = 0x040c;
  26012. t.afii10062 = 0x040e;
  26013. t.afii10063 = 0xf6c4;
  26014. t.afii10064 = 0xf6c5;
  26015. t.afii10065 = 0x0430;
  26016. t.afii10066 = 0x0431;
  26017. t.afii10067 = 0x0432;
  26018. t.afii10068 = 0x0433;
  26019. t.afii10069 = 0x0434;
  26020. t.afii10070 = 0x0435;
  26021. t.afii10071 = 0x0451;
  26022. t.afii10072 = 0x0436;
  26023. t.afii10073 = 0x0437;
  26024. t.afii10074 = 0x0438;
  26025. t.afii10075 = 0x0439;
  26026. t.afii10076 = 0x043a;
  26027. t.afii10077 = 0x043b;
  26028. t.afii10078 = 0x043c;
  26029. t.afii10079 = 0x043d;
  26030. t.afii10080 = 0x043e;
  26031. t.afii10081 = 0x043f;
  26032. t.afii10082 = 0x0440;
  26033. t.afii10083 = 0x0441;
  26034. t.afii10084 = 0x0442;
  26035. t.afii10085 = 0x0443;
  26036. t.afii10086 = 0x0444;
  26037. t.afii10087 = 0x0445;
  26038. t.afii10088 = 0x0446;
  26039. t.afii10089 = 0x0447;
  26040. t.afii10090 = 0x0448;
  26041. t.afii10091 = 0x0449;
  26042. t.afii10092 = 0x044a;
  26043. t.afii10093 = 0x044b;
  26044. t.afii10094 = 0x044c;
  26045. t.afii10095 = 0x044d;
  26046. t.afii10096 = 0x044e;
  26047. t.afii10097 = 0x044f;
  26048. t.afii10098 = 0x0491;
  26049. t.afii10099 = 0x0452;
  26050. t.afii10100 = 0x0453;
  26051. t.afii10101 = 0x0454;
  26052. t.afii10102 = 0x0455;
  26053. t.afii10103 = 0x0456;
  26054. t.afii10104 = 0x0457;
  26055. t.afii10105 = 0x0458;
  26056. t.afii10106 = 0x0459;
  26057. t.afii10107 = 0x045a;
  26058. t.afii10108 = 0x045b;
  26059. t.afii10109 = 0x045c;
  26060. t.afii10110 = 0x045e;
  26061. t.afii10145 = 0x040f;
  26062. t.afii10146 = 0x0462;
  26063. t.afii10147 = 0x0472;
  26064. t.afii10148 = 0x0474;
  26065. t.afii10192 = 0xf6c6;
  26066. t.afii10193 = 0x045f;
  26067. t.afii10194 = 0x0463;
  26068. t.afii10195 = 0x0473;
  26069. t.afii10196 = 0x0475;
  26070. t.afii10831 = 0xf6c7;
  26071. t.afii10832 = 0xf6c8;
  26072. t.afii10846 = 0x04d9;
  26073. t.afii299 = 0x200e;
  26074. t.afii300 = 0x200f;
  26075. t.afii301 = 0x200d;
  26076. t.afii57381 = 0x066a;
  26077. t.afii57388 = 0x060c;
  26078. t.afii57392 = 0x0660;
  26079. t.afii57393 = 0x0661;
  26080. t.afii57394 = 0x0662;
  26081. t.afii57395 = 0x0663;
  26082. t.afii57396 = 0x0664;
  26083. t.afii57397 = 0x0665;
  26084. t.afii57398 = 0x0666;
  26085. t.afii57399 = 0x0667;
  26086. t.afii57400 = 0x0668;
  26087. t.afii57401 = 0x0669;
  26088. t.afii57403 = 0x061b;
  26089. t.afii57407 = 0x061f;
  26090. t.afii57409 = 0x0621;
  26091. t.afii57410 = 0x0622;
  26092. t.afii57411 = 0x0623;
  26093. t.afii57412 = 0x0624;
  26094. t.afii57413 = 0x0625;
  26095. t.afii57414 = 0x0626;
  26096. t.afii57415 = 0x0627;
  26097. t.afii57416 = 0x0628;
  26098. t.afii57417 = 0x0629;
  26099. t.afii57418 = 0x062a;
  26100. t.afii57419 = 0x062b;
  26101. t.afii57420 = 0x062c;
  26102. t.afii57421 = 0x062d;
  26103. t.afii57422 = 0x062e;
  26104. t.afii57423 = 0x062f;
  26105. t.afii57424 = 0x0630;
  26106. t.afii57425 = 0x0631;
  26107. t.afii57426 = 0x0632;
  26108. t.afii57427 = 0x0633;
  26109. t.afii57428 = 0x0634;
  26110. t.afii57429 = 0x0635;
  26111. t.afii57430 = 0x0636;
  26112. t.afii57431 = 0x0637;
  26113. t.afii57432 = 0x0638;
  26114. t.afii57433 = 0x0639;
  26115. t.afii57434 = 0x063a;
  26116. t.afii57440 = 0x0640;
  26117. t.afii57441 = 0x0641;
  26118. t.afii57442 = 0x0642;
  26119. t.afii57443 = 0x0643;
  26120. t.afii57444 = 0x0644;
  26121. t.afii57445 = 0x0645;
  26122. t.afii57446 = 0x0646;
  26123. t.afii57448 = 0x0648;
  26124. t.afii57449 = 0x0649;
  26125. t.afii57450 = 0x064a;
  26126. t.afii57451 = 0x064b;
  26127. t.afii57452 = 0x064c;
  26128. t.afii57453 = 0x064d;
  26129. t.afii57454 = 0x064e;
  26130. t.afii57455 = 0x064f;
  26131. t.afii57456 = 0x0650;
  26132. t.afii57457 = 0x0651;
  26133. t.afii57458 = 0x0652;
  26134. t.afii57470 = 0x0647;
  26135. t.afii57505 = 0x06a4;
  26136. t.afii57506 = 0x067e;
  26137. t.afii57507 = 0x0686;
  26138. t.afii57508 = 0x0698;
  26139. t.afii57509 = 0x06af;
  26140. t.afii57511 = 0x0679;
  26141. t.afii57512 = 0x0688;
  26142. t.afii57513 = 0x0691;
  26143. t.afii57514 = 0x06ba;
  26144. t.afii57519 = 0x06d2;
  26145. t.afii57534 = 0x06d5;
  26146. t.afii57636 = 0x20aa;
  26147. t.afii57645 = 0x05be;
  26148. t.afii57658 = 0x05c3;
  26149. t.afii57664 = 0x05d0;
  26150. t.afii57665 = 0x05d1;
  26151. t.afii57666 = 0x05d2;
  26152. t.afii57667 = 0x05d3;
  26153. t.afii57668 = 0x05d4;
  26154. t.afii57669 = 0x05d5;
  26155. t.afii57670 = 0x05d6;
  26156. t.afii57671 = 0x05d7;
  26157. t.afii57672 = 0x05d8;
  26158. t.afii57673 = 0x05d9;
  26159. t.afii57674 = 0x05da;
  26160. t.afii57675 = 0x05db;
  26161. t.afii57676 = 0x05dc;
  26162. t.afii57677 = 0x05dd;
  26163. t.afii57678 = 0x05de;
  26164. t.afii57679 = 0x05df;
  26165. t.afii57680 = 0x05e0;
  26166. t.afii57681 = 0x05e1;
  26167. t.afii57682 = 0x05e2;
  26168. t.afii57683 = 0x05e3;
  26169. t.afii57684 = 0x05e4;
  26170. t.afii57685 = 0x05e5;
  26171. t.afii57686 = 0x05e6;
  26172. t.afii57687 = 0x05e7;
  26173. t.afii57688 = 0x05e8;
  26174. t.afii57689 = 0x05e9;
  26175. t.afii57690 = 0x05ea;
  26176. t.afii57694 = 0xfb2a;
  26177. t.afii57695 = 0xfb2b;
  26178. t.afii57700 = 0xfb4b;
  26179. t.afii57705 = 0xfb1f;
  26180. t.afii57716 = 0x05f0;
  26181. t.afii57717 = 0x05f1;
  26182. t.afii57718 = 0x05f2;
  26183. t.afii57723 = 0xfb35;
  26184. t.afii57793 = 0x05b4;
  26185. t.afii57794 = 0x05b5;
  26186. t.afii57795 = 0x05b6;
  26187. t.afii57796 = 0x05bb;
  26188. t.afii57797 = 0x05b8;
  26189. t.afii57798 = 0x05b7;
  26190. t.afii57799 = 0x05b0;
  26191. t.afii57800 = 0x05b2;
  26192. t.afii57801 = 0x05b1;
  26193. t.afii57802 = 0x05b3;
  26194. t.afii57803 = 0x05c2;
  26195. t.afii57804 = 0x05c1;
  26196. t.afii57806 = 0x05b9;
  26197. t.afii57807 = 0x05bc;
  26198. t.afii57839 = 0x05bd;
  26199. t.afii57841 = 0x05bf;
  26200. t.afii57842 = 0x05c0;
  26201. t.afii57929 = 0x02bc;
  26202. t.afii61248 = 0x2105;
  26203. t.afii61289 = 0x2113;
  26204. t.afii61352 = 0x2116;
  26205. t.afii61573 = 0x202c;
  26206. t.afii61574 = 0x202d;
  26207. t.afii61575 = 0x202e;
  26208. t.afii61664 = 0x200c;
  26209. t.afii63167 = 0x066d;
  26210. t.afii64937 = 0x02bd;
  26211. t.agrave = 0x00e0;
  26212. t.agujarati = 0x0a85;
  26213. t.agurmukhi = 0x0a05;
  26214. t.ahiragana = 0x3042;
  26215. t.ahookabove = 0x1ea3;
  26216. t.aibengali = 0x0990;
  26217. t.aibopomofo = 0x311e;
  26218. t.aideva = 0x0910;
  26219. t.aiecyrillic = 0x04d5;
  26220. t.aigujarati = 0x0a90;
  26221. t.aigurmukhi = 0x0a10;
  26222. t.aimatragurmukhi = 0x0a48;
  26223. t.ainarabic = 0x0639;
  26224. t.ainfinalarabic = 0xfeca;
  26225. t.aininitialarabic = 0xfecb;
  26226. t.ainmedialarabic = 0xfecc;
  26227. t.ainvertedbreve = 0x0203;
  26228. t.aivowelsignbengali = 0x09c8;
  26229. t.aivowelsigndeva = 0x0948;
  26230. t.aivowelsigngujarati = 0x0ac8;
  26231. t.akatakana = 0x30a2;
  26232. t.akatakanahalfwidth = 0xff71;
  26233. t.akorean = 0x314f;
  26234. t.alef = 0x05d0;
  26235. t.alefarabic = 0x0627;
  26236. t.alefdageshhebrew = 0xfb30;
  26237. t.aleffinalarabic = 0xfe8e;
  26238. t.alefhamzaabovearabic = 0x0623;
  26239. t.alefhamzaabovefinalarabic = 0xfe84;
  26240. t.alefhamzabelowarabic = 0x0625;
  26241. t.alefhamzabelowfinalarabic = 0xfe88;
  26242. t.alefhebrew = 0x05d0;
  26243. t.aleflamedhebrew = 0xfb4f;
  26244. t.alefmaddaabovearabic = 0x0622;
  26245. t.alefmaddaabovefinalarabic = 0xfe82;
  26246. t.alefmaksuraarabic = 0x0649;
  26247. t.alefmaksurafinalarabic = 0xfef0;
  26248. t.alefmaksurainitialarabic = 0xfef3;
  26249. t.alefmaksuramedialarabic = 0xfef4;
  26250. t.alefpatahhebrew = 0xfb2e;
  26251. t.alefqamatshebrew = 0xfb2f;
  26252. t.aleph = 0x2135;
  26253. t.allequal = 0x224c;
  26254. t.alpha = 0x03b1;
  26255. t.alphatonos = 0x03ac;
  26256. t.amacron = 0x0101;
  26257. t.amonospace = 0xff41;
  26258. t.ampersand = 0x0026;
  26259. t.ampersandmonospace = 0xff06;
  26260. t.ampersandsmall = 0xf726;
  26261. t.amsquare = 0x33c2;
  26262. t.anbopomofo = 0x3122;
  26263. t.angbopomofo = 0x3124;
  26264. t.angbracketleft = 0x3008;
  26265. t.angbracketright = 0x3009;
  26266. t.angkhankhuthai = 0x0e5a;
  26267. t.angle = 0x2220;
  26268. t.anglebracketleft = 0x3008;
  26269. t.anglebracketleftvertical = 0xfe3f;
  26270. t.anglebracketright = 0x3009;
  26271. t.anglebracketrightvertical = 0xfe40;
  26272. t.angleleft = 0x2329;
  26273. t.angleright = 0x232a;
  26274. t.angstrom = 0x212b;
  26275. t.anoteleia = 0x0387;
  26276. t.anudattadeva = 0x0952;
  26277. t.anusvarabengali = 0x0982;
  26278. t.anusvaradeva = 0x0902;
  26279. t.anusvaragujarati = 0x0a82;
  26280. t.aogonek = 0x0105;
  26281. t.apaatosquare = 0x3300;
  26282. t.aparen = 0x249c;
  26283. t.apostrophearmenian = 0x055a;
  26284. t.apostrophemod = 0x02bc;
  26285. t.apple = 0xf8ff;
  26286. t.approaches = 0x2250;
  26287. t.approxequal = 0x2248;
  26288. t.approxequalorimage = 0x2252;
  26289. t.approximatelyequal = 0x2245;
  26290. t.araeaekorean = 0x318e;
  26291. t.araeakorean = 0x318d;
  26292. t.arc = 0x2312;
  26293. t.arighthalfring = 0x1e9a;
  26294. t.aring = 0x00e5;
  26295. t.aringacute = 0x01fb;
  26296. t.aringbelow = 0x1e01;
  26297. t.arrowboth = 0x2194;
  26298. t.arrowdashdown = 0x21e3;
  26299. t.arrowdashleft = 0x21e0;
  26300. t.arrowdashright = 0x21e2;
  26301. t.arrowdashup = 0x21e1;
  26302. t.arrowdblboth = 0x21d4;
  26303. t.arrowdbldown = 0x21d3;
  26304. t.arrowdblleft = 0x21d0;
  26305. t.arrowdblright = 0x21d2;
  26306. t.arrowdblup = 0x21d1;
  26307. t.arrowdown = 0x2193;
  26308. t.arrowdownleft = 0x2199;
  26309. t.arrowdownright = 0x2198;
  26310. t.arrowdownwhite = 0x21e9;
  26311. t.arrowheaddownmod = 0x02c5;
  26312. t.arrowheadleftmod = 0x02c2;
  26313. t.arrowheadrightmod = 0x02c3;
  26314. t.arrowheadupmod = 0x02c4;
  26315. t.arrowhorizex = 0xf8e7;
  26316. t.arrowleft = 0x2190;
  26317. t.arrowleftdbl = 0x21d0;
  26318. t.arrowleftdblstroke = 0x21cd;
  26319. t.arrowleftoverright = 0x21c6;
  26320. t.arrowleftwhite = 0x21e6;
  26321. t.arrowright = 0x2192;
  26322. t.arrowrightdblstroke = 0x21cf;
  26323. t.arrowrightheavy = 0x279e;
  26324. t.arrowrightoverleft = 0x21c4;
  26325. t.arrowrightwhite = 0x21e8;
  26326. t.arrowtableft = 0x21e4;
  26327. t.arrowtabright = 0x21e5;
  26328. t.arrowup = 0x2191;
  26329. t.arrowupdn = 0x2195;
  26330. t.arrowupdnbse = 0x21a8;
  26331. t.arrowupdownbase = 0x21a8;
  26332. t.arrowupleft = 0x2196;
  26333. t.arrowupleftofdown = 0x21c5;
  26334. t.arrowupright = 0x2197;
  26335. t.arrowupwhite = 0x21e7;
  26336. t.arrowvertex = 0xf8e6;
  26337. t.asciicircum = 0x005e;
  26338. t.asciicircummonospace = 0xff3e;
  26339. t.asciitilde = 0x007e;
  26340. t.asciitildemonospace = 0xff5e;
  26341. t.ascript = 0x0251;
  26342. t.ascriptturned = 0x0252;
  26343. t.asmallhiragana = 0x3041;
  26344. t.asmallkatakana = 0x30a1;
  26345. t.asmallkatakanahalfwidth = 0xff67;
  26346. t.asterisk = 0x002a;
  26347. t.asteriskaltonearabic = 0x066d;
  26348. t.asteriskarabic = 0x066d;
  26349. t.asteriskmath = 0x2217;
  26350. t.asteriskmonospace = 0xff0a;
  26351. t.asterisksmall = 0xfe61;
  26352. t.asterism = 0x2042;
  26353. t.asuperior = 0xf6e9;
  26354. t.asymptoticallyequal = 0x2243;
  26355. t.at = 0x0040;
  26356. t.atilde = 0x00e3;
  26357. t.atmonospace = 0xff20;
  26358. t.atsmall = 0xfe6b;
  26359. t.aturned = 0x0250;
  26360. t.aubengali = 0x0994;
  26361. t.aubopomofo = 0x3120;
  26362. t.audeva = 0x0914;
  26363. t.augujarati = 0x0a94;
  26364. t.augurmukhi = 0x0a14;
  26365. t.aulengthmarkbengali = 0x09d7;
  26366. t.aumatragurmukhi = 0x0a4c;
  26367. t.auvowelsignbengali = 0x09cc;
  26368. t.auvowelsigndeva = 0x094c;
  26369. t.auvowelsigngujarati = 0x0acc;
  26370. t.avagrahadeva = 0x093d;
  26371. t.aybarmenian = 0x0561;
  26372. t.ayin = 0x05e2;
  26373. t.ayinaltonehebrew = 0xfb20;
  26374. t.ayinhebrew = 0x05e2;
  26375. t.b = 0x0062;
  26376. t.babengali = 0x09ac;
  26377. t.backslash = 0x005c;
  26378. t.backslashmonospace = 0xff3c;
  26379. t.badeva = 0x092c;
  26380. t.bagujarati = 0x0aac;
  26381. t.bagurmukhi = 0x0a2c;
  26382. t.bahiragana = 0x3070;
  26383. t.bahtthai = 0x0e3f;
  26384. t.bakatakana = 0x30d0;
  26385. t.bar = 0x007c;
  26386. t.barmonospace = 0xff5c;
  26387. t.bbopomofo = 0x3105;
  26388. t.bcircle = 0x24d1;
  26389. t.bdotaccent = 0x1e03;
  26390. t.bdotbelow = 0x1e05;
  26391. t.beamedsixteenthnotes = 0x266c;
  26392. t.because = 0x2235;
  26393. t.becyrillic = 0x0431;
  26394. t.beharabic = 0x0628;
  26395. t.behfinalarabic = 0xfe90;
  26396. t.behinitialarabic = 0xfe91;
  26397. t.behiragana = 0x3079;
  26398. t.behmedialarabic = 0xfe92;
  26399. t.behmeeminitialarabic = 0xfc9f;
  26400. t.behmeemisolatedarabic = 0xfc08;
  26401. t.behnoonfinalarabic = 0xfc6d;
  26402. t.bekatakana = 0x30d9;
  26403. t.benarmenian = 0x0562;
  26404. t.bet = 0x05d1;
  26405. t.beta = 0x03b2;
  26406. t.betasymbolgreek = 0x03d0;
  26407. t.betdagesh = 0xfb31;
  26408. t.betdageshhebrew = 0xfb31;
  26409. t.bethebrew = 0x05d1;
  26410. t.betrafehebrew = 0xfb4c;
  26411. t.bhabengali = 0x09ad;
  26412. t.bhadeva = 0x092d;
  26413. t.bhagujarati = 0x0aad;
  26414. t.bhagurmukhi = 0x0a2d;
  26415. t.bhook = 0x0253;
  26416. t.bihiragana = 0x3073;
  26417. t.bikatakana = 0x30d3;
  26418. t.bilabialclick = 0x0298;
  26419. t.bindigurmukhi = 0x0a02;
  26420. t.birusquare = 0x3331;
  26421. t.blackcircle = 0x25cf;
  26422. t.blackdiamond = 0x25c6;
  26423. t.blackdownpointingtriangle = 0x25bc;
  26424. t.blackleftpointingpointer = 0x25c4;
  26425. t.blackleftpointingtriangle = 0x25c0;
  26426. t.blacklenticularbracketleft = 0x3010;
  26427. t.blacklenticularbracketleftvertical = 0xfe3b;
  26428. t.blacklenticularbracketright = 0x3011;
  26429. t.blacklenticularbracketrightvertical = 0xfe3c;
  26430. t.blacklowerlefttriangle = 0x25e3;
  26431. t.blacklowerrighttriangle = 0x25e2;
  26432. t.blackrectangle = 0x25ac;
  26433. t.blackrightpointingpointer = 0x25ba;
  26434. t.blackrightpointingtriangle = 0x25b6;
  26435. t.blacksmallsquare = 0x25aa;
  26436. t.blacksmilingface = 0x263b;
  26437. t.blacksquare = 0x25a0;
  26438. t.blackstar = 0x2605;
  26439. t.blackupperlefttriangle = 0x25e4;
  26440. t.blackupperrighttriangle = 0x25e5;
  26441. t.blackuppointingsmalltriangle = 0x25b4;
  26442. t.blackuppointingtriangle = 0x25b2;
  26443. t.blank = 0x2423;
  26444. t.blinebelow = 0x1e07;
  26445. t.block = 0x2588;
  26446. t.bmonospace = 0xff42;
  26447. t.bobaimaithai = 0x0e1a;
  26448. t.bohiragana = 0x307c;
  26449. t.bokatakana = 0x30dc;
  26450. t.bparen = 0x249d;
  26451. t.bqsquare = 0x33c3;
  26452. t.braceex = 0xf8f4;
  26453. t.braceleft = 0x007b;
  26454. t.braceleftbt = 0xf8f3;
  26455. t.braceleftmid = 0xf8f2;
  26456. t.braceleftmonospace = 0xff5b;
  26457. t.braceleftsmall = 0xfe5b;
  26458. t.bracelefttp = 0xf8f1;
  26459. t.braceleftvertical = 0xfe37;
  26460. t.braceright = 0x007d;
  26461. t.bracerightbt = 0xf8fe;
  26462. t.bracerightmid = 0xf8fd;
  26463. t.bracerightmonospace = 0xff5d;
  26464. t.bracerightsmall = 0xfe5c;
  26465. t.bracerighttp = 0xf8fc;
  26466. t.bracerightvertical = 0xfe38;
  26467. t.bracketleft = 0x005b;
  26468. t.bracketleftbt = 0xf8f0;
  26469. t.bracketleftex = 0xf8ef;
  26470. t.bracketleftmonospace = 0xff3b;
  26471. t.bracketlefttp = 0xf8ee;
  26472. t.bracketright = 0x005d;
  26473. t.bracketrightbt = 0xf8fb;
  26474. t.bracketrightex = 0xf8fa;
  26475. t.bracketrightmonospace = 0xff3d;
  26476. t.bracketrighttp = 0xf8f9;
  26477. t.breve = 0x02d8;
  26478. t.brevebelowcmb = 0x032e;
  26479. t.brevecmb = 0x0306;
  26480. t.breveinvertedbelowcmb = 0x032f;
  26481. t.breveinvertedcmb = 0x0311;
  26482. t.breveinverteddoublecmb = 0x0361;
  26483. t.bridgebelowcmb = 0x032a;
  26484. t.bridgeinvertedbelowcmb = 0x033a;
  26485. t.brokenbar = 0x00a6;
  26486. t.bstroke = 0x0180;
  26487. t.bsuperior = 0xf6ea;
  26488. t.btopbar = 0x0183;
  26489. t.buhiragana = 0x3076;
  26490. t.bukatakana = 0x30d6;
  26491. t.bullet = 0x2022;
  26492. t.bulletinverse = 0x25d8;
  26493. t.bulletoperator = 0x2219;
  26494. t.bullseye = 0x25ce;
  26495. t.c = 0x0063;
  26496. t.caarmenian = 0x056e;
  26497. t.cabengali = 0x099a;
  26498. t.cacute = 0x0107;
  26499. t.cadeva = 0x091a;
  26500. t.cagujarati = 0x0a9a;
  26501. t.cagurmukhi = 0x0a1a;
  26502. t.calsquare = 0x3388;
  26503. t.candrabindubengali = 0x0981;
  26504. t.candrabinducmb = 0x0310;
  26505. t.candrabindudeva = 0x0901;
  26506. t.candrabindugujarati = 0x0a81;
  26507. t.capslock = 0x21ea;
  26508. t.careof = 0x2105;
  26509. t.caron = 0x02c7;
  26510. t.caronbelowcmb = 0x032c;
  26511. t.caroncmb = 0x030c;
  26512. t.carriagereturn = 0x21b5;
  26513. t.cbopomofo = 0x3118;
  26514. t.ccaron = 0x010d;
  26515. t.ccedilla = 0x00e7;
  26516. t.ccedillaacute = 0x1e09;
  26517. t.ccircle = 0x24d2;
  26518. t.ccircumflex = 0x0109;
  26519. t.ccurl = 0x0255;
  26520. t.cdot = 0x010b;
  26521. t.cdotaccent = 0x010b;
  26522. t.cdsquare = 0x33c5;
  26523. t.cedilla = 0x00b8;
  26524. t.cedillacmb = 0x0327;
  26525. t.cent = 0x00a2;
  26526. t.centigrade = 0x2103;
  26527. t.centinferior = 0xf6df;
  26528. t.centmonospace = 0xffe0;
  26529. t.centoldstyle = 0xf7a2;
  26530. t.centsuperior = 0xf6e0;
  26531. t.chaarmenian = 0x0579;
  26532. t.chabengali = 0x099b;
  26533. t.chadeva = 0x091b;
  26534. t.chagujarati = 0x0a9b;
  26535. t.chagurmukhi = 0x0a1b;
  26536. t.chbopomofo = 0x3114;
  26537. t.cheabkhasiancyrillic = 0x04bd;
  26538. t.checkmark = 0x2713;
  26539. t.checyrillic = 0x0447;
  26540. t.chedescenderabkhasiancyrillic = 0x04bf;
  26541. t.chedescendercyrillic = 0x04b7;
  26542. t.chedieresiscyrillic = 0x04f5;
  26543. t.cheharmenian = 0x0573;
  26544. t.chekhakassiancyrillic = 0x04cc;
  26545. t.cheverticalstrokecyrillic = 0x04b9;
  26546. t.chi = 0x03c7;
  26547. t.chieuchacirclekorean = 0x3277;
  26548. t.chieuchaparenkorean = 0x3217;
  26549. t.chieuchcirclekorean = 0x3269;
  26550. t.chieuchkorean = 0x314a;
  26551. t.chieuchparenkorean = 0x3209;
  26552. t.chochangthai = 0x0e0a;
  26553. t.chochanthai = 0x0e08;
  26554. t.chochingthai = 0x0e09;
  26555. t.chochoethai = 0x0e0c;
  26556. t.chook = 0x0188;
  26557. t.cieucacirclekorean = 0x3276;
  26558. t.cieucaparenkorean = 0x3216;
  26559. t.cieuccirclekorean = 0x3268;
  26560. t.cieuckorean = 0x3148;
  26561. t.cieucparenkorean = 0x3208;
  26562. t.cieucuparenkorean = 0x321c;
  26563. t.circle = 0x25cb;
  26564. t.circlecopyrt = 0x00a9;
  26565. t.circlemultiply = 0x2297;
  26566. t.circleot = 0x2299;
  26567. t.circleplus = 0x2295;
  26568. t.circlepostalmark = 0x3036;
  26569. t.circlewithlefthalfblack = 0x25d0;
  26570. t.circlewithrighthalfblack = 0x25d1;
  26571. t.circumflex = 0x02c6;
  26572. t.circumflexbelowcmb = 0x032d;
  26573. t.circumflexcmb = 0x0302;
  26574. t.clear = 0x2327;
  26575. t.clickalveolar = 0x01c2;
  26576. t.clickdental = 0x01c0;
  26577. t.clicklateral = 0x01c1;
  26578. t.clickretroflex = 0x01c3;
  26579. t.club = 0x2663;
  26580. t.clubsuitblack = 0x2663;
  26581. t.clubsuitwhite = 0x2667;
  26582. t.cmcubedsquare = 0x33a4;
  26583. t.cmonospace = 0xff43;
  26584. t.cmsquaredsquare = 0x33a0;
  26585. t.coarmenian = 0x0581;
  26586. t.colon = 0x003a;
  26587. t.colonmonetary = 0x20a1;
  26588. t.colonmonospace = 0xff1a;
  26589. t.colonsign = 0x20a1;
  26590. t.colonsmall = 0xfe55;
  26591. t.colontriangularhalfmod = 0x02d1;
  26592. t.colontriangularmod = 0x02d0;
  26593. t.comma = 0x002c;
  26594. t.commaabovecmb = 0x0313;
  26595. t.commaaboverightcmb = 0x0315;
  26596. t.commaaccent = 0xf6c3;
  26597. t.commaarabic = 0x060c;
  26598. t.commaarmenian = 0x055d;
  26599. t.commainferior = 0xf6e1;
  26600. t.commamonospace = 0xff0c;
  26601. t.commareversedabovecmb = 0x0314;
  26602. t.commareversedmod = 0x02bd;
  26603. t.commasmall = 0xfe50;
  26604. t.commasuperior = 0xf6e2;
  26605. t.commaturnedabovecmb = 0x0312;
  26606. t.commaturnedmod = 0x02bb;
  26607. t.compass = 0x263c;
  26608. t.congruent = 0x2245;
  26609. t.contourintegral = 0x222e;
  26610. t.control = 0x2303;
  26611. t.controlACK = 0x0006;
  26612. t.controlBEL = 0x0007;
  26613. t.controlBS = 0x0008;
  26614. t.controlCAN = 0x0018;
  26615. t.controlCR = 0x000d;
  26616. t.controlDC1 = 0x0011;
  26617. t.controlDC2 = 0x0012;
  26618. t.controlDC3 = 0x0013;
  26619. t.controlDC4 = 0x0014;
  26620. t.controlDEL = 0x007f;
  26621. t.controlDLE = 0x0010;
  26622. t.controlEM = 0x0019;
  26623. t.controlENQ = 0x0005;
  26624. t.controlEOT = 0x0004;
  26625. t.controlESC = 0x001b;
  26626. t.controlETB = 0x0017;
  26627. t.controlETX = 0x0003;
  26628. t.controlFF = 0x000c;
  26629. t.controlFS = 0x001c;
  26630. t.controlGS = 0x001d;
  26631. t.controlHT = 0x0009;
  26632. t.controlLF = 0x000a;
  26633. t.controlNAK = 0x0015;
  26634. t.controlNULL = 0x0000;
  26635. t.controlRS = 0x001e;
  26636. t.controlSI = 0x000f;
  26637. t.controlSO = 0x000e;
  26638. t.controlSOT = 0x0002;
  26639. t.controlSTX = 0x0001;
  26640. t.controlSUB = 0x001a;
  26641. t.controlSYN = 0x0016;
  26642. t.controlUS = 0x001f;
  26643. t.controlVT = 0x000b;
  26644. t.copyright = 0x00a9;
  26645. t.copyrightsans = 0xf8e9;
  26646. t.copyrightserif = 0xf6d9;
  26647. t.cornerbracketleft = 0x300c;
  26648. t.cornerbracketlefthalfwidth = 0xff62;
  26649. t.cornerbracketleftvertical = 0xfe41;
  26650. t.cornerbracketright = 0x300d;
  26651. t.cornerbracketrighthalfwidth = 0xff63;
  26652. t.cornerbracketrightvertical = 0xfe42;
  26653. t.corporationsquare = 0x337f;
  26654. t.cosquare = 0x33c7;
  26655. t.coverkgsquare = 0x33c6;
  26656. t.cparen = 0x249e;
  26657. t.cruzeiro = 0x20a2;
  26658. t.cstretched = 0x0297;
  26659. t.curlyand = 0x22cf;
  26660. t.curlyor = 0x22ce;
  26661. t.currency = 0x00a4;
  26662. t.cyrBreve = 0xf6d1;
  26663. t.cyrFlex = 0xf6d2;
  26664. t.cyrbreve = 0xf6d4;
  26665. t.cyrflex = 0xf6d5;
  26666. t.d = 0x0064;
  26667. t.daarmenian = 0x0564;
  26668. t.dabengali = 0x09a6;
  26669. t.dadarabic = 0x0636;
  26670. t.dadeva = 0x0926;
  26671. t.dadfinalarabic = 0xfebe;
  26672. t.dadinitialarabic = 0xfebf;
  26673. t.dadmedialarabic = 0xfec0;
  26674. t.dagesh = 0x05bc;
  26675. t.dageshhebrew = 0x05bc;
  26676. t.dagger = 0x2020;
  26677. t.daggerdbl = 0x2021;
  26678. t.dagujarati = 0x0aa6;
  26679. t.dagurmukhi = 0x0a26;
  26680. t.dahiragana = 0x3060;
  26681. t.dakatakana = 0x30c0;
  26682. t.dalarabic = 0x062f;
  26683. t.dalet = 0x05d3;
  26684. t.daletdagesh = 0xfb33;
  26685. t.daletdageshhebrew = 0xfb33;
  26686. t.dalethebrew = 0x05d3;
  26687. t.dalfinalarabic = 0xfeaa;
  26688. t.dammaarabic = 0x064f;
  26689. t.dammalowarabic = 0x064f;
  26690. t.dammatanaltonearabic = 0x064c;
  26691. t.dammatanarabic = 0x064c;
  26692. t.danda = 0x0964;
  26693. t.dargahebrew = 0x05a7;
  26694. t.dargalefthebrew = 0x05a7;
  26695. t.dasiapneumatacyrilliccmb = 0x0485;
  26696. t.dblGrave = 0xf6d3;
  26697. t.dblanglebracketleft = 0x300a;
  26698. t.dblanglebracketleftvertical = 0xfe3d;
  26699. t.dblanglebracketright = 0x300b;
  26700. t.dblanglebracketrightvertical = 0xfe3e;
  26701. t.dblarchinvertedbelowcmb = 0x032b;
  26702. t.dblarrowleft = 0x21d4;
  26703. t.dblarrowright = 0x21d2;
  26704. t.dbldanda = 0x0965;
  26705. t.dblgrave = 0xf6d6;
  26706. t.dblgravecmb = 0x030f;
  26707. t.dblintegral = 0x222c;
  26708. t.dbllowline = 0x2017;
  26709. t.dbllowlinecmb = 0x0333;
  26710. t.dbloverlinecmb = 0x033f;
  26711. t.dblprimemod = 0x02ba;
  26712. t.dblverticalbar = 0x2016;
  26713. t.dblverticallineabovecmb = 0x030e;
  26714. t.dbopomofo = 0x3109;
  26715. t.dbsquare = 0x33c8;
  26716. t.dcaron = 0x010f;
  26717. t.dcedilla = 0x1e11;
  26718. t.dcircle = 0x24d3;
  26719. t.dcircumflexbelow = 0x1e13;
  26720. t.dcroat = 0x0111;
  26721. t.ddabengali = 0x09a1;
  26722. t.ddadeva = 0x0921;
  26723. t.ddagujarati = 0x0aa1;
  26724. t.ddagurmukhi = 0x0a21;
  26725. t.ddalarabic = 0x0688;
  26726. t.ddalfinalarabic = 0xfb89;
  26727. t.dddhadeva = 0x095c;
  26728. t.ddhabengali = 0x09a2;
  26729. t.ddhadeva = 0x0922;
  26730. t.ddhagujarati = 0x0aa2;
  26731. t.ddhagurmukhi = 0x0a22;
  26732. t.ddotaccent = 0x1e0b;
  26733. t.ddotbelow = 0x1e0d;
  26734. t.decimalseparatorarabic = 0x066b;
  26735. t.decimalseparatorpersian = 0x066b;
  26736. t.decyrillic = 0x0434;
  26737. t.degree = 0x00b0;
  26738. t.dehihebrew = 0x05ad;
  26739. t.dehiragana = 0x3067;
  26740. t.deicoptic = 0x03ef;
  26741. t.dekatakana = 0x30c7;
  26742. t.deleteleft = 0x232b;
  26743. t.deleteright = 0x2326;
  26744. t.delta = 0x03b4;
  26745. t.deltaturned = 0x018d;
  26746. t.denominatorminusonenumeratorbengali = 0x09f8;
  26747. t.dezh = 0x02a4;
  26748. t.dhabengali = 0x09a7;
  26749. t.dhadeva = 0x0927;
  26750. t.dhagujarati = 0x0aa7;
  26751. t.dhagurmukhi = 0x0a27;
  26752. t.dhook = 0x0257;
  26753. t.dialytikatonos = 0x0385;
  26754. t.dialytikatonoscmb = 0x0344;
  26755. t.diamond = 0x2666;
  26756. t.diamondsuitwhite = 0x2662;
  26757. t.dieresis = 0x00a8;
  26758. t.dieresisacute = 0xf6d7;
  26759. t.dieresisbelowcmb = 0x0324;
  26760. t.dieresiscmb = 0x0308;
  26761. t.dieresisgrave = 0xf6d8;
  26762. t.dieresistonos = 0x0385;
  26763. t.dihiragana = 0x3062;
  26764. t.dikatakana = 0x30c2;
  26765. t.dittomark = 0x3003;
  26766. t.divide = 0x00f7;
  26767. t.divides = 0x2223;
  26768. t.divisionslash = 0x2215;
  26769. t.djecyrillic = 0x0452;
  26770. t.dkshade = 0x2593;
  26771. t.dlinebelow = 0x1e0f;
  26772. t.dlsquare = 0x3397;
  26773. t.dmacron = 0x0111;
  26774. t.dmonospace = 0xff44;
  26775. t.dnblock = 0x2584;
  26776. t.dochadathai = 0x0e0e;
  26777. t.dodekthai = 0x0e14;
  26778. t.dohiragana = 0x3069;
  26779. t.dokatakana = 0x30c9;
  26780. t.dollar = 0x0024;
  26781. t.dollarinferior = 0xf6e3;
  26782. t.dollarmonospace = 0xff04;
  26783. t.dollaroldstyle = 0xf724;
  26784. t.dollarsmall = 0xfe69;
  26785. t.dollarsuperior = 0xf6e4;
  26786. t.dong = 0x20ab;
  26787. t.dorusquare = 0x3326;
  26788. t.dotaccent = 0x02d9;
  26789. t.dotaccentcmb = 0x0307;
  26790. t.dotbelowcmb = 0x0323;
  26791. t.dotbelowcomb = 0x0323;
  26792. t.dotkatakana = 0x30fb;
  26793. t.dotlessi = 0x0131;
  26794. t.dotlessj = 0xf6be;
  26795. t.dotlessjstrokehook = 0x0284;
  26796. t.dotmath = 0x22c5;
  26797. t.dottedcircle = 0x25cc;
  26798. t.doubleyodpatah = 0xfb1f;
  26799. t.doubleyodpatahhebrew = 0xfb1f;
  26800. t.downtackbelowcmb = 0x031e;
  26801. t.downtackmod = 0x02d5;
  26802. t.dparen = 0x249f;
  26803. t.dsuperior = 0xf6eb;
  26804. t.dtail = 0x0256;
  26805. t.dtopbar = 0x018c;
  26806. t.duhiragana = 0x3065;
  26807. t.dukatakana = 0x30c5;
  26808. t.dz = 0x01f3;
  26809. t.dzaltone = 0x02a3;
  26810. t.dzcaron = 0x01c6;
  26811. t.dzcurl = 0x02a5;
  26812. t.dzeabkhasiancyrillic = 0x04e1;
  26813. t.dzecyrillic = 0x0455;
  26814. t.dzhecyrillic = 0x045f;
  26815. t.e = 0x0065;
  26816. t.eacute = 0x00e9;
  26817. t.earth = 0x2641;
  26818. t.ebengali = 0x098f;
  26819. t.ebopomofo = 0x311c;
  26820. t.ebreve = 0x0115;
  26821. t.ecandradeva = 0x090d;
  26822. t.ecandragujarati = 0x0a8d;
  26823. t.ecandravowelsigndeva = 0x0945;
  26824. t.ecandravowelsigngujarati = 0x0ac5;
  26825. t.ecaron = 0x011b;
  26826. t.ecedillabreve = 0x1e1d;
  26827. t.echarmenian = 0x0565;
  26828. t.echyiwnarmenian = 0x0587;
  26829. t.ecircle = 0x24d4;
  26830. t.ecircumflex = 0x00ea;
  26831. t.ecircumflexacute = 0x1ebf;
  26832. t.ecircumflexbelow = 0x1e19;
  26833. t.ecircumflexdotbelow = 0x1ec7;
  26834. t.ecircumflexgrave = 0x1ec1;
  26835. t.ecircumflexhookabove = 0x1ec3;
  26836. t.ecircumflextilde = 0x1ec5;
  26837. t.ecyrillic = 0x0454;
  26838. t.edblgrave = 0x0205;
  26839. t.edeva = 0x090f;
  26840. t.edieresis = 0x00eb;
  26841. t.edot = 0x0117;
  26842. t.edotaccent = 0x0117;
  26843. t.edotbelow = 0x1eb9;
  26844. t.eegurmukhi = 0x0a0f;
  26845. t.eematragurmukhi = 0x0a47;
  26846. t.efcyrillic = 0x0444;
  26847. t.egrave = 0x00e8;
  26848. t.egujarati = 0x0a8f;
  26849. t.eharmenian = 0x0567;
  26850. t.ehbopomofo = 0x311d;
  26851. t.ehiragana = 0x3048;
  26852. t.ehookabove = 0x1ebb;
  26853. t.eibopomofo = 0x311f;
  26854. t.eight = 0x0038;
  26855. t.eightarabic = 0x0668;
  26856. t.eightbengali = 0x09ee;
  26857. t.eightcircle = 0x2467;
  26858. t.eightcircleinversesansserif = 0x2791;
  26859. t.eightdeva = 0x096e;
  26860. t.eighteencircle = 0x2471;
  26861. t.eighteenparen = 0x2485;
  26862. t.eighteenperiod = 0x2499;
  26863. t.eightgujarati = 0x0aee;
  26864. t.eightgurmukhi = 0x0a6e;
  26865. t.eighthackarabic = 0x0668;
  26866. t.eighthangzhou = 0x3028;
  26867. t.eighthnotebeamed = 0x266b;
  26868. t.eightideographicparen = 0x3227;
  26869. t.eightinferior = 0x2088;
  26870. t.eightmonospace = 0xff18;
  26871. t.eightoldstyle = 0xf738;
  26872. t.eightparen = 0x247b;
  26873. t.eightperiod = 0x248f;
  26874. t.eightpersian = 0x06f8;
  26875. t.eightroman = 0x2177;
  26876. t.eightsuperior = 0x2078;
  26877. t.eightthai = 0x0e58;
  26878. t.einvertedbreve = 0x0207;
  26879. t.eiotifiedcyrillic = 0x0465;
  26880. t.ekatakana = 0x30a8;
  26881. t.ekatakanahalfwidth = 0xff74;
  26882. t.ekonkargurmukhi = 0x0a74;
  26883. t.ekorean = 0x3154;
  26884. t.elcyrillic = 0x043b;
  26885. t.element = 0x2208;
  26886. t.elevencircle = 0x246a;
  26887. t.elevenparen = 0x247e;
  26888. t.elevenperiod = 0x2492;
  26889. t.elevenroman = 0x217a;
  26890. t.ellipsis = 0x2026;
  26891. t.ellipsisvertical = 0x22ee;
  26892. t.emacron = 0x0113;
  26893. t.emacronacute = 0x1e17;
  26894. t.emacrongrave = 0x1e15;
  26895. t.emcyrillic = 0x043c;
  26896. t.emdash = 0x2014;
  26897. t.emdashvertical = 0xfe31;
  26898. t.emonospace = 0xff45;
  26899. t.emphasismarkarmenian = 0x055b;
  26900. t.emptyset = 0x2205;
  26901. t.enbopomofo = 0x3123;
  26902. t.encyrillic = 0x043d;
  26903. t.endash = 0x2013;
  26904. t.endashvertical = 0xfe32;
  26905. t.endescendercyrillic = 0x04a3;
  26906. t.eng = 0x014b;
  26907. t.engbopomofo = 0x3125;
  26908. t.enghecyrillic = 0x04a5;
  26909. t.enhookcyrillic = 0x04c8;
  26910. t.enspace = 0x2002;
  26911. t.eogonek = 0x0119;
  26912. t.eokorean = 0x3153;
  26913. t.eopen = 0x025b;
  26914. t.eopenclosed = 0x029a;
  26915. t.eopenreversed = 0x025c;
  26916. t.eopenreversedclosed = 0x025e;
  26917. t.eopenreversedhook = 0x025d;
  26918. t.eparen = 0x24a0;
  26919. t.epsilon = 0x03b5;
  26920. t.epsilontonos = 0x03ad;
  26921. t.equal = 0x003d;
  26922. t.equalmonospace = 0xff1d;
  26923. t.equalsmall = 0xfe66;
  26924. t.equalsuperior = 0x207c;
  26925. t.equivalence = 0x2261;
  26926. t.erbopomofo = 0x3126;
  26927. t.ercyrillic = 0x0440;
  26928. t.ereversed = 0x0258;
  26929. t.ereversedcyrillic = 0x044d;
  26930. t.escyrillic = 0x0441;
  26931. t.esdescendercyrillic = 0x04ab;
  26932. t.esh = 0x0283;
  26933. t.eshcurl = 0x0286;
  26934. t.eshortdeva = 0x090e;
  26935. t.eshortvowelsigndeva = 0x0946;
  26936. t.eshreversedloop = 0x01aa;
  26937. t.eshsquatreversed = 0x0285;
  26938. t.esmallhiragana = 0x3047;
  26939. t.esmallkatakana = 0x30a7;
  26940. t.esmallkatakanahalfwidth = 0xff6a;
  26941. t.estimated = 0x212e;
  26942. t.esuperior = 0xf6ec;
  26943. t.eta = 0x03b7;
  26944. t.etarmenian = 0x0568;
  26945. t.etatonos = 0x03ae;
  26946. t.eth = 0x00f0;
  26947. t.etilde = 0x1ebd;
  26948. t.etildebelow = 0x1e1b;
  26949. t.etnahtafoukhhebrew = 0x0591;
  26950. t.etnahtafoukhlefthebrew = 0x0591;
  26951. t.etnahtahebrew = 0x0591;
  26952. t.etnahtalefthebrew = 0x0591;
  26953. t.eturned = 0x01dd;
  26954. t.eukorean = 0x3161;
  26955. t.euro = 0x20ac;
  26956. t.evowelsignbengali = 0x09c7;
  26957. t.evowelsigndeva = 0x0947;
  26958. t.evowelsigngujarati = 0x0ac7;
  26959. t.exclam = 0x0021;
  26960. t.exclamarmenian = 0x055c;
  26961. t.exclamdbl = 0x203c;
  26962. t.exclamdown = 0x00a1;
  26963. t.exclamdownsmall = 0xf7a1;
  26964. t.exclammonospace = 0xff01;
  26965. t.exclamsmall = 0xf721;
  26966. t.existential = 0x2203;
  26967. t.ezh = 0x0292;
  26968. t.ezhcaron = 0x01ef;
  26969. t.ezhcurl = 0x0293;
  26970. t.ezhreversed = 0x01b9;
  26971. t.ezhtail = 0x01ba;
  26972. t.f = 0x0066;
  26973. t.fadeva = 0x095e;
  26974. t.fagurmukhi = 0x0a5e;
  26975. t.fahrenheit = 0x2109;
  26976. t.fathaarabic = 0x064e;
  26977. t.fathalowarabic = 0x064e;
  26978. t.fathatanarabic = 0x064b;
  26979. t.fbopomofo = 0x3108;
  26980. t.fcircle = 0x24d5;
  26981. t.fdotaccent = 0x1e1f;
  26982. t.feharabic = 0x0641;
  26983. t.feharmenian = 0x0586;
  26984. t.fehfinalarabic = 0xfed2;
  26985. t.fehinitialarabic = 0xfed3;
  26986. t.fehmedialarabic = 0xfed4;
  26987. t.feicoptic = 0x03e5;
  26988. t.female = 0x2640;
  26989. t.ff = 0xfb00;
  26990. t.f_f = 0xfb00;
  26991. t.ffi = 0xfb03;
  26992. t.f_f_i = 0xfb03;
  26993. t.ffl = 0xfb04;
  26994. t.f_f_l = 0xfb04;
  26995. t.fi = 0xfb01;
  26996. t.f_i = 0xfb01;
  26997. t.fifteencircle = 0x246e;
  26998. t.fifteenparen = 0x2482;
  26999. t.fifteenperiod = 0x2496;
  27000. t.figuredash = 0x2012;
  27001. t.filledbox = 0x25a0;
  27002. t.filledrect = 0x25ac;
  27003. t.finalkaf = 0x05da;
  27004. t.finalkafdagesh = 0xfb3a;
  27005. t.finalkafdageshhebrew = 0xfb3a;
  27006. t.finalkafhebrew = 0x05da;
  27007. t.finalmem = 0x05dd;
  27008. t.finalmemhebrew = 0x05dd;
  27009. t.finalnun = 0x05df;
  27010. t.finalnunhebrew = 0x05df;
  27011. t.finalpe = 0x05e3;
  27012. t.finalpehebrew = 0x05e3;
  27013. t.finaltsadi = 0x05e5;
  27014. t.finaltsadihebrew = 0x05e5;
  27015. t.firsttonechinese = 0x02c9;
  27016. t.fisheye = 0x25c9;
  27017. t.fitacyrillic = 0x0473;
  27018. t.five = 0x0035;
  27019. t.fivearabic = 0x0665;
  27020. t.fivebengali = 0x09eb;
  27021. t.fivecircle = 0x2464;
  27022. t.fivecircleinversesansserif = 0x278e;
  27023. t.fivedeva = 0x096b;
  27024. t.fiveeighths = 0x215d;
  27025. t.fivegujarati = 0x0aeb;
  27026. t.fivegurmukhi = 0x0a6b;
  27027. t.fivehackarabic = 0x0665;
  27028. t.fivehangzhou = 0x3025;
  27029. t.fiveideographicparen = 0x3224;
  27030. t.fiveinferior = 0x2085;
  27031. t.fivemonospace = 0xff15;
  27032. t.fiveoldstyle = 0xf735;
  27033. t.fiveparen = 0x2478;
  27034. t.fiveperiod = 0x248c;
  27035. t.fivepersian = 0x06f5;
  27036. t.fiveroman = 0x2174;
  27037. t.fivesuperior = 0x2075;
  27038. t.fivethai = 0x0e55;
  27039. t.fl = 0xfb02;
  27040. t.f_l = 0xfb02;
  27041. t.florin = 0x0192;
  27042. t.fmonospace = 0xff46;
  27043. t.fmsquare = 0x3399;
  27044. t.fofanthai = 0x0e1f;
  27045. t.fofathai = 0x0e1d;
  27046. t.fongmanthai = 0x0e4f;
  27047. t.forall = 0x2200;
  27048. t.four = 0x0034;
  27049. t.fourarabic = 0x0664;
  27050. t.fourbengali = 0x09ea;
  27051. t.fourcircle = 0x2463;
  27052. t.fourcircleinversesansserif = 0x278d;
  27053. t.fourdeva = 0x096a;
  27054. t.fourgujarati = 0x0aea;
  27055. t.fourgurmukhi = 0x0a6a;
  27056. t.fourhackarabic = 0x0664;
  27057. t.fourhangzhou = 0x3024;
  27058. t.fourideographicparen = 0x3223;
  27059. t.fourinferior = 0x2084;
  27060. t.fourmonospace = 0xff14;
  27061. t.fournumeratorbengali = 0x09f7;
  27062. t.fouroldstyle = 0xf734;
  27063. t.fourparen = 0x2477;
  27064. t.fourperiod = 0x248b;
  27065. t.fourpersian = 0x06f4;
  27066. t.fourroman = 0x2173;
  27067. t.foursuperior = 0x2074;
  27068. t.fourteencircle = 0x246d;
  27069. t.fourteenparen = 0x2481;
  27070. t.fourteenperiod = 0x2495;
  27071. t.fourthai = 0x0e54;
  27072. t.fourthtonechinese = 0x02cb;
  27073. t.fparen = 0x24a1;
  27074. t.fraction = 0x2044;
  27075. t.franc = 0x20a3;
  27076. t.g = 0x0067;
  27077. t.gabengali = 0x0997;
  27078. t.gacute = 0x01f5;
  27079. t.gadeva = 0x0917;
  27080. t.gafarabic = 0x06af;
  27081. t.gaffinalarabic = 0xfb93;
  27082. t.gafinitialarabic = 0xfb94;
  27083. t.gafmedialarabic = 0xfb95;
  27084. t.gagujarati = 0x0a97;
  27085. t.gagurmukhi = 0x0a17;
  27086. t.gahiragana = 0x304c;
  27087. t.gakatakana = 0x30ac;
  27088. t.gamma = 0x03b3;
  27089. t.gammalatinsmall = 0x0263;
  27090. t.gammasuperior = 0x02e0;
  27091. t.gangiacoptic = 0x03eb;
  27092. t.gbopomofo = 0x310d;
  27093. t.gbreve = 0x011f;
  27094. t.gcaron = 0x01e7;
  27095. t.gcedilla = 0x0123;
  27096. t.gcircle = 0x24d6;
  27097. t.gcircumflex = 0x011d;
  27098. t.gcommaaccent = 0x0123;
  27099. t.gdot = 0x0121;
  27100. t.gdotaccent = 0x0121;
  27101. t.gecyrillic = 0x0433;
  27102. t.gehiragana = 0x3052;
  27103. t.gekatakana = 0x30b2;
  27104. t.geometricallyequal = 0x2251;
  27105. t.gereshaccenthebrew = 0x059c;
  27106. t.gereshhebrew = 0x05f3;
  27107. t.gereshmuqdamhebrew = 0x059d;
  27108. t.germandbls = 0x00df;
  27109. t.gershayimaccenthebrew = 0x059e;
  27110. t.gershayimhebrew = 0x05f4;
  27111. t.getamark = 0x3013;
  27112. t.ghabengali = 0x0998;
  27113. t.ghadarmenian = 0x0572;
  27114. t.ghadeva = 0x0918;
  27115. t.ghagujarati = 0x0a98;
  27116. t.ghagurmukhi = 0x0a18;
  27117. t.ghainarabic = 0x063a;
  27118. t.ghainfinalarabic = 0xfece;
  27119. t.ghaininitialarabic = 0xfecf;
  27120. t.ghainmedialarabic = 0xfed0;
  27121. t.ghemiddlehookcyrillic = 0x0495;
  27122. t.ghestrokecyrillic = 0x0493;
  27123. t.gheupturncyrillic = 0x0491;
  27124. t.ghhadeva = 0x095a;
  27125. t.ghhagurmukhi = 0x0a5a;
  27126. t.ghook = 0x0260;
  27127. t.ghzsquare = 0x3393;
  27128. t.gihiragana = 0x304e;
  27129. t.gikatakana = 0x30ae;
  27130. t.gimarmenian = 0x0563;
  27131. t.gimel = 0x05d2;
  27132. t.gimeldagesh = 0xfb32;
  27133. t.gimeldageshhebrew = 0xfb32;
  27134. t.gimelhebrew = 0x05d2;
  27135. t.gjecyrillic = 0x0453;
  27136. t.glottalinvertedstroke = 0x01be;
  27137. t.glottalstop = 0x0294;
  27138. t.glottalstopinverted = 0x0296;
  27139. t.glottalstopmod = 0x02c0;
  27140. t.glottalstopreversed = 0x0295;
  27141. t.glottalstopreversedmod = 0x02c1;
  27142. t.glottalstopreversedsuperior = 0x02e4;
  27143. t.glottalstopstroke = 0x02a1;
  27144. t.glottalstopstrokereversed = 0x02a2;
  27145. t.gmacron = 0x1e21;
  27146. t.gmonospace = 0xff47;
  27147. t.gohiragana = 0x3054;
  27148. t.gokatakana = 0x30b4;
  27149. t.gparen = 0x24a2;
  27150. t.gpasquare = 0x33ac;
  27151. t.gradient = 0x2207;
  27152. t.grave = 0x0060;
  27153. t.gravebelowcmb = 0x0316;
  27154. t.gravecmb = 0x0300;
  27155. t.gravecomb = 0x0300;
  27156. t.gravedeva = 0x0953;
  27157. t.gravelowmod = 0x02ce;
  27158. t.gravemonospace = 0xff40;
  27159. t.gravetonecmb = 0x0340;
  27160. t.greater = 0x003e;
  27161. t.greaterequal = 0x2265;
  27162. t.greaterequalorless = 0x22db;
  27163. t.greatermonospace = 0xff1e;
  27164. t.greaterorequivalent = 0x2273;
  27165. t.greaterorless = 0x2277;
  27166. t.greateroverequal = 0x2267;
  27167. t.greatersmall = 0xfe65;
  27168. t.gscript = 0x0261;
  27169. t.gstroke = 0x01e5;
  27170. t.guhiragana = 0x3050;
  27171. t.guillemotleft = 0x00ab;
  27172. t.guillemotright = 0x00bb;
  27173. t.guilsinglleft = 0x2039;
  27174. t.guilsinglright = 0x203a;
  27175. t.gukatakana = 0x30b0;
  27176. t.guramusquare = 0x3318;
  27177. t.gysquare = 0x33c9;
  27178. t.h = 0x0068;
  27179. t.haabkhasiancyrillic = 0x04a9;
  27180. t.haaltonearabic = 0x06c1;
  27181. t.habengali = 0x09b9;
  27182. t.hadescendercyrillic = 0x04b3;
  27183. t.hadeva = 0x0939;
  27184. t.hagujarati = 0x0ab9;
  27185. t.hagurmukhi = 0x0a39;
  27186. t.haharabic = 0x062d;
  27187. t.hahfinalarabic = 0xfea2;
  27188. t.hahinitialarabic = 0xfea3;
  27189. t.hahiragana = 0x306f;
  27190. t.hahmedialarabic = 0xfea4;
  27191. t.haitusquare = 0x332a;
  27192. t.hakatakana = 0x30cf;
  27193. t.hakatakanahalfwidth = 0xff8a;
  27194. t.halantgurmukhi = 0x0a4d;
  27195. t.hamzaarabic = 0x0621;
  27196. t.hamzalowarabic = 0x0621;
  27197. t.hangulfiller = 0x3164;
  27198. t.hardsigncyrillic = 0x044a;
  27199. t.harpoonleftbarbup = 0x21bc;
  27200. t.harpoonrightbarbup = 0x21c0;
  27201. t.hasquare = 0x33ca;
  27202. t.hatafpatah = 0x05b2;
  27203. t.hatafpatah16 = 0x05b2;
  27204. t.hatafpatah23 = 0x05b2;
  27205. t.hatafpatah2f = 0x05b2;
  27206. t.hatafpatahhebrew = 0x05b2;
  27207. t.hatafpatahnarrowhebrew = 0x05b2;
  27208. t.hatafpatahquarterhebrew = 0x05b2;
  27209. t.hatafpatahwidehebrew = 0x05b2;
  27210. t.hatafqamats = 0x05b3;
  27211. t.hatafqamats1b = 0x05b3;
  27212. t.hatafqamats28 = 0x05b3;
  27213. t.hatafqamats34 = 0x05b3;
  27214. t.hatafqamatshebrew = 0x05b3;
  27215. t.hatafqamatsnarrowhebrew = 0x05b3;
  27216. t.hatafqamatsquarterhebrew = 0x05b3;
  27217. t.hatafqamatswidehebrew = 0x05b3;
  27218. t.hatafsegol = 0x05b1;
  27219. t.hatafsegol17 = 0x05b1;
  27220. t.hatafsegol24 = 0x05b1;
  27221. t.hatafsegol30 = 0x05b1;
  27222. t.hatafsegolhebrew = 0x05b1;
  27223. t.hatafsegolnarrowhebrew = 0x05b1;
  27224. t.hatafsegolquarterhebrew = 0x05b1;
  27225. t.hatafsegolwidehebrew = 0x05b1;
  27226. t.hbar = 0x0127;
  27227. t.hbopomofo = 0x310f;
  27228. t.hbrevebelow = 0x1e2b;
  27229. t.hcedilla = 0x1e29;
  27230. t.hcircle = 0x24d7;
  27231. t.hcircumflex = 0x0125;
  27232. t.hdieresis = 0x1e27;
  27233. t.hdotaccent = 0x1e23;
  27234. t.hdotbelow = 0x1e25;
  27235. t.he = 0x05d4;
  27236. t.heart = 0x2665;
  27237. t.heartsuitblack = 0x2665;
  27238. t.heartsuitwhite = 0x2661;
  27239. t.hedagesh = 0xfb34;
  27240. t.hedageshhebrew = 0xfb34;
  27241. t.hehaltonearabic = 0x06c1;
  27242. t.heharabic = 0x0647;
  27243. t.hehebrew = 0x05d4;
  27244. t.hehfinalaltonearabic = 0xfba7;
  27245. t.hehfinalalttwoarabic = 0xfeea;
  27246. t.hehfinalarabic = 0xfeea;
  27247. t.hehhamzaabovefinalarabic = 0xfba5;
  27248. t.hehhamzaaboveisolatedarabic = 0xfba4;
  27249. t.hehinitialaltonearabic = 0xfba8;
  27250. t.hehinitialarabic = 0xfeeb;
  27251. t.hehiragana = 0x3078;
  27252. t.hehmedialaltonearabic = 0xfba9;
  27253. t.hehmedialarabic = 0xfeec;
  27254. t.heiseierasquare = 0x337b;
  27255. t.hekatakana = 0x30d8;
  27256. t.hekatakanahalfwidth = 0xff8d;
  27257. t.hekutaarusquare = 0x3336;
  27258. t.henghook = 0x0267;
  27259. t.herutusquare = 0x3339;
  27260. t.het = 0x05d7;
  27261. t.hethebrew = 0x05d7;
  27262. t.hhook = 0x0266;
  27263. t.hhooksuperior = 0x02b1;
  27264. t.hieuhacirclekorean = 0x327b;
  27265. t.hieuhaparenkorean = 0x321b;
  27266. t.hieuhcirclekorean = 0x326d;
  27267. t.hieuhkorean = 0x314e;
  27268. t.hieuhparenkorean = 0x320d;
  27269. t.hihiragana = 0x3072;
  27270. t.hikatakana = 0x30d2;
  27271. t.hikatakanahalfwidth = 0xff8b;
  27272. t.hiriq = 0x05b4;
  27273. t.hiriq14 = 0x05b4;
  27274. t.hiriq21 = 0x05b4;
  27275. t.hiriq2d = 0x05b4;
  27276. t.hiriqhebrew = 0x05b4;
  27277. t.hiriqnarrowhebrew = 0x05b4;
  27278. t.hiriqquarterhebrew = 0x05b4;
  27279. t.hiriqwidehebrew = 0x05b4;
  27280. t.hlinebelow = 0x1e96;
  27281. t.hmonospace = 0xff48;
  27282. t.hoarmenian = 0x0570;
  27283. t.hohipthai = 0x0e2b;
  27284. t.hohiragana = 0x307b;
  27285. t.hokatakana = 0x30db;
  27286. t.hokatakanahalfwidth = 0xff8e;
  27287. t.holam = 0x05b9;
  27288. t.holam19 = 0x05b9;
  27289. t.holam26 = 0x05b9;
  27290. t.holam32 = 0x05b9;
  27291. t.holamhebrew = 0x05b9;
  27292. t.holamnarrowhebrew = 0x05b9;
  27293. t.holamquarterhebrew = 0x05b9;
  27294. t.holamwidehebrew = 0x05b9;
  27295. t.honokhukthai = 0x0e2e;
  27296. t.hookabovecomb = 0x0309;
  27297. t.hookcmb = 0x0309;
  27298. t.hookpalatalizedbelowcmb = 0x0321;
  27299. t.hookretroflexbelowcmb = 0x0322;
  27300. t.hoonsquare = 0x3342;
  27301. t.horicoptic = 0x03e9;
  27302. t.horizontalbar = 0x2015;
  27303. t.horncmb = 0x031b;
  27304. t.hotsprings = 0x2668;
  27305. t.house = 0x2302;
  27306. t.hparen = 0x24a3;
  27307. t.hsuperior = 0x02b0;
  27308. t.hturned = 0x0265;
  27309. t.huhiragana = 0x3075;
  27310. t.huiitosquare = 0x3333;
  27311. t.hukatakana = 0x30d5;
  27312. t.hukatakanahalfwidth = 0xff8c;
  27313. t.hungarumlaut = 0x02dd;
  27314. t.hungarumlautcmb = 0x030b;
  27315. t.hv = 0x0195;
  27316. t.hyphen = 0x002d;
  27317. t.hypheninferior = 0xf6e5;
  27318. t.hyphenmonospace = 0xff0d;
  27319. t.hyphensmall = 0xfe63;
  27320. t.hyphensuperior = 0xf6e6;
  27321. t.hyphentwo = 0x2010;
  27322. t.i = 0x0069;
  27323. t.iacute = 0x00ed;
  27324. t.iacyrillic = 0x044f;
  27325. t.ibengali = 0x0987;
  27326. t.ibopomofo = 0x3127;
  27327. t.ibreve = 0x012d;
  27328. t.icaron = 0x01d0;
  27329. t.icircle = 0x24d8;
  27330. t.icircumflex = 0x00ee;
  27331. t.icyrillic = 0x0456;
  27332. t.idblgrave = 0x0209;
  27333. t.ideographearthcircle = 0x328f;
  27334. t.ideographfirecircle = 0x328b;
  27335. t.ideographicallianceparen = 0x323f;
  27336. t.ideographiccallparen = 0x323a;
  27337. t.ideographiccentrecircle = 0x32a5;
  27338. t.ideographicclose = 0x3006;
  27339. t.ideographiccomma = 0x3001;
  27340. t.ideographiccommaleft = 0xff64;
  27341. t.ideographiccongratulationparen = 0x3237;
  27342. t.ideographiccorrectcircle = 0x32a3;
  27343. t.ideographicearthparen = 0x322f;
  27344. t.ideographicenterpriseparen = 0x323d;
  27345. t.ideographicexcellentcircle = 0x329d;
  27346. t.ideographicfestivalparen = 0x3240;
  27347. t.ideographicfinancialcircle = 0x3296;
  27348. t.ideographicfinancialparen = 0x3236;
  27349. t.ideographicfireparen = 0x322b;
  27350. t.ideographichaveparen = 0x3232;
  27351. t.ideographichighcircle = 0x32a4;
  27352. t.ideographiciterationmark = 0x3005;
  27353. t.ideographiclaborcircle = 0x3298;
  27354. t.ideographiclaborparen = 0x3238;
  27355. t.ideographicleftcircle = 0x32a7;
  27356. t.ideographiclowcircle = 0x32a6;
  27357. t.ideographicmedicinecircle = 0x32a9;
  27358. t.ideographicmetalparen = 0x322e;
  27359. t.ideographicmoonparen = 0x322a;
  27360. t.ideographicnameparen = 0x3234;
  27361. t.ideographicperiod = 0x3002;
  27362. t.ideographicprintcircle = 0x329e;
  27363. t.ideographicreachparen = 0x3243;
  27364. t.ideographicrepresentparen = 0x3239;
  27365. t.ideographicresourceparen = 0x323e;
  27366. t.ideographicrightcircle = 0x32a8;
  27367. t.ideographicsecretcircle = 0x3299;
  27368. t.ideographicselfparen = 0x3242;
  27369. t.ideographicsocietyparen = 0x3233;
  27370. t.ideographicspace = 0x3000;
  27371. t.ideographicspecialparen = 0x3235;
  27372. t.ideographicstockparen = 0x3231;
  27373. t.ideographicstudyparen = 0x323b;
  27374. t.ideographicsunparen = 0x3230;
  27375. t.ideographicsuperviseparen = 0x323c;
  27376. t.ideographicwaterparen = 0x322c;
  27377. t.ideographicwoodparen = 0x322d;
  27378. t.ideographiczero = 0x3007;
  27379. t.ideographmetalcircle = 0x328e;
  27380. t.ideographmooncircle = 0x328a;
  27381. t.ideographnamecircle = 0x3294;
  27382. t.ideographsuncircle = 0x3290;
  27383. t.ideographwatercircle = 0x328c;
  27384. t.ideographwoodcircle = 0x328d;
  27385. t.ideva = 0x0907;
  27386. t.idieresis = 0x00ef;
  27387. t.idieresisacute = 0x1e2f;
  27388. t.idieresiscyrillic = 0x04e5;
  27389. t.idotbelow = 0x1ecb;
  27390. t.iebrevecyrillic = 0x04d7;
  27391. t.iecyrillic = 0x0435;
  27392. t.ieungacirclekorean = 0x3275;
  27393. t.ieungaparenkorean = 0x3215;
  27394. t.ieungcirclekorean = 0x3267;
  27395. t.ieungkorean = 0x3147;
  27396. t.ieungparenkorean = 0x3207;
  27397. t.igrave = 0x00ec;
  27398. t.igujarati = 0x0a87;
  27399. t.igurmukhi = 0x0a07;
  27400. t.ihiragana = 0x3044;
  27401. t.ihookabove = 0x1ec9;
  27402. t.iibengali = 0x0988;
  27403. t.iicyrillic = 0x0438;
  27404. t.iideva = 0x0908;
  27405. t.iigujarati = 0x0a88;
  27406. t.iigurmukhi = 0x0a08;
  27407. t.iimatragurmukhi = 0x0a40;
  27408. t.iinvertedbreve = 0x020b;
  27409. t.iishortcyrillic = 0x0439;
  27410. t.iivowelsignbengali = 0x09c0;
  27411. t.iivowelsigndeva = 0x0940;
  27412. t.iivowelsigngujarati = 0x0ac0;
  27413. t.ij = 0x0133;
  27414. t.ikatakana = 0x30a4;
  27415. t.ikatakanahalfwidth = 0xff72;
  27416. t.ikorean = 0x3163;
  27417. t.ilde = 0x02dc;
  27418. t.iluyhebrew = 0x05ac;
  27419. t.imacron = 0x012b;
  27420. t.imacroncyrillic = 0x04e3;
  27421. t.imageorapproximatelyequal = 0x2253;
  27422. t.imatragurmukhi = 0x0a3f;
  27423. t.imonospace = 0xff49;
  27424. t.increment = 0x2206;
  27425. t.infinity = 0x221e;
  27426. t.iniarmenian = 0x056b;
  27427. t.integral = 0x222b;
  27428. t.integralbottom = 0x2321;
  27429. t.integralbt = 0x2321;
  27430. t.integralex = 0xf8f5;
  27431. t.integraltop = 0x2320;
  27432. t.integraltp = 0x2320;
  27433. t.intersection = 0x2229;
  27434. t.intisquare = 0x3305;
  27435. t.invbullet = 0x25d8;
  27436. t.invcircle = 0x25d9;
  27437. t.invsmileface = 0x263b;
  27438. t.iocyrillic = 0x0451;
  27439. t.iogonek = 0x012f;
  27440. t.iota = 0x03b9;
  27441. t.iotadieresis = 0x03ca;
  27442. t.iotadieresistonos = 0x0390;
  27443. t.iotalatin = 0x0269;
  27444. t.iotatonos = 0x03af;
  27445. t.iparen = 0x24a4;
  27446. t.irigurmukhi = 0x0a72;
  27447. t.ismallhiragana = 0x3043;
  27448. t.ismallkatakana = 0x30a3;
  27449. t.ismallkatakanahalfwidth = 0xff68;
  27450. t.issharbengali = 0x09fa;
  27451. t.istroke = 0x0268;
  27452. t.isuperior = 0xf6ed;
  27453. t.iterationhiragana = 0x309d;
  27454. t.iterationkatakana = 0x30fd;
  27455. t.itilde = 0x0129;
  27456. t.itildebelow = 0x1e2d;
  27457. t.iubopomofo = 0x3129;
  27458. t.iucyrillic = 0x044e;
  27459. t.ivowelsignbengali = 0x09bf;
  27460. t.ivowelsigndeva = 0x093f;
  27461. t.ivowelsigngujarati = 0x0abf;
  27462. t.izhitsacyrillic = 0x0475;
  27463. t.izhitsadblgravecyrillic = 0x0477;
  27464. t.j = 0x006a;
  27465. t.jaarmenian = 0x0571;
  27466. t.jabengali = 0x099c;
  27467. t.jadeva = 0x091c;
  27468. t.jagujarati = 0x0a9c;
  27469. t.jagurmukhi = 0x0a1c;
  27470. t.jbopomofo = 0x3110;
  27471. t.jcaron = 0x01f0;
  27472. t.jcircle = 0x24d9;
  27473. t.jcircumflex = 0x0135;
  27474. t.jcrossedtail = 0x029d;
  27475. t.jdotlessstroke = 0x025f;
  27476. t.jecyrillic = 0x0458;
  27477. t.jeemarabic = 0x062c;
  27478. t.jeemfinalarabic = 0xfe9e;
  27479. t.jeeminitialarabic = 0xfe9f;
  27480. t.jeemmedialarabic = 0xfea0;
  27481. t.jeharabic = 0x0698;
  27482. t.jehfinalarabic = 0xfb8b;
  27483. t.jhabengali = 0x099d;
  27484. t.jhadeva = 0x091d;
  27485. t.jhagujarati = 0x0a9d;
  27486. t.jhagurmukhi = 0x0a1d;
  27487. t.jheharmenian = 0x057b;
  27488. t.jis = 0x3004;
  27489. t.jmonospace = 0xff4a;
  27490. t.jparen = 0x24a5;
  27491. t.jsuperior = 0x02b2;
  27492. t.k = 0x006b;
  27493. t.kabashkircyrillic = 0x04a1;
  27494. t.kabengali = 0x0995;
  27495. t.kacute = 0x1e31;
  27496. t.kacyrillic = 0x043a;
  27497. t.kadescendercyrillic = 0x049b;
  27498. t.kadeva = 0x0915;
  27499. t.kaf = 0x05db;
  27500. t.kafarabic = 0x0643;
  27501. t.kafdagesh = 0xfb3b;
  27502. t.kafdageshhebrew = 0xfb3b;
  27503. t.kaffinalarabic = 0xfeda;
  27504. t.kafhebrew = 0x05db;
  27505. t.kafinitialarabic = 0xfedb;
  27506. t.kafmedialarabic = 0xfedc;
  27507. t.kafrafehebrew = 0xfb4d;
  27508. t.kagujarati = 0x0a95;
  27509. t.kagurmukhi = 0x0a15;
  27510. t.kahiragana = 0x304b;
  27511. t.kahookcyrillic = 0x04c4;
  27512. t.kakatakana = 0x30ab;
  27513. t.kakatakanahalfwidth = 0xff76;
  27514. t.kappa = 0x03ba;
  27515. t.kappasymbolgreek = 0x03f0;
  27516. t.kapyeounmieumkorean = 0x3171;
  27517. t.kapyeounphieuphkorean = 0x3184;
  27518. t.kapyeounpieupkorean = 0x3178;
  27519. t.kapyeounssangpieupkorean = 0x3179;
  27520. t.karoriisquare = 0x330d;
  27521. t.kashidaautoarabic = 0x0640;
  27522. t.kashidaautonosidebearingarabic = 0x0640;
  27523. t.kasmallkatakana = 0x30f5;
  27524. t.kasquare = 0x3384;
  27525. t.kasraarabic = 0x0650;
  27526. t.kasratanarabic = 0x064d;
  27527. t.kastrokecyrillic = 0x049f;
  27528. t.katahiraprolongmarkhalfwidth = 0xff70;
  27529. t.kaverticalstrokecyrillic = 0x049d;
  27530. t.kbopomofo = 0x310e;
  27531. t.kcalsquare = 0x3389;
  27532. t.kcaron = 0x01e9;
  27533. t.kcedilla = 0x0137;
  27534. t.kcircle = 0x24da;
  27535. t.kcommaaccent = 0x0137;
  27536. t.kdotbelow = 0x1e33;
  27537. t.keharmenian = 0x0584;
  27538. t.kehiragana = 0x3051;
  27539. t.kekatakana = 0x30b1;
  27540. t.kekatakanahalfwidth = 0xff79;
  27541. t.kenarmenian = 0x056f;
  27542. t.kesmallkatakana = 0x30f6;
  27543. t.kgreenlandic = 0x0138;
  27544. t.khabengali = 0x0996;
  27545. t.khacyrillic = 0x0445;
  27546. t.khadeva = 0x0916;
  27547. t.khagujarati = 0x0a96;
  27548. t.khagurmukhi = 0x0a16;
  27549. t.khaharabic = 0x062e;
  27550. t.khahfinalarabic = 0xfea6;
  27551. t.khahinitialarabic = 0xfea7;
  27552. t.khahmedialarabic = 0xfea8;
  27553. t.kheicoptic = 0x03e7;
  27554. t.khhadeva = 0x0959;
  27555. t.khhagurmukhi = 0x0a59;
  27556. t.khieukhacirclekorean = 0x3278;
  27557. t.khieukhaparenkorean = 0x3218;
  27558. t.khieukhcirclekorean = 0x326a;
  27559. t.khieukhkorean = 0x314b;
  27560. t.khieukhparenkorean = 0x320a;
  27561. t.khokhaithai = 0x0e02;
  27562. t.khokhonthai = 0x0e05;
  27563. t.khokhuatthai = 0x0e03;
  27564. t.khokhwaithai = 0x0e04;
  27565. t.khomutthai = 0x0e5b;
  27566. t.khook = 0x0199;
  27567. t.khorakhangthai = 0x0e06;
  27568. t.khzsquare = 0x3391;
  27569. t.kihiragana = 0x304d;
  27570. t.kikatakana = 0x30ad;
  27571. t.kikatakanahalfwidth = 0xff77;
  27572. t.kiroguramusquare = 0x3315;
  27573. t.kiromeetorusquare = 0x3316;
  27574. t.kirosquare = 0x3314;
  27575. t.kiyeokacirclekorean = 0x326e;
  27576. t.kiyeokaparenkorean = 0x320e;
  27577. t.kiyeokcirclekorean = 0x3260;
  27578. t.kiyeokkorean = 0x3131;
  27579. t.kiyeokparenkorean = 0x3200;
  27580. t.kiyeoksioskorean = 0x3133;
  27581. t.kjecyrillic = 0x045c;
  27582. t.klinebelow = 0x1e35;
  27583. t.klsquare = 0x3398;
  27584. t.kmcubedsquare = 0x33a6;
  27585. t.kmonospace = 0xff4b;
  27586. t.kmsquaredsquare = 0x33a2;
  27587. t.kohiragana = 0x3053;
  27588. t.kohmsquare = 0x33c0;
  27589. t.kokaithai = 0x0e01;
  27590. t.kokatakana = 0x30b3;
  27591. t.kokatakanahalfwidth = 0xff7a;
  27592. t.kooposquare = 0x331e;
  27593. t.koppacyrillic = 0x0481;
  27594. t.koreanstandardsymbol = 0x327f;
  27595. t.koroniscmb = 0x0343;
  27596. t.kparen = 0x24a6;
  27597. t.kpasquare = 0x33aa;
  27598. t.ksicyrillic = 0x046f;
  27599. t.ktsquare = 0x33cf;
  27600. t.kturned = 0x029e;
  27601. t.kuhiragana = 0x304f;
  27602. t.kukatakana = 0x30af;
  27603. t.kukatakanahalfwidth = 0xff78;
  27604. t.kvsquare = 0x33b8;
  27605. t.kwsquare = 0x33be;
  27606. t.l = 0x006c;
  27607. t.labengali = 0x09b2;
  27608. t.lacute = 0x013a;
  27609. t.ladeva = 0x0932;
  27610. t.lagujarati = 0x0ab2;
  27611. t.lagurmukhi = 0x0a32;
  27612. t.lakkhangyaothai = 0x0e45;
  27613. t.lamaleffinalarabic = 0xfefc;
  27614. t.lamalefhamzaabovefinalarabic = 0xfef8;
  27615. t.lamalefhamzaaboveisolatedarabic = 0xfef7;
  27616. t.lamalefhamzabelowfinalarabic = 0xfefa;
  27617. t.lamalefhamzabelowisolatedarabic = 0xfef9;
  27618. t.lamalefisolatedarabic = 0xfefb;
  27619. t.lamalefmaddaabovefinalarabic = 0xfef6;
  27620. t.lamalefmaddaaboveisolatedarabic = 0xfef5;
  27621. t.lamarabic = 0x0644;
  27622. t.lambda = 0x03bb;
  27623. t.lambdastroke = 0x019b;
  27624. t.lamed = 0x05dc;
  27625. t.lameddagesh = 0xfb3c;
  27626. t.lameddageshhebrew = 0xfb3c;
  27627. t.lamedhebrew = 0x05dc;
  27628. t.lamfinalarabic = 0xfede;
  27629. t.lamhahinitialarabic = 0xfcca;
  27630. t.laminitialarabic = 0xfedf;
  27631. t.lamjeeminitialarabic = 0xfcc9;
  27632. t.lamkhahinitialarabic = 0xfccb;
  27633. t.lamlamhehisolatedarabic = 0xfdf2;
  27634. t.lammedialarabic = 0xfee0;
  27635. t.lammeemhahinitialarabic = 0xfd88;
  27636. t.lammeeminitialarabic = 0xfccc;
  27637. t.largecircle = 0x25ef;
  27638. t.lbar = 0x019a;
  27639. t.lbelt = 0x026c;
  27640. t.lbopomofo = 0x310c;
  27641. t.lcaron = 0x013e;
  27642. t.lcedilla = 0x013c;
  27643. t.lcircle = 0x24db;
  27644. t.lcircumflexbelow = 0x1e3d;
  27645. t.lcommaaccent = 0x013c;
  27646. t.ldot = 0x0140;
  27647. t.ldotaccent = 0x0140;
  27648. t.ldotbelow = 0x1e37;
  27649. t.ldotbelowmacron = 0x1e39;
  27650. t.leftangleabovecmb = 0x031a;
  27651. t.lefttackbelowcmb = 0x0318;
  27652. t.less = 0x003c;
  27653. t.lessequal = 0x2264;
  27654. t.lessequalorgreater = 0x22da;
  27655. t.lessmonospace = 0xff1c;
  27656. t.lessorequivalent = 0x2272;
  27657. t.lessorgreater = 0x2276;
  27658. t.lessoverequal = 0x2266;
  27659. t.lesssmall = 0xfe64;
  27660. t.lezh = 0x026e;
  27661. t.lfblock = 0x258c;
  27662. t.lhookretroflex = 0x026d;
  27663. t.lira = 0x20a4;
  27664. t.liwnarmenian = 0x056c;
  27665. t.lj = 0x01c9;
  27666. t.ljecyrillic = 0x0459;
  27667. t.ll = 0xf6c0;
  27668. t.lladeva = 0x0933;
  27669. t.llagujarati = 0x0ab3;
  27670. t.llinebelow = 0x1e3b;
  27671. t.llladeva = 0x0934;
  27672. t.llvocalicbengali = 0x09e1;
  27673. t.llvocalicdeva = 0x0961;
  27674. t.llvocalicvowelsignbengali = 0x09e3;
  27675. t.llvocalicvowelsigndeva = 0x0963;
  27676. t.lmiddletilde = 0x026b;
  27677. t.lmonospace = 0xff4c;
  27678. t.lmsquare = 0x33d0;
  27679. t.lochulathai = 0x0e2c;
  27680. t.logicaland = 0x2227;
  27681. t.logicalnot = 0x00ac;
  27682. t.logicalnotreversed = 0x2310;
  27683. t.logicalor = 0x2228;
  27684. t.lolingthai = 0x0e25;
  27685. t.longs = 0x017f;
  27686. t.lowlinecenterline = 0xfe4e;
  27687. t.lowlinecmb = 0x0332;
  27688. t.lowlinedashed = 0xfe4d;
  27689. t.lozenge = 0x25ca;
  27690. t.lparen = 0x24a7;
  27691. t.lslash = 0x0142;
  27692. t.lsquare = 0x2113;
  27693. t.lsuperior = 0xf6ee;
  27694. t.ltshade = 0x2591;
  27695. t.luthai = 0x0e26;
  27696. t.lvocalicbengali = 0x098c;
  27697. t.lvocalicdeva = 0x090c;
  27698. t.lvocalicvowelsignbengali = 0x09e2;
  27699. t.lvocalicvowelsigndeva = 0x0962;
  27700. t.lxsquare = 0x33d3;
  27701. t.m = 0x006d;
  27702. t.mabengali = 0x09ae;
  27703. t.macron = 0x00af;
  27704. t.macronbelowcmb = 0x0331;
  27705. t.macroncmb = 0x0304;
  27706. t.macronlowmod = 0x02cd;
  27707. t.macronmonospace = 0xffe3;
  27708. t.macute = 0x1e3f;
  27709. t.madeva = 0x092e;
  27710. t.magujarati = 0x0aae;
  27711. t.magurmukhi = 0x0a2e;
  27712. t.mahapakhhebrew = 0x05a4;
  27713. t.mahapakhlefthebrew = 0x05a4;
  27714. t.mahiragana = 0x307e;
  27715. t.maichattawalowleftthai = 0xf895;
  27716. t.maichattawalowrightthai = 0xf894;
  27717. t.maichattawathai = 0x0e4b;
  27718. t.maichattawaupperleftthai = 0xf893;
  27719. t.maieklowleftthai = 0xf88c;
  27720. t.maieklowrightthai = 0xf88b;
  27721. t.maiekthai = 0x0e48;
  27722. t.maiekupperleftthai = 0xf88a;
  27723. t.maihanakatleftthai = 0xf884;
  27724. t.maihanakatthai = 0x0e31;
  27725. t.maitaikhuleftthai = 0xf889;
  27726. t.maitaikhuthai = 0x0e47;
  27727. t.maitholowleftthai = 0xf88f;
  27728. t.maitholowrightthai = 0xf88e;
  27729. t.maithothai = 0x0e49;
  27730. t.maithoupperleftthai = 0xf88d;
  27731. t.maitrilowleftthai = 0xf892;
  27732. t.maitrilowrightthai = 0xf891;
  27733. t.maitrithai = 0x0e4a;
  27734. t.maitriupperleftthai = 0xf890;
  27735. t.maiyamokthai = 0x0e46;
  27736. t.makatakana = 0x30de;
  27737. t.makatakanahalfwidth = 0xff8f;
  27738. t.male = 0x2642;
  27739. t.mansyonsquare = 0x3347;
  27740. t.maqafhebrew = 0x05be;
  27741. t.mars = 0x2642;
  27742. t.masoracirclehebrew = 0x05af;
  27743. t.masquare = 0x3383;
  27744. t.mbopomofo = 0x3107;
  27745. t.mbsquare = 0x33d4;
  27746. t.mcircle = 0x24dc;
  27747. t.mcubedsquare = 0x33a5;
  27748. t.mdotaccent = 0x1e41;
  27749. t.mdotbelow = 0x1e43;
  27750. t.meemarabic = 0x0645;
  27751. t.meemfinalarabic = 0xfee2;
  27752. t.meeminitialarabic = 0xfee3;
  27753. t.meemmedialarabic = 0xfee4;
  27754. t.meemmeeminitialarabic = 0xfcd1;
  27755. t.meemmeemisolatedarabic = 0xfc48;
  27756. t.meetorusquare = 0x334d;
  27757. t.mehiragana = 0x3081;
  27758. t.meizierasquare = 0x337e;
  27759. t.mekatakana = 0x30e1;
  27760. t.mekatakanahalfwidth = 0xff92;
  27761. t.mem = 0x05de;
  27762. t.memdagesh = 0xfb3e;
  27763. t.memdageshhebrew = 0xfb3e;
  27764. t.memhebrew = 0x05de;
  27765. t.menarmenian = 0x0574;
  27766. t.merkhahebrew = 0x05a5;
  27767. t.merkhakefulahebrew = 0x05a6;
  27768. t.merkhakefulalefthebrew = 0x05a6;
  27769. t.merkhalefthebrew = 0x05a5;
  27770. t.mhook = 0x0271;
  27771. t.mhzsquare = 0x3392;
  27772. t.middledotkatakanahalfwidth = 0xff65;
  27773. t.middot = 0x00b7;
  27774. t.mieumacirclekorean = 0x3272;
  27775. t.mieumaparenkorean = 0x3212;
  27776. t.mieumcirclekorean = 0x3264;
  27777. t.mieumkorean = 0x3141;
  27778. t.mieumpansioskorean = 0x3170;
  27779. t.mieumparenkorean = 0x3204;
  27780. t.mieumpieupkorean = 0x316e;
  27781. t.mieumsioskorean = 0x316f;
  27782. t.mihiragana = 0x307f;
  27783. t.mikatakana = 0x30df;
  27784. t.mikatakanahalfwidth = 0xff90;
  27785. t.minus = 0x2212;
  27786. t.minusbelowcmb = 0x0320;
  27787. t.minuscircle = 0x2296;
  27788. t.minusmod = 0x02d7;
  27789. t.minusplus = 0x2213;
  27790. t.minute = 0x2032;
  27791. t.miribaarusquare = 0x334a;
  27792. t.mirisquare = 0x3349;
  27793. t.mlonglegturned = 0x0270;
  27794. t.mlsquare = 0x3396;
  27795. t.mmcubedsquare = 0x33a3;
  27796. t.mmonospace = 0xff4d;
  27797. t.mmsquaredsquare = 0x339f;
  27798. t.mohiragana = 0x3082;
  27799. t.mohmsquare = 0x33c1;
  27800. t.mokatakana = 0x30e2;
  27801. t.mokatakanahalfwidth = 0xff93;
  27802. t.molsquare = 0x33d6;
  27803. t.momathai = 0x0e21;
  27804. t.moverssquare = 0x33a7;
  27805. t.moverssquaredsquare = 0x33a8;
  27806. t.mparen = 0x24a8;
  27807. t.mpasquare = 0x33ab;
  27808. t.mssquare = 0x33b3;
  27809. t.msuperior = 0xf6ef;
  27810. t.mturned = 0x026f;
  27811. t.mu = 0x00b5;
  27812. t.mu1 = 0x00b5;
  27813. t.muasquare = 0x3382;
  27814. t.muchgreater = 0x226b;
  27815. t.muchless = 0x226a;
  27816. t.mufsquare = 0x338c;
  27817. t.mugreek = 0x03bc;
  27818. t.mugsquare = 0x338d;
  27819. t.muhiragana = 0x3080;
  27820. t.mukatakana = 0x30e0;
  27821. t.mukatakanahalfwidth = 0xff91;
  27822. t.mulsquare = 0x3395;
  27823. t.multiply = 0x00d7;
  27824. t.mumsquare = 0x339b;
  27825. t.munahhebrew = 0x05a3;
  27826. t.munahlefthebrew = 0x05a3;
  27827. t.musicalnote = 0x266a;
  27828. t.musicalnotedbl = 0x266b;
  27829. t.musicflatsign = 0x266d;
  27830. t.musicsharpsign = 0x266f;
  27831. t.mussquare = 0x33b2;
  27832. t.muvsquare = 0x33b6;
  27833. t.muwsquare = 0x33bc;
  27834. t.mvmegasquare = 0x33b9;
  27835. t.mvsquare = 0x33b7;
  27836. t.mwmegasquare = 0x33bf;
  27837. t.mwsquare = 0x33bd;
  27838. t.n = 0x006e;
  27839. t.nabengali = 0x09a8;
  27840. t.nabla = 0x2207;
  27841. t.nacute = 0x0144;
  27842. t.nadeva = 0x0928;
  27843. t.nagujarati = 0x0aa8;
  27844. t.nagurmukhi = 0x0a28;
  27845. t.nahiragana = 0x306a;
  27846. t.nakatakana = 0x30ca;
  27847. t.nakatakanahalfwidth = 0xff85;
  27848. t.napostrophe = 0x0149;
  27849. t.nasquare = 0x3381;
  27850. t.nbopomofo = 0x310b;
  27851. t.nbspace = 0x00a0;
  27852. t.ncaron = 0x0148;
  27853. t.ncedilla = 0x0146;
  27854. t.ncircle = 0x24dd;
  27855. t.ncircumflexbelow = 0x1e4b;
  27856. t.ncommaaccent = 0x0146;
  27857. t.ndotaccent = 0x1e45;
  27858. t.ndotbelow = 0x1e47;
  27859. t.nehiragana = 0x306d;
  27860. t.nekatakana = 0x30cd;
  27861. t.nekatakanahalfwidth = 0xff88;
  27862. t.newsheqelsign = 0x20aa;
  27863. t.nfsquare = 0x338b;
  27864. t.ngabengali = 0x0999;
  27865. t.ngadeva = 0x0919;
  27866. t.ngagujarati = 0x0a99;
  27867. t.ngagurmukhi = 0x0a19;
  27868. t.ngonguthai = 0x0e07;
  27869. t.nhiragana = 0x3093;
  27870. t.nhookleft = 0x0272;
  27871. t.nhookretroflex = 0x0273;
  27872. t.nieunacirclekorean = 0x326f;
  27873. t.nieunaparenkorean = 0x320f;
  27874. t.nieuncieuckorean = 0x3135;
  27875. t.nieuncirclekorean = 0x3261;
  27876. t.nieunhieuhkorean = 0x3136;
  27877. t.nieunkorean = 0x3134;
  27878. t.nieunpansioskorean = 0x3168;
  27879. t.nieunparenkorean = 0x3201;
  27880. t.nieunsioskorean = 0x3167;
  27881. t.nieuntikeutkorean = 0x3166;
  27882. t.nihiragana = 0x306b;
  27883. t.nikatakana = 0x30cb;
  27884. t.nikatakanahalfwidth = 0xff86;
  27885. t.nikhahitleftthai = 0xf899;
  27886. t.nikhahitthai = 0x0e4d;
  27887. t.nine = 0x0039;
  27888. t.ninearabic = 0x0669;
  27889. t.ninebengali = 0x09ef;
  27890. t.ninecircle = 0x2468;
  27891. t.ninecircleinversesansserif = 0x2792;
  27892. t.ninedeva = 0x096f;
  27893. t.ninegujarati = 0x0aef;
  27894. t.ninegurmukhi = 0x0a6f;
  27895. t.ninehackarabic = 0x0669;
  27896. t.ninehangzhou = 0x3029;
  27897. t.nineideographicparen = 0x3228;
  27898. t.nineinferior = 0x2089;
  27899. t.ninemonospace = 0xff19;
  27900. t.nineoldstyle = 0xf739;
  27901. t.nineparen = 0x247c;
  27902. t.nineperiod = 0x2490;
  27903. t.ninepersian = 0x06f9;
  27904. t.nineroman = 0x2178;
  27905. t.ninesuperior = 0x2079;
  27906. t.nineteencircle = 0x2472;
  27907. t.nineteenparen = 0x2486;
  27908. t.nineteenperiod = 0x249a;
  27909. t.ninethai = 0x0e59;
  27910. t.nj = 0x01cc;
  27911. t.njecyrillic = 0x045a;
  27912. t.nkatakana = 0x30f3;
  27913. t.nkatakanahalfwidth = 0xff9d;
  27914. t.nlegrightlong = 0x019e;
  27915. t.nlinebelow = 0x1e49;
  27916. t.nmonospace = 0xff4e;
  27917. t.nmsquare = 0x339a;
  27918. t.nnabengali = 0x09a3;
  27919. t.nnadeva = 0x0923;
  27920. t.nnagujarati = 0x0aa3;
  27921. t.nnagurmukhi = 0x0a23;
  27922. t.nnnadeva = 0x0929;
  27923. t.nohiragana = 0x306e;
  27924. t.nokatakana = 0x30ce;
  27925. t.nokatakanahalfwidth = 0xff89;
  27926. t.nonbreakingspace = 0x00a0;
  27927. t.nonenthai = 0x0e13;
  27928. t.nonuthai = 0x0e19;
  27929. t.noonarabic = 0x0646;
  27930. t.noonfinalarabic = 0xfee6;
  27931. t.noonghunnaarabic = 0x06ba;
  27932. t.noonghunnafinalarabic = 0xfb9f;
  27933. t.nooninitialarabic = 0xfee7;
  27934. t.noonjeeminitialarabic = 0xfcd2;
  27935. t.noonjeemisolatedarabic = 0xfc4b;
  27936. t.noonmedialarabic = 0xfee8;
  27937. t.noonmeeminitialarabic = 0xfcd5;
  27938. t.noonmeemisolatedarabic = 0xfc4e;
  27939. t.noonnoonfinalarabic = 0xfc8d;
  27940. t.notcontains = 0x220c;
  27941. t.notelement = 0x2209;
  27942. t.notelementof = 0x2209;
  27943. t.notequal = 0x2260;
  27944. t.notgreater = 0x226f;
  27945. t.notgreaternorequal = 0x2271;
  27946. t.notgreaternorless = 0x2279;
  27947. t.notidentical = 0x2262;
  27948. t.notless = 0x226e;
  27949. t.notlessnorequal = 0x2270;
  27950. t.notparallel = 0x2226;
  27951. t.notprecedes = 0x2280;
  27952. t.notsubset = 0x2284;
  27953. t.notsucceeds = 0x2281;
  27954. t.notsuperset = 0x2285;
  27955. t.nowarmenian = 0x0576;
  27956. t.nparen = 0x24a9;
  27957. t.nssquare = 0x33b1;
  27958. t.nsuperior = 0x207f;
  27959. t.ntilde = 0x00f1;
  27960. t.nu = 0x03bd;
  27961. t.nuhiragana = 0x306c;
  27962. t.nukatakana = 0x30cc;
  27963. t.nukatakanahalfwidth = 0xff87;
  27964. t.nuktabengali = 0x09bc;
  27965. t.nuktadeva = 0x093c;
  27966. t.nuktagujarati = 0x0abc;
  27967. t.nuktagurmukhi = 0x0a3c;
  27968. t.numbersign = 0x0023;
  27969. t.numbersignmonospace = 0xff03;
  27970. t.numbersignsmall = 0xfe5f;
  27971. t.numeralsigngreek = 0x0374;
  27972. t.numeralsignlowergreek = 0x0375;
  27973. t.numero = 0x2116;
  27974. t.nun = 0x05e0;
  27975. t.nundagesh = 0xfb40;
  27976. t.nundageshhebrew = 0xfb40;
  27977. t.nunhebrew = 0x05e0;
  27978. t.nvsquare = 0x33b5;
  27979. t.nwsquare = 0x33bb;
  27980. t.nyabengali = 0x099e;
  27981. t.nyadeva = 0x091e;
  27982. t.nyagujarati = 0x0a9e;
  27983. t.nyagurmukhi = 0x0a1e;
  27984. t.o = 0x006f;
  27985. t.oacute = 0x00f3;
  27986. t.oangthai = 0x0e2d;
  27987. t.obarred = 0x0275;
  27988. t.obarredcyrillic = 0x04e9;
  27989. t.obarreddieresiscyrillic = 0x04eb;
  27990. t.obengali = 0x0993;
  27991. t.obopomofo = 0x311b;
  27992. t.obreve = 0x014f;
  27993. t.ocandradeva = 0x0911;
  27994. t.ocandragujarati = 0x0a91;
  27995. t.ocandravowelsigndeva = 0x0949;
  27996. t.ocandravowelsigngujarati = 0x0ac9;
  27997. t.ocaron = 0x01d2;
  27998. t.ocircle = 0x24de;
  27999. t.ocircumflex = 0x00f4;
  28000. t.ocircumflexacute = 0x1ed1;
  28001. t.ocircumflexdotbelow = 0x1ed9;
  28002. t.ocircumflexgrave = 0x1ed3;
  28003. t.ocircumflexhookabove = 0x1ed5;
  28004. t.ocircumflextilde = 0x1ed7;
  28005. t.ocyrillic = 0x043e;
  28006. t.odblacute = 0x0151;
  28007. t.odblgrave = 0x020d;
  28008. t.odeva = 0x0913;
  28009. t.odieresis = 0x00f6;
  28010. t.odieresiscyrillic = 0x04e7;
  28011. t.odotbelow = 0x1ecd;
  28012. t.oe = 0x0153;
  28013. t.oekorean = 0x315a;
  28014. t.ogonek = 0x02db;
  28015. t.ogonekcmb = 0x0328;
  28016. t.ograve = 0x00f2;
  28017. t.ogujarati = 0x0a93;
  28018. t.oharmenian = 0x0585;
  28019. t.ohiragana = 0x304a;
  28020. t.ohookabove = 0x1ecf;
  28021. t.ohorn = 0x01a1;
  28022. t.ohornacute = 0x1edb;
  28023. t.ohorndotbelow = 0x1ee3;
  28024. t.ohorngrave = 0x1edd;
  28025. t.ohornhookabove = 0x1edf;
  28026. t.ohorntilde = 0x1ee1;
  28027. t.ohungarumlaut = 0x0151;
  28028. t.oi = 0x01a3;
  28029. t.oinvertedbreve = 0x020f;
  28030. t.okatakana = 0x30aa;
  28031. t.okatakanahalfwidth = 0xff75;
  28032. t.okorean = 0x3157;
  28033. t.olehebrew = 0x05ab;
  28034. t.omacron = 0x014d;
  28035. t.omacronacute = 0x1e53;
  28036. t.omacrongrave = 0x1e51;
  28037. t.omdeva = 0x0950;
  28038. t.omega = 0x03c9;
  28039. t.omega1 = 0x03d6;
  28040. t.omegacyrillic = 0x0461;
  28041. t.omegalatinclosed = 0x0277;
  28042. t.omegaroundcyrillic = 0x047b;
  28043. t.omegatitlocyrillic = 0x047d;
  28044. t.omegatonos = 0x03ce;
  28045. t.omgujarati = 0x0ad0;
  28046. t.omicron = 0x03bf;
  28047. t.omicrontonos = 0x03cc;
  28048. t.omonospace = 0xff4f;
  28049. t.one = 0x0031;
  28050. t.onearabic = 0x0661;
  28051. t.onebengali = 0x09e7;
  28052. t.onecircle = 0x2460;
  28053. t.onecircleinversesansserif = 0x278a;
  28054. t.onedeva = 0x0967;
  28055. t.onedotenleader = 0x2024;
  28056. t.oneeighth = 0x215b;
  28057. t.onefitted = 0xf6dc;
  28058. t.onegujarati = 0x0ae7;
  28059. t.onegurmukhi = 0x0a67;
  28060. t.onehackarabic = 0x0661;
  28061. t.onehalf = 0x00bd;
  28062. t.onehangzhou = 0x3021;
  28063. t.oneideographicparen = 0x3220;
  28064. t.oneinferior = 0x2081;
  28065. t.onemonospace = 0xff11;
  28066. t.onenumeratorbengali = 0x09f4;
  28067. t.oneoldstyle = 0xf731;
  28068. t.oneparen = 0x2474;
  28069. t.oneperiod = 0x2488;
  28070. t.onepersian = 0x06f1;
  28071. t.onequarter = 0x00bc;
  28072. t.oneroman = 0x2170;
  28073. t.onesuperior = 0x00b9;
  28074. t.onethai = 0x0e51;
  28075. t.onethird = 0x2153;
  28076. t.oogonek = 0x01eb;
  28077. t.oogonekmacron = 0x01ed;
  28078. t.oogurmukhi = 0x0a13;
  28079. t.oomatragurmukhi = 0x0a4b;
  28080. t.oopen = 0x0254;
  28081. t.oparen = 0x24aa;
  28082. t.openbullet = 0x25e6;
  28083. t.option = 0x2325;
  28084. t.ordfeminine = 0x00aa;
  28085. t.ordmasculine = 0x00ba;
  28086. t.orthogonal = 0x221f;
  28087. t.oshortdeva = 0x0912;
  28088. t.oshortvowelsigndeva = 0x094a;
  28089. t.oslash = 0x00f8;
  28090. t.oslashacute = 0x01ff;
  28091. t.osmallhiragana = 0x3049;
  28092. t.osmallkatakana = 0x30a9;
  28093. t.osmallkatakanahalfwidth = 0xff6b;
  28094. t.ostrokeacute = 0x01ff;
  28095. t.osuperior = 0xf6f0;
  28096. t.otcyrillic = 0x047f;
  28097. t.otilde = 0x00f5;
  28098. t.otildeacute = 0x1e4d;
  28099. t.otildedieresis = 0x1e4f;
  28100. t.oubopomofo = 0x3121;
  28101. t.overline = 0x203e;
  28102. t.overlinecenterline = 0xfe4a;
  28103. t.overlinecmb = 0x0305;
  28104. t.overlinedashed = 0xfe49;
  28105. t.overlinedblwavy = 0xfe4c;
  28106. t.overlinewavy = 0xfe4b;
  28107. t.overscore = 0x00af;
  28108. t.ovowelsignbengali = 0x09cb;
  28109. t.ovowelsigndeva = 0x094b;
  28110. t.ovowelsigngujarati = 0x0acb;
  28111. t.p = 0x0070;
  28112. t.paampssquare = 0x3380;
  28113. t.paasentosquare = 0x332b;
  28114. t.pabengali = 0x09aa;
  28115. t.pacute = 0x1e55;
  28116. t.padeva = 0x092a;
  28117. t.pagedown = 0x21df;
  28118. t.pageup = 0x21de;
  28119. t.pagujarati = 0x0aaa;
  28120. t.pagurmukhi = 0x0a2a;
  28121. t.pahiragana = 0x3071;
  28122. t.paiyannoithai = 0x0e2f;
  28123. t.pakatakana = 0x30d1;
  28124. t.palatalizationcyrilliccmb = 0x0484;
  28125. t.palochkacyrillic = 0x04c0;
  28126. t.pansioskorean = 0x317f;
  28127. t.paragraph = 0x00b6;
  28128. t.parallel = 0x2225;
  28129. t.parenleft = 0x0028;
  28130. t.parenleftaltonearabic = 0xfd3e;
  28131. t.parenleftbt = 0xf8ed;
  28132. t.parenleftex = 0xf8ec;
  28133. t.parenleftinferior = 0x208d;
  28134. t.parenleftmonospace = 0xff08;
  28135. t.parenleftsmall = 0xfe59;
  28136. t.parenleftsuperior = 0x207d;
  28137. t.parenlefttp = 0xf8eb;
  28138. t.parenleftvertical = 0xfe35;
  28139. t.parenright = 0x0029;
  28140. t.parenrightaltonearabic = 0xfd3f;
  28141. t.parenrightbt = 0xf8f8;
  28142. t.parenrightex = 0xf8f7;
  28143. t.parenrightinferior = 0x208e;
  28144. t.parenrightmonospace = 0xff09;
  28145. t.parenrightsmall = 0xfe5a;
  28146. t.parenrightsuperior = 0x207e;
  28147. t.parenrighttp = 0xf8f6;
  28148. t.parenrightvertical = 0xfe36;
  28149. t.partialdiff = 0x2202;
  28150. t.paseqhebrew = 0x05c0;
  28151. t.pashtahebrew = 0x0599;
  28152. t.pasquare = 0x33a9;
  28153. t.patah = 0x05b7;
  28154. t.patah11 = 0x05b7;
  28155. t.patah1d = 0x05b7;
  28156. t.patah2a = 0x05b7;
  28157. t.patahhebrew = 0x05b7;
  28158. t.patahnarrowhebrew = 0x05b7;
  28159. t.patahquarterhebrew = 0x05b7;
  28160. t.patahwidehebrew = 0x05b7;
  28161. t.pazerhebrew = 0x05a1;
  28162. t.pbopomofo = 0x3106;
  28163. t.pcircle = 0x24df;
  28164. t.pdotaccent = 0x1e57;
  28165. t.pe = 0x05e4;
  28166. t.pecyrillic = 0x043f;
  28167. t.pedagesh = 0xfb44;
  28168. t.pedageshhebrew = 0xfb44;
  28169. t.peezisquare = 0x333b;
  28170. t.pefinaldageshhebrew = 0xfb43;
  28171. t.peharabic = 0x067e;
  28172. t.peharmenian = 0x057a;
  28173. t.pehebrew = 0x05e4;
  28174. t.pehfinalarabic = 0xfb57;
  28175. t.pehinitialarabic = 0xfb58;
  28176. t.pehiragana = 0x307a;
  28177. t.pehmedialarabic = 0xfb59;
  28178. t.pekatakana = 0x30da;
  28179. t.pemiddlehookcyrillic = 0x04a7;
  28180. t.perafehebrew = 0xfb4e;
  28181. t.percent = 0x0025;
  28182. t.percentarabic = 0x066a;
  28183. t.percentmonospace = 0xff05;
  28184. t.percentsmall = 0xfe6a;
  28185. t.period = 0x002e;
  28186. t.periodarmenian = 0x0589;
  28187. t.periodcentered = 0x00b7;
  28188. t.periodhalfwidth = 0xff61;
  28189. t.periodinferior = 0xf6e7;
  28190. t.periodmonospace = 0xff0e;
  28191. t.periodsmall = 0xfe52;
  28192. t.periodsuperior = 0xf6e8;
  28193. t.perispomenigreekcmb = 0x0342;
  28194. t.perpendicular = 0x22a5;
  28195. t.perthousand = 0x2030;
  28196. t.peseta = 0x20a7;
  28197. t.pfsquare = 0x338a;
  28198. t.phabengali = 0x09ab;
  28199. t.phadeva = 0x092b;
  28200. t.phagujarati = 0x0aab;
  28201. t.phagurmukhi = 0x0a2b;
  28202. t.phi = 0x03c6;
  28203. t.phi1 = 0x03d5;
  28204. t.phieuphacirclekorean = 0x327a;
  28205. t.phieuphaparenkorean = 0x321a;
  28206. t.phieuphcirclekorean = 0x326c;
  28207. t.phieuphkorean = 0x314d;
  28208. t.phieuphparenkorean = 0x320c;
  28209. t.philatin = 0x0278;
  28210. t.phinthuthai = 0x0e3a;
  28211. t.phisymbolgreek = 0x03d5;
  28212. t.phook = 0x01a5;
  28213. t.phophanthai = 0x0e1e;
  28214. t.phophungthai = 0x0e1c;
  28215. t.phosamphaothai = 0x0e20;
  28216. t.pi = 0x03c0;
  28217. t.pieupacirclekorean = 0x3273;
  28218. t.pieupaparenkorean = 0x3213;
  28219. t.pieupcieuckorean = 0x3176;
  28220. t.pieupcirclekorean = 0x3265;
  28221. t.pieupkiyeokkorean = 0x3172;
  28222. t.pieupkorean = 0x3142;
  28223. t.pieupparenkorean = 0x3205;
  28224. t.pieupsioskiyeokkorean = 0x3174;
  28225. t.pieupsioskorean = 0x3144;
  28226. t.pieupsiostikeutkorean = 0x3175;
  28227. t.pieupthieuthkorean = 0x3177;
  28228. t.pieuptikeutkorean = 0x3173;
  28229. t.pihiragana = 0x3074;
  28230. t.pikatakana = 0x30d4;
  28231. t.pisymbolgreek = 0x03d6;
  28232. t.piwrarmenian = 0x0583;
  28233. t.planckover2pi = 0x210f;
  28234. t.planckover2pi1 = 0x210f;
  28235. t.plus = 0x002b;
  28236. t.plusbelowcmb = 0x031f;
  28237. t.pluscircle = 0x2295;
  28238. t.plusminus = 0x00b1;
  28239. t.plusmod = 0x02d6;
  28240. t.plusmonospace = 0xff0b;
  28241. t.plussmall = 0xfe62;
  28242. t.plussuperior = 0x207a;
  28243. t.pmonospace = 0xff50;
  28244. t.pmsquare = 0x33d8;
  28245. t.pohiragana = 0x307d;
  28246. t.pointingindexdownwhite = 0x261f;
  28247. t.pointingindexleftwhite = 0x261c;
  28248. t.pointingindexrightwhite = 0x261e;
  28249. t.pointingindexupwhite = 0x261d;
  28250. t.pokatakana = 0x30dd;
  28251. t.poplathai = 0x0e1b;
  28252. t.postalmark = 0x3012;
  28253. t.postalmarkface = 0x3020;
  28254. t.pparen = 0x24ab;
  28255. t.precedes = 0x227a;
  28256. t.prescription = 0x211e;
  28257. t.primemod = 0x02b9;
  28258. t.primereversed = 0x2035;
  28259. t.product = 0x220f;
  28260. t.projective = 0x2305;
  28261. t.prolongedkana = 0x30fc;
  28262. t.propellor = 0x2318;
  28263. t.propersubset = 0x2282;
  28264. t.propersuperset = 0x2283;
  28265. t.proportion = 0x2237;
  28266. t.proportional = 0x221d;
  28267. t.psi = 0x03c8;
  28268. t.psicyrillic = 0x0471;
  28269. t.psilipneumatacyrilliccmb = 0x0486;
  28270. t.pssquare = 0x33b0;
  28271. t.puhiragana = 0x3077;
  28272. t.pukatakana = 0x30d7;
  28273. t.pvsquare = 0x33b4;
  28274. t.pwsquare = 0x33ba;
  28275. t.q = 0x0071;
  28276. t.qadeva = 0x0958;
  28277. t.qadmahebrew = 0x05a8;
  28278. t.qafarabic = 0x0642;
  28279. t.qaffinalarabic = 0xfed6;
  28280. t.qafinitialarabic = 0xfed7;
  28281. t.qafmedialarabic = 0xfed8;
  28282. t.qamats = 0x05b8;
  28283. t.qamats10 = 0x05b8;
  28284. t.qamats1a = 0x05b8;
  28285. t.qamats1c = 0x05b8;
  28286. t.qamats27 = 0x05b8;
  28287. t.qamats29 = 0x05b8;
  28288. t.qamats33 = 0x05b8;
  28289. t.qamatsde = 0x05b8;
  28290. t.qamatshebrew = 0x05b8;
  28291. t.qamatsnarrowhebrew = 0x05b8;
  28292. t.qamatsqatanhebrew = 0x05b8;
  28293. t.qamatsqatannarrowhebrew = 0x05b8;
  28294. t.qamatsqatanquarterhebrew = 0x05b8;
  28295. t.qamatsqatanwidehebrew = 0x05b8;
  28296. t.qamatsquarterhebrew = 0x05b8;
  28297. t.qamatswidehebrew = 0x05b8;
  28298. t.qarneyparahebrew = 0x059f;
  28299. t.qbopomofo = 0x3111;
  28300. t.qcircle = 0x24e0;
  28301. t.qhook = 0x02a0;
  28302. t.qmonospace = 0xff51;
  28303. t.qof = 0x05e7;
  28304. t.qofdagesh = 0xfb47;
  28305. t.qofdageshhebrew = 0xfb47;
  28306. t.qofhebrew = 0x05e7;
  28307. t.qparen = 0x24ac;
  28308. t.quarternote = 0x2669;
  28309. t.qubuts = 0x05bb;
  28310. t.qubuts18 = 0x05bb;
  28311. t.qubuts25 = 0x05bb;
  28312. t.qubuts31 = 0x05bb;
  28313. t.qubutshebrew = 0x05bb;
  28314. t.qubutsnarrowhebrew = 0x05bb;
  28315. t.qubutsquarterhebrew = 0x05bb;
  28316. t.qubutswidehebrew = 0x05bb;
  28317. t.question = 0x003f;
  28318. t.questionarabic = 0x061f;
  28319. t.questionarmenian = 0x055e;
  28320. t.questiondown = 0x00bf;
  28321. t.questiondownsmall = 0xf7bf;
  28322. t.questiongreek = 0x037e;
  28323. t.questionmonospace = 0xff1f;
  28324. t.questionsmall = 0xf73f;
  28325. t.quotedbl = 0x0022;
  28326. t.quotedblbase = 0x201e;
  28327. t.quotedblleft = 0x201c;
  28328. t.quotedblmonospace = 0xff02;
  28329. t.quotedblprime = 0x301e;
  28330. t.quotedblprimereversed = 0x301d;
  28331. t.quotedblright = 0x201d;
  28332. t.quoteleft = 0x2018;
  28333. t.quoteleftreversed = 0x201b;
  28334. t.quotereversed = 0x201b;
  28335. t.quoteright = 0x2019;
  28336. t.quoterightn = 0x0149;
  28337. t.quotesinglbase = 0x201a;
  28338. t.quotesingle = 0x0027;
  28339. t.quotesinglemonospace = 0xff07;
  28340. t.r = 0x0072;
  28341. t.raarmenian = 0x057c;
  28342. t.rabengali = 0x09b0;
  28343. t.racute = 0x0155;
  28344. t.radeva = 0x0930;
  28345. t.radical = 0x221a;
  28346. t.radicalex = 0xf8e5;
  28347. t.radoverssquare = 0x33ae;
  28348. t.radoverssquaredsquare = 0x33af;
  28349. t.radsquare = 0x33ad;
  28350. t.rafe = 0x05bf;
  28351. t.rafehebrew = 0x05bf;
  28352. t.ragujarati = 0x0ab0;
  28353. t.ragurmukhi = 0x0a30;
  28354. t.rahiragana = 0x3089;
  28355. t.rakatakana = 0x30e9;
  28356. t.rakatakanahalfwidth = 0xff97;
  28357. t.ralowerdiagonalbengali = 0x09f1;
  28358. t.ramiddlediagonalbengali = 0x09f0;
  28359. t.ramshorn = 0x0264;
  28360. t.ratio = 0x2236;
  28361. t.rbopomofo = 0x3116;
  28362. t.rcaron = 0x0159;
  28363. t.rcedilla = 0x0157;
  28364. t.rcircle = 0x24e1;
  28365. t.rcommaaccent = 0x0157;
  28366. t.rdblgrave = 0x0211;
  28367. t.rdotaccent = 0x1e59;
  28368. t.rdotbelow = 0x1e5b;
  28369. t.rdotbelowmacron = 0x1e5d;
  28370. t.referencemark = 0x203b;
  28371. t.reflexsubset = 0x2286;
  28372. t.reflexsuperset = 0x2287;
  28373. t.registered = 0x00ae;
  28374. t.registersans = 0xf8e8;
  28375. t.registerserif = 0xf6da;
  28376. t.reharabic = 0x0631;
  28377. t.reharmenian = 0x0580;
  28378. t.rehfinalarabic = 0xfeae;
  28379. t.rehiragana = 0x308c;
  28380. t.rekatakana = 0x30ec;
  28381. t.rekatakanahalfwidth = 0xff9a;
  28382. t.resh = 0x05e8;
  28383. t.reshdageshhebrew = 0xfb48;
  28384. t.reshhebrew = 0x05e8;
  28385. t.reversedtilde = 0x223d;
  28386. t.reviahebrew = 0x0597;
  28387. t.reviamugrashhebrew = 0x0597;
  28388. t.revlogicalnot = 0x2310;
  28389. t.rfishhook = 0x027e;
  28390. t.rfishhookreversed = 0x027f;
  28391. t.rhabengali = 0x09dd;
  28392. t.rhadeva = 0x095d;
  28393. t.rho = 0x03c1;
  28394. t.rhook = 0x027d;
  28395. t.rhookturned = 0x027b;
  28396. t.rhookturnedsuperior = 0x02b5;
  28397. t.rhosymbolgreek = 0x03f1;
  28398. t.rhotichookmod = 0x02de;
  28399. t.rieulacirclekorean = 0x3271;
  28400. t.rieulaparenkorean = 0x3211;
  28401. t.rieulcirclekorean = 0x3263;
  28402. t.rieulhieuhkorean = 0x3140;
  28403. t.rieulkiyeokkorean = 0x313a;
  28404. t.rieulkiyeoksioskorean = 0x3169;
  28405. t.rieulkorean = 0x3139;
  28406. t.rieulmieumkorean = 0x313b;
  28407. t.rieulpansioskorean = 0x316c;
  28408. t.rieulparenkorean = 0x3203;
  28409. t.rieulphieuphkorean = 0x313f;
  28410. t.rieulpieupkorean = 0x313c;
  28411. t.rieulpieupsioskorean = 0x316b;
  28412. t.rieulsioskorean = 0x313d;
  28413. t.rieulthieuthkorean = 0x313e;
  28414. t.rieultikeutkorean = 0x316a;
  28415. t.rieulyeorinhieuhkorean = 0x316d;
  28416. t.rightangle = 0x221f;
  28417. t.righttackbelowcmb = 0x0319;
  28418. t.righttriangle = 0x22bf;
  28419. t.rihiragana = 0x308a;
  28420. t.rikatakana = 0x30ea;
  28421. t.rikatakanahalfwidth = 0xff98;
  28422. t.ring = 0x02da;
  28423. t.ringbelowcmb = 0x0325;
  28424. t.ringcmb = 0x030a;
  28425. t.ringhalfleft = 0x02bf;
  28426. t.ringhalfleftarmenian = 0x0559;
  28427. t.ringhalfleftbelowcmb = 0x031c;
  28428. t.ringhalfleftcentered = 0x02d3;
  28429. t.ringhalfright = 0x02be;
  28430. t.ringhalfrightbelowcmb = 0x0339;
  28431. t.ringhalfrightcentered = 0x02d2;
  28432. t.rinvertedbreve = 0x0213;
  28433. t.rittorusquare = 0x3351;
  28434. t.rlinebelow = 0x1e5f;
  28435. t.rlongleg = 0x027c;
  28436. t.rlonglegturned = 0x027a;
  28437. t.rmonospace = 0xff52;
  28438. t.rohiragana = 0x308d;
  28439. t.rokatakana = 0x30ed;
  28440. t.rokatakanahalfwidth = 0xff9b;
  28441. t.roruathai = 0x0e23;
  28442. t.rparen = 0x24ad;
  28443. t.rrabengali = 0x09dc;
  28444. t.rradeva = 0x0931;
  28445. t.rragurmukhi = 0x0a5c;
  28446. t.rreharabic = 0x0691;
  28447. t.rrehfinalarabic = 0xfb8d;
  28448. t.rrvocalicbengali = 0x09e0;
  28449. t.rrvocalicdeva = 0x0960;
  28450. t.rrvocalicgujarati = 0x0ae0;
  28451. t.rrvocalicvowelsignbengali = 0x09c4;
  28452. t.rrvocalicvowelsigndeva = 0x0944;
  28453. t.rrvocalicvowelsigngujarati = 0x0ac4;
  28454. t.rsuperior = 0xf6f1;
  28455. t.rtblock = 0x2590;
  28456. t.rturned = 0x0279;
  28457. t.rturnedsuperior = 0x02b4;
  28458. t.ruhiragana = 0x308b;
  28459. t.rukatakana = 0x30eb;
  28460. t.rukatakanahalfwidth = 0xff99;
  28461. t.rupeemarkbengali = 0x09f2;
  28462. t.rupeesignbengali = 0x09f3;
  28463. t.rupiah = 0xf6dd;
  28464. t.ruthai = 0x0e24;
  28465. t.rvocalicbengali = 0x098b;
  28466. t.rvocalicdeva = 0x090b;
  28467. t.rvocalicgujarati = 0x0a8b;
  28468. t.rvocalicvowelsignbengali = 0x09c3;
  28469. t.rvocalicvowelsigndeva = 0x0943;
  28470. t.rvocalicvowelsigngujarati = 0x0ac3;
  28471. t.s = 0x0073;
  28472. t.sabengali = 0x09b8;
  28473. t.sacute = 0x015b;
  28474. t.sacutedotaccent = 0x1e65;
  28475. t.sadarabic = 0x0635;
  28476. t.sadeva = 0x0938;
  28477. t.sadfinalarabic = 0xfeba;
  28478. t.sadinitialarabic = 0xfebb;
  28479. t.sadmedialarabic = 0xfebc;
  28480. t.sagujarati = 0x0ab8;
  28481. t.sagurmukhi = 0x0a38;
  28482. t.sahiragana = 0x3055;
  28483. t.sakatakana = 0x30b5;
  28484. t.sakatakanahalfwidth = 0xff7b;
  28485. t.sallallahoualayhewasallamarabic = 0xfdfa;
  28486. t.samekh = 0x05e1;
  28487. t.samekhdagesh = 0xfb41;
  28488. t.samekhdageshhebrew = 0xfb41;
  28489. t.samekhhebrew = 0x05e1;
  28490. t.saraaathai = 0x0e32;
  28491. t.saraaethai = 0x0e41;
  28492. t.saraaimaimalaithai = 0x0e44;
  28493. t.saraaimaimuanthai = 0x0e43;
  28494. t.saraamthai = 0x0e33;
  28495. t.saraathai = 0x0e30;
  28496. t.saraethai = 0x0e40;
  28497. t.saraiileftthai = 0xf886;
  28498. t.saraiithai = 0x0e35;
  28499. t.saraileftthai = 0xf885;
  28500. t.saraithai = 0x0e34;
  28501. t.saraothai = 0x0e42;
  28502. t.saraueeleftthai = 0xf888;
  28503. t.saraueethai = 0x0e37;
  28504. t.saraueleftthai = 0xf887;
  28505. t.sarauethai = 0x0e36;
  28506. t.sarauthai = 0x0e38;
  28507. t.sarauuthai = 0x0e39;
  28508. t.sbopomofo = 0x3119;
  28509. t.scaron = 0x0161;
  28510. t.scarondotaccent = 0x1e67;
  28511. t.scedilla = 0x015f;
  28512. t.schwa = 0x0259;
  28513. t.schwacyrillic = 0x04d9;
  28514. t.schwadieresiscyrillic = 0x04db;
  28515. t.schwahook = 0x025a;
  28516. t.scircle = 0x24e2;
  28517. t.scircumflex = 0x015d;
  28518. t.scommaaccent = 0x0219;
  28519. t.sdotaccent = 0x1e61;
  28520. t.sdotbelow = 0x1e63;
  28521. t.sdotbelowdotaccent = 0x1e69;
  28522. t.seagullbelowcmb = 0x033c;
  28523. t.second = 0x2033;
  28524. t.secondtonechinese = 0x02ca;
  28525. t.section = 0x00a7;
  28526. t.seenarabic = 0x0633;
  28527. t.seenfinalarabic = 0xfeb2;
  28528. t.seeninitialarabic = 0xfeb3;
  28529. t.seenmedialarabic = 0xfeb4;
  28530. t.segol = 0x05b6;
  28531. t.segol13 = 0x05b6;
  28532. t.segol1f = 0x05b6;
  28533. t.segol2c = 0x05b6;
  28534. t.segolhebrew = 0x05b6;
  28535. t.segolnarrowhebrew = 0x05b6;
  28536. t.segolquarterhebrew = 0x05b6;
  28537. t.segoltahebrew = 0x0592;
  28538. t.segolwidehebrew = 0x05b6;
  28539. t.seharmenian = 0x057d;
  28540. t.sehiragana = 0x305b;
  28541. t.sekatakana = 0x30bb;
  28542. t.sekatakanahalfwidth = 0xff7e;
  28543. t.semicolon = 0x003b;
  28544. t.semicolonarabic = 0x061b;
  28545. t.semicolonmonospace = 0xff1b;
  28546. t.semicolonsmall = 0xfe54;
  28547. t.semivoicedmarkkana = 0x309c;
  28548. t.semivoicedmarkkanahalfwidth = 0xff9f;
  28549. t.sentisquare = 0x3322;
  28550. t.sentosquare = 0x3323;
  28551. t.seven = 0x0037;
  28552. t.sevenarabic = 0x0667;
  28553. t.sevenbengali = 0x09ed;
  28554. t.sevencircle = 0x2466;
  28555. t.sevencircleinversesansserif = 0x2790;
  28556. t.sevendeva = 0x096d;
  28557. t.seveneighths = 0x215e;
  28558. t.sevengujarati = 0x0aed;
  28559. t.sevengurmukhi = 0x0a6d;
  28560. t.sevenhackarabic = 0x0667;
  28561. t.sevenhangzhou = 0x3027;
  28562. t.sevenideographicparen = 0x3226;
  28563. t.seveninferior = 0x2087;
  28564. t.sevenmonospace = 0xff17;
  28565. t.sevenoldstyle = 0xf737;
  28566. t.sevenparen = 0x247a;
  28567. t.sevenperiod = 0x248e;
  28568. t.sevenpersian = 0x06f7;
  28569. t.sevenroman = 0x2176;
  28570. t.sevensuperior = 0x2077;
  28571. t.seventeencircle = 0x2470;
  28572. t.seventeenparen = 0x2484;
  28573. t.seventeenperiod = 0x2498;
  28574. t.seventhai = 0x0e57;
  28575. t.sfthyphen = 0x00ad;
  28576. t.shaarmenian = 0x0577;
  28577. t.shabengali = 0x09b6;
  28578. t.shacyrillic = 0x0448;
  28579. t.shaddaarabic = 0x0651;
  28580. t.shaddadammaarabic = 0xfc61;
  28581. t.shaddadammatanarabic = 0xfc5e;
  28582. t.shaddafathaarabic = 0xfc60;
  28583. t.shaddakasraarabic = 0xfc62;
  28584. t.shaddakasratanarabic = 0xfc5f;
  28585. t.shade = 0x2592;
  28586. t.shadedark = 0x2593;
  28587. t.shadelight = 0x2591;
  28588. t.shademedium = 0x2592;
  28589. t.shadeva = 0x0936;
  28590. t.shagujarati = 0x0ab6;
  28591. t.shagurmukhi = 0x0a36;
  28592. t.shalshelethebrew = 0x0593;
  28593. t.shbopomofo = 0x3115;
  28594. t.shchacyrillic = 0x0449;
  28595. t.sheenarabic = 0x0634;
  28596. t.sheenfinalarabic = 0xfeb6;
  28597. t.sheeninitialarabic = 0xfeb7;
  28598. t.sheenmedialarabic = 0xfeb8;
  28599. t.sheicoptic = 0x03e3;
  28600. t.sheqel = 0x20aa;
  28601. t.sheqelhebrew = 0x20aa;
  28602. t.sheva = 0x05b0;
  28603. t.sheva115 = 0x05b0;
  28604. t.sheva15 = 0x05b0;
  28605. t.sheva22 = 0x05b0;
  28606. t.sheva2e = 0x05b0;
  28607. t.shevahebrew = 0x05b0;
  28608. t.shevanarrowhebrew = 0x05b0;
  28609. t.shevaquarterhebrew = 0x05b0;
  28610. t.shevawidehebrew = 0x05b0;
  28611. t.shhacyrillic = 0x04bb;
  28612. t.shimacoptic = 0x03ed;
  28613. t.shin = 0x05e9;
  28614. t.shindagesh = 0xfb49;
  28615. t.shindageshhebrew = 0xfb49;
  28616. t.shindageshshindot = 0xfb2c;
  28617. t.shindageshshindothebrew = 0xfb2c;
  28618. t.shindageshsindot = 0xfb2d;
  28619. t.shindageshsindothebrew = 0xfb2d;
  28620. t.shindothebrew = 0x05c1;
  28621. t.shinhebrew = 0x05e9;
  28622. t.shinshindot = 0xfb2a;
  28623. t.shinshindothebrew = 0xfb2a;
  28624. t.shinsindot = 0xfb2b;
  28625. t.shinsindothebrew = 0xfb2b;
  28626. t.shook = 0x0282;
  28627. t.sigma = 0x03c3;
  28628. t.sigma1 = 0x03c2;
  28629. t.sigmafinal = 0x03c2;
  28630. t.sigmalunatesymbolgreek = 0x03f2;
  28631. t.sihiragana = 0x3057;
  28632. t.sikatakana = 0x30b7;
  28633. t.sikatakanahalfwidth = 0xff7c;
  28634. t.siluqhebrew = 0x05bd;
  28635. t.siluqlefthebrew = 0x05bd;
  28636. t.similar = 0x223c;
  28637. t.sindothebrew = 0x05c2;
  28638. t.siosacirclekorean = 0x3274;
  28639. t.siosaparenkorean = 0x3214;
  28640. t.sioscieuckorean = 0x317e;
  28641. t.sioscirclekorean = 0x3266;
  28642. t.sioskiyeokkorean = 0x317a;
  28643. t.sioskorean = 0x3145;
  28644. t.siosnieunkorean = 0x317b;
  28645. t.siosparenkorean = 0x3206;
  28646. t.siospieupkorean = 0x317d;
  28647. t.siostikeutkorean = 0x317c;
  28648. t.six = 0x0036;
  28649. t.sixarabic = 0x0666;
  28650. t.sixbengali = 0x09ec;
  28651. t.sixcircle = 0x2465;
  28652. t.sixcircleinversesansserif = 0x278f;
  28653. t.sixdeva = 0x096c;
  28654. t.sixgujarati = 0x0aec;
  28655. t.sixgurmukhi = 0x0a6c;
  28656. t.sixhackarabic = 0x0666;
  28657. t.sixhangzhou = 0x3026;
  28658. t.sixideographicparen = 0x3225;
  28659. t.sixinferior = 0x2086;
  28660. t.sixmonospace = 0xff16;
  28661. t.sixoldstyle = 0xf736;
  28662. t.sixparen = 0x2479;
  28663. t.sixperiod = 0x248d;
  28664. t.sixpersian = 0x06f6;
  28665. t.sixroman = 0x2175;
  28666. t.sixsuperior = 0x2076;
  28667. t.sixteencircle = 0x246f;
  28668. t.sixteencurrencydenominatorbengali = 0x09f9;
  28669. t.sixteenparen = 0x2483;
  28670. t.sixteenperiod = 0x2497;
  28671. t.sixthai = 0x0e56;
  28672. t.slash = 0x002f;
  28673. t.slashmonospace = 0xff0f;
  28674. t.slong = 0x017f;
  28675. t.slongdotaccent = 0x1e9b;
  28676. t.smileface = 0x263a;
  28677. t.smonospace = 0xff53;
  28678. t.sofpasuqhebrew = 0x05c3;
  28679. t.softhyphen = 0x00ad;
  28680. t.softsigncyrillic = 0x044c;
  28681. t.sohiragana = 0x305d;
  28682. t.sokatakana = 0x30bd;
  28683. t.sokatakanahalfwidth = 0xff7f;
  28684. t.soliduslongoverlaycmb = 0x0338;
  28685. t.solidusshortoverlaycmb = 0x0337;
  28686. t.sorusithai = 0x0e29;
  28687. t.sosalathai = 0x0e28;
  28688. t.sosothai = 0x0e0b;
  28689. t.sosuathai = 0x0e2a;
  28690. t.space = 0x0020;
  28691. t.spacehackarabic = 0x0020;
  28692. t.spade = 0x2660;
  28693. t.spadesuitblack = 0x2660;
  28694. t.spadesuitwhite = 0x2664;
  28695. t.sparen = 0x24ae;
  28696. t.squarebelowcmb = 0x033b;
  28697. t.squarecc = 0x33c4;
  28698. t.squarecm = 0x339d;
  28699. t.squarediagonalcrosshatchfill = 0x25a9;
  28700. t.squarehorizontalfill = 0x25a4;
  28701. t.squarekg = 0x338f;
  28702. t.squarekm = 0x339e;
  28703. t.squarekmcapital = 0x33ce;
  28704. t.squareln = 0x33d1;
  28705. t.squarelog = 0x33d2;
  28706. t.squaremg = 0x338e;
  28707. t.squaremil = 0x33d5;
  28708. t.squaremm = 0x339c;
  28709. t.squaremsquared = 0x33a1;
  28710. t.squareorthogonalcrosshatchfill = 0x25a6;
  28711. t.squareupperlefttolowerrightfill = 0x25a7;
  28712. t.squareupperrighttolowerleftfill = 0x25a8;
  28713. t.squareverticalfill = 0x25a5;
  28714. t.squarewhitewithsmallblack = 0x25a3;
  28715. t.srsquare = 0x33db;
  28716. t.ssabengali = 0x09b7;
  28717. t.ssadeva = 0x0937;
  28718. t.ssagujarati = 0x0ab7;
  28719. t.ssangcieuckorean = 0x3149;
  28720. t.ssanghieuhkorean = 0x3185;
  28721. t.ssangieungkorean = 0x3180;
  28722. t.ssangkiyeokkorean = 0x3132;
  28723. t.ssangnieunkorean = 0x3165;
  28724. t.ssangpieupkorean = 0x3143;
  28725. t.ssangsioskorean = 0x3146;
  28726. t.ssangtikeutkorean = 0x3138;
  28727. t.ssuperior = 0xf6f2;
  28728. t.sterling = 0x00a3;
  28729. t.sterlingmonospace = 0xffe1;
  28730. t.strokelongoverlaycmb = 0x0336;
  28731. t.strokeshortoverlaycmb = 0x0335;
  28732. t.subset = 0x2282;
  28733. t.subsetnotequal = 0x228a;
  28734. t.subsetorequal = 0x2286;
  28735. t.succeeds = 0x227b;
  28736. t.suchthat = 0x220b;
  28737. t.suhiragana = 0x3059;
  28738. t.sukatakana = 0x30b9;
  28739. t.sukatakanahalfwidth = 0xff7d;
  28740. t.sukunarabic = 0x0652;
  28741. t.summation = 0x2211;
  28742. t.sun = 0x263c;
  28743. t.superset = 0x2283;
  28744. t.supersetnotequal = 0x228b;
  28745. t.supersetorequal = 0x2287;
  28746. t.svsquare = 0x33dc;
  28747. t.syouwaerasquare = 0x337c;
  28748. t.t = 0x0074;
  28749. t.tabengali = 0x09a4;
  28750. t.tackdown = 0x22a4;
  28751. t.tackleft = 0x22a3;
  28752. t.tadeva = 0x0924;
  28753. t.tagujarati = 0x0aa4;
  28754. t.tagurmukhi = 0x0a24;
  28755. t.taharabic = 0x0637;
  28756. t.tahfinalarabic = 0xfec2;
  28757. t.tahinitialarabic = 0xfec3;
  28758. t.tahiragana = 0x305f;
  28759. t.tahmedialarabic = 0xfec4;
  28760. t.taisyouerasquare = 0x337d;
  28761. t.takatakana = 0x30bf;
  28762. t.takatakanahalfwidth = 0xff80;
  28763. t.tatweelarabic = 0x0640;
  28764. t.tau = 0x03c4;
  28765. t.tav = 0x05ea;
  28766. t.tavdages = 0xfb4a;
  28767. t.tavdagesh = 0xfb4a;
  28768. t.tavdageshhebrew = 0xfb4a;
  28769. t.tavhebrew = 0x05ea;
  28770. t.tbar = 0x0167;
  28771. t.tbopomofo = 0x310a;
  28772. t.tcaron = 0x0165;
  28773. t.tccurl = 0x02a8;
  28774. t.tcedilla = 0x0163;
  28775. t.tcheharabic = 0x0686;
  28776. t.tchehfinalarabic = 0xfb7b;
  28777. t.tchehinitialarabic = 0xfb7c;
  28778. t.tchehmedialarabic = 0xfb7d;
  28779. t.tcircle = 0x24e3;
  28780. t.tcircumflexbelow = 0x1e71;
  28781. t.tcommaaccent = 0x0163;
  28782. t.tdieresis = 0x1e97;
  28783. t.tdotaccent = 0x1e6b;
  28784. t.tdotbelow = 0x1e6d;
  28785. t.tecyrillic = 0x0442;
  28786. t.tedescendercyrillic = 0x04ad;
  28787. t.teharabic = 0x062a;
  28788. t.tehfinalarabic = 0xfe96;
  28789. t.tehhahinitialarabic = 0xfca2;
  28790. t.tehhahisolatedarabic = 0xfc0c;
  28791. t.tehinitialarabic = 0xfe97;
  28792. t.tehiragana = 0x3066;
  28793. t.tehjeeminitialarabic = 0xfca1;
  28794. t.tehjeemisolatedarabic = 0xfc0b;
  28795. t.tehmarbutaarabic = 0x0629;
  28796. t.tehmarbutafinalarabic = 0xfe94;
  28797. t.tehmedialarabic = 0xfe98;
  28798. t.tehmeeminitialarabic = 0xfca4;
  28799. t.tehmeemisolatedarabic = 0xfc0e;
  28800. t.tehnoonfinalarabic = 0xfc73;
  28801. t.tekatakana = 0x30c6;
  28802. t.tekatakanahalfwidth = 0xff83;
  28803. t.telephone = 0x2121;
  28804. t.telephoneblack = 0x260e;
  28805. t.telishagedolahebrew = 0x05a0;
  28806. t.telishaqetanahebrew = 0x05a9;
  28807. t.tencircle = 0x2469;
  28808. t.tenideographicparen = 0x3229;
  28809. t.tenparen = 0x247d;
  28810. t.tenperiod = 0x2491;
  28811. t.tenroman = 0x2179;
  28812. t.tesh = 0x02a7;
  28813. t.tet = 0x05d8;
  28814. t.tetdagesh = 0xfb38;
  28815. t.tetdageshhebrew = 0xfb38;
  28816. t.tethebrew = 0x05d8;
  28817. t.tetsecyrillic = 0x04b5;
  28818. t.tevirhebrew = 0x059b;
  28819. t.tevirlefthebrew = 0x059b;
  28820. t.thabengali = 0x09a5;
  28821. t.thadeva = 0x0925;
  28822. t.thagujarati = 0x0aa5;
  28823. t.thagurmukhi = 0x0a25;
  28824. t.thalarabic = 0x0630;
  28825. t.thalfinalarabic = 0xfeac;
  28826. t.thanthakhatlowleftthai = 0xf898;
  28827. t.thanthakhatlowrightthai = 0xf897;
  28828. t.thanthakhatthai = 0x0e4c;
  28829. t.thanthakhatupperleftthai = 0xf896;
  28830. t.theharabic = 0x062b;
  28831. t.thehfinalarabic = 0xfe9a;
  28832. t.thehinitialarabic = 0xfe9b;
  28833. t.thehmedialarabic = 0xfe9c;
  28834. t.thereexists = 0x2203;
  28835. t.therefore = 0x2234;
  28836. t.theta = 0x03b8;
  28837. t.theta1 = 0x03d1;
  28838. t.thetasymbolgreek = 0x03d1;
  28839. t.thieuthacirclekorean = 0x3279;
  28840. t.thieuthaparenkorean = 0x3219;
  28841. t.thieuthcirclekorean = 0x326b;
  28842. t.thieuthkorean = 0x314c;
  28843. t.thieuthparenkorean = 0x320b;
  28844. t.thirteencircle = 0x246c;
  28845. t.thirteenparen = 0x2480;
  28846. t.thirteenperiod = 0x2494;
  28847. t.thonangmonthothai = 0x0e11;
  28848. t.thook = 0x01ad;
  28849. t.thophuthaothai = 0x0e12;
  28850. t.thorn = 0x00fe;
  28851. t.thothahanthai = 0x0e17;
  28852. t.thothanthai = 0x0e10;
  28853. t.thothongthai = 0x0e18;
  28854. t.thothungthai = 0x0e16;
  28855. t.thousandcyrillic = 0x0482;
  28856. t.thousandsseparatorarabic = 0x066c;
  28857. t.thousandsseparatorpersian = 0x066c;
  28858. t.three = 0x0033;
  28859. t.threearabic = 0x0663;
  28860. t.threebengali = 0x09e9;
  28861. t.threecircle = 0x2462;
  28862. t.threecircleinversesansserif = 0x278c;
  28863. t.threedeva = 0x0969;
  28864. t.threeeighths = 0x215c;
  28865. t.threegujarati = 0x0ae9;
  28866. t.threegurmukhi = 0x0a69;
  28867. t.threehackarabic = 0x0663;
  28868. t.threehangzhou = 0x3023;
  28869. t.threeideographicparen = 0x3222;
  28870. t.threeinferior = 0x2083;
  28871. t.threemonospace = 0xff13;
  28872. t.threenumeratorbengali = 0x09f6;
  28873. t.threeoldstyle = 0xf733;
  28874. t.threeparen = 0x2476;
  28875. t.threeperiod = 0x248a;
  28876. t.threepersian = 0x06f3;
  28877. t.threequarters = 0x00be;
  28878. t.threequartersemdash = 0xf6de;
  28879. t.threeroman = 0x2172;
  28880. t.threesuperior = 0x00b3;
  28881. t.threethai = 0x0e53;
  28882. t.thzsquare = 0x3394;
  28883. t.tihiragana = 0x3061;
  28884. t.tikatakana = 0x30c1;
  28885. t.tikatakanahalfwidth = 0xff81;
  28886. t.tikeutacirclekorean = 0x3270;
  28887. t.tikeutaparenkorean = 0x3210;
  28888. t.tikeutcirclekorean = 0x3262;
  28889. t.tikeutkorean = 0x3137;
  28890. t.tikeutparenkorean = 0x3202;
  28891. t.tilde = 0x02dc;
  28892. t.tildebelowcmb = 0x0330;
  28893. t.tildecmb = 0x0303;
  28894. t.tildecomb = 0x0303;
  28895. t.tildedoublecmb = 0x0360;
  28896. t.tildeoperator = 0x223c;
  28897. t.tildeoverlaycmb = 0x0334;
  28898. t.tildeverticalcmb = 0x033e;
  28899. t.timescircle = 0x2297;
  28900. t.tipehahebrew = 0x0596;
  28901. t.tipehalefthebrew = 0x0596;
  28902. t.tippigurmukhi = 0x0a70;
  28903. t.titlocyrilliccmb = 0x0483;
  28904. t.tiwnarmenian = 0x057f;
  28905. t.tlinebelow = 0x1e6f;
  28906. t.tmonospace = 0xff54;
  28907. t.toarmenian = 0x0569;
  28908. t.tohiragana = 0x3068;
  28909. t.tokatakana = 0x30c8;
  28910. t.tokatakanahalfwidth = 0xff84;
  28911. t.tonebarextrahighmod = 0x02e5;
  28912. t.tonebarextralowmod = 0x02e9;
  28913. t.tonebarhighmod = 0x02e6;
  28914. t.tonebarlowmod = 0x02e8;
  28915. t.tonebarmidmod = 0x02e7;
  28916. t.tonefive = 0x01bd;
  28917. t.tonesix = 0x0185;
  28918. t.tonetwo = 0x01a8;
  28919. t.tonos = 0x0384;
  28920. t.tonsquare = 0x3327;
  28921. t.topatakthai = 0x0e0f;
  28922. t.tortoiseshellbracketleft = 0x3014;
  28923. t.tortoiseshellbracketleftsmall = 0xfe5d;
  28924. t.tortoiseshellbracketleftvertical = 0xfe39;
  28925. t.tortoiseshellbracketright = 0x3015;
  28926. t.tortoiseshellbracketrightsmall = 0xfe5e;
  28927. t.tortoiseshellbracketrightvertical = 0xfe3a;
  28928. t.totaothai = 0x0e15;
  28929. t.tpalatalhook = 0x01ab;
  28930. t.tparen = 0x24af;
  28931. t.trademark = 0x2122;
  28932. t.trademarksans = 0xf8ea;
  28933. t.trademarkserif = 0xf6db;
  28934. t.tretroflexhook = 0x0288;
  28935. t.triagdn = 0x25bc;
  28936. t.triaglf = 0x25c4;
  28937. t.triagrt = 0x25ba;
  28938. t.triagup = 0x25b2;
  28939. t.ts = 0x02a6;
  28940. t.tsadi = 0x05e6;
  28941. t.tsadidagesh = 0xfb46;
  28942. t.tsadidageshhebrew = 0xfb46;
  28943. t.tsadihebrew = 0x05e6;
  28944. t.tsecyrillic = 0x0446;
  28945. t.tsere = 0x05b5;
  28946. t.tsere12 = 0x05b5;
  28947. t.tsere1e = 0x05b5;
  28948. t.tsere2b = 0x05b5;
  28949. t.tserehebrew = 0x05b5;
  28950. t.tserenarrowhebrew = 0x05b5;
  28951. t.tserequarterhebrew = 0x05b5;
  28952. t.tserewidehebrew = 0x05b5;
  28953. t.tshecyrillic = 0x045b;
  28954. t.tsuperior = 0xf6f3;
  28955. t.ttabengali = 0x099f;
  28956. t.ttadeva = 0x091f;
  28957. t.ttagujarati = 0x0a9f;
  28958. t.ttagurmukhi = 0x0a1f;
  28959. t.tteharabic = 0x0679;
  28960. t.ttehfinalarabic = 0xfb67;
  28961. t.ttehinitialarabic = 0xfb68;
  28962. t.ttehmedialarabic = 0xfb69;
  28963. t.tthabengali = 0x09a0;
  28964. t.tthadeva = 0x0920;
  28965. t.tthagujarati = 0x0aa0;
  28966. t.tthagurmukhi = 0x0a20;
  28967. t.tturned = 0x0287;
  28968. t.tuhiragana = 0x3064;
  28969. t.tukatakana = 0x30c4;
  28970. t.tukatakanahalfwidth = 0xff82;
  28971. t.tusmallhiragana = 0x3063;
  28972. t.tusmallkatakana = 0x30c3;
  28973. t.tusmallkatakanahalfwidth = 0xff6f;
  28974. t.twelvecircle = 0x246b;
  28975. t.twelveparen = 0x247f;
  28976. t.twelveperiod = 0x2493;
  28977. t.twelveroman = 0x217b;
  28978. t.twentycircle = 0x2473;
  28979. t.twentyhangzhou = 0x5344;
  28980. t.twentyparen = 0x2487;
  28981. t.twentyperiod = 0x249b;
  28982. t.two = 0x0032;
  28983. t.twoarabic = 0x0662;
  28984. t.twobengali = 0x09e8;
  28985. t.twocircle = 0x2461;
  28986. t.twocircleinversesansserif = 0x278b;
  28987. t.twodeva = 0x0968;
  28988. t.twodotenleader = 0x2025;
  28989. t.twodotleader = 0x2025;
  28990. t.twodotleadervertical = 0xfe30;
  28991. t.twogujarati = 0x0ae8;
  28992. t.twogurmukhi = 0x0a68;
  28993. t.twohackarabic = 0x0662;
  28994. t.twohangzhou = 0x3022;
  28995. t.twoideographicparen = 0x3221;
  28996. t.twoinferior = 0x2082;
  28997. t.twomonospace = 0xff12;
  28998. t.twonumeratorbengali = 0x09f5;
  28999. t.twooldstyle = 0xf732;
  29000. t.twoparen = 0x2475;
  29001. t.twoperiod = 0x2489;
  29002. t.twopersian = 0x06f2;
  29003. t.tworoman = 0x2171;
  29004. t.twostroke = 0x01bb;
  29005. t.twosuperior = 0x00b2;
  29006. t.twothai = 0x0e52;
  29007. t.twothirds = 0x2154;
  29008. t.u = 0x0075;
  29009. t.uacute = 0x00fa;
  29010. t.ubar = 0x0289;
  29011. t.ubengali = 0x0989;
  29012. t.ubopomofo = 0x3128;
  29013. t.ubreve = 0x016d;
  29014. t.ucaron = 0x01d4;
  29015. t.ucircle = 0x24e4;
  29016. t.ucircumflex = 0x00fb;
  29017. t.ucircumflexbelow = 0x1e77;
  29018. t.ucyrillic = 0x0443;
  29019. t.udattadeva = 0x0951;
  29020. t.udblacute = 0x0171;
  29021. t.udblgrave = 0x0215;
  29022. t.udeva = 0x0909;
  29023. t.udieresis = 0x00fc;
  29024. t.udieresisacute = 0x01d8;
  29025. t.udieresisbelow = 0x1e73;
  29026. t.udieresiscaron = 0x01da;
  29027. t.udieresiscyrillic = 0x04f1;
  29028. t.udieresisgrave = 0x01dc;
  29029. t.udieresismacron = 0x01d6;
  29030. t.udotbelow = 0x1ee5;
  29031. t.ugrave = 0x00f9;
  29032. t.ugujarati = 0x0a89;
  29033. t.ugurmukhi = 0x0a09;
  29034. t.uhiragana = 0x3046;
  29035. t.uhookabove = 0x1ee7;
  29036. t.uhorn = 0x01b0;
  29037. t.uhornacute = 0x1ee9;
  29038. t.uhorndotbelow = 0x1ef1;
  29039. t.uhorngrave = 0x1eeb;
  29040. t.uhornhookabove = 0x1eed;
  29041. t.uhorntilde = 0x1eef;
  29042. t.uhungarumlaut = 0x0171;
  29043. t.uhungarumlautcyrillic = 0x04f3;
  29044. t.uinvertedbreve = 0x0217;
  29045. t.ukatakana = 0x30a6;
  29046. t.ukatakanahalfwidth = 0xff73;
  29047. t.ukcyrillic = 0x0479;
  29048. t.ukorean = 0x315c;
  29049. t.umacron = 0x016b;
  29050. t.umacroncyrillic = 0x04ef;
  29051. t.umacrondieresis = 0x1e7b;
  29052. t.umatragurmukhi = 0x0a41;
  29053. t.umonospace = 0xff55;
  29054. t.underscore = 0x005f;
  29055. t.underscoredbl = 0x2017;
  29056. t.underscoremonospace = 0xff3f;
  29057. t.underscorevertical = 0xfe33;
  29058. t.underscorewavy = 0xfe4f;
  29059. t.union = 0x222a;
  29060. t.universal = 0x2200;
  29061. t.uogonek = 0x0173;
  29062. t.uparen = 0x24b0;
  29063. t.upblock = 0x2580;
  29064. t.upperdothebrew = 0x05c4;
  29065. t.upsilon = 0x03c5;
  29066. t.upsilondieresis = 0x03cb;
  29067. t.upsilondieresistonos = 0x03b0;
  29068. t.upsilonlatin = 0x028a;
  29069. t.upsilontonos = 0x03cd;
  29070. t.uptackbelowcmb = 0x031d;
  29071. t.uptackmod = 0x02d4;
  29072. t.uragurmukhi = 0x0a73;
  29073. t.uring = 0x016f;
  29074. t.ushortcyrillic = 0x045e;
  29075. t.usmallhiragana = 0x3045;
  29076. t.usmallkatakana = 0x30a5;
  29077. t.usmallkatakanahalfwidth = 0xff69;
  29078. t.ustraightcyrillic = 0x04af;
  29079. t.ustraightstrokecyrillic = 0x04b1;
  29080. t.utilde = 0x0169;
  29081. t.utildeacute = 0x1e79;
  29082. t.utildebelow = 0x1e75;
  29083. t.uubengali = 0x098a;
  29084. t.uudeva = 0x090a;
  29085. t.uugujarati = 0x0a8a;
  29086. t.uugurmukhi = 0x0a0a;
  29087. t.uumatragurmukhi = 0x0a42;
  29088. t.uuvowelsignbengali = 0x09c2;
  29089. t.uuvowelsigndeva = 0x0942;
  29090. t.uuvowelsigngujarati = 0x0ac2;
  29091. t.uvowelsignbengali = 0x09c1;
  29092. t.uvowelsigndeva = 0x0941;
  29093. t.uvowelsigngujarati = 0x0ac1;
  29094. t.v = 0x0076;
  29095. t.vadeva = 0x0935;
  29096. t.vagujarati = 0x0ab5;
  29097. t.vagurmukhi = 0x0a35;
  29098. t.vakatakana = 0x30f7;
  29099. t.vav = 0x05d5;
  29100. t.vavdagesh = 0xfb35;
  29101. t.vavdagesh65 = 0xfb35;
  29102. t.vavdageshhebrew = 0xfb35;
  29103. t.vavhebrew = 0x05d5;
  29104. t.vavholam = 0xfb4b;
  29105. t.vavholamhebrew = 0xfb4b;
  29106. t.vavvavhebrew = 0x05f0;
  29107. t.vavyodhebrew = 0x05f1;
  29108. t.vcircle = 0x24e5;
  29109. t.vdotbelow = 0x1e7f;
  29110. t.vecyrillic = 0x0432;
  29111. t.veharabic = 0x06a4;
  29112. t.vehfinalarabic = 0xfb6b;
  29113. t.vehinitialarabic = 0xfb6c;
  29114. t.vehmedialarabic = 0xfb6d;
  29115. t.vekatakana = 0x30f9;
  29116. t.venus = 0x2640;
  29117. t.verticalbar = 0x007c;
  29118. t.verticallineabovecmb = 0x030d;
  29119. t.verticallinebelowcmb = 0x0329;
  29120. t.verticallinelowmod = 0x02cc;
  29121. t.verticallinemod = 0x02c8;
  29122. t.vewarmenian = 0x057e;
  29123. t.vhook = 0x028b;
  29124. t.vikatakana = 0x30f8;
  29125. t.viramabengali = 0x09cd;
  29126. t.viramadeva = 0x094d;
  29127. t.viramagujarati = 0x0acd;
  29128. t.visargabengali = 0x0983;
  29129. t.visargadeva = 0x0903;
  29130. t.visargagujarati = 0x0a83;
  29131. t.vmonospace = 0xff56;
  29132. t.voarmenian = 0x0578;
  29133. t.voicediterationhiragana = 0x309e;
  29134. t.voicediterationkatakana = 0x30fe;
  29135. t.voicedmarkkana = 0x309b;
  29136. t.voicedmarkkanahalfwidth = 0xff9e;
  29137. t.vokatakana = 0x30fa;
  29138. t.vparen = 0x24b1;
  29139. t.vtilde = 0x1e7d;
  29140. t.vturned = 0x028c;
  29141. t.vuhiragana = 0x3094;
  29142. t.vukatakana = 0x30f4;
  29143. t.w = 0x0077;
  29144. t.wacute = 0x1e83;
  29145. t.waekorean = 0x3159;
  29146. t.wahiragana = 0x308f;
  29147. t.wakatakana = 0x30ef;
  29148. t.wakatakanahalfwidth = 0xff9c;
  29149. t.wakorean = 0x3158;
  29150. t.wasmallhiragana = 0x308e;
  29151. t.wasmallkatakana = 0x30ee;
  29152. t.wattosquare = 0x3357;
  29153. t.wavedash = 0x301c;
  29154. t.wavyunderscorevertical = 0xfe34;
  29155. t.wawarabic = 0x0648;
  29156. t.wawfinalarabic = 0xfeee;
  29157. t.wawhamzaabovearabic = 0x0624;
  29158. t.wawhamzaabovefinalarabic = 0xfe86;
  29159. t.wbsquare = 0x33dd;
  29160. t.wcircle = 0x24e6;
  29161. t.wcircumflex = 0x0175;
  29162. t.wdieresis = 0x1e85;
  29163. t.wdotaccent = 0x1e87;
  29164. t.wdotbelow = 0x1e89;
  29165. t.wehiragana = 0x3091;
  29166. t.weierstrass = 0x2118;
  29167. t.wekatakana = 0x30f1;
  29168. t.wekorean = 0x315e;
  29169. t.weokorean = 0x315d;
  29170. t.wgrave = 0x1e81;
  29171. t.whitebullet = 0x25e6;
  29172. t.whitecircle = 0x25cb;
  29173. t.whitecircleinverse = 0x25d9;
  29174. t.whitecornerbracketleft = 0x300e;
  29175. t.whitecornerbracketleftvertical = 0xfe43;
  29176. t.whitecornerbracketright = 0x300f;
  29177. t.whitecornerbracketrightvertical = 0xfe44;
  29178. t.whitediamond = 0x25c7;
  29179. t.whitediamondcontainingblacksmalldiamond = 0x25c8;
  29180. t.whitedownpointingsmalltriangle = 0x25bf;
  29181. t.whitedownpointingtriangle = 0x25bd;
  29182. t.whiteleftpointingsmalltriangle = 0x25c3;
  29183. t.whiteleftpointingtriangle = 0x25c1;
  29184. t.whitelenticularbracketleft = 0x3016;
  29185. t.whitelenticularbracketright = 0x3017;
  29186. t.whiterightpointingsmalltriangle = 0x25b9;
  29187. t.whiterightpointingtriangle = 0x25b7;
  29188. t.whitesmallsquare = 0x25ab;
  29189. t.whitesmilingface = 0x263a;
  29190. t.whitesquare = 0x25a1;
  29191. t.whitestar = 0x2606;
  29192. t.whitetelephone = 0x260f;
  29193. t.whitetortoiseshellbracketleft = 0x3018;
  29194. t.whitetortoiseshellbracketright = 0x3019;
  29195. t.whiteuppointingsmalltriangle = 0x25b5;
  29196. t.whiteuppointingtriangle = 0x25b3;
  29197. t.wihiragana = 0x3090;
  29198. t.wikatakana = 0x30f0;
  29199. t.wikorean = 0x315f;
  29200. t.wmonospace = 0xff57;
  29201. t.wohiragana = 0x3092;
  29202. t.wokatakana = 0x30f2;
  29203. t.wokatakanahalfwidth = 0xff66;
  29204. t.won = 0x20a9;
  29205. t.wonmonospace = 0xffe6;
  29206. t.wowaenthai = 0x0e27;
  29207. t.wparen = 0x24b2;
  29208. t.wring = 0x1e98;
  29209. t.wsuperior = 0x02b7;
  29210. t.wturned = 0x028d;
  29211. t.wynn = 0x01bf;
  29212. t.x = 0x0078;
  29213. t.xabovecmb = 0x033d;
  29214. t.xbopomofo = 0x3112;
  29215. t.xcircle = 0x24e7;
  29216. t.xdieresis = 0x1e8d;
  29217. t.xdotaccent = 0x1e8b;
  29218. t.xeharmenian = 0x056d;
  29219. t.xi = 0x03be;
  29220. t.xmonospace = 0xff58;
  29221. t.xparen = 0x24b3;
  29222. t.xsuperior = 0x02e3;
  29223. t.y = 0x0079;
  29224. t.yaadosquare = 0x334e;
  29225. t.yabengali = 0x09af;
  29226. t.yacute = 0x00fd;
  29227. t.yadeva = 0x092f;
  29228. t.yaekorean = 0x3152;
  29229. t.yagujarati = 0x0aaf;
  29230. t.yagurmukhi = 0x0a2f;
  29231. t.yahiragana = 0x3084;
  29232. t.yakatakana = 0x30e4;
  29233. t.yakatakanahalfwidth = 0xff94;
  29234. t.yakorean = 0x3151;
  29235. t.yamakkanthai = 0x0e4e;
  29236. t.yasmallhiragana = 0x3083;
  29237. t.yasmallkatakana = 0x30e3;
  29238. t.yasmallkatakanahalfwidth = 0xff6c;
  29239. t.yatcyrillic = 0x0463;
  29240. t.ycircle = 0x24e8;
  29241. t.ycircumflex = 0x0177;
  29242. t.ydieresis = 0x00ff;
  29243. t.ydotaccent = 0x1e8f;
  29244. t.ydotbelow = 0x1ef5;
  29245. t.yeharabic = 0x064a;
  29246. t.yehbarreearabic = 0x06d2;
  29247. t.yehbarreefinalarabic = 0xfbaf;
  29248. t.yehfinalarabic = 0xfef2;
  29249. t.yehhamzaabovearabic = 0x0626;
  29250. t.yehhamzaabovefinalarabic = 0xfe8a;
  29251. t.yehhamzaaboveinitialarabic = 0xfe8b;
  29252. t.yehhamzaabovemedialarabic = 0xfe8c;
  29253. t.yehinitialarabic = 0xfef3;
  29254. t.yehmedialarabic = 0xfef4;
  29255. t.yehmeeminitialarabic = 0xfcdd;
  29256. t.yehmeemisolatedarabic = 0xfc58;
  29257. t.yehnoonfinalarabic = 0xfc94;
  29258. t.yehthreedotsbelowarabic = 0x06d1;
  29259. t.yekorean = 0x3156;
  29260. t.yen = 0x00a5;
  29261. t.yenmonospace = 0xffe5;
  29262. t.yeokorean = 0x3155;
  29263. t.yeorinhieuhkorean = 0x3186;
  29264. t.yerahbenyomohebrew = 0x05aa;
  29265. t.yerahbenyomolefthebrew = 0x05aa;
  29266. t.yericyrillic = 0x044b;
  29267. t.yerudieresiscyrillic = 0x04f9;
  29268. t.yesieungkorean = 0x3181;
  29269. t.yesieungpansioskorean = 0x3183;
  29270. t.yesieungsioskorean = 0x3182;
  29271. t.yetivhebrew = 0x059a;
  29272. t.ygrave = 0x1ef3;
  29273. t.yhook = 0x01b4;
  29274. t.yhookabove = 0x1ef7;
  29275. t.yiarmenian = 0x0575;
  29276. t.yicyrillic = 0x0457;
  29277. t.yikorean = 0x3162;
  29278. t.yinyang = 0x262f;
  29279. t.yiwnarmenian = 0x0582;
  29280. t.ymonospace = 0xff59;
  29281. t.yod = 0x05d9;
  29282. t.yoddagesh = 0xfb39;
  29283. t.yoddageshhebrew = 0xfb39;
  29284. t.yodhebrew = 0x05d9;
  29285. t.yodyodhebrew = 0x05f2;
  29286. t.yodyodpatahhebrew = 0xfb1f;
  29287. t.yohiragana = 0x3088;
  29288. t.yoikorean = 0x3189;
  29289. t.yokatakana = 0x30e8;
  29290. t.yokatakanahalfwidth = 0xff96;
  29291. t.yokorean = 0x315b;
  29292. t.yosmallhiragana = 0x3087;
  29293. t.yosmallkatakana = 0x30e7;
  29294. t.yosmallkatakanahalfwidth = 0xff6e;
  29295. t.yotgreek = 0x03f3;
  29296. t.yoyaekorean = 0x3188;
  29297. t.yoyakorean = 0x3187;
  29298. t.yoyakthai = 0x0e22;
  29299. t.yoyingthai = 0x0e0d;
  29300. t.yparen = 0x24b4;
  29301. t.ypogegrammeni = 0x037a;
  29302. t.ypogegrammenigreekcmb = 0x0345;
  29303. t.yr = 0x01a6;
  29304. t.yring = 0x1e99;
  29305. t.ysuperior = 0x02b8;
  29306. t.ytilde = 0x1ef9;
  29307. t.yturned = 0x028e;
  29308. t.yuhiragana = 0x3086;
  29309. t.yuikorean = 0x318c;
  29310. t.yukatakana = 0x30e6;
  29311. t.yukatakanahalfwidth = 0xff95;
  29312. t.yukorean = 0x3160;
  29313. t.yusbigcyrillic = 0x046b;
  29314. t.yusbigiotifiedcyrillic = 0x046d;
  29315. t.yuslittlecyrillic = 0x0467;
  29316. t.yuslittleiotifiedcyrillic = 0x0469;
  29317. t.yusmallhiragana = 0x3085;
  29318. t.yusmallkatakana = 0x30e5;
  29319. t.yusmallkatakanahalfwidth = 0xff6d;
  29320. t.yuyekorean = 0x318b;
  29321. t.yuyeokorean = 0x318a;
  29322. t.yyabengali = 0x09df;
  29323. t.yyadeva = 0x095f;
  29324. t.z = 0x007a;
  29325. t.zaarmenian = 0x0566;
  29326. t.zacute = 0x017a;
  29327. t.zadeva = 0x095b;
  29328. t.zagurmukhi = 0x0a5b;
  29329. t.zaharabic = 0x0638;
  29330. t.zahfinalarabic = 0xfec6;
  29331. t.zahinitialarabic = 0xfec7;
  29332. t.zahiragana = 0x3056;
  29333. t.zahmedialarabic = 0xfec8;
  29334. t.zainarabic = 0x0632;
  29335. t.zainfinalarabic = 0xfeb0;
  29336. t.zakatakana = 0x30b6;
  29337. t.zaqefgadolhebrew = 0x0595;
  29338. t.zaqefqatanhebrew = 0x0594;
  29339. t.zarqahebrew = 0x0598;
  29340. t.zayin = 0x05d6;
  29341. t.zayindagesh = 0xfb36;
  29342. t.zayindageshhebrew = 0xfb36;
  29343. t.zayinhebrew = 0x05d6;
  29344. t.zbopomofo = 0x3117;
  29345. t.zcaron = 0x017e;
  29346. t.zcircle = 0x24e9;
  29347. t.zcircumflex = 0x1e91;
  29348. t.zcurl = 0x0291;
  29349. t.zdot = 0x017c;
  29350. t.zdotaccent = 0x017c;
  29351. t.zdotbelow = 0x1e93;
  29352. t.zecyrillic = 0x0437;
  29353. t.zedescendercyrillic = 0x0499;
  29354. t.zedieresiscyrillic = 0x04df;
  29355. t.zehiragana = 0x305c;
  29356. t.zekatakana = 0x30bc;
  29357. t.zero = 0x0030;
  29358. t.zeroarabic = 0x0660;
  29359. t.zerobengali = 0x09e6;
  29360. t.zerodeva = 0x0966;
  29361. t.zerogujarati = 0x0ae6;
  29362. t.zerogurmukhi = 0x0a66;
  29363. t.zerohackarabic = 0x0660;
  29364. t.zeroinferior = 0x2080;
  29365. t.zeromonospace = 0xff10;
  29366. t.zerooldstyle = 0xf730;
  29367. t.zeropersian = 0x06f0;
  29368. t.zerosuperior = 0x2070;
  29369. t.zerothai = 0x0e50;
  29370. t.zerowidthjoiner = 0xfeff;
  29371. t.zerowidthnonjoiner = 0x200c;
  29372. t.zerowidthspace = 0x200b;
  29373. t.zeta = 0x03b6;
  29374. t.zhbopomofo = 0x3113;
  29375. t.zhearmenian = 0x056a;
  29376. t.zhebrevecyrillic = 0x04c2;
  29377. t.zhecyrillic = 0x0436;
  29378. t.zhedescendercyrillic = 0x0497;
  29379. t.zhedieresiscyrillic = 0x04dd;
  29380. t.zihiragana = 0x3058;
  29381. t.zikatakana = 0x30b8;
  29382. t.zinorhebrew = 0x05ae;
  29383. t.zlinebelow = 0x1e95;
  29384. t.zmonospace = 0xff5a;
  29385. t.zohiragana = 0x305e;
  29386. t.zokatakana = 0x30be;
  29387. t.zparen = 0x24b5;
  29388. t.zretroflexhook = 0x0290;
  29389. t.zstroke = 0x01b6;
  29390. t.zuhiragana = 0x305a;
  29391. t.zukatakana = 0x30ba;
  29392. t[".notdef"] = 0x0000;
  29393. t.angbracketleftbig = 0x2329;
  29394. t.angbracketleftBig = 0x2329;
  29395. t.angbracketleftbigg = 0x2329;
  29396. t.angbracketleftBigg = 0x2329;
  29397. t.angbracketrightBig = 0x232a;
  29398. t.angbracketrightbig = 0x232a;
  29399. t.angbracketrightBigg = 0x232a;
  29400. t.angbracketrightbigg = 0x232a;
  29401. t.arrowhookleft = 0x21aa;
  29402. t.arrowhookright = 0x21a9;
  29403. t.arrowlefttophalf = 0x21bc;
  29404. t.arrowleftbothalf = 0x21bd;
  29405. t.arrownortheast = 0x2197;
  29406. t.arrownorthwest = 0x2196;
  29407. t.arrowrighttophalf = 0x21c0;
  29408. t.arrowrightbothalf = 0x21c1;
  29409. t.arrowsoutheast = 0x2198;
  29410. t.arrowsouthwest = 0x2199;
  29411. t.backslashbig = 0x2216;
  29412. t.backslashBig = 0x2216;
  29413. t.backslashBigg = 0x2216;
  29414. t.backslashbigg = 0x2216;
  29415. t.bardbl = 0x2016;
  29416. t.bracehtipdownleft = 0xfe37;
  29417. t.bracehtipdownright = 0xfe37;
  29418. t.bracehtipupleft = 0xfe38;
  29419. t.bracehtipupright = 0xfe38;
  29420. t.braceleftBig = 0x007b;
  29421. t.braceleftbig = 0x007b;
  29422. t.braceleftbigg = 0x007b;
  29423. t.braceleftBigg = 0x007b;
  29424. t.bracerightBig = 0x007d;
  29425. t.bracerightbig = 0x007d;
  29426. t.bracerightbigg = 0x007d;
  29427. t.bracerightBigg = 0x007d;
  29428. t.bracketleftbig = 0x005b;
  29429. t.bracketleftBig = 0x005b;
  29430. t.bracketleftbigg = 0x005b;
  29431. t.bracketleftBigg = 0x005b;
  29432. t.bracketrightBig = 0x005d;
  29433. t.bracketrightbig = 0x005d;
  29434. t.bracketrightbigg = 0x005d;
  29435. t.bracketrightBigg = 0x005d;
  29436. t.ceilingleftbig = 0x2308;
  29437. t.ceilingleftBig = 0x2308;
  29438. t.ceilingleftBigg = 0x2308;
  29439. t.ceilingleftbigg = 0x2308;
  29440. t.ceilingrightbig = 0x2309;
  29441. t.ceilingrightBig = 0x2309;
  29442. t.ceilingrightbigg = 0x2309;
  29443. t.ceilingrightBigg = 0x2309;
  29444. t.circledotdisplay = 0x2299;
  29445. t.circledottext = 0x2299;
  29446. t.circlemultiplydisplay = 0x2297;
  29447. t.circlemultiplytext = 0x2297;
  29448. t.circleplusdisplay = 0x2295;
  29449. t.circleplustext = 0x2295;
  29450. t.contintegraldisplay = 0x222e;
  29451. t.contintegraltext = 0x222e;
  29452. t.coproductdisplay = 0x2210;
  29453. t.coproducttext = 0x2210;
  29454. t.floorleftBig = 0x230a;
  29455. t.floorleftbig = 0x230a;
  29456. t.floorleftbigg = 0x230a;
  29457. t.floorleftBigg = 0x230a;
  29458. t.floorrightbig = 0x230b;
  29459. t.floorrightBig = 0x230b;
  29460. t.floorrightBigg = 0x230b;
  29461. t.floorrightbigg = 0x230b;
  29462. t.hatwide = 0x0302;
  29463. t.hatwider = 0x0302;
  29464. t.hatwidest = 0x0302;
  29465. t.intercal = 0x1d40;
  29466. t.integraldisplay = 0x222b;
  29467. t.integraltext = 0x222b;
  29468. t.intersectiondisplay = 0x22c2;
  29469. t.intersectiontext = 0x22c2;
  29470. t.logicalanddisplay = 0x2227;
  29471. t.logicalandtext = 0x2227;
  29472. t.logicalordisplay = 0x2228;
  29473. t.logicalortext = 0x2228;
  29474. t.parenleftBig = 0x0028;
  29475. t.parenleftbig = 0x0028;
  29476. t.parenleftBigg = 0x0028;
  29477. t.parenleftbigg = 0x0028;
  29478. t.parenrightBig = 0x0029;
  29479. t.parenrightbig = 0x0029;
  29480. t.parenrightBigg = 0x0029;
  29481. t.parenrightbigg = 0x0029;
  29482. t.prime = 0x2032;
  29483. t.productdisplay = 0x220f;
  29484. t.producttext = 0x220f;
  29485. t.radicalbig = 0x221a;
  29486. t.radicalBig = 0x221a;
  29487. t.radicalBigg = 0x221a;
  29488. t.radicalbigg = 0x221a;
  29489. t.radicalbt = 0x221a;
  29490. t.radicaltp = 0x221a;
  29491. t.radicalvertex = 0x221a;
  29492. t.slashbig = 0x002f;
  29493. t.slashBig = 0x002f;
  29494. t.slashBigg = 0x002f;
  29495. t.slashbigg = 0x002f;
  29496. t.summationdisplay = 0x2211;
  29497. t.summationtext = 0x2211;
  29498. t.tildewide = 0x02dc;
  29499. t.tildewider = 0x02dc;
  29500. t.tildewidest = 0x02dc;
  29501. t.uniondisplay = 0x22c3;
  29502. t.unionmultidisplay = 0x228e;
  29503. t.unionmultitext = 0x228e;
  29504. t.unionsqdisplay = 0x2294;
  29505. t.unionsqtext = 0x2294;
  29506. t.uniontext = 0x22c3;
  29507. t.vextenddouble = 0x2225;
  29508. t.vextendsingle = 0x2223;
  29509. });
  29510. exports.getGlyphsUnicode = getGlyphsUnicode;
  29511. const getDingbatsGlyphsUnicode = (0, _core_utils.getLookupTableFactory)(function (t) {
  29512. t.space = 0x0020;
  29513. t.a1 = 0x2701;
  29514. t.a2 = 0x2702;
  29515. t.a202 = 0x2703;
  29516. t.a3 = 0x2704;
  29517. t.a4 = 0x260e;
  29518. t.a5 = 0x2706;
  29519. t.a119 = 0x2707;
  29520. t.a118 = 0x2708;
  29521. t.a117 = 0x2709;
  29522. t.a11 = 0x261b;
  29523. t.a12 = 0x261e;
  29524. t.a13 = 0x270c;
  29525. t.a14 = 0x270d;
  29526. t.a15 = 0x270e;
  29527. t.a16 = 0x270f;
  29528. t.a105 = 0x2710;
  29529. t.a17 = 0x2711;
  29530. t.a18 = 0x2712;
  29531. t.a19 = 0x2713;
  29532. t.a20 = 0x2714;
  29533. t.a21 = 0x2715;
  29534. t.a22 = 0x2716;
  29535. t.a23 = 0x2717;
  29536. t.a24 = 0x2718;
  29537. t.a25 = 0x2719;
  29538. t.a26 = 0x271a;
  29539. t.a27 = 0x271b;
  29540. t.a28 = 0x271c;
  29541. t.a6 = 0x271d;
  29542. t.a7 = 0x271e;
  29543. t.a8 = 0x271f;
  29544. t.a9 = 0x2720;
  29545. t.a10 = 0x2721;
  29546. t.a29 = 0x2722;
  29547. t.a30 = 0x2723;
  29548. t.a31 = 0x2724;
  29549. t.a32 = 0x2725;
  29550. t.a33 = 0x2726;
  29551. t.a34 = 0x2727;
  29552. t.a35 = 0x2605;
  29553. t.a36 = 0x2729;
  29554. t.a37 = 0x272a;
  29555. t.a38 = 0x272b;
  29556. t.a39 = 0x272c;
  29557. t.a40 = 0x272d;
  29558. t.a41 = 0x272e;
  29559. t.a42 = 0x272f;
  29560. t.a43 = 0x2730;
  29561. t.a44 = 0x2731;
  29562. t.a45 = 0x2732;
  29563. t.a46 = 0x2733;
  29564. t.a47 = 0x2734;
  29565. t.a48 = 0x2735;
  29566. t.a49 = 0x2736;
  29567. t.a50 = 0x2737;
  29568. t.a51 = 0x2738;
  29569. t.a52 = 0x2739;
  29570. t.a53 = 0x273a;
  29571. t.a54 = 0x273b;
  29572. t.a55 = 0x273c;
  29573. t.a56 = 0x273d;
  29574. t.a57 = 0x273e;
  29575. t.a58 = 0x273f;
  29576. t.a59 = 0x2740;
  29577. t.a60 = 0x2741;
  29578. t.a61 = 0x2742;
  29579. t.a62 = 0x2743;
  29580. t.a63 = 0x2744;
  29581. t.a64 = 0x2745;
  29582. t.a65 = 0x2746;
  29583. t.a66 = 0x2747;
  29584. t.a67 = 0x2748;
  29585. t.a68 = 0x2749;
  29586. t.a69 = 0x274a;
  29587. t.a70 = 0x274b;
  29588. t.a71 = 0x25cf;
  29589. t.a72 = 0x274d;
  29590. t.a73 = 0x25a0;
  29591. t.a74 = 0x274f;
  29592. t.a203 = 0x2750;
  29593. t.a75 = 0x2751;
  29594. t.a204 = 0x2752;
  29595. t.a76 = 0x25b2;
  29596. t.a77 = 0x25bc;
  29597. t.a78 = 0x25c6;
  29598. t.a79 = 0x2756;
  29599. t.a81 = 0x25d7;
  29600. t.a82 = 0x2758;
  29601. t.a83 = 0x2759;
  29602. t.a84 = 0x275a;
  29603. t.a97 = 0x275b;
  29604. t.a98 = 0x275c;
  29605. t.a99 = 0x275d;
  29606. t.a100 = 0x275e;
  29607. t.a101 = 0x2761;
  29608. t.a102 = 0x2762;
  29609. t.a103 = 0x2763;
  29610. t.a104 = 0x2764;
  29611. t.a106 = 0x2765;
  29612. t.a107 = 0x2766;
  29613. t.a108 = 0x2767;
  29614. t.a112 = 0x2663;
  29615. t.a111 = 0x2666;
  29616. t.a110 = 0x2665;
  29617. t.a109 = 0x2660;
  29618. t.a120 = 0x2460;
  29619. t.a121 = 0x2461;
  29620. t.a122 = 0x2462;
  29621. t.a123 = 0x2463;
  29622. t.a124 = 0x2464;
  29623. t.a125 = 0x2465;
  29624. t.a126 = 0x2466;
  29625. t.a127 = 0x2467;
  29626. t.a128 = 0x2468;
  29627. t.a129 = 0x2469;
  29628. t.a130 = 0x2776;
  29629. t.a131 = 0x2777;
  29630. t.a132 = 0x2778;
  29631. t.a133 = 0x2779;
  29632. t.a134 = 0x277a;
  29633. t.a135 = 0x277b;
  29634. t.a136 = 0x277c;
  29635. t.a137 = 0x277d;
  29636. t.a138 = 0x277e;
  29637. t.a139 = 0x277f;
  29638. t.a140 = 0x2780;
  29639. t.a141 = 0x2781;
  29640. t.a142 = 0x2782;
  29641. t.a143 = 0x2783;
  29642. t.a144 = 0x2784;
  29643. t.a145 = 0x2785;
  29644. t.a146 = 0x2786;
  29645. t.a147 = 0x2787;
  29646. t.a148 = 0x2788;
  29647. t.a149 = 0x2789;
  29648. t.a150 = 0x278a;
  29649. t.a151 = 0x278b;
  29650. t.a152 = 0x278c;
  29651. t.a153 = 0x278d;
  29652. t.a154 = 0x278e;
  29653. t.a155 = 0x278f;
  29654. t.a156 = 0x2790;
  29655. t.a157 = 0x2791;
  29656. t.a158 = 0x2792;
  29657. t.a159 = 0x2793;
  29658. t.a160 = 0x2794;
  29659. t.a161 = 0x2192;
  29660. t.a163 = 0x2194;
  29661. t.a164 = 0x2195;
  29662. t.a196 = 0x2798;
  29663. t.a165 = 0x2799;
  29664. t.a192 = 0x279a;
  29665. t.a166 = 0x279b;
  29666. t.a167 = 0x279c;
  29667. t.a168 = 0x279d;
  29668. t.a169 = 0x279e;
  29669. t.a170 = 0x279f;
  29670. t.a171 = 0x27a0;
  29671. t.a172 = 0x27a1;
  29672. t.a173 = 0x27a2;
  29673. t.a162 = 0x27a3;
  29674. t.a174 = 0x27a4;
  29675. t.a175 = 0x27a5;
  29676. t.a176 = 0x27a6;
  29677. t.a177 = 0x27a7;
  29678. t.a178 = 0x27a8;
  29679. t.a179 = 0x27a9;
  29680. t.a193 = 0x27aa;
  29681. t.a180 = 0x27ab;
  29682. t.a199 = 0x27ac;
  29683. t.a181 = 0x27ad;
  29684. t.a200 = 0x27ae;
  29685. t.a182 = 0x27af;
  29686. t.a201 = 0x27b1;
  29687. t.a183 = 0x27b2;
  29688. t.a184 = 0x27b3;
  29689. t.a197 = 0x27b4;
  29690. t.a185 = 0x27b5;
  29691. t.a194 = 0x27b6;
  29692. t.a198 = 0x27b7;
  29693. t.a186 = 0x27b8;
  29694. t.a195 = 0x27b9;
  29695. t.a187 = 0x27ba;
  29696. t.a188 = 0x27bb;
  29697. t.a189 = 0x27bc;
  29698. t.a190 = 0x27bd;
  29699. t.a191 = 0x27be;
  29700. t.a89 = 0x2768;
  29701. t.a90 = 0x2769;
  29702. t.a93 = 0x276a;
  29703. t.a94 = 0x276b;
  29704. t.a91 = 0x276c;
  29705. t.a92 = 0x276d;
  29706. t.a205 = 0x276e;
  29707. t.a85 = 0x276f;
  29708. t.a206 = 0x2770;
  29709. t.a86 = 0x2771;
  29710. t.a87 = 0x2772;
  29711. t.a88 = 0x2773;
  29712. t.a95 = 0x2774;
  29713. t.a96 = 0x2775;
  29714. t[".notdef"] = 0x0000;
  29715. });
  29716. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  29717. /***/ }),
  29718. /* 40 */
  29719. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  29720. Object.defineProperty(exports, "__esModule", ({
  29721. value: true
  29722. }));
  29723. exports.clearUnicodeCaches = clearUnicodeCaches;
  29724. exports.getCharUnicodeCategory = getCharUnicodeCategory;
  29725. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  29726. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  29727. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  29728. var _core_utils = __w_pdfjs_require__(3);
  29729. const getSpecialPUASymbols = (0, _core_utils.getLookupTableFactory)(function (t) {
  29730. t[63721] = 0x00a9;
  29731. t[63193] = 0x00a9;
  29732. t[63720] = 0x00ae;
  29733. t[63194] = 0x00ae;
  29734. t[63722] = 0x2122;
  29735. t[63195] = 0x2122;
  29736. t[63729] = 0x23a7;
  29737. t[63730] = 0x23a8;
  29738. t[63731] = 0x23a9;
  29739. t[63740] = 0x23ab;
  29740. t[63741] = 0x23ac;
  29741. t[63742] = 0x23ad;
  29742. t[63726] = 0x23a1;
  29743. t[63727] = 0x23a2;
  29744. t[63728] = 0x23a3;
  29745. t[63737] = 0x23a4;
  29746. t[63738] = 0x23a5;
  29747. t[63739] = 0x23a6;
  29748. t[63723] = 0x239b;
  29749. t[63724] = 0x239c;
  29750. t[63725] = 0x239d;
  29751. t[63734] = 0x239e;
  29752. t[63735] = 0x239f;
  29753. t[63736] = 0x23a0;
  29754. });
  29755. function mapSpecialUnicodeValues(code) {
  29756. if (code >= 0xfff0 && code <= 0xffff) {
  29757. return 0;
  29758. } else if (code >= 0xf600 && code <= 0xf8ff) {
  29759. return getSpecialPUASymbols()[code] || code;
  29760. } else if (code === 0x00ad) {
  29761. return 0x002d;
  29762. }
  29763. return code;
  29764. }
  29765. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  29766. let unicode = glyphsUnicodeMap[name];
  29767. if (unicode !== undefined) {
  29768. return unicode;
  29769. }
  29770. if (!name) {
  29771. return -1;
  29772. }
  29773. if (name[0] === "u") {
  29774. const nameLen = name.length;
  29775. let hexStr;
  29776. if (nameLen === 7 && name[1] === "n" && name[2] === "i") {
  29777. hexStr = name.substring(3);
  29778. } else if (nameLen >= 5 && nameLen <= 7) {
  29779. hexStr = name.substring(1);
  29780. } else {
  29781. return -1;
  29782. }
  29783. if (hexStr === hexStr.toUpperCase()) {
  29784. unicode = parseInt(hexStr, 16);
  29785. if (unicode >= 0) {
  29786. return unicode;
  29787. }
  29788. }
  29789. }
  29790. return -1;
  29791. }
  29792. const UnicodeRanges = [[0x0000, 0x007f], [0x0080, 0x00ff], [0x0100, 0x017f], [0x0180, 0x024f], [0x0250, 0x02af, 0x1d00, 0x1d7f, 0x1d80, 0x1dbf], [0x02b0, 0x02ff, 0xa700, 0xa71f], [0x0300, 0x036f, 0x1dc0, 0x1dff], [0x0370, 0x03ff], [0x2c80, 0x2cff], [0x0400, 0x04ff, 0x0500, 0x052f, 0x2de0, 0x2dff, 0xa640, 0xa69f], [0x0530, 0x058f], [0x0590, 0x05ff], [0xa500, 0xa63f], [0x0600, 0x06ff, 0x0750, 0x077f], [0x07c0, 0x07ff], [0x0900, 0x097f], [0x0980, 0x09ff], [0x0a00, 0x0a7f], [0x0a80, 0x0aff], [0x0b00, 0x0b7f], [0x0b80, 0x0bff], [0x0c00, 0x0c7f], [0x0c80, 0x0cff], [0x0d00, 0x0d7f], [0x0e00, 0x0e7f], [0x0e80, 0x0eff], [0x10a0, 0x10ff, 0x2d00, 0x2d2f], [0x1b00, 0x1b7f], [0x1100, 0x11ff], [0x1e00, 0x1eff, 0x2c60, 0x2c7f, 0xa720, 0xa7ff], [0x1f00, 0x1fff], [0x2000, 0x206f, 0x2e00, 0x2e7f], [0x2070, 0x209f], [0x20a0, 0x20cf], [0x20d0, 0x20ff], [0x2100, 0x214f], [0x2150, 0x218f], [0x2190, 0x21ff, 0x27f0, 0x27ff, 0x2900, 0x297f, 0x2b00, 0x2bff], [0x2200, 0x22ff, 0x2a00, 0x2aff, 0x27c0, 0x27ef, 0x2980, 0x29ff], [0x2300, 0x23ff], [0x2400, 0x243f], [0x2440, 0x245f], [0x2460, 0x24ff], [0x2500, 0x257f], [0x2580, 0x259f], [0x25a0, 0x25ff], [0x2600, 0x26ff], [0x2700, 0x27bf], [0x3000, 0x303f], [0x3040, 0x309f], [0x30a0, 0x30ff, 0x31f0, 0x31ff], [0x3100, 0x312f, 0x31a0, 0x31bf], [0x3130, 0x318f], [0xa840, 0xa87f], [0x3200, 0x32ff], [0x3300, 0x33ff], [0xac00, 0xd7af], [0xd800, 0xdfff], [0x10900, 0x1091f], [0x4e00, 0x9fff, 0x2e80, 0x2eff, 0x2f00, 0x2fdf, 0x2ff0, 0x2fff, 0x3400, 0x4dbf, 0x20000, 0x2a6df, 0x3190, 0x319f], [0xe000, 0xf8ff], [0x31c0, 0x31ef, 0xf900, 0xfaff, 0x2f800, 0x2fa1f], [0xfb00, 0xfb4f], [0xfb50, 0xfdff], [0xfe20, 0xfe2f], [0xfe10, 0xfe1f], [0xfe50, 0xfe6f], [0xfe70, 0xfeff], [0xff00, 0xffef], [0xfff0, 0xffff], [0x0f00, 0x0fff], [0x0700, 0x074f], [0x0780, 0x07bf], [0x0d80, 0x0dff], [0x1000, 0x109f], [0x1200, 0x137f, 0x1380, 0x139f, 0x2d80, 0x2ddf], [0x13a0, 0x13ff], [0x1400, 0x167f], [0x1680, 0x169f], [0x16a0, 0x16ff], [0x1780, 0x17ff], [0x1800, 0x18af], [0x2800, 0x28ff], [0xa000, 0xa48f], [0x1700, 0x171f, 0x1720, 0x173f, 0x1740, 0x175f, 0x1760, 0x177f], [0x10300, 0x1032f], [0x10330, 0x1034f], [0x10400, 0x1044f], [0x1d000, 0x1d0ff, 0x1d100, 0x1d1ff, 0x1d200, 0x1d24f], [0x1d400, 0x1d7ff], [0xff000, 0xffffd], [0xfe00, 0xfe0f, 0xe0100, 0xe01ef], [0xe0000, 0xe007f], [0x1900, 0x194f], [0x1950, 0x197f], [0x1980, 0x19df], [0x1a00, 0x1a1f], [0x2c00, 0x2c5f], [0x2d30, 0x2d7f], [0x4dc0, 0x4dff], [0xa800, 0xa82f], [0x10000, 0x1007f, 0x10080, 0x100ff, 0x10100, 0x1013f], [0x10140, 0x1018f], [0x10380, 0x1039f], [0x103a0, 0x103df], [0x10450, 0x1047f], [0x10480, 0x104af], [0x10800, 0x1083f], [0x10a00, 0x10a5f], [0x1d300, 0x1d35f], [0x12000, 0x123ff, 0x12400, 0x1247f], [0x1d360, 0x1d37f], [0x1b80, 0x1bbf], [0x1c00, 0x1c4f], [0x1c50, 0x1c7f], [0xa880, 0xa8df], [0xa900, 0xa92f], [0xa930, 0xa95f], [0xaa00, 0xaa5f], [0x10190, 0x101cf], [0x101d0, 0x101ff], [0x102a0, 0x102df, 0x10280, 0x1029f, 0x10920, 0x1093f], [0x1f030, 0x1f09f, 0x1f000, 0x1f02f]];
  29793. function getUnicodeRangeFor(value, lastPosition = -1) {
  29794. if (lastPosition !== -1) {
  29795. const range = UnicodeRanges[lastPosition];
  29796. for (let i = 0, ii = range.length; i < ii; i += 2) {
  29797. if (value >= range[i] && value <= range[i + 1]) {
  29798. return lastPosition;
  29799. }
  29800. }
  29801. }
  29802. for (let i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  29803. const range = UnicodeRanges[i];
  29804. for (let j = 0, jj = range.length; j < jj; j += 2) {
  29805. if (value >= range[j] && value <= range[j + 1]) {
  29806. return i;
  29807. }
  29808. }
  29809. }
  29810. return -1;
  29811. }
  29812. const SpecialCharRegExp = new RegExp("^(\\s)|(\\p{Mn})|(\\p{Cf})$", "u");
  29813. const CategoryCache = new Map();
  29814. function getCharUnicodeCategory(char) {
  29815. const cachedCategory = CategoryCache.get(char);
  29816. if (cachedCategory) {
  29817. return cachedCategory;
  29818. }
  29819. const groups = char.match(SpecialCharRegExp);
  29820. const category = {
  29821. isWhitespace: !!groups?.[1],
  29822. isZeroWidthDiacritic: !!groups?.[2],
  29823. isInvisibleFormatMark: !!groups?.[3]
  29824. };
  29825. CategoryCache.set(char, category);
  29826. return category;
  29827. }
  29828. function clearUnicodeCaches() {
  29829. CategoryCache.clear();
  29830. }
  29831. /***/ }),
  29832. /* 41 */
  29833. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  29834. Object.defineProperty(exports, "__esModule", ({
  29835. value: true
  29836. }));
  29837. exports.getSerifFonts = exports.getNonStdFontMap = exports.getGlyphMapForStandardFonts = exports.getFontNameToFileMap = void 0;
  29838. exports.getStandardFontName = getStandardFontName;
  29839. exports.getSymbolsFonts = exports.getSupplementalGlyphMapForCalibri = exports.getSupplementalGlyphMapForArialBlack = exports.getStdFontMap = void 0;
  29840. exports.isKnownFontName = isKnownFontName;
  29841. var _core_utils = __w_pdfjs_require__(3);
  29842. var _fonts_utils = __w_pdfjs_require__(38);
  29843. const getStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  29844. t["Times-Roman"] = "Times-Roman";
  29845. t.Helvetica = "Helvetica";
  29846. t.Courier = "Courier";
  29847. t.Symbol = "Symbol";
  29848. t["Times-Bold"] = "Times-Bold";
  29849. t["Helvetica-Bold"] = "Helvetica-Bold";
  29850. t["Courier-Bold"] = "Courier-Bold";
  29851. t.ZapfDingbats = "ZapfDingbats";
  29852. t["Times-Italic"] = "Times-Italic";
  29853. t["Helvetica-Oblique"] = "Helvetica-Oblique";
  29854. t["Courier-Oblique"] = "Courier-Oblique";
  29855. t["Times-BoldItalic"] = "Times-BoldItalic";
  29856. t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
  29857. t["Courier-BoldOblique"] = "Courier-BoldOblique";
  29858. t.ArialNarrow = "Helvetica";
  29859. t["ArialNarrow-Bold"] = "Helvetica-Bold";
  29860. t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
  29861. t["ArialNarrow-Italic"] = "Helvetica-Oblique";
  29862. t.ArialBlack = "Helvetica";
  29863. t["ArialBlack-Bold"] = "Helvetica-Bold";
  29864. t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
  29865. t["ArialBlack-Italic"] = "Helvetica-Oblique";
  29866. t["Arial-Black"] = "Helvetica";
  29867. t["Arial-Black-Bold"] = "Helvetica-Bold";
  29868. t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
  29869. t["Arial-Black-Italic"] = "Helvetica-Oblique";
  29870. t.Arial = "Helvetica";
  29871. t["Arial-Bold"] = "Helvetica-Bold";
  29872. t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
  29873. t["Arial-Italic"] = "Helvetica-Oblique";
  29874. t.ArialMT = "Helvetica";
  29875. t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
  29876. t["Arial-BoldMT"] = "Helvetica-Bold";
  29877. t["Arial-ItalicMT"] = "Helvetica-Oblique";
  29878. t["Arial-BoldItalicMT-BoldItalic"] = "Helvetica-BoldOblique";
  29879. t["Arial-BoldMT-Bold"] = "Helvetica-Bold";
  29880. t["Arial-ItalicMT-Italic"] = "Helvetica-Oblique";
  29881. t.ArialUnicodeMS = "Helvetica";
  29882. t["ArialUnicodeMS-Bold"] = "Helvetica-Bold";
  29883. t["ArialUnicodeMS-BoldItalic"] = "Helvetica-BoldOblique";
  29884. t["ArialUnicodeMS-Italic"] = "Helvetica-Oblique";
  29885. t["Courier-BoldItalic"] = "Courier-BoldOblique";
  29886. t["Courier-Italic"] = "Courier-Oblique";
  29887. t.CourierNew = "Courier";
  29888. t["CourierNew-Bold"] = "Courier-Bold";
  29889. t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
  29890. t["CourierNew-Italic"] = "Courier-Oblique";
  29891. t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
  29892. t["CourierNewPS-BoldMT"] = "Courier-Bold";
  29893. t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
  29894. t.CourierNewPSMT = "Courier";
  29895. t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
  29896. t["Helvetica-Italic"] = "Helvetica-Oblique";
  29897. t["Symbol-Bold"] = "Symbol";
  29898. t["Symbol-BoldItalic"] = "Symbol";
  29899. t["Symbol-Italic"] = "Symbol";
  29900. t.TimesNewRoman = "Times-Roman";
  29901. t["TimesNewRoman-Bold"] = "Times-Bold";
  29902. t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
  29903. t["TimesNewRoman-Italic"] = "Times-Italic";
  29904. t.TimesNewRomanPS = "Times-Roman";
  29905. t["TimesNewRomanPS-Bold"] = "Times-Bold";
  29906. t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
  29907. t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
  29908. t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
  29909. t["TimesNewRomanPS-Italic"] = "Times-Italic";
  29910. t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
  29911. t.TimesNewRomanPSMT = "Times-Roman";
  29912. t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
  29913. t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
  29914. t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
  29915. });
  29916. exports.getStdFontMap = getStdFontMap;
  29917. const getFontNameToFileMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  29918. t.Courier = "FoxitFixed.pfb";
  29919. t["Courier-Bold"] = "FoxitFixedBold.pfb";
  29920. t["Courier-BoldOblique"] = "FoxitFixedBoldItalic.pfb";
  29921. t["Courier-Oblique"] = "FoxitFixedItalic.pfb";
  29922. t.Helvetica = "LiberationSans-Regular.ttf";
  29923. t["Helvetica-Bold"] = "LiberationSans-Bold.ttf";
  29924. t["Helvetica-BoldOblique"] = "LiberationSans-BoldItalic.ttf";
  29925. t["Helvetica-Oblique"] = "LiberationSans-Italic.ttf";
  29926. t["Times-Roman"] = "FoxitSerif.pfb";
  29927. t["Times-Bold"] = "FoxitSerifBold.pfb";
  29928. t["Times-BoldItalic"] = "FoxitSerifBoldItalic.pfb";
  29929. t["Times-Italic"] = "FoxitSerifItalic.pfb";
  29930. t.Symbol = "FoxitSymbol.pfb";
  29931. t.ZapfDingbats = "FoxitDingbats.pfb";
  29932. t["LiberationSans-Regular"] = "LiberationSans-Regular.ttf";
  29933. t["LiberationSans-Bold"] = "LiberationSans-Bold.ttf";
  29934. t["LiberationSans-Italic"] = "LiberationSans-Italic.ttf";
  29935. t["LiberationSans-BoldItalic"] = "LiberationSans-BoldItalic.ttf";
  29936. });
  29937. exports.getFontNameToFileMap = getFontNameToFileMap;
  29938. const getNonStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  29939. t.Calibri = "Helvetica";
  29940. t["Calibri-Bold"] = "Helvetica-Bold";
  29941. t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
  29942. t["Calibri-Italic"] = "Helvetica-Oblique";
  29943. t.CenturyGothic = "Helvetica";
  29944. t["CenturyGothic-Bold"] = "Helvetica-Bold";
  29945. t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
  29946. t["CenturyGothic-Italic"] = "Helvetica-Oblique";
  29947. t.ComicSansMS = "Comic Sans MS";
  29948. t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
  29949. t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
  29950. t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
  29951. t.Impact = "Helvetica";
  29952. t["ItcSymbol-Bold"] = "Helvetica-Bold";
  29953. t["ItcSymbol-BoldItalic"] = "Helvetica-BoldOblique";
  29954. t["ItcSymbol-Book"] = "Helvetica";
  29955. t["ItcSymbol-BookItalic"] = "Helvetica-Oblique";
  29956. t["ItcSymbol-Medium"] = "Helvetica";
  29957. t["ItcSymbol-MediumItalic"] = "Helvetica-Oblique";
  29958. t.LucidaConsole = "Courier";
  29959. t["LucidaConsole-Bold"] = "Courier-Bold";
  29960. t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
  29961. t["LucidaConsole-Italic"] = "Courier-Oblique";
  29962. t["LucidaSans-Demi"] = "Helvetica-Bold";
  29963. t["MS-Gothic"] = "MS Gothic";
  29964. t["MS-Gothic-Bold"] = "MS Gothic-Bold";
  29965. t["MS-Gothic-BoldItalic"] = "MS Gothic-BoldItalic";
  29966. t["MS-Gothic-Italic"] = "MS Gothic-Italic";
  29967. t["MS-Mincho"] = "MS Mincho";
  29968. t["MS-Mincho-Bold"] = "MS Mincho-Bold";
  29969. t["MS-Mincho-BoldItalic"] = "MS Mincho-BoldItalic";
  29970. t["MS-Mincho-Italic"] = "MS Mincho-Italic";
  29971. t["MS-PGothic"] = "MS PGothic";
  29972. t["MS-PGothic-Bold"] = "MS PGothic-Bold";
  29973. t["MS-PGothic-BoldItalic"] = "MS PGothic-BoldItalic";
  29974. t["MS-PGothic-Italic"] = "MS PGothic-Italic";
  29975. t["MS-PMincho"] = "MS PMincho";
  29976. t["MS-PMincho-Bold"] = "MS PMincho-Bold";
  29977. t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
  29978. t["MS-PMincho-Italic"] = "MS PMincho-Italic";
  29979. t.NuptialScript = "Times-Italic";
  29980. t.SegoeUISymbol = "Helvetica";
  29981. });
  29982. exports.getNonStdFontMap = getNonStdFontMap;
  29983. const getSerifFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  29984. t["Adobe Jenson"] = true;
  29985. t["Adobe Text"] = true;
  29986. t.Albertus = true;
  29987. t.Aldus = true;
  29988. t.Alexandria = true;
  29989. t.Algerian = true;
  29990. t["American Typewriter"] = true;
  29991. t.Antiqua = true;
  29992. t.Apex = true;
  29993. t.Arno = true;
  29994. t.Aster = true;
  29995. t.Aurora = true;
  29996. t.Baskerville = true;
  29997. t.Bell = true;
  29998. t.Bembo = true;
  29999. t["Bembo Schoolbook"] = true;
  30000. t.Benguiat = true;
  30001. t["Berkeley Old Style"] = true;
  30002. t["Bernhard Modern"] = true;
  30003. t["Berthold City"] = true;
  30004. t.Bodoni = true;
  30005. t["Bauer Bodoni"] = true;
  30006. t["Book Antiqua"] = true;
  30007. t.Bookman = true;
  30008. t["Bordeaux Roman"] = true;
  30009. t["Californian FB"] = true;
  30010. t.Calisto = true;
  30011. t.Calvert = true;
  30012. t.Capitals = true;
  30013. t.Cambria = true;
  30014. t.Cartier = true;
  30015. t.Caslon = true;
  30016. t.Catull = true;
  30017. t.Centaur = true;
  30018. t["Century Old Style"] = true;
  30019. t["Century Schoolbook"] = true;
  30020. t.Chaparral = true;
  30021. t["Charis SIL"] = true;
  30022. t.Cheltenham = true;
  30023. t["Cholla Slab"] = true;
  30024. t.Clarendon = true;
  30025. t.Clearface = true;
  30026. t.Cochin = true;
  30027. t.Colonna = true;
  30028. t["Computer Modern"] = true;
  30029. t["Concrete Roman"] = true;
  30030. t.Constantia = true;
  30031. t["Cooper Black"] = true;
  30032. t.Corona = true;
  30033. t.Ecotype = true;
  30034. t.Egyptienne = true;
  30035. t.Elephant = true;
  30036. t.Excelsior = true;
  30037. t.Fairfield = true;
  30038. t["FF Scala"] = true;
  30039. t.Folkard = true;
  30040. t.Footlight = true;
  30041. t.FreeSerif = true;
  30042. t["Friz Quadrata"] = true;
  30043. t.Garamond = true;
  30044. t.Gentium = true;
  30045. t.Georgia = true;
  30046. t.Gloucester = true;
  30047. t["Goudy Old Style"] = true;
  30048. t["Goudy Schoolbook"] = true;
  30049. t["Goudy Pro Font"] = true;
  30050. t.Granjon = true;
  30051. t["Guardian Egyptian"] = true;
  30052. t.Heather = true;
  30053. t.Hercules = true;
  30054. t["High Tower Text"] = true;
  30055. t.Hiroshige = true;
  30056. t["Hoefler Text"] = true;
  30057. t["Humana Serif"] = true;
  30058. t.Imprint = true;
  30059. t["Ionic No. 5"] = true;
  30060. t.Janson = true;
  30061. t.Joanna = true;
  30062. t.Korinna = true;
  30063. t.Lexicon = true;
  30064. t.LiberationSerif = true;
  30065. t["Liberation Serif"] = true;
  30066. t["Linux Libertine"] = true;
  30067. t.Literaturnaya = true;
  30068. t.Lucida = true;
  30069. t["Lucida Bright"] = true;
  30070. t.Melior = true;
  30071. t.Memphis = true;
  30072. t.Miller = true;
  30073. t.Minion = true;
  30074. t.Modern = true;
  30075. t["Mona Lisa"] = true;
  30076. t["Mrs Eaves"] = true;
  30077. t["MS Serif"] = true;
  30078. t["Museo Slab"] = true;
  30079. t["New York"] = true;
  30080. t["Nimbus Roman"] = true;
  30081. t["NPS Rawlinson Roadway"] = true;
  30082. t.NuptialScript = true;
  30083. t.Palatino = true;
  30084. t.Perpetua = true;
  30085. t.Plantin = true;
  30086. t["Plantin Schoolbook"] = true;
  30087. t.Playbill = true;
  30088. t["Poor Richard"] = true;
  30089. t["Rawlinson Roadway"] = true;
  30090. t.Renault = true;
  30091. t.Requiem = true;
  30092. t.Rockwell = true;
  30093. t.Roman = true;
  30094. t["Rotis Serif"] = true;
  30095. t.Sabon = true;
  30096. t.Scala = true;
  30097. t.Seagull = true;
  30098. t.Sistina = true;
  30099. t.Souvenir = true;
  30100. t.STIX = true;
  30101. t["Stone Informal"] = true;
  30102. t["Stone Serif"] = true;
  30103. t.Sylfaen = true;
  30104. t.Times = true;
  30105. t.Trajan = true;
  30106. t["Trinité"] = true;
  30107. t["Trump Mediaeval"] = true;
  30108. t.Utopia = true;
  30109. t["Vale Type"] = true;
  30110. t["Bitstream Vera"] = true;
  30111. t["Vera Serif"] = true;
  30112. t.Versailles = true;
  30113. t.Wanted = true;
  30114. t.Weiss = true;
  30115. t["Wide Latin"] = true;
  30116. t.Windsor = true;
  30117. t.XITS = true;
  30118. });
  30119. exports.getSerifFonts = getSerifFonts;
  30120. const getSymbolsFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  30121. t.Dingbats = true;
  30122. t.Symbol = true;
  30123. t.ZapfDingbats = true;
  30124. t.Wingdings = true;
  30125. t["Wingdings-Bold"] = true;
  30126. t["Wingdings-Regular"] = true;
  30127. });
  30128. exports.getSymbolsFonts = getSymbolsFonts;
  30129. const getGlyphMapForStandardFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  30130. t[2] = 10;
  30131. t[3] = 32;
  30132. t[4] = 33;
  30133. t[5] = 34;
  30134. t[6] = 35;
  30135. t[7] = 36;
  30136. t[8] = 37;
  30137. t[9] = 38;
  30138. t[10] = 39;
  30139. t[11] = 40;
  30140. t[12] = 41;
  30141. t[13] = 42;
  30142. t[14] = 43;
  30143. t[15] = 44;
  30144. t[16] = 45;
  30145. t[17] = 46;
  30146. t[18] = 47;
  30147. t[19] = 48;
  30148. t[20] = 49;
  30149. t[21] = 50;
  30150. t[22] = 51;
  30151. t[23] = 52;
  30152. t[24] = 53;
  30153. t[25] = 54;
  30154. t[26] = 55;
  30155. t[27] = 56;
  30156. t[28] = 57;
  30157. t[29] = 58;
  30158. t[30] = 894;
  30159. t[31] = 60;
  30160. t[32] = 61;
  30161. t[33] = 62;
  30162. t[34] = 63;
  30163. t[35] = 64;
  30164. t[36] = 65;
  30165. t[37] = 66;
  30166. t[38] = 67;
  30167. t[39] = 68;
  30168. t[40] = 69;
  30169. t[41] = 70;
  30170. t[42] = 71;
  30171. t[43] = 72;
  30172. t[44] = 73;
  30173. t[45] = 74;
  30174. t[46] = 75;
  30175. t[47] = 76;
  30176. t[48] = 77;
  30177. t[49] = 78;
  30178. t[50] = 79;
  30179. t[51] = 80;
  30180. t[52] = 81;
  30181. t[53] = 82;
  30182. t[54] = 83;
  30183. t[55] = 84;
  30184. t[56] = 85;
  30185. t[57] = 86;
  30186. t[58] = 87;
  30187. t[59] = 88;
  30188. t[60] = 89;
  30189. t[61] = 90;
  30190. t[62] = 91;
  30191. t[63] = 92;
  30192. t[64] = 93;
  30193. t[65] = 94;
  30194. t[66] = 95;
  30195. t[67] = 96;
  30196. t[68] = 97;
  30197. t[69] = 98;
  30198. t[70] = 99;
  30199. t[71] = 100;
  30200. t[72] = 101;
  30201. t[73] = 102;
  30202. t[74] = 103;
  30203. t[75] = 104;
  30204. t[76] = 105;
  30205. t[77] = 106;
  30206. t[78] = 107;
  30207. t[79] = 108;
  30208. t[80] = 109;
  30209. t[81] = 110;
  30210. t[82] = 111;
  30211. t[83] = 112;
  30212. t[84] = 113;
  30213. t[85] = 114;
  30214. t[86] = 115;
  30215. t[87] = 116;
  30216. t[88] = 117;
  30217. t[89] = 118;
  30218. t[90] = 119;
  30219. t[91] = 120;
  30220. t[92] = 121;
  30221. t[93] = 122;
  30222. t[94] = 123;
  30223. t[95] = 124;
  30224. t[96] = 125;
  30225. t[97] = 126;
  30226. t[98] = 196;
  30227. t[99] = 197;
  30228. t[100] = 199;
  30229. t[101] = 201;
  30230. t[102] = 209;
  30231. t[103] = 214;
  30232. t[104] = 220;
  30233. t[105] = 225;
  30234. t[106] = 224;
  30235. t[107] = 226;
  30236. t[108] = 228;
  30237. t[109] = 227;
  30238. t[110] = 229;
  30239. t[111] = 231;
  30240. t[112] = 233;
  30241. t[113] = 232;
  30242. t[114] = 234;
  30243. t[115] = 235;
  30244. t[116] = 237;
  30245. t[117] = 236;
  30246. t[118] = 238;
  30247. t[119] = 239;
  30248. t[120] = 241;
  30249. t[121] = 243;
  30250. t[122] = 242;
  30251. t[123] = 244;
  30252. t[124] = 246;
  30253. t[125] = 245;
  30254. t[126] = 250;
  30255. t[127] = 249;
  30256. t[128] = 251;
  30257. t[129] = 252;
  30258. t[130] = 8224;
  30259. t[131] = 176;
  30260. t[132] = 162;
  30261. t[133] = 163;
  30262. t[134] = 167;
  30263. t[135] = 8226;
  30264. t[136] = 182;
  30265. t[137] = 223;
  30266. t[138] = 174;
  30267. t[139] = 169;
  30268. t[140] = 8482;
  30269. t[141] = 180;
  30270. t[142] = 168;
  30271. t[143] = 8800;
  30272. t[144] = 198;
  30273. t[145] = 216;
  30274. t[146] = 8734;
  30275. t[147] = 177;
  30276. t[148] = 8804;
  30277. t[149] = 8805;
  30278. t[150] = 165;
  30279. t[151] = 181;
  30280. t[152] = 8706;
  30281. t[153] = 8721;
  30282. t[154] = 8719;
  30283. t[156] = 8747;
  30284. t[157] = 170;
  30285. t[158] = 186;
  30286. t[159] = 8486;
  30287. t[160] = 230;
  30288. t[161] = 248;
  30289. t[162] = 191;
  30290. t[163] = 161;
  30291. t[164] = 172;
  30292. t[165] = 8730;
  30293. t[166] = 402;
  30294. t[167] = 8776;
  30295. t[168] = 8710;
  30296. t[169] = 171;
  30297. t[170] = 187;
  30298. t[171] = 8230;
  30299. t[179] = 8220;
  30300. t[180] = 8221;
  30301. t[181] = 8216;
  30302. t[182] = 8217;
  30303. t[200] = 193;
  30304. t[203] = 205;
  30305. t[207] = 211;
  30306. t[210] = 218;
  30307. t[223] = 711;
  30308. t[224] = 321;
  30309. t[225] = 322;
  30310. t[226] = 352;
  30311. t[227] = 353;
  30312. t[228] = 381;
  30313. t[229] = 382;
  30314. t[233] = 221;
  30315. t[234] = 253;
  30316. t[252] = 263;
  30317. t[253] = 268;
  30318. t[254] = 269;
  30319. t[258] = 258;
  30320. t[260] = 260;
  30321. t[261] = 261;
  30322. t[265] = 280;
  30323. t[266] = 281;
  30324. t[267] = 282;
  30325. t[268] = 283;
  30326. t[269] = 313;
  30327. t[275] = 323;
  30328. t[276] = 324;
  30329. t[278] = 328;
  30330. t[283] = 344;
  30331. t[284] = 345;
  30332. t[285] = 346;
  30333. t[286] = 347;
  30334. t[292] = 367;
  30335. t[295] = 377;
  30336. t[296] = 378;
  30337. t[298] = 380;
  30338. t[305] = 963;
  30339. t[306] = 964;
  30340. t[307] = 966;
  30341. t[308] = 8215;
  30342. t[309] = 8252;
  30343. t[310] = 8319;
  30344. t[311] = 8359;
  30345. t[312] = 8592;
  30346. t[313] = 8593;
  30347. t[337] = 9552;
  30348. t[493] = 1039;
  30349. t[494] = 1040;
  30350. t[672] = 1488;
  30351. t[673] = 1489;
  30352. t[674] = 1490;
  30353. t[675] = 1491;
  30354. t[676] = 1492;
  30355. t[677] = 1493;
  30356. t[678] = 1494;
  30357. t[679] = 1495;
  30358. t[680] = 1496;
  30359. t[681] = 1497;
  30360. t[682] = 1498;
  30361. t[683] = 1499;
  30362. t[684] = 1500;
  30363. t[685] = 1501;
  30364. t[686] = 1502;
  30365. t[687] = 1503;
  30366. t[688] = 1504;
  30367. t[689] = 1505;
  30368. t[690] = 1506;
  30369. t[691] = 1507;
  30370. t[692] = 1508;
  30371. t[693] = 1509;
  30372. t[694] = 1510;
  30373. t[695] = 1511;
  30374. t[696] = 1512;
  30375. t[697] = 1513;
  30376. t[698] = 1514;
  30377. t[705] = 1524;
  30378. t[706] = 8362;
  30379. t[710] = 64288;
  30380. t[711] = 64298;
  30381. t[759] = 1617;
  30382. t[761] = 1776;
  30383. t[763] = 1778;
  30384. t[775] = 1652;
  30385. t[777] = 1764;
  30386. t[778] = 1780;
  30387. t[779] = 1781;
  30388. t[780] = 1782;
  30389. t[782] = 771;
  30390. t[783] = 64726;
  30391. t[786] = 8363;
  30392. t[788] = 8532;
  30393. t[790] = 768;
  30394. t[791] = 769;
  30395. t[792] = 768;
  30396. t[795] = 803;
  30397. t[797] = 64336;
  30398. t[798] = 64337;
  30399. t[799] = 64342;
  30400. t[800] = 64343;
  30401. t[801] = 64344;
  30402. t[802] = 64345;
  30403. t[803] = 64362;
  30404. t[804] = 64363;
  30405. t[805] = 64364;
  30406. t[2424] = 7821;
  30407. t[2425] = 7822;
  30408. t[2426] = 7823;
  30409. t[2427] = 7824;
  30410. t[2428] = 7825;
  30411. t[2429] = 7826;
  30412. t[2430] = 7827;
  30413. t[2433] = 7682;
  30414. t[2678] = 8045;
  30415. t[2679] = 8046;
  30416. t[2830] = 1552;
  30417. t[2838] = 686;
  30418. t[2840] = 751;
  30419. t[2842] = 753;
  30420. t[2843] = 754;
  30421. t[2844] = 755;
  30422. t[2846] = 757;
  30423. t[2856] = 767;
  30424. t[2857] = 848;
  30425. t[2858] = 849;
  30426. t[2862] = 853;
  30427. t[2863] = 854;
  30428. t[2864] = 855;
  30429. t[2865] = 861;
  30430. t[2866] = 862;
  30431. t[2906] = 7460;
  30432. t[2908] = 7462;
  30433. t[2909] = 7463;
  30434. t[2910] = 7464;
  30435. t[2912] = 7466;
  30436. t[2913] = 7467;
  30437. t[2914] = 7468;
  30438. t[2916] = 7470;
  30439. t[2917] = 7471;
  30440. t[2918] = 7472;
  30441. t[2920] = 7474;
  30442. t[2921] = 7475;
  30443. t[2922] = 7476;
  30444. t[2924] = 7478;
  30445. t[2925] = 7479;
  30446. t[2926] = 7480;
  30447. t[2928] = 7482;
  30448. t[2929] = 7483;
  30449. t[2930] = 7484;
  30450. t[2932] = 7486;
  30451. t[2933] = 7487;
  30452. t[2934] = 7488;
  30453. t[2936] = 7490;
  30454. t[2937] = 7491;
  30455. t[2938] = 7492;
  30456. t[2940] = 7494;
  30457. t[2941] = 7495;
  30458. t[2942] = 7496;
  30459. t[2944] = 7498;
  30460. t[2946] = 7500;
  30461. t[2948] = 7502;
  30462. t[2950] = 7504;
  30463. t[2951] = 7505;
  30464. t[2952] = 7506;
  30465. t[2954] = 7508;
  30466. t[2955] = 7509;
  30467. t[2956] = 7510;
  30468. t[2958] = 7512;
  30469. t[2959] = 7513;
  30470. t[2960] = 7514;
  30471. t[2962] = 7516;
  30472. t[2963] = 7517;
  30473. t[2964] = 7518;
  30474. t[2966] = 7520;
  30475. t[2967] = 7521;
  30476. t[2968] = 7522;
  30477. t[2970] = 7524;
  30478. t[2971] = 7525;
  30479. t[2972] = 7526;
  30480. t[2974] = 7528;
  30481. t[2975] = 7529;
  30482. t[2976] = 7530;
  30483. t[2978] = 1537;
  30484. t[2979] = 1538;
  30485. t[2980] = 1539;
  30486. t[2982] = 1549;
  30487. t[2983] = 1551;
  30488. t[2984] = 1552;
  30489. t[2986] = 1554;
  30490. t[2987] = 1555;
  30491. t[2988] = 1556;
  30492. t[2990] = 1623;
  30493. t[2991] = 1624;
  30494. t[2995] = 1775;
  30495. t[2999] = 1791;
  30496. t[3002] = 64290;
  30497. t[3003] = 64291;
  30498. t[3004] = 64292;
  30499. t[3006] = 64294;
  30500. t[3007] = 64295;
  30501. t[3008] = 64296;
  30502. t[3011] = 1900;
  30503. t[3014] = 8223;
  30504. t[3015] = 8244;
  30505. t[3017] = 7532;
  30506. t[3018] = 7533;
  30507. t[3019] = 7534;
  30508. t[3075] = 7590;
  30509. t[3076] = 7591;
  30510. t[3079] = 7594;
  30511. t[3080] = 7595;
  30512. t[3083] = 7598;
  30513. t[3084] = 7599;
  30514. t[3087] = 7602;
  30515. t[3088] = 7603;
  30516. t[3091] = 7606;
  30517. t[3092] = 7607;
  30518. t[3095] = 7610;
  30519. t[3096] = 7611;
  30520. t[3099] = 7614;
  30521. t[3100] = 7615;
  30522. t[3103] = 7618;
  30523. t[3104] = 7619;
  30524. t[3107] = 8337;
  30525. t[3108] = 8338;
  30526. t[3116] = 1884;
  30527. t[3119] = 1885;
  30528. t[3120] = 1885;
  30529. t[3123] = 1886;
  30530. t[3124] = 1886;
  30531. t[3127] = 1887;
  30532. t[3128] = 1887;
  30533. t[3131] = 1888;
  30534. t[3132] = 1888;
  30535. t[3135] = 1889;
  30536. t[3136] = 1889;
  30537. t[3139] = 1890;
  30538. t[3140] = 1890;
  30539. t[3143] = 1891;
  30540. t[3144] = 1891;
  30541. t[3147] = 1892;
  30542. t[3148] = 1892;
  30543. t[3153] = 580;
  30544. t[3154] = 581;
  30545. t[3157] = 584;
  30546. t[3158] = 585;
  30547. t[3161] = 588;
  30548. t[3162] = 589;
  30549. t[3165] = 891;
  30550. t[3166] = 892;
  30551. t[3169] = 1274;
  30552. t[3170] = 1275;
  30553. t[3173] = 1278;
  30554. t[3174] = 1279;
  30555. t[3181] = 7622;
  30556. t[3182] = 7623;
  30557. t[3282] = 11799;
  30558. t[3316] = 578;
  30559. t[3379] = 42785;
  30560. t[3393] = 1159;
  30561. t[3416] = 8377;
  30562. });
  30563. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  30564. const getSupplementalGlyphMapForArialBlack = (0, _core_utils.getLookupTableFactory)(function (t) {
  30565. t[227] = 322;
  30566. t[264] = 261;
  30567. t[291] = 346;
  30568. });
  30569. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  30570. const getSupplementalGlyphMapForCalibri = (0, _core_utils.getLookupTableFactory)(function (t) {
  30571. t[1] = 32;
  30572. t[4] = 65;
  30573. t[5] = 192;
  30574. t[6] = 193;
  30575. t[9] = 196;
  30576. t[17] = 66;
  30577. t[18] = 67;
  30578. t[21] = 268;
  30579. t[24] = 68;
  30580. t[28] = 69;
  30581. t[29] = 200;
  30582. t[30] = 201;
  30583. t[32] = 282;
  30584. t[38] = 70;
  30585. t[39] = 71;
  30586. t[44] = 72;
  30587. t[47] = 73;
  30588. t[48] = 204;
  30589. t[49] = 205;
  30590. t[58] = 74;
  30591. t[60] = 75;
  30592. t[62] = 76;
  30593. t[68] = 77;
  30594. t[69] = 78;
  30595. t[75] = 79;
  30596. t[76] = 210;
  30597. t[80] = 214;
  30598. t[87] = 80;
  30599. t[89] = 81;
  30600. t[90] = 82;
  30601. t[92] = 344;
  30602. t[94] = 83;
  30603. t[97] = 352;
  30604. t[100] = 84;
  30605. t[104] = 85;
  30606. t[109] = 220;
  30607. t[115] = 86;
  30608. t[116] = 87;
  30609. t[121] = 88;
  30610. t[122] = 89;
  30611. t[124] = 221;
  30612. t[127] = 90;
  30613. t[129] = 381;
  30614. t[258] = 97;
  30615. t[259] = 224;
  30616. t[260] = 225;
  30617. t[263] = 228;
  30618. t[268] = 261;
  30619. t[271] = 98;
  30620. t[272] = 99;
  30621. t[273] = 263;
  30622. t[275] = 269;
  30623. t[282] = 100;
  30624. t[286] = 101;
  30625. t[287] = 232;
  30626. t[288] = 233;
  30627. t[290] = 283;
  30628. t[295] = 281;
  30629. t[296] = 102;
  30630. t[336] = 103;
  30631. t[346] = 104;
  30632. t[349] = 105;
  30633. t[350] = 236;
  30634. t[351] = 237;
  30635. t[361] = 106;
  30636. t[364] = 107;
  30637. t[367] = 108;
  30638. t[371] = 322;
  30639. t[373] = 109;
  30640. t[374] = 110;
  30641. t[381] = 111;
  30642. t[382] = 242;
  30643. t[383] = 243;
  30644. t[386] = 246;
  30645. t[393] = 112;
  30646. t[395] = 113;
  30647. t[396] = 114;
  30648. t[398] = 345;
  30649. t[400] = 115;
  30650. t[401] = 347;
  30651. t[403] = 353;
  30652. t[410] = 116;
  30653. t[437] = 117;
  30654. t[442] = 252;
  30655. t[448] = 118;
  30656. t[449] = 119;
  30657. t[454] = 120;
  30658. t[455] = 121;
  30659. t[457] = 253;
  30660. t[460] = 122;
  30661. t[462] = 382;
  30662. t[463] = 380;
  30663. t[853] = 44;
  30664. t[855] = 58;
  30665. t[856] = 46;
  30666. t[876] = 47;
  30667. t[878] = 45;
  30668. t[882] = 45;
  30669. t[894] = 40;
  30670. t[895] = 41;
  30671. t[896] = 91;
  30672. t[897] = 93;
  30673. t[923] = 64;
  30674. t[1004] = 48;
  30675. t[1005] = 49;
  30676. t[1006] = 50;
  30677. t[1007] = 51;
  30678. t[1008] = 52;
  30679. t[1009] = 53;
  30680. t[1010] = 54;
  30681. t[1011] = 55;
  30682. t[1012] = 56;
  30683. t[1013] = 57;
  30684. t[1081] = 37;
  30685. t[1085] = 43;
  30686. t[1086] = 45;
  30687. });
  30688. exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
  30689. function getStandardFontName(name) {
  30690. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  30691. const stdFontMap = getStdFontMap();
  30692. return stdFontMap[fontName];
  30693. }
  30694. function isKnownFontName(name) {
  30695. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  30696. return !!(getStdFontMap()[fontName] || getNonStdFontMap()[fontName] || getSerifFonts()[fontName] || getSymbolsFonts()[fontName]);
  30697. }
  30698. /***/ }),
  30699. /* 42 */
  30700. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  30701. Object.defineProperty(exports, "__esModule", ({
  30702. value: true
  30703. }));
  30704. exports.ToUnicodeMap = exports.IdentityToUnicodeMap = void 0;
  30705. var _util = __w_pdfjs_require__(2);
  30706. class ToUnicodeMap {
  30707. constructor(cmap = []) {
  30708. this._map = cmap;
  30709. }
  30710. get length() {
  30711. return this._map.length;
  30712. }
  30713. forEach(callback) {
  30714. for (const charCode in this._map) {
  30715. callback(charCode, this._map[charCode].charCodeAt(0));
  30716. }
  30717. }
  30718. has(i) {
  30719. return this._map[i] !== undefined;
  30720. }
  30721. get(i) {
  30722. return this._map[i];
  30723. }
  30724. charCodeOf(value) {
  30725. const map = this._map;
  30726. if (map.length <= 0x10000) {
  30727. return map.indexOf(value);
  30728. }
  30729. for (const charCode in map) {
  30730. if (map[charCode] === value) {
  30731. return charCode | 0;
  30732. }
  30733. }
  30734. return -1;
  30735. }
  30736. amend(map) {
  30737. for (const charCode in map) {
  30738. this._map[charCode] = map[charCode];
  30739. }
  30740. }
  30741. }
  30742. exports.ToUnicodeMap = ToUnicodeMap;
  30743. class IdentityToUnicodeMap {
  30744. constructor(firstChar, lastChar) {
  30745. this.firstChar = firstChar;
  30746. this.lastChar = lastChar;
  30747. }
  30748. get length() {
  30749. return this.lastChar + 1 - this.firstChar;
  30750. }
  30751. forEach(callback) {
  30752. for (let i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  30753. callback(i, i);
  30754. }
  30755. }
  30756. has(i) {
  30757. return this.firstChar <= i && i <= this.lastChar;
  30758. }
  30759. get(i) {
  30760. if (this.firstChar <= i && i <= this.lastChar) {
  30761. return String.fromCharCode(i);
  30762. }
  30763. return undefined;
  30764. }
  30765. charCodeOf(v) {
  30766. return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  30767. }
  30768. amend(map) {
  30769. (0, _util.unreachable)("Should not call amend()");
  30770. }
  30771. }
  30772. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  30773. /***/ }),
  30774. /* 43 */
  30775. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  30776. Object.defineProperty(exports, "__esModule", ({
  30777. value: true
  30778. }));
  30779. exports.CFFFont = void 0;
  30780. var _cff_parser = __w_pdfjs_require__(35);
  30781. var _fonts_utils = __w_pdfjs_require__(38);
  30782. var _util = __w_pdfjs_require__(2);
  30783. class CFFFont {
  30784. constructor(file, properties) {
  30785. this.properties = properties;
  30786. const parser = new _cff_parser.CFFParser(file, properties, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  30787. this.cff = parser.parse();
  30788. this.cff.duplicateFirstGlyph();
  30789. const compiler = new _cff_parser.CFFCompiler(this.cff);
  30790. this.seacs = this.cff.seacs;
  30791. try {
  30792. this.data = compiler.compile();
  30793. } catch {
  30794. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  30795. this.data = file;
  30796. }
  30797. this._createBuiltInEncoding();
  30798. }
  30799. get numGlyphs() {
  30800. return this.cff.charStrings.count;
  30801. }
  30802. getCharset() {
  30803. return this.cff.charset.charset;
  30804. }
  30805. getGlyphMapping() {
  30806. const cff = this.cff;
  30807. const properties = this.properties;
  30808. const {
  30809. cidToGidMap,
  30810. cMap
  30811. } = properties;
  30812. const charsets = cff.charset.charset;
  30813. let charCodeToGlyphId;
  30814. let glyphId;
  30815. if (properties.composite) {
  30816. let invCidToGidMap;
  30817. if (cidToGidMap?.length > 0) {
  30818. invCidToGidMap = Object.create(null);
  30819. for (let i = 0, ii = cidToGidMap.length; i < ii; i++) {
  30820. const gid = cidToGidMap[i];
  30821. if (gid !== undefined) {
  30822. invCidToGidMap[gid] = i;
  30823. }
  30824. }
  30825. }
  30826. charCodeToGlyphId = Object.create(null);
  30827. let charCode;
  30828. if (cff.isCIDFont) {
  30829. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  30830. const cid = charsets[glyphId];
  30831. charCode = cMap.charCodeOf(cid);
  30832. if (invCidToGidMap?.[charCode] !== undefined) {
  30833. charCode = invCidToGidMap[charCode];
  30834. }
  30835. charCodeToGlyphId[charCode] = glyphId;
  30836. }
  30837. } else {
  30838. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  30839. charCode = cMap.charCodeOf(glyphId);
  30840. charCodeToGlyphId[charCode] = glyphId;
  30841. }
  30842. }
  30843. return charCodeToGlyphId;
  30844. }
  30845. let encoding = cff.encoding ? cff.encoding.encoding : null;
  30846. if (properties.isInternalFont) {
  30847. encoding = properties.defaultEncoding;
  30848. }
  30849. charCodeToGlyphId = (0, _fonts_utils.type1FontGlyphMapping)(properties, encoding, charsets);
  30850. return charCodeToGlyphId;
  30851. }
  30852. hasGlyphId(id) {
  30853. return this.cff.hasGlyphId(id);
  30854. }
  30855. _createBuiltInEncoding() {
  30856. const {
  30857. charset,
  30858. encoding
  30859. } = this.cff;
  30860. if (!charset || !encoding) {
  30861. return;
  30862. }
  30863. const charsets = charset.charset,
  30864. encodings = encoding.encoding;
  30865. const map = [];
  30866. for (const charCode in encodings) {
  30867. const glyphId = encodings[charCode];
  30868. if (glyphId >= 0) {
  30869. const glyphName = charsets[glyphId];
  30870. if (glyphName) {
  30871. map[charCode] = glyphName;
  30872. }
  30873. }
  30874. }
  30875. if (map.length > 0) {
  30876. this.properties.builtInEncoding = map;
  30877. }
  30878. }
  30879. }
  30880. exports.CFFFont = CFFFont;
  30881. /***/ }),
  30882. /* 44 */
  30883. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  30884. Object.defineProperty(exports, "__esModule", ({
  30885. value: true
  30886. }));
  30887. exports.FontRendererFactory = void 0;
  30888. var _util = __w_pdfjs_require__(2);
  30889. var _cff_parser = __w_pdfjs_require__(35);
  30890. var _glyphlist = __w_pdfjs_require__(39);
  30891. var _encodings = __w_pdfjs_require__(37);
  30892. var _stream = __w_pdfjs_require__(8);
  30893. function getUint32(data, offset) {
  30894. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  30895. }
  30896. function getUint16(data, offset) {
  30897. return data[offset] << 8 | data[offset + 1];
  30898. }
  30899. function getInt16(data, offset) {
  30900. return (data[offset] << 24 | data[offset + 1] << 16) >> 16;
  30901. }
  30902. function getInt8(data, offset) {
  30903. return data[offset] << 24 >> 24;
  30904. }
  30905. function getFloat214(data, offset) {
  30906. return getInt16(data, offset) / 16384;
  30907. }
  30908. function getSubroutineBias(subrs) {
  30909. const numSubrs = subrs.length;
  30910. let bias = 32768;
  30911. if (numSubrs < 1240) {
  30912. bias = 107;
  30913. } else if (numSubrs < 33900) {
  30914. bias = 1131;
  30915. }
  30916. return bias;
  30917. }
  30918. function parseCmap(data, start, end) {
  30919. const offset = getUint16(data, start + 2) === 1 ? getUint32(data, start + 8) : getUint32(data, start + 16);
  30920. const format = getUint16(data, start + offset);
  30921. let ranges, p, i;
  30922. if (format === 4) {
  30923. getUint16(data, start + offset + 2);
  30924. const segCount = getUint16(data, start + offset + 6) >> 1;
  30925. p = start + offset + 14;
  30926. ranges = [];
  30927. for (i = 0; i < segCount; i++, p += 2) {
  30928. ranges[i] = {
  30929. end: getUint16(data, p)
  30930. };
  30931. }
  30932. p += 2;
  30933. for (i = 0; i < segCount; i++, p += 2) {
  30934. ranges[i].start = getUint16(data, p);
  30935. }
  30936. for (i = 0; i < segCount; i++, p += 2) {
  30937. ranges[i].idDelta = getUint16(data, p);
  30938. }
  30939. for (i = 0; i < segCount; i++, p += 2) {
  30940. let idOffset = getUint16(data, p);
  30941. if (idOffset === 0) {
  30942. continue;
  30943. }
  30944. ranges[i].ids = [];
  30945. for (let j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  30946. ranges[i].ids[j] = getUint16(data, p + idOffset);
  30947. idOffset += 2;
  30948. }
  30949. }
  30950. return ranges;
  30951. } else if (format === 12) {
  30952. const groups = getUint32(data, start + offset + 12);
  30953. p = start + offset + 16;
  30954. ranges = [];
  30955. for (i = 0; i < groups; i++) {
  30956. start = getUint32(data, p);
  30957. ranges.push({
  30958. start,
  30959. end: getUint32(data, p + 4),
  30960. idDelta: getUint32(data, p + 8) - start
  30961. });
  30962. p += 12;
  30963. }
  30964. return ranges;
  30965. }
  30966. throw new _util.FormatError(`unsupported cmap: ${format}`);
  30967. }
  30968. function parseCff(data, start, end, seacAnalysisEnabled) {
  30969. const properties = {};
  30970. const parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
  30971. const cff = parser.parse();
  30972. return {
  30973. glyphs: cff.charStrings.objects,
  30974. subrs: cff.topDict.privateDict?.subrsIndex?.objects,
  30975. gsubrs: cff.globalSubrIndex?.objects,
  30976. isCFFCIDFont: cff.isCIDFont,
  30977. fdSelect: cff.fdSelect,
  30978. fdArray: cff.fdArray
  30979. };
  30980. }
  30981. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  30982. let itemSize, itemDecode;
  30983. if (isGlyphLocationsLong) {
  30984. itemSize = 4;
  30985. itemDecode = getUint32;
  30986. } else {
  30987. itemSize = 2;
  30988. itemDecode = (data, offset) => 2 * getUint16(data, offset);
  30989. }
  30990. const glyphs = [];
  30991. let startOffset = itemDecode(loca, 0);
  30992. for (let j = itemSize; j < loca.length; j += itemSize) {
  30993. const endOffset = itemDecode(loca, j);
  30994. glyphs.push(glyf.subarray(startOffset, endOffset));
  30995. startOffset = endOffset;
  30996. }
  30997. return glyphs;
  30998. }
  30999. function lookupCmap(ranges, unicode) {
  31000. const code = unicode.codePointAt(0);
  31001. let gid = 0,
  31002. l = 0,
  31003. r = ranges.length - 1;
  31004. while (l < r) {
  31005. const c = l + r + 1 >> 1;
  31006. if (code < ranges[c].start) {
  31007. r = c - 1;
  31008. } else {
  31009. l = c;
  31010. }
  31011. }
  31012. if (ranges[l].start <= code && code <= ranges[l].end) {
  31013. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
  31014. }
  31015. return {
  31016. charCode: code,
  31017. glyphId: gid
  31018. };
  31019. }
  31020. function compileGlyf(code, cmds, font) {
  31021. function moveTo(x, y) {
  31022. cmds.push({
  31023. cmd: "moveTo",
  31024. args: [x, y]
  31025. });
  31026. }
  31027. function lineTo(x, y) {
  31028. cmds.push({
  31029. cmd: "lineTo",
  31030. args: [x, y]
  31031. });
  31032. }
  31033. function quadraticCurveTo(xa, ya, x, y) {
  31034. cmds.push({
  31035. cmd: "quadraticCurveTo",
  31036. args: [xa, ya, x, y]
  31037. });
  31038. }
  31039. let i = 0;
  31040. const numberOfContours = getInt16(code, i);
  31041. let flags;
  31042. let x = 0,
  31043. y = 0;
  31044. i += 10;
  31045. if (numberOfContours < 0) {
  31046. do {
  31047. flags = getUint16(code, i);
  31048. const glyphIndex = getUint16(code, i + 2);
  31049. i += 4;
  31050. let arg1, arg2;
  31051. if (flags & 0x01) {
  31052. if (flags & 0x02) {
  31053. arg1 = getInt16(code, i);
  31054. arg2 = getInt16(code, i + 2);
  31055. } else {
  31056. arg1 = getUint16(code, i);
  31057. arg2 = getUint16(code, i + 2);
  31058. }
  31059. i += 4;
  31060. } else if (flags & 0x02) {
  31061. arg1 = getInt8(code, i++);
  31062. arg2 = getInt8(code, i++);
  31063. } else {
  31064. arg1 = code[i++];
  31065. arg2 = code[i++];
  31066. }
  31067. if (flags & 0x02) {
  31068. x = arg1;
  31069. y = arg2;
  31070. } else {
  31071. x = 0;
  31072. y = 0;
  31073. }
  31074. let scaleX = 1,
  31075. scaleY = 1,
  31076. scale01 = 0,
  31077. scale10 = 0;
  31078. if (flags & 0x08) {
  31079. scaleX = scaleY = getFloat214(code, i);
  31080. i += 2;
  31081. } else if (flags & 0x40) {
  31082. scaleX = getFloat214(code, i);
  31083. scaleY = getFloat214(code, i + 2);
  31084. i += 4;
  31085. } else if (flags & 0x80) {
  31086. scaleX = getFloat214(code, i);
  31087. scale01 = getFloat214(code, i + 2);
  31088. scale10 = getFloat214(code, i + 4);
  31089. scaleY = getFloat214(code, i + 6);
  31090. i += 8;
  31091. }
  31092. const subglyph = font.glyphs[glyphIndex];
  31093. if (subglyph) {
  31094. cmds.push({
  31095. cmd: "save"
  31096. }, {
  31097. cmd: "transform",
  31098. args: [scaleX, scale01, scale10, scaleY, x, y]
  31099. });
  31100. if (!(flags & 0x02)) {}
  31101. compileGlyf(subglyph, cmds, font);
  31102. cmds.push({
  31103. cmd: "restore"
  31104. });
  31105. }
  31106. } while (flags & 0x20);
  31107. } else {
  31108. const endPtsOfContours = [];
  31109. let j, jj;
  31110. for (j = 0; j < numberOfContours; j++) {
  31111. endPtsOfContours.push(getUint16(code, i));
  31112. i += 2;
  31113. }
  31114. const instructionLength = getUint16(code, i);
  31115. i += 2 + instructionLength;
  31116. const numberOfPoints = endPtsOfContours.at(-1) + 1;
  31117. const points = [];
  31118. while (points.length < numberOfPoints) {
  31119. flags = code[i++];
  31120. let repeat = 1;
  31121. if (flags & 0x08) {
  31122. repeat += code[i++];
  31123. }
  31124. while (repeat-- > 0) {
  31125. points.push({
  31126. flags
  31127. });
  31128. }
  31129. }
  31130. for (j = 0; j < numberOfPoints; j++) {
  31131. switch (points[j].flags & 0x12) {
  31132. case 0x00:
  31133. x += getInt16(code, i);
  31134. i += 2;
  31135. break;
  31136. case 0x02:
  31137. x -= code[i++];
  31138. break;
  31139. case 0x12:
  31140. x += code[i++];
  31141. break;
  31142. }
  31143. points[j].x = x;
  31144. }
  31145. for (j = 0; j < numberOfPoints; j++) {
  31146. switch (points[j].flags & 0x24) {
  31147. case 0x00:
  31148. y += getInt16(code, i);
  31149. i += 2;
  31150. break;
  31151. case 0x04:
  31152. y -= code[i++];
  31153. break;
  31154. case 0x24:
  31155. y += code[i++];
  31156. break;
  31157. }
  31158. points[j].y = y;
  31159. }
  31160. let startPoint = 0;
  31161. for (i = 0; i < numberOfContours; i++) {
  31162. const endPoint = endPtsOfContours[i];
  31163. const contour = points.slice(startPoint, endPoint + 1);
  31164. if (contour[0].flags & 1) {
  31165. contour.push(contour[0]);
  31166. } else if (contour.at(-1).flags & 1) {
  31167. contour.unshift(contour.at(-1));
  31168. } else {
  31169. const p = {
  31170. flags: 1,
  31171. x: (contour[0].x + contour.at(-1).x) / 2,
  31172. y: (contour[0].y + contour.at(-1).y) / 2
  31173. };
  31174. contour.unshift(p);
  31175. contour.push(p);
  31176. }
  31177. moveTo(contour[0].x, contour[0].y);
  31178. for (j = 1, jj = contour.length; j < jj; j++) {
  31179. if (contour[j].flags & 1) {
  31180. lineTo(contour[j].x, contour[j].y);
  31181. } else if (contour[j + 1].flags & 1) {
  31182. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  31183. j++;
  31184. } else {
  31185. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  31186. }
  31187. }
  31188. startPoint = endPoint + 1;
  31189. }
  31190. }
  31191. }
  31192. function compileCharString(charStringCode, cmds, font, glyphId) {
  31193. function moveTo(x, y) {
  31194. cmds.push({
  31195. cmd: "moveTo",
  31196. args: [x, y]
  31197. });
  31198. }
  31199. function lineTo(x, y) {
  31200. cmds.push({
  31201. cmd: "lineTo",
  31202. args: [x, y]
  31203. });
  31204. }
  31205. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  31206. cmds.push({
  31207. cmd: "bezierCurveTo",
  31208. args: [x1, y1, x2, y2, x, y]
  31209. });
  31210. }
  31211. const stack = [];
  31212. let x = 0,
  31213. y = 0;
  31214. let stems = 0;
  31215. function parse(code) {
  31216. let i = 0;
  31217. while (i < code.length) {
  31218. let stackClean = false;
  31219. let v = code[i++];
  31220. let xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  31221. switch (v) {
  31222. case 1:
  31223. stems += stack.length >> 1;
  31224. stackClean = true;
  31225. break;
  31226. case 3:
  31227. stems += stack.length >> 1;
  31228. stackClean = true;
  31229. break;
  31230. case 4:
  31231. y += stack.pop();
  31232. moveTo(x, y);
  31233. stackClean = true;
  31234. break;
  31235. case 5:
  31236. while (stack.length > 0) {
  31237. x += stack.shift();
  31238. y += stack.shift();
  31239. lineTo(x, y);
  31240. }
  31241. break;
  31242. case 6:
  31243. while (stack.length > 0) {
  31244. x += stack.shift();
  31245. lineTo(x, y);
  31246. if (stack.length === 0) {
  31247. break;
  31248. }
  31249. y += stack.shift();
  31250. lineTo(x, y);
  31251. }
  31252. break;
  31253. case 7:
  31254. while (stack.length > 0) {
  31255. y += stack.shift();
  31256. lineTo(x, y);
  31257. if (stack.length === 0) {
  31258. break;
  31259. }
  31260. x += stack.shift();
  31261. lineTo(x, y);
  31262. }
  31263. break;
  31264. case 8:
  31265. while (stack.length > 0) {
  31266. xa = x + stack.shift();
  31267. ya = y + stack.shift();
  31268. xb = xa + stack.shift();
  31269. yb = ya + stack.shift();
  31270. x = xb + stack.shift();
  31271. y = yb + stack.shift();
  31272. bezierCurveTo(xa, ya, xb, yb, x, y);
  31273. }
  31274. break;
  31275. case 10:
  31276. n = stack.pop();
  31277. subrCode = null;
  31278. if (font.isCFFCIDFont) {
  31279. const fdIndex = font.fdSelect.getFDIndex(glyphId);
  31280. if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
  31281. const fontDict = font.fdArray[fdIndex];
  31282. let subrs;
  31283. if (fontDict.privateDict?.subrsIndex) {
  31284. subrs = fontDict.privateDict.subrsIndex.objects;
  31285. }
  31286. if (subrs) {
  31287. n += getSubroutineBias(subrs);
  31288. subrCode = subrs[n];
  31289. }
  31290. } else {
  31291. (0, _util.warn)("Invalid fd index for glyph index.");
  31292. }
  31293. } else {
  31294. subrCode = font.subrs[n + font.subrsBias];
  31295. }
  31296. if (subrCode) {
  31297. parse(subrCode);
  31298. }
  31299. break;
  31300. case 11:
  31301. return;
  31302. case 12:
  31303. v = code[i++];
  31304. switch (v) {
  31305. case 34:
  31306. xa = x + stack.shift();
  31307. xb = xa + stack.shift();
  31308. y1 = y + stack.shift();
  31309. x = xb + stack.shift();
  31310. bezierCurveTo(xa, y, xb, y1, x, y1);
  31311. xa = x + stack.shift();
  31312. xb = xa + stack.shift();
  31313. x = xb + stack.shift();
  31314. bezierCurveTo(xa, y1, xb, y, x, y);
  31315. break;
  31316. case 35:
  31317. xa = x + stack.shift();
  31318. ya = y + stack.shift();
  31319. xb = xa + stack.shift();
  31320. yb = ya + stack.shift();
  31321. x = xb + stack.shift();
  31322. y = yb + stack.shift();
  31323. bezierCurveTo(xa, ya, xb, yb, x, y);
  31324. xa = x + stack.shift();
  31325. ya = y + stack.shift();
  31326. xb = xa + stack.shift();
  31327. yb = ya + stack.shift();
  31328. x = xb + stack.shift();
  31329. y = yb + stack.shift();
  31330. bezierCurveTo(xa, ya, xb, yb, x, y);
  31331. stack.pop();
  31332. break;
  31333. case 36:
  31334. xa = x + stack.shift();
  31335. y1 = y + stack.shift();
  31336. xb = xa + stack.shift();
  31337. y2 = y1 + stack.shift();
  31338. x = xb + stack.shift();
  31339. bezierCurveTo(xa, y1, xb, y2, x, y2);
  31340. xa = x + stack.shift();
  31341. xb = xa + stack.shift();
  31342. y3 = y2 + stack.shift();
  31343. x = xb + stack.shift();
  31344. bezierCurveTo(xa, y2, xb, y3, x, y);
  31345. break;
  31346. case 37:
  31347. const x0 = x,
  31348. y0 = y;
  31349. xa = x + stack.shift();
  31350. ya = y + stack.shift();
  31351. xb = xa + stack.shift();
  31352. yb = ya + stack.shift();
  31353. x = xb + stack.shift();
  31354. y = yb + stack.shift();
  31355. bezierCurveTo(xa, ya, xb, yb, x, y);
  31356. xa = x + stack.shift();
  31357. ya = y + stack.shift();
  31358. xb = xa + stack.shift();
  31359. yb = ya + stack.shift();
  31360. x = xb;
  31361. y = yb;
  31362. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  31363. x += stack.shift();
  31364. } else {
  31365. y += stack.shift();
  31366. }
  31367. bezierCurveTo(xa, ya, xb, yb, x, y);
  31368. break;
  31369. default:
  31370. throw new _util.FormatError(`unknown operator: 12 ${v}`);
  31371. }
  31372. break;
  31373. case 14:
  31374. if (stack.length >= 4) {
  31375. const achar = stack.pop();
  31376. const bchar = stack.pop();
  31377. y = stack.pop();
  31378. x = stack.pop();
  31379. cmds.push({
  31380. cmd: "save"
  31381. }, {
  31382. cmd: "translate",
  31383. args: [x, y]
  31384. });
  31385. let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
  31386. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  31387. cmds.push({
  31388. cmd: "restore"
  31389. });
  31390. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
  31391. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  31392. }
  31393. return;
  31394. case 18:
  31395. stems += stack.length >> 1;
  31396. stackClean = true;
  31397. break;
  31398. case 19:
  31399. stems += stack.length >> 1;
  31400. i += stems + 7 >> 3;
  31401. stackClean = true;
  31402. break;
  31403. case 20:
  31404. stems += stack.length >> 1;
  31405. i += stems + 7 >> 3;
  31406. stackClean = true;
  31407. break;
  31408. case 21:
  31409. y += stack.pop();
  31410. x += stack.pop();
  31411. moveTo(x, y);
  31412. stackClean = true;
  31413. break;
  31414. case 22:
  31415. x += stack.pop();
  31416. moveTo(x, y);
  31417. stackClean = true;
  31418. break;
  31419. case 23:
  31420. stems += stack.length >> 1;
  31421. stackClean = true;
  31422. break;
  31423. case 24:
  31424. while (stack.length > 2) {
  31425. xa = x + stack.shift();
  31426. ya = y + stack.shift();
  31427. xb = xa + stack.shift();
  31428. yb = ya + stack.shift();
  31429. x = xb + stack.shift();
  31430. y = yb + stack.shift();
  31431. bezierCurveTo(xa, ya, xb, yb, x, y);
  31432. }
  31433. x += stack.shift();
  31434. y += stack.shift();
  31435. lineTo(x, y);
  31436. break;
  31437. case 25:
  31438. while (stack.length > 6) {
  31439. x += stack.shift();
  31440. y += stack.shift();
  31441. lineTo(x, y);
  31442. }
  31443. xa = x + stack.shift();
  31444. ya = y + stack.shift();
  31445. xb = xa + stack.shift();
  31446. yb = ya + stack.shift();
  31447. x = xb + stack.shift();
  31448. y = yb + stack.shift();
  31449. bezierCurveTo(xa, ya, xb, yb, x, y);
  31450. break;
  31451. case 26:
  31452. if (stack.length % 2) {
  31453. x += stack.shift();
  31454. }
  31455. while (stack.length > 0) {
  31456. xa = x;
  31457. ya = y + stack.shift();
  31458. xb = xa + stack.shift();
  31459. yb = ya + stack.shift();
  31460. x = xb;
  31461. y = yb + stack.shift();
  31462. bezierCurveTo(xa, ya, xb, yb, x, y);
  31463. }
  31464. break;
  31465. case 27:
  31466. if (stack.length % 2) {
  31467. y += stack.shift();
  31468. }
  31469. while (stack.length > 0) {
  31470. xa = x + stack.shift();
  31471. ya = y;
  31472. xb = xa + stack.shift();
  31473. yb = ya + stack.shift();
  31474. x = xb + stack.shift();
  31475. y = yb;
  31476. bezierCurveTo(xa, ya, xb, yb, x, y);
  31477. }
  31478. break;
  31479. case 28:
  31480. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  31481. i += 2;
  31482. break;
  31483. case 29:
  31484. n = stack.pop() + font.gsubrsBias;
  31485. subrCode = font.gsubrs[n];
  31486. if (subrCode) {
  31487. parse(subrCode);
  31488. }
  31489. break;
  31490. case 30:
  31491. while (stack.length > 0) {
  31492. xa = x;
  31493. ya = y + stack.shift();
  31494. xb = xa + stack.shift();
  31495. yb = ya + stack.shift();
  31496. x = xb + stack.shift();
  31497. y = yb + (stack.length === 1 ? stack.shift() : 0);
  31498. bezierCurveTo(xa, ya, xb, yb, x, y);
  31499. if (stack.length === 0) {
  31500. break;
  31501. }
  31502. xa = x + stack.shift();
  31503. ya = y;
  31504. xb = xa + stack.shift();
  31505. yb = ya + stack.shift();
  31506. y = yb + stack.shift();
  31507. x = xb + (stack.length === 1 ? stack.shift() : 0);
  31508. bezierCurveTo(xa, ya, xb, yb, x, y);
  31509. }
  31510. break;
  31511. case 31:
  31512. while (stack.length > 0) {
  31513. xa = x + stack.shift();
  31514. ya = y;
  31515. xb = xa + stack.shift();
  31516. yb = ya + stack.shift();
  31517. y = yb + stack.shift();
  31518. x = xb + (stack.length === 1 ? stack.shift() : 0);
  31519. bezierCurveTo(xa, ya, xb, yb, x, y);
  31520. if (stack.length === 0) {
  31521. break;
  31522. }
  31523. xa = x;
  31524. ya = y + stack.shift();
  31525. xb = xa + stack.shift();
  31526. yb = ya + stack.shift();
  31527. x = xb + stack.shift();
  31528. y = yb + (stack.length === 1 ? stack.shift() : 0);
  31529. bezierCurveTo(xa, ya, xb, yb, x, y);
  31530. }
  31531. break;
  31532. default:
  31533. if (v < 32) {
  31534. throw new _util.FormatError(`unknown operator: ${v}`);
  31535. }
  31536. if (v < 247) {
  31537. stack.push(v - 139);
  31538. } else if (v < 251) {
  31539. stack.push((v - 247) * 256 + code[i++] + 108);
  31540. } else if (v < 255) {
  31541. stack.push(-(v - 251) * 256 - code[i++] - 108);
  31542. } else {
  31543. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  31544. i += 4;
  31545. }
  31546. break;
  31547. }
  31548. if (stackClean) {
  31549. stack.length = 0;
  31550. }
  31551. }
  31552. }
  31553. parse(charStringCode);
  31554. }
  31555. const NOOP = [];
  31556. class CompiledFont {
  31557. constructor(fontMatrix) {
  31558. if (this.constructor === CompiledFont) {
  31559. (0, _util.unreachable)("Cannot initialize CompiledFont.");
  31560. }
  31561. this.fontMatrix = fontMatrix;
  31562. this.compiledGlyphs = Object.create(null);
  31563. this.compiledCharCodeToGlyphId = Object.create(null);
  31564. }
  31565. getPathJs(unicode) {
  31566. const {
  31567. charCode,
  31568. glyphId
  31569. } = lookupCmap(this.cmap, unicode);
  31570. let fn = this.compiledGlyphs[glyphId];
  31571. if (!fn) {
  31572. try {
  31573. fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
  31574. this.compiledGlyphs[glyphId] = fn;
  31575. } catch (ex) {
  31576. this.compiledGlyphs[glyphId] = NOOP;
  31577. if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
  31578. this.compiledCharCodeToGlyphId[charCode] = glyphId;
  31579. }
  31580. throw ex;
  31581. }
  31582. }
  31583. if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
  31584. this.compiledCharCodeToGlyphId[charCode] = glyphId;
  31585. }
  31586. return fn;
  31587. }
  31588. compileGlyph(code, glyphId) {
  31589. if (!code || code.length === 0 || code[0] === 14) {
  31590. return NOOP;
  31591. }
  31592. let fontMatrix = this.fontMatrix;
  31593. if (this.isCFFCIDFont) {
  31594. const fdIndex = this.fdSelect.getFDIndex(glyphId);
  31595. if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
  31596. const fontDict = this.fdArray[fdIndex];
  31597. fontMatrix = fontDict.getByName("FontMatrix") || _util.FONT_IDENTITY_MATRIX;
  31598. } else {
  31599. (0, _util.warn)("Invalid fd index for glyph index.");
  31600. }
  31601. }
  31602. const cmds = [{
  31603. cmd: "save"
  31604. }, {
  31605. cmd: "transform",
  31606. args: fontMatrix.slice()
  31607. }, {
  31608. cmd: "scale",
  31609. args: ["size", "-size"]
  31610. }];
  31611. this.compileGlyphImpl(code, cmds, glyphId);
  31612. cmds.push({
  31613. cmd: "restore"
  31614. });
  31615. return cmds;
  31616. }
  31617. compileGlyphImpl() {
  31618. (0, _util.unreachable)("Children classes should implement this.");
  31619. }
  31620. hasBuiltPath(unicode) {
  31621. const {
  31622. charCode,
  31623. glyphId
  31624. } = lookupCmap(this.cmap, unicode);
  31625. return this.compiledGlyphs[glyphId] !== undefined && this.compiledCharCodeToGlyphId[charCode] !== undefined;
  31626. }
  31627. }
  31628. class TrueTypeCompiled extends CompiledFont {
  31629. constructor(glyphs, cmap, fontMatrix) {
  31630. super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
  31631. this.glyphs = glyphs;
  31632. this.cmap = cmap;
  31633. }
  31634. compileGlyphImpl(code, cmds) {
  31635. compileGlyf(code, cmds, this);
  31636. }
  31637. }
  31638. class Type2Compiled extends CompiledFont {
  31639. constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
  31640. super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
  31641. this.glyphs = cffInfo.glyphs;
  31642. this.gsubrs = cffInfo.gsubrs || [];
  31643. this.subrs = cffInfo.subrs || [];
  31644. this.cmap = cmap;
  31645. this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
  31646. this.gsubrsBias = getSubroutineBias(this.gsubrs);
  31647. this.subrsBias = getSubroutineBias(this.subrs);
  31648. this.isCFFCIDFont = cffInfo.isCFFCIDFont;
  31649. this.fdSelect = cffInfo.fdSelect;
  31650. this.fdArray = cffInfo.fdArray;
  31651. }
  31652. compileGlyphImpl(code, cmds, glyphId) {
  31653. compileCharString(code, cmds, this, glyphId);
  31654. }
  31655. }
  31656. class FontRendererFactory {
  31657. static create(font, seacAnalysisEnabled) {
  31658. const data = new Uint8Array(font.data);
  31659. let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  31660. const numTables = getUint16(data, 4);
  31661. for (let i = 0, p = 12; i < numTables; i++, p += 16) {
  31662. const tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
  31663. const offset = getUint32(data, p + 8);
  31664. const length = getUint32(data, p + 12);
  31665. switch (tag) {
  31666. case "cmap":
  31667. cmap = parseCmap(data, offset, offset + length);
  31668. break;
  31669. case "glyf":
  31670. glyf = data.subarray(offset, offset + length);
  31671. break;
  31672. case "loca":
  31673. loca = data.subarray(offset, offset + length);
  31674. break;
  31675. case "head":
  31676. unitsPerEm = getUint16(data, offset + 18);
  31677. indexToLocFormat = getUint16(data, offset + 50);
  31678. break;
  31679. case "CFF ":
  31680. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  31681. break;
  31682. }
  31683. }
  31684. if (glyf) {
  31685. const fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
  31686. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  31687. }
  31688. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  31689. }
  31690. }
  31691. exports.FontRendererFactory = FontRendererFactory;
  31692. /***/ }),
  31693. /* 45 */
  31694. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  31695. Object.defineProperty(exports, "__esModule", ({
  31696. value: true
  31697. }));
  31698. exports.getMetrics = exports.getFontBasicMetrics = void 0;
  31699. var _core_utils = __w_pdfjs_require__(3);
  31700. const getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
  31701. t.Courier = 600;
  31702. t["Courier-Bold"] = 600;
  31703. t["Courier-BoldOblique"] = 600;
  31704. t["Courier-Oblique"] = 600;
  31705. t.Helvetica = (0, _core_utils.getLookupTableFactory)(function (t) {
  31706. t.space = 278;
  31707. t.exclam = 278;
  31708. t.quotedbl = 355;
  31709. t.numbersign = 556;
  31710. t.dollar = 556;
  31711. t.percent = 889;
  31712. t.ampersand = 667;
  31713. t.quoteright = 222;
  31714. t.parenleft = 333;
  31715. t.parenright = 333;
  31716. t.asterisk = 389;
  31717. t.plus = 584;
  31718. t.comma = 278;
  31719. t.hyphen = 333;
  31720. t.period = 278;
  31721. t.slash = 278;
  31722. t.zero = 556;
  31723. t.one = 556;
  31724. t.two = 556;
  31725. t.three = 556;
  31726. t.four = 556;
  31727. t.five = 556;
  31728. t.six = 556;
  31729. t.seven = 556;
  31730. t.eight = 556;
  31731. t.nine = 556;
  31732. t.colon = 278;
  31733. t.semicolon = 278;
  31734. t.less = 584;
  31735. t.equal = 584;
  31736. t.greater = 584;
  31737. t.question = 556;
  31738. t.at = 1015;
  31739. t.A = 667;
  31740. t.B = 667;
  31741. t.C = 722;
  31742. t.D = 722;
  31743. t.E = 667;
  31744. t.F = 611;
  31745. t.G = 778;
  31746. t.H = 722;
  31747. t.I = 278;
  31748. t.J = 500;
  31749. t.K = 667;
  31750. t.L = 556;
  31751. t.M = 833;
  31752. t.N = 722;
  31753. t.O = 778;
  31754. t.P = 667;
  31755. t.Q = 778;
  31756. t.R = 722;
  31757. t.S = 667;
  31758. t.T = 611;
  31759. t.U = 722;
  31760. t.V = 667;
  31761. t.W = 944;
  31762. t.X = 667;
  31763. t.Y = 667;
  31764. t.Z = 611;
  31765. t.bracketleft = 278;
  31766. t.backslash = 278;
  31767. t.bracketright = 278;
  31768. t.asciicircum = 469;
  31769. t.underscore = 556;
  31770. t.quoteleft = 222;
  31771. t.a = 556;
  31772. t.b = 556;
  31773. t.c = 500;
  31774. t.d = 556;
  31775. t.e = 556;
  31776. t.f = 278;
  31777. t.g = 556;
  31778. t.h = 556;
  31779. t.i = 222;
  31780. t.j = 222;
  31781. t.k = 500;
  31782. t.l = 222;
  31783. t.m = 833;
  31784. t.n = 556;
  31785. t.o = 556;
  31786. t.p = 556;
  31787. t.q = 556;
  31788. t.r = 333;
  31789. t.s = 500;
  31790. t.t = 278;
  31791. t.u = 556;
  31792. t.v = 500;
  31793. t.w = 722;
  31794. t.x = 500;
  31795. t.y = 500;
  31796. t.z = 500;
  31797. t.braceleft = 334;
  31798. t.bar = 260;
  31799. t.braceright = 334;
  31800. t.asciitilde = 584;
  31801. t.exclamdown = 333;
  31802. t.cent = 556;
  31803. t.sterling = 556;
  31804. t.fraction = 167;
  31805. t.yen = 556;
  31806. t.florin = 556;
  31807. t.section = 556;
  31808. t.currency = 556;
  31809. t.quotesingle = 191;
  31810. t.quotedblleft = 333;
  31811. t.guillemotleft = 556;
  31812. t.guilsinglleft = 333;
  31813. t.guilsinglright = 333;
  31814. t.fi = 500;
  31815. t.fl = 500;
  31816. t.endash = 556;
  31817. t.dagger = 556;
  31818. t.daggerdbl = 556;
  31819. t.periodcentered = 278;
  31820. t.paragraph = 537;
  31821. t.bullet = 350;
  31822. t.quotesinglbase = 222;
  31823. t.quotedblbase = 333;
  31824. t.quotedblright = 333;
  31825. t.guillemotright = 556;
  31826. t.ellipsis = 1000;
  31827. t.perthousand = 1000;
  31828. t.questiondown = 611;
  31829. t.grave = 333;
  31830. t.acute = 333;
  31831. t.circumflex = 333;
  31832. t.tilde = 333;
  31833. t.macron = 333;
  31834. t.breve = 333;
  31835. t.dotaccent = 333;
  31836. t.dieresis = 333;
  31837. t.ring = 333;
  31838. t.cedilla = 333;
  31839. t.hungarumlaut = 333;
  31840. t.ogonek = 333;
  31841. t.caron = 333;
  31842. t.emdash = 1000;
  31843. t.AE = 1000;
  31844. t.ordfeminine = 370;
  31845. t.Lslash = 556;
  31846. t.Oslash = 778;
  31847. t.OE = 1000;
  31848. t.ordmasculine = 365;
  31849. t.ae = 889;
  31850. t.dotlessi = 278;
  31851. t.lslash = 222;
  31852. t.oslash = 611;
  31853. t.oe = 944;
  31854. t.germandbls = 611;
  31855. t.Idieresis = 278;
  31856. t.eacute = 556;
  31857. t.abreve = 556;
  31858. t.uhungarumlaut = 556;
  31859. t.ecaron = 556;
  31860. t.Ydieresis = 667;
  31861. t.divide = 584;
  31862. t.Yacute = 667;
  31863. t.Acircumflex = 667;
  31864. t.aacute = 556;
  31865. t.Ucircumflex = 722;
  31866. t.yacute = 500;
  31867. t.scommaaccent = 500;
  31868. t.ecircumflex = 556;
  31869. t.Uring = 722;
  31870. t.Udieresis = 722;
  31871. t.aogonek = 556;
  31872. t.Uacute = 722;
  31873. t.uogonek = 556;
  31874. t.Edieresis = 667;
  31875. t.Dcroat = 722;
  31876. t.commaaccent = 250;
  31877. t.copyright = 737;
  31878. t.Emacron = 667;
  31879. t.ccaron = 500;
  31880. t.aring = 556;
  31881. t.Ncommaaccent = 722;
  31882. t.lacute = 222;
  31883. t.agrave = 556;
  31884. t.Tcommaaccent = 611;
  31885. t.Cacute = 722;
  31886. t.atilde = 556;
  31887. t.Edotaccent = 667;
  31888. t.scaron = 500;
  31889. t.scedilla = 500;
  31890. t.iacute = 278;
  31891. t.lozenge = 471;
  31892. t.Rcaron = 722;
  31893. t.Gcommaaccent = 778;
  31894. t.ucircumflex = 556;
  31895. t.acircumflex = 556;
  31896. t.Amacron = 667;
  31897. t.rcaron = 333;
  31898. t.ccedilla = 500;
  31899. t.Zdotaccent = 611;
  31900. t.Thorn = 667;
  31901. t.Omacron = 778;
  31902. t.Racute = 722;
  31903. t.Sacute = 667;
  31904. t.dcaron = 643;
  31905. t.Umacron = 722;
  31906. t.uring = 556;
  31907. t.threesuperior = 333;
  31908. t.Ograve = 778;
  31909. t.Agrave = 667;
  31910. t.Abreve = 667;
  31911. t.multiply = 584;
  31912. t.uacute = 556;
  31913. t.Tcaron = 611;
  31914. t.partialdiff = 476;
  31915. t.ydieresis = 500;
  31916. t.Nacute = 722;
  31917. t.icircumflex = 278;
  31918. t.Ecircumflex = 667;
  31919. t.adieresis = 556;
  31920. t.edieresis = 556;
  31921. t.cacute = 500;
  31922. t.nacute = 556;
  31923. t.umacron = 556;
  31924. t.Ncaron = 722;
  31925. t.Iacute = 278;
  31926. t.plusminus = 584;
  31927. t.brokenbar = 260;
  31928. t.registered = 737;
  31929. t.Gbreve = 778;
  31930. t.Idotaccent = 278;
  31931. t.summation = 600;
  31932. t.Egrave = 667;
  31933. t.racute = 333;
  31934. t.omacron = 556;
  31935. t.Zacute = 611;
  31936. t.Zcaron = 611;
  31937. t.greaterequal = 549;
  31938. t.Eth = 722;
  31939. t.Ccedilla = 722;
  31940. t.lcommaaccent = 222;
  31941. t.tcaron = 317;
  31942. t.eogonek = 556;
  31943. t.Uogonek = 722;
  31944. t.Aacute = 667;
  31945. t.Adieresis = 667;
  31946. t.egrave = 556;
  31947. t.zacute = 500;
  31948. t.iogonek = 222;
  31949. t.Oacute = 778;
  31950. t.oacute = 556;
  31951. t.amacron = 556;
  31952. t.sacute = 500;
  31953. t.idieresis = 278;
  31954. t.Ocircumflex = 778;
  31955. t.Ugrave = 722;
  31956. t.Delta = 612;
  31957. t.thorn = 556;
  31958. t.twosuperior = 333;
  31959. t.Odieresis = 778;
  31960. t.mu = 556;
  31961. t.igrave = 278;
  31962. t.ohungarumlaut = 556;
  31963. t.Eogonek = 667;
  31964. t.dcroat = 556;
  31965. t.threequarters = 834;
  31966. t.Scedilla = 667;
  31967. t.lcaron = 299;
  31968. t.Kcommaaccent = 667;
  31969. t.Lacute = 556;
  31970. t.trademark = 1000;
  31971. t.edotaccent = 556;
  31972. t.Igrave = 278;
  31973. t.Imacron = 278;
  31974. t.Lcaron = 556;
  31975. t.onehalf = 834;
  31976. t.lessequal = 549;
  31977. t.ocircumflex = 556;
  31978. t.ntilde = 556;
  31979. t.Uhungarumlaut = 722;
  31980. t.Eacute = 667;
  31981. t.emacron = 556;
  31982. t.gbreve = 556;
  31983. t.onequarter = 834;
  31984. t.Scaron = 667;
  31985. t.Scommaaccent = 667;
  31986. t.Ohungarumlaut = 778;
  31987. t.degree = 400;
  31988. t.ograve = 556;
  31989. t.Ccaron = 722;
  31990. t.ugrave = 556;
  31991. t.radical = 453;
  31992. t.Dcaron = 722;
  31993. t.rcommaaccent = 333;
  31994. t.Ntilde = 722;
  31995. t.otilde = 556;
  31996. t.Rcommaaccent = 722;
  31997. t.Lcommaaccent = 556;
  31998. t.Atilde = 667;
  31999. t.Aogonek = 667;
  32000. t.Aring = 667;
  32001. t.Otilde = 778;
  32002. t.zdotaccent = 500;
  32003. t.Ecaron = 667;
  32004. t.Iogonek = 278;
  32005. t.kcommaaccent = 500;
  32006. t.minus = 584;
  32007. t.Icircumflex = 278;
  32008. t.ncaron = 556;
  32009. t.tcommaaccent = 278;
  32010. t.logicalnot = 584;
  32011. t.odieresis = 556;
  32012. t.udieresis = 556;
  32013. t.notequal = 549;
  32014. t.gcommaaccent = 556;
  32015. t.eth = 556;
  32016. t.zcaron = 500;
  32017. t.ncommaaccent = 556;
  32018. t.onesuperior = 333;
  32019. t.imacron = 278;
  32020. t.Euro = 556;
  32021. });
  32022. t["Helvetica-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  32023. t.space = 278;
  32024. t.exclam = 333;
  32025. t.quotedbl = 474;
  32026. t.numbersign = 556;
  32027. t.dollar = 556;
  32028. t.percent = 889;
  32029. t.ampersand = 722;
  32030. t.quoteright = 278;
  32031. t.parenleft = 333;
  32032. t.parenright = 333;
  32033. t.asterisk = 389;
  32034. t.plus = 584;
  32035. t.comma = 278;
  32036. t.hyphen = 333;
  32037. t.period = 278;
  32038. t.slash = 278;
  32039. t.zero = 556;
  32040. t.one = 556;
  32041. t.two = 556;
  32042. t.three = 556;
  32043. t.four = 556;
  32044. t.five = 556;
  32045. t.six = 556;
  32046. t.seven = 556;
  32047. t.eight = 556;
  32048. t.nine = 556;
  32049. t.colon = 333;
  32050. t.semicolon = 333;
  32051. t.less = 584;
  32052. t.equal = 584;
  32053. t.greater = 584;
  32054. t.question = 611;
  32055. t.at = 975;
  32056. t.A = 722;
  32057. t.B = 722;
  32058. t.C = 722;
  32059. t.D = 722;
  32060. t.E = 667;
  32061. t.F = 611;
  32062. t.G = 778;
  32063. t.H = 722;
  32064. t.I = 278;
  32065. t.J = 556;
  32066. t.K = 722;
  32067. t.L = 611;
  32068. t.M = 833;
  32069. t.N = 722;
  32070. t.O = 778;
  32071. t.P = 667;
  32072. t.Q = 778;
  32073. t.R = 722;
  32074. t.S = 667;
  32075. t.T = 611;
  32076. t.U = 722;
  32077. t.V = 667;
  32078. t.W = 944;
  32079. t.X = 667;
  32080. t.Y = 667;
  32081. t.Z = 611;
  32082. t.bracketleft = 333;
  32083. t.backslash = 278;
  32084. t.bracketright = 333;
  32085. t.asciicircum = 584;
  32086. t.underscore = 556;
  32087. t.quoteleft = 278;
  32088. t.a = 556;
  32089. t.b = 611;
  32090. t.c = 556;
  32091. t.d = 611;
  32092. t.e = 556;
  32093. t.f = 333;
  32094. t.g = 611;
  32095. t.h = 611;
  32096. t.i = 278;
  32097. t.j = 278;
  32098. t.k = 556;
  32099. t.l = 278;
  32100. t.m = 889;
  32101. t.n = 611;
  32102. t.o = 611;
  32103. t.p = 611;
  32104. t.q = 611;
  32105. t.r = 389;
  32106. t.s = 556;
  32107. t.t = 333;
  32108. t.u = 611;
  32109. t.v = 556;
  32110. t.w = 778;
  32111. t.x = 556;
  32112. t.y = 556;
  32113. t.z = 500;
  32114. t.braceleft = 389;
  32115. t.bar = 280;
  32116. t.braceright = 389;
  32117. t.asciitilde = 584;
  32118. t.exclamdown = 333;
  32119. t.cent = 556;
  32120. t.sterling = 556;
  32121. t.fraction = 167;
  32122. t.yen = 556;
  32123. t.florin = 556;
  32124. t.section = 556;
  32125. t.currency = 556;
  32126. t.quotesingle = 238;
  32127. t.quotedblleft = 500;
  32128. t.guillemotleft = 556;
  32129. t.guilsinglleft = 333;
  32130. t.guilsinglright = 333;
  32131. t.fi = 611;
  32132. t.fl = 611;
  32133. t.endash = 556;
  32134. t.dagger = 556;
  32135. t.daggerdbl = 556;
  32136. t.periodcentered = 278;
  32137. t.paragraph = 556;
  32138. t.bullet = 350;
  32139. t.quotesinglbase = 278;
  32140. t.quotedblbase = 500;
  32141. t.quotedblright = 500;
  32142. t.guillemotright = 556;
  32143. t.ellipsis = 1000;
  32144. t.perthousand = 1000;
  32145. t.questiondown = 611;
  32146. t.grave = 333;
  32147. t.acute = 333;
  32148. t.circumflex = 333;
  32149. t.tilde = 333;
  32150. t.macron = 333;
  32151. t.breve = 333;
  32152. t.dotaccent = 333;
  32153. t.dieresis = 333;
  32154. t.ring = 333;
  32155. t.cedilla = 333;
  32156. t.hungarumlaut = 333;
  32157. t.ogonek = 333;
  32158. t.caron = 333;
  32159. t.emdash = 1000;
  32160. t.AE = 1000;
  32161. t.ordfeminine = 370;
  32162. t.Lslash = 611;
  32163. t.Oslash = 778;
  32164. t.OE = 1000;
  32165. t.ordmasculine = 365;
  32166. t.ae = 889;
  32167. t.dotlessi = 278;
  32168. t.lslash = 278;
  32169. t.oslash = 611;
  32170. t.oe = 944;
  32171. t.germandbls = 611;
  32172. t.Idieresis = 278;
  32173. t.eacute = 556;
  32174. t.abreve = 556;
  32175. t.uhungarumlaut = 611;
  32176. t.ecaron = 556;
  32177. t.Ydieresis = 667;
  32178. t.divide = 584;
  32179. t.Yacute = 667;
  32180. t.Acircumflex = 722;
  32181. t.aacute = 556;
  32182. t.Ucircumflex = 722;
  32183. t.yacute = 556;
  32184. t.scommaaccent = 556;
  32185. t.ecircumflex = 556;
  32186. t.Uring = 722;
  32187. t.Udieresis = 722;
  32188. t.aogonek = 556;
  32189. t.Uacute = 722;
  32190. t.uogonek = 611;
  32191. t.Edieresis = 667;
  32192. t.Dcroat = 722;
  32193. t.commaaccent = 250;
  32194. t.copyright = 737;
  32195. t.Emacron = 667;
  32196. t.ccaron = 556;
  32197. t.aring = 556;
  32198. t.Ncommaaccent = 722;
  32199. t.lacute = 278;
  32200. t.agrave = 556;
  32201. t.Tcommaaccent = 611;
  32202. t.Cacute = 722;
  32203. t.atilde = 556;
  32204. t.Edotaccent = 667;
  32205. t.scaron = 556;
  32206. t.scedilla = 556;
  32207. t.iacute = 278;
  32208. t.lozenge = 494;
  32209. t.Rcaron = 722;
  32210. t.Gcommaaccent = 778;
  32211. t.ucircumflex = 611;
  32212. t.acircumflex = 556;
  32213. t.Amacron = 722;
  32214. t.rcaron = 389;
  32215. t.ccedilla = 556;
  32216. t.Zdotaccent = 611;
  32217. t.Thorn = 667;
  32218. t.Omacron = 778;
  32219. t.Racute = 722;
  32220. t.Sacute = 667;
  32221. t.dcaron = 743;
  32222. t.Umacron = 722;
  32223. t.uring = 611;
  32224. t.threesuperior = 333;
  32225. t.Ograve = 778;
  32226. t.Agrave = 722;
  32227. t.Abreve = 722;
  32228. t.multiply = 584;
  32229. t.uacute = 611;
  32230. t.Tcaron = 611;
  32231. t.partialdiff = 494;
  32232. t.ydieresis = 556;
  32233. t.Nacute = 722;
  32234. t.icircumflex = 278;
  32235. t.Ecircumflex = 667;
  32236. t.adieresis = 556;
  32237. t.edieresis = 556;
  32238. t.cacute = 556;
  32239. t.nacute = 611;
  32240. t.umacron = 611;
  32241. t.Ncaron = 722;
  32242. t.Iacute = 278;
  32243. t.plusminus = 584;
  32244. t.brokenbar = 280;
  32245. t.registered = 737;
  32246. t.Gbreve = 778;
  32247. t.Idotaccent = 278;
  32248. t.summation = 600;
  32249. t.Egrave = 667;
  32250. t.racute = 389;
  32251. t.omacron = 611;
  32252. t.Zacute = 611;
  32253. t.Zcaron = 611;
  32254. t.greaterequal = 549;
  32255. t.Eth = 722;
  32256. t.Ccedilla = 722;
  32257. t.lcommaaccent = 278;
  32258. t.tcaron = 389;
  32259. t.eogonek = 556;
  32260. t.Uogonek = 722;
  32261. t.Aacute = 722;
  32262. t.Adieresis = 722;
  32263. t.egrave = 556;
  32264. t.zacute = 500;
  32265. t.iogonek = 278;
  32266. t.Oacute = 778;
  32267. t.oacute = 611;
  32268. t.amacron = 556;
  32269. t.sacute = 556;
  32270. t.idieresis = 278;
  32271. t.Ocircumflex = 778;
  32272. t.Ugrave = 722;
  32273. t.Delta = 612;
  32274. t.thorn = 611;
  32275. t.twosuperior = 333;
  32276. t.Odieresis = 778;
  32277. t.mu = 611;
  32278. t.igrave = 278;
  32279. t.ohungarumlaut = 611;
  32280. t.Eogonek = 667;
  32281. t.dcroat = 611;
  32282. t.threequarters = 834;
  32283. t.Scedilla = 667;
  32284. t.lcaron = 400;
  32285. t.Kcommaaccent = 722;
  32286. t.Lacute = 611;
  32287. t.trademark = 1000;
  32288. t.edotaccent = 556;
  32289. t.Igrave = 278;
  32290. t.Imacron = 278;
  32291. t.Lcaron = 611;
  32292. t.onehalf = 834;
  32293. t.lessequal = 549;
  32294. t.ocircumflex = 611;
  32295. t.ntilde = 611;
  32296. t.Uhungarumlaut = 722;
  32297. t.Eacute = 667;
  32298. t.emacron = 556;
  32299. t.gbreve = 611;
  32300. t.onequarter = 834;
  32301. t.Scaron = 667;
  32302. t.Scommaaccent = 667;
  32303. t.Ohungarumlaut = 778;
  32304. t.degree = 400;
  32305. t.ograve = 611;
  32306. t.Ccaron = 722;
  32307. t.ugrave = 611;
  32308. t.radical = 549;
  32309. t.Dcaron = 722;
  32310. t.rcommaaccent = 389;
  32311. t.Ntilde = 722;
  32312. t.otilde = 611;
  32313. t.Rcommaaccent = 722;
  32314. t.Lcommaaccent = 611;
  32315. t.Atilde = 722;
  32316. t.Aogonek = 722;
  32317. t.Aring = 722;
  32318. t.Otilde = 778;
  32319. t.zdotaccent = 500;
  32320. t.Ecaron = 667;
  32321. t.Iogonek = 278;
  32322. t.kcommaaccent = 556;
  32323. t.minus = 584;
  32324. t.Icircumflex = 278;
  32325. t.ncaron = 611;
  32326. t.tcommaaccent = 333;
  32327. t.logicalnot = 584;
  32328. t.odieresis = 611;
  32329. t.udieresis = 611;
  32330. t.notequal = 549;
  32331. t.gcommaaccent = 611;
  32332. t.eth = 611;
  32333. t.zcaron = 500;
  32334. t.ncommaaccent = 611;
  32335. t.onesuperior = 333;
  32336. t.imacron = 278;
  32337. t.Euro = 556;
  32338. });
  32339. t["Helvetica-BoldOblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  32340. t.space = 278;
  32341. t.exclam = 333;
  32342. t.quotedbl = 474;
  32343. t.numbersign = 556;
  32344. t.dollar = 556;
  32345. t.percent = 889;
  32346. t.ampersand = 722;
  32347. t.quoteright = 278;
  32348. t.parenleft = 333;
  32349. t.parenright = 333;
  32350. t.asterisk = 389;
  32351. t.plus = 584;
  32352. t.comma = 278;
  32353. t.hyphen = 333;
  32354. t.period = 278;
  32355. t.slash = 278;
  32356. t.zero = 556;
  32357. t.one = 556;
  32358. t.two = 556;
  32359. t.three = 556;
  32360. t.four = 556;
  32361. t.five = 556;
  32362. t.six = 556;
  32363. t.seven = 556;
  32364. t.eight = 556;
  32365. t.nine = 556;
  32366. t.colon = 333;
  32367. t.semicolon = 333;
  32368. t.less = 584;
  32369. t.equal = 584;
  32370. t.greater = 584;
  32371. t.question = 611;
  32372. t.at = 975;
  32373. t.A = 722;
  32374. t.B = 722;
  32375. t.C = 722;
  32376. t.D = 722;
  32377. t.E = 667;
  32378. t.F = 611;
  32379. t.G = 778;
  32380. t.H = 722;
  32381. t.I = 278;
  32382. t.J = 556;
  32383. t.K = 722;
  32384. t.L = 611;
  32385. t.M = 833;
  32386. t.N = 722;
  32387. t.O = 778;
  32388. t.P = 667;
  32389. t.Q = 778;
  32390. t.R = 722;
  32391. t.S = 667;
  32392. t.T = 611;
  32393. t.U = 722;
  32394. t.V = 667;
  32395. t.W = 944;
  32396. t.X = 667;
  32397. t.Y = 667;
  32398. t.Z = 611;
  32399. t.bracketleft = 333;
  32400. t.backslash = 278;
  32401. t.bracketright = 333;
  32402. t.asciicircum = 584;
  32403. t.underscore = 556;
  32404. t.quoteleft = 278;
  32405. t.a = 556;
  32406. t.b = 611;
  32407. t.c = 556;
  32408. t.d = 611;
  32409. t.e = 556;
  32410. t.f = 333;
  32411. t.g = 611;
  32412. t.h = 611;
  32413. t.i = 278;
  32414. t.j = 278;
  32415. t.k = 556;
  32416. t.l = 278;
  32417. t.m = 889;
  32418. t.n = 611;
  32419. t.o = 611;
  32420. t.p = 611;
  32421. t.q = 611;
  32422. t.r = 389;
  32423. t.s = 556;
  32424. t.t = 333;
  32425. t.u = 611;
  32426. t.v = 556;
  32427. t.w = 778;
  32428. t.x = 556;
  32429. t.y = 556;
  32430. t.z = 500;
  32431. t.braceleft = 389;
  32432. t.bar = 280;
  32433. t.braceright = 389;
  32434. t.asciitilde = 584;
  32435. t.exclamdown = 333;
  32436. t.cent = 556;
  32437. t.sterling = 556;
  32438. t.fraction = 167;
  32439. t.yen = 556;
  32440. t.florin = 556;
  32441. t.section = 556;
  32442. t.currency = 556;
  32443. t.quotesingle = 238;
  32444. t.quotedblleft = 500;
  32445. t.guillemotleft = 556;
  32446. t.guilsinglleft = 333;
  32447. t.guilsinglright = 333;
  32448. t.fi = 611;
  32449. t.fl = 611;
  32450. t.endash = 556;
  32451. t.dagger = 556;
  32452. t.daggerdbl = 556;
  32453. t.periodcentered = 278;
  32454. t.paragraph = 556;
  32455. t.bullet = 350;
  32456. t.quotesinglbase = 278;
  32457. t.quotedblbase = 500;
  32458. t.quotedblright = 500;
  32459. t.guillemotright = 556;
  32460. t.ellipsis = 1000;
  32461. t.perthousand = 1000;
  32462. t.questiondown = 611;
  32463. t.grave = 333;
  32464. t.acute = 333;
  32465. t.circumflex = 333;
  32466. t.tilde = 333;
  32467. t.macron = 333;
  32468. t.breve = 333;
  32469. t.dotaccent = 333;
  32470. t.dieresis = 333;
  32471. t.ring = 333;
  32472. t.cedilla = 333;
  32473. t.hungarumlaut = 333;
  32474. t.ogonek = 333;
  32475. t.caron = 333;
  32476. t.emdash = 1000;
  32477. t.AE = 1000;
  32478. t.ordfeminine = 370;
  32479. t.Lslash = 611;
  32480. t.Oslash = 778;
  32481. t.OE = 1000;
  32482. t.ordmasculine = 365;
  32483. t.ae = 889;
  32484. t.dotlessi = 278;
  32485. t.lslash = 278;
  32486. t.oslash = 611;
  32487. t.oe = 944;
  32488. t.germandbls = 611;
  32489. t.Idieresis = 278;
  32490. t.eacute = 556;
  32491. t.abreve = 556;
  32492. t.uhungarumlaut = 611;
  32493. t.ecaron = 556;
  32494. t.Ydieresis = 667;
  32495. t.divide = 584;
  32496. t.Yacute = 667;
  32497. t.Acircumflex = 722;
  32498. t.aacute = 556;
  32499. t.Ucircumflex = 722;
  32500. t.yacute = 556;
  32501. t.scommaaccent = 556;
  32502. t.ecircumflex = 556;
  32503. t.Uring = 722;
  32504. t.Udieresis = 722;
  32505. t.aogonek = 556;
  32506. t.Uacute = 722;
  32507. t.uogonek = 611;
  32508. t.Edieresis = 667;
  32509. t.Dcroat = 722;
  32510. t.commaaccent = 250;
  32511. t.copyright = 737;
  32512. t.Emacron = 667;
  32513. t.ccaron = 556;
  32514. t.aring = 556;
  32515. t.Ncommaaccent = 722;
  32516. t.lacute = 278;
  32517. t.agrave = 556;
  32518. t.Tcommaaccent = 611;
  32519. t.Cacute = 722;
  32520. t.atilde = 556;
  32521. t.Edotaccent = 667;
  32522. t.scaron = 556;
  32523. t.scedilla = 556;
  32524. t.iacute = 278;
  32525. t.lozenge = 494;
  32526. t.Rcaron = 722;
  32527. t.Gcommaaccent = 778;
  32528. t.ucircumflex = 611;
  32529. t.acircumflex = 556;
  32530. t.Amacron = 722;
  32531. t.rcaron = 389;
  32532. t.ccedilla = 556;
  32533. t.Zdotaccent = 611;
  32534. t.Thorn = 667;
  32535. t.Omacron = 778;
  32536. t.Racute = 722;
  32537. t.Sacute = 667;
  32538. t.dcaron = 743;
  32539. t.Umacron = 722;
  32540. t.uring = 611;
  32541. t.threesuperior = 333;
  32542. t.Ograve = 778;
  32543. t.Agrave = 722;
  32544. t.Abreve = 722;
  32545. t.multiply = 584;
  32546. t.uacute = 611;
  32547. t.Tcaron = 611;
  32548. t.partialdiff = 494;
  32549. t.ydieresis = 556;
  32550. t.Nacute = 722;
  32551. t.icircumflex = 278;
  32552. t.Ecircumflex = 667;
  32553. t.adieresis = 556;
  32554. t.edieresis = 556;
  32555. t.cacute = 556;
  32556. t.nacute = 611;
  32557. t.umacron = 611;
  32558. t.Ncaron = 722;
  32559. t.Iacute = 278;
  32560. t.plusminus = 584;
  32561. t.brokenbar = 280;
  32562. t.registered = 737;
  32563. t.Gbreve = 778;
  32564. t.Idotaccent = 278;
  32565. t.summation = 600;
  32566. t.Egrave = 667;
  32567. t.racute = 389;
  32568. t.omacron = 611;
  32569. t.Zacute = 611;
  32570. t.Zcaron = 611;
  32571. t.greaterequal = 549;
  32572. t.Eth = 722;
  32573. t.Ccedilla = 722;
  32574. t.lcommaaccent = 278;
  32575. t.tcaron = 389;
  32576. t.eogonek = 556;
  32577. t.Uogonek = 722;
  32578. t.Aacute = 722;
  32579. t.Adieresis = 722;
  32580. t.egrave = 556;
  32581. t.zacute = 500;
  32582. t.iogonek = 278;
  32583. t.Oacute = 778;
  32584. t.oacute = 611;
  32585. t.amacron = 556;
  32586. t.sacute = 556;
  32587. t.idieresis = 278;
  32588. t.Ocircumflex = 778;
  32589. t.Ugrave = 722;
  32590. t.Delta = 612;
  32591. t.thorn = 611;
  32592. t.twosuperior = 333;
  32593. t.Odieresis = 778;
  32594. t.mu = 611;
  32595. t.igrave = 278;
  32596. t.ohungarumlaut = 611;
  32597. t.Eogonek = 667;
  32598. t.dcroat = 611;
  32599. t.threequarters = 834;
  32600. t.Scedilla = 667;
  32601. t.lcaron = 400;
  32602. t.Kcommaaccent = 722;
  32603. t.Lacute = 611;
  32604. t.trademark = 1000;
  32605. t.edotaccent = 556;
  32606. t.Igrave = 278;
  32607. t.Imacron = 278;
  32608. t.Lcaron = 611;
  32609. t.onehalf = 834;
  32610. t.lessequal = 549;
  32611. t.ocircumflex = 611;
  32612. t.ntilde = 611;
  32613. t.Uhungarumlaut = 722;
  32614. t.Eacute = 667;
  32615. t.emacron = 556;
  32616. t.gbreve = 611;
  32617. t.onequarter = 834;
  32618. t.Scaron = 667;
  32619. t.Scommaaccent = 667;
  32620. t.Ohungarumlaut = 778;
  32621. t.degree = 400;
  32622. t.ograve = 611;
  32623. t.Ccaron = 722;
  32624. t.ugrave = 611;
  32625. t.radical = 549;
  32626. t.Dcaron = 722;
  32627. t.rcommaaccent = 389;
  32628. t.Ntilde = 722;
  32629. t.otilde = 611;
  32630. t.Rcommaaccent = 722;
  32631. t.Lcommaaccent = 611;
  32632. t.Atilde = 722;
  32633. t.Aogonek = 722;
  32634. t.Aring = 722;
  32635. t.Otilde = 778;
  32636. t.zdotaccent = 500;
  32637. t.Ecaron = 667;
  32638. t.Iogonek = 278;
  32639. t.kcommaaccent = 556;
  32640. t.minus = 584;
  32641. t.Icircumflex = 278;
  32642. t.ncaron = 611;
  32643. t.tcommaaccent = 333;
  32644. t.logicalnot = 584;
  32645. t.odieresis = 611;
  32646. t.udieresis = 611;
  32647. t.notequal = 549;
  32648. t.gcommaaccent = 611;
  32649. t.eth = 611;
  32650. t.zcaron = 500;
  32651. t.ncommaaccent = 611;
  32652. t.onesuperior = 333;
  32653. t.imacron = 278;
  32654. t.Euro = 556;
  32655. });
  32656. t["Helvetica-Oblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  32657. t.space = 278;
  32658. t.exclam = 278;
  32659. t.quotedbl = 355;
  32660. t.numbersign = 556;
  32661. t.dollar = 556;
  32662. t.percent = 889;
  32663. t.ampersand = 667;
  32664. t.quoteright = 222;
  32665. t.parenleft = 333;
  32666. t.parenright = 333;
  32667. t.asterisk = 389;
  32668. t.plus = 584;
  32669. t.comma = 278;
  32670. t.hyphen = 333;
  32671. t.period = 278;
  32672. t.slash = 278;
  32673. t.zero = 556;
  32674. t.one = 556;
  32675. t.two = 556;
  32676. t.three = 556;
  32677. t.four = 556;
  32678. t.five = 556;
  32679. t.six = 556;
  32680. t.seven = 556;
  32681. t.eight = 556;
  32682. t.nine = 556;
  32683. t.colon = 278;
  32684. t.semicolon = 278;
  32685. t.less = 584;
  32686. t.equal = 584;
  32687. t.greater = 584;
  32688. t.question = 556;
  32689. t.at = 1015;
  32690. t.A = 667;
  32691. t.B = 667;
  32692. t.C = 722;
  32693. t.D = 722;
  32694. t.E = 667;
  32695. t.F = 611;
  32696. t.G = 778;
  32697. t.H = 722;
  32698. t.I = 278;
  32699. t.J = 500;
  32700. t.K = 667;
  32701. t.L = 556;
  32702. t.M = 833;
  32703. t.N = 722;
  32704. t.O = 778;
  32705. t.P = 667;
  32706. t.Q = 778;
  32707. t.R = 722;
  32708. t.S = 667;
  32709. t.T = 611;
  32710. t.U = 722;
  32711. t.V = 667;
  32712. t.W = 944;
  32713. t.X = 667;
  32714. t.Y = 667;
  32715. t.Z = 611;
  32716. t.bracketleft = 278;
  32717. t.backslash = 278;
  32718. t.bracketright = 278;
  32719. t.asciicircum = 469;
  32720. t.underscore = 556;
  32721. t.quoteleft = 222;
  32722. t.a = 556;
  32723. t.b = 556;
  32724. t.c = 500;
  32725. t.d = 556;
  32726. t.e = 556;
  32727. t.f = 278;
  32728. t.g = 556;
  32729. t.h = 556;
  32730. t.i = 222;
  32731. t.j = 222;
  32732. t.k = 500;
  32733. t.l = 222;
  32734. t.m = 833;
  32735. t.n = 556;
  32736. t.o = 556;
  32737. t.p = 556;
  32738. t.q = 556;
  32739. t.r = 333;
  32740. t.s = 500;
  32741. t.t = 278;
  32742. t.u = 556;
  32743. t.v = 500;
  32744. t.w = 722;
  32745. t.x = 500;
  32746. t.y = 500;
  32747. t.z = 500;
  32748. t.braceleft = 334;
  32749. t.bar = 260;
  32750. t.braceright = 334;
  32751. t.asciitilde = 584;
  32752. t.exclamdown = 333;
  32753. t.cent = 556;
  32754. t.sterling = 556;
  32755. t.fraction = 167;
  32756. t.yen = 556;
  32757. t.florin = 556;
  32758. t.section = 556;
  32759. t.currency = 556;
  32760. t.quotesingle = 191;
  32761. t.quotedblleft = 333;
  32762. t.guillemotleft = 556;
  32763. t.guilsinglleft = 333;
  32764. t.guilsinglright = 333;
  32765. t.fi = 500;
  32766. t.fl = 500;
  32767. t.endash = 556;
  32768. t.dagger = 556;
  32769. t.daggerdbl = 556;
  32770. t.periodcentered = 278;
  32771. t.paragraph = 537;
  32772. t.bullet = 350;
  32773. t.quotesinglbase = 222;
  32774. t.quotedblbase = 333;
  32775. t.quotedblright = 333;
  32776. t.guillemotright = 556;
  32777. t.ellipsis = 1000;
  32778. t.perthousand = 1000;
  32779. t.questiondown = 611;
  32780. t.grave = 333;
  32781. t.acute = 333;
  32782. t.circumflex = 333;
  32783. t.tilde = 333;
  32784. t.macron = 333;
  32785. t.breve = 333;
  32786. t.dotaccent = 333;
  32787. t.dieresis = 333;
  32788. t.ring = 333;
  32789. t.cedilla = 333;
  32790. t.hungarumlaut = 333;
  32791. t.ogonek = 333;
  32792. t.caron = 333;
  32793. t.emdash = 1000;
  32794. t.AE = 1000;
  32795. t.ordfeminine = 370;
  32796. t.Lslash = 556;
  32797. t.Oslash = 778;
  32798. t.OE = 1000;
  32799. t.ordmasculine = 365;
  32800. t.ae = 889;
  32801. t.dotlessi = 278;
  32802. t.lslash = 222;
  32803. t.oslash = 611;
  32804. t.oe = 944;
  32805. t.germandbls = 611;
  32806. t.Idieresis = 278;
  32807. t.eacute = 556;
  32808. t.abreve = 556;
  32809. t.uhungarumlaut = 556;
  32810. t.ecaron = 556;
  32811. t.Ydieresis = 667;
  32812. t.divide = 584;
  32813. t.Yacute = 667;
  32814. t.Acircumflex = 667;
  32815. t.aacute = 556;
  32816. t.Ucircumflex = 722;
  32817. t.yacute = 500;
  32818. t.scommaaccent = 500;
  32819. t.ecircumflex = 556;
  32820. t.Uring = 722;
  32821. t.Udieresis = 722;
  32822. t.aogonek = 556;
  32823. t.Uacute = 722;
  32824. t.uogonek = 556;
  32825. t.Edieresis = 667;
  32826. t.Dcroat = 722;
  32827. t.commaaccent = 250;
  32828. t.copyright = 737;
  32829. t.Emacron = 667;
  32830. t.ccaron = 500;
  32831. t.aring = 556;
  32832. t.Ncommaaccent = 722;
  32833. t.lacute = 222;
  32834. t.agrave = 556;
  32835. t.Tcommaaccent = 611;
  32836. t.Cacute = 722;
  32837. t.atilde = 556;
  32838. t.Edotaccent = 667;
  32839. t.scaron = 500;
  32840. t.scedilla = 500;
  32841. t.iacute = 278;
  32842. t.lozenge = 471;
  32843. t.Rcaron = 722;
  32844. t.Gcommaaccent = 778;
  32845. t.ucircumflex = 556;
  32846. t.acircumflex = 556;
  32847. t.Amacron = 667;
  32848. t.rcaron = 333;
  32849. t.ccedilla = 500;
  32850. t.Zdotaccent = 611;
  32851. t.Thorn = 667;
  32852. t.Omacron = 778;
  32853. t.Racute = 722;
  32854. t.Sacute = 667;
  32855. t.dcaron = 643;
  32856. t.Umacron = 722;
  32857. t.uring = 556;
  32858. t.threesuperior = 333;
  32859. t.Ograve = 778;
  32860. t.Agrave = 667;
  32861. t.Abreve = 667;
  32862. t.multiply = 584;
  32863. t.uacute = 556;
  32864. t.Tcaron = 611;
  32865. t.partialdiff = 476;
  32866. t.ydieresis = 500;
  32867. t.Nacute = 722;
  32868. t.icircumflex = 278;
  32869. t.Ecircumflex = 667;
  32870. t.adieresis = 556;
  32871. t.edieresis = 556;
  32872. t.cacute = 500;
  32873. t.nacute = 556;
  32874. t.umacron = 556;
  32875. t.Ncaron = 722;
  32876. t.Iacute = 278;
  32877. t.plusminus = 584;
  32878. t.brokenbar = 260;
  32879. t.registered = 737;
  32880. t.Gbreve = 778;
  32881. t.Idotaccent = 278;
  32882. t.summation = 600;
  32883. t.Egrave = 667;
  32884. t.racute = 333;
  32885. t.omacron = 556;
  32886. t.Zacute = 611;
  32887. t.Zcaron = 611;
  32888. t.greaterequal = 549;
  32889. t.Eth = 722;
  32890. t.Ccedilla = 722;
  32891. t.lcommaaccent = 222;
  32892. t.tcaron = 317;
  32893. t.eogonek = 556;
  32894. t.Uogonek = 722;
  32895. t.Aacute = 667;
  32896. t.Adieresis = 667;
  32897. t.egrave = 556;
  32898. t.zacute = 500;
  32899. t.iogonek = 222;
  32900. t.Oacute = 778;
  32901. t.oacute = 556;
  32902. t.amacron = 556;
  32903. t.sacute = 500;
  32904. t.idieresis = 278;
  32905. t.Ocircumflex = 778;
  32906. t.Ugrave = 722;
  32907. t.Delta = 612;
  32908. t.thorn = 556;
  32909. t.twosuperior = 333;
  32910. t.Odieresis = 778;
  32911. t.mu = 556;
  32912. t.igrave = 278;
  32913. t.ohungarumlaut = 556;
  32914. t.Eogonek = 667;
  32915. t.dcroat = 556;
  32916. t.threequarters = 834;
  32917. t.Scedilla = 667;
  32918. t.lcaron = 299;
  32919. t.Kcommaaccent = 667;
  32920. t.Lacute = 556;
  32921. t.trademark = 1000;
  32922. t.edotaccent = 556;
  32923. t.Igrave = 278;
  32924. t.Imacron = 278;
  32925. t.Lcaron = 556;
  32926. t.onehalf = 834;
  32927. t.lessequal = 549;
  32928. t.ocircumflex = 556;
  32929. t.ntilde = 556;
  32930. t.Uhungarumlaut = 722;
  32931. t.Eacute = 667;
  32932. t.emacron = 556;
  32933. t.gbreve = 556;
  32934. t.onequarter = 834;
  32935. t.Scaron = 667;
  32936. t.Scommaaccent = 667;
  32937. t.Ohungarumlaut = 778;
  32938. t.degree = 400;
  32939. t.ograve = 556;
  32940. t.Ccaron = 722;
  32941. t.ugrave = 556;
  32942. t.radical = 453;
  32943. t.Dcaron = 722;
  32944. t.rcommaaccent = 333;
  32945. t.Ntilde = 722;
  32946. t.otilde = 556;
  32947. t.Rcommaaccent = 722;
  32948. t.Lcommaaccent = 556;
  32949. t.Atilde = 667;
  32950. t.Aogonek = 667;
  32951. t.Aring = 667;
  32952. t.Otilde = 778;
  32953. t.zdotaccent = 500;
  32954. t.Ecaron = 667;
  32955. t.Iogonek = 278;
  32956. t.kcommaaccent = 500;
  32957. t.minus = 584;
  32958. t.Icircumflex = 278;
  32959. t.ncaron = 556;
  32960. t.tcommaaccent = 278;
  32961. t.logicalnot = 584;
  32962. t.odieresis = 556;
  32963. t.udieresis = 556;
  32964. t.notequal = 549;
  32965. t.gcommaaccent = 556;
  32966. t.eth = 556;
  32967. t.zcaron = 500;
  32968. t.ncommaaccent = 556;
  32969. t.onesuperior = 333;
  32970. t.imacron = 278;
  32971. t.Euro = 556;
  32972. });
  32973. t.Symbol = (0, _core_utils.getLookupTableFactory)(function (t) {
  32974. t.space = 250;
  32975. t.exclam = 333;
  32976. t.universal = 713;
  32977. t.numbersign = 500;
  32978. t.existential = 549;
  32979. t.percent = 833;
  32980. t.ampersand = 778;
  32981. t.suchthat = 439;
  32982. t.parenleft = 333;
  32983. t.parenright = 333;
  32984. t.asteriskmath = 500;
  32985. t.plus = 549;
  32986. t.comma = 250;
  32987. t.minus = 549;
  32988. t.period = 250;
  32989. t.slash = 278;
  32990. t.zero = 500;
  32991. t.one = 500;
  32992. t.two = 500;
  32993. t.three = 500;
  32994. t.four = 500;
  32995. t.five = 500;
  32996. t.six = 500;
  32997. t.seven = 500;
  32998. t.eight = 500;
  32999. t.nine = 500;
  33000. t.colon = 278;
  33001. t.semicolon = 278;
  33002. t.less = 549;
  33003. t.equal = 549;
  33004. t.greater = 549;
  33005. t.question = 444;
  33006. t.congruent = 549;
  33007. t.Alpha = 722;
  33008. t.Beta = 667;
  33009. t.Chi = 722;
  33010. t.Delta = 612;
  33011. t.Epsilon = 611;
  33012. t.Phi = 763;
  33013. t.Gamma = 603;
  33014. t.Eta = 722;
  33015. t.Iota = 333;
  33016. t.theta1 = 631;
  33017. t.Kappa = 722;
  33018. t.Lambda = 686;
  33019. t.Mu = 889;
  33020. t.Nu = 722;
  33021. t.Omicron = 722;
  33022. t.Pi = 768;
  33023. t.Theta = 741;
  33024. t.Rho = 556;
  33025. t.Sigma = 592;
  33026. t.Tau = 611;
  33027. t.Upsilon = 690;
  33028. t.sigma1 = 439;
  33029. t.Omega = 768;
  33030. t.Xi = 645;
  33031. t.Psi = 795;
  33032. t.Zeta = 611;
  33033. t.bracketleft = 333;
  33034. t.therefore = 863;
  33035. t.bracketright = 333;
  33036. t.perpendicular = 658;
  33037. t.underscore = 500;
  33038. t.radicalex = 500;
  33039. t.alpha = 631;
  33040. t.beta = 549;
  33041. t.chi = 549;
  33042. t.delta = 494;
  33043. t.epsilon = 439;
  33044. t.phi = 521;
  33045. t.gamma = 411;
  33046. t.eta = 603;
  33047. t.iota = 329;
  33048. t.phi1 = 603;
  33049. t.kappa = 549;
  33050. t.lambda = 549;
  33051. t.mu = 576;
  33052. t.nu = 521;
  33053. t.omicron = 549;
  33054. t.pi = 549;
  33055. t.theta = 521;
  33056. t.rho = 549;
  33057. t.sigma = 603;
  33058. t.tau = 439;
  33059. t.upsilon = 576;
  33060. t.omega1 = 713;
  33061. t.omega = 686;
  33062. t.xi = 493;
  33063. t.psi = 686;
  33064. t.zeta = 494;
  33065. t.braceleft = 480;
  33066. t.bar = 200;
  33067. t.braceright = 480;
  33068. t.similar = 549;
  33069. t.Euro = 750;
  33070. t.Upsilon1 = 620;
  33071. t.minute = 247;
  33072. t.lessequal = 549;
  33073. t.fraction = 167;
  33074. t.infinity = 713;
  33075. t.florin = 500;
  33076. t.club = 753;
  33077. t.diamond = 753;
  33078. t.heart = 753;
  33079. t.spade = 753;
  33080. t.arrowboth = 1042;
  33081. t.arrowleft = 987;
  33082. t.arrowup = 603;
  33083. t.arrowright = 987;
  33084. t.arrowdown = 603;
  33085. t.degree = 400;
  33086. t.plusminus = 549;
  33087. t.second = 411;
  33088. t.greaterequal = 549;
  33089. t.multiply = 549;
  33090. t.proportional = 713;
  33091. t.partialdiff = 494;
  33092. t.bullet = 460;
  33093. t.divide = 549;
  33094. t.notequal = 549;
  33095. t.equivalence = 549;
  33096. t.approxequal = 549;
  33097. t.ellipsis = 1000;
  33098. t.arrowvertex = 603;
  33099. t.arrowhorizex = 1000;
  33100. t.carriagereturn = 658;
  33101. t.aleph = 823;
  33102. t.Ifraktur = 686;
  33103. t.Rfraktur = 795;
  33104. t.weierstrass = 987;
  33105. t.circlemultiply = 768;
  33106. t.circleplus = 768;
  33107. t.emptyset = 823;
  33108. t.intersection = 768;
  33109. t.union = 768;
  33110. t.propersuperset = 713;
  33111. t.reflexsuperset = 713;
  33112. t.notsubset = 713;
  33113. t.propersubset = 713;
  33114. t.reflexsubset = 713;
  33115. t.element = 713;
  33116. t.notelement = 713;
  33117. t.angle = 768;
  33118. t.gradient = 713;
  33119. t.registerserif = 790;
  33120. t.copyrightserif = 790;
  33121. t.trademarkserif = 890;
  33122. t.product = 823;
  33123. t.radical = 549;
  33124. t.dotmath = 250;
  33125. t.logicalnot = 713;
  33126. t.logicaland = 603;
  33127. t.logicalor = 603;
  33128. t.arrowdblboth = 1042;
  33129. t.arrowdblleft = 987;
  33130. t.arrowdblup = 603;
  33131. t.arrowdblright = 987;
  33132. t.arrowdbldown = 603;
  33133. t.lozenge = 494;
  33134. t.angleleft = 329;
  33135. t.registersans = 790;
  33136. t.copyrightsans = 790;
  33137. t.trademarksans = 786;
  33138. t.summation = 713;
  33139. t.parenlefttp = 384;
  33140. t.parenleftex = 384;
  33141. t.parenleftbt = 384;
  33142. t.bracketlefttp = 384;
  33143. t.bracketleftex = 384;
  33144. t.bracketleftbt = 384;
  33145. t.bracelefttp = 494;
  33146. t.braceleftmid = 494;
  33147. t.braceleftbt = 494;
  33148. t.braceex = 494;
  33149. t.angleright = 329;
  33150. t.integral = 274;
  33151. t.integraltp = 686;
  33152. t.integralex = 686;
  33153. t.integralbt = 686;
  33154. t.parenrighttp = 384;
  33155. t.parenrightex = 384;
  33156. t.parenrightbt = 384;
  33157. t.bracketrighttp = 384;
  33158. t.bracketrightex = 384;
  33159. t.bracketrightbt = 384;
  33160. t.bracerighttp = 494;
  33161. t.bracerightmid = 494;
  33162. t.bracerightbt = 494;
  33163. t.apple = 790;
  33164. });
  33165. t["Times-Roman"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  33166. t.space = 250;
  33167. t.exclam = 333;
  33168. t.quotedbl = 408;
  33169. t.numbersign = 500;
  33170. t.dollar = 500;
  33171. t.percent = 833;
  33172. t.ampersand = 778;
  33173. t.quoteright = 333;
  33174. t.parenleft = 333;
  33175. t.parenright = 333;
  33176. t.asterisk = 500;
  33177. t.plus = 564;
  33178. t.comma = 250;
  33179. t.hyphen = 333;
  33180. t.period = 250;
  33181. t.slash = 278;
  33182. t.zero = 500;
  33183. t.one = 500;
  33184. t.two = 500;
  33185. t.three = 500;
  33186. t.four = 500;
  33187. t.five = 500;
  33188. t.six = 500;
  33189. t.seven = 500;
  33190. t.eight = 500;
  33191. t.nine = 500;
  33192. t.colon = 278;
  33193. t.semicolon = 278;
  33194. t.less = 564;
  33195. t.equal = 564;
  33196. t.greater = 564;
  33197. t.question = 444;
  33198. t.at = 921;
  33199. t.A = 722;
  33200. t.B = 667;
  33201. t.C = 667;
  33202. t.D = 722;
  33203. t.E = 611;
  33204. t.F = 556;
  33205. t.G = 722;
  33206. t.H = 722;
  33207. t.I = 333;
  33208. t.J = 389;
  33209. t.K = 722;
  33210. t.L = 611;
  33211. t.M = 889;
  33212. t.N = 722;
  33213. t.O = 722;
  33214. t.P = 556;
  33215. t.Q = 722;
  33216. t.R = 667;
  33217. t.S = 556;
  33218. t.T = 611;
  33219. t.U = 722;
  33220. t.V = 722;
  33221. t.W = 944;
  33222. t.X = 722;
  33223. t.Y = 722;
  33224. t.Z = 611;
  33225. t.bracketleft = 333;
  33226. t.backslash = 278;
  33227. t.bracketright = 333;
  33228. t.asciicircum = 469;
  33229. t.underscore = 500;
  33230. t.quoteleft = 333;
  33231. t.a = 444;
  33232. t.b = 500;
  33233. t.c = 444;
  33234. t.d = 500;
  33235. t.e = 444;
  33236. t.f = 333;
  33237. t.g = 500;
  33238. t.h = 500;
  33239. t.i = 278;
  33240. t.j = 278;
  33241. t.k = 500;
  33242. t.l = 278;
  33243. t.m = 778;
  33244. t.n = 500;
  33245. t.o = 500;
  33246. t.p = 500;
  33247. t.q = 500;
  33248. t.r = 333;
  33249. t.s = 389;
  33250. t.t = 278;
  33251. t.u = 500;
  33252. t.v = 500;
  33253. t.w = 722;
  33254. t.x = 500;
  33255. t.y = 500;
  33256. t.z = 444;
  33257. t.braceleft = 480;
  33258. t.bar = 200;
  33259. t.braceright = 480;
  33260. t.asciitilde = 541;
  33261. t.exclamdown = 333;
  33262. t.cent = 500;
  33263. t.sterling = 500;
  33264. t.fraction = 167;
  33265. t.yen = 500;
  33266. t.florin = 500;
  33267. t.section = 500;
  33268. t.currency = 500;
  33269. t.quotesingle = 180;
  33270. t.quotedblleft = 444;
  33271. t.guillemotleft = 500;
  33272. t.guilsinglleft = 333;
  33273. t.guilsinglright = 333;
  33274. t.fi = 556;
  33275. t.fl = 556;
  33276. t.endash = 500;
  33277. t.dagger = 500;
  33278. t.daggerdbl = 500;
  33279. t.periodcentered = 250;
  33280. t.paragraph = 453;
  33281. t.bullet = 350;
  33282. t.quotesinglbase = 333;
  33283. t.quotedblbase = 444;
  33284. t.quotedblright = 444;
  33285. t.guillemotright = 500;
  33286. t.ellipsis = 1000;
  33287. t.perthousand = 1000;
  33288. t.questiondown = 444;
  33289. t.grave = 333;
  33290. t.acute = 333;
  33291. t.circumflex = 333;
  33292. t.tilde = 333;
  33293. t.macron = 333;
  33294. t.breve = 333;
  33295. t.dotaccent = 333;
  33296. t.dieresis = 333;
  33297. t.ring = 333;
  33298. t.cedilla = 333;
  33299. t.hungarumlaut = 333;
  33300. t.ogonek = 333;
  33301. t.caron = 333;
  33302. t.emdash = 1000;
  33303. t.AE = 889;
  33304. t.ordfeminine = 276;
  33305. t.Lslash = 611;
  33306. t.Oslash = 722;
  33307. t.OE = 889;
  33308. t.ordmasculine = 310;
  33309. t.ae = 667;
  33310. t.dotlessi = 278;
  33311. t.lslash = 278;
  33312. t.oslash = 500;
  33313. t.oe = 722;
  33314. t.germandbls = 500;
  33315. t.Idieresis = 333;
  33316. t.eacute = 444;
  33317. t.abreve = 444;
  33318. t.uhungarumlaut = 500;
  33319. t.ecaron = 444;
  33320. t.Ydieresis = 722;
  33321. t.divide = 564;
  33322. t.Yacute = 722;
  33323. t.Acircumflex = 722;
  33324. t.aacute = 444;
  33325. t.Ucircumflex = 722;
  33326. t.yacute = 500;
  33327. t.scommaaccent = 389;
  33328. t.ecircumflex = 444;
  33329. t.Uring = 722;
  33330. t.Udieresis = 722;
  33331. t.aogonek = 444;
  33332. t.Uacute = 722;
  33333. t.uogonek = 500;
  33334. t.Edieresis = 611;
  33335. t.Dcroat = 722;
  33336. t.commaaccent = 250;
  33337. t.copyright = 760;
  33338. t.Emacron = 611;
  33339. t.ccaron = 444;
  33340. t.aring = 444;
  33341. t.Ncommaaccent = 722;
  33342. t.lacute = 278;
  33343. t.agrave = 444;
  33344. t.Tcommaaccent = 611;
  33345. t.Cacute = 667;
  33346. t.atilde = 444;
  33347. t.Edotaccent = 611;
  33348. t.scaron = 389;
  33349. t.scedilla = 389;
  33350. t.iacute = 278;
  33351. t.lozenge = 471;
  33352. t.Rcaron = 667;
  33353. t.Gcommaaccent = 722;
  33354. t.ucircumflex = 500;
  33355. t.acircumflex = 444;
  33356. t.Amacron = 722;
  33357. t.rcaron = 333;
  33358. t.ccedilla = 444;
  33359. t.Zdotaccent = 611;
  33360. t.Thorn = 556;
  33361. t.Omacron = 722;
  33362. t.Racute = 667;
  33363. t.Sacute = 556;
  33364. t.dcaron = 588;
  33365. t.Umacron = 722;
  33366. t.uring = 500;
  33367. t.threesuperior = 300;
  33368. t.Ograve = 722;
  33369. t.Agrave = 722;
  33370. t.Abreve = 722;
  33371. t.multiply = 564;
  33372. t.uacute = 500;
  33373. t.Tcaron = 611;
  33374. t.partialdiff = 476;
  33375. t.ydieresis = 500;
  33376. t.Nacute = 722;
  33377. t.icircumflex = 278;
  33378. t.Ecircumflex = 611;
  33379. t.adieresis = 444;
  33380. t.edieresis = 444;
  33381. t.cacute = 444;
  33382. t.nacute = 500;
  33383. t.umacron = 500;
  33384. t.Ncaron = 722;
  33385. t.Iacute = 333;
  33386. t.plusminus = 564;
  33387. t.brokenbar = 200;
  33388. t.registered = 760;
  33389. t.Gbreve = 722;
  33390. t.Idotaccent = 333;
  33391. t.summation = 600;
  33392. t.Egrave = 611;
  33393. t.racute = 333;
  33394. t.omacron = 500;
  33395. t.Zacute = 611;
  33396. t.Zcaron = 611;
  33397. t.greaterequal = 549;
  33398. t.Eth = 722;
  33399. t.Ccedilla = 667;
  33400. t.lcommaaccent = 278;
  33401. t.tcaron = 326;
  33402. t.eogonek = 444;
  33403. t.Uogonek = 722;
  33404. t.Aacute = 722;
  33405. t.Adieresis = 722;
  33406. t.egrave = 444;
  33407. t.zacute = 444;
  33408. t.iogonek = 278;
  33409. t.Oacute = 722;
  33410. t.oacute = 500;
  33411. t.amacron = 444;
  33412. t.sacute = 389;
  33413. t.idieresis = 278;
  33414. t.Ocircumflex = 722;
  33415. t.Ugrave = 722;
  33416. t.Delta = 612;
  33417. t.thorn = 500;
  33418. t.twosuperior = 300;
  33419. t.Odieresis = 722;
  33420. t.mu = 500;
  33421. t.igrave = 278;
  33422. t.ohungarumlaut = 500;
  33423. t.Eogonek = 611;
  33424. t.dcroat = 500;
  33425. t.threequarters = 750;
  33426. t.Scedilla = 556;
  33427. t.lcaron = 344;
  33428. t.Kcommaaccent = 722;
  33429. t.Lacute = 611;
  33430. t.trademark = 980;
  33431. t.edotaccent = 444;
  33432. t.Igrave = 333;
  33433. t.Imacron = 333;
  33434. t.Lcaron = 611;
  33435. t.onehalf = 750;
  33436. t.lessequal = 549;
  33437. t.ocircumflex = 500;
  33438. t.ntilde = 500;
  33439. t.Uhungarumlaut = 722;
  33440. t.Eacute = 611;
  33441. t.emacron = 444;
  33442. t.gbreve = 500;
  33443. t.onequarter = 750;
  33444. t.Scaron = 556;
  33445. t.Scommaaccent = 556;
  33446. t.Ohungarumlaut = 722;
  33447. t.degree = 400;
  33448. t.ograve = 500;
  33449. t.Ccaron = 667;
  33450. t.ugrave = 500;
  33451. t.radical = 453;
  33452. t.Dcaron = 722;
  33453. t.rcommaaccent = 333;
  33454. t.Ntilde = 722;
  33455. t.otilde = 500;
  33456. t.Rcommaaccent = 667;
  33457. t.Lcommaaccent = 611;
  33458. t.Atilde = 722;
  33459. t.Aogonek = 722;
  33460. t.Aring = 722;
  33461. t.Otilde = 722;
  33462. t.zdotaccent = 444;
  33463. t.Ecaron = 611;
  33464. t.Iogonek = 333;
  33465. t.kcommaaccent = 500;
  33466. t.minus = 564;
  33467. t.Icircumflex = 333;
  33468. t.ncaron = 500;
  33469. t.tcommaaccent = 278;
  33470. t.logicalnot = 564;
  33471. t.odieresis = 500;
  33472. t.udieresis = 500;
  33473. t.notequal = 549;
  33474. t.gcommaaccent = 500;
  33475. t.eth = 500;
  33476. t.zcaron = 444;
  33477. t.ncommaaccent = 500;
  33478. t.onesuperior = 300;
  33479. t.imacron = 278;
  33480. t.Euro = 500;
  33481. });
  33482. t["Times-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  33483. t.space = 250;
  33484. t.exclam = 333;
  33485. t.quotedbl = 555;
  33486. t.numbersign = 500;
  33487. t.dollar = 500;
  33488. t.percent = 1000;
  33489. t.ampersand = 833;
  33490. t.quoteright = 333;
  33491. t.parenleft = 333;
  33492. t.parenright = 333;
  33493. t.asterisk = 500;
  33494. t.plus = 570;
  33495. t.comma = 250;
  33496. t.hyphen = 333;
  33497. t.period = 250;
  33498. t.slash = 278;
  33499. t.zero = 500;
  33500. t.one = 500;
  33501. t.two = 500;
  33502. t.three = 500;
  33503. t.four = 500;
  33504. t.five = 500;
  33505. t.six = 500;
  33506. t.seven = 500;
  33507. t.eight = 500;
  33508. t.nine = 500;
  33509. t.colon = 333;
  33510. t.semicolon = 333;
  33511. t.less = 570;
  33512. t.equal = 570;
  33513. t.greater = 570;
  33514. t.question = 500;
  33515. t.at = 930;
  33516. t.A = 722;
  33517. t.B = 667;
  33518. t.C = 722;
  33519. t.D = 722;
  33520. t.E = 667;
  33521. t.F = 611;
  33522. t.G = 778;
  33523. t.H = 778;
  33524. t.I = 389;
  33525. t.J = 500;
  33526. t.K = 778;
  33527. t.L = 667;
  33528. t.M = 944;
  33529. t.N = 722;
  33530. t.O = 778;
  33531. t.P = 611;
  33532. t.Q = 778;
  33533. t.R = 722;
  33534. t.S = 556;
  33535. t.T = 667;
  33536. t.U = 722;
  33537. t.V = 722;
  33538. t.W = 1000;
  33539. t.X = 722;
  33540. t.Y = 722;
  33541. t.Z = 667;
  33542. t.bracketleft = 333;
  33543. t.backslash = 278;
  33544. t.bracketright = 333;
  33545. t.asciicircum = 581;
  33546. t.underscore = 500;
  33547. t.quoteleft = 333;
  33548. t.a = 500;
  33549. t.b = 556;
  33550. t.c = 444;
  33551. t.d = 556;
  33552. t.e = 444;
  33553. t.f = 333;
  33554. t.g = 500;
  33555. t.h = 556;
  33556. t.i = 278;
  33557. t.j = 333;
  33558. t.k = 556;
  33559. t.l = 278;
  33560. t.m = 833;
  33561. t.n = 556;
  33562. t.o = 500;
  33563. t.p = 556;
  33564. t.q = 556;
  33565. t.r = 444;
  33566. t.s = 389;
  33567. t.t = 333;
  33568. t.u = 556;
  33569. t.v = 500;
  33570. t.w = 722;
  33571. t.x = 500;
  33572. t.y = 500;
  33573. t.z = 444;
  33574. t.braceleft = 394;
  33575. t.bar = 220;
  33576. t.braceright = 394;
  33577. t.asciitilde = 520;
  33578. t.exclamdown = 333;
  33579. t.cent = 500;
  33580. t.sterling = 500;
  33581. t.fraction = 167;
  33582. t.yen = 500;
  33583. t.florin = 500;
  33584. t.section = 500;
  33585. t.currency = 500;
  33586. t.quotesingle = 278;
  33587. t.quotedblleft = 500;
  33588. t.guillemotleft = 500;
  33589. t.guilsinglleft = 333;
  33590. t.guilsinglright = 333;
  33591. t.fi = 556;
  33592. t.fl = 556;
  33593. t.endash = 500;
  33594. t.dagger = 500;
  33595. t.daggerdbl = 500;
  33596. t.periodcentered = 250;
  33597. t.paragraph = 540;
  33598. t.bullet = 350;
  33599. t.quotesinglbase = 333;
  33600. t.quotedblbase = 500;
  33601. t.quotedblright = 500;
  33602. t.guillemotright = 500;
  33603. t.ellipsis = 1000;
  33604. t.perthousand = 1000;
  33605. t.questiondown = 500;
  33606. t.grave = 333;
  33607. t.acute = 333;
  33608. t.circumflex = 333;
  33609. t.tilde = 333;
  33610. t.macron = 333;
  33611. t.breve = 333;
  33612. t.dotaccent = 333;
  33613. t.dieresis = 333;
  33614. t.ring = 333;
  33615. t.cedilla = 333;
  33616. t.hungarumlaut = 333;
  33617. t.ogonek = 333;
  33618. t.caron = 333;
  33619. t.emdash = 1000;
  33620. t.AE = 1000;
  33621. t.ordfeminine = 300;
  33622. t.Lslash = 667;
  33623. t.Oslash = 778;
  33624. t.OE = 1000;
  33625. t.ordmasculine = 330;
  33626. t.ae = 722;
  33627. t.dotlessi = 278;
  33628. t.lslash = 278;
  33629. t.oslash = 500;
  33630. t.oe = 722;
  33631. t.germandbls = 556;
  33632. t.Idieresis = 389;
  33633. t.eacute = 444;
  33634. t.abreve = 500;
  33635. t.uhungarumlaut = 556;
  33636. t.ecaron = 444;
  33637. t.Ydieresis = 722;
  33638. t.divide = 570;
  33639. t.Yacute = 722;
  33640. t.Acircumflex = 722;
  33641. t.aacute = 500;
  33642. t.Ucircumflex = 722;
  33643. t.yacute = 500;
  33644. t.scommaaccent = 389;
  33645. t.ecircumflex = 444;
  33646. t.Uring = 722;
  33647. t.Udieresis = 722;
  33648. t.aogonek = 500;
  33649. t.Uacute = 722;
  33650. t.uogonek = 556;
  33651. t.Edieresis = 667;
  33652. t.Dcroat = 722;
  33653. t.commaaccent = 250;
  33654. t.copyright = 747;
  33655. t.Emacron = 667;
  33656. t.ccaron = 444;
  33657. t.aring = 500;
  33658. t.Ncommaaccent = 722;
  33659. t.lacute = 278;
  33660. t.agrave = 500;
  33661. t.Tcommaaccent = 667;
  33662. t.Cacute = 722;
  33663. t.atilde = 500;
  33664. t.Edotaccent = 667;
  33665. t.scaron = 389;
  33666. t.scedilla = 389;
  33667. t.iacute = 278;
  33668. t.lozenge = 494;
  33669. t.Rcaron = 722;
  33670. t.Gcommaaccent = 778;
  33671. t.ucircumflex = 556;
  33672. t.acircumflex = 500;
  33673. t.Amacron = 722;
  33674. t.rcaron = 444;
  33675. t.ccedilla = 444;
  33676. t.Zdotaccent = 667;
  33677. t.Thorn = 611;
  33678. t.Omacron = 778;
  33679. t.Racute = 722;
  33680. t.Sacute = 556;
  33681. t.dcaron = 672;
  33682. t.Umacron = 722;
  33683. t.uring = 556;
  33684. t.threesuperior = 300;
  33685. t.Ograve = 778;
  33686. t.Agrave = 722;
  33687. t.Abreve = 722;
  33688. t.multiply = 570;
  33689. t.uacute = 556;
  33690. t.Tcaron = 667;
  33691. t.partialdiff = 494;
  33692. t.ydieresis = 500;
  33693. t.Nacute = 722;
  33694. t.icircumflex = 278;
  33695. t.Ecircumflex = 667;
  33696. t.adieresis = 500;
  33697. t.edieresis = 444;
  33698. t.cacute = 444;
  33699. t.nacute = 556;
  33700. t.umacron = 556;
  33701. t.Ncaron = 722;
  33702. t.Iacute = 389;
  33703. t.plusminus = 570;
  33704. t.brokenbar = 220;
  33705. t.registered = 747;
  33706. t.Gbreve = 778;
  33707. t.Idotaccent = 389;
  33708. t.summation = 600;
  33709. t.Egrave = 667;
  33710. t.racute = 444;
  33711. t.omacron = 500;
  33712. t.Zacute = 667;
  33713. t.Zcaron = 667;
  33714. t.greaterequal = 549;
  33715. t.Eth = 722;
  33716. t.Ccedilla = 722;
  33717. t.lcommaaccent = 278;
  33718. t.tcaron = 416;
  33719. t.eogonek = 444;
  33720. t.Uogonek = 722;
  33721. t.Aacute = 722;
  33722. t.Adieresis = 722;
  33723. t.egrave = 444;
  33724. t.zacute = 444;
  33725. t.iogonek = 278;
  33726. t.Oacute = 778;
  33727. t.oacute = 500;
  33728. t.amacron = 500;
  33729. t.sacute = 389;
  33730. t.idieresis = 278;
  33731. t.Ocircumflex = 778;
  33732. t.Ugrave = 722;
  33733. t.Delta = 612;
  33734. t.thorn = 556;
  33735. t.twosuperior = 300;
  33736. t.Odieresis = 778;
  33737. t.mu = 556;
  33738. t.igrave = 278;
  33739. t.ohungarumlaut = 500;
  33740. t.Eogonek = 667;
  33741. t.dcroat = 556;
  33742. t.threequarters = 750;
  33743. t.Scedilla = 556;
  33744. t.lcaron = 394;
  33745. t.Kcommaaccent = 778;
  33746. t.Lacute = 667;
  33747. t.trademark = 1000;
  33748. t.edotaccent = 444;
  33749. t.Igrave = 389;
  33750. t.Imacron = 389;
  33751. t.Lcaron = 667;
  33752. t.onehalf = 750;
  33753. t.lessequal = 549;
  33754. t.ocircumflex = 500;
  33755. t.ntilde = 556;
  33756. t.Uhungarumlaut = 722;
  33757. t.Eacute = 667;
  33758. t.emacron = 444;
  33759. t.gbreve = 500;
  33760. t.onequarter = 750;
  33761. t.Scaron = 556;
  33762. t.Scommaaccent = 556;
  33763. t.Ohungarumlaut = 778;
  33764. t.degree = 400;
  33765. t.ograve = 500;
  33766. t.Ccaron = 722;
  33767. t.ugrave = 556;
  33768. t.radical = 549;
  33769. t.Dcaron = 722;
  33770. t.rcommaaccent = 444;
  33771. t.Ntilde = 722;
  33772. t.otilde = 500;
  33773. t.Rcommaaccent = 722;
  33774. t.Lcommaaccent = 667;
  33775. t.Atilde = 722;
  33776. t.Aogonek = 722;
  33777. t.Aring = 722;
  33778. t.Otilde = 778;
  33779. t.zdotaccent = 444;
  33780. t.Ecaron = 667;
  33781. t.Iogonek = 389;
  33782. t.kcommaaccent = 556;
  33783. t.minus = 570;
  33784. t.Icircumflex = 389;
  33785. t.ncaron = 556;
  33786. t.tcommaaccent = 333;
  33787. t.logicalnot = 570;
  33788. t.odieresis = 500;
  33789. t.udieresis = 556;
  33790. t.notequal = 549;
  33791. t.gcommaaccent = 500;
  33792. t.eth = 500;
  33793. t.zcaron = 444;
  33794. t.ncommaaccent = 556;
  33795. t.onesuperior = 300;
  33796. t.imacron = 278;
  33797. t.Euro = 500;
  33798. });
  33799. t["Times-BoldItalic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  33800. t.space = 250;
  33801. t.exclam = 389;
  33802. t.quotedbl = 555;
  33803. t.numbersign = 500;
  33804. t.dollar = 500;
  33805. t.percent = 833;
  33806. t.ampersand = 778;
  33807. t.quoteright = 333;
  33808. t.parenleft = 333;
  33809. t.parenright = 333;
  33810. t.asterisk = 500;
  33811. t.plus = 570;
  33812. t.comma = 250;
  33813. t.hyphen = 333;
  33814. t.period = 250;
  33815. t.slash = 278;
  33816. t.zero = 500;
  33817. t.one = 500;
  33818. t.two = 500;
  33819. t.three = 500;
  33820. t.four = 500;
  33821. t.five = 500;
  33822. t.six = 500;
  33823. t.seven = 500;
  33824. t.eight = 500;
  33825. t.nine = 500;
  33826. t.colon = 333;
  33827. t.semicolon = 333;
  33828. t.less = 570;
  33829. t.equal = 570;
  33830. t.greater = 570;
  33831. t.question = 500;
  33832. t.at = 832;
  33833. t.A = 667;
  33834. t.B = 667;
  33835. t.C = 667;
  33836. t.D = 722;
  33837. t.E = 667;
  33838. t.F = 667;
  33839. t.G = 722;
  33840. t.H = 778;
  33841. t.I = 389;
  33842. t.J = 500;
  33843. t.K = 667;
  33844. t.L = 611;
  33845. t.M = 889;
  33846. t.N = 722;
  33847. t.O = 722;
  33848. t.P = 611;
  33849. t.Q = 722;
  33850. t.R = 667;
  33851. t.S = 556;
  33852. t.T = 611;
  33853. t.U = 722;
  33854. t.V = 667;
  33855. t.W = 889;
  33856. t.X = 667;
  33857. t.Y = 611;
  33858. t.Z = 611;
  33859. t.bracketleft = 333;
  33860. t.backslash = 278;
  33861. t.bracketright = 333;
  33862. t.asciicircum = 570;
  33863. t.underscore = 500;
  33864. t.quoteleft = 333;
  33865. t.a = 500;
  33866. t.b = 500;
  33867. t.c = 444;
  33868. t.d = 500;
  33869. t.e = 444;
  33870. t.f = 333;
  33871. t.g = 500;
  33872. t.h = 556;
  33873. t.i = 278;
  33874. t.j = 278;
  33875. t.k = 500;
  33876. t.l = 278;
  33877. t.m = 778;
  33878. t.n = 556;
  33879. t.o = 500;
  33880. t.p = 500;
  33881. t.q = 500;
  33882. t.r = 389;
  33883. t.s = 389;
  33884. t.t = 278;
  33885. t.u = 556;
  33886. t.v = 444;
  33887. t.w = 667;
  33888. t.x = 500;
  33889. t.y = 444;
  33890. t.z = 389;
  33891. t.braceleft = 348;
  33892. t.bar = 220;
  33893. t.braceright = 348;
  33894. t.asciitilde = 570;
  33895. t.exclamdown = 389;
  33896. t.cent = 500;
  33897. t.sterling = 500;
  33898. t.fraction = 167;
  33899. t.yen = 500;
  33900. t.florin = 500;
  33901. t.section = 500;
  33902. t.currency = 500;
  33903. t.quotesingle = 278;
  33904. t.quotedblleft = 500;
  33905. t.guillemotleft = 500;
  33906. t.guilsinglleft = 333;
  33907. t.guilsinglright = 333;
  33908. t.fi = 556;
  33909. t.fl = 556;
  33910. t.endash = 500;
  33911. t.dagger = 500;
  33912. t.daggerdbl = 500;
  33913. t.periodcentered = 250;
  33914. t.paragraph = 500;
  33915. t.bullet = 350;
  33916. t.quotesinglbase = 333;
  33917. t.quotedblbase = 500;
  33918. t.quotedblright = 500;
  33919. t.guillemotright = 500;
  33920. t.ellipsis = 1000;
  33921. t.perthousand = 1000;
  33922. t.questiondown = 500;
  33923. t.grave = 333;
  33924. t.acute = 333;
  33925. t.circumflex = 333;
  33926. t.tilde = 333;
  33927. t.macron = 333;
  33928. t.breve = 333;
  33929. t.dotaccent = 333;
  33930. t.dieresis = 333;
  33931. t.ring = 333;
  33932. t.cedilla = 333;
  33933. t.hungarumlaut = 333;
  33934. t.ogonek = 333;
  33935. t.caron = 333;
  33936. t.emdash = 1000;
  33937. t.AE = 944;
  33938. t.ordfeminine = 266;
  33939. t.Lslash = 611;
  33940. t.Oslash = 722;
  33941. t.OE = 944;
  33942. t.ordmasculine = 300;
  33943. t.ae = 722;
  33944. t.dotlessi = 278;
  33945. t.lslash = 278;
  33946. t.oslash = 500;
  33947. t.oe = 722;
  33948. t.germandbls = 500;
  33949. t.Idieresis = 389;
  33950. t.eacute = 444;
  33951. t.abreve = 500;
  33952. t.uhungarumlaut = 556;
  33953. t.ecaron = 444;
  33954. t.Ydieresis = 611;
  33955. t.divide = 570;
  33956. t.Yacute = 611;
  33957. t.Acircumflex = 667;
  33958. t.aacute = 500;
  33959. t.Ucircumflex = 722;
  33960. t.yacute = 444;
  33961. t.scommaaccent = 389;
  33962. t.ecircumflex = 444;
  33963. t.Uring = 722;
  33964. t.Udieresis = 722;
  33965. t.aogonek = 500;
  33966. t.Uacute = 722;
  33967. t.uogonek = 556;
  33968. t.Edieresis = 667;
  33969. t.Dcroat = 722;
  33970. t.commaaccent = 250;
  33971. t.copyright = 747;
  33972. t.Emacron = 667;
  33973. t.ccaron = 444;
  33974. t.aring = 500;
  33975. t.Ncommaaccent = 722;
  33976. t.lacute = 278;
  33977. t.agrave = 500;
  33978. t.Tcommaaccent = 611;
  33979. t.Cacute = 667;
  33980. t.atilde = 500;
  33981. t.Edotaccent = 667;
  33982. t.scaron = 389;
  33983. t.scedilla = 389;
  33984. t.iacute = 278;
  33985. t.lozenge = 494;
  33986. t.Rcaron = 667;
  33987. t.Gcommaaccent = 722;
  33988. t.ucircumflex = 556;
  33989. t.acircumflex = 500;
  33990. t.Amacron = 667;
  33991. t.rcaron = 389;
  33992. t.ccedilla = 444;
  33993. t.Zdotaccent = 611;
  33994. t.Thorn = 611;
  33995. t.Omacron = 722;
  33996. t.Racute = 667;
  33997. t.Sacute = 556;
  33998. t.dcaron = 608;
  33999. t.Umacron = 722;
  34000. t.uring = 556;
  34001. t.threesuperior = 300;
  34002. t.Ograve = 722;
  34003. t.Agrave = 667;
  34004. t.Abreve = 667;
  34005. t.multiply = 570;
  34006. t.uacute = 556;
  34007. t.Tcaron = 611;
  34008. t.partialdiff = 494;
  34009. t.ydieresis = 444;
  34010. t.Nacute = 722;
  34011. t.icircumflex = 278;
  34012. t.Ecircumflex = 667;
  34013. t.adieresis = 500;
  34014. t.edieresis = 444;
  34015. t.cacute = 444;
  34016. t.nacute = 556;
  34017. t.umacron = 556;
  34018. t.Ncaron = 722;
  34019. t.Iacute = 389;
  34020. t.plusminus = 570;
  34021. t.brokenbar = 220;
  34022. t.registered = 747;
  34023. t.Gbreve = 722;
  34024. t.Idotaccent = 389;
  34025. t.summation = 600;
  34026. t.Egrave = 667;
  34027. t.racute = 389;
  34028. t.omacron = 500;
  34029. t.Zacute = 611;
  34030. t.Zcaron = 611;
  34031. t.greaterequal = 549;
  34032. t.Eth = 722;
  34033. t.Ccedilla = 667;
  34034. t.lcommaaccent = 278;
  34035. t.tcaron = 366;
  34036. t.eogonek = 444;
  34037. t.Uogonek = 722;
  34038. t.Aacute = 667;
  34039. t.Adieresis = 667;
  34040. t.egrave = 444;
  34041. t.zacute = 389;
  34042. t.iogonek = 278;
  34043. t.Oacute = 722;
  34044. t.oacute = 500;
  34045. t.amacron = 500;
  34046. t.sacute = 389;
  34047. t.idieresis = 278;
  34048. t.Ocircumflex = 722;
  34049. t.Ugrave = 722;
  34050. t.Delta = 612;
  34051. t.thorn = 500;
  34052. t.twosuperior = 300;
  34053. t.Odieresis = 722;
  34054. t.mu = 576;
  34055. t.igrave = 278;
  34056. t.ohungarumlaut = 500;
  34057. t.Eogonek = 667;
  34058. t.dcroat = 500;
  34059. t.threequarters = 750;
  34060. t.Scedilla = 556;
  34061. t.lcaron = 382;
  34062. t.Kcommaaccent = 667;
  34063. t.Lacute = 611;
  34064. t.trademark = 1000;
  34065. t.edotaccent = 444;
  34066. t.Igrave = 389;
  34067. t.Imacron = 389;
  34068. t.Lcaron = 611;
  34069. t.onehalf = 750;
  34070. t.lessequal = 549;
  34071. t.ocircumflex = 500;
  34072. t.ntilde = 556;
  34073. t.Uhungarumlaut = 722;
  34074. t.Eacute = 667;
  34075. t.emacron = 444;
  34076. t.gbreve = 500;
  34077. t.onequarter = 750;
  34078. t.Scaron = 556;
  34079. t.Scommaaccent = 556;
  34080. t.Ohungarumlaut = 722;
  34081. t.degree = 400;
  34082. t.ograve = 500;
  34083. t.Ccaron = 667;
  34084. t.ugrave = 556;
  34085. t.radical = 549;
  34086. t.Dcaron = 722;
  34087. t.rcommaaccent = 389;
  34088. t.Ntilde = 722;
  34089. t.otilde = 500;
  34090. t.Rcommaaccent = 667;
  34091. t.Lcommaaccent = 611;
  34092. t.Atilde = 667;
  34093. t.Aogonek = 667;
  34094. t.Aring = 667;
  34095. t.Otilde = 722;
  34096. t.zdotaccent = 389;
  34097. t.Ecaron = 667;
  34098. t.Iogonek = 389;
  34099. t.kcommaaccent = 500;
  34100. t.minus = 606;
  34101. t.Icircumflex = 389;
  34102. t.ncaron = 556;
  34103. t.tcommaaccent = 278;
  34104. t.logicalnot = 606;
  34105. t.odieresis = 500;
  34106. t.udieresis = 556;
  34107. t.notequal = 549;
  34108. t.gcommaaccent = 500;
  34109. t.eth = 500;
  34110. t.zcaron = 389;
  34111. t.ncommaaccent = 556;
  34112. t.onesuperior = 300;
  34113. t.imacron = 278;
  34114. t.Euro = 500;
  34115. });
  34116. t["Times-Italic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  34117. t.space = 250;
  34118. t.exclam = 333;
  34119. t.quotedbl = 420;
  34120. t.numbersign = 500;
  34121. t.dollar = 500;
  34122. t.percent = 833;
  34123. t.ampersand = 778;
  34124. t.quoteright = 333;
  34125. t.parenleft = 333;
  34126. t.parenright = 333;
  34127. t.asterisk = 500;
  34128. t.plus = 675;
  34129. t.comma = 250;
  34130. t.hyphen = 333;
  34131. t.period = 250;
  34132. t.slash = 278;
  34133. t.zero = 500;
  34134. t.one = 500;
  34135. t.two = 500;
  34136. t.three = 500;
  34137. t.four = 500;
  34138. t.five = 500;
  34139. t.six = 500;
  34140. t.seven = 500;
  34141. t.eight = 500;
  34142. t.nine = 500;
  34143. t.colon = 333;
  34144. t.semicolon = 333;
  34145. t.less = 675;
  34146. t.equal = 675;
  34147. t.greater = 675;
  34148. t.question = 500;
  34149. t.at = 920;
  34150. t.A = 611;
  34151. t.B = 611;
  34152. t.C = 667;
  34153. t.D = 722;
  34154. t.E = 611;
  34155. t.F = 611;
  34156. t.G = 722;
  34157. t.H = 722;
  34158. t.I = 333;
  34159. t.J = 444;
  34160. t.K = 667;
  34161. t.L = 556;
  34162. t.M = 833;
  34163. t.N = 667;
  34164. t.O = 722;
  34165. t.P = 611;
  34166. t.Q = 722;
  34167. t.R = 611;
  34168. t.S = 500;
  34169. t.T = 556;
  34170. t.U = 722;
  34171. t.V = 611;
  34172. t.W = 833;
  34173. t.X = 611;
  34174. t.Y = 556;
  34175. t.Z = 556;
  34176. t.bracketleft = 389;
  34177. t.backslash = 278;
  34178. t.bracketright = 389;
  34179. t.asciicircum = 422;
  34180. t.underscore = 500;
  34181. t.quoteleft = 333;
  34182. t.a = 500;
  34183. t.b = 500;
  34184. t.c = 444;
  34185. t.d = 500;
  34186. t.e = 444;
  34187. t.f = 278;
  34188. t.g = 500;
  34189. t.h = 500;
  34190. t.i = 278;
  34191. t.j = 278;
  34192. t.k = 444;
  34193. t.l = 278;
  34194. t.m = 722;
  34195. t.n = 500;
  34196. t.o = 500;
  34197. t.p = 500;
  34198. t.q = 500;
  34199. t.r = 389;
  34200. t.s = 389;
  34201. t.t = 278;
  34202. t.u = 500;
  34203. t.v = 444;
  34204. t.w = 667;
  34205. t.x = 444;
  34206. t.y = 444;
  34207. t.z = 389;
  34208. t.braceleft = 400;
  34209. t.bar = 275;
  34210. t.braceright = 400;
  34211. t.asciitilde = 541;
  34212. t.exclamdown = 389;
  34213. t.cent = 500;
  34214. t.sterling = 500;
  34215. t.fraction = 167;
  34216. t.yen = 500;
  34217. t.florin = 500;
  34218. t.section = 500;
  34219. t.currency = 500;
  34220. t.quotesingle = 214;
  34221. t.quotedblleft = 556;
  34222. t.guillemotleft = 500;
  34223. t.guilsinglleft = 333;
  34224. t.guilsinglright = 333;
  34225. t.fi = 500;
  34226. t.fl = 500;
  34227. t.endash = 500;
  34228. t.dagger = 500;
  34229. t.daggerdbl = 500;
  34230. t.periodcentered = 250;
  34231. t.paragraph = 523;
  34232. t.bullet = 350;
  34233. t.quotesinglbase = 333;
  34234. t.quotedblbase = 556;
  34235. t.quotedblright = 556;
  34236. t.guillemotright = 500;
  34237. t.ellipsis = 889;
  34238. t.perthousand = 1000;
  34239. t.questiondown = 500;
  34240. t.grave = 333;
  34241. t.acute = 333;
  34242. t.circumflex = 333;
  34243. t.tilde = 333;
  34244. t.macron = 333;
  34245. t.breve = 333;
  34246. t.dotaccent = 333;
  34247. t.dieresis = 333;
  34248. t.ring = 333;
  34249. t.cedilla = 333;
  34250. t.hungarumlaut = 333;
  34251. t.ogonek = 333;
  34252. t.caron = 333;
  34253. t.emdash = 889;
  34254. t.AE = 889;
  34255. t.ordfeminine = 276;
  34256. t.Lslash = 556;
  34257. t.Oslash = 722;
  34258. t.OE = 944;
  34259. t.ordmasculine = 310;
  34260. t.ae = 667;
  34261. t.dotlessi = 278;
  34262. t.lslash = 278;
  34263. t.oslash = 500;
  34264. t.oe = 667;
  34265. t.germandbls = 500;
  34266. t.Idieresis = 333;
  34267. t.eacute = 444;
  34268. t.abreve = 500;
  34269. t.uhungarumlaut = 500;
  34270. t.ecaron = 444;
  34271. t.Ydieresis = 556;
  34272. t.divide = 675;
  34273. t.Yacute = 556;
  34274. t.Acircumflex = 611;
  34275. t.aacute = 500;
  34276. t.Ucircumflex = 722;
  34277. t.yacute = 444;
  34278. t.scommaaccent = 389;
  34279. t.ecircumflex = 444;
  34280. t.Uring = 722;
  34281. t.Udieresis = 722;
  34282. t.aogonek = 500;
  34283. t.Uacute = 722;
  34284. t.uogonek = 500;
  34285. t.Edieresis = 611;
  34286. t.Dcroat = 722;
  34287. t.commaaccent = 250;
  34288. t.copyright = 760;
  34289. t.Emacron = 611;
  34290. t.ccaron = 444;
  34291. t.aring = 500;
  34292. t.Ncommaaccent = 667;
  34293. t.lacute = 278;
  34294. t.agrave = 500;
  34295. t.Tcommaaccent = 556;
  34296. t.Cacute = 667;
  34297. t.atilde = 500;
  34298. t.Edotaccent = 611;
  34299. t.scaron = 389;
  34300. t.scedilla = 389;
  34301. t.iacute = 278;
  34302. t.lozenge = 471;
  34303. t.Rcaron = 611;
  34304. t.Gcommaaccent = 722;
  34305. t.ucircumflex = 500;
  34306. t.acircumflex = 500;
  34307. t.Amacron = 611;
  34308. t.rcaron = 389;
  34309. t.ccedilla = 444;
  34310. t.Zdotaccent = 556;
  34311. t.Thorn = 611;
  34312. t.Omacron = 722;
  34313. t.Racute = 611;
  34314. t.Sacute = 500;
  34315. t.dcaron = 544;
  34316. t.Umacron = 722;
  34317. t.uring = 500;
  34318. t.threesuperior = 300;
  34319. t.Ograve = 722;
  34320. t.Agrave = 611;
  34321. t.Abreve = 611;
  34322. t.multiply = 675;
  34323. t.uacute = 500;
  34324. t.Tcaron = 556;
  34325. t.partialdiff = 476;
  34326. t.ydieresis = 444;
  34327. t.Nacute = 667;
  34328. t.icircumflex = 278;
  34329. t.Ecircumflex = 611;
  34330. t.adieresis = 500;
  34331. t.edieresis = 444;
  34332. t.cacute = 444;
  34333. t.nacute = 500;
  34334. t.umacron = 500;
  34335. t.Ncaron = 667;
  34336. t.Iacute = 333;
  34337. t.plusminus = 675;
  34338. t.brokenbar = 275;
  34339. t.registered = 760;
  34340. t.Gbreve = 722;
  34341. t.Idotaccent = 333;
  34342. t.summation = 600;
  34343. t.Egrave = 611;
  34344. t.racute = 389;
  34345. t.omacron = 500;
  34346. t.Zacute = 556;
  34347. t.Zcaron = 556;
  34348. t.greaterequal = 549;
  34349. t.Eth = 722;
  34350. t.Ccedilla = 667;
  34351. t.lcommaaccent = 278;
  34352. t.tcaron = 300;
  34353. t.eogonek = 444;
  34354. t.Uogonek = 722;
  34355. t.Aacute = 611;
  34356. t.Adieresis = 611;
  34357. t.egrave = 444;
  34358. t.zacute = 389;
  34359. t.iogonek = 278;
  34360. t.Oacute = 722;
  34361. t.oacute = 500;
  34362. t.amacron = 500;
  34363. t.sacute = 389;
  34364. t.idieresis = 278;
  34365. t.Ocircumflex = 722;
  34366. t.Ugrave = 722;
  34367. t.Delta = 612;
  34368. t.thorn = 500;
  34369. t.twosuperior = 300;
  34370. t.Odieresis = 722;
  34371. t.mu = 500;
  34372. t.igrave = 278;
  34373. t.ohungarumlaut = 500;
  34374. t.Eogonek = 611;
  34375. t.dcroat = 500;
  34376. t.threequarters = 750;
  34377. t.Scedilla = 500;
  34378. t.lcaron = 300;
  34379. t.Kcommaaccent = 667;
  34380. t.Lacute = 556;
  34381. t.trademark = 980;
  34382. t.edotaccent = 444;
  34383. t.Igrave = 333;
  34384. t.Imacron = 333;
  34385. t.Lcaron = 611;
  34386. t.onehalf = 750;
  34387. t.lessequal = 549;
  34388. t.ocircumflex = 500;
  34389. t.ntilde = 500;
  34390. t.Uhungarumlaut = 722;
  34391. t.Eacute = 611;
  34392. t.emacron = 444;
  34393. t.gbreve = 500;
  34394. t.onequarter = 750;
  34395. t.Scaron = 500;
  34396. t.Scommaaccent = 500;
  34397. t.Ohungarumlaut = 722;
  34398. t.degree = 400;
  34399. t.ograve = 500;
  34400. t.Ccaron = 667;
  34401. t.ugrave = 500;
  34402. t.radical = 453;
  34403. t.Dcaron = 722;
  34404. t.rcommaaccent = 389;
  34405. t.Ntilde = 667;
  34406. t.otilde = 500;
  34407. t.Rcommaaccent = 611;
  34408. t.Lcommaaccent = 556;
  34409. t.Atilde = 611;
  34410. t.Aogonek = 611;
  34411. t.Aring = 611;
  34412. t.Otilde = 722;
  34413. t.zdotaccent = 389;
  34414. t.Ecaron = 611;
  34415. t.Iogonek = 333;
  34416. t.kcommaaccent = 444;
  34417. t.minus = 675;
  34418. t.Icircumflex = 333;
  34419. t.ncaron = 500;
  34420. t.tcommaaccent = 278;
  34421. t.logicalnot = 675;
  34422. t.odieresis = 500;
  34423. t.udieresis = 500;
  34424. t.notequal = 549;
  34425. t.gcommaaccent = 500;
  34426. t.eth = 500;
  34427. t.zcaron = 389;
  34428. t.ncommaaccent = 500;
  34429. t.onesuperior = 300;
  34430. t.imacron = 278;
  34431. t.Euro = 500;
  34432. });
  34433. t.ZapfDingbats = (0, _core_utils.getLookupTableFactory)(function (t) {
  34434. t.space = 278;
  34435. t.a1 = 974;
  34436. t.a2 = 961;
  34437. t.a202 = 974;
  34438. t.a3 = 980;
  34439. t.a4 = 719;
  34440. t.a5 = 789;
  34441. t.a119 = 790;
  34442. t.a118 = 791;
  34443. t.a117 = 690;
  34444. t.a11 = 960;
  34445. t.a12 = 939;
  34446. t.a13 = 549;
  34447. t.a14 = 855;
  34448. t.a15 = 911;
  34449. t.a16 = 933;
  34450. t.a105 = 911;
  34451. t.a17 = 945;
  34452. t.a18 = 974;
  34453. t.a19 = 755;
  34454. t.a20 = 846;
  34455. t.a21 = 762;
  34456. t.a22 = 761;
  34457. t.a23 = 571;
  34458. t.a24 = 677;
  34459. t.a25 = 763;
  34460. t.a26 = 760;
  34461. t.a27 = 759;
  34462. t.a28 = 754;
  34463. t.a6 = 494;
  34464. t.a7 = 552;
  34465. t.a8 = 537;
  34466. t.a9 = 577;
  34467. t.a10 = 692;
  34468. t.a29 = 786;
  34469. t.a30 = 788;
  34470. t.a31 = 788;
  34471. t.a32 = 790;
  34472. t.a33 = 793;
  34473. t.a34 = 794;
  34474. t.a35 = 816;
  34475. t.a36 = 823;
  34476. t.a37 = 789;
  34477. t.a38 = 841;
  34478. t.a39 = 823;
  34479. t.a40 = 833;
  34480. t.a41 = 816;
  34481. t.a42 = 831;
  34482. t.a43 = 923;
  34483. t.a44 = 744;
  34484. t.a45 = 723;
  34485. t.a46 = 749;
  34486. t.a47 = 790;
  34487. t.a48 = 792;
  34488. t.a49 = 695;
  34489. t.a50 = 776;
  34490. t.a51 = 768;
  34491. t.a52 = 792;
  34492. t.a53 = 759;
  34493. t.a54 = 707;
  34494. t.a55 = 708;
  34495. t.a56 = 682;
  34496. t.a57 = 701;
  34497. t.a58 = 826;
  34498. t.a59 = 815;
  34499. t.a60 = 789;
  34500. t.a61 = 789;
  34501. t.a62 = 707;
  34502. t.a63 = 687;
  34503. t.a64 = 696;
  34504. t.a65 = 689;
  34505. t.a66 = 786;
  34506. t.a67 = 787;
  34507. t.a68 = 713;
  34508. t.a69 = 791;
  34509. t.a70 = 785;
  34510. t.a71 = 791;
  34511. t.a72 = 873;
  34512. t.a73 = 761;
  34513. t.a74 = 762;
  34514. t.a203 = 762;
  34515. t.a75 = 759;
  34516. t.a204 = 759;
  34517. t.a76 = 892;
  34518. t.a77 = 892;
  34519. t.a78 = 788;
  34520. t.a79 = 784;
  34521. t.a81 = 438;
  34522. t.a82 = 138;
  34523. t.a83 = 277;
  34524. t.a84 = 415;
  34525. t.a97 = 392;
  34526. t.a98 = 392;
  34527. t.a99 = 668;
  34528. t.a100 = 668;
  34529. t.a89 = 390;
  34530. t.a90 = 390;
  34531. t.a93 = 317;
  34532. t.a94 = 317;
  34533. t.a91 = 276;
  34534. t.a92 = 276;
  34535. t.a205 = 509;
  34536. t.a85 = 509;
  34537. t.a206 = 410;
  34538. t.a86 = 410;
  34539. t.a87 = 234;
  34540. t.a88 = 234;
  34541. t.a95 = 334;
  34542. t.a96 = 334;
  34543. t.a101 = 732;
  34544. t.a102 = 544;
  34545. t.a103 = 544;
  34546. t.a104 = 910;
  34547. t.a106 = 667;
  34548. t.a107 = 760;
  34549. t.a108 = 760;
  34550. t.a112 = 776;
  34551. t.a111 = 595;
  34552. t.a110 = 694;
  34553. t.a109 = 626;
  34554. t.a120 = 788;
  34555. t.a121 = 788;
  34556. t.a122 = 788;
  34557. t.a123 = 788;
  34558. t.a124 = 788;
  34559. t.a125 = 788;
  34560. t.a126 = 788;
  34561. t.a127 = 788;
  34562. t.a128 = 788;
  34563. t.a129 = 788;
  34564. t.a130 = 788;
  34565. t.a131 = 788;
  34566. t.a132 = 788;
  34567. t.a133 = 788;
  34568. t.a134 = 788;
  34569. t.a135 = 788;
  34570. t.a136 = 788;
  34571. t.a137 = 788;
  34572. t.a138 = 788;
  34573. t.a139 = 788;
  34574. t.a140 = 788;
  34575. t.a141 = 788;
  34576. t.a142 = 788;
  34577. t.a143 = 788;
  34578. t.a144 = 788;
  34579. t.a145 = 788;
  34580. t.a146 = 788;
  34581. t.a147 = 788;
  34582. t.a148 = 788;
  34583. t.a149 = 788;
  34584. t.a150 = 788;
  34585. t.a151 = 788;
  34586. t.a152 = 788;
  34587. t.a153 = 788;
  34588. t.a154 = 788;
  34589. t.a155 = 788;
  34590. t.a156 = 788;
  34591. t.a157 = 788;
  34592. t.a158 = 788;
  34593. t.a159 = 788;
  34594. t.a160 = 894;
  34595. t.a161 = 838;
  34596. t.a163 = 1016;
  34597. t.a164 = 458;
  34598. t.a196 = 748;
  34599. t.a165 = 924;
  34600. t.a192 = 748;
  34601. t.a166 = 918;
  34602. t.a167 = 927;
  34603. t.a168 = 928;
  34604. t.a169 = 928;
  34605. t.a170 = 834;
  34606. t.a171 = 873;
  34607. t.a172 = 828;
  34608. t.a173 = 924;
  34609. t.a162 = 924;
  34610. t.a174 = 917;
  34611. t.a175 = 930;
  34612. t.a176 = 931;
  34613. t.a177 = 463;
  34614. t.a178 = 883;
  34615. t.a179 = 836;
  34616. t.a193 = 836;
  34617. t.a180 = 867;
  34618. t.a199 = 867;
  34619. t.a181 = 696;
  34620. t.a200 = 696;
  34621. t.a182 = 874;
  34622. t.a201 = 874;
  34623. t.a183 = 760;
  34624. t.a184 = 946;
  34625. t.a197 = 771;
  34626. t.a185 = 865;
  34627. t.a194 = 771;
  34628. t.a198 = 888;
  34629. t.a186 = 967;
  34630. t.a195 = 888;
  34631. t.a187 = 831;
  34632. t.a188 = 873;
  34633. t.a189 = 927;
  34634. t.a190 = 970;
  34635. t.a191 = 918;
  34636. });
  34637. });
  34638. exports.getMetrics = getMetrics;
  34639. const getFontBasicMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
  34640. t.Courier = {
  34641. ascent: 629,
  34642. descent: -157,
  34643. capHeight: 562,
  34644. xHeight: -426
  34645. };
  34646. t["Courier-Bold"] = {
  34647. ascent: 629,
  34648. descent: -157,
  34649. capHeight: 562,
  34650. xHeight: 439
  34651. };
  34652. t["Courier-Oblique"] = {
  34653. ascent: 629,
  34654. descent: -157,
  34655. capHeight: 562,
  34656. xHeight: 426
  34657. };
  34658. t["Courier-BoldOblique"] = {
  34659. ascent: 629,
  34660. descent: -157,
  34661. capHeight: 562,
  34662. xHeight: 426
  34663. };
  34664. t.Helvetica = {
  34665. ascent: 718,
  34666. descent: -207,
  34667. capHeight: 718,
  34668. xHeight: 523
  34669. };
  34670. t["Helvetica-Bold"] = {
  34671. ascent: 718,
  34672. descent: -207,
  34673. capHeight: 718,
  34674. xHeight: 532
  34675. };
  34676. t["Helvetica-Oblique"] = {
  34677. ascent: 718,
  34678. descent: -207,
  34679. capHeight: 718,
  34680. xHeight: 523
  34681. };
  34682. t["Helvetica-BoldOblique"] = {
  34683. ascent: 718,
  34684. descent: -207,
  34685. capHeight: 718,
  34686. xHeight: 532
  34687. };
  34688. t["Times-Roman"] = {
  34689. ascent: 683,
  34690. descent: -217,
  34691. capHeight: 662,
  34692. xHeight: 450
  34693. };
  34694. t["Times-Bold"] = {
  34695. ascent: 683,
  34696. descent: -217,
  34697. capHeight: 676,
  34698. xHeight: 461
  34699. };
  34700. t["Times-Italic"] = {
  34701. ascent: 683,
  34702. descent: -217,
  34703. capHeight: 653,
  34704. xHeight: 441
  34705. };
  34706. t["Times-BoldItalic"] = {
  34707. ascent: 683,
  34708. descent: -217,
  34709. capHeight: 669,
  34710. xHeight: 462
  34711. };
  34712. t.Symbol = {
  34713. ascent: Math.NaN,
  34714. descent: Math.NaN,
  34715. capHeight: Math.NaN,
  34716. xHeight: Math.NaN
  34717. };
  34718. t.ZapfDingbats = {
  34719. ascent: Math.NaN,
  34720. descent: Math.NaN,
  34721. capHeight: Math.NaN,
  34722. xHeight: Math.NaN
  34723. };
  34724. });
  34725. exports.getFontBasicMetrics = getFontBasicMetrics;
  34726. /***/ }),
  34727. /* 46 */
  34728. /***/ ((__unused_webpack_module, exports) => {
  34729. Object.defineProperty(exports, "__esModule", ({
  34730. value: true
  34731. }));
  34732. exports.GlyfTable = void 0;
  34733. const ON_CURVE_POINT = 1 << 0;
  34734. const X_SHORT_VECTOR = 1 << 1;
  34735. const Y_SHORT_VECTOR = 1 << 2;
  34736. const REPEAT_FLAG = 1 << 3;
  34737. const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
  34738. const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
  34739. const OVERLAP_SIMPLE = 1 << 6;
  34740. const ARG_1_AND_2_ARE_WORDS = 1 << 0;
  34741. const ARGS_ARE_XY_VALUES = 1 << 1;
  34742. const WE_HAVE_A_SCALE = 1 << 3;
  34743. const MORE_COMPONENTS = 1 << 5;
  34744. const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
  34745. const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
  34746. const WE_HAVE_INSTRUCTIONS = 1 << 8;
  34747. class GlyfTable {
  34748. constructor({
  34749. glyfTable,
  34750. isGlyphLocationsLong,
  34751. locaTable,
  34752. numGlyphs
  34753. }) {
  34754. this.glyphs = [];
  34755. const loca = new DataView(locaTable.buffer, locaTable.byteOffset, locaTable.byteLength);
  34756. const glyf = new DataView(glyfTable.buffer, glyfTable.byteOffset, glyfTable.byteLength);
  34757. const offsetSize = isGlyphLocationsLong ? 4 : 2;
  34758. let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
  34759. let pos = 0;
  34760. for (let i = 0; i < numGlyphs; i++) {
  34761. pos += offsetSize;
  34762. const next = isGlyphLocationsLong ? loca.getUint32(pos) : 2 * loca.getUint16(pos);
  34763. if (next === prev) {
  34764. this.glyphs.push(new Glyph({}));
  34765. continue;
  34766. }
  34767. const glyph = Glyph.parse(prev, glyf);
  34768. this.glyphs.push(glyph);
  34769. prev = next;
  34770. }
  34771. }
  34772. getSize() {
  34773. return this.glyphs.reduce((a, g) => {
  34774. const size = g.getSize();
  34775. return a + (size + 3 & ~3);
  34776. }, 0);
  34777. }
  34778. write() {
  34779. const totalSize = this.getSize();
  34780. const glyfTable = new DataView(new ArrayBuffer(totalSize));
  34781. const isLocationLong = totalSize > 0x1fffe;
  34782. const offsetSize = isLocationLong ? 4 : 2;
  34783. const locaTable = new DataView(new ArrayBuffer((this.glyphs.length + 1) * offsetSize));
  34784. if (isLocationLong) {
  34785. locaTable.setUint32(0, 0);
  34786. } else {
  34787. locaTable.setUint16(0, 0);
  34788. }
  34789. let pos = 0;
  34790. let locaIndex = 0;
  34791. for (const glyph of this.glyphs) {
  34792. pos += glyph.write(pos, glyfTable);
  34793. pos = pos + 3 & ~3;
  34794. locaIndex += offsetSize;
  34795. if (isLocationLong) {
  34796. locaTable.setUint32(locaIndex, pos);
  34797. } else {
  34798. locaTable.setUint16(locaIndex, pos >> 1);
  34799. }
  34800. }
  34801. return {
  34802. isLocationLong,
  34803. loca: new Uint8Array(locaTable.buffer),
  34804. glyf: new Uint8Array(glyfTable.buffer)
  34805. };
  34806. }
  34807. scale(factors) {
  34808. for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
  34809. this.glyphs[i].scale(factors[i]);
  34810. }
  34811. }
  34812. }
  34813. exports.GlyfTable = GlyfTable;
  34814. class Glyph {
  34815. constructor({
  34816. header = null,
  34817. simple = null,
  34818. composites = null
  34819. }) {
  34820. this.header = header;
  34821. this.simple = simple;
  34822. this.composites = composites;
  34823. }
  34824. static parse(pos, glyf) {
  34825. const [read, header] = GlyphHeader.parse(pos, glyf);
  34826. pos += read;
  34827. if (header.numberOfContours < 0) {
  34828. const composites = [];
  34829. while (true) {
  34830. const [n, composite] = CompositeGlyph.parse(pos, glyf);
  34831. pos += n;
  34832. composites.push(composite);
  34833. if (!(composite.flags & MORE_COMPONENTS)) {
  34834. break;
  34835. }
  34836. }
  34837. return new Glyph({
  34838. header,
  34839. composites
  34840. });
  34841. }
  34842. const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
  34843. return new Glyph({
  34844. header,
  34845. simple
  34846. });
  34847. }
  34848. getSize() {
  34849. if (!this.header) {
  34850. return 0;
  34851. }
  34852. const size = this.simple ? this.simple.getSize() : this.composites.reduce((a, c) => a + c.getSize(), 0);
  34853. return this.header.getSize() + size;
  34854. }
  34855. write(pos, buf) {
  34856. if (!this.header) {
  34857. return 0;
  34858. }
  34859. const spos = pos;
  34860. pos += this.header.write(pos, buf);
  34861. if (this.simple) {
  34862. pos += this.simple.write(pos, buf);
  34863. } else {
  34864. for (const composite of this.composites) {
  34865. pos += composite.write(pos, buf);
  34866. }
  34867. }
  34868. return pos - spos;
  34869. }
  34870. scale(factor) {
  34871. if (!this.header) {
  34872. return;
  34873. }
  34874. const xMiddle = (this.header.xMin + this.header.xMax) / 2;
  34875. this.header.scale(xMiddle, factor);
  34876. if (this.simple) {
  34877. this.simple.scale(xMiddle, factor);
  34878. } else {
  34879. for (const composite of this.composites) {
  34880. composite.scale(xMiddle, factor);
  34881. }
  34882. }
  34883. }
  34884. }
  34885. class GlyphHeader {
  34886. constructor({
  34887. numberOfContours,
  34888. xMin,
  34889. yMin,
  34890. xMax,
  34891. yMax
  34892. }) {
  34893. this.numberOfContours = numberOfContours;
  34894. this.xMin = xMin;
  34895. this.yMin = yMin;
  34896. this.xMax = xMax;
  34897. this.yMax = yMax;
  34898. }
  34899. static parse(pos, glyf) {
  34900. return [10, new GlyphHeader({
  34901. numberOfContours: glyf.getInt16(pos),
  34902. xMin: glyf.getInt16(pos + 2),
  34903. yMin: glyf.getInt16(pos + 4),
  34904. xMax: glyf.getInt16(pos + 6),
  34905. yMax: glyf.getInt16(pos + 8)
  34906. })];
  34907. }
  34908. getSize() {
  34909. return 10;
  34910. }
  34911. write(pos, buf) {
  34912. buf.setInt16(pos, this.numberOfContours);
  34913. buf.setInt16(pos + 2, this.xMin);
  34914. buf.setInt16(pos + 4, this.yMin);
  34915. buf.setInt16(pos + 6, this.xMax);
  34916. buf.setInt16(pos + 8, this.yMax);
  34917. return 10;
  34918. }
  34919. scale(x, factor) {
  34920. this.xMin = Math.round(x + (this.xMin - x) * factor);
  34921. this.xMax = Math.round(x + (this.xMax - x) * factor);
  34922. }
  34923. }
  34924. class Contour {
  34925. constructor({
  34926. flags,
  34927. xCoordinates,
  34928. yCoordinates
  34929. }) {
  34930. this.xCoordinates = xCoordinates;
  34931. this.yCoordinates = yCoordinates;
  34932. this.flags = flags;
  34933. }
  34934. }
  34935. class SimpleGlyph {
  34936. constructor({
  34937. contours,
  34938. instructions
  34939. }) {
  34940. this.contours = contours;
  34941. this.instructions = instructions;
  34942. }
  34943. static parse(pos, glyf, numberOfContours) {
  34944. const endPtsOfContours = [];
  34945. for (let i = 0; i < numberOfContours; i++) {
  34946. const endPt = glyf.getUint16(pos);
  34947. pos += 2;
  34948. endPtsOfContours.push(endPt);
  34949. }
  34950. const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
  34951. const instructionLength = glyf.getUint16(pos);
  34952. pos += 2;
  34953. const instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
  34954. pos += instructionLength;
  34955. const flags = [];
  34956. for (let i = 0; i < numberOfPt; pos++, i++) {
  34957. let flag = glyf.getUint8(pos);
  34958. flags.push(flag);
  34959. if (flag & REPEAT_FLAG) {
  34960. const count = glyf.getUint8(++pos);
  34961. flag ^= REPEAT_FLAG;
  34962. for (let m = 0; m < count; m++) {
  34963. flags.push(flag);
  34964. }
  34965. i += count;
  34966. }
  34967. }
  34968. const allXCoordinates = [];
  34969. let xCoordinates = [];
  34970. let yCoordinates = [];
  34971. let pointFlags = [];
  34972. const contours = [];
  34973. let endPtsOfContoursIndex = 0;
  34974. let lastCoordinate = 0;
  34975. for (let i = 0; i < numberOfPt; i++) {
  34976. const flag = flags[i];
  34977. if (flag & X_SHORT_VECTOR) {
  34978. const x = glyf.getUint8(pos++);
  34979. lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
  34980. xCoordinates.push(lastCoordinate);
  34981. } else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
  34982. xCoordinates.push(lastCoordinate);
  34983. } else {
  34984. lastCoordinate += glyf.getInt16(pos);
  34985. pos += 2;
  34986. xCoordinates.push(lastCoordinate);
  34987. }
  34988. if (endPtsOfContours[endPtsOfContoursIndex] === i) {
  34989. endPtsOfContoursIndex++;
  34990. allXCoordinates.push(xCoordinates);
  34991. xCoordinates = [];
  34992. }
  34993. }
  34994. lastCoordinate = 0;
  34995. endPtsOfContoursIndex = 0;
  34996. for (let i = 0; i < numberOfPt; i++) {
  34997. const flag = flags[i];
  34998. if (flag & Y_SHORT_VECTOR) {
  34999. const y = glyf.getUint8(pos++);
  35000. lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
  35001. yCoordinates.push(lastCoordinate);
  35002. } else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
  35003. yCoordinates.push(lastCoordinate);
  35004. } else {
  35005. lastCoordinate += glyf.getInt16(pos);
  35006. pos += 2;
  35007. yCoordinates.push(lastCoordinate);
  35008. }
  35009. pointFlags.push(flag & ON_CURVE_POINT | flag & OVERLAP_SIMPLE);
  35010. if (endPtsOfContours[endPtsOfContoursIndex] === i) {
  35011. xCoordinates = allXCoordinates[endPtsOfContoursIndex];
  35012. endPtsOfContoursIndex++;
  35013. contours.push(new Contour({
  35014. flags: pointFlags,
  35015. xCoordinates,
  35016. yCoordinates
  35017. }));
  35018. yCoordinates = [];
  35019. pointFlags = [];
  35020. }
  35021. }
  35022. return new SimpleGlyph({
  35023. contours,
  35024. instructions
  35025. });
  35026. }
  35027. getSize() {
  35028. let size = this.contours.length * 2 + 2 + this.instructions.length;
  35029. let lastX = 0;
  35030. let lastY = 0;
  35031. for (const contour of this.contours) {
  35032. size += contour.flags.length;
  35033. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  35034. const x = contour.xCoordinates[i];
  35035. const y = contour.yCoordinates[i];
  35036. let abs = Math.abs(x - lastX);
  35037. if (abs > 255) {
  35038. size += 2;
  35039. } else if (abs > 0) {
  35040. size += 1;
  35041. }
  35042. lastX = x;
  35043. abs = Math.abs(y - lastY);
  35044. if (abs > 255) {
  35045. size += 2;
  35046. } else if (abs > 0) {
  35047. size += 1;
  35048. }
  35049. lastY = y;
  35050. }
  35051. }
  35052. return size;
  35053. }
  35054. write(pos, buf) {
  35055. const spos = pos;
  35056. const xCoordinates = [];
  35057. const yCoordinates = [];
  35058. const flags = [];
  35059. let lastX = 0;
  35060. let lastY = 0;
  35061. for (const contour of this.contours) {
  35062. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  35063. let flag = contour.flags[i];
  35064. const x = contour.xCoordinates[i];
  35065. let delta = x - lastX;
  35066. if (delta === 0) {
  35067. flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
  35068. xCoordinates.push(0);
  35069. } else {
  35070. const abs = Math.abs(delta);
  35071. if (abs <= 255) {
  35072. flag |= delta >= 0 ? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR : X_SHORT_VECTOR;
  35073. xCoordinates.push(abs);
  35074. } else {
  35075. xCoordinates.push(delta);
  35076. }
  35077. }
  35078. lastX = x;
  35079. const y = contour.yCoordinates[i];
  35080. delta = y - lastY;
  35081. if (delta === 0) {
  35082. flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
  35083. yCoordinates.push(0);
  35084. } else {
  35085. const abs = Math.abs(delta);
  35086. if (abs <= 255) {
  35087. flag |= delta >= 0 ? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR : Y_SHORT_VECTOR;
  35088. yCoordinates.push(abs);
  35089. } else {
  35090. yCoordinates.push(delta);
  35091. }
  35092. }
  35093. lastY = y;
  35094. flags.push(flag);
  35095. }
  35096. buf.setUint16(pos, xCoordinates.length - 1);
  35097. pos += 2;
  35098. }
  35099. buf.setUint16(pos, this.instructions.length);
  35100. pos += 2;
  35101. if (this.instructions.length) {
  35102. new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
  35103. pos += this.instructions.length;
  35104. }
  35105. for (const flag of flags) {
  35106. buf.setUint8(pos++, flag);
  35107. }
  35108. for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
  35109. const x = xCoordinates[i];
  35110. const flag = flags[i];
  35111. if (flag & X_SHORT_VECTOR) {
  35112. buf.setUint8(pos++, x);
  35113. } else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
  35114. buf.setInt16(pos, x);
  35115. pos += 2;
  35116. }
  35117. }
  35118. for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
  35119. const y = yCoordinates[i];
  35120. const flag = flags[i];
  35121. if (flag & Y_SHORT_VECTOR) {
  35122. buf.setUint8(pos++, y);
  35123. } else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
  35124. buf.setInt16(pos, y);
  35125. pos += 2;
  35126. }
  35127. }
  35128. return pos - spos;
  35129. }
  35130. scale(x, factor) {
  35131. for (const contour of this.contours) {
  35132. if (contour.xCoordinates.length === 0) {
  35133. continue;
  35134. }
  35135. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  35136. contour.xCoordinates[i] = Math.round(x + (contour.xCoordinates[i] - x) * factor);
  35137. }
  35138. }
  35139. }
  35140. }
  35141. class CompositeGlyph {
  35142. constructor({
  35143. flags,
  35144. glyphIndex,
  35145. argument1,
  35146. argument2,
  35147. transf,
  35148. instructions
  35149. }) {
  35150. this.flags = flags;
  35151. this.glyphIndex = glyphIndex;
  35152. this.argument1 = argument1;
  35153. this.argument2 = argument2;
  35154. this.transf = transf;
  35155. this.instructions = instructions;
  35156. }
  35157. static parse(pos, glyf) {
  35158. const spos = pos;
  35159. const transf = [];
  35160. let flags = glyf.getUint16(pos);
  35161. const glyphIndex = glyf.getUint16(pos + 2);
  35162. pos += 4;
  35163. let argument1, argument2;
  35164. if (flags & ARG_1_AND_2_ARE_WORDS) {
  35165. if (flags & ARGS_ARE_XY_VALUES) {
  35166. argument1 = glyf.getInt16(pos);
  35167. argument2 = glyf.getInt16(pos + 2);
  35168. } else {
  35169. argument1 = glyf.getUint16(pos);
  35170. argument2 = glyf.getUint16(pos + 2);
  35171. }
  35172. pos += 4;
  35173. flags ^= ARG_1_AND_2_ARE_WORDS;
  35174. } else {
  35175. if (flags & ARGS_ARE_XY_VALUES) {
  35176. argument1 = glyf.getInt8(pos);
  35177. argument2 = glyf.getInt8(pos + 1);
  35178. } else {
  35179. argument1 = glyf.getUint8(pos);
  35180. argument2 = glyf.getUint8(pos + 1);
  35181. }
  35182. pos += 2;
  35183. }
  35184. if (flags & WE_HAVE_A_SCALE) {
  35185. transf.push(glyf.getUint16(pos));
  35186. pos += 2;
  35187. } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
  35188. transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
  35189. pos += 4;
  35190. } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
  35191. transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2), glyf.getUint16(pos + 4), glyf.getUint16(pos + 6));
  35192. pos += 8;
  35193. }
  35194. let instructions = null;
  35195. if (flags & WE_HAVE_INSTRUCTIONS) {
  35196. const instructionLength = glyf.getUint16(pos);
  35197. pos += 2;
  35198. instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
  35199. pos += instructionLength;
  35200. }
  35201. return [pos - spos, new CompositeGlyph({
  35202. flags,
  35203. glyphIndex,
  35204. argument1,
  35205. argument2,
  35206. transf,
  35207. instructions
  35208. })];
  35209. }
  35210. getSize() {
  35211. let size = 2 + 2 + this.transf.length * 2;
  35212. if (this.flags & WE_HAVE_INSTRUCTIONS) {
  35213. size += 2 + this.instructions.length;
  35214. }
  35215. size += 2;
  35216. if (this.flags & 2) {
  35217. if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
  35218. size += 2;
  35219. }
  35220. } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
  35221. size += 2;
  35222. }
  35223. return size;
  35224. }
  35225. write(pos, buf) {
  35226. const spos = pos;
  35227. if (this.flags & ARGS_ARE_XY_VALUES) {
  35228. if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
  35229. this.flags |= ARG_1_AND_2_ARE_WORDS;
  35230. }
  35231. } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
  35232. this.flags |= ARG_1_AND_2_ARE_WORDS;
  35233. }
  35234. buf.setUint16(pos, this.flags);
  35235. buf.setUint16(pos + 2, this.glyphIndex);
  35236. pos += 4;
  35237. if (this.flags & ARG_1_AND_2_ARE_WORDS) {
  35238. if (this.flags & ARGS_ARE_XY_VALUES) {
  35239. buf.setInt16(pos, this.argument1);
  35240. buf.setInt16(pos + 2, this.argument2);
  35241. } else {
  35242. buf.setUint16(pos, this.argument1);
  35243. buf.setUint16(pos + 2, this.argument2);
  35244. }
  35245. pos += 4;
  35246. } else {
  35247. buf.setUint8(pos, this.argument1);
  35248. buf.setUint8(pos + 1, this.argument2);
  35249. pos += 2;
  35250. }
  35251. if (this.flags & WE_HAVE_INSTRUCTIONS) {
  35252. buf.setUint16(pos, this.instructions.length);
  35253. pos += 2;
  35254. if (this.instructions.length) {
  35255. new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
  35256. pos += this.instructions.length;
  35257. }
  35258. }
  35259. return pos - spos;
  35260. }
  35261. scale(x, factor) {}
  35262. }
  35263. /***/ }),
  35264. /* 47 */
  35265. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  35266. Object.defineProperty(exports, "__esModule", ({
  35267. value: true
  35268. }));
  35269. exports.OpenTypeFileBuilder = void 0;
  35270. var _core_utils = __w_pdfjs_require__(3);
  35271. var _util = __w_pdfjs_require__(2);
  35272. function writeInt16(dest, offset, num) {
  35273. dest[offset] = num >> 8 & 0xff;
  35274. dest[offset + 1] = num & 0xff;
  35275. }
  35276. function writeInt32(dest, offset, num) {
  35277. dest[offset] = num >> 24 & 0xff;
  35278. dest[offset + 1] = num >> 16 & 0xff;
  35279. dest[offset + 2] = num >> 8 & 0xff;
  35280. dest[offset + 3] = num & 0xff;
  35281. }
  35282. function writeData(dest, offset, data) {
  35283. if (data instanceof Uint8Array) {
  35284. dest.set(data, offset);
  35285. } else if (typeof data === "string") {
  35286. for (let i = 0, ii = data.length; i < ii; i++) {
  35287. dest[offset++] = data.charCodeAt(i) & 0xff;
  35288. }
  35289. } else {
  35290. for (const num of data) {
  35291. dest[offset++] = num & 0xff;
  35292. }
  35293. }
  35294. }
  35295. const OTF_HEADER_SIZE = 12;
  35296. const OTF_TABLE_ENTRY_SIZE = 16;
  35297. class OpenTypeFileBuilder {
  35298. constructor(sfnt) {
  35299. this.sfnt = sfnt;
  35300. this.tables = Object.create(null);
  35301. }
  35302. static getSearchParams(entriesCount, entrySize) {
  35303. let maxPower2 = 1,
  35304. log2 = 0;
  35305. while ((maxPower2 ^ entriesCount) > maxPower2) {
  35306. maxPower2 <<= 1;
  35307. log2++;
  35308. }
  35309. const searchRange = maxPower2 * entrySize;
  35310. return {
  35311. range: searchRange,
  35312. entry: log2,
  35313. rangeShift: entrySize * entriesCount - searchRange
  35314. };
  35315. }
  35316. toArray() {
  35317. let sfnt = this.sfnt;
  35318. const tables = this.tables;
  35319. const tablesNames = Object.keys(tables);
  35320. tablesNames.sort();
  35321. const numTables = tablesNames.length;
  35322. let i, j, jj, table, tableName;
  35323. let offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  35324. const tableOffsets = [offset];
  35325. for (i = 0; i < numTables; i++) {
  35326. table = tables[tablesNames[i]];
  35327. const paddedLength = (table.length + 3 & ~3) >>> 0;
  35328. offset += paddedLength;
  35329. tableOffsets.push(offset);
  35330. }
  35331. const file = new Uint8Array(offset);
  35332. for (i = 0; i < numTables; i++) {
  35333. table = tables[tablesNames[i]];
  35334. writeData(file, tableOffsets[i], table);
  35335. }
  35336. if (sfnt === "true") {
  35337. sfnt = (0, _util.string32)(0x00010000);
  35338. }
  35339. file[0] = sfnt.charCodeAt(0) & 0xff;
  35340. file[1] = sfnt.charCodeAt(1) & 0xff;
  35341. file[2] = sfnt.charCodeAt(2) & 0xff;
  35342. file[3] = sfnt.charCodeAt(3) & 0xff;
  35343. writeInt16(file, 4, numTables);
  35344. const searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  35345. writeInt16(file, 6, searchParams.range);
  35346. writeInt16(file, 8, searchParams.entry);
  35347. writeInt16(file, 10, searchParams.rangeShift);
  35348. offset = OTF_HEADER_SIZE;
  35349. for (i = 0; i < numTables; i++) {
  35350. tableName = tablesNames[i];
  35351. file[offset] = tableName.charCodeAt(0) & 0xff;
  35352. file[offset + 1] = tableName.charCodeAt(1) & 0xff;
  35353. file[offset + 2] = tableName.charCodeAt(2) & 0xff;
  35354. file[offset + 3] = tableName.charCodeAt(3) & 0xff;
  35355. let checksum = 0;
  35356. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  35357. const quad = (0, _core_utils.readUint32)(file, j);
  35358. checksum = checksum + quad >>> 0;
  35359. }
  35360. writeInt32(file, offset + 4, checksum);
  35361. writeInt32(file, offset + 8, tableOffsets[i]);
  35362. writeInt32(file, offset + 12, tables[tableName].length);
  35363. offset += OTF_TABLE_ENTRY_SIZE;
  35364. }
  35365. return file;
  35366. }
  35367. addTable(tag, data) {
  35368. if (tag in this.tables) {
  35369. throw new Error("Table " + tag + " already exists");
  35370. }
  35371. this.tables[tag] = data;
  35372. }
  35373. }
  35374. exports.OpenTypeFileBuilder = OpenTypeFileBuilder;
  35375. /***/ }),
  35376. /* 48 */
  35377. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  35378. Object.defineProperty(exports, "__esModule", ({
  35379. value: true
  35380. }));
  35381. exports.Type1Font = void 0;
  35382. var _cff_parser = __w_pdfjs_require__(35);
  35383. var _util = __w_pdfjs_require__(2);
  35384. var _fonts_utils = __w_pdfjs_require__(38);
  35385. var _core_utils = __w_pdfjs_require__(3);
  35386. var _stream = __w_pdfjs_require__(8);
  35387. var _type1_parser = __w_pdfjs_require__(49);
  35388. function findBlock(streamBytes, signature, startIndex) {
  35389. const streamBytesLength = streamBytes.length;
  35390. const signatureLength = signature.length;
  35391. const scanLength = streamBytesLength - signatureLength;
  35392. let i = startIndex,
  35393. found = false;
  35394. while (i < scanLength) {
  35395. let j = 0;
  35396. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  35397. j++;
  35398. }
  35399. if (j >= signatureLength) {
  35400. i += j;
  35401. while (i < streamBytesLength && (0, _core_utils.isWhiteSpace)(streamBytes[i])) {
  35402. i++;
  35403. }
  35404. found = true;
  35405. break;
  35406. }
  35407. i++;
  35408. }
  35409. return {
  35410. found,
  35411. length: i
  35412. };
  35413. }
  35414. function getHeaderBlock(stream, suggestedLength) {
  35415. const EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
  35416. const streamStartPos = stream.pos;
  35417. let headerBytes, headerBytesLength, block;
  35418. try {
  35419. headerBytes = stream.getBytes(suggestedLength);
  35420. headerBytesLength = headerBytes.length;
  35421. } catch {}
  35422. if (headerBytesLength === suggestedLength) {
  35423. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  35424. if (block.found && block.length === suggestedLength) {
  35425. return {
  35426. stream: new _stream.Stream(headerBytes),
  35427. length: suggestedLength
  35428. };
  35429. }
  35430. }
  35431. (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
  35432. stream.pos = streamStartPos;
  35433. const SCAN_BLOCK_LENGTH = 2048;
  35434. let actualLength;
  35435. while (true) {
  35436. const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  35437. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  35438. if (block.length === 0) {
  35439. break;
  35440. }
  35441. stream.pos += block.length;
  35442. if (block.found) {
  35443. actualLength = stream.pos - streamStartPos;
  35444. break;
  35445. }
  35446. }
  35447. stream.pos = streamStartPos;
  35448. if (actualLength) {
  35449. return {
  35450. stream: new _stream.Stream(stream.getBytes(actualLength)),
  35451. length: actualLength
  35452. };
  35453. }
  35454. (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
  35455. return {
  35456. stream: new _stream.Stream(stream.getBytes(suggestedLength)),
  35457. length: suggestedLength
  35458. };
  35459. }
  35460. function getEexecBlock(stream, suggestedLength) {
  35461. const eexecBytes = stream.getBytes();
  35462. if (eexecBytes.length === 0) {
  35463. throw new _util.FormatError("getEexecBlock - no font program found.");
  35464. }
  35465. return {
  35466. stream: new _stream.Stream(eexecBytes),
  35467. length: eexecBytes.length
  35468. };
  35469. }
  35470. class Type1Font {
  35471. constructor(name, file, properties) {
  35472. const PFB_HEADER_SIZE = 6;
  35473. let headerBlockLength = properties.length1;
  35474. let eexecBlockLength = properties.length2;
  35475. let pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  35476. const pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  35477. if (pfbHeaderPresent) {
  35478. file.skip(PFB_HEADER_SIZE);
  35479. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  35480. }
  35481. const headerBlock = getHeaderBlock(file, headerBlockLength);
  35482. const headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  35483. headerBlockParser.extractFontHeader(properties);
  35484. if (pfbHeaderPresent) {
  35485. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  35486. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  35487. }
  35488. const eexecBlock = getEexecBlock(file, eexecBlockLength);
  35489. const eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  35490. const data = eexecBlockParser.extractFontProgram(properties);
  35491. for (const key in data.properties) {
  35492. properties[key] = data.properties[key];
  35493. }
  35494. const charstrings = data.charstrings;
  35495. const type2Charstrings = this.getType2Charstrings(charstrings);
  35496. const subrs = this.getType2Subrs(data.subrs);
  35497. this.charstrings = charstrings;
  35498. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  35499. this.seacs = this.getSeacs(data.charstrings);
  35500. }
  35501. get numGlyphs() {
  35502. return this.charstrings.length + 1;
  35503. }
  35504. getCharset() {
  35505. const charset = [".notdef"];
  35506. for (const {
  35507. glyphName
  35508. } of this.charstrings) {
  35509. charset.push(glyphName);
  35510. }
  35511. return charset;
  35512. }
  35513. getGlyphMapping(properties) {
  35514. const charstrings = this.charstrings;
  35515. if (properties.composite) {
  35516. const charCodeToGlyphId = Object.create(null);
  35517. for (let glyphId = 0, charstringsLen = charstrings.length; glyphId < charstringsLen; glyphId++) {
  35518. const charCode = properties.cMap.charCodeOf(glyphId);
  35519. charCodeToGlyphId[charCode] = glyphId + 1;
  35520. }
  35521. return charCodeToGlyphId;
  35522. }
  35523. const glyphNames = [".notdef"];
  35524. let builtInEncoding, glyphId;
  35525. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  35526. glyphNames.push(charstrings[glyphId].glyphName);
  35527. }
  35528. const encoding = properties.builtInEncoding;
  35529. if (encoding) {
  35530. builtInEncoding = Object.create(null);
  35531. for (const charCode in encoding) {
  35532. glyphId = glyphNames.indexOf(encoding[charCode]);
  35533. if (glyphId >= 0) {
  35534. builtInEncoding[charCode] = glyphId;
  35535. }
  35536. }
  35537. }
  35538. return (0, _fonts_utils.type1FontGlyphMapping)(properties, builtInEncoding, glyphNames);
  35539. }
  35540. hasGlyphId(id) {
  35541. if (id < 0 || id >= this.numGlyphs) {
  35542. return false;
  35543. }
  35544. if (id === 0) {
  35545. return true;
  35546. }
  35547. const glyph = this.charstrings[id - 1];
  35548. return glyph.charstring.length > 0;
  35549. }
  35550. getSeacs(charstrings) {
  35551. const seacMap = [];
  35552. for (let i = 0, ii = charstrings.length; i < ii; i++) {
  35553. const charstring = charstrings[i];
  35554. if (charstring.seac) {
  35555. seacMap[i + 1] = charstring.seac;
  35556. }
  35557. }
  35558. return seacMap;
  35559. }
  35560. getType2Charstrings(type1Charstrings) {
  35561. const type2Charstrings = [];
  35562. for (const type1Charstring of type1Charstrings) {
  35563. type2Charstrings.push(type1Charstring.charstring);
  35564. }
  35565. return type2Charstrings;
  35566. }
  35567. getType2Subrs(type1Subrs) {
  35568. let bias = 0;
  35569. const count = type1Subrs.length;
  35570. if (count < 1133) {
  35571. bias = 107;
  35572. } else if (count < 33769) {
  35573. bias = 1131;
  35574. } else {
  35575. bias = 32768;
  35576. }
  35577. const type2Subrs = [];
  35578. let i;
  35579. for (i = 0; i < bias; i++) {
  35580. type2Subrs.push([0x0b]);
  35581. }
  35582. for (i = 0; i < count; i++) {
  35583. type2Subrs.push(type1Subrs[i]);
  35584. }
  35585. return type2Subrs;
  35586. }
  35587. wrap(name, glyphs, charstrings, subrs, properties) {
  35588. const cff = new _cff_parser.CFF();
  35589. cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
  35590. cff.names = [name];
  35591. const topDict = new _cff_parser.CFFTopDict();
  35592. topDict.setByName("version", 391);
  35593. topDict.setByName("Notice", 392);
  35594. topDict.setByName("FullName", 393);
  35595. topDict.setByName("FamilyName", 394);
  35596. topDict.setByName("Weight", 395);
  35597. topDict.setByName("Encoding", null);
  35598. topDict.setByName("FontMatrix", properties.fontMatrix);
  35599. topDict.setByName("FontBBox", properties.bbox);
  35600. topDict.setByName("charset", null);
  35601. topDict.setByName("CharStrings", null);
  35602. topDict.setByName("Private", null);
  35603. cff.topDict = topDict;
  35604. const strings = new _cff_parser.CFFStrings();
  35605. strings.add("Version 0.11");
  35606. strings.add("See original notice");
  35607. strings.add(name);
  35608. strings.add(name);
  35609. strings.add("Medium");
  35610. cff.strings = strings;
  35611. cff.globalSubrIndex = new _cff_parser.CFFIndex();
  35612. const count = glyphs.length;
  35613. const charsetArray = [".notdef"];
  35614. let i, ii;
  35615. for (i = 0; i < count; i++) {
  35616. const glyphName = charstrings[i].glyphName;
  35617. const index = _cff_parser.CFFStandardStrings.indexOf(glyphName);
  35618. if (index === -1) {
  35619. strings.add(glyphName);
  35620. }
  35621. charsetArray.push(glyphName);
  35622. }
  35623. cff.charset = new _cff_parser.CFFCharset(false, 0, charsetArray);
  35624. const charStringsIndex = new _cff_parser.CFFIndex();
  35625. charStringsIndex.add([0x8b, 0x0e]);
  35626. for (i = 0; i < count; i++) {
  35627. charStringsIndex.add(glyphs[i]);
  35628. }
  35629. cff.charStrings = charStringsIndex;
  35630. const privateDict = new _cff_parser.CFFPrivateDict();
  35631. privateDict.setByName("Subrs", null);
  35632. const fields = ["BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StemSnapH", "StemSnapV", "BlueShift", "BlueFuzz", "BlueScale", "LanguageGroup", "ExpansionFactor", "ForceBold", "StdHW", "StdVW"];
  35633. for (i = 0, ii = fields.length; i < ii; i++) {
  35634. const field = fields[i];
  35635. if (!(field in properties.privateData)) {
  35636. continue;
  35637. }
  35638. const value = properties.privateData[field];
  35639. if (Array.isArray(value)) {
  35640. for (let j = value.length - 1; j > 0; j--) {
  35641. value[j] -= value[j - 1];
  35642. }
  35643. }
  35644. privateDict.setByName(field, value);
  35645. }
  35646. cff.topDict.privateDict = privateDict;
  35647. const subrIndex = new _cff_parser.CFFIndex();
  35648. for (i = 0, ii = subrs.length; i < ii; i++) {
  35649. subrIndex.add(subrs[i]);
  35650. }
  35651. privateDict.subrsIndex = subrIndex;
  35652. const compiler = new _cff_parser.CFFCompiler(cff);
  35653. return compiler.compile();
  35654. }
  35655. }
  35656. exports.Type1Font = Type1Font;
  35657. /***/ }),
  35658. /* 49 */
  35659. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  35660. Object.defineProperty(exports, "__esModule", ({
  35661. value: true
  35662. }));
  35663. exports.Type1Parser = void 0;
  35664. var _encodings = __w_pdfjs_require__(37);
  35665. var _core_utils = __w_pdfjs_require__(3);
  35666. var _stream = __w_pdfjs_require__(8);
  35667. var _util = __w_pdfjs_require__(2);
  35668. const HINTING_ENABLED = false;
  35669. const COMMAND_MAP = {
  35670. hstem: [1],
  35671. vstem: [3],
  35672. vmoveto: [4],
  35673. rlineto: [5],
  35674. hlineto: [6],
  35675. vlineto: [7],
  35676. rrcurveto: [8],
  35677. callsubr: [10],
  35678. flex: [12, 35],
  35679. drop: [12, 18],
  35680. endchar: [14],
  35681. rmoveto: [21],
  35682. hmoveto: [22],
  35683. vhcurveto: [30],
  35684. hvcurveto: [31]
  35685. };
  35686. class Type1CharString {
  35687. constructor() {
  35688. this.width = 0;
  35689. this.lsb = 0;
  35690. this.flexing = false;
  35691. this.output = [];
  35692. this.stack = [];
  35693. }
  35694. convert(encoded, subrs, seacAnalysisEnabled) {
  35695. const count = encoded.length;
  35696. let error = false;
  35697. let wx, sbx, subrNumber;
  35698. for (let i = 0; i < count; i++) {
  35699. let value = encoded[i];
  35700. if (value < 32) {
  35701. if (value === 12) {
  35702. value = (value << 8) + encoded[++i];
  35703. }
  35704. switch (value) {
  35705. case 1:
  35706. if (!HINTING_ENABLED) {
  35707. this.stack = [];
  35708. break;
  35709. }
  35710. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35711. break;
  35712. case 3:
  35713. if (!HINTING_ENABLED) {
  35714. this.stack = [];
  35715. break;
  35716. }
  35717. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35718. break;
  35719. case 4:
  35720. if (this.flexing) {
  35721. if (this.stack.length < 1) {
  35722. error = true;
  35723. break;
  35724. }
  35725. const dy = this.stack.pop();
  35726. this.stack.push(0, dy);
  35727. break;
  35728. }
  35729. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  35730. break;
  35731. case 5:
  35732. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  35733. break;
  35734. case 6:
  35735. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  35736. break;
  35737. case 7:
  35738. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  35739. break;
  35740. case 8:
  35741. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  35742. break;
  35743. case 9:
  35744. this.stack = [];
  35745. break;
  35746. case 10:
  35747. if (this.stack.length < 1) {
  35748. error = true;
  35749. break;
  35750. }
  35751. subrNumber = this.stack.pop();
  35752. if (!subrs[subrNumber]) {
  35753. error = true;
  35754. break;
  35755. }
  35756. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  35757. break;
  35758. case 11:
  35759. return error;
  35760. case 13:
  35761. if (this.stack.length < 2) {
  35762. error = true;
  35763. break;
  35764. }
  35765. wx = this.stack.pop();
  35766. sbx = this.stack.pop();
  35767. this.lsb = sbx;
  35768. this.width = wx;
  35769. this.stack.push(wx, sbx);
  35770. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  35771. break;
  35772. case 14:
  35773. this.output.push(COMMAND_MAP.endchar[0]);
  35774. break;
  35775. case 21:
  35776. if (this.flexing) {
  35777. break;
  35778. }
  35779. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  35780. break;
  35781. case 22:
  35782. if (this.flexing) {
  35783. this.stack.push(0);
  35784. break;
  35785. }
  35786. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  35787. break;
  35788. case 30:
  35789. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  35790. break;
  35791. case 31:
  35792. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  35793. break;
  35794. case (12 << 8) + 0:
  35795. this.stack = [];
  35796. break;
  35797. case (12 << 8) + 1:
  35798. if (!HINTING_ENABLED) {
  35799. this.stack = [];
  35800. break;
  35801. }
  35802. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35803. break;
  35804. case (12 << 8) + 2:
  35805. if (!HINTING_ENABLED) {
  35806. this.stack = [];
  35807. break;
  35808. }
  35809. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35810. break;
  35811. case (12 << 8) + 6:
  35812. if (seacAnalysisEnabled) {
  35813. const asb = this.stack.at(-5);
  35814. this.seac = this.stack.splice(-4, 4);
  35815. this.seac[0] += this.lsb - asb;
  35816. error = this.executeCommand(0, COMMAND_MAP.endchar);
  35817. } else {
  35818. error = this.executeCommand(4, COMMAND_MAP.endchar);
  35819. }
  35820. break;
  35821. case (12 << 8) + 7:
  35822. if (this.stack.length < 4) {
  35823. error = true;
  35824. break;
  35825. }
  35826. this.stack.pop();
  35827. wx = this.stack.pop();
  35828. const sby = this.stack.pop();
  35829. sbx = this.stack.pop();
  35830. this.lsb = sbx;
  35831. this.width = wx;
  35832. this.stack.push(wx, sbx, sby);
  35833. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  35834. break;
  35835. case (12 << 8) + 12:
  35836. if (this.stack.length < 2) {
  35837. error = true;
  35838. break;
  35839. }
  35840. const num2 = this.stack.pop();
  35841. const num1 = this.stack.pop();
  35842. this.stack.push(num1 / num2);
  35843. break;
  35844. case (12 << 8) + 16:
  35845. if (this.stack.length < 2) {
  35846. error = true;
  35847. break;
  35848. }
  35849. subrNumber = this.stack.pop();
  35850. const numArgs = this.stack.pop();
  35851. if (subrNumber === 0 && numArgs === 3) {
  35852. const flexArgs = this.stack.splice(-17, 17);
  35853. this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
  35854. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  35855. this.flexing = false;
  35856. this.stack.push(flexArgs[15], flexArgs[16]);
  35857. } else if (subrNumber === 1 && numArgs === 0) {
  35858. this.flexing = true;
  35859. }
  35860. break;
  35861. case (12 << 8) + 17:
  35862. break;
  35863. case (12 << 8) + 33:
  35864. this.stack = [];
  35865. break;
  35866. default:
  35867. (0, _util.warn)('Unknown type 1 charstring command of "' + value + '"');
  35868. break;
  35869. }
  35870. if (error) {
  35871. break;
  35872. }
  35873. continue;
  35874. } else if (value <= 246) {
  35875. value -= 139;
  35876. } else if (value <= 250) {
  35877. value = (value - 247) * 256 + encoded[++i] + 108;
  35878. } else if (value <= 254) {
  35879. value = -((value - 251) * 256) - encoded[++i] - 108;
  35880. } else {
  35881. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  35882. }
  35883. this.stack.push(value);
  35884. }
  35885. return error;
  35886. }
  35887. executeCommand(howManyArgs, command, keepStack) {
  35888. const stackLength = this.stack.length;
  35889. if (howManyArgs > stackLength) {
  35890. return true;
  35891. }
  35892. const start = stackLength - howManyArgs;
  35893. for (let i = start; i < stackLength; i++) {
  35894. let value = this.stack[i];
  35895. if (Number.isInteger(value)) {
  35896. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  35897. } else {
  35898. value = 65536 * value | 0;
  35899. this.output.push(255, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  35900. }
  35901. }
  35902. this.output.push(...command);
  35903. if (keepStack) {
  35904. this.stack.splice(start, howManyArgs);
  35905. } else {
  35906. this.stack.length = 0;
  35907. }
  35908. return false;
  35909. }
  35910. }
  35911. const EEXEC_ENCRYPT_KEY = 55665;
  35912. const CHAR_STRS_ENCRYPT_KEY = 4330;
  35913. function isHexDigit(code) {
  35914. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  35915. }
  35916. function decrypt(data, key, discardNumber) {
  35917. if (discardNumber >= data.length) {
  35918. return new Uint8Array(0);
  35919. }
  35920. const c1 = 52845,
  35921. c2 = 22719;
  35922. let r = key | 0,
  35923. i,
  35924. j;
  35925. for (i = 0; i < discardNumber; i++) {
  35926. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  35927. }
  35928. const count = data.length - discardNumber;
  35929. const decrypted = new Uint8Array(count);
  35930. for (i = discardNumber, j = 0; j < count; i++, j++) {
  35931. const value = data[i];
  35932. decrypted[j] = value ^ r >> 8;
  35933. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35934. }
  35935. return decrypted;
  35936. }
  35937. function decryptAscii(data, key, discardNumber) {
  35938. const c1 = 52845,
  35939. c2 = 22719;
  35940. let r = key | 0;
  35941. const count = data.length,
  35942. maybeLength = count >>> 1;
  35943. const decrypted = new Uint8Array(maybeLength);
  35944. let i, j;
  35945. for (i = 0, j = 0; i < count; i++) {
  35946. const digit1 = data[i];
  35947. if (!isHexDigit(digit1)) {
  35948. continue;
  35949. }
  35950. i++;
  35951. let digit2;
  35952. while (i < count && !isHexDigit(digit2 = data[i])) {
  35953. i++;
  35954. }
  35955. if (i < count) {
  35956. const value = parseInt(String.fromCharCode(digit1, digit2), 16);
  35957. decrypted[j++] = value ^ r >> 8;
  35958. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35959. }
  35960. }
  35961. return decrypted.slice(discardNumber, j);
  35962. }
  35963. function isSpecial(c) {
  35964. return c === 0x2f || c === 0x5b || c === 0x5d || c === 0x7b || c === 0x7d || c === 0x28 || c === 0x29;
  35965. }
  35966. class Type1Parser {
  35967. constructor(stream, encrypted, seacAnalysisEnabled) {
  35968. if (encrypted) {
  35969. const data = stream.getBytes();
  35970. const isBinary = !((isHexDigit(data[0]) || (0, _core_utils.isWhiteSpace)(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
  35971. stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  35972. }
  35973. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  35974. this.stream = stream;
  35975. this.nextChar();
  35976. }
  35977. readNumberArray() {
  35978. this.getToken();
  35979. const array = [];
  35980. while (true) {
  35981. const token = this.getToken();
  35982. if (token === null || token === "]" || token === "}") {
  35983. break;
  35984. }
  35985. array.push(parseFloat(token || 0));
  35986. }
  35987. return array;
  35988. }
  35989. readNumber() {
  35990. const token = this.getToken();
  35991. return parseFloat(token || 0);
  35992. }
  35993. readInt() {
  35994. const token = this.getToken();
  35995. return parseInt(token || 0, 10) | 0;
  35996. }
  35997. readBoolean() {
  35998. const token = this.getToken();
  35999. return token === "true" ? 1 : 0;
  36000. }
  36001. nextChar() {
  36002. return this.currentChar = this.stream.getByte();
  36003. }
  36004. prevChar() {
  36005. this.stream.skip(-2);
  36006. return this.currentChar = this.stream.getByte();
  36007. }
  36008. getToken() {
  36009. let comment = false;
  36010. let ch = this.currentChar;
  36011. while (true) {
  36012. if (ch === -1) {
  36013. return null;
  36014. }
  36015. if (comment) {
  36016. if (ch === 0x0a || ch === 0x0d) {
  36017. comment = false;
  36018. }
  36019. } else if (ch === 0x25) {
  36020. comment = true;
  36021. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  36022. break;
  36023. }
  36024. ch = this.nextChar();
  36025. }
  36026. if (isSpecial(ch)) {
  36027. this.nextChar();
  36028. return String.fromCharCode(ch);
  36029. }
  36030. let token = "";
  36031. do {
  36032. token += String.fromCharCode(ch);
  36033. ch = this.nextChar();
  36034. } while (ch >= 0 && !(0, _core_utils.isWhiteSpace)(ch) && !isSpecial(ch));
  36035. return token;
  36036. }
  36037. readCharStrings(bytes, lenIV) {
  36038. if (lenIV === -1) {
  36039. return bytes;
  36040. }
  36041. return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
  36042. }
  36043. extractFontProgram(properties) {
  36044. const stream = this.stream;
  36045. const subrs = [],
  36046. charstrings = [];
  36047. const privateData = Object.create(null);
  36048. privateData.lenIV = 4;
  36049. const program = {
  36050. subrs: [],
  36051. charstrings: [],
  36052. properties: {
  36053. privateData
  36054. }
  36055. };
  36056. let token, length, data, lenIV;
  36057. while ((token = this.getToken()) !== null) {
  36058. if (token !== "/") {
  36059. continue;
  36060. }
  36061. token = this.getToken();
  36062. switch (token) {
  36063. case "CharStrings":
  36064. this.getToken();
  36065. this.getToken();
  36066. this.getToken();
  36067. this.getToken();
  36068. while (true) {
  36069. token = this.getToken();
  36070. if (token === null || token === "end") {
  36071. break;
  36072. }
  36073. if (token !== "/") {
  36074. continue;
  36075. }
  36076. const glyph = this.getToken();
  36077. length = this.readInt();
  36078. this.getToken();
  36079. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  36080. lenIV = program.properties.privateData.lenIV;
  36081. const encoded = this.readCharStrings(data, lenIV);
  36082. this.nextChar();
  36083. token = this.getToken();
  36084. if (token === "noaccess") {
  36085. this.getToken();
  36086. } else if (token === "/") {
  36087. this.prevChar();
  36088. }
  36089. charstrings.push({
  36090. glyph,
  36091. encoded
  36092. });
  36093. }
  36094. break;
  36095. case "Subrs":
  36096. this.readInt();
  36097. this.getToken();
  36098. while (this.getToken() === "dup") {
  36099. const index = this.readInt();
  36100. length = this.readInt();
  36101. this.getToken();
  36102. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  36103. lenIV = program.properties.privateData.lenIV;
  36104. const encoded = this.readCharStrings(data, lenIV);
  36105. this.nextChar();
  36106. token = this.getToken();
  36107. if (token === "noaccess") {
  36108. this.getToken();
  36109. }
  36110. subrs[index] = encoded;
  36111. }
  36112. break;
  36113. case "BlueValues":
  36114. case "OtherBlues":
  36115. case "FamilyBlues":
  36116. case "FamilyOtherBlues":
  36117. const blueArray = this.readNumberArray();
  36118. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  36119. program.properties.privateData[token] = blueArray;
  36120. }
  36121. break;
  36122. case "StemSnapH":
  36123. case "StemSnapV":
  36124. program.properties.privateData[token] = this.readNumberArray();
  36125. break;
  36126. case "StdHW":
  36127. case "StdVW":
  36128. program.properties.privateData[token] = this.readNumberArray()[0];
  36129. break;
  36130. case "BlueShift":
  36131. case "lenIV":
  36132. case "BlueFuzz":
  36133. case "BlueScale":
  36134. case "LanguageGroup":
  36135. program.properties.privateData[token] = this.readNumber();
  36136. break;
  36137. case "ExpansionFactor":
  36138. program.properties.privateData[token] = this.readNumber() || 0.06;
  36139. break;
  36140. case "ForceBold":
  36141. program.properties.privateData[token] = this.readBoolean();
  36142. break;
  36143. }
  36144. }
  36145. for (const {
  36146. encoded,
  36147. glyph
  36148. } of charstrings) {
  36149. const charString = new Type1CharString();
  36150. const error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  36151. let output = charString.output;
  36152. if (error) {
  36153. output = [14];
  36154. }
  36155. const charStringObject = {
  36156. glyphName: glyph,
  36157. charstring: output,
  36158. width: charString.width,
  36159. lsb: charString.lsb,
  36160. seac: charString.seac
  36161. };
  36162. if (glyph === ".notdef") {
  36163. program.charstrings.unshift(charStringObject);
  36164. } else {
  36165. program.charstrings.push(charStringObject);
  36166. }
  36167. if (properties.builtInEncoding) {
  36168. const index = properties.builtInEncoding.indexOf(glyph);
  36169. if (index > -1 && properties.widths[index] === undefined && index >= properties.firstChar && index <= properties.lastChar) {
  36170. properties.widths[index] = charString.width;
  36171. }
  36172. }
  36173. }
  36174. return program;
  36175. }
  36176. extractFontHeader(properties) {
  36177. let token;
  36178. while ((token = this.getToken()) !== null) {
  36179. if (token !== "/") {
  36180. continue;
  36181. }
  36182. token = this.getToken();
  36183. switch (token) {
  36184. case "FontMatrix":
  36185. const matrix = this.readNumberArray();
  36186. properties.fontMatrix = matrix;
  36187. break;
  36188. case "Encoding":
  36189. const encodingArg = this.getToken();
  36190. let encoding;
  36191. if (!/^\d+$/.test(encodingArg)) {
  36192. encoding = (0, _encodings.getEncoding)(encodingArg);
  36193. } else {
  36194. encoding = [];
  36195. const size = parseInt(encodingArg, 10) | 0;
  36196. this.getToken();
  36197. for (let j = 0; j < size; j++) {
  36198. token = this.getToken();
  36199. while (token !== "dup" && token !== "def") {
  36200. token = this.getToken();
  36201. if (token === null) {
  36202. return;
  36203. }
  36204. }
  36205. if (token === "def") {
  36206. break;
  36207. }
  36208. const index = this.readInt();
  36209. this.getToken();
  36210. const glyph = this.getToken();
  36211. encoding[index] = glyph;
  36212. this.getToken();
  36213. }
  36214. }
  36215. properties.builtInEncoding = encoding;
  36216. break;
  36217. case "FontBBox":
  36218. const fontBBox = this.readNumberArray();
  36219. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  36220. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  36221. properties.ascentScaled = true;
  36222. break;
  36223. }
  36224. }
  36225. }
  36226. }
  36227. exports.Type1Parser = Type1Parser;
  36228. /***/ }),
  36229. /* 50 */
  36230. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  36231. Object.defineProperty(exports, "__esModule", ({
  36232. value: true
  36233. }));
  36234. exports.Pattern = void 0;
  36235. exports.getTilingPatternIR = getTilingPatternIR;
  36236. var _util = __w_pdfjs_require__(2);
  36237. var _base_stream = __w_pdfjs_require__(5);
  36238. var _colorspace = __w_pdfjs_require__(12);
  36239. var _core_utils = __w_pdfjs_require__(3);
  36240. const ShadingType = {
  36241. FUNCTION_BASED: 1,
  36242. AXIAL: 2,
  36243. RADIAL: 3,
  36244. FREE_FORM_MESH: 4,
  36245. LATTICE_FORM_MESH: 5,
  36246. COONS_PATCH_MESH: 6,
  36247. TENSOR_PATCH_MESH: 7
  36248. };
  36249. class Pattern {
  36250. constructor() {
  36251. (0, _util.unreachable)("Cannot initialize Pattern.");
  36252. }
  36253. static parseShading(shading, xref, res, pdfFunctionFactory, localColorSpaceCache) {
  36254. const dict = shading instanceof _base_stream.BaseStream ? shading.dict : shading;
  36255. const type = dict.get("ShadingType");
  36256. try {
  36257. switch (type) {
  36258. case ShadingType.AXIAL:
  36259. case ShadingType.RADIAL:
  36260. return new RadialAxialShading(dict, xref, res, pdfFunctionFactory, localColorSpaceCache);
  36261. case ShadingType.FREE_FORM_MESH:
  36262. case ShadingType.LATTICE_FORM_MESH:
  36263. case ShadingType.COONS_PATCH_MESH:
  36264. case ShadingType.TENSOR_PATCH_MESH:
  36265. return new MeshShading(shading, xref, res, pdfFunctionFactory, localColorSpaceCache);
  36266. default:
  36267. throw new _util.FormatError("Unsupported ShadingType: " + type);
  36268. }
  36269. } catch (ex) {
  36270. if (ex instanceof _core_utils.MissingDataException) {
  36271. throw ex;
  36272. }
  36273. (0, _util.warn)(ex);
  36274. return new DummyShading();
  36275. }
  36276. }
  36277. }
  36278. exports.Pattern = Pattern;
  36279. class BaseShading {
  36280. static SMALL_NUMBER = 1e-6;
  36281. constructor() {
  36282. if (this.constructor === BaseShading) {
  36283. (0, _util.unreachable)("Cannot initialize BaseShading.");
  36284. }
  36285. }
  36286. getIR() {
  36287. (0, _util.unreachable)("Abstract method `getIR` called.");
  36288. }
  36289. }
  36290. class RadialAxialShading extends BaseShading {
  36291. constructor(dict, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  36292. super();
  36293. this.coordsArr = dict.getArray("Coords");
  36294. this.shadingType = dict.get("ShadingType");
  36295. const cs = _colorspace.ColorSpace.parse({
  36296. cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
  36297. xref,
  36298. resources,
  36299. pdfFunctionFactory,
  36300. localColorSpaceCache
  36301. });
  36302. const bbox = dict.getArray("BBox");
  36303. this.bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  36304. let t0 = 0.0,
  36305. t1 = 1.0;
  36306. if (dict.has("Domain")) {
  36307. const domainArr = dict.getArray("Domain");
  36308. t0 = domainArr[0];
  36309. t1 = domainArr[1];
  36310. }
  36311. let extendStart = false,
  36312. extendEnd = false;
  36313. if (dict.has("Extend")) {
  36314. const extendArr = dict.getArray("Extend");
  36315. extendStart = extendArr[0];
  36316. extendEnd = extendArr[1];
  36317. }
  36318. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  36319. const [x1, y1, r1, x2, y2, r2] = this.coordsArr;
  36320. const distance = Math.hypot(x1 - x2, y1 - y2);
  36321. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  36322. (0, _util.warn)("Unsupported radial gradient.");
  36323. }
  36324. }
  36325. this.extendStart = extendStart;
  36326. this.extendEnd = extendEnd;
  36327. const fnObj = dict.getRaw("Function");
  36328. const fn = pdfFunctionFactory.createFromArray(fnObj);
  36329. const NUMBER_OF_SAMPLES = 840;
  36330. const step = (t1 - t0) / NUMBER_OF_SAMPLES;
  36331. const colorStops = this.colorStops = [];
  36332. if (t0 >= t1 || step <= 0) {
  36333. (0, _util.info)("Bad shading domain.");
  36334. return;
  36335. }
  36336. const color = new Float32Array(cs.numComps),
  36337. ratio = new Float32Array(1);
  36338. let rgbColor;
  36339. let iBase = 0;
  36340. ratio[0] = t0;
  36341. fn(ratio, 0, color, 0);
  36342. let rgbBase = cs.getRgb(color, 0);
  36343. const cssColorBase = _util.Util.makeHexColor(rgbBase[0], rgbBase[1], rgbBase[2]);
  36344. colorStops.push([0, cssColorBase]);
  36345. let iPrev = 1;
  36346. ratio[0] = t0 + step;
  36347. fn(ratio, 0, color, 0);
  36348. let rgbPrev = cs.getRgb(color, 0);
  36349. let maxSlopeR = rgbPrev[0] - rgbBase[0] + 1;
  36350. let maxSlopeG = rgbPrev[1] - rgbBase[1] + 1;
  36351. let maxSlopeB = rgbPrev[2] - rgbBase[2] + 1;
  36352. let minSlopeR = rgbPrev[0] - rgbBase[0] - 1;
  36353. let minSlopeG = rgbPrev[1] - rgbBase[1] - 1;
  36354. let minSlopeB = rgbPrev[2] - rgbBase[2] - 1;
  36355. for (let i = 2; i < NUMBER_OF_SAMPLES; i++) {
  36356. ratio[0] = t0 + i * step;
  36357. fn(ratio, 0, color, 0);
  36358. rgbColor = cs.getRgb(color, 0);
  36359. const run = i - iBase;
  36360. maxSlopeR = Math.min(maxSlopeR, (rgbColor[0] - rgbBase[0] + 1) / run);
  36361. maxSlopeG = Math.min(maxSlopeG, (rgbColor[1] - rgbBase[1] + 1) / run);
  36362. maxSlopeB = Math.min(maxSlopeB, (rgbColor[2] - rgbBase[2] + 1) / run);
  36363. minSlopeR = Math.max(minSlopeR, (rgbColor[0] - rgbBase[0] - 1) / run);
  36364. minSlopeG = Math.max(minSlopeG, (rgbColor[1] - rgbBase[1] - 1) / run);
  36365. minSlopeB = Math.max(minSlopeB, (rgbColor[2] - rgbBase[2] - 1) / run);
  36366. const slopesExist = minSlopeR <= maxSlopeR && minSlopeG <= maxSlopeG && minSlopeB <= maxSlopeB;
  36367. if (!slopesExist) {
  36368. const cssColor = _util.Util.makeHexColor(rgbPrev[0], rgbPrev[1], rgbPrev[2]);
  36369. colorStops.push([iPrev / NUMBER_OF_SAMPLES, cssColor]);
  36370. maxSlopeR = rgbColor[0] - rgbPrev[0] + 1;
  36371. maxSlopeG = rgbColor[1] - rgbPrev[1] + 1;
  36372. maxSlopeB = rgbColor[2] - rgbPrev[2] + 1;
  36373. minSlopeR = rgbColor[0] - rgbPrev[0] - 1;
  36374. minSlopeG = rgbColor[1] - rgbPrev[1] - 1;
  36375. minSlopeB = rgbColor[2] - rgbPrev[2] - 1;
  36376. iBase = iPrev;
  36377. rgbBase = rgbPrev;
  36378. }
  36379. iPrev = i;
  36380. rgbPrev = rgbColor;
  36381. }
  36382. const cssColor = _util.Util.makeHexColor(rgbPrev[0], rgbPrev[1], rgbPrev[2]);
  36383. colorStops.push([1, cssColor]);
  36384. let background = "transparent";
  36385. if (dict.has("Background")) {
  36386. rgbColor = cs.getRgb(dict.get("Background"), 0);
  36387. background = _util.Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
  36388. }
  36389. if (!extendStart) {
  36390. colorStops.unshift([0, background]);
  36391. colorStops[1][0] += BaseShading.SMALL_NUMBER;
  36392. }
  36393. if (!extendEnd) {
  36394. colorStops.at(-1)[0] -= BaseShading.SMALL_NUMBER;
  36395. colorStops.push([1, background]);
  36396. }
  36397. this.colorStops = colorStops;
  36398. }
  36399. getIR() {
  36400. const coordsArr = this.coordsArr;
  36401. const shadingType = this.shadingType;
  36402. let type, p0, p1, r0, r1;
  36403. if (shadingType === ShadingType.AXIAL) {
  36404. p0 = [coordsArr[0], coordsArr[1]];
  36405. p1 = [coordsArr[2], coordsArr[3]];
  36406. r0 = null;
  36407. r1 = null;
  36408. type = "axial";
  36409. } else if (shadingType === ShadingType.RADIAL) {
  36410. p0 = [coordsArr[0], coordsArr[1]];
  36411. p1 = [coordsArr[3], coordsArr[4]];
  36412. r0 = coordsArr[2];
  36413. r1 = coordsArr[5];
  36414. type = "radial";
  36415. } else {
  36416. (0, _util.unreachable)(`getPattern type unknown: ${shadingType}`);
  36417. }
  36418. return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
  36419. }
  36420. }
  36421. class MeshStreamReader {
  36422. constructor(stream, context) {
  36423. this.stream = stream;
  36424. this.context = context;
  36425. this.buffer = 0;
  36426. this.bufferLength = 0;
  36427. const numComps = context.numComps;
  36428. this.tmpCompsBuf = new Float32Array(numComps);
  36429. const csNumComps = context.colorSpace.numComps;
  36430. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  36431. }
  36432. get hasData() {
  36433. if (this.stream.end) {
  36434. return this.stream.pos < this.stream.end;
  36435. }
  36436. if (this.bufferLength > 0) {
  36437. return true;
  36438. }
  36439. const nextByte = this.stream.getByte();
  36440. if (nextByte < 0) {
  36441. return false;
  36442. }
  36443. this.buffer = nextByte;
  36444. this.bufferLength = 8;
  36445. return true;
  36446. }
  36447. readBits(n) {
  36448. let buffer = this.buffer;
  36449. let bufferLength = this.bufferLength;
  36450. if (n === 32) {
  36451. if (bufferLength === 0) {
  36452. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  36453. }
  36454. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  36455. const nextByte = this.stream.getByte();
  36456. this.buffer = nextByte & (1 << bufferLength) - 1;
  36457. return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
  36458. }
  36459. if (n === 8 && bufferLength === 0) {
  36460. return this.stream.getByte();
  36461. }
  36462. while (bufferLength < n) {
  36463. buffer = buffer << 8 | this.stream.getByte();
  36464. bufferLength += 8;
  36465. }
  36466. bufferLength -= n;
  36467. this.bufferLength = bufferLength;
  36468. this.buffer = buffer & (1 << bufferLength) - 1;
  36469. return buffer >> bufferLength;
  36470. }
  36471. align() {
  36472. this.buffer = 0;
  36473. this.bufferLength = 0;
  36474. }
  36475. readFlag() {
  36476. return this.readBits(this.context.bitsPerFlag);
  36477. }
  36478. readCoordinate() {
  36479. const bitsPerCoordinate = this.context.bitsPerCoordinate;
  36480. const xi = this.readBits(bitsPerCoordinate);
  36481. const yi = this.readBits(bitsPerCoordinate);
  36482. const decode = this.context.decode;
  36483. const scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  36484. return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
  36485. }
  36486. readComponents() {
  36487. const numComps = this.context.numComps;
  36488. const bitsPerComponent = this.context.bitsPerComponent;
  36489. const scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  36490. const decode = this.context.decode;
  36491. const components = this.tmpCompsBuf;
  36492. for (let i = 0, j = 4; i < numComps; i++, j += 2) {
  36493. const ci = this.readBits(bitsPerComponent);
  36494. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  36495. }
  36496. const color = this.tmpCsCompsBuf;
  36497. if (this.context.colorFn) {
  36498. this.context.colorFn(components, 0, color, 0);
  36499. }
  36500. return this.context.colorSpace.getRgb(color, 0);
  36501. }
  36502. }
  36503. const getB = function getBClosure() {
  36504. function buildB(count) {
  36505. const lut = [];
  36506. for (let i = 0; i <= count; i++) {
  36507. const t = i / count,
  36508. t_ = 1 - t;
  36509. lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));
  36510. }
  36511. return lut;
  36512. }
  36513. const cache = Object.create(null);
  36514. return function (count) {
  36515. return cache[count] ||= buildB(count);
  36516. };
  36517. }();
  36518. class MeshShading extends BaseShading {
  36519. static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  36520. static MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  36521. static TRIANGLE_DENSITY = 20;
  36522. constructor(stream, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  36523. super();
  36524. if (!(stream instanceof _base_stream.BaseStream)) {
  36525. throw new _util.FormatError("Mesh data is not a stream");
  36526. }
  36527. const dict = stream.dict;
  36528. this.shadingType = dict.get("ShadingType");
  36529. const bbox = dict.getArray("BBox");
  36530. this.bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  36531. const cs = _colorspace.ColorSpace.parse({
  36532. cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
  36533. xref,
  36534. resources,
  36535. pdfFunctionFactory,
  36536. localColorSpaceCache
  36537. });
  36538. this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
  36539. const fnObj = dict.getRaw("Function");
  36540. const fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
  36541. this.coords = [];
  36542. this.colors = [];
  36543. this.figures = [];
  36544. const decodeContext = {
  36545. bitsPerCoordinate: dict.get("BitsPerCoordinate"),
  36546. bitsPerComponent: dict.get("BitsPerComponent"),
  36547. bitsPerFlag: dict.get("BitsPerFlag"),
  36548. decode: dict.getArray("Decode"),
  36549. colorFn: fn,
  36550. colorSpace: cs,
  36551. numComps: fn ? 1 : cs.numComps
  36552. };
  36553. const reader = new MeshStreamReader(stream, decodeContext);
  36554. let patchMesh = false;
  36555. switch (this.shadingType) {
  36556. case ShadingType.FREE_FORM_MESH:
  36557. this._decodeType4Shading(reader);
  36558. break;
  36559. case ShadingType.LATTICE_FORM_MESH:
  36560. const verticesPerRow = dict.get("VerticesPerRow") | 0;
  36561. if (verticesPerRow < 2) {
  36562. throw new _util.FormatError("Invalid VerticesPerRow");
  36563. }
  36564. this._decodeType5Shading(reader, verticesPerRow);
  36565. break;
  36566. case ShadingType.COONS_PATCH_MESH:
  36567. this._decodeType6Shading(reader);
  36568. patchMesh = true;
  36569. break;
  36570. case ShadingType.TENSOR_PATCH_MESH:
  36571. this._decodeType7Shading(reader);
  36572. patchMesh = true;
  36573. break;
  36574. default:
  36575. (0, _util.unreachable)("Unsupported mesh type.");
  36576. break;
  36577. }
  36578. if (patchMesh) {
  36579. this._updateBounds();
  36580. for (let i = 0, ii = this.figures.length; i < ii; i++) {
  36581. this._buildFigureFromPatch(i);
  36582. }
  36583. }
  36584. this._updateBounds();
  36585. this._packData();
  36586. }
  36587. _decodeType4Shading(reader) {
  36588. const coords = this.coords;
  36589. const colors = this.colors;
  36590. const operators = [];
  36591. const ps = [];
  36592. let verticesLeft = 0;
  36593. while (reader.hasData) {
  36594. const f = reader.readFlag();
  36595. const coord = reader.readCoordinate();
  36596. const color = reader.readComponents();
  36597. if (verticesLeft === 0) {
  36598. if (!(0 <= f && f <= 2)) {
  36599. throw new _util.FormatError("Unknown type4 flag");
  36600. }
  36601. switch (f) {
  36602. case 0:
  36603. verticesLeft = 3;
  36604. break;
  36605. case 1:
  36606. ps.push(ps.at(-2), ps.at(-1));
  36607. verticesLeft = 1;
  36608. break;
  36609. case 2:
  36610. ps.push(ps.at(-3), ps.at(-1));
  36611. verticesLeft = 1;
  36612. break;
  36613. }
  36614. operators.push(f);
  36615. }
  36616. ps.push(coords.length);
  36617. coords.push(coord);
  36618. colors.push(color);
  36619. verticesLeft--;
  36620. reader.align();
  36621. }
  36622. this.figures.push({
  36623. type: "triangles",
  36624. coords: new Int32Array(ps),
  36625. colors: new Int32Array(ps)
  36626. });
  36627. }
  36628. _decodeType5Shading(reader, verticesPerRow) {
  36629. const coords = this.coords;
  36630. const colors = this.colors;
  36631. const ps = [];
  36632. while (reader.hasData) {
  36633. const coord = reader.readCoordinate();
  36634. const color = reader.readComponents();
  36635. ps.push(coords.length);
  36636. coords.push(coord);
  36637. colors.push(color);
  36638. }
  36639. this.figures.push({
  36640. type: "lattice",
  36641. coords: new Int32Array(ps),
  36642. colors: new Int32Array(ps),
  36643. verticesPerRow
  36644. });
  36645. }
  36646. _decodeType6Shading(reader) {
  36647. const coords = this.coords;
  36648. const colors = this.colors;
  36649. const ps = new Int32Array(16);
  36650. const cs = new Int32Array(4);
  36651. while (reader.hasData) {
  36652. const f = reader.readFlag();
  36653. if (!(0 <= f && f <= 3)) {
  36654. throw new _util.FormatError("Unknown type6 flag");
  36655. }
  36656. const pi = coords.length;
  36657. for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  36658. coords.push(reader.readCoordinate());
  36659. }
  36660. const ci = colors.length;
  36661. for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  36662. colors.push(reader.readComponents());
  36663. }
  36664. let tmp1, tmp2, tmp3, tmp4;
  36665. switch (f) {
  36666. case 0:
  36667. ps[12] = pi + 3;
  36668. ps[13] = pi + 4;
  36669. ps[14] = pi + 5;
  36670. ps[15] = pi + 6;
  36671. ps[8] = pi + 2;
  36672. ps[11] = pi + 7;
  36673. ps[4] = pi + 1;
  36674. ps[7] = pi + 8;
  36675. ps[0] = pi;
  36676. ps[1] = pi + 11;
  36677. ps[2] = pi + 10;
  36678. ps[3] = pi + 9;
  36679. cs[2] = ci + 1;
  36680. cs[3] = ci + 2;
  36681. cs[0] = ci;
  36682. cs[1] = ci + 3;
  36683. break;
  36684. case 1:
  36685. tmp1 = ps[12];
  36686. tmp2 = ps[13];
  36687. tmp3 = ps[14];
  36688. tmp4 = ps[15];
  36689. ps[12] = tmp4;
  36690. ps[13] = pi + 0;
  36691. ps[14] = pi + 1;
  36692. ps[15] = pi + 2;
  36693. ps[8] = tmp3;
  36694. ps[11] = pi + 3;
  36695. ps[4] = tmp2;
  36696. ps[7] = pi + 4;
  36697. ps[0] = tmp1;
  36698. ps[1] = pi + 7;
  36699. ps[2] = pi + 6;
  36700. ps[3] = pi + 5;
  36701. tmp1 = cs[2];
  36702. tmp2 = cs[3];
  36703. cs[2] = tmp2;
  36704. cs[3] = ci;
  36705. cs[0] = tmp1;
  36706. cs[1] = ci + 1;
  36707. break;
  36708. case 2:
  36709. tmp1 = ps[15];
  36710. tmp2 = ps[11];
  36711. ps[12] = ps[3];
  36712. ps[13] = pi + 0;
  36713. ps[14] = pi + 1;
  36714. ps[15] = pi + 2;
  36715. ps[8] = ps[7];
  36716. ps[11] = pi + 3;
  36717. ps[4] = tmp2;
  36718. ps[7] = pi + 4;
  36719. ps[0] = tmp1;
  36720. ps[1] = pi + 7;
  36721. ps[2] = pi + 6;
  36722. ps[3] = pi + 5;
  36723. tmp1 = cs[3];
  36724. cs[2] = cs[1];
  36725. cs[3] = ci;
  36726. cs[0] = tmp1;
  36727. cs[1] = ci + 1;
  36728. break;
  36729. case 3:
  36730. ps[12] = ps[0];
  36731. ps[13] = pi + 0;
  36732. ps[14] = pi + 1;
  36733. ps[15] = pi + 2;
  36734. ps[8] = ps[1];
  36735. ps[11] = pi + 3;
  36736. ps[4] = ps[2];
  36737. ps[7] = pi + 4;
  36738. ps[0] = ps[3];
  36739. ps[1] = pi + 7;
  36740. ps[2] = pi + 6;
  36741. ps[3] = pi + 5;
  36742. cs[2] = cs[0];
  36743. cs[3] = ci;
  36744. cs[0] = cs[1];
  36745. cs[1] = ci + 1;
  36746. break;
  36747. }
  36748. ps[5] = coords.length;
  36749. coords.push([(-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9]);
  36750. ps[6] = coords.length;
  36751. coords.push([(-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9]);
  36752. ps[9] = coords.length;
  36753. coords.push([(-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9]);
  36754. ps[10] = coords.length;
  36755. coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]);
  36756. this.figures.push({
  36757. type: "patch",
  36758. coords: new Int32Array(ps),
  36759. colors: new Int32Array(cs)
  36760. });
  36761. }
  36762. }
  36763. _decodeType7Shading(reader) {
  36764. const coords = this.coords;
  36765. const colors = this.colors;
  36766. const ps = new Int32Array(16);
  36767. const cs = new Int32Array(4);
  36768. while (reader.hasData) {
  36769. const f = reader.readFlag();
  36770. if (!(0 <= f && f <= 3)) {
  36771. throw new _util.FormatError("Unknown type7 flag");
  36772. }
  36773. const pi = coords.length;
  36774. for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  36775. coords.push(reader.readCoordinate());
  36776. }
  36777. const ci = colors.length;
  36778. for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  36779. colors.push(reader.readComponents());
  36780. }
  36781. let tmp1, tmp2, tmp3, tmp4;
  36782. switch (f) {
  36783. case 0:
  36784. ps[12] = pi + 3;
  36785. ps[13] = pi + 4;
  36786. ps[14] = pi + 5;
  36787. ps[15] = pi + 6;
  36788. ps[8] = pi + 2;
  36789. ps[9] = pi + 13;
  36790. ps[10] = pi + 14;
  36791. ps[11] = pi + 7;
  36792. ps[4] = pi + 1;
  36793. ps[5] = pi + 12;
  36794. ps[6] = pi + 15;
  36795. ps[7] = pi + 8;
  36796. ps[0] = pi;
  36797. ps[1] = pi + 11;
  36798. ps[2] = pi + 10;
  36799. ps[3] = pi + 9;
  36800. cs[2] = ci + 1;
  36801. cs[3] = ci + 2;
  36802. cs[0] = ci;
  36803. cs[1] = ci + 3;
  36804. break;
  36805. case 1:
  36806. tmp1 = ps[12];
  36807. tmp2 = ps[13];
  36808. tmp3 = ps[14];
  36809. tmp4 = ps[15];
  36810. ps[12] = tmp4;
  36811. ps[13] = pi + 0;
  36812. ps[14] = pi + 1;
  36813. ps[15] = pi + 2;
  36814. ps[8] = tmp3;
  36815. ps[9] = pi + 9;
  36816. ps[10] = pi + 10;
  36817. ps[11] = pi + 3;
  36818. ps[4] = tmp2;
  36819. ps[5] = pi + 8;
  36820. ps[6] = pi + 11;
  36821. ps[7] = pi + 4;
  36822. ps[0] = tmp1;
  36823. ps[1] = pi + 7;
  36824. ps[2] = pi + 6;
  36825. ps[3] = pi + 5;
  36826. tmp1 = cs[2];
  36827. tmp2 = cs[3];
  36828. cs[2] = tmp2;
  36829. cs[3] = ci;
  36830. cs[0] = tmp1;
  36831. cs[1] = ci + 1;
  36832. break;
  36833. case 2:
  36834. tmp1 = ps[15];
  36835. tmp2 = ps[11];
  36836. ps[12] = ps[3];
  36837. ps[13] = pi + 0;
  36838. ps[14] = pi + 1;
  36839. ps[15] = pi + 2;
  36840. ps[8] = ps[7];
  36841. ps[9] = pi + 9;
  36842. ps[10] = pi + 10;
  36843. ps[11] = pi + 3;
  36844. ps[4] = tmp2;
  36845. ps[5] = pi + 8;
  36846. ps[6] = pi + 11;
  36847. ps[7] = pi + 4;
  36848. ps[0] = tmp1;
  36849. ps[1] = pi + 7;
  36850. ps[2] = pi + 6;
  36851. ps[3] = pi + 5;
  36852. tmp1 = cs[3];
  36853. cs[2] = cs[1];
  36854. cs[3] = ci;
  36855. cs[0] = tmp1;
  36856. cs[1] = ci + 1;
  36857. break;
  36858. case 3:
  36859. ps[12] = ps[0];
  36860. ps[13] = pi + 0;
  36861. ps[14] = pi + 1;
  36862. ps[15] = pi + 2;
  36863. ps[8] = ps[1];
  36864. ps[9] = pi + 9;
  36865. ps[10] = pi + 10;
  36866. ps[11] = pi + 3;
  36867. ps[4] = ps[2];
  36868. ps[5] = pi + 8;
  36869. ps[6] = pi + 11;
  36870. ps[7] = pi + 4;
  36871. ps[0] = ps[3];
  36872. ps[1] = pi + 7;
  36873. ps[2] = pi + 6;
  36874. ps[3] = pi + 5;
  36875. cs[2] = cs[0];
  36876. cs[3] = ci;
  36877. cs[0] = cs[1];
  36878. cs[1] = ci + 1;
  36879. break;
  36880. }
  36881. this.figures.push({
  36882. type: "patch",
  36883. coords: new Int32Array(ps),
  36884. colors: new Int32Array(cs)
  36885. });
  36886. }
  36887. }
  36888. _buildFigureFromPatch(index) {
  36889. const figure = this.figures[index];
  36890. (0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
  36891. const coords = this.coords,
  36892. colors = this.colors;
  36893. const pi = figure.coords;
  36894. const ci = figure.colors;
  36895. const figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  36896. const figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  36897. const figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  36898. const figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  36899. let splitXBy = Math.ceil((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY / (this.bounds[2] - this.bounds[0]));
  36900. splitXBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  36901. let splitYBy = Math.ceil((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY / (this.bounds[3] - this.bounds[1]));
  36902. splitYBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  36903. const verticesPerRow = splitXBy + 1;
  36904. const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  36905. const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  36906. let k = 0;
  36907. const cl = new Uint8Array(3),
  36908. cr = new Uint8Array(3);
  36909. const c0 = colors[ci[0]],
  36910. c1 = colors[ci[1]],
  36911. c2 = colors[ci[2]],
  36912. c3 = colors[ci[3]];
  36913. const bRow = getB(splitYBy),
  36914. bCol = getB(splitXBy);
  36915. for (let row = 0; row <= splitYBy; row++) {
  36916. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  36917. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  36918. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  36919. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  36920. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  36921. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  36922. for (let col = 0; col <= splitXBy; col++, k++) {
  36923. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  36924. continue;
  36925. }
  36926. let x = 0,
  36927. y = 0;
  36928. let q = 0;
  36929. for (let i = 0; i <= 3; i++) {
  36930. for (let j = 0; j <= 3; j++, q++) {
  36931. const m = bRow[row][i] * bCol[col][j];
  36932. x += coords[pi[q]][0] * m;
  36933. y += coords[pi[q]][1] * m;
  36934. }
  36935. }
  36936. figureCoords[k] = coords.length;
  36937. coords.push([x, y]);
  36938. figureColors[k] = colors.length;
  36939. const newColor = new Uint8Array(3);
  36940. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  36941. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  36942. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  36943. colors.push(newColor);
  36944. }
  36945. }
  36946. figureCoords[0] = pi[0];
  36947. figureColors[0] = ci[0];
  36948. figureCoords[splitXBy] = pi[3];
  36949. figureColors[splitXBy] = ci[1];
  36950. figureCoords[verticesPerRow * splitYBy] = pi[12];
  36951. figureColors[verticesPerRow * splitYBy] = ci[2];
  36952. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  36953. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  36954. this.figures[index] = {
  36955. type: "lattice",
  36956. coords: figureCoords,
  36957. colors: figureColors,
  36958. verticesPerRow
  36959. };
  36960. }
  36961. _updateBounds() {
  36962. let minX = this.coords[0][0],
  36963. minY = this.coords[0][1],
  36964. maxX = minX,
  36965. maxY = minY;
  36966. for (let i = 1, ii = this.coords.length; i < ii; i++) {
  36967. const x = this.coords[i][0],
  36968. y = this.coords[i][1];
  36969. minX = minX > x ? x : minX;
  36970. minY = minY > y ? y : minY;
  36971. maxX = maxX < x ? x : maxX;
  36972. maxY = maxY < y ? y : maxY;
  36973. }
  36974. this.bounds = [minX, minY, maxX, maxY];
  36975. }
  36976. _packData() {
  36977. let i, ii, j, jj;
  36978. const coords = this.coords;
  36979. const coordsPacked = new Float32Array(coords.length * 2);
  36980. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  36981. const xy = coords[i];
  36982. coordsPacked[j++] = xy[0];
  36983. coordsPacked[j++] = xy[1];
  36984. }
  36985. this.coords = coordsPacked;
  36986. const colors = this.colors;
  36987. const colorsPacked = new Uint8Array(colors.length * 3);
  36988. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  36989. const c = colors[i];
  36990. colorsPacked[j++] = c[0];
  36991. colorsPacked[j++] = c[1];
  36992. colorsPacked[j++] = c[2];
  36993. }
  36994. this.colors = colorsPacked;
  36995. const figures = this.figures;
  36996. for (i = 0, ii = figures.length; i < ii; i++) {
  36997. const figure = figures[i],
  36998. ps = figure.coords,
  36999. cs = figure.colors;
  37000. for (j = 0, jj = ps.length; j < jj; j++) {
  37001. ps[j] *= 2;
  37002. cs[j] *= 3;
  37003. }
  37004. }
  37005. }
  37006. getIR() {
  37007. return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.bbox, this.background];
  37008. }
  37009. }
  37010. class DummyShading extends BaseShading {
  37011. getIR() {
  37012. return ["Dummy"];
  37013. }
  37014. }
  37015. function getTilingPatternIR(operatorList, dict, color) {
  37016. const matrix = dict.getArray("Matrix");
  37017. const bbox = _util.Util.normalizeRect(dict.getArray("BBox"));
  37018. const xstep = dict.get("XStep");
  37019. const ystep = dict.get("YStep");
  37020. const paintType = dict.get("PaintType");
  37021. const tilingType = dict.get("TilingType");
  37022. if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
  37023. throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
  37024. }
  37025. return ["TilingPattern", color, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
  37026. }
  37027. /***/ }),
  37028. /* 51 */
  37029. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37030. Object.defineProperty(exports, "__esModule", ({
  37031. value: true
  37032. }));
  37033. exports.getXfaFontDict = getXfaFontDict;
  37034. exports.getXfaFontName = getXfaFontName;
  37035. var _calibri_factors = __w_pdfjs_require__(52);
  37036. var _primitives = __w_pdfjs_require__(4);
  37037. var _helvetica_factors = __w_pdfjs_require__(53);
  37038. var _liberationsans_widths = __w_pdfjs_require__(54);
  37039. var _myriadpro_factors = __w_pdfjs_require__(55);
  37040. var _segoeui_factors = __w_pdfjs_require__(56);
  37041. var _core_utils = __w_pdfjs_require__(3);
  37042. var _fonts_utils = __w_pdfjs_require__(38);
  37043. const getXFAFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  37044. t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = {
  37045. name: "LiberationSans-Regular",
  37046. factors: _myriadpro_factors.MyriadProRegularFactors,
  37047. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  37048. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  37049. metrics: _myriadpro_factors.MyriadProRegularMetrics
  37050. };
  37051. t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = {
  37052. name: "LiberationSans-Bold",
  37053. factors: _myriadpro_factors.MyriadProBoldFactors,
  37054. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  37055. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  37056. metrics: _myriadpro_factors.MyriadProBoldMetrics
  37057. };
  37058. t["MyriadPro-It"] = t["MyriadPro-Italic"] = t["PdfJS-Fallback-Italic"] = {
  37059. name: "LiberationSans-Italic",
  37060. factors: _myriadpro_factors.MyriadProItalicFactors,
  37061. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  37062. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  37063. metrics: _myriadpro_factors.MyriadProItalicMetrics
  37064. };
  37065. t["MyriadPro-BoldIt"] = t["MyriadPro-BoldItalic"] = t["PdfJS-Fallback-BoldItalic"] = {
  37066. name: "LiberationSans-BoldItalic",
  37067. factors: _myriadpro_factors.MyriadProBoldItalicFactors,
  37068. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  37069. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  37070. metrics: _myriadpro_factors.MyriadProBoldItalicMetrics
  37071. };
  37072. t.ArialMT = t.Arial = t["Arial-Regular"] = {
  37073. name: "LiberationSans-Regular",
  37074. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  37075. baseMapping: _liberationsans_widths.LiberationSansRegularMapping
  37076. };
  37077. t["Arial-BoldMT"] = t["Arial-Bold"] = {
  37078. name: "LiberationSans-Bold",
  37079. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  37080. baseMapping: _liberationsans_widths.LiberationSansBoldMapping
  37081. };
  37082. t["Arial-ItalicMT"] = t["Arial-Italic"] = {
  37083. name: "LiberationSans-Italic",
  37084. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  37085. baseMapping: _liberationsans_widths.LiberationSansItalicMapping
  37086. };
  37087. t["Arial-BoldItalicMT"] = t["Arial-BoldItalic"] = {
  37088. name: "LiberationSans-BoldItalic",
  37089. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  37090. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping
  37091. };
  37092. t["Calibri-Regular"] = {
  37093. name: "LiberationSans-Regular",
  37094. factors: _calibri_factors.CalibriRegularFactors,
  37095. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  37096. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  37097. metrics: _calibri_factors.CalibriRegularMetrics
  37098. };
  37099. t["Calibri-Bold"] = {
  37100. name: "LiberationSans-Bold",
  37101. factors: _calibri_factors.CalibriBoldFactors,
  37102. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  37103. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  37104. metrics: _calibri_factors.CalibriBoldMetrics
  37105. };
  37106. t["Calibri-Italic"] = {
  37107. name: "LiberationSans-Italic",
  37108. factors: _calibri_factors.CalibriItalicFactors,
  37109. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  37110. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  37111. metrics: _calibri_factors.CalibriItalicMetrics
  37112. };
  37113. t["Calibri-BoldItalic"] = {
  37114. name: "LiberationSans-BoldItalic",
  37115. factors: _calibri_factors.CalibriBoldItalicFactors,
  37116. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  37117. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  37118. metrics: _calibri_factors.CalibriBoldItalicMetrics
  37119. };
  37120. t["Segoeui-Regular"] = {
  37121. name: "LiberationSans-Regular",
  37122. factors: _segoeui_factors.SegoeuiRegularFactors,
  37123. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  37124. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  37125. metrics: _segoeui_factors.SegoeuiRegularMetrics
  37126. };
  37127. t["Segoeui-Bold"] = {
  37128. name: "LiberationSans-Bold",
  37129. factors: _segoeui_factors.SegoeuiBoldFactors,
  37130. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  37131. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  37132. metrics: _segoeui_factors.SegoeuiBoldMetrics
  37133. };
  37134. t["Segoeui-Italic"] = {
  37135. name: "LiberationSans-Italic",
  37136. factors: _segoeui_factors.SegoeuiItalicFactors,
  37137. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  37138. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  37139. metrics: _segoeui_factors.SegoeuiItalicMetrics
  37140. };
  37141. t["Segoeui-BoldItalic"] = {
  37142. name: "LiberationSans-BoldItalic",
  37143. factors: _segoeui_factors.SegoeuiBoldItalicFactors,
  37144. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  37145. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  37146. metrics: _segoeui_factors.SegoeuiBoldItalicMetrics
  37147. };
  37148. t["Helvetica-Regular"] = t.Helvetica = {
  37149. name: "LiberationSans-Regular",
  37150. factors: _helvetica_factors.HelveticaRegularFactors,
  37151. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  37152. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  37153. metrics: _helvetica_factors.HelveticaRegularMetrics
  37154. };
  37155. t["Helvetica-Bold"] = {
  37156. name: "LiberationSans-Bold",
  37157. factors: _helvetica_factors.HelveticaBoldFactors,
  37158. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  37159. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  37160. metrics: _helvetica_factors.HelveticaBoldMetrics
  37161. };
  37162. t["Helvetica-Italic"] = {
  37163. name: "LiberationSans-Italic",
  37164. factors: _helvetica_factors.HelveticaItalicFactors,
  37165. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  37166. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  37167. metrics: _helvetica_factors.HelveticaItalicMetrics
  37168. };
  37169. t["Helvetica-BoldItalic"] = {
  37170. name: "LiberationSans-BoldItalic",
  37171. factors: _helvetica_factors.HelveticaBoldItalicFactors,
  37172. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  37173. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  37174. metrics: _helvetica_factors.HelveticaBoldItalicMetrics
  37175. };
  37176. });
  37177. function getXfaFontName(name) {
  37178. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  37179. const fontMap = getXFAFontMap();
  37180. return fontMap[fontName];
  37181. }
  37182. function getXfaFontWidths(name) {
  37183. const info = getXfaFontName(name);
  37184. if (!info) {
  37185. return null;
  37186. }
  37187. const {
  37188. baseWidths,
  37189. baseMapping,
  37190. factors
  37191. } = info;
  37192. const rescaledBaseWidths = !factors ? baseWidths : baseWidths.map((w, i) => w * factors[i]);
  37193. let currentCode = -2;
  37194. let currentArray;
  37195. const newWidths = [];
  37196. for (const [unicode, glyphIndex] of baseMapping.map((charUnicode, index) => [charUnicode, index]).sort(([unicode1], [unicode2]) => unicode1 - unicode2)) {
  37197. if (unicode === -1) {
  37198. continue;
  37199. }
  37200. if (unicode === currentCode + 1) {
  37201. currentArray.push(rescaledBaseWidths[glyphIndex]);
  37202. currentCode += 1;
  37203. } else {
  37204. currentCode = unicode;
  37205. currentArray = [rescaledBaseWidths[glyphIndex]];
  37206. newWidths.push(unicode, currentArray);
  37207. }
  37208. }
  37209. return newWidths;
  37210. }
  37211. function getXfaFontDict(name) {
  37212. const widths = getXfaFontWidths(name);
  37213. const dict = new _primitives.Dict(null);
  37214. dict.set("BaseFont", _primitives.Name.get(name));
  37215. dict.set("Type", _primitives.Name.get("Font"));
  37216. dict.set("Subtype", _primitives.Name.get("CIDFontType2"));
  37217. dict.set("Encoding", _primitives.Name.get("Identity-H"));
  37218. dict.set("CIDToGIDMap", _primitives.Name.get("Identity"));
  37219. dict.set("W", widths);
  37220. dict.set("FirstChar", widths[0]);
  37221. dict.set("LastChar", widths.at(-2) + widths.at(-1).length - 1);
  37222. const descriptor = new _primitives.Dict(null);
  37223. dict.set("FontDescriptor", descriptor);
  37224. const systemInfo = new _primitives.Dict(null);
  37225. systemInfo.set("Ordering", "Identity");
  37226. systemInfo.set("Registry", "Adobe");
  37227. systemInfo.set("Supplement", 0);
  37228. dict.set("CIDSystemInfo", systemInfo);
  37229. return dict;
  37230. }
  37231. /***/ }),
  37232. /* 52 */
  37233. /***/ ((__unused_webpack_module, exports) => {
  37234. Object.defineProperty(exports, "__esModule", ({
  37235. value: true
  37236. }));
  37237. exports.CalibriRegularMetrics = exports.CalibriRegularFactors = exports.CalibriItalicMetrics = exports.CalibriItalicFactors = exports.CalibriBoldMetrics = exports.CalibriBoldItalicMetrics = exports.CalibriBoldItalicFactors = exports.CalibriBoldFactors = void 0;
  37238. const CalibriBoldFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.54657, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.73293, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.9121, 0.86943, 0.79795, 0.88198, 0.77958, 0.70864, 0.81055, 0.90399, 0.88653, 0.96017, 0.82577, 0.77892, 0.78257, 0.97507, 1.54657, 0.97507, 0.85284, 0.89552, 0.90176, 0.88762, 0.8785, 0.75241, 0.8785, 0.90518, 0.95015, 0.77618, 0.8785, 0.88401, 0.91916, 0.86304, 0.88401, 0.91488, 0.8785, 0.8801, 0.8785, 0.8785, 0.91343, 0.7173, 1.04106, 0.8785, 0.85075, 0.95794, 0.82616, 0.85162, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.12401, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.73293, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.9121, 0.86943, 0.86943, 0.86943, 0.86943, 0.86943, 0.85284, 0.87508, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.8715, 0.75241, 0.90518, 0.90518, 0.90518, 0.90518, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.8785, 0.8801, 0.8801, 0.8801, 0.8801, 0.8801, 0.90747, 0.89049, 0.8785, 0.8785, 0.8785, 0.8785, 0.85162, 0.8785, 0.85162, 0.83908, 0.88762, 0.83908, 0.88762, 0.83908, 0.88762, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.87289, 0.83016, 0.88506, 0.93125, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.81921, 0.77618, 0.81921, 0.77618, 0.81921, 0.77618, 1, 1, 0.87356, 0.8785, 0.91075, 0.89608, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76229, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.79468, 0.91926, 0.88175, 0.70823, 0.94903, 0.9121, 0.8785, 1, 1, 0.9121, 0.8785, 0.87802, 0.88656, 0.8785, 0.86943, 0.8801, 0.86943, 0.8801, 0.86943, 0.8801, 0.87402, 0.89291, 0.77958, 0.91343, 1, 1, 0.77958, 0.91343, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.96017, 0.95794, 0.77892, 0.85162, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.88762, 0.77539, 0.8715, 0.87508, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70674, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.06303, 0.83908, 0.80352, 0.57184, 0.6965, 0.56289, 0.82001, 0.56029, 0.81235, 1.02988, 0.83908, 0.7762, 0.68156, 0.80367, 0.73133, 0.78257, 0.87356, 0.86943, 0.95958, 0.75727, 0.89019, 1.04924, 0.9121, 0.7648, 0.86943, 0.87356, 0.79795, 0.78275, 0.81055, 0.77892, 0.9762, 0.82577, 0.99819, 0.84896, 0.95958, 0.77892, 0.96108, 1.01407, 0.89049, 1.02988, 0.94211, 0.96108, 0.8936, 0.84021, 0.87842, 0.96399, 0.79109, 0.89049, 1.00813, 1.02988, 0.86077, 0.87445, 0.92099, 0.84723, 0.86513, 0.8801, 0.75638, 0.85714, 0.78216, 0.79586, 0.87965, 0.94211, 0.97747, 0.78287, 0.97926, 0.84971, 1.02988, 0.94211, 0.8801, 0.94211, 0.84971, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90264, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90518, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90548, 1, 1, 1, 1, 1, 1, 0.96017, 0.95794, 0.96017, 0.95794, 0.96017, 0.95794, 0.77892, 0.85162, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.92794, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71143, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.93835, 0.83406, 0.91133, 0.84107, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90527, 1.81055, 0.90527, 1.81055, 1.31006, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37239. exports.CalibriBoldFactors = CalibriBoldFactors;
  37240. const CalibriBoldMetrics = {
  37241. lineHeight: 1.2207,
  37242. lineGap: 0.2207
  37243. };
  37244. exports.CalibriBoldMetrics = CalibriBoldMetrics;
  37245. const CalibriBoldItalicFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.56239, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.71805, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.90872, 0.85938, 0.79795, 0.87068, 0.77958, 0.69766, 0.81055, 0.90399, 0.88653, 0.96068, 0.82577, 0.77892, 0.78257, 0.97507, 1.529, 0.97507, 0.85284, 0.89552, 0.90176, 0.94908, 0.86411, 0.74012, 0.86411, 0.88323, 0.95015, 0.86411, 0.86331, 0.88401, 0.91916, 0.86304, 0.88401, 0.9039, 0.86331, 0.86331, 0.86411, 0.86411, 0.90464, 0.70852, 1.04106, 0.86331, 0.84372, 0.95794, 0.82616, 0.84548, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.19129, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.71805, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.90872, 0.85938, 0.85938, 0.85938, 0.85938, 0.85938, 0.85284, 0.87068, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.85887, 0.74012, 0.88323, 0.88323, 0.88323, 0.88323, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.90747, 0.89049, 0.86331, 0.86331, 0.86331, 0.86331, 0.84548, 0.86411, 0.84548, 0.83908, 0.94908, 0.83908, 0.94908, 0.83908, 0.94908, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.87289, 0.79538, 0.88506, 0.92726, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.81921, 0.86411, 0.81921, 0.86411, 0.81921, 0.86411, 1, 1, 0.87356, 0.86331, 0.91075, 0.8777, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76467, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.77312, 0.91926, 0.88175, 0.70823, 0.94903, 0.90872, 0.86331, 1, 1, 0.90872, 0.86331, 0.86906, 0.88116, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.87402, 0.86549, 0.77958, 0.90464, 1, 1, 0.77958, 0.90464, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.96068, 0.95794, 0.77892, 0.84548, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.94908, 0.77539, 0.85887, 0.87068, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70088, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.48387, 0.83908, 0.80352, 0.57118, 0.6965, 0.56347, 0.79179, 0.55853, 0.80346, 1.02988, 0.83908, 0.7762, 0.67174, 0.86036, 0.73133, 0.78257, 0.87356, 0.86441, 0.95958, 0.75727, 0.89019, 1.04924, 0.90872, 0.74889, 0.85938, 0.87891, 0.79795, 0.7957, 0.81055, 0.77892, 0.97447, 0.82577, 0.97466, 0.87179, 0.95958, 0.77892, 0.94252, 0.95612, 0.8753, 1.02988, 0.92733, 0.94252, 0.87411, 0.84021, 0.8728, 0.95612, 0.74081, 0.8753, 1.02189, 1.02988, 0.84814, 0.87445, 0.91822, 0.84723, 0.85668, 0.86331, 0.81344, 0.87581, 0.76422, 0.82046, 0.96057, 0.92733, 0.99375, 0.78022, 0.95452, 0.86015, 1.02988, 0.92733, 0.86331, 0.92733, 0.86015, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90631, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88323, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85174, 1, 1, 1, 1, 1, 1, 0.96068, 0.95794, 0.96068, 0.95794, 0.96068, 0.95794, 0.77892, 0.84548, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.89807, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71094, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.92972, 0.83406, 0.91133, 0.83326, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90616, 1.81055, 0.90527, 1.81055, 1.3107, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37246. exports.CalibriBoldItalicFactors = CalibriBoldItalicFactors;
  37247. const CalibriBoldItalicMetrics = {
  37248. lineHeight: 1.2207,
  37249. lineGap: 0.2207
  37250. };
  37251. exports.CalibriBoldItalicMetrics = CalibriBoldItalicMetrics;
  37252. const CalibriItalicFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39543, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.72346, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 0.75593, 1.02638, 0.89249, 0.84118, 0.77452, 0.85374, 0.75186, 0.67789, 0.79776, 0.88844, 0.85066, 0.94309, 0.77818, 0.7306, 0.76659, 1.10369, 1.38313, 1.10369, 1.06139, 0.89552, 0.8739, 0.9245, 0.9245, 0.83203, 0.9245, 0.85865, 1.09842, 0.9245, 0.9245, 1.03297, 1.07692, 0.90918, 1.03297, 0.94959, 0.9245, 0.92274, 0.9245, 0.9245, 1.02933, 0.77832, 1.20562, 0.9245, 0.8916, 0.98986, 0.86621, 0.89453, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.16359, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.72346, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89249, 0.84118, 0.84118, 0.84118, 0.84118, 0.84118, 0.85284, 0.84557, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.84843, 0.83203, 0.85865, 0.85865, 0.85865, 0.85865, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.9245, 0.92274, 0.92274, 0.92274, 0.92274, 0.92274, 0.90747, 0.86651, 0.9245, 0.9245, 0.9245, 0.9245, 0.89453, 0.9245, 0.89453, 0.8675, 0.9245, 0.8675, 0.9245, 0.8675, 0.9245, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.85193, 0.8875, 0.86477, 0.99034, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.81105, 0.9245, 0.81105, 0.9245, 0.81105, 0.9245, 1, 1, 0.86275, 0.9245, 0.90872, 0.93591, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77896, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.9375, 0.98156, 0.93407, 0.77261, 1.11429, 0.89249, 0.9245, 1, 1, 0.89249, 0.9245, 0.92534, 0.86698, 0.9245, 0.84118, 0.92274, 0.84118, 0.92274, 0.84118, 0.92274, 0.8667, 0.86291, 0.75186, 1.02933, 1, 1, 0.75186, 1.02933, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 1, 1, 0.79776, 0.97655, 0.79776, 1.23023, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.94309, 0.98986, 0.7306, 0.89453, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.9245, 0.76318, 0.84843, 0.84557, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67009, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.8675, 0.90861, 0.6192, 0.7363, 0.64824, 0.82411, 0.56321, 0.85696, 1.23516, 0.8675, 0.81552, 0.7286, 0.84134, 0.73206, 0.76659, 0.86275, 0.84369, 0.90685, 0.77892, 0.85871, 1.02638, 0.89249, 0.75828, 0.84118, 0.85984, 0.77452, 0.76466, 0.79776, 0.7306, 0.90782, 0.77818, 0.903, 0.87291, 0.90685, 0.7306, 0.99058, 1.03667, 0.94635, 1.23516, 0.9849, 0.99058, 0.92393, 0.8916, 0.942, 1.03667, 0.75026, 0.94635, 1.0297, 1.23516, 0.90918, 0.94048, 0.98217, 0.89746, 0.84153, 0.92274, 0.82507, 0.88832, 0.84438, 0.88178, 1.03525, 0.9849, 1.00225, 0.78086, 0.97248, 0.89404, 1.23516, 0.9849, 0.92274, 0.9849, 0.89404, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89693, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85865, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90933, 1, 1, 1, 1, 1, 1, 0.94309, 0.98986, 0.94309, 0.98986, 0.94309, 0.98986, 0.7306, 0.89453, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.68994, 1.03809, 1, 1, 1.0176, 1.0176, 1.11523, 1.4956, 2.01462, 0.97858, 0.82616, 0.91133, 0.83437, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90572, 1.81055, 0.90749, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85284, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37253. exports.CalibriItalicFactors = CalibriItalicFactors;
  37254. const CalibriItalicMetrics = {
  37255. lineHeight: 1.2207,
  37256. lineGap: 0.2207
  37257. };
  37258. exports.CalibriItalicMetrics = CalibriItalicMetrics;
  37259. const CalibriRegularFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39016, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.73834, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 0.75593, 1.02638, 0.89385, 0.85122, 0.77452, 0.86503, 0.75186, 0.68887, 0.79776, 0.88844, 0.85066, 0.94258, 0.77818, 0.7306, 0.76659, 1.10369, 1.39016, 1.10369, 1.06139, 0.89552, 0.8739, 0.86128, 0.94469, 0.8457, 0.94469, 0.89464, 1.09842, 0.84636, 0.94469, 1.03297, 1.07692, 0.90918, 1.03297, 0.95897, 0.94469, 0.9482, 0.94469, 0.94469, 1.04692, 0.78223, 1.20562, 0.94469, 0.90332, 0.98986, 0.86621, 0.90527, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.08707, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.73834, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89385, 0.85122, 0.85122, 0.85122, 0.85122, 0.85122, 0.85284, 0.85311, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.8693, 0.8457, 0.89464, 0.89464, 0.89464, 0.89464, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.94469, 0.9482, 0.9482, 0.9482, 0.9482, 0.9482, 0.90747, 0.86651, 0.94469, 0.94469, 0.94469, 0.94469, 0.90527, 0.94469, 0.90527, 0.8675, 0.86128, 0.8675, 0.86128, 0.8675, 0.86128, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.85193, 0.92454, 0.86477, 0.9921, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.81105, 0.84636, 0.81105, 0.84636, 0.81105, 0.84636, 1, 1, 0.86275, 0.94469, 0.90872, 0.95786, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77741, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.90452, 0.98156, 1.11842, 0.77261, 1.11429, 0.89385, 0.94469, 1, 1, 0.89385, 0.94469, 0.95877, 0.86901, 0.94469, 0.85122, 0.9482, 0.85122, 0.9482, 0.85122, 0.9482, 0.8667, 0.90016, 0.75186, 1.04692, 1, 1, 0.75186, 1.04692, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 1, 1, 0.79776, 0.92188, 0.79776, 1.23023, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.94258, 0.98986, 0.7306, 0.90527, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.86128, 0.76318, 0.8693, 0.85311, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67742, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.86686, 0.90861, 0.62267, 0.74359, 0.65649, 0.85498, 0.56963, 0.88254, 1.23516, 0.8675, 0.81552, 0.75443, 0.84503, 0.73206, 0.76659, 0.86275, 0.85122, 0.90685, 0.77892, 0.85746, 1.02638, 0.89385, 0.75657, 0.85122, 0.86275, 0.77452, 0.74171, 0.79776, 0.7306, 0.95165, 0.77818, 0.89772, 0.88831, 0.90685, 0.7306, 0.98142, 1.02191, 0.96576, 1.23516, 0.99018, 0.98142, 0.9236, 0.89258, 0.94035, 1.02191, 0.78848, 0.96576, 0.9561, 1.23516, 0.90918, 0.92578, 0.95424, 0.89746, 0.83969, 0.9482, 0.80113, 0.89442, 0.85208, 0.86155, 0.98022, 0.99018, 1.00452, 0.81209, 0.99247, 0.89181, 1.23516, 0.99018, 0.9482, 0.99018, 0.89181, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88844, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89464, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96766, 1, 1, 1, 1, 1, 1, 0.94258, 0.98986, 0.94258, 0.98986, 0.94258, 0.98986, 0.7306, 0.90527, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.69043, 1.03809, 1, 1, 1.0176, 1.0176, 1.11523, 1.4956, 2.01462, 0.99331, 0.82616, 0.91133, 0.84286, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90527, 1.81055, 0.90527, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1.07185, 0.99413, 0.96334, 1.08065, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37260. exports.CalibriRegularFactors = CalibriRegularFactors;
  37261. const CalibriRegularMetrics = {
  37262. lineHeight: 1.2207,
  37263. lineGap: 0.2207
  37264. };
  37265. exports.CalibriRegularMetrics = CalibriRegularMetrics;
  37266. /***/ }),
  37267. /* 53 */
  37268. /***/ ((__unused_webpack_module, exports) => {
  37269. Object.defineProperty(exports, "__esModule", ({
  37270. value: true
  37271. }));
  37272. exports.HelveticaRegularMetrics = exports.HelveticaRegularFactors = exports.HelveticaItalicMetrics = exports.HelveticaItalicFactors = exports.HelveticaBoldMetrics = exports.HelveticaBoldItalicMetrics = exports.HelveticaBoldItalicFactors = exports.HelveticaBoldFactors = void 0;
  37273. const HelveticaBoldFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.03374, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.00042, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.03828, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00034, 0.99977, 1, 0.99997, 1.00026, 1.00078, 1.00036, 0.99973, 1.00013, 1.0006, 0.99977, 0.99977, 0.99988, 0.85148, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 1.00069, 1.00022, 0.99977, 1.00001, 0.99984, 1.00026, 1.00001, 1.00024, 1.00001, 0.9999, 1, 1.0006, 1.00001, 1.00041, 0.99962, 1.00026, 1.0006, 0.99995, 1.00041, 0.99942, 0.99973, 0.99927, 1.00082, 0.99902, 1.00026, 1.00087, 1.0006, 1.00069, 0.99973, 0.99867, 0.99973, 0.9993, 1.00026, 1.00049, 1.00056, 1, 0.99988, 0.99935, 0.99995, 0.99954, 1.00055, 0.99945, 1.00032, 1.0006, 0.99995, 1.00026, 0.99995, 1.00032, 1.00001, 1.00008, 0.99971, 1.00019, 0.9994, 1.00001, 1.0006, 1.00044, 0.99973, 1.00023, 1.00047, 1, 0.99942, 0.99561, 0.99989, 1.00035, 0.99977, 1.00035, 0.99977, 1.00019, 0.99944, 1.00001, 1.00021, 0.99926, 1.00035, 1.00035, 0.99942, 1.00048, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.99989, 1.00057, 1.00001, 0.99936, 1.00052, 1.00012, 0.99996, 1.00043, 1, 1.00035, 0.9994, 0.99976, 1.00035, 0.99973, 1.00052, 1.00041, 1.00119, 1.00037, 0.99973, 1.00002, 0.99986, 1.00041, 1.00041, 0.99902, 0.9996, 1.00034, 0.99999, 1.00026, 0.99999, 1.00026, 0.99973, 1.00052, 0.99973, 1, 0.99973, 1.00041, 1.00075, 0.9994, 1.0003, 0.99999, 1, 1.00041, 0.99955, 1, 0.99915, 0.99973, 0.99973, 1.00026, 1.00119, 0.99955, 0.99973, 1.0006, 0.99911, 1.0006, 1.00026, 0.99972, 1.00026, 0.99902, 1.00041, 0.99973, 0.99999, 1, 1, 1.00038, 1.0005, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 1.00047, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37274. exports.HelveticaBoldFactors = HelveticaBoldFactors;
  37275. const HelveticaBoldMetrics = {
  37276. lineHeight: 1.2,
  37277. lineGap: 0.2
  37278. };
  37279. exports.HelveticaBoldMetrics = HelveticaBoldMetrics;
  37280. const HelveticaBoldItalicFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.0044, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99971, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.01011, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99977, 1, 1, 1.00026, 0.99969, 0.99972, 0.99981, 0.9998, 1.0006, 0.99977, 0.99977, 1.00022, 0.91155, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 0.99966, 1.00022, 1.00032, 1.00001, 0.99944, 1.00026, 1.00001, 0.99968, 1.00001, 1.00047, 1, 1.0006, 1.00001, 0.99981, 1.00101, 1.00026, 1.0006, 0.99948, 0.99981, 1.00064, 0.99973, 0.99942, 1.00101, 1.00061, 1.00026, 1.00069, 1.0006, 1.00014, 0.99973, 1.01322, 0.99973, 1.00065, 1.00026, 1.00012, 0.99923, 1, 1.00064, 1.00076, 0.99948, 1.00055, 1.00063, 1.00007, 0.99943, 1.0006, 0.99948, 1.00026, 0.99948, 0.99943, 1.00001, 1.00001, 1.00029, 1.00038, 1.00035, 1.00001, 1.0006, 1.0006, 0.99973, 0.99978, 1.00001, 1.00057, 0.99989, 0.99967, 0.99964, 0.99967, 0.99977, 0.99999, 0.99977, 1.00038, 0.99977, 1.00001, 0.99973, 1.00066, 0.99967, 0.99967, 1.00041, 0.99998, 0.99999, 0.99977, 1.00022, 0.99967, 1.00001, 0.99977, 1.00026, 0.99964, 1.00031, 1.00001, 0.99999, 0.99999, 1, 1.00023, 1, 1, 0.99999, 1.00035, 1.00001, 0.99999, 0.99973, 0.99977, 0.99999, 1.00058, 0.99973, 0.99973, 0.99955, 0.9995, 1.00026, 1.00026, 1.00032, 0.99989, 1.00034, 0.99999, 1.00026, 1.00026, 1.00026, 0.99973, 0.45998, 0.99973, 1.00026, 0.99973, 1.00001, 0.99999, 0.99982, 0.99994, 0.99996, 1, 1.00042, 1.00044, 1.00029, 1.00023, 0.99973, 0.99973, 1.00026, 0.99949, 1.00002, 0.99973, 1.0006, 1.0006, 1.0006, 0.99975, 1.00026, 1.00026, 1.00032, 0.98685, 0.99973, 1.00026, 1, 1, 0.99966, 1.00044, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1, 0.99973, 0.99971, 0.99978, 1, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00098, 1, 1, 1, 1.00049, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37281. exports.HelveticaBoldItalicFactors = HelveticaBoldItalicFactors;
  37282. const HelveticaBoldItalicMetrics = {
  37283. lineHeight: 1.35,
  37284. lineGap: 0.2
  37285. };
  37286. exports.HelveticaBoldItalicMetrics = HelveticaBoldItalicMetrics;
  37287. const HelveticaItalicFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.0288, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 0.99946, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.06311, 0.99973, 1.00024, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00041, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.89547, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00001, 1, 1.00054, 0.99977, 1.00084, 1.00007, 0.99973, 1.00013, 0.99924, 1.00001, 1.00001, 0.99945, 0.91221, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00001, 0.99999, 0.99977, 0.99933, 1.00022, 1.00054, 1.00001, 1.00065, 1.00026, 1.00001, 1.0001, 1.00001, 1.00052, 1, 1.0006, 1.00001, 0.99945, 0.99897, 0.99968, 0.99924, 1.00036, 0.99945, 0.99949, 1, 1.0006, 0.99897, 0.99918, 0.99968, 0.99911, 0.99924, 1, 0.99962, 1.01487, 1, 1.0005, 0.99973, 1.00012, 1.00043, 1, 0.99995, 0.99994, 1.00036, 0.99947, 1.00019, 1.00063, 1.00025, 0.99924, 1.00036, 0.99973, 1.00036, 1.00025, 1.00001, 1.00001, 1.00027, 1.0001, 1.00068, 1.00001, 1.0006, 1.0006, 1, 1.00008, 0.99957, 0.99972, 0.9994, 0.99954, 0.99975, 1.00051, 1.00001, 1.00019, 1.00001, 1.0001, 0.99986, 1.00001, 1.00001, 1.00038, 0.99954, 0.99954, 0.9994, 1.00066, 0.99999, 0.99977, 1.00022, 1.00054, 1.00001, 0.99977, 1.00026, 0.99975, 1.0001, 1.00001, 0.99993, 0.9995, 0.99955, 1.00016, 0.99978, 0.99974, 1.00019, 1.00022, 0.99955, 1.00053, 0.99973, 1.00089, 1.00005, 0.99967, 1.00048, 0.99973, 1.00002, 1.00034, 0.99973, 0.99973, 0.99964, 1.00006, 1.00066, 0.99947, 0.99973, 0.98894, 0.99973, 1, 0.44898, 1, 0.99946, 1, 1.00039, 1.00082, 0.99991, 0.99991, 0.99985, 1.00022, 1.00023, 1.00061, 1.00006, 0.99966, 0.99973, 0.99973, 0.99973, 1.00019, 1.0008, 1, 0.99924, 0.99924, 0.99924, 0.99983, 1.00044, 0.99973, 0.99964, 0.98332, 1, 0.99973, 1, 1, 0.99962, 0.99895, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 1.00423, 0.99925, 0.99999, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00049, 1, 1.00245, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 1.00003, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37288. exports.HelveticaItalicFactors = HelveticaItalicFactors;
  37289. const HelveticaItalicMetrics = {
  37290. lineHeight: 1.35,
  37291. lineGap: 0.2
  37292. };
  37293. exports.HelveticaItalicMetrics = HelveticaItalicMetrics;
  37294. const HelveticaRegularFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.04596, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 1.00019, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.02572, 0.99973, 1.00005, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99999, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.84533, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99928, 1, 0.99977, 1.00013, 1.00055, 0.99947, 0.99945, 0.99941, 0.99924, 1.00001, 1.00001, 1.0004, 0.91621, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00005, 0.99999, 0.99977, 1.00015, 1.00022, 0.99977, 1.00001, 0.99973, 1.00026, 1.00001, 1.00019, 1.00001, 0.99946, 1, 1.0006, 1.00001, 0.99978, 1.00045, 0.99973, 0.99924, 1.00023, 0.99978, 0.99966, 1, 1.00065, 1.00045, 1.00019, 0.99973, 0.99973, 0.99924, 1, 1, 0.96499, 1, 1.00055, 0.99973, 1.00008, 1.00027, 1, 0.9997, 0.99995, 1.00023, 0.99933, 1.00019, 1.00015, 1.00031, 0.99924, 1.00023, 0.99973, 1.00023, 1.00031, 1.00001, 0.99928, 1.00029, 1.00092, 1.00035, 1.00001, 1.0006, 1.0006, 1, 0.99988, 0.99975, 1, 1.00082, 0.99561, 0.9996, 1.00035, 1.00001, 0.99962, 1.00001, 1.00092, 0.99964, 1.00001, 0.99963, 0.99999, 1.00035, 1.00035, 1.00082, 0.99962, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.9996, 0.99967, 1.00001, 1.00034, 1.00074, 1.00054, 1.00053, 1.00063, 0.99971, 0.99962, 1.00035, 0.99975, 0.99977, 0.99973, 1.00043, 0.99953, 1.0007, 0.99915, 0.99973, 1.00008, 0.99892, 1.00073, 1.00073, 1.00114, 0.99915, 1.00073, 0.99955, 0.99973, 1.00092, 0.99973, 1, 0.99998, 1, 1.0003, 1, 1.00043, 1.00001, 0.99969, 1.0003, 1, 1.00035, 1.00001, 0.9995, 1, 1.00092, 0.99973, 0.99973, 0.99973, 1.0007, 0.9995, 1, 0.99924, 1.0006, 0.99924, 0.99972, 1.00062, 0.99973, 1.00114, 1.00073, 1, 0.99955, 1, 1, 1.00047, 0.99968, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 0.99925, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37295. exports.HelveticaRegularFactors = HelveticaRegularFactors;
  37296. const HelveticaRegularMetrics = {
  37297. lineHeight: 1.2,
  37298. lineGap: 0.2
  37299. };
  37300. exports.HelveticaRegularMetrics = HelveticaRegularMetrics;
  37301. /***/ }),
  37302. /* 54 */
  37303. /***/ ((__unused_webpack_module, exports) => {
  37304. Object.defineProperty(exports, "__esModule", ({
  37305. value: true
  37306. }));
  37307. exports.LiberationSansRegularWidths = exports.LiberationSansRegularMapping = exports.LiberationSansItalicWidths = exports.LiberationSansItalicMapping = exports.LiberationSansBoldWidths = exports.LiberationSansBoldMapping = exports.LiberationSansBoldItalicWidths = exports.LiberationSansBoldItalicMapping = void 0;
  37308. const LiberationSansBoldWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 719, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 785, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 385, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 465, 722, 333, 853, 906, 474, 825, 927, 838, 278, 722, 722, 601, 719, 667, 611, 722, 778, 278, 722, 667, 833, 722, 644, 778, 722, 667, 600, 611, 667, 821, 667, 809, 802, 278, 667, 615, 451, 611, 278, 582, 615, 610, 556, 606, 475, 460, 611, 541, 278, 558, 556, 612, 556, 445, 611, 766, 619, 520, 684, 446, 582, 715, 576, 753, 845, 278, 582, 611, 582, 845, 667, 669, 885, 567, 711, 667, 278, 276, 556, 1094, 1062, 875, 610, 722, 622, 719, 722, 719, 722, 567, 712, 667, 904, 626, 719, 719, 610, 702, 833, 722, 778, 719, 667, 722, 611, 622, 854, 667, 730, 703, 1005, 1019, 870, 979, 719, 711, 1031, 719, 556, 618, 615, 417, 635, 556, 709, 497, 615, 615, 500, 635, 740, 604, 611, 604, 611, 556, 490, 556, 875, 556, 615, 581, 833, 844, 729, 854, 615, 552, 854, 583, 556, 556, 611, 417, 552, 556, 278, 281, 278, 969, 906, 611, 500, 615, 556, 604, 778, 611, 487, 447, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1094, 556, 885, 489, 1115, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333];
  37309. exports.LiberationSansBoldWidths = LiberationSansBoldWidths;
  37310. const LiberationSansBoldMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
  37311. exports.LiberationSansBoldMapping = LiberationSansBoldMapping;
  37312. const LiberationSansBoldItalicWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 740, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 782, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 396, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 722, 333, 854, 906, 473, 844, 930, 847, 278, 722, 722, 610, 671, 667, 611, 722, 778, 278, 722, 667, 833, 722, 657, 778, 718, 667, 590, 611, 667, 822, 667, 829, 781, 278, 667, 620, 479, 611, 278, 591, 620, 621, 556, 610, 479, 492, 611, 558, 278, 566, 556, 603, 556, 450, 611, 712, 605, 532, 664, 409, 591, 704, 578, 773, 834, 278, 591, 611, 591, 834, 667, 667, 886, 614, 719, 667, 278, 278, 556, 1094, 1042, 854, 622, 719, 677, 719, 722, 708, 722, 614, 722, 667, 927, 643, 719, 719, 615, 687, 833, 722, 778, 719, 667, 722, 611, 677, 781, 667, 729, 708, 979, 989, 854, 1000, 708, 719, 1042, 729, 556, 619, 604, 534, 618, 556, 736, 510, 611, 611, 507, 622, 740, 604, 611, 611, 611, 556, 889, 556, 885, 556, 646, 583, 889, 935, 707, 854, 594, 552, 865, 589, 556, 556, 611, 469, 563, 556, 278, 278, 278, 969, 906, 611, 507, 619, 556, 611, 778, 611, 575, 467, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1104, 556, 885, 516, 1146, 1000, 768, 600, 834, 834, 834, 834, 999, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333];
  37313. exports.LiberationSansBoldItalicWidths = LiberationSansBoldItalicWidths;
  37314. const LiberationSansBoldItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
  37315. exports.LiberationSansBoldItalicMapping = LiberationSansBoldItalicMapping;
  37316. const LiberationSansItalicWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 625, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 733, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 281, 556, 400, 556, 222, 722, 556, 722, 556, 722, 556, 615, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 354, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 789, 846, 389, 794, 865, 775, 222, 667, 667, 570, 671, 667, 611, 722, 778, 278, 667, 667, 833, 722, 648, 778, 725, 667, 600, 611, 667, 837, 667, 831, 761, 278, 667, 570, 439, 555, 222, 550, 570, 571, 500, 556, 439, 463, 555, 542, 222, 500, 492, 548, 500, 447, 556, 670, 573, 486, 603, 374, 550, 652, 546, 728, 779, 222, 550, 556, 550, 779, 667, 667, 843, 544, 708, 667, 278, 278, 500, 1066, 982, 844, 589, 715, 639, 724, 667, 651, 667, 544, 704, 667, 917, 614, 715, 715, 589, 686, 833, 722, 778, 725, 667, 722, 611, 639, 795, 667, 727, 673, 920, 923, 805, 886, 651, 694, 1022, 682, 556, 562, 522, 493, 553, 556, 688, 465, 556, 556, 472, 564, 686, 550, 556, 556, 556, 500, 833, 500, 835, 500, 572, 518, 830, 851, 621, 736, 526, 492, 752, 534, 556, 556, 556, 378, 496, 500, 222, 222, 222, 910, 828, 556, 472, 565, 500, 556, 778, 556, 492, 339, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1083, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 998, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 584, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285];
  37317. exports.LiberationSansItalicWidths = LiberationSansItalicWidths;
  37318. const LiberationSansItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
  37319. exports.LiberationSansItalicMapping = LiberationSansItalicMapping;
  37320. const LiberationSansRegularWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 615, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 735, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 292, 556, 334, 556, 222, 722, 556, 722, 556, 722, 556, 604, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 375, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 784, 838, 384, 774, 855, 752, 222, 667, 667, 551, 668, 667, 611, 722, 778, 278, 667, 668, 833, 722, 650, 778, 722, 667, 618, 611, 667, 798, 667, 835, 748, 278, 667, 578, 446, 556, 222, 547, 578, 575, 500, 557, 446, 441, 556, 556, 222, 500, 500, 576, 500, 448, 556, 690, 569, 482, 617, 395, 547, 648, 525, 713, 781, 222, 547, 556, 547, 781, 667, 667, 865, 542, 719, 667, 278, 278, 500, 1057, 1010, 854, 583, 722, 635, 719, 667, 656, 667, 542, 677, 667, 923, 604, 719, 719, 583, 656, 833, 722, 778, 719, 667, 722, 611, 635, 760, 667, 740, 667, 917, 938, 792, 885, 656, 719, 1010, 722, 556, 573, 531, 365, 583, 556, 669, 458, 559, 559, 438, 583, 688, 552, 556, 542, 556, 500, 458, 500, 823, 500, 573, 521, 802, 823, 625, 719, 521, 510, 750, 542, 556, 556, 556, 365, 510, 500, 222, 278, 222, 906, 812, 556, 438, 559, 500, 552, 778, 556, 489, 411, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1073, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285];
  37321. exports.LiberationSansRegularWidths = LiberationSansRegularWidths;
  37322. const LiberationSansRegularMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
  37323. exports.LiberationSansRegularMapping = LiberationSansRegularMapping;
  37324. /***/ }),
  37325. /* 55 */
  37326. /***/ ((__unused_webpack_module, exports) => {
  37327. Object.defineProperty(exports, "__esModule", ({
  37328. value: true
  37329. }));
  37330. exports.MyriadProRegularMetrics = exports.MyriadProRegularFactors = exports.MyriadProItalicMetrics = exports.MyriadProItalicFactors = exports.MyriadProBoldMetrics = exports.MyriadProBoldItalicMetrics = exports.MyriadProBoldItalicFactors = exports.MyriadProBoldFactors = void 0;
  37331. const MyriadProBoldFactors = [1.36898, 1, 1, 0.72706, 0.80479, 0.83734, 0.98894, 0.99793, 0.9897, 0.93884, 0.86209, 0.94292, 0.94292, 1.16661, 1.02058, 0.93582, 0.96694, 0.93582, 1.19137, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.72851, 0.78966, 0.90838, 0.83637, 0.82391, 0.96376, 0.80061, 0.86275, 0.8768, 0.95407, 1.0258, 0.73901, 0.85022, 0.83655, 1.0156, 0.95546, 0.92179, 0.87107, 0.92179, 0.82114, 0.8096, 0.89713, 0.94438, 0.95353, 0.94083, 0.91905, 0.90406, 0.9446, 0.94292, 1.18777, 0.94292, 1.02058, 0.89903, 0.90088, 0.94938, 0.97898, 0.81093, 0.97571, 0.94938, 1.024, 0.9577, 0.95933, 0.98621, 1.0474, 0.97455, 0.98981, 0.9672, 0.95933, 0.9446, 0.97898, 0.97407, 0.97646, 0.78036, 1.10208, 0.95442, 0.95298, 0.97579, 0.9332, 0.94039, 0.938, 0.80687, 1.01149, 0.80687, 1.02058, 0.80479, 0.99793, 0.99793, 0.99793, 0.99793, 1.01149, 1.00872, 0.90088, 0.91882, 1.0213, 0.8361, 1.02058, 0.62295, 0.54324, 0.89022, 1.08595, 1, 1, 0.90088, 1, 0.97455, 0.93582, 0.90088, 1, 1.05686, 0.8361, 0.99642, 0.99642, 0.99642, 0.72851, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.868, 0.82391, 0.80061, 0.80061, 0.80061, 0.80061, 1.0258, 1.0258, 1.0258, 1.0258, 0.97484, 0.95546, 0.92179, 0.92179, 0.92179, 0.92179, 0.92179, 1.02058, 0.92179, 0.94438, 0.94438, 0.94438, 0.94438, 0.90406, 0.86958, 0.98225, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.9031, 0.81093, 0.94938, 0.94938, 0.94938, 0.94938, 0.98621, 0.98621, 0.98621, 0.98621, 0.93969, 0.95933, 0.9446, 0.9446, 0.9446, 0.9446, 0.9446, 1.08595, 0.9446, 0.95442, 0.95442, 0.95442, 0.95442, 0.94039, 0.97898, 0.94039, 0.90838, 0.94938, 0.90838, 0.94938, 0.90838, 0.94938, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.96376, 0.84313, 0.97484, 0.97571, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.8768, 0.9577, 0.8768, 0.9577, 0.8768, 0.9577, 1, 1, 0.95407, 0.95933, 0.97069, 0.95933, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 0.887, 1.01591, 0.73901, 1.0474, 1, 1, 0.97455, 0.83655, 0.98981, 1, 1, 0.83655, 0.73977, 0.83655, 0.73903, 0.84638, 1.033, 0.95546, 0.95933, 1, 1, 0.95546, 0.95933, 0.8271, 0.95417, 0.95933, 0.92179, 0.9446, 0.92179, 0.9446, 0.92179, 0.9446, 0.936, 0.91964, 0.82114, 0.97646, 1, 1, 0.82114, 0.97646, 0.8096, 0.78036, 0.8096, 0.78036, 1, 1, 0.8096, 0.78036, 1, 1, 0.89713, 0.77452, 0.89713, 1.10208, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94083, 0.97579, 0.90406, 0.94039, 0.90406, 0.9446, 0.938, 0.9446, 0.938, 0.9446, 0.938, 1, 0.99793, 0.90838, 0.94938, 0.868, 0.9031, 0.92179, 0.9446, 1, 1, 0.89713, 1.10208, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90989, 0.9358, 0.91945, 0.83181, 0.75261, 0.87992, 0.82976, 0.96034, 0.83689, 0.97268, 1.0078, 0.90838, 0.83637, 0.8019, 0.90157, 0.80061, 0.9446, 0.95407, 0.92436, 1.0258, 0.85022, 0.97153, 1.0156, 0.95546, 0.89192, 0.92179, 0.92361, 0.87107, 0.96318, 0.89713, 0.93704, 0.95638, 0.91905, 0.91709, 0.92796, 1.0258, 0.93704, 0.94836, 1.0373, 0.95933, 1.0078, 0.95871, 0.94836, 0.96174, 0.92601, 0.9498, 0.98607, 0.95776, 0.95933, 1.05453, 1.0078, 0.98275, 0.9314, 0.95617, 0.91701, 1.05993, 0.9446, 0.78367, 0.9553, 1, 0.86832, 1.0128, 0.95871, 0.99394, 0.87548, 0.96361, 0.86774, 1.0078, 0.95871, 0.9446, 0.95871, 0.86774, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.94083, 0.97579, 0.94083, 0.97579, 0.94083, 0.97579, 0.90406, 0.94039, 0.96694, 1, 0.89903, 1, 1, 1, 0.93582, 0.93582, 0.93582, 1, 0.908, 0.908, 0.918, 0.94219, 0.94219, 0.96544, 1, 1.285, 1, 1, 0.81079, 0.81079, 1, 1, 0.74854, 1, 1, 1, 1, 0.99793, 1, 1, 1, 0.65, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.17173, 1, 0.80535, 0.76169, 1.02058, 1.0732, 1.05486, 1, 1, 1.30692, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.16161, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37332. exports.MyriadProBoldFactors = MyriadProBoldFactors;
  37333. const MyriadProBoldMetrics = {
  37334. lineHeight: 1.2,
  37335. lineGap: 0.2
  37336. };
  37337. exports.MyriadProBoldMetrics = MyriadProBoldMetrics;
  37338. const MyriadProBoldItalicFactors = [1.36898, 1, 1, 0.66227, 0.80779, 0.81625, 0.97276, 0.97276, 0.97733, 0.92222, 0.83266, 0.94292, 0.94292, 1.16148, 1.02058, 0.93582, 0.96694, 0.93582, 1.17337, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.71541, 0.76813, 0.85576, 0.80591, 0.80729, 0.94299, 0.77512, 0.83655, 0.86523, 0.92222, 0.98621, 0.71743, 0.81698, 0.79726, 0.98558, 0.92222, 0.90637, 0.83809, 0.90637, 0.80729, 0.76463, 0.86275, 0.90699, 0.91605, 0.9154, 0.85308, 0.85458, 0.90531, 0.94292, 1.21296, 0.94292, 1.02058, 0.89903, 1.18616, 0.99613, 0.91677, 0.78216, 0.91677, 0.90083, 0.98796, 0.9135, 0.92168, 0.95381, 0.98981, 0.95298, 0.95381, 0.93459, 0.92168, 0.91513, 0.92004, 0.91677, 0.95077, 0.748, 1.04502, 0.91677, 0.92061, 0.94236, 0.89544, 0.89364, 0.9, 0.80687, 0.8578, 0.80687, 1.02058, 0.80779, 0.97276, 0.97276, 0.97276, 0.97276, 0.8578, 0.99973, 1.18616, 0.91339, 1.08074, 0.82891, 1.02058, 0.55509, 0.71526, 0.89022, 1.08595, 1, 1, 1.18616, 1, 0.96736, 0.93582, 1.18616, 1, 1.04864, 0.82711, 0.99043, 0.99043, 0.99043, 0.71541, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.845, 0.80729, 0.77512, 0.77512, 0.77512, 0.77512, 0.98621, 0.98621, 0.98621, 0.98621, 0.95961, 0.92222, 0.90637, 0.90637, 0.90637, 0.90637, 0.90637, 1.02058, 0.90251, 0.90699, 0.90699, 0.90699, 0.90699, 0.85458, 0.83659, 0.94951, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.85811, 0.78216, 0.90083, 0.90083, 0.90083, 0.90083, 0.95381, 0.95381, 0.95381, 0.95381, 0.9135, 0.92168, 0.91513, 0.91513, 0.91513, 0.91513, 0.91513, 1.08595, 0.91677, 0.91677, 0.91677, 0.91677, 0.91677, 0.89364, 0.92332, 0.89364, 0.85576, 0.99613, 0.85576, 0.99613, 0.85576, 0.99613, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.94299, 0.76783, 0.95961, 0.91677, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.86523, 0.9135, 0.86523, 0.9135, 0.86523, 0.9135, 1, 1, 0.92222, 0.92168, 0.92222, 0.92168, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.86036, 0.97096, 0.71743, 0.98981, 1, 1, 0.95298, 0.79726, 0.95381, 1, 1, 0.79726, 0.6894, 0.79726, 0.74321, 0.81691, 1.0006, 0.92222, 0.92168, 1, 1, 0.92222, 0.92168, 0.79464, 0.92098, 0.92168, 0.90637, 0.91513, 0.90637, 0.91513, 0.90637, 0.91513, 0.909, 0.87514, 0.80729, 0.95077, 1, 1, 0.80729, 0.95077, 0.76463, 0.748, 0.76463, 0.748, 1, 1, 0.76463, 0.748, 1, 1, 0.86275, 0.72651, 0.86275, 1.04502, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.9154, 0.94236, 0.85458, 0.89364, 0.85458, 0.90531, 0.9, 0.90531, 0.9, 0.90531, 0.9, 1, 0.97276, 0.85576, 0.99613, 0.845, 0.85811, 0.90251, 0.91677, 1, 1, 0.86275, 1.04502, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.00899, 1.30628, 0.85576, 0.80178, 0.66862, 0.7927, 0.69323, 0.88127, 0.72459, 0.89711, 0.95381, 0.85576, 0.80591, 0.7805, 0.94729, 0.77512, 0.90531, 0.92222, 0.90637, 0.98621, 0.81698, 0.92655, 0.98558, 0.92222, 0.85359, 0.90637, 0.90976, 0.83809, 0.94523, 0.86275, 0.83509, 0.93157, 0.85308, 0.83392, 0.92346, 0.98621, 0.83509, 0.92886, 0.91324, 0.92168, 0.95381, 0.90646, 0.92886, 0.90557, 0.86847, 0.90276, 0.91324, 0.86842, 0.92168, 0.99531, 0.95381, 0.9224, 0.85408, 0.92699, 0.86847, 1.0051, 0.91513, 0.80487, 0.93481, 1, 0.88159, 1.05214, 0.90646, 0.97355, 0.81539, 0.89398, 0.85923, 0.95381, 0.90646, 0.91513, 0.90646, 0.85923, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9154, 0.94236, 0.9154, 0.94236, 0.9154, 0.94236, 0.85458, 0.89364, 0.96694, 1, 0.89903, 1, 1, 1, 0.91782, 0.91782, 0.91782, 1, 0.896, 0.896, 0.896, 0.9332, 0.9332, 0.95973, 1, 1.26, 1, 1, 0.80479, 0.80178, 1, 1, 0.85633, 1, 1, 1, 1, 0.97276, 1, 1, 1, 0.698, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.14542, 1, 0.79199, 0.78694, 1.02058, 1.03493, 1.05486, 1, 1, 1.23026, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.20006, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37339. exports.MyriadProBoldItalicFactors = MyriadProBoldItalicFactors;
  37340. const MyriadProBoldItalicMetrics = {
  37341. lineHeight: 1.2,
  37342. lineGap: 0.2
  37343. };
  37344. exports.MyriadProBoldItalicMetrics = MyriadProBoldItalicMetrics;
  37345. const MyriadProItalicFactors = [1.36898, 1, 1, 0.65507, 0.84943, 0.85639, 0.88465, 0.88465, 0.86936, 0.88307, 0.86948, 0.85283, 0.85283, 1.06383, 1.02058, 0.75945, 0.9219, 0.75945, 1.17337, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.75945, 0.75945, 1.02058, 1.02058, 1.02058, 0.69046, 0.70926, 0.85158, 0.77812, 0.76852, 0.89591, 0.70466, 0.76125, 0.80094, 0.86822, 0.83864, 0.728, 0.77212, 0.79475, 0.93637, 0.87514, 0.8588, 0.76013, 0.8588, 0.72421, 0.69866, 0.77598, 0.85991, 0.80811, 0.87832, 0.78112, 0.77512, 0.8562, 1.0222, 1.18417, 1.0222, 1.27014, 0.89903, 1.15012, 0.93859, 0.94399, 0.846, 0.94399, 0.81453, 1.0186, 0.94219, 0.96017, 1.03075, 1.02175, 0.912, 1.03075, 0.96998, 0.96017, 0.93859, 0.94399, 0.94399, 0.95493, 0.746, 1.12658, 0.94578, 0.91, 0.979, 0.882, 0.882, 0.83, 0.85034, 0.83537, 0.85034, 1.02058, 0.70869, 0.88465, 0.88465, 0.88465, 0.88465, 0.83537, 0.90083, 1.15012, 0.9161, 0.94565, 0.73541, 1.02058, 0.53609, 0.69353, 0.79519, 1.08595, 1, 1, 1.15012, 1, 0.91974, 0.75945, 1.15012, 1, 0.9446, 0.73361, 0.9005, 0.9005, 0.9005, 0.62864, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.773, 0.76852, 0.70466, 0.70466, 0.70466, 0.70466, 0.83864, 0.83864, 0.83864, 0.83864, 0.90561, 0.87514, 0.8588, 0.8588, 0.8588, 0.8588, 0.8588, 1.02058, 0.85751, 0.85991, 0.85991, 0.85991, 0.85991, 0.77512, 0.76013, 0.88075, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.8075, 0.846, 0.81453, 0.81453, 0.81453, 0.81453, 0.82424, 0.82424, 0.82424, 0.82424, 0.9278, 0.96017, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 1.08595, 0.8562, 0.94578, 0.94578, 0.94578, 0.94578, 0.882, 0.94578, 0.882, 0.85158, 0.93859, 0.85158, 0.93859, 0.85158, 0.93859, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.89591, 0.8544, 0.90561, 0.94399, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.80094, 0.94219, 0.80094, 0.94219, 0.80094, 0.94219, 1, 1, 0.86822, 0.96017, 0.86822, 0.96017, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 1.03075, 0.83864, 0.82424, 0.81402, 1.02738, 0.728, 1.02175, 1, 1, 0.912, 0.79475, 1.03075, 1, 1, 0.79475, 0.83911, 0.79475, 0.66266, 0.80553, 1.06676, 0.87514, 0.96017, 1, 1, 0.87514, 0.96017, 0.86865, 0.87396, 0.96017, 0.8588, 0.93859, 0.8588, 0.93859, 0.8588, 0.93859, 0.867, 0.84759, 0.72421, 0.95493, 1, 1, 0.72421, 0.95493, 0.69866, 0.746, 0.69866, 0.746, 1, 1, 0.69866, 0.746, 1, 1, 0.77598, 0.88417, 0.77598, 1.12658, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.87832, 0.979, 0.77512, 0.882, 0.77512, 0.8562, 0.83, 0.8562, 0.83, 0.8562, 0.83, 1, 0.88465, 0.85158, 0.93859, 0.773, 0.8075, 0.85751, 0.8562, 1, 1, 0.77598, 1.12658, 1.15012, 1.15012, 1.15012, 1.15012, 1.15012, 1.15313, 1.15012, 1.15012, 1.15012, 1.08106, 1.03901, 0.85158, 0.77025, 0.62264, 0.7646, 0.65351, 0.86026, 0.69461, 0.89947, 1.03075, 0.85158, 0.77812, 0.76449, 0.88836, 0.70466, 0.8562, 0.86822, 0.8588, 0.83864, 0.77212, 0.85308, 0.93637, 0.87514, 0.82352, 0.8588, 0.85701, 0.76013, 0.89058, 0.77598, 0.8156, 0.82565, 0.78112, 0.77899, 0.89386, 0.83864, 0.8156, 0.9486, 0.92388, 0.96186, 1.03075, 0.91123, 0.9486, 0.93298, 0.878, 0.93942, 0.92388, 0.84596, 0.96186, 0.95119, 1.03075, 0.922, 0.88787, 0.95829, 0.88, 0.93559, 0.93859, 0.78815, 0.93758, 1, 0.89217, 1.03737, 0.91123, 0.93969, 0.77487, 0.85769, 0.86799, 1.03075, 0.91123, 0.93859, 0.91123, 0.86799, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87832, 0.979, 0.87832, 0.979, 0.87832, 0.979, 0.77512, 0.882, 0.9219, 1, 0.89903, 1, 1, 1, 0.87321, 0.87321, 0.87321, 1, 1.027, 1.027, 1.027, 0.86847, 0.86847, 0.79121, 1, 1.124, 1, 1, 0.73572, 0.73572, 1, 1, 0.85034, 1, 1, 1, 1, 0.88465, 1, 1, 1, 0.669, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04828, 1, 0.74948, 0.75187, 1.02058, 0.98391, 1.02119, 1, 1, 1.06233, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05233, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37346. exports.MyriadProItalicFactors = MyriadProItalicFactors;
  37347. const MyriadProItalicMetrics = {
  37348. lineHeight: 1.2,
  37349. lineGap: 0.2
  37350. };
  37351. exports.MyriadProItalicMetrics = MyriadProItalicMetrics;
  37352. const MyriadProRegularFactors = [1.36898, 1, 1, 0.76305, 0.82784, 0.94935, 0.89364, 0.92241, 0.89073, 0.90706, 0.98472, 0.85283, 0.85283, 1.0664, 1.02058, 0.74505, 0.9219, 0.74505, 1.23456, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.74505, 0.74505, 1.02058, 1.02058, 1.02058, 0.73002, 0.72601, 0.91755, 0.8126, 0.80314, 0.92222, 0.73764, 0.79726, 0.83051, 0.90284, 0.86023, 0.74, 0.8126, 0.84869, 0.96518, 0.91115, 0.8858, 0.79761, 0.8858, 0.74498, 0.73914, 0.81363, 0.89591, 0.83659, 0.89633, 0.85608, 0.8111, 0.90531, 1.0222, 1.22736, 1.0222, 1.27014, 0.89903, 0.90088, 0.86667, 1.0231, 0.896, 1.01411, 0.90083, 1.05099, 1.00512, 0.99793, 1.05326, 1.09377, 0.938, 1.06226, 1.00119, 0.99793, 0.98714, 1.0231, 1.01231, 0.98196, 0.792, 1.19137, 0.99074, 0.962, 1.01915, 0.926, 0.942, 0.856, 0.85034, 0.92006, 0.85034, 1.02058, 0.69067, 0.92241, 0.92241, 0.92241, 0.92241, 0.92006, 0.9332, 0.90088, 0.91882, 0.93484, 0.75339, 1.02058, 0.56866, 0.54324, 0.79519, 1.08595, 1, 1, 0.90088, 1, 0.95325, 0.74505, 0.90088, 1, 0.97198, 0.75339, 0.91009, 0.91009, 0.91009, 0.66466, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.788, 0.80314, 0.73764, 0.73764, 0.73764, 0.73764, 0.86023, 0.86023, 0.86023, 0.86023, 0.92915, 0.91115, 0.8858, 0.8858, 0.8858, 0.8858, 0.8858, 1.02058, 0.8858, 0.89591, 0.89591, 0.89591, 0.89591, 0.8111, 0.79611, 0.89713, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86936, 0.896, 0.90083, 0.90083, 0.90083, 0.90083, 0.84224, 0.84224, 0.84224, 0.84224, 0.97276, 0.99793, 0.98714, 0.98714, 0.98714, 0.98714, 0.98714, 1.08595, 0.89876, 0.99074, 0.99074, 0.99074, 0.99074, 0.942, 1.0231, 0.942, 0.91755, 0.86667, 0.91755, 0.86667, 0.91755, 0.86667, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.92222, 0.93372, 0.92915, 1.01411, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.83051, 1.00512, 0.83051, 1.00512, 0.83051, 1.00512, 1, 1, 0.90284, 0.99793, 0.90976, 0.99793, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 1.05326, 0.86023, 0.84224, 0.82873, 1.07469, 0.74, 1.09377, 1, 1, 0.938, 0.84869, 1.06226, 1, 1, 0.84869, 0.83704, 0.84869, 0.81441, 0.85588, 1.08927, 0.91115, 0.99793, 1, 1, 0.91115, 0.99793, 0.91887, 0.90991, 0.99793, 0.8858, 0.98714, 0.8858, 0.98714, 0.8858, 0.98714, 0.894, 0.91434, 0.74498, 0.98196, 1, 1, 0.74498, 0.98196, 0.73914, 0.792, 0.73914, 0.792, 1, 1, 0.73914, 0.792, 1, 1, 0.81363, 0.904, 0.81363, 1.19137, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89633, 1.01915, 0.8111, 0.942, 0.8111, 0.90531, 0.856, 0.90531, 0.856, 0.90531, 0.856, 1, 0.92241, 0.91755, 0.86667, 0.788, 0.86936, 0.8858, 0.89876, 1, 1, 0.81363, 1.19137, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90388, 1.03901, 0.92138, 0.78105, 0.7154, 0.86169, 0.80513, 0.94007, 0.82528, 0.98612, 1.06226, 0.91755, 0.8126, 0.81884, 0.92819, 0.73764, 0.90531, 0.90284, 0.8858, 0.86023, 0.8126, 0.91172, 0.96518, 0.91115, 0.83089, 0.8858, 0.87791, 0.79761, 0.89297, 0.81363, 0.88157, 0.89992, 0.85608, 0.81992, 0.94307, 0.86023, 0.88157, 0.95308, 0.98699, 0.99793, 1.06226, 0.95817, 0.95308, 0.97358, 0.928, 0.98088, 0.98699, 0.92761, 0.99793, 0.96017, 1.06226, 0.986, 0.944, 0.95978, 0.938, 0.96705, 0.98714, 0.80442, 0.98972, 1, 0.89762, 1.04552, 0.95817, 0.99007, 0.87064, 0.91879, 0.88888, 1.06226, 0.95817, 0.98714, 0.95817, 0.88888, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89633, 1.01915, 0.89633, 1.01915, 0.89633, 1.01915, 0.8111, 0.942, 0.9219, 1, 0.89903, 1, 1, 1, 0.93173, 0.93173, 0.93173, 1, 1.06304, 1.06304, 1.06904, 0.89903, 0.89903, 0.80549, 1, 1.156, 1, 1, 0.76575, 0.76575, 1, 1, 0.72458, 1, 1, 1, 1, 0.92241, 1, 1, 1, 0.619, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.07257, 1, 0.74705, 0.71119, 1.02058, 1.024, 1.02119, 1, 1, 1.1536, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05638, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37353. exports.MyriadProRegularFactors = MyriadProRegularFactors;
  37354. const MyriadProRegularMetrics = {
  37355. lineHeight: 1.2,
  37356. lineGap: 0.2
  37357. };
  37358. exports.MyriadProRegularMetrics = MyriadProRegularMetrics;
  37359. /***/ }),
  37360. /* 56 */
  37361. /***/ ((__unused_webpack_module, exports) => {
  37362. Object.defineProperty(exports, "__esModule", ({
  37363. value: true
  37364. }));
  37365. exports.SegoeuiRegularMetrics = exports.SegoeuiRegularFactors = exports.SegoeuiItalicMetrics = exports.SegoeuiItalicFactors = exports.SegoeuiBoldMetrics = exports.SegoeuiBoldItalicMetrics = exports.SegoeuiBoldItalicFactors = exports.SegoeuiBoldFactors = void 0;
  37366. const SegoeuiBoldFactors = [1.76738, 1, 1, 0.99297, 0.9824, 1.04016, 1.06497, 1.03424, 0.97529, 1.17647, 1.23203, 1.1085, 1.1085, 1.16939, 1.2107, 0.9754, 1.21408, 0.9754, 1.59578, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 0.81378, 0.81378, 1.2107, 1.2107, 1.2107, 0.71703, 0.97847, 0.97363, 0.88776, 0.8641, 1.02096, 0.79795, 0.85132, 0.914, 1.06085, 1.1406, 0.8007, 0.89858, 0.83693, 1.14889, 1.09398, 0.97489, 0.92094, 0.97489, 0.90399, 0.84041, 0.95923, 1.00135, 1, 1.06467, 0.98243, 0.90996, 0.99361, 1.1085, 1.56942, 1.1085, 1.2107, 0.74627, 0.94282, 0.96752, 1.01519, 0.86304, 1.01359, 0.97278, 1.15103, 1.01359, 0.98561, 1.02285, 1.02285, 1.00527, 1.02285, 1.0302, 0.99041, 1.0008, 1.01519, 1.01359, 1.02258, 0.79104, 1.16862, 0.99041, 0.97454, 1.02511, 0.99298, 0.96752, 0.95801, 0.94856, 1.16579, 0.94856, 1.2107, 0.9824, 1.03424, 1.03424, 1, 1.03424, 1.16579, 0.8727, 1.3871, 1.18622, 1.10818, 1.04478, 1.2107, 1.18622, 0.75155, 0.94994, 1.28826, 1.21408, 1.21408, 0.91056, 1, 0.91572, 0.9754, 0.64663, 1.18328, 1.24866, 1.04478, 1.14169, 1.15749, 1.17389, 0.71703, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.93506, 0.8641, 0.79795, 0.79795, 0.79795, 0.79795, 1.1406, 1.1406, 1.1406, 1.1406, 1.02096, 1.09398, 0.97426, 0.97426, 0.97426, 0.97426, 0.97426, 1.2107, 0.97489, 1.00135, 1.00135, 1.00135, 1.00135, 0.90996, 0.92094, 1.02798, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.93136, 0.86304, 0.97278, 0.97278, 0.97278, 0.97278, 1.02285, 1.02285, 1.02285, 1.02285, 0.97122, 0.99041, 1, 1, 1, 1, 1, 1.28826, 1.0008, 0.99041, 0.99041, 0.99041, 0.99041, 0.96752, 1.01519, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 1.02096, 1.03057, 1.02096, 1.03517, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.914, 1.01359, 0.914, 1.01359, 0.914, 1.01359, 1, 1, 1.06085, 0.98561, 1.06085, 1.00879, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 0.97138, 1.08692, 0.8007, 1.02285, 1, 1, 1.00527, 0.83693, 1.02285, 1, 1, 0.83693, 0.9455, 0.83693, 0.90418, 0.83693, 1.13005, 1.09398, 0.99041, 1, 1, 1.09398, 0.99041, 0.96692, 1.09251, 0.99041, 0.97489, 1.0008, 0.97489, 1.0008, 0.97489, 1.0008, 0.93994, 0.97931, 0.90399, 1.02258, 1, 1, 0.90399, 1.02258, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 1, 1, 0.95923, 1.07034, 0.95923, 1.16862, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.06467, 1.02511, 0.90996, 0.96752, 0.90996, 0.99361, 0.95801, 0.99361, 0.95801, 0.99361, 0.95801, 1.07733, 1.03424, 0.97363, 0.96752, 0.93506, 0.93136, 0.97489, 1.0008, 1, 1, 0.95923, 1.16862, 1.15103, 1.15103, 1.01173, 1.03959, 0.75953, 0.81378, 0.79912, 1.15103, 1.21994, 0.95161, 0.87815, 1.01149, 0.81525, 0.7676, 0.98167, 1.01134, 1.02546, 0.84097, 1.03089, 1.18102, 0.97363, 0.88776, 0.85134, 0.97826, 0.79795, 0.99361, 1.06085, 0.97489, 1.1406, 0.89858, 1.0388, 1.14889, 1.09398, 0.86039, 0.97489, 1.0595, 0.92094, 0.94793, 0.95923, 0.90996, 0.99346, 0.98243, 1.02112, 0.95493, 1.1406, 0.90996, 1.03574, 1.02597, 1.0008, 1.18102, 1.06628, 1.03574, 1.0192, 1.01932, 1.00886, 0.97531, 1.0106, 1.0008, 1.13189, 1.18102, 1.02277, 0.98683, 1.0016, 0.99561, 1.07237, 1.0008, 0.90434, 0.99921, 0.93803, 0.8965, 1.23085, 1.06628, 1.04983, 0.96268, 1.0499, 0.98439, 1.18102, 1.06628, 1.0008, 1.06628, 0.98439, 0.79795, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09466, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.97278, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.02065, 1, 1, 1, 1, 1, 1, 1.06467, 1.02511, 1.06467, 1.02511, 1.06467, 1.02511, 0.90996, 0.96752, 1, 1.21408, 0.89903, 1, 1, 0.75155, 1.04394, 1.04394, 1.04394, 1.04394, 0.98633, 0.98633, 0.98633, 0.73047, 0.73047, 1.20642, 0.91211, 1.25635, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.12454, 0.93503, 1.03424, 1.19687, 1.03424, 1, 1, 1, 0.771, 1, 1, 1.15749, 1.15749, 1.15749, 1.10948, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.16897, 1, 0.96085, 0.90137, 1.2107, 1.18416, 1.13973, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21172, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18874, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.09193, 1.09193, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37367. exports.SegoeuiBoldFactors = SegoeuiBoldFactors;
  37368. const SegoeuiBoldMetrics = {
  37369. lineHeight: 1.33008,
  37370. lineGap: 0
  37371. };
  37372. exports.SegoeuiBoldMetrics = SegoeuiBoldMetrics;
  37373. const SegoeuiBoldItalicFactors = [1.76738, 1, 1, 0.98946, 1.03959, 1.04016, 1.02809, 1.036, 0.97639, 1.10953, 1.23203, 1.11144, 1.11144, 1.16939, 1.21237, 0.9754, 1.21261, 0.9754, 1.59754, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 0.81378, 0.81378, 1.21237, 1.21237, 1.21237, 0.73541, 0.97847, 0.97363, 0.89723, 0.87897, 1.0426, 0.79429, 0.85292, 0.91149, 1.05815, 1.1406, 0.79631, 0.90128, 0.83853, 1.04396, 1.10615, 0.97552, 0.94436, 0.97552, 0.88641, 0.80527, 0.96083, 1.00135, 1, 1.06777, 0.9817, 0.91142, 0.99361, 1.11144, 1.57293, 1.11144, 1.21237, 0.74627, 1.31818, 1.06585, 0.97042, 0.83055, 0.97042, 0.93503, 1.1261, 0.97042, 0.97922, 1.14236, 0.94552, 1.01054, 1.14236, 1.02471, 0.97922, 0.94165, 0.97042, 0.97042, 1.0276, 0.78929, 1.1261, 0.97922, 0.95874, 1.02197, 0.98507, 0.96752, 0.97168, 0.95107, 1.16579, 0.95107, 1.21237, 1.03959, 1.036, 1.036, 1, 1.036, 1.16579, 0.87357, 1.31818, 1.18754, 1.26781, 1.05356, 1.21237, 1.18622, 0.79487, 0.94994, 1.29004, 1.24047, 1.24047, 1.31818, 1, 0.91484, 0.9754, 1.31818, 1.1349, 1.24866, 1.05356, 1.13934, 1.15574, 1.17389, 0.73541, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.94385, 0.87897, 0.79429, 0.79429, 0.79429, 0.79429, 1.1406, 1.1406, 1.1406, 1.1406, 1.0426, 1.10615, 0.97552, 0.97552, 0.97552, 0.97552, 0.97552, 1.21237, 0.97552, 1.00135, 1.00135, 1.00135, 1.00135, 0.91142, 0.94436, 0.98721, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 0.96705, 0.83055, 0.93503, 0.93503, 0.93503, 0.93503, 1.14236, 1.14236, 1.14236, 1.14236, 0.93125, 0.97922, 0.94165, 0.94165, 0.94165, 0.94165, 0.94165, 1.29004, 0.94165, 0.97922, 0.97922, 0.97922, 0.97922, 0.96752, 0.97042, 0.96752, 0.97363, 1.06585, 0.97363, 1.06585, 0.97363, 1.06585, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 1.0426, 1.0033, 1.0426, 0.97042, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.91149, 0.97042, 0.91149, 0.97042, 0.91149, 0.97042, 1, 1, 1.05815, 0.97922, 1.05815, 0.97922, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 0.97441, 1.04302, 0.79631, 1.01582, 1, 1, 1.01054, 0.83853, 1.14236, 1, 1, 0.83853, 1.09125, 0.83853, 0.90418, 0.83853, 1.19508, 1.10615, 0.97922, 1, 1, 1.10615, 0.97922, 1.01034, 1.10466, 0.97922, 0.97552, 0.94165, 0.97552, 0.94165, 0.97552, 0.94165, 0.91602, 0.91981, 0.88641, 1.0276, 1, 1, 0.88641, 1.0276, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 1, 1, 0.96083, 1.05403, 0.95923, 1.16862, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.06777, 1.02197, 0.91142, 0.96752, 0.91142, 0.99361, 0.97168, 0.99361, 0.97168, 0.99361, 0.97168, 1.23199, 1.036, 0.97363, 1.06585, 0.94385, 0.96705, 0.97552, 0.94165, 1, 1, 0.96083, 1.1261, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 0.95161, 1.27126, 1.00811, 0.83284, 0.77702, 0.99137, 0.95253, 1.0347, 0.86142, 1.07205, 1.14236, 0.97363, 0.89723, 0.86869, 1.09818, 0.79429, 0.99361, 1.05815, 0.97552, 1.1406, 0.90128, 1.06662, 1.04396, 1.10615, 0.84918, 0.97552, 1.04694, 0.94436, 0.98015, 0.96083, 0.91142, 1.00356, 0.9817, 1.01945, 0.98999, 1.1406, 0.91142, 1.04961, 0.9898, 1.00639, 1.14236, 1.07514, 1.04961, 0.99607, 1.02897, 1.008, 0.9898, 0.95134, 1.00639, 1.11121, 1.14236, 1.00518, 0.97981, 1.02186, 1, 1.08578, 0.94165, 0.99314, 0.98387, 0.93028, 0.93377, 1.35125, 1.07514, 1.10687, 0.93491, 1.04232, 1.00351, 1.14236, 1.07514, 0.94165, 1.07514, 1.00351, 0.79429, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09097, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.93503, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96609, 1, 1, 1, 1, 1, 1, 1.06777, 1.02197, 1.06777, 1.02197, 1.06777, 1.02197, 0.91142, 0.96752, 1, 1.21261, 0.89903, 1, 1, 0.75155, 1.04745, 1.04745, 1.04745, 1.04394, 0.98633, 0.98633, 0.98633, 0.72959, 0.72959, 1.20502, 0.91406, 1.26514, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.09125, 0.93327, 1.03336, 1.16541, 1.036, 1, 1, 1, 0.771, 1, 1, 1.15574, 1.15574, 1.15574, 1.15574, 0.86364, 0.94434, 0.86279, 0.94434, 0.86224, 1, 1, 1.16798, 1, 0.96085, 0.90068, 1.21237, 1.18416, 1.13904, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21339, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18775, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.13269, 1.13269, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37374. exports.SegoeuiBoldItalicFactors = SegoeuiBoldItalicFactors;
  37375. const SegoeuiBoldItalicMetrics = {
  37376. lineHeight: 1.33008,
  37377. lineGap: 0
  37378. };
  37379. exports.SegoeuiBoldItalicMetrics = SegoeuiBoldItalicMetrics;
  37380. const SegoeuiItalicFactors = [1.76738, 1, 1, 0.98946, 1.14763, 1.05365, 1.06234, 0.96927, 0.92586, 1.15373, 1.18414, 0.91349, 0.91349, 1.07403, 1.17308, 0.78383, 1.20088, 0.78383, 1.42531, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78383, 0.78383, 1.17308, 1.17308, 1.17308, 0.77349, 0.94565, 0.94729, 0.85944, 0.88506, 0.9858, 0.74817, 0.80016, 0.88449, 0.98039, 0.95782, 0.69238, 0.89898, 0.83231, 0.98183, 1.03989, 0.96924, 0.86237, 0.96924, 0.80595, 0.74524, 0.86091, 0.95402, 0.94143, 0.98448, 0.8858, 0.83089, 0.93285, 1.0949, 1.39016, 1.0949, 1.45994, 0.74627, 1.04839, 0.97454, 0.97454, 0.87207, 0.97454, 0.87533, 1.06151, 0.97454, 1.00176, 1.16484, 1.08132, 0.98047, 1.16484, 1.02989, 1.01054, 0.96225, 0.97454, 0.97454, 1.06598, 0.79004, 1.16344, 1.00351, 0.94629, 0.9973, 0.91016, 0.96777, 0.9043, 0.91082, 0.92481, 0.91082, 1.17308, 0.95748, 0.96927, 0.96927, 1, 0.96927, 0.92481, 0.80597, 1.04839, 1.23393, 1.1781, 0.9245, 1.17308, 1.20808, 0.63218, 0.94261, 1.24822, 1.09971, 1.09971, 1.04839, 1, 0.85273, 0.78032, 1.04839, 1.09971, 1.22326, 0.9245, 1.09836, 1.13525, 1.15222, 0.70424, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.85498, 0.88506, 0.74817, 0.74817, 0.74817, 0.74817, 0.95782, 0.95782, 0.95782, 0.95782, 0.9858, 1.03989, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.17308, 0.96924, 0.95402, 0.95402, 0.95402, 0.95402, 0.83089, 0.86237, 0.88409, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.92916, 0.87207, 0.87533, 0.87533, 0.87533, 0.87533, 0.93146, 0.93146, 0.93146, 0.93146, 0.93854, 1.01054, 0.96225, 0.96225, 0.96225, 0.96225, 0.96225, 1.24822, 0.8761, 1.00351, 1.00351, 1.00351, 1.00351, 0.96777, 0.97454, 0.96777, 0.94729, 0.97454, 0.94729, 0.97454, 0.94729, 0.97454, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.9858, 0.95391, 0.9858, 0.97454, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.88449, 0.97454, 0.88449, 0.97454, 0.88449, 0.97454, 1, 1, 0.98039, 1.00176, 0.98039, 1.00176, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 1.16484, 0.95782, 0.93146, 0.84421, 1.12761, 0.69238, 1.08132, 1, 1, 0.98047, 0.83231, 1.16484, 1, 1, 0.84723, 1.04861, 0.84723, 0.78755, 0.83231, 1.23736, 1.03989, 1.01054, 1, 1, 1.03989, 1.01054, 0.9857, 1.03849, 1.01054, 0.96924, 0.96225, 0.96924, 0.96225, 0.96924, 0.96225, 0.92383, 0.90171, 0.80595, 1.06598, 1, 1, 0.80595, 1.06598, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 1, 1, 0.86091, 1.02759, 0.85771, 1.16344, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.98448, 0.9973, 0.83089, 0.96777, 0.83089, 0.93285, 0.9043, 0.93285, 0.9043, 0.93285, 0.9043, 1.31868, 0.96927, 0.94729, 0.97454, 0.85498, 0.92916, 0.96924, 0.8761, 1, 1, 0.86091, 1.16344, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 0.81965, 0.81965, 0.94729, 0.78032, 0.71022, 0.90883, 0.84171, 0.99877, 0.77596, 1.05734, 1.2, 0.94729, 0.85944, 0.82791, 0.9607, 0.74817, 0.93285, 0.98039, 0.96924, 0.95782, 0.89898, 0.98316, 0.98183, 1.03989, 0.78614, 0.96924, 0.97642, 0.86237, 0.86075, 0.86091, 0.83089, 0.90082, 0.8858, 0.97296, 1.01284, 0.95782, 0.83089, 1.0976, 1.04, 1.03342, 1.2, 1.0675, 1.0976, 0.98205, 1.03809, 1.05097, 1.04, 0.95364, 1.03342, 1.05401, 1.2, 1.02148, 1.0119, 1.04724, 1.0127, 1.02732, 0.96225, 0.8965, 0.97783, 0.93574, 0.94818, 1.30679, 1.0675, 1.11826, 0.99821, 1.0557, 1.0326, 1.2, 1.0675, 0.96225, 1.0675, 1.0326, 0.74817, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03754, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87533, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.98705, 1, 1, 1, 1, 1, 1, 0.98448, 0.9973, 0.98448, 0.9973, 0.98448, 0.9973, 0.83089, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 0.94945, 0.94945, 0.94945, 0.94945, 1.12317, 1.12317, 1.12317, 0.67603, 0.67603, 1.15621, 0.73584, 1.21191, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87709, 0.96927, 1.01473, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.09836, 1.09836, 1.09836, 1.01522, 0.86321, 0.94434, 0.8649, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86438, 1.17308, 1.18416, 1.14589, 0.69825, 0.97622, 1.96791, 1.24822, 1.24822, 1.17308, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.17984, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10742, 1.10742, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37381. exports.SegoeuiItalicFactors = SegoeuiItalicFactors;
  37382. const SegoeuiItalicMetrics = {
  37383. lineHeight: 1.33008,
  37384. lineGap: 0
  37385. };
  37386. exports.SegoeuiItalicMetrics = SegoeuiItalicMetrics;
  37387. const SegoeuiRegularFactors = [1.76738, 1, 1, 0.98594, 1.02285, 1.10454, 1.06234, 0.96927, 0.92037, 1.19985, 1.2046, 0.90616, 0.90616, 1.07152, 1.1714, 0.78032, 1.20088, 0.78032, 1.40246, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78032, 0.78032, 1.1714, 1.1714, 1.1714, 0.80597, 0.94084, 0.96706, 0.85944, 0.85734, 0.97093, 0.75842, 0.79936, 0.88198, 0.9831, 0.95782, 0.71387, 0.86969, 0.84636, 1.07796, 1.03584, 0.96924, 0.83968, 0.96924, 0.82826, 0.79649, 0.85771, 0.95132, 0.93119, 0.98965, 0.88433, 0.8287, 0.93365, 1.08612, 1.3638, 1.08612, 1.45786, 0.74627, 0.80499, 0.91484, 1.05707, 0.92383, 1.05882, 0.9403, 1.12654, 1.05882, 1.01756, 1.09011, 1.09011, 0.99414, 1.09011, 1.034, 1.01756, 1.05356, 1.05707, 1.05882, 1.04399, 0.84863, 1.21968, 1.01756, 0.95801, 1.00068, 0.91797, 0.96777, 0.9043, 0.90351, 0.92105, 0.90351, 1.1714, 0.85337, 0.96927, 0.96927, 0.99912, 0.96927, 0.92105, 0.80597, 1.2434, 1.20808, 1.05937, 0.90957, 1.1714, 1.20808, 0.75155, 0.94261, 1.24644, 1.09971, 1.09971, 0.84751, 1, 0.85273, 0.78032, 0.61584, 1.05425, 1.17914, 0.90957, 1.08665, 1.11593, 1.14169, 0.73381, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.86035, 0.85734, 0.75842, 0.75842, 0.75842, 0.75842, 0.95782, 0.95782, 0.95782, 0.95782, 0.97093, 1.03584, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.1714, 0.96924, 0.95132, 0.95132, 0.95132, 0.95132, 0.8287, 0.83968, 0.89049, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.93575, 0.92383, 0.9403, 0.9403, 0.9403, 0.9403, 0.8717, 0.8717, 0.8717, 0.8717, 1.00527, 1.01756, 1.05356, 1.05356, 1.05356, 1.05356, 1.05356, 1.24644, 0.95923, 1.01756, 1.01756, 1.01756, 1.01756, 0.96777, 1.05707, 0.96777, 0.96706, 0.91484, 0.96706, 0.91484, 0.96706, 0.91484, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.97093, 1.0969, 0.97093, 1.05882, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.88198, 1.05882, 0.88198, 1.05882, 0.88198, 1.05882, 1, 1, 0.9831, 1.01756, 0.9831, 1.01756, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 1.09011, 0.95782, 0.8717, 0.84784, 1.11551, 0.71387, 1.09011, 1, 1, 0.99414, 0.84636, 1.09011, 1, 1, 0.84636, 1.0536, 0.84636, 0.94298, 0.84636, 1.23297, 1.03584, 1.01756, 1, 1, 1.03584, 1.01756, 1.00323, 1.03444, 1.01756, 0.96924, 1.05356, 0.96924, 1.05356, 0.96924, 1.05356, 0.93066, 0.98293, 0.82826, 1.04399, 1, 1, 0.82826, 1.04399, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 1, 1, 0.85771, 1.17318, 0.85771, 1.21968, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.98965, 1.00068, 0.8287, 0.96777, 0.8287, 0.93365, 0.9043, 0.93365, 0.9043, 0.93365, 0.9043, 1.08571, 0.96927, 0.96706, 0.91484, 0.86035, 0.93575, 0.96924, 0.95923, 1, 1, 0.85771, 1.21968, 1.11437, 1.11437, 0.93109, 0.91202, 0.60411, 0.84164, 0.55572, 1.01173, 0.97361, 0.81818, 0.81818, 0.96635, 0.78032, 0.72727, 0.92366, 0.98601, 1.03405, 0.77968, 1.09799, 1.2, 0.96706, 0.85944, 0.85638, 0.96491, 0.75842, 0.93365, 0.9831, 0.96924, 0.95782, 0.86969, 0.94152, 1.07796, 1.03584, 0.78437, 0.96924, 0.98715, 0.83968, 0.83491, 0.85771, 0.8287, 0.94492, 0.88433, 0.9287, 1.0098, 0.95782, 0.8287, 1.0625, 0.98248, 1.03424, 1.2, 1.01071, 1.0625, 0.95246, 1.03809, 1.04912, 0.98248, 1.00221, 1.03424, 1.05443, 1.2, 1.04785, 0.99609, 1.00169, 1.05176, 0.99346, 1.05356, 0.9087, 1.03004, 0.95542, 0.93117, 1.23362, 1.01071, 1.07831, 1.02512, 1.05205, 1.03502, 1.2, 1.01071, 1.05356, 1.01071, 1.03502, 0.75842, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03719, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9403, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04021, 1, 1, 1, 1, 1, 1, 0.98965, 1.00068, 0.98965, 1.00068, 0.98965, 1.00068, 0.8287, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 1.03077, 1.03077, 1.03077, 1.03077, 1.13196, 1.13196, 1.13196, 0.67428, 0.67428, 1.16039, 0.73291, 1.20996, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87796, 0.96927, 1.01518, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.10539, 1.10539, 1.11358, 1.06967, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86507, 1.1714, 1.18416, 1.14589, 0.69825, 0.97622, 1.9697, 1.24822, 1.24822, 1.17238, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18083, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10938, 1.10938, 1, 1, 1, 1.05425, 1.09971, 1.09971, 1.09971, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  37388. exports.SegoeuiRegularFactors = SegoeuiRegularFactors;
  37389. const SegoeuiRegularMetrics = {
  37390. lineHeight: 1.33008,
  37391. lineGap: 0
  37392. };
  37393. exports.SegoeuiRegularMetrics = SegoeuiRegularMetrics;
  37394. /***/ }),
  37395. /* 57 */
  37396. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37397. Object.defineProperty(exports, "__esModule", ({
  37398. value: true
  37399. }));
  37400. exports.PostScriptEvaluator = exports.PostScriptCompiler = exports.PDFFunctionFactory = void 0;
  37401. exports.isPDFFunction = isPDFFunction;
  37402. var _primitives = __w_pdfjs_require__(4);
  37403. var _util = __w_pdfjs_require__(2);
  37404. var _ps_parser = __w_pdfjs_require__(58);
  37405. var _base_stream = __w_pdfjs_require__(5);
  37406. var _image_utils = __w_pdfjs_require__(59);
  37407. class PDFFunctionFactory {
  37408. constructor({
  37409. xref,
  37410. isEvalSupported = true
  37411. }) {
  37412. this.xref = xref;
  37413. this.isEvalSupported = isEvalSupported !== false;
  37414. }
  37415. create(fn) {
  37416. const cachedFunction = this.getCached(fn);
  37417. if (cachedFunction) {
  37418. return cachedFunction;
  37419. }
  37420. const parsedFunction = PDFFunction.parse({
  37421. xref: this.xref,
  37422. isEvalSupported: this.isEvalSupported,
  37423. fn: fn instanceof _primitives.Ref ? this.xref.fetch(fn) : fn
  37424. });
  37425. this._cache(fn, parsedFunction);
  37426. return parsedFunction;
  37427. }
  37428. createFromArray(fnObj) {
  37429. const cachedFunction = this.getCached(fnObj);
  37430. if (cachedFunction) {
  37431. return cachedFunction;
  37432. }
  37433. const parsedFunction = PDFFunction.parseArray({
  37434. xref: this.xref,
  37435. isEvalSupported: this.isEvalSupported,
  37436. fnObj: fnObj instanceof _primitives.Ref ? this.xref.fetch(fnObj) : fnObj
  37437. });
  37438. this._cache(fnObj, parsedFunction);
  37439. return parsedFunction;
  37440. }
  37441. getCached(cacheKey) {
  37442. let fnRef;
  37443. if (cacheKey instanceof _primitives.Ref) {
  37444. fnRef = cacheKey;
  37445. } else if (cacheKey instanceof _primitives.Dict) {
  37446. fnRef = cacheKey.objId;
  37447. } else if (cacheKey instanceof _base_stream.BaseStream) {
  37448. fnRef = cacheKey.dict?.objId;
  37449. }
  37450. if (fnRef) {
  37451. const localFunction = this._localFunctionCache.getByRef(fnRef);
  37452. if (localFunction) {
  37453. return localFunction;
  37454. }
  37455. }
  37456. return null;
  37457. }
  37458. _cache(cacheKey, parsedFunction) {
  37459. if (!parsedFunction) {
  37460. throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.');
  37461. }
  37462. let fnRef;
  37463. if (cacheKey instanceof _primitives.Ref) {
  37464. fnRef = cacheKey;
  37465. } else if (cacheKey instanceof _primitives.Dict) {
  37466. fnRef = cacheKey.objId;
  37467. } else if (cacheKey instanceof _base_stream.BaseStream) {
  37468. fnRef = cacheKey.dict?.objId;
  37469. }
  37470. if (fnRef) {
  37471. this._localFunctionCache.set(null, fnRef, parsedFunction);
  37472. }
  37473. }
  37474. get _localFunctionCache() {
  37475. return (0, _util.shadow)(this, "_localFunctionCache", new _image_utils.LocalFunctionCache());
  37476. }
  37477. }
  37478. exports.PDFFunctionFactory = PDFFunctionFactory;
  37479. function toNumberArray(arr) {
  37480. if (!Array.isArray(arr)) {
  37481. return null;
  37482. }
  37483. const length = arr.length;
  37484. for (let i = 0; i < length; i++) {
  37485. if (typeof arr[i] !== "number") {
  37486. const result = new Array(length);
  37487. for (let j = 0; j < length; j++) {
  37488. result[j] = +arr[j];
  37489. }
  37490. return result;
  37491. }
  37492. }
  37493. return arr;
  37494. }
  37495. class PDFFunction {
  37496. static getSampleArray(size, outputSize, bps, stream) {
  37497. let i, ii;
  37498. let length = 1;
  37499. for (i = 0, ii = size.length; i < ii; i++) {
  37500. length *= size[i];
  37501. }
  37502. length *= outputSize;
  37503. const array = new Array(length);
  37504. let codeSize = 0;
  37505. let codeBuf = 0;
  37506. const sampleMul = 1.0 / (2.0 ** bps - 1);
  37507. const strBytes = stream.getBytes((length * bps + 7) / 8);
  37508. let strIdx = 0;
  37509. for (i = 0; i < length; i++) {
  37510. while (codeSize < bps) {
  37511. codeBuf <<= 8;
  37512. codeBuf |= strBytes[strIdx++];
  37513. codeSize += 8;
  37514. }
  37515. codeSize -= bps;
  37516. array[i] = (codeBuf >> codeSize) * sampleMul;
  37517. codeBuf &= (1 << codeSize) - 1;
  37518. }
  37519. return array;
  37520. }
  37521. static parse({
  37522. xref,
  37523. isEvalSupported,
  37524. fn
  37525. }) {
  37526. const dict = fn.dict || fn;
  37527. const typeNum = dict.get("FunctionType");
  37528. switch (typeNum) {
  37529. case 0:
  37530. return this.constructSampled({
  37531. xref,
  37532. isEvalSupported,
  37533. fn,
  37534. dict
  37535. });
  37536. case 1:
  37537. break;
  37538. case 2:
  37539. return this.constructInterpolated({
  37540. xref,
  37541. isEvalSupported,
  37542. dict
  37543. });
  37544. case 3:
  37545. return this.constructStiched({
  37546. xref,
  37547. isEvalSupported,
  37548. dict
  37549. });
  37550. case 4:
  37551. return this.constructPostScript({
  37552. xref,
  37553. isEvalSupported,
  37554. fn,
  37555. dict
  37556. });
  37557. }
  37558. throw new _util.FormatError("Unknown type of function");
  37559. }
  37560. static parseArray({
  37561. xref,
  37562. isEvalSupported,
  37563. fnObj
  37564. }) {
  37565. if (!Array.isArray(fnObj)) {
  37566. return this.parse({
  37567. xref,
  37568. isEvalSupported,
  37569. fn: fnObj
  37570. });
  37571. }
  37572. const fnArray = [];
  37573. for (const fn of fnObj) {
  37574. fnArray.push(this.parse({
  37575. xref,
  37576. isEvalSupported,
  37577. fn: xref.fetchIfRef(fn)
  37578. }));
  37579. }
  37580. return function (src, srcOffset, dest, destOffset) {
  37581. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  37582. fnArray[i](src, srcOffset, dest, destOffset + i);
  37583. }
  37584. };
  37585. }
  37586. static constructSampled({
  37587. xref,
  37588. isEvalSupported,
  37589. fn,
  37590. dict
  37591. }) {
  37592. function toMultiArray(arr) {
  37593. const inputLength = arr.length;
  37594. const out = [];
  37595. let index = 0;
  37596. for (let i = 0; i < inputLength; i += 2) {
  37597. out[index++] = [arr[i], arr[i + 1]];
  37598. }
  37599. return out;
  37600. }
  37601. function interpolate(x, xmin, xmax, ymin, ymax) {
  37602. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  37603. }
  37604. let domain = toNumberArray(dict.getArray("Domain"));
  37605. let range = toNumberArray(dict.getArray("Range"));
  37606. if (!domain || !range) {
  37607. throw new _util.FormatError("No domain or range");
  37608. }
  37609. const inputSize = domain.length / 2;
  37610. const outputSize = range.length / 2;
  37611. domain = toMultiArray(domain);
  37612. range = toMultiArray(range);
  37613. const size = toNumberArray(dict.getArray("Size"));
  37614. const bps = dict.get("BitsPerSample");
  37615. const order = dict.get("Order") || 1;
  37616. if (order !== 1) {
  37617. (0, _util.info)("No support for cubic spline interpolation: " + order);
  37618. }
  37619. let encode = toNumberArray(dict.getArray("Encode"));
  37620. if (!encode) {
  37621. encode = [];
  37622. for (let i = 0; i < inputSize; ++i) {
  37623. encode.push([0, size[i] - 1]);
  37624. }
  37625. } else {
  37626. encode = toMultiArray(encode);
  37627. }
  37628. let decode = toNumberArray(dict.getArray("Decode"));
  37629. decode = !decode ? range : toMultiArray(decode);
  37630. const samples = this.getSampleArray(size, outputSize, bps, fn);
  37631. return function constructSampledFn(src, srcOffset, dest, destOffset) {
  37632. const cubeVertices = 1 << inputSize;
  37633. const cubeN = new Float64Array(cubeVertices);
  37634. const cubeVertex = new Uint32Array(cubeVertices);
  37635. let i, j;
  37636. for (j = 0; j < cubeVertices; j++) {
  37637. cubeN[j] = 1;
  37638. }
  37639. let k = outputSize,
  37640. pos = 1;
  37641. for (i = 0; i < inputSize; ++i) {
  37642. const domain_2i = domain[i][0];
  37643. const domain_2i_1 = domain[i][1];
  37644. const xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  37645. let e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  37646. const size_i = size[i];
  37647. e = Math.min(Math.max(e, 0), size_i - 1);
  37648. const e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  37649. const n0 = e0 + 1 - e;
  37650. const n1 = e - e0;
  37651. const offset0 = e0 * k;
  37652. const offset1 = offset0 + k;
  37653. for (j = 0; j < cubeVertices; j++) {
  37654. if (j & pos) {
  37655. cubeN[j] *= n1;
  37656. cubeVertex[j] += offset1;
  37657. } else {
  37658. cubeN[j] *= n0;
  37659. cubeVertex[j] += offset0;
  37660. }
  37661. }
  37662. k *= size_i;
  37663. pos <<= 1;
  37664. }
  37665. for (j = 0; j < outputSize; ++j) {
  37666. let rj = 0;
  37667. for (i = 0; i < cubeVertices; i++) {
  37668. rj += samples[cubeVertex[i] + j] * cubeN[i];
  37669. }
  37670. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  37671. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  37672. }
  37673. };
  37674. }
  37675. static constructInterpolated({
  37676. xref,
  37677. isEvalSupported,
  37678. dict
  37679. }) {
  37680. const c0 = toNumberArray(dict.getArray("C0")) || [0];
  37681. const c1 = toNumberArray(dict.getArray("C1")) || [1];
  37682. const n = dict.get("N");
  37683. const diff = [];
  37684. for (let i = 0, ii = c0.length; i < ii; ++i) {
  37685. diff.push(c1[i] - c0[i]);
  37686. }
  37687. const length = diff.length;
  37688. return function constructInterpolatedFn(src, srcOffset, dest, destOffset) {
  37689. const x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
  37690. for (let j = 0; j < length; ++j) {
  37691. dest[destOffset + j] = c0[j] + x * diff[j];
  37692. }
  37693. };
  37694. }
  37695. static constructStiched({
  37696. xref,
  37697. isEvalSupported,
  37698. dict
  37699. }) {
  37700. const domain = toNumberArray(dict.getArray("Domain"));
  37701. if (!domain) {
  37702. throw new _util.FormatError("No domain");
  37703. }
  37704. const inputSize = domain.length / 2;
  37705. if (inputSize !== 1) {
  37706. throw new _util.FormatError("Bad domain for stiched function");
  37707. }
  37708. const fns = [];
  37709. for (const fn of dict.get("Functions")) {
  37710. fns.push(this.parse({
  37711. xref,
  37712. isEvalSupported,
  37713. fn: xref.fetchIfRef(fn)
  37714. }));
  37715. }
  37716. const bounds = toNumberArray(dict.getArray("Bounds"));
  37717. const encode = toNumberArray(dict.getArray("Encode"));
  37718. const tmpBuf = new Float32Array(1);
  37719. return function constructStichedFn(src, srcOffset, dest, destOffset) {
  37720. const clip = function constructStichedFromIRClip(v, min, max) {
  37721. if (v > max) {
  37722. v = max;
  37723. } else if (v < min) {
  37724. v = min;
  37725. }
  37726. return v;
  37727. };
  37728. const v = clip(src[srcOffset], domain[0], domain[1]);
  37729. const length = bounds.length;
  37730. let i;
  37731. for (i = 0; i < length; ++i) {
  37732. if (v < bounds[i]) {
  37733. break;
  37734. }
  37735. }
  37736. let dmin = domain[0];
  37737. if (i > 0) {
  37738. dmin = bounds[i - 1];
  37739. }
  37740. let dmax = domain[1];
  37741. if (i < bounds.length) {
  37742. dmax = bounds[i];
  37743. }
  37744. const rmin = encode[2 * i];
  37745. const rmax = encode[2 * i + 1];
  37746. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  37747. fns[i](tmpBuf, 0, dest, destOffset);
  37748. };
  37749. }
  37750. static constructPostScript({
  37751. xref,
  37752. isEvalSupported,
  37753. fn,
  37754. dict
  37755. }) {
  37756. const domain = toNumberArray(dict.getArray("Domain"));
  37757. const range = toNumberArray(dict.getArray("Range"));
  37758. if (!domain) {
  37759. throw new _util.FormatError("No domain.");
  37760. }
  37761. if (!range) {
  37762. throw new _util.FormatError("No range.");
  37763. }
  37764. const lexer = new _ps_parser.PostScriptLexer(fn);
  37765. const parser = new _ps_parser.PostScriptParser(lexer);
  37766. const code = parser.parse();
  37767. if (isEvalSupported && _util.FeatureTest.isEvalSupported) {
  37768. const compiled = new PostScriptCompiler().compile(code, domain, range);
  37769. if (compiled) {
  37770. return new Function("src", "srcOffset", "dest", "destOffset", compiled);
  37771. }
  37772. }
  37773. (0, _util.info)("Unable to compile PS function");
  37774. const numOutputs = range.length >> 1;
  37775. const numInputs = domain.length >> 1;
  37776. const evaluator = new PostScriptEvaluator(code);
  37777. const cache = Object.create(null);
  37778. const MAX_CACHE_SIZE = 2048 * 4;
  37779. let cache_available = MAX_CACHE_SIZE;
  37780. const tmpBuf = new Float32Array(numInputs);
  37781. return function constructPostScriptFn(src, srcOffset, dest, destOffset) {
  37782. let i, value;
  37783. let key = "";
  37784. const input = tmpBuf;
  37785. for (i = 0; i < numInputs; i++) {
  37786. value = src[srcOffset + i];
  37787. input[i] = value;
  37788. key += value + "_";
  37789. }
  37790. const cachedValue = cache[key];
  37791. if (cachedValue !== undefined) {
  37792. dest.set(cachedValue, destOffset);
  37793. return;
  37794. }
  37795. const output = new Float32Array(numOutputs);
  37796. const stack = evaluator.execute(input);
  37797. const stackIndex = stack.length - numOutputs;
  37798. for (i = 0; i < numOutputs; i++) {
  37799. value = stack[stackIndex + i];
  37800. let bound = range[i * 2];
  37801. if (value < bound) {
  37802. value = bound;
  37803. } else {
  37804. bound = range[i * 2 + 1];
  37805. if (value > bound) {
  37806. value = bound;
  37807. }
  37808. }
  37809. output[i] = value;
  37810. }
  37811. if (cache_available > 0) {
  37812. cache_available--;
  37813. cache[key] = output;
  37814. }
  37815. dest.set(output, destOffset);
  37816. };
  37817. }
  37818. }
  37819. function isPDFFunction(v) {
  37820. let fnDict;
  37821. if (v instanceof _primitives.Dict) {
  37822. fnDict = v;
  37823. } else if (v instanceof _base_stream.BaseStream) {
  37824. fnDict = v.dict;
  37825. } else {
  37826. return false;
  37827. }
  37828. return fnDict.has("FunctionType");
  37829. }
  37830. class PostScriptStack {
  37831. static MAX_STACK_SIZE = 100;
  37832. constructor(initialStack) {
  37833. this.stack = initialStack ? Array.from(initialStack) : [];
  37834. }
  37835. push(value) {
  37836. if (this.stack.length >= PostScriptStack.MAX_STACK_SIZE) {
  37837. throw new Error("PostScript function stack overflow.");
  37838. }
  37839. this.stack.push(value);
  37840. }
  37841. pop() {
  37842. if (this.stack.length <= 0) {
  37843. throw new Error("PostScript function stack underflow.");
  37844. }
  37845. return this.stack.pop();
  37846. }
  37847. copy(n) {
  37848. if (this.stack.length + n >= PostScriptStack.MAX_STACK_SIZE) {
  37849. throw new Error("PostScript function stack overflow.");
  37850. }
  37851. const stack = this.stack;
  37852. for (let i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  37853. stack.push(stack[i]);
  37854. }
  37855. }
  37856. index(n) {
  37857. this.push(this.stack[this.stack.length - n - 1]);
  37858. }
  37859. roll(n, p) {
  37860. const stack = this.stack;
  37861. const l = stack.length - n;
  37862. const r = stack.length - 1;
  37863. const c = l + (p - Math.floor(p / n) * n);
  37864. for (let i = l, j = r; i < j; i++, j--) {
  37865. const t = stack[i];
  37866. stack[i] = stack[j];
  37867. stack[j] = t;
  37868. }
  37869. for (let i = l, j = c - 1; i < j; i++, j--) {
  37870. const t = stack[i];
  37871. stack[i] = stack[j];
  37872. stack[j] = t;
  37873. }
  37874. for (let i = c, j = r; i < j; i++, j--) {
  37875. const t = stack[i];
  37876. stack[i] = stack[j];
  37877. stack[j] = t;
  37878. }
  37879. }
  37880. }
  37881. class PostScriptEvaluator {
  37882. constructor(operators) {
  37883. this.operators = operators;
  37884. }
  37885. execute(initialStack) {
  37886. const stack = new PostScriptStack(initialStack);
  37887. let counter = 0;
  37888. const operators = this.operators;
  37889. const length = operators.length;
  37890. let operator, a, b;
  37891. while (counter < length) {
  37892. operator = operators[counter++];
  37893. if (typeof operator === "number") {
  37894. stack.push(operator);
  37895. continue;
  37896. }
  37897. switch (operator) {
  37898. case "jz":
  37899. b = stack.pop();
  37900. a = stack.pop();
  37901. if (!a) {
  37902. counter = b;
  37903. }
  37904. break;
  37905. case "j":
  37906. a = stack.pop();
  37907. counter = a;
  37908. break;
  37909. case "abs":
  37910. a = stack.pop();
  37911. stack.push(Math.abs(a));
  37912. break;
  37913. case "add":
  37914. b = stack.pop();
  37915. a = stack.pop();
  37916. stack.push(a + b);
  37917. break;
  37918. case "and":
  37919. b = stack.pop();
  37920. a = stack.pop();
  37921. if (typeof a === "boolean" && typeof b === "boolean") {
  37922. stack.push(a && b);
  37923. } else {
  37924. stack.push(a & b);
  37925. }
  37926. break;
  37927. case "atan":
  37928. b = stack.pop();
  37929. a = stack.pop();
  37930. a = Math.atan2(a, b) / Math.PI * 180;
  37931. if (a < 0) {
  37932. a += 360;
  37933. }
  37934. stack.push(a);
  37935. break;
  37936. case "bitshift":
  37937. b = stack.pop();
  37938. a = stack.pop();
  37939. if (a > 0) {
  37940. stack.push(a << b);
  37941. } else {
  37942. stack.push(a >> b);
  37943. }
  37944. break;
  37945. case "ceiling":
  37946. a = stack.pop();
  37947. stack.push(Math.ceil(a));
  37948. break;
  37949. case "copy":
  37950. a = stack.pop();
  37951. stack.copy(a);
  37952. break;
  37953. case "cos":
  37954. a = stack.pop();
  37955. stack.push(Math.cos(a % 360 / 180 * Math.PI));
  37956. break;
  37957. case "cvi":
  37958. a = stack.pop() | 0;
  37959. stack.push(a);
  37960. break;
  37961. case "cvr":
  37962. break;
  37963. case "div":
  37964. b = stack.pop();
  37965. a = stack.pop();
  37966. stack.push(a / b);
  37967. break;
  37968. case "dup":
  37969. stack.copy(1);
  37970. break;
  37971. case "eq":
  37972. b = stack.pop();
  37973. a = stack.pop();
  37974. stack.push(a === b);
  37975. break;
  37976. case "exch":
  37977. stack.roll(2, 1);
  37978. break;
  37979. case "exp":
  37980. b = stack.pop();
  37981. a = stack.pop();
  37982. stack.push(a ** b);
  37983. break;
  37984. case "false":
  37985. stack.push(false);
  37986. break;
  37987. case "floor":
  37988. a = stack.pop();
  37989. stack.push(Math.floor(a));
  37990. break;
  37991. case "ge":
  37992. b = stack.pop();
  37993. a = stack.pop();
  37994. stack.push(a >= b);
  37995. break;
  37996. case "gt":
  37997. b = stack.pop();
  37998. a = stack.pop();
  37999. stack.push(a > b);
  38000. break;
  38001. case "idiv":
  38002. b = stack.pop();
  38003. a = stack.pop();
  38004. stack.push(a / b | 0);
  38005. break;
  38006. case "index":
  38007. a = stack.pop();
  38008. stack.index(a);
  38009. break;
  38010. case "le":
  38011. b = stack.pop();
  38012. a = stack.pop();
  38013. stack.push(a <= b);
  38014. break;
  38015. case "ln":
  38016. a = stack.pop();
  38017. stack.push(Math.log(a));
  38018. break;
  38019. case "log":
  38020. a = stack.pop();
  38021. stack.push(Math.log10(a));
  38022. break;
  38023. case "lt":
  38024. b = stack.pop();
  38025. a = stack.pop();
  38026. stack.push(a < b);
  38027. break;
  38028. case "mod":
  38029. b = stack.pop();
  38030. a = stack.pop();
  38031. stack.push(a % b);
  38032. break;
  38033. case "mul":
  38034. b = stack.pop();
  38035. a = stack.pop();
  38036. stack.push(a * b);
  38037. break;
  38038. case "ne":
  38039. b = stack.pop();
  38040. a = stack.pop();
  38041. stack.push(a !== b);
  38042. break;
  38043. case "neg":
  38044. a = stack.pop();
  38045. stack.push(-a);
  38046. break;
  38047. case "not":
  38048. a = stack.pop();
  38049. if (typeof a === "boolean") {
  38050. stack.push(!a);
  38051. } else {
  38052. stack.push(~a);
  38053. }
  38054. break;
  38055. case "or":
  38056. b = stack.pop();
  38057. a = stack.pop();
  38058. if (typeof a === "boolean" && typeof b === "boolean") {
  38059. stack.push(a || b);
  38060. } else {
  38061. stack.push(a | b);
  38062. }
  38063. break;
  38064. case "pop":
  38065. stack.pop();
  38066. break;
  38067. case "roll":
  38068. b = stack.pop();
  38069. a = stack.pop();
  38070. stack.roll(a, b);
  38071. break;
  38072. case "round":
  38073. a = stack.pop();
  38074. stack.push(Math.round(a));
  38075. break;
  38076. case "sin":
  38077. a = stack.pop();
  38078. stack.push(Math.sin(a % 360 / 180 * Math.PI));
  38079. break;
  38080. case "sqrt":
  38081. a = stack.pop();
  38082. stack.push(Math.sqrt(a));
  38083. break;
  38084. case "sub":
  38085. b = stack.pop();
  38086. a = stack.pop();
  38087. stack.push(a - b);
  38088. break;
  38089. case "true":
  38090. stack.push(true);
  38091. break;
  38092. case "truncate":
  38093. a = stack.pop();
  38094. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  38095. stack.push(a);
  38096. break;
  38097. case "xor":
  38098. b = stack.pop();
  38099. a = stack.pop();
  38100. if (typeof a === "boolean" && typeof b === "boolean") {
  38101. stack.push(a !== b);
  38102. } else {
  38103. stack.push(a ^ b);
  38104. }
  38105. break;
  38106. default:
  38107. throw new _util.FormatError(`Unknown operator ${operator}`);
  38108. }
  38109. }
  38110. return stack.stack;
  38111. }
  38112. }
  38113. exports.PostScriptEvaluator = PostScriptEvaluator;
  38114. class AstNode {
  38115. constructor(type) {
  38116. this.type = type;
  38117. }
  38118. visit(visitor) {
  38119. (0, _util.unreachable)("abstract method");
  38120. }
  38121. }
  38122. class AstArgument extends AstNode {
  38123. constructor(index, min, max) {
  38124. super("args");
  38125. this.index = index;
  38126. this.min = min;
  38127. this.max = max;
  38128. }
  38129. visit(visitor) {
  38130. visitor.visitArgument(this);
  38131. }
  38132. }
  38133. class AstLiteral extends AstNode {
  38134. constructor(number) {
  38135. super("literal");
  38136. this.number = number;
  38137. this.min = number;
  38138. this.max = number;
  38139. }
  38140. visit(visitor) {
  38141. visitor.visitLiteral(this);
  38142. }
  38143. }
  38144. class AstBinaryOperation extends AstNode {
  38145. constructor(op, arg1, arg2, min, max) {
  38146. super("binary");
  38147. this.op = op;
  38148. this.arg1 = arg1;
  38149. this.arg2 = arg2;
  38150. this.min = min;
  38151. this.max = max;
  38152. }
  38153. visit(visitor) {
  38154. visitor.visitBinaryOperation(this);
  38155. }
  38156. }
  38157. class AstMin extends AstNode {
  38158. constructor(arg, max) {
  38159. super("max");
  38160. this.arg = arg;
  38161. this.min = arg.min;
  38162. this.max = max;
  38163. }
  38164. visit(visitor) {
  38165. visitor.visitMin(this);
  38166. }
  38167. }
  38168. class AstVariable extends AstNode {
  38169. constructor(index, min, max) {
  38170. super("var");
  38171. this.index = index;
  38172. this.min = min;
  38173. this.max = max;
  38174. }
  38175. visit(visitor) {
  38176. visitor.visitVariable(this);
  38177. }
  38178. }
  38179. class AstVariableDefinition extends AstNode {
  38180. constructor(variable, arg) {
  38181. super("definition");
  38182. this.variable = variable;
  38183. this.arg = arg;
  38184. }
  38185. visit(visitor) {
  38186. visitor.visitVariableDefinition(this);
  38187. }
  38188. }
  38189. class ExpressionBuilderVisitor {
  38190. constructor() {
  38191. this.parts = [];
  38192. }
  38193. visitArgument(arg) {
  38194. this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
  38195. }
  38196. visitVariable(variable) {
  38197. this.parts.push("v", variable.index);
  38198. }
  38199. visitLiteral(literal) {
  38200. this.parts.push(literal.number);
  38201. }
  38202. visitBinaryOperation(operation) {
  38203. this.parts.push("(");
  38204. operation.arg1.visit(this);
  38205. this.parts.push(" ", operation.op, " ");
  38206. operation.arg2.visit(this);
  38207. this.parts.push(")");
  38208. }
  38209. visitVariableDefinition(definition) {
  38210. this.parts.push("var ");
  38211. definition.variable.visit(this);
  38212. this.parts.push(" = ");
  38213. definition.arg.visit(this);
  38214. this.parts.push(";");
  38215. }
  38216. visitMin(max) {
  38217. this.parts.push("Math.min(");
  38218. max.arg.visit(this);
  38219. this.parts.push(", ", max.max, ")");
  38220. }
  38221. toString() {
  38222. return this.parts.join("");
  38223. }
  38224. }
  38225. function buildAddOperation(num1, num2) {
  38226. if (num2.type === "literal" && num2.number === 0) {
  38227. return num1;
  38228. }
  38229. if (num1.type === "literal" && num1.number === 0) {
  38230. return num2;
  38231. }
  38232. if (num2.type === "literal" && num1.type === "literal") {
  38233. return new AstLiteral(num1.number + num2.number);
  38234. }
  38235. return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
  38236. }
  38237. function buildMulOperation(num1, num2) {
  38238. if (num2.type === "literal") {
  38239. if (num2.number === 0) {
  38240. return new AstLiteral(0);
  38241. } else if (num2.number === 1) {
  38242. return num1;
  38243. } else if (num1.type === "literal") {
  38244. return new AstLiteral(num1.number * num2.number);
  38245. }
  38246. }
  38247. if (num1.type === "literal") {
  38248. if (num1.number === 0) {
  38249. return new AstLiteral(0);
  38250. } else if (num1.number === 1) {
  38251. return num2;
  38252. }
  38253. }
  38254. const min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  38255. const max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  38256. return new AstBinaryOperation("*", num1, num2, min, max);
  38257. }
  38258. function buildSubOperation(num1, num2) {
  38259. if (num2.type === "literal") {
  38260. if (num2.number === 0) {
  38261. return num1;
  38262. } else if (num1.type === "literal") {
  38263. return new AstLiteral(num1.number - num2.number);
  38264. }
  38265. }
  38266. if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
  38267. return num2.arg2;
  38268. }
  38269. return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
  38270. }
  38271. function buildMinOperation(num1, max) {
  38272. if (num1.min >= max) {
  38273. return new AstLiteral(max);
  38274. } else if (num1.max <= max) {
  38275. return num1;
  38276. }
  38277. return new AstMin(num1, max);
  38278. }
  38279. class PostScriptCompiler {
  38280. compile(code, domain, range) {
  38281. const stack = [];
  38282. const instructions = [];
  38283. const inputSize = domain.length >> 1,
  38284. outputSize = range.length >> 1;
  38285. let lastRegister = 0;
  38286. let n, j;
  38287. let num1, num2, ast1, ast2, tmpVar, item;
  38288. for (let i = 0; i < inputSize; i++) {
  38289. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  38290. }
  38291. for (let i = 0, ii = code.length; i < ii; i++) {
  38292. item = code[i];
  38293. if (typeof item === "number") {
  38294. stack.push(new AstLiteral(item));
  38295. continue;
  38296. }
  38297. switch (item) {
  38298. case "add":
  38299. if (stack.length < 2) {
  38300. return null;
  38301. }
  38302. num2 = stack.pop();
  38303. num1 = stack.pop();
  38304. stack.push(buildAddOperation(num1, num2));
  38305. break;
  38306. case "cvr":
  38307. if (stack.length < 1) {
  38308. return null;
  38309. }
  38310. break;
  38311. case "mul":
  38312. if (stack.length < 2) {
  38313. return null;
  38314. }
  38315. num2 = stack.pop();
  38316. num1 = stack.pop();
  38317. stack.push(buildMulOperation(num1, num2));
  38318. break;
  38319. case "sub":
  38320. if (stack.length < 2) {
  38321. return null;
  38322. }
  38323. num2 = stack.pop();
  38324. num1 = stack.pop();
  38325. stack.push(buildSubOperation(num1, num2));
  38326. break;
  38327. case "exch":
  38328. if (stack.length < 2) {
  38329. return null;
  38330. }
  38331. ast1 = stack.pop();
  38332. ast2 = stack.pop();
  38333. stack.push(ast1, ast2);
  38334. break;
  38335. case "pop":
  38336. if (stack.length < 1) {
  38337. return null;
  38338. }
  38339. stack.pop();
  38340. break;
  38341. case "index":
  38342. if (stack.length < 1) {
  38343. return null;
  38344. }
  38345. num1 = stack.pop();
  38346. if (num1.type !== "literal") {
  38347. return null;
  38348. }
  38349. n = num1.number;
  38350. if (n < 0 || !Number.isInteger(n) || stack.length < n) {
  38351. return null;
  38352. }
  38353. ast1 = stack[stack.length - n - 1];
  38354. if (ast1.type === "literal" || ast1.type === "var") {
  38355. stack.push(ast1);
  38356. break;
  38357. }
  38358. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  38359. stack[stack.length - n - 1] = tmpVar;
  38360. stack.push(tmpVar);
  38361. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  38362. break;
  38363. case "dup":
  38364. if (stack.length < 1) {
  38365. return null;
  38366. }
  38367. if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) {
  38368. num1 = stack.pop();
  38369. stack.push(buildMinOperation(num1, code[i + 1]));
  38370. i += 6;
  38371. break;
  38372. }
  38373. ast1 = stack.at(-1);
  38374. if (ast1.type === "literal" || ast1.type === "var") {
  38375. stack.push(ast1);
  38376. break;
  38377. }
  38378. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  38379. stack[stack.length - 1] = tmpVar;
  38380. stack.push(tmpVar);
  38381. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  38382. break;
  38383. case "roll":
  38384. if (stack.length < 2) {
  38385. return null;
  38386. }
  38387. num2 = stack.pop();
  38388. num1 = stack.pop();
  38389. if (num2.type !== "literal" || num1.type !== "literal") {
  38390. return null;
  38391. }
  38392. j = num2.number;
  38393. n = num1.number;
  38394. if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
  38395. return null;
  38396. }
  38397. j = (j % n + n) % n;
  38398. if (j === 0) {
  38399. break;
  38400. }
  38401. stack.push(...stack.splice(stack.length - n, n - j));
  38402. break;
  38403. default:
  38404. return null;
  38405. }
  38406. }
  38407. if (stack.length !== outputSize) {
  38408. return null;
  38409. }
  38410. const result = [];
  38411. for (const instruction of instructions) {
  38412. const statementBuilder = new ExpressionBuilderVisitor();
  38413. instruction.visit(statementBuilder);
  38414. result.push(statementBuilder.toString());
  38415. }
  38416. for (let i = 0, ii = stack.length; i < ii; i++) {
  38417. const expr = stack[i],
  38418. statementBuilder = new ExpressionBuilderVisitor();
  38419. expr.visit(statementBuilder);
  38420. const min = range[i * 2],
  38421. max = range[i * 2 + 1];
  38422. const out = [statementBuilder.toString()];
  38423. if (min > expr.min) {
  38424. out.unshift("Math.max(", min, ", ");
  38425. out.push(")");
  38426. }
  38427. if (max < expr.max) {
  38428. out.unshift("Math.min(", max, ", ");
  38429. out.push(")");
  38430. }
  38431. out.unshift("dest[destOffset + ", i, "] = ");
  38432. out.push(";");
  38433. result.push(out.join(""));
  38434. }
  38435. return result.join("\n");
  38436. }
  38437. }
  38438. exports.PostScriptCompiler = PostScriptCompiler;
  38439. /***/ }),
  38440. /* 58 */
  38441. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38442. Object.defineProperty(exports, "__esModule", ({
  38443. value: true
  38444. }));
  38445. exports.PostScriptParser = exports.PostScriptLexer = void 0;
  38446. var _util = __w_pdfjs_require__(2);
  38447. var _primitives = __w_pdfjs_require__(4);
  38448. var _core_utils = __w_pdfjs_require__(3);
  38449. class PostScriptParser {
  38450. constructor(lexer) {
  38451. this.lexer = lexer;
  38452. this.operators = [];
  38453. this.token = null;
  38454. this.prev = null;
  38455. }
  38456. nextToken() {
  38457. this.prev = this.token;
  38458. this.token = this.lexer.getToken();
  38459. }
  38460. accept(type) {
  38461. if (this.token.type === type) {
  38462. this.nextToken();
  38463. return true;
  38464. }
  38465. return false;
  38466. }
  38467. expect(type) {
  38468. if (this.accept(type)) {
  38469. return true;
  38470. }
  38471. throw new _util.FormatError(`Unexpected symbol: found ${this.token.type} expected ${type}.`);
  38472. }
  38473. parse() {
  38474. this.nextToken();
  38475. this.expect(PostScriptTokenTypes.LBRACE);
  38476. this.parseBlock();
  38477. this.expect(PostScriptTokenTypes.RBRACE);
  38478. return this.operators;
  38479. }
  38480. parseBlock() {
  38481. while (true) {
  38482. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  38483. this.operators.push(this.prev.value);
  38484. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  38485. this.operators.push(this.prev.value);
  38486. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  38487. this.parseCondition();
  38488. } else {
  38489. return;
  38490. }
  38491. }
  38492. }
  38493. parseCondition() {
  38494. const conditionLocation = this.operators.length;
  38495. this.operators.push(null, null);
  38496. this.parseBlock();
  38497. this.expect(PostScriptTokenTypes.RBRACE);
  38498. if (this.accept(PostScriptTokenTypes.IF)) {
  38499. this.operators[conditionLocation] = this.operators.length;
  38500. this.operators[conditionLocation + 1] = "jz";
  38501. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  38502. const jumpLocation = this.operators.length;
  38503. this.operators.push(null, null);
  38504. const endOfTrue = this.operators.length;
  38505. this.parseBlock();
  38506. this.expect(PostScriptTokenTypes.RBRACE);
  38507. this.expect(PostScriptTokenTypes.IFELSE);
  38508. this.operators[jumpLocation] = this.operators.length;
  38509. this.operators[jumpLocation + 1] = "j";
  38510. this.operators[conditionLocation] = endOfTrue;
  38511. this.operators[conditionLocation + 1] = "jz";
  38512. } else {
  38513. throw new _util.FormatError("PS Function: error parsing conditional.");
  38514. }
  38515. }
  38516. }
  38517. exports.PostScriptParser = PostScriptParser;
  38518. const PostScriptTokenTypes = {
  38519. LBRACE: 0,
  38520. RBRACE: 1,
  38521. NUMBER: 2,
  38522. OPERATOR: 3,
  38523. IF: 4,
  38524. IFELSE: 5
  38525. };
  38526. class PostScriptToken {
  38527. static get opCache() {
  38528. return (0, _util.shadow)(this, "opCache", Object.create(null));
  38529. }
  38530. constructor(type, value) {
  38531. this.type = type;
  38532. this.value = value;
  38533. }
  38534. static getOperator(op) {
  38535. return PostScriptToken.opCache[op] ||= new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  38536. }
  38537. static get LBRACE() {
  38538. return (0, _util.shadow)(this, "LBRACE", new PostScriptToken(PostScriptTokenTypes.LBRACE, "{"));
  38539. }
  38540. static get RBRACE() {
  38541. return (0, _util.shadow)(this, "RBRACE", new PostScriptToken(PostScriptTokenTypes.RBRACE, "}"));
  38542. }
  38543. static get IF() {
  38544. return (0, _util.shadow)(this, "IF", new PostScriptToken(PostScriptTokenTypes.IF, "IF"));
  38545. }
  38546. static get IFELSE() {
  38547. return (0, _util.shadow)(this, "IFELSE", new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE"));
  38548. }
  38549. }
  38550. class PostScriptLexer {
  38551. constructor(stream) {
  38552. this.stream = stream;
  38553. this.nextChar();
  38554. this.strBuf = [];
  38555. }
  38556. nextChar() {
  38557. return this.currentChar = this.stream.getByte();
  38558. }
  38559. getToken() {
  38560. let comment = false;
  38561. let ch = this.currentChar;
  38562. while (true) {
  38563. if (ch < 0) {
  38564. return _primitives.EOF;
  38565. }
  38566. if (comment) {
  38567. if (ch === 0x0a || ch === 0x0d) {
  38568. comment = false;
  38569. }
  38570. } else if (ch === 0x25) {
  38571. comment = true;
  38572. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  38573. break;
  38574. }
  38575. ch = this.nextChar();
  38576. }
  38577. switch (ch | 0) {
  38578. case 0x30:
  38579. case 0x31:
  38580. case 0x32:
  38581. case 0x33:
  38582. case 0x34:
  38583. case 0x35:
  38584. case 0x36:
  38585. case 0x37:
  38586. case 0x38:
  38587. case 0x39:
  38588. case 0x2b:
  38589. case 0x2d:
  38590. case 0x2e:
  38591. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  38592. case 0x7b:
  38593. this.nextChar();
  38594. return PostScriptToken.LBRACE;
  38595. case 0x7d:
  38596. this.nextChar();
  38597. return PostScriptToken.RBRACE;
  38598. }
  38599. const strBuf = this.strBuf;
  38600. strBuf.length = 0;
  38601. strBuf[0] = String.fromCharCode(ch);
  38602. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5a || ch >= 0x61 && ch <= 0x7a)) {
  38603. strBuf.push(String.fromCharCode(ch));
  38604. }
  38605. const str = strBuf.join("");
  38606. switch (str.toLowerCase()) {
  38607. case "if":
  38608. return PostScriptToken.IF;
  38609. case "ifelse":
  38610. return PostScriptToken.IFELSE;
  38611. default:
  38612. return PostScriptToken.getOperator(str);
  38613. }
  38614. }
  38615. getNumber() {
  38616. let ch = this.currentChar;
  38617. const strBuf = this.strBuf;
  38618. strBuf.length = 0;
  38619. strBuf[0] = String.fromCharCode(ch);
  38620. while ((ch = this.nextChar()) >= 0) {
  38621. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2d || ch === 0x2e) {
  38622. strBuf.push(String.fromCharCode(ch));
  38623. } else {
  38624. break;
  38625. }
  38626. }
  38627. const value = parseFloat(strBuf.join(""));
  38628. if (isNaN(value)) {
  38629. throw new _util.FormatError(`Invalid floating point number: ${value}`);
  38630. }
  38631. return value;
  38632. }
  38633. }
  38634. exports.PostScriptLexer = PostScriptLexer;
  38635. /***/ }),
  38636. /* 59 */
  38637. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38638. Object.defineProperty(exports, "__esModule", ({
  38639. value: true
  38640. }));
  38641. exports.RegionalImageCache = exports.LocalTilingPatternCache = exports.LocalImageCache = exports.LocalGStateCache = exports.LocalFunctionCache = exports.LocalColorSpaceCache = exports.GlobalImageCache = void 0;
  38642. var _util = __w_pdfjs_require__(2);
  38643. var _primitives = __w_pdfjs_require__(4);
  38644. class BaseLocalCache {
  38645. constructor(options) {
  38646. if (this.constructor === BaseLocalCache) {
  38647. (0, _util.unreachable)("Cannot initialize BaseLocalCache.");
  38648. }
  38649. this._onlyRefs = options?.onlyRefs === true;
  38650. if (!this._onlyRefs) {
  38651. this._nameRefMap = new Map();
  38652. this._imageMap = new Map();
  38653. }
  38654. this._imageCache = new _primitives.RefSetCache();
  38655. }
  38656. getByName(name) {
  38657. if (this._onlyRefs) {
  38658. (0, _util.unreachable)("Should not call `getByName` method.");
  38659. }
  38660. const ref = this._nameRefMap.get(name);
  38661. if (ref) {
  38662. return this.getByRef(ref);
  38663. }
  38664. return this._imageMap.get(name) || null;
  38665. }
  38666. getByRef(ref) {
  38667. return this._imageCache.get(ref) || null;
  38668. }
  38669. set(name, ref, data) {
  38670. (0, _util.unreachable)("Abstract method `set` called.");
  38671. }
  38672. }
  38673. class LocalImageCache extends BaseLocalCache {
  38674. set(name, ref = null, data) {
  38675. if (typeof name !== "string") {
  38676. throw new Error('LocalImageCache.set - expected "name" argument.');
  38677. }
  38678. if (ref) {
  38679. if (this._imageCache.has(ref)) {
  38680. return;
  38681. }
  38682. this._nameRefMap.set(name, ref);
  38683. this._imageCache.put(ref, data);
  38684. return;
  38685. }
  38686. if (this._imageMap.has(name)) {
  38687. return;
  38688. }
  38689. this._imageMap.set(name, data);
  38690. }
  38691. }
  38692. exports.LocalImageCache = LocalImageCache;
  38693. class LocalColorSpaceCache extends BaseLocalCache {
  38694. set(name = null, ref = null, data) {
  38695. if (typeof name !== "string" && !ref) {
  38696. throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.');
  38697. }
  38698. if (ref) {
  38699. if (this._imageCache.has(ref)) {
  38700. return;
  38701. }
  38702. if (name !== null) {
  38703. this._nameRefMap.set(name, ref);
  38704. }
  38705. this._imageCache.put(ref, data);
  38706. return;
  38707. }
  38708. if (this._imageMap.has(name)) {
  38709. return;
  38710. }
  38711. this._imageMap.set(name, data);
  38712. }
  38713. }
  38714. exports.LocalColorSpaceCache = LocalColorSpaceCache;
  38715. class LocalFunctionCache extends BaseLocalCache {
  38716. constructor(options) {
  38717. super({
  38718. onlyRefs: true
  38719. });
  38720. }
  38721. set(name = null, ref, data) {
  38722. if (!ref) {
  38723. throw new Error('LocalFunctionCache.set - expected "ref" argument.');
  38724. }
  38725. if (this._imageCache.has(ref)) {
  38726. return;
  38727. }
  38728. this._imageCache.put(ref, data);
  38729. }
  38730. }
  38731. exports.LocalFunctionCache = LocalFunctionCache;
  38732. class LocalGStateCache extends BaseLocalCache {
  38733. set(name, ref = null, data) {
  38734. if (typeof name !== "string") {
  38735. throw new Error('LocalGStateCache.set - expected "name" argument.');
  38736. }
  38737. if (ref) {
  38738. if (this._imageCache.has(ref)) {
  38739. return;
  38740. }
  38741. this._nameRefMap.set(name, ref);
  38742. this._imageCache.put(ref, data);
  38743. return;
  38744. }
  38745. if (this._imageMap.has(name)) {
  38746. return;
  38747. }
  38748. this._imageMap.set(name, data);
  38749. }
  38750. }
  38751. exports.LocalGStateCache = LocalGStateCache;
  38752. class LocalTilingPatternCache extends BaseLocalCache {
  38753. constructor(options) {
  38754. super({
  38755. onlyRefs: true
  38756. });
  38757. }
  38758. set(name = null, ref, data) {
  38759. if (!ref) {
  38760. throw new Error('LocalTilingPatternCache.set - expected "ref" argument.');
  38761. }
  38762. if (this._imageCache.has(ref)) {
  38763. return;
  38764. }
  38765. this._imageCache.put(ref, data);
  38766. }
  38767. }
  38768. exports.LocalTilingPatternCache = LocalTilingPatternCache;
  38769. class RegionalImageCache extends BaseLocalCache {
  38770. constructor(options) {
  38771. super({
  38772. onlyRefs: true
  38773. });
  38774. }
  38775. set(name = null, ref, data) {
  38776. if (!ref) {
  38777. throw new Error('RegionalImageCache.set - expected "ref" argument.');
  38778. }
  38779. if (this._imageCache.has(ref)) {
  38780. return;
  38781. }
  38782. this._imageCache.put(ref, data);
  38783. }
  38784. }
  38785. exports.RegionalImageCache = RegionalImageCache;
  38786. class GlobalImageCache {
  38787. static NUM_PAGES_THRESHOLD = 2;
  38788. static MIN_IMAGES_TO_CACHE = 10;
  38789. static MAX_BYTE_SIZE = 5 * _util.MAX_IMAGE_SIZE_TO_CACHE;
  38790. constructor() {
  38791. this._refCache = new _primitives.RefSetCache();
  38792. this._imageCache = new _primitives.RefSetCache();
  38793. }
  38794. get _byteSize() {
  38795. let byteSize = 0;
  38796. for (const imageData of this._imageCache) {
  38797. byteSize += imageData.byteSize;
  38798. }
  38799. return byteSize;
  38800. }
  38801. get _cacheLimitReached() {
  38802. if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) {
  38803. return false;
  38804. }
  38805. if (this._byteSize < GlobalImageCache.MAX_BYTE_SIZE) {
  38806. return false;
  38807. }
  38808. return true;
  38809. }
  38810. shouldCache(ref, pageIndex) {
  38811. let pageIndexSet = this._refCache.get(ref);
  38812. if (!pageIndexSet) {
  38813. pageIndexSet = new Set();
  38814. this._refCache.put(ref, pageIndexSet);
  38815. }
  38816. pageIndexSet.add(pageIndex);
  38817. if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  38818. return false;
  38819. }
  38820. if (!this._imageCache.has(ref) && this._cacheLimitReached) {
  38821. return false;
  38822. }
  38823. return true;
  38824. }
  38825. addByteSize(ref, byteSize) {
  38826. const imageData = this._imageCache.get(ref);
  38827. if (!imageData) {
  38828. return;
  38829. }
  38830. if (imageData.byteSize) {
  38831. return;
  38832. }
  38833. imageData.byteSize = byteSize;
  38834. }
  38835. getData(ref, pageIndex) {
  38836. const pageIndexSet = this._refCache.get(ref);
  38837. if (!pageIndexSet) {
  38838. return null;
  38839. }
  38840. if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  38841. return null;
  38842. }
  38843. const imageData = this._imageCache.get(ref);
  38844. if (!imageData) {
  38845. return null;
  38846. }
  38847. pageIndexSet.add(pageIndex);
  38848. return imageData;
  38849. }
  38850. setData(ref, data) {
  38851. if (!this._refCache.has(ref)) {
  38852. throw new Error('GlobalImageCache.setData - expected "shouldCache" to have been called.');
  38853. }
  38854. if (this._imageCache.has(ref)) {
  38855. return;
  38856. }
  38857. if (this._cacheLimitReached) {
  38858. (0, _util.warn)("GlobalImageCache.setData - cache limit reached.");
  38859. return;
  38860. }
  38861. this._imageCache.put(ref, data);
  38862. }
  38863. clear(onlyData = false) {
  38864. if (!onlyData) {
  38865. this._refCache.clear();
  38866. }
  38867. this._imageCache.clear();
  38868. }
  38869. }
  38870. exports.GlobalImageCache = GlobalImageCache;
  38871. /***/ }),
  38872. /* 60 */
  38873. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38874. Object.defineProperty(exports, "__esModule", ({
  38875. value: true
  38876. }));
  38877. exports.bidi = bidi;
  38878. var _util = __w_pdfjs_require__(2);
  38879. const baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"];
  38880. const arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"];
  38881. function isOdd(i) {
  38882. return (i & 1) !== 0;
  38883. }
  38884. function isEven(i) {
  38885. return (i & 1) === 0;
  38886. }
  38887. function findUnequal(arr, start, value) {
  38888. let j, jj;
  38889. for (j = start, jj = arr.length; j < jj; ++j) {
  38890. if (arr[j] !== value) {
  38891. return j;
  38892. }
  38893. }
  38894. return j;
  38895. }
  38896. function setValues(arr, start, end, value) {
  38897. for (let j = start; j < end; ++j) {
  38898. arr[j] = value;
  38899. }
  38900. }
  38901. function reverseValues(arr, start, end) {
  38902. for (let i = start, j = end - 1; i < j; ++i, --j) {
  38903. const temp = arr[i];
  38904. arr[i] = arr[j];
  38905. arr[j] = temp;
  38906. }
  38907. }
  38908. function createBidiText(str, isLTR, vertical = false) {
  38909. let dir = "ltr";
  38910. if (vertical) {
  38911. dir = "ttb";
  38912. } else if (!isLTR) {
  38913. dir = "rtl";
  38914. }
  38915. return {
  38916. str,
  38917. dir
  38918. };
  38919. }
  38920. const chars = [];
  38921. const types = [];
  38922. function bidi(str, startLevel = -1, vertical = false) {
  38923. let isLTR = true;
  38924. const strLength = str.length;
  38925. if (strLength === 0 || vertical) {
  38926. return createBidiText(str, isLTR, vertical);
  38927. }
  38928. chars.length = strLength;
  38929. types.length = strLength;
  38930. let numBidi = 0;
  38931. let i, ii;
  38932. for (i = 0; i < strLength; ++i) {
  38933. chars[i] = str.charAt(i);
  38934. const charCode = str.charCodeAt(i);
  38935. let charType = "L";
  38936. if (charCode <= 0x00ff) {
  38937. charType = baseTypes[charCode];
  38938. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  38939. charType = "R";
  38940. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  38941. charType = arabicTypes[charCode & 0xff];
  38942. if (!charType) {
  38943. (0, _util.warn)("Bidi: invalid Unicode character " + charCode.toString(16));
  38944. }
  38945. } else if (0x0700 <= charCode && charCode <= 0x08ac || 0xfb50 <= charCode && charCode <= 0xfdff || 0xfe70 <= charCode && charCode <= 0xfeff) {
  38946. charType = "AL";
  38947. }
  38948. if (charType === "R" || charType === "AL" || charType === "AN") {
  38949. numBidi++;
  38950. }
  38951. types[i] = charType;
  38952. }
  38953. if (numBidi === 0) {
  38954. isLTR = true;
  38955. return createBidiText(str, isLTR);
  38956. }
  38957. if (startLevel === -1) {
  38958. if (numBidi / strLength < 0.3 && strLength > 4) {
  38959. isLTR = true;
  38960. startLevel = 0;
  38961. } else {
  38962. isLTR = false;
  38963. startLevel = 1;
  38964. }
  38965. }
  38966. const levels = [];
  38967. for (i = 0; i < strLength; ++i) {
  38968. levels[i] = startLevel;
  38969. }
  38970. const e = isOdd(startLevel) ? "R" : "L";
  38971. const sor = e;
  38972. const eor = sor;
  38973. let lastType = sor;
  38974. for (i = 0; i < strLength; ++i) {
  38975. if (types[i] === "NSM") {
  38976. types[i] = lastType;
  38977. } else {
  38978. lastType = types[i];
  38979. }
  38980. }
  38981. lastType = sor;
  38982. let t;
  38983. for (i = 0; i < strLength; ++i) {
  38984. t = types[i];
  38985. if (t === "EN") {
  38986. types[i] = lastType === "AL" ? "AN" : "EN";
  38987. } else if (t === "R" || t === "L" || t === "AL") {
  38988. lastType = t;
  38989. }
  38990. }
  38991. for (i = 0; i < strLength; ++i) {
  38992. t = types[i];
  38993. if (t === "AL") {
  38994. types[i] = "R";
  38995. }
  38996. }
  38997. for (i = 1; i < strLength - 1; ++i) {
  38998. if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
  38999. types[i] = "EN";
  39000. }
  39001. if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
  39002. types[i] = types[i - 1];
  39003. }
  39004. }
  39005. for (i = 0; i < strLength; ++i) {
  39006. if (types[i] === "EN") {
  39007. for (let j = i - 1; j >= 0; --j) {
  39008. if (types[j] !== "ET") {
  39009. break;
  39010. }
  39011. types[j] = "EN";
  39012. }
  39013. for (let j = i + 1; j < strLength; ++j) {
  39014. if (types[j] !== "ET") {
  39015. break;
  39016. }
  39017. types[j] = "EN";
  39018. }
  39019. }
  39020. }
  39021. for (i = 0; i < strLength; ++i) {
  39022. t = types[i];
  39023. if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
  39024. types[i] = "ON";
  39025. }
  39026. }
  39027. lastType = sor;
  39028. for (i = 0; i < strLength; ++i) {
  39029. t = types[i];
  39030. if (t === "EN") {
  39031. types[i] = lastType === "L" ? "L" : "EN";
  39032. } else if (t === "R" || t === "L") {
  39033. lastType = t;
  39034. }
  39035. }
  39036. for (i = 0; i < strLength; ++i) {
  39037. if (types[i] === "ON") {
  39038. const end = findUnequal(types, i + 1, "ON");
  39039. let before = sor;
  39040. if (i > 0) {
  39041. before = types[i - 1];
  39042. }
  39043. let after = eor;
  39044. if (end + 1 < strLength) {
  39045. after = types[end + 1];
  39046. }
  39047. if (before !== "L") {
  39048. before = "R";
  39049. }
  39050. if (after !== "L") {
  39051. after = "R";
  39052. }
  39053. if (before === after) {
  39054. setValues(types, i, end, before);
  39055. }
  39056. i = end - 1;
  39057. }
  39058. }
  39059. for (i = 0; i < strLength; ++i) {
  39060. if (types[i] === "ON") {
  39061. types[i] = e;
  39062. }
  39063. }
  39064. for (i = 0; i < strLength; ++i) {
  39065. t = types[i];
  39066. if (isEven(levels[i])) {
  39067. if (t === "R") {
  39068. levels[i] += 1;
  39069. } else if (t === "AN" || t === "EN") {
  39070. levels[i] += 2;
  39071. }
  39072. } else if (t === "L" || t === "AN" || t === "EN") {
  39073. levels[i] += 1;
  39074. }
  39075. }
  39076. let highestLevel = -1;
  39077. let lowestOddLevel = 99;
  39078. let level;
  39079. for (i = 0, ii = levels.length; i < ii; ++i) {
  39080. level = levels[i];
  39081. if (highestLevel < level) {
  39082. highestLevel = level;
  39083. }
  39084. if (lowestOddLevel > level && isOdd(level)) {
  39085. lowestOddLevel = level;
  39086. }
  39087. }
  39088. for (level = highestLevel; level >= lowestOddLevel; --level) {
  39089. let start = -1;
  39090. for (i = 0, ii = levels.length; i < ii; ++i) {
  39091. if (levels[i] < level) {
  39092. if (start >= 0) {
  39093. reverseValues(chars, start, i);
  39094. start = -1;
  39095. }
  39096. } else if (start < 0) {
  39097. start = i;
  39098. }
  39099. }
  39100. if (start >= 0) {
  39101. reverseValues(chars, start, levels.length);
  39102. }
  39103. }
  39104. for (i = 0, ii = chars.length; i < ii; ++i) {
  39105. const ch = chars[i];
  39106. if (ch === "<" || ch === ">") {
  39107. chars[i] = "";
  39108. }
  39109. }
  39110. return createBidiText(chars.join(""), isLTR);
  39111. }
  39112. /***/ }),
  39113. /* 61 */
  39114. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  39115. Object.defineProperty(exports, "__esModule", ({
  39116. value: true
  39117. }));
  39118. exports.getFontSubstitution = getFontSubstitution;
  39119. var _fonts_utils = __w_pdfjs_require__(38);
  39120. var _core_utils = __w_pdfjs_require__(3);
  39121. const NORMAL = {
  39122. style: "normal",
  39123. weight: "normal"
  39124. };
  39125. const BOLD = {
  39126. style: "normal",
  39127. weight: "bold"
  39128. };
  39129. const ITALIC = {
  39130. style: "italic",
  39131. weight: "normal"
  39132. };
  39133. const BOLDITALIC = {
  39134. style: "italic",
  39135. weight: "bold"
  39136. };
  39137. const substitutionMap = new Map([["Times-Roman", {
  39138. local: ["Times New Roman", "Times-Roman", "Times", "Liberation Serif", "Nimbus Roman", "Nimbus Roman L", "Tinos", "Thorndale", "TeX Gyre Termes", "FreeSerif", "DejaVu Serif", "Bitstream Vera Serif", "Ubuntu"],
  39139. style: NORMAL,
  39140. ultimate: "serif"
  39141. }], ["Times-Bold", {
  39142. alias: "Times-Roman",
  39143. style: BOLD,
  39144. ultimate: "serif"
  39145. }], ["Times-Italic", {
  39146. alias: "Times-Roman",
  39147. style: ITALIC,
  39148. ultimate: "serif"
  39149. }], ["Times-BoldItalic", {
  39150. alias: "Times-Roman",
  39151. style: BOLDITALIC,
  39152. ultimate: "serif"
  39153. }], ["Helvetica", {
  39154. local: ["Helvetica", "Helvetica Neue", "Arial", "Arial Nova", "Liberation Sans", "Arimo", "Nimbus Sans", "Nimbus Sans L", "A030", "TeX Gyre Heros", "FreeSans", "DejaVu Sans", "Albany", "Bitstream Vera Sans", "Arial Unicode MS", "Microsoft Sans Serif", "Apple Symbols", "Cantarell"],
  39155. path: "LiberationSans-Regular.ttf",
  39156. style: NORMAL,
  39157. ultimate: "sans-serif"
  39158. }], ["Helvetica-Bold", {
  39159. alias: "Helvetica",
  39160. path: "LiberationSans-Bold.ttf",
  39161. style: BOLD,
  39162. ultimate: "sans-serif"
  39163. }], ["Helvetica-Oblique", {
  39164. alias: "Helvetica",
  39165. path: "LiberationSans-Italic.ttf",
  39166. style: ITALIC,
  39167. ultimate: "sans-serif"
  39168. }], ["Helvetica-BoldOblique", {
  39169. alias: "Helvetica",
  39170. path: "LiberationSans-BoldItalic.ttf",
  39171. style: BOLDITALIC,
  39172. ultimate: "sans-serif"
  39173. }], ["Courier", {
  39174. local: ["Courier", "Courier New", "Liberation Mono", "Nimbus Mono", "Nimbus Mono L", "Cousine", "Cumberland", "TeX Gyre Cursor", "FreeMono"],
  39175. style: NORMAL,
  39176. ultimate: "monospace"
  39177. }], ["Courier-Bold", {
  39178. alias: "Courier",
  39179. style: BOLD,
  39180. ultimate: "monospace"
  39181. }], ["Courier-Oblique", {
  39182. alias: "Courier",
  39183. style: ITALIC,
  39184. ultimate: "monospace"
  39185. }], ["Courier-BoldOblique", {
  39186. alias: "Courier",
  39187. style: BOLDITALIC,
  39188. ultimate: "monospace"
  39189. }], ["ArialBlack", {
  39190. local: ["Arial Black"],
  39191. style: {
  39192. style: "normal",
  39193. weight: "900"
  39194. },
  39195. fallback: "Helvetica-Bold"
  39196. }], ["ArialBlack-Bold", {
  39197. alias: "ArialBlack"
  39198. }], ["ArialBlack-Italic", {
  39199. alias: "ArialBlack",
  39200. style: {
  39201. style: "italic",
  39202. weight: "900"
  39203. },
  39204. fallback: "Helvetica-BoldOblique"
  39205. }], ["ArialBlack-BoldItalic", {
  39206. alias: "ArialBlack-Italic"
  39207. }], ["ArialNarrow", {
  39208. local: ["Arial Narrow", "Liberation Sans Narrow", "Helvetica Condensed", "Nimbus Sans Narrow", "TeX Gyre Heros Cn"],
  39209. style: NORMAL,
  39210. fallback: "Helvetica"
  39211. }], ["ArialNarrow-Bold", {
  39212. alias: "ArialNarrow",
  39213. style: BOLD,
  39214. fallback: "Helvetica-Bold"
  39215. }], ["ArialNarrow-Italic", {
  39216. alias: "ArialNarrow",
  39217. style: ITALIC,
  39218. fallback: "Helvetica-Oblique"
  39219. }], ["ArialNarrow-BoldItalic", {
  39220. alias: "ArialNarrow",
  39221. style: BOLDITALIC,
  39222. fallback: "Helvetica-BoldOblique"
  39223. }], ["Calibri", {
  39224. local: ["Calibri", "Carlito"],
  39225. style: NORMAL,
  39226. fallback: "Helvetica"
  39227. }], ["Calibri-Bold", {
  39228. alias: "Calibri",
  39229. style: BOLD,
  39230. fallback: "Helvetica-Bold"
  39231. }], ["Calibri-Italic", {
  39232. alias: "Calibri",
  39233. style: ITALIC,
  39234. fallback: "Helvetica-Oblique"
  39235. }], ["Calibri-BoldItalic", {
  39236. alias: "Calibri",
  39237. style: BOLDITALIC,
  39238. fallback: "Helvetica-BoldOblique"
  39239. }], ["Wingdings", {
  39240. local: ["Wingdings", "URW Dingbats"],
  39241. style: NORMAL
  39242. }], ["Wingdings-Regular", {
  39243. alias: "Wingdings"
  39244. }], ["Wingdings-Bold", {
  39245. alias: "Wingdings"
  39246. }]]);
  39247. const fontAliases = new Map([["Arial-Black", "ArialBlack"]]);
  39248. function getStyleToAppend(style) {
  39249. switch (style) {
  39250. case BOLD:
  39251. return "Bold";
  39252. case ITALIC:
  39253. return "Italic";
  39254. case BOLDITALIC:
  39255. return "Bold Italic";
  39256. default:
  39257. if (style?.weight === "bold") {
  39258. return "Bold";
  39259. }
  39260. if (style?.style === "italic") {
  39261. return "Italic";
  39262. }
  39263. }
  39264. return "";
  39265. }
  39266. function generateFont({
  39267. alias,
  39268. local,
  39269. path,
  39270. fallback,
  39271. style,
  39272. ultimate
  39273. }, src, localFontPath, useFallback = true, usePath = true, append = "") {
  39274. const result = {
  39275. style: null,
  39276. ultimate: null
  39277. };
  39278. if (local) {
  39279. const extra = append ? ` ${append}` : "";
  39280. for (const name of local) {
  39281. src.push(`local(${name}${extra})`);
  39282. }
  39283. }
  39284. if (alias) {
  39285. const substitution = substitutionMap.get(alias);
  39286. const aliasAppend = append || getStyleToAppend(style);
  39287. Object.assign(result, generateFont(substitution, src, localFontPath, useFallback && !fallback, usePath && !path, aliasAppend));
  39288. }
  39289. if (style) {
  39290. result.style = style;
  39291. }
  39292. if (ultimate) {
  39293. result.ultimate = ultimate;
  39294. }
  39295. if (useFallback && fallback) {
  39296. const fallbackInfo = substitutionMap.get(fallback);
  39297. const {
  39298. ultimate: fallbackUltimate
  39299. } = generateFont(fallbackInfo, src, localFontPath, useFallback, usePath && !path, append);
  39300. result.ultimate ||= fallbackUltimate;
  39301. }
  39302. if (usePath && path && localFontPath) {
  39303. src.push(`url(${localFontPath}${path})`);
  39304. }
  39305. return result;
  39306. }
  39307. function getFontSubstitution(systemFontCache, idFactory, localFontPath, baseFontName, standardFontName) {
  39308. baseFontName = (0, _fonts_utils.normalizeFontName)(baseFontName);
  39309. const key = baseFontName;
  39310. let substitutionInfo = systemFontCache.get(key);
  39311. if (substitutionInfo) {
  39312. return substitutionInfo;
  39313. }
  39314. let substitution = substitutionMap.get(baseFontName);
  39315. if (!substitution) {
  39316. for (const [alias, subst] of fontAliases) {
  39317. if (baseFontName.startsWith(alias)) {
  39318. baseFontName = `${subst}${baseFontName.substring(alias.length)}`;
  39319. substitution = substitutionMap.get(baseFontName);
  39320. break;
  39321. }
  39322. }
  39323. }
  39324. let mustAddBaseFont = false;
  39325. if (!substitution) {
  39326. substitution = substitutionMap.get(standardFontName);
  39327. mustAddBaseFont = true;
  39328. }
  39329. const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`;
  39330. if (!substitution) {
  39331. if (!(0, _core_utils.validateFontName)(baseFontName)) {
  39332. systemFontCache.set(key, null);
  39333. return null;
  39334. }
  39335. const bold = /bold/gi.test(baseFontName);
  39336. const italic = /oblique|italic/gi.test(baseFontName);
  39337. const style = bold && italic && BOLDITALIC || bold && BOLD || italic && ITALIC || NORMAL;
  39338. substitutionInfo = {
  39339. css: loadedName,
  39340. guessFallback: true,
  39341. loadedName,
  39342. baseFontName,
  39343. src: `local(${baseFontName})`,
  39344. style
  39345. };
  39346. systemFontCache.set(key, substitutionInfo);
  39347. return substitutionInfo;
  39348. }
  39349. const src = [];
  39350. if (mustAddBaseFont && (0, _core_utils.validateFontName)(baseFontName)) {
  39351. src.push(`local(${baseFontName})`);
  39352. }
  39353. const {
  39354. style,
  39355. ultimate
  39356. } = generateFont(substitution, src, localFontPath);
  39357. const guessFallback = ultimate === null;
  39358. const fallback = guessFallback ? "" : `,${ultimate}`;
  39359. substitutionInfo = {
  39360. css: `${loadedName}${fallback}`,
  39361. guessFallback,
  39362. loadedName,
  39363. baseFontName,
  39364. src: src.join(","),
  39365. style
  39366. };
  39367. systemFontCache.set(key, substitutionInfo);
  39368. return substitutionInfo;
  39369. }
  39370. /***/ }),
  39371. /* 62 */
  39372. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  39373. Object.defineProperty(exports, "__esModule", ({
  39374. value: true
  39375. }));
  39376. exports.ImageResizer = void 0;
  39377. var _util = __w_pdfjs_require__(2);
  39378. const MIN_IMAGE_DIM = 2048;
  39379. const MAX_IMAGE_DIM = 65537;
  39380. const MAX_ERROR = 128;
  39381. class ImageResizer {
  39382. constructor(imgData, isMask) {
  39383. this._imgData = imgData;
  39384. this._isMask = isMask;
  39385. }
  39386. static needsToBeResized(width, height) {
  39387. if (width <= this._goodSquareLength && height <= this._goodSquareLength) {
  39388. return false;
  39389. }
  39390. const {
  39391. MAX_DIM
  39392. } = this;
  39393. if (width > MAX_DIM || height > MAX_DIM) {
  39394. return true;
  39395. }
  39396. const area = width * height;
  39397. if (this._hasMaxArea) {
  39398. return area > this.MAX_AREA;
  39399. }
  39400. if (area < this._goodSquareLength ** 2) {
  39401. return false;
  39402. }
  39403. if (this._areGoodDims(width, height)) {
  39404. this._goodSquareLength = Math.max(this._goodSquareLength, Math.floor(Math.sqrt(width * height)));
  39405. return false;
  39406. }
  39407. this._goodSquareLength = this._guessMax(this._goodSquareLength, MAX_DIM, MAX_ERROR, 0);
  39408. const maxArea = this.MAX_AREA = this._goodSquareLength ** 2;
  39409. return area > maxArea;
  39410. }
  39411. static get MAX_DIM() {
  39412. return (0, _util.shadow)(this, "MAX_DIM", this._guessMax(MIN_IMAGE_DIM, MAX_IMAGE_DIM, 0, 1));
  39413. }
  39414. static get MAX_AREA() {
  39415. this._hasMaxArea = true;
  39416. return (0, _util.shadow)(this, "MAX_AREA", this._guessMax(ImageResizer._goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2);
  39417. }
  39418. static set MAX_AREA(area) {
  39419. if (area >= 0) {
  39420. this._hasMaxArea = true;
  39421. (0, _util.shadow)(this, "MAX_AREA", area);
  39422. }
  39423. }
  39424. static setMaxArea(area) {
  39425. if (!this._hasMaxArea) {
  39426. this.MAX_AREA = area >> 2;
  39427. }
  39428. }
  39429. static _areGoodDims(width, height) {
  39430. try {
  39431. const canvas = new OffscreenCanvas(width, height);
  39432. const ctx = canvas.getContext("2d");
  39433. ctx.fillRect(0, 0, 1, 1);
  39434. const opacity = ctx.getImageData(0, 0, 1, 1).data[3];
  39435. canvas.width = canvas.height = 1;
  39436. return opacity !== 0;
  39437. } catch {
  39438. return false;
  39439. }
  39440. }
  39441. static _guessMax(start, end, tolerance, defaultHeight) {
  39442. while (start + tolerance + 1 < end) {
  39443. const middle = Math.floor((start + end) / 2);
  39444. const height = defaultHeight || middle;
  39445. if (this._areGoodDims(middle, height)) {
  39446. start = middle;
  39447. } else {
  39448. end = middle;
  39449. }
  39450. }
  39451. return start;
  39452. }
  39453. static async createImage(imgData, isMask = false) {
  39454. return new ImageResizer(imgData, isMask)._createImage();
  39455. }
  39456. async _createImage() {
  39457. const data = this._encodeBMP();
  39458. const blob = new Blob([data.buffer], {
  39459. type: "image/bmp"
  39460. });
  39461. const bitmapPromise = createImageBitmap(blob);
  39462. const {
  39463. MAX_AREA,
  39464. MAX_DIM
  39465. } = ImageResizer;
  39466. const {
  39467. _imgData: imgData
  39468. } = this;
  39469. const {
  39470. width,
  39471. height
  39472. } = imgData;
  39473. const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(width * height / MAX_AREA));
  39474. const firstFactor = Math.max(minFactor, 2);
  39475. const factor = Math.round(10 * (minFactor + 1.25)) / 10 / firstFactor;
  39476. const N = Math.floor(Math.log2(factor));
  39477. const steps = new Array(N + 2).fill(2);
  39478. steps[0] = firstFactor;
  39479. steps.splice(-1, 1, factor / (1 << N));
  39480. let newWidth = width;
  39481. let newHeight = height;
  39482. let bitmap = await bitmapPromise;
  39483. for (const step of steps) {
  39484. const prevWidth = newWidth;
  39485. const prevHeight = newHeight;
  39486. newWidth = Math.floor(newWidth / step) - 1;
  39487. newHeight = Math.floor(newHeight / step) - 1;
  39488. const canvas = new OffscreenCanvas(newWidth, newHeight);
  39489. const ctx = canvas.getContext("2d");
  39490. ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
  39491. bitmap = canvas.transferToImageBitmap();
  39492. }
  39493. imgData.data = null;
  39494. imgData.bitmap = bitmap;
  39495. imgData.width = newWidth;
  39496. imgData.height = newHeight;
  39497. return imgData;
  39498. }
  39499. _encodeBMP() {
  39500. const {
  39501. width,
  39502. height,
  39503. kind
  39504. } = this._imgData;
  39505. let data = this._imgData.data;
  39506. let bitPerPixel;
  39507. let colorTable = new Uint8Array(0);
  39508. let maskTable = colorTable;
  39509. let compression = 0;
  39510. switch (kind) {
  39511. case _util.ImageKind.GRAYSCALE_1BPP:
  39512. {
  39513. bitPerPixel = 1;
  39514. colorTable = new Uint8Array(this._isMask ? [255, 255, 255, 255, 0, 0, 0, 0] : [0, 0, 0, 0, 255, 255, 255, 255]);
  39515. const rowLen = width + 7 >> 3;
  39516. const rowSize = rowLen + 3 & -4;
  39517. if (rowLen !== rowSize) {
  39518. const newData = new Uint8Array(rowSize * height);
  39519. let k = 0;
  39520. for (let i = 0, ii = height * rowLen; i < ii; i += rowLen, k += rowSize) {
  39521. newData.set(data.subarray(i, i + rowLen), k);
  39522. }
  39523. data = newData;
  39524. }
  39525. break;
  39526. }
  39527. case _util.ImageKind.RGB_24BPP:
  39528. {
  39529. bitPerPixel = 24;
  39530. if (width & 3) {
  39531. const rowLen = 3 * width;
  39532. const rowSize = rowLen + 3 & -4;
  39533. const extraLen = rowSize - rowLen;
  39534. const newData = new Uint8Array(rowSize * height);
  39535. let k = 0;
  39536. for (let i = 0, ii = height * rowLen; i < ii; i += rowLen) {
  39537. const row = data.subarray(i, i + rowLen);
  39538. for (let j = 0; j < rowLen; j += 3) {
  39539. newData[k++] = row[j + 2];
  39540. newData[k++] = row[j + 1];
  39541. newData[k++] = row[j];
  39542. }
  39543. k += extraLen;
  39544. }
  39545. data = newData;
  39546. } else {
  39547. for (let i = 0, ii = data.length; i < ii; i += 3) {
  39548. const tmp = data[i];
  39549. data[i] = data[i + 2];
  39550. data[i + 2] = tmp;
  39551. }
  39552. }
  39553. break;
  39554. }
  39555. case _util.ImageKind.RGBA_32BPP:
  39556. bitPerPixel = 32;
  39557. compression = 3;
  39558. maskTable = new Uint8Array(4 + 4 + 4 + 4 + 52);
  39559. const view = new DataView(maskTable.buffer);
  39560. if (_util.FeatureTest.isLittleEndian) {
  39561. view.setUint32(0, 0x000000ff, true);
  39562. view.setUint32(4, 0x0000ff00, true);
  39563. view.setUint32(8, 0x00ff0000, true);
  39564. view.setUint32(12, 0xff000000, true);
  39565. } else {
  39566. view.setUint32(0, 0xff000000, true);
  39567. view.setUint32(4, 0x00ff0000, true);
  39568. view.setUint32(8, 0x0000ff00, true);
  39569. view.setUint32(12, 0x000000ff, true);
  39570. }
  39571. break;
  39572. default:
  39573. throw new Error("invalid format");
  39574. }
  39575. let i = 0;
  39576. const headerLength = 40 + maskTable.length;
  39577. const fileLength = 14 + headerLength + colorTable.length + data.length;
  39578. const bmpData = new Uint8Array(fileLength);
  39579. const view = new DataView(bmpData.buffer);
  39580. view.setUint16(i, 0x4d42, true);
  39581. i += 2;
  39582. view.setUint32(i, fileLength, true);
  39583. i += 4;
  39584. view.setUint32(i, 0, true);
  39585. i += 4;
  39586. view.setUint32(i, 14 + headerLength + colorTable.length, true);
  39587. i += 4;
  39588. view.setUint32(i, headerLength, true);
  39589. i += 4;
  39590. view.setInt32(i, width, true);
  39591. i += 4;
  39592. view.setInt32(i, -height, true);
  39593. i += 4;
  39594. view.setUint16(i, 1, true);
  39595. i += 2;
  39596. view.setUint16(i, bitPerPixel, true);
  39597. i += 2;
  39598. view.setUint32(i, compression, true);
  39599. i += 4;
  39600. view.setUint32(i, 0, true);
  39601. i += 4;
  39602. view.setInt32(i, 0, true);
  39603. i += 4;
  39604. view.setInt32(i, 0, true);
  39605. i += 4;
  39606. view.setUint32(i, colorTable.length / 4, true);
  39607. i += 4;
  39608. view.setUint32(i, 0, true);
  39609. i += 4;
  39610. bmpData.set(maskTable, i);
  39611. i += maskTable.length;
  39612. bmpData.set(colorTable, i);
  39613. i += colorTable.length;
  39614. bmpData.set(data, i);
  39615. return bmpData;
  39616. }
  39617. }
  39618. exports.ImageResizer = ImageResizer;
  39619. ImageResizer._goodSquareLength = MIN_IMAGE_DIM;
  39620. /***/ }),
  39621. /* 63 */
  39622. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  39623. Object.defineProperty(exports, "__esModule", ({
  39624. value: true
  39625. }));
  39626. exports.MurmurHash3_64 = void 0;
  39627. var _util = __w_pdfjs_require__(2);
  39628. const SEED = 0xc3d2e1f0;
  39629. const MASK_HIGH = 0xffff0000;
  39630. const MASK_LOW = 0xffff;
  39631. class MurmurHash3_64 {
  39632. constructor(seed) {
  39633. this.h1 = seed ? seed & 0xffffffff : SEED;
  39634. this.h2 = seed ? seed & 0xffffffff : SEED;
  39635. }
  39636. update(input) {
  39637. let data, length;
  39638. if (typeof input === "string") {
  39639. data = new Uint8Array(input.length * 2);
  39640. length = 0;
  39641. for (let i = 0, ii = input.length; i < ii; i++) {
  39642. const code = input.charCodeAt(i);
  39643. if (code <= 0xff) {
  39644. data[length++] = code;
  39645. } else {
  39646. data[length++] = code >>> 8;
  39647. data[length++] = code & 0xff;
  39648. }
  39649. }
  39650. } else if ((0, _util.isArrayBuffer)(input)) {
  39651. data = input.slice();
  39652. length = data.byteLength;
  39653. } else {
  39654. throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
  39655. }
  39656. const blockCounts = length >> 2;
  39657. const tailLength = length - blockCounts * 4;
  39658. const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  39659. let k1 = 0,
  39660. k2 = 0;
  39661. let h1 = this.h1,
  39662. h2 = this.h2;
  39663. const C1 = 0xcc9e2d51,
  39664. C2 = 0x1b873593;
  39665. const C1_LOW = C1 & MASK_LOW,
  39666. C2_LOW = C2 & MASK_LOW;
  39667. for (let i = 0; i < blockCounts; i++) {
  39668. if (i & 1) {
  39669. k1 = dataUint32[i];
  39670. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  39671. k1 = k1 << 15 | k1 >>> 17;
  39672. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  39673. h1 ^= k1;
  39674. h1 = h1 << 13 | h1 >>> 19;
  39675. h1 = h1 * 5 + 0xe6546b64;
  39676. } else {
  39677. k2 = dataUint32[i];
  39678. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  39679. k2 = k2 << 15 | k2 >>> 17;
  39680. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  39681. h2 ^= k2;
  39682. h2 = h2 << 13 | h2 >>> 19;
  39683. h2 = h2 * 5 + 0xe6546b64;
  39684. }
  39685. }
  39686. k1 = 0;
  39687. switch (tailLength) {
  39688. case 3:
  39689. k1 ^= data[blockCounts * 4 + 2] << 16;
  39690. case 2:
  39691. k1 ^= data[blockCounts * 4 + 1] << 8;
  39692. case 1:
  39693. k1 ^= data[blockCounts * 4];
  39694. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  39695. k1 = k1 << 15 | k1 >>> 17;
  39696. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  39697. if (blockCounts & 1) {
  39698. h1 ^= k1;
  39699. } else {
  39700. h2 ^= k1;
  39701. }
  39702. }
  39703. this.h1 = h1;
  39704. this.h2 = h2;
  39705. }
  39706. hexdigest() {
  39707. let h1 = this.h1,
  39708. h2 = this.h2;
  39709. h1 ^= h2 >>> 1;
  39710. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  39711. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  39712. h1 ^= h2 >>> 1;
  39713. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  39714. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  39715. h1 ^= h2 >>> 1;
  39716. return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
  39717. }
  39718. }
  39719. exports.MurmurHash3_64 = MurmurHash3_64;
  39720. /***/ }),
  39721. /* 64 */
  39722. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  39723. Object.defineProperty(exports, "__esModule", ({
  39724. value: true
  39725. }));
  39726. exports.OperatorList = void 0;
  39727. var _util = __w_pdfjs_require__(2);
  39728. function addState(parentState, pattern, checkFn, iterateFn, processFn) {
  39729. let state = parentState;
  39730. for (let i = 0, ii = pattern.length - 1; i < ii; i++) {
  39731. const item = pattern[i];
  39732. state = state[item] ||= [];
  39733. }
  39734. state[pattern.at(-1)] = {
  39735. checkFn,
  39736. iterateFn,
  39737. processFn
  39738. };
  39739. }
  39740. const InitialState = [];
  39741. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
  39742. const fnArray = context.fnArray;
  39743. const iFirstSave = context.iCurr - 3;
  39744. const pos = (i - iFirstSave) % 4;
  39745. switch (pos) {
  39746. case 0:
  39747. return fnArray[i] === _util.OPS.save;
  39748. case 1:
  39749. return fnArray[i] === _util.OPS.transform;
  39750. case 2:
  39751. return fnArray[i] === _util.OPS.paintInlineImageXObject;
  39752. case 3:
  39753. return fnArray[i] === _util.OPS.restore;
  39754. }
  39755. throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`);
  39756. }, function foundInlineImageGroup(context, i) {
  39757. const MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  39758. const MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  39759. const MAX_WIDTH = 1000;
  39760. const IMAGE_PADDING = 1;
  39761. const fnArray = context.fnArray,
  39762. argsArray = context.argsArray;
  39763. const curr = context.iCurr;
  39764. const iFirstSave = curr - 3;
  39765. const iFirstTransform = curr - 2;
  39766. const iFirstPIIXO = curr - 1;
  39767. const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  39768. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  39769. return i - (i - iFirstSave) % 4;
  39770. }
  39771. let maxX = 0;
  39772. const map = [];
  39773. let maxLineHeight = 0;
  39774. let currentX = IMAGE_PADDING,
  39775. currentY = IMAGE_PADDING;
  39776. for (let q = 0; q < count; q++) {
  39777. const transform = argsArray[iFirstTransform + (q << 2)];
  39778. const img = argsArray[iFirstPIIXO + (q << 2)][0];
  39779. if (currentX + img.width > MAX_WIDTH) {
  39780. maxX = Math.max(maxX, currentX);
  39781. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  39782. currentX = 0;
  39783. maxLineHeight = 0;
  39784. }
  39785. map.push({
  39786. transform,
  39787. x: currentX,
  39788. y: currentY,
  39789. w: img.width,
  39790. h: img.height
  39791. });
  39792. currentX += img.width + 2 * IMAGE_PADDING;
  39793. maxLineHeight = Math.max(maxLineHeight, img.height);
  39794. }
  39795. const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  39796. const imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  39797. const imgData = new Uint8Array(imgWidth * imgHeight * 4);
  39798. const imgRowSize = imgWidth << 2;
  39799. for (let q = 0; q < count; q++) {
  39800. const data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  39801. const rowSize = map[q].w << 2;
  39802. let dataOffset = 0;
  39803. let offset = map[q].x + map[q].y * imgWidth << 2;
  39804. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  39805. for (let k = 0, kk = map[q].h; k < kk; k++) {
  39806. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  39807. dataOffset += rowSize;
  39808. offset += imgRowSize;
  39809. }
  39810. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  39811. while (offset >= 0) {
  39812. data[offset - 4] = data[offset];
  39813. data[offset - 3] = data[offset + 1];
  39814. data[offset - 2] = data[offset + 2];
  39815. data[offset - 1] = data[offset + 3];
  39816. data[offset + rowSize] = data[offset + rowSize - 4];
  39817. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  39818. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  39819. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  39820. offset -= imgRowSize;
  39821. }
  39822. }
  39823. const img = {
  39824. width: imgWidth,
  39825. height: imgHeight
  39826. };
  39827. if (context.isOffscreenCanvasSupported) {
  39828. const canvas = new OffscreenCanvas(imgWidth, imgHeight);
  39829. const ctx = canvas.getContext("2d");
  39830. ctx.putImageData(new ImageData(new Uint8ClampedArray(imgData.buffer), imgWidth, imgHeight), 0, 0);
  39831. img.bitmap = canvas.transferToImageBitmap();
  39832. img.data = null;
  39833. } else {
  39834. img.kind = _util.ImageKind.RGBA_32BPP;
  39835. img.data = imgData;
  39836. }
  39837. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
  39838. argsArray.splice(iFirstSave, count * 4, [img, map]);
  39839. return iFirstSave + 1;
  39840. });
  39841. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
  39842. const fnArray = context.fnArray;
  39843. const iFirstSave = context.iCurr - 3;
  39844. const pos = (i - iFirstSave) % 4;
  39845. switch (pos) {
  39846. case 0:
  39847. return fnArray[i] === _util.OPS.save;
  39848. case 1:
  39849. return fnArray[i] === _util.OPS.transform;
  39850. case 2:
  39851. return fnArray[i] === _util.OPS.paintImageMaskXObject;
  39852. case 3:
  39853. return fnArray[i] === _util.OPS.restore;
  39854. }
  39855. throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`);
  39856. }, function foundImageMaskGroup(context, i) {
  39857. const MIN_IMAGES_IN_MASKS_BLOCK = 10;
  39858. const MAX_IMAGES_IN_MASKS_BLOCK = 100;
  39859. const MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  39860. const fnArray = context.fnArray,
  39861. argsArray = context.argsArray;
  39862. const curr = context.iCurr;
  39863. const iFirstSave = curr - 3;
  39864. const iFirstTransform = curr - 2;
  39865. const iFirstPIMXO = curr - 1;
  39866. let count = Math.floor((i - iFirstSave) / 4);
  39867. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  39868. return i - (i - iFirstSave) % 4;
  39869. }
  39870. let isSameImage = false;
  39871. let iTransform, transformArgs;
  39872. const firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  39873. const firstTransformArg0 = argsArray[iFirstTransform][0],
  39874. firstTransformArg1 = argsArray[iFirstTransform][1],
  39875. firstTransformArg2 = argsArray[iFirstTransform][2],
  39876. firstTransformArg3 = argsArray[iFirstTransform][3];
  39877. if (firstTransformArg1 === firstTransformArg2) {
  39878. isSameImage = true;
  39879. iTransform = iFirstTransform + 4;
  39880. let iPIMXO = iFirstPIMXO + 4;
  39881. for (let q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  39882. transformArgs = argsArray[iTransform];
  39883. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== firstTransformArg1 || transformArgs[2] !== firstTransformArg2 || transformArgs[3] !== firstTransformArg3) {
  39884. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  39885. isSameImage = false;
  39886. } else {
  39887. count = q;
  39888. }
  39889. break;
  39890. }
  39891. }
  39892. }
  39893. if (isSameImage) {
  39894. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  39895. const positions = new Float32Array(count * 2);
  39896. iTransform = iFirstTransform;
  39897. for (let q = 0; q < count; q++, iTransform += 4) {
  39898. transformArgs = argsArray[iTransform];
  39899. positions[q << 1] = transformArgs[4];
  39900. positions[(q << 1) + 1] = transformArgs[5];
  39901. }
  39902. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
  39903. argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg1, firstTransformArg2, firstTransformArg3, positions]);
  39904. } else {
  39905. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  39906. const images = [];
  39907. for (let q = 0; q < count; q++) {
  39908. transformArgs = argsArray[iFirstTransform + (q << 2)];
  39909. const maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  39910. images.push({
  39911. data: maskParams.data,
  39912. width: maskParams.width,
  39913. height: maskParams.height,
  39914. interpolate: maskParams.interpolate,
  39915. count: maskParams.count,
  39916. transform: transformArgs
  39917. });
  39918. }
  39919. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
  39920. argsArray.splice(iFirstSave, count * 4, [images]);
  39921. }
  39922. return iFirstSave + 1;
  39923. });
  39924. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
  39925. const argsArray = context.argsArray;
  39926. const iFirstTransform = context.iCurr - 2;
  39927. return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
  39928. }, function iterateImageGroup(context, i) {
  39929. const fnArray = context.fnArray,
  39930. argsArray = context.argsArray;
  39931. const iFirstSave = context.iCurr - 3;
  39932. const pos = (i - iFirstSave) % 4;
  39933. switch (pos) {
  39934. case 0:
  39935. return fnArray[i] === _util.OPS.save;
  39936. case 1:
  39937. if (fnArray[i] !== _util.OPS.transform) {
  39938. return false;
  39939. }
  39940. const iFirstTransform = context.iCurr - 2;
  39941. const firstTransformArg0 = argsArray[iFirstTransform][0];
  39942. const firstTransformArg3 = argsArray[iFirstTransform][3];
  39943. if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
  39944. return false;
  39945. }
  39946. return true;
  39947. case 2:
  39948. if (fnArray[i] !== _util.OPS.paintImageXObject) {
  39949. return false;
  39950. }
  39951. const iFirstPIXO = context.iCurr - 1;
  39952. const firstPIXOArg0 = argsArray[iFirstPIXO][0];
  39953. if (argsArray[i][0] !== firstPIXOArg0) {
  39954. return false;
  39955. }
  39956. return true;
  39957. case 3:
  39958. return fnArray[i] === _util.OPS.restore;
  39959. }
  39960. throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
  39961. }, function (context, i) {
  39962. const MIN_IMAGES_IN_BLOCK = 3;
  39963. const MAX_IMAGES_IN_BLOCK = 1000;
  39964. const fnArray = context.fnArray,
  39965. argsArray = context.argsArray;
  39966. const curr = context.iCurr;
  39967. const iFirstSave = curr - 3;
  39968. const iFirstTransform = curr - 2;
  39969. const iFirstPIXO = curr - 1;
  39970. const firstPIXOArg0 = argsArray[iFirstPIXO][0];
  39971. const firstTransformArg0 = argsArray[iFirstTransform][0];
  39972. const firstTransformArg3 = argsArray[iFirstTransform][3];
  39973. const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
  39974. if (count < MIN_IMAGES_IN_BLOCK) {
  39975. return i - (i - iFirstSave) % 4;
  39976. }
  39977. const positions = new Float32Array(count * 2);
  39978. let iTransform = iFirstTransform;
  39979. for (let q = 0; q < count; q++, iTransform += 4) {
  39980. const transformArgs = argsArray[iTransform];
  39981. positions[q << 1] = transformArgs[4];
  39982. positions[(q << 1) + 1] = transformArgs[5];
  39983. }
  39984. const args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
  39985. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
  39986. argsArray.splice(iFirstSave, count * 4, args);
  39987. return iFirstSave + 1;
  39988. });
  39989. addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function iterateShowTextGroup(context, i) {
  39990. const fnArray = context.fnArray,
  39991. argsArray = context.argsArray;
  39992. const iFirstSave = context.iCurr - 4;
  39993. const pos = (i - iFirstSave) % 5;
  39994. switch (pos) {
  39995. case 0:
  39996. return fnArray[i] === _util.OPS.beginText;
  39997. case 1:
  39998. return fnArray[i] === _util.OPS.setFont;
  39999. case 2:
  40000. return fnArray[i] === _util.OPS.setTextMatrix;
  40001. case 3:
  40002. if (fnArray[i] !== _util.OPS.showText) {
  40003. return false;
  40004. }
  40005. const iFirstSetFont = context.iCurr - 3;
  40006. const firstSetFontArg0 = argsArray[iFirstSetFont][0];
  40007. const firstSetFontArg1 = argsArray[iFirstSetFont][1];
  40008. if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
  40009. return false;
  40010. }
  40011. return true;
  40012. case 4:
  40013. return fnArray[i] === _util.OPS.endText;
  40014. }
  40015. throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
  40016. }, function (context, i) {
  40017. const MIN_CHARS_IN_BLOCK = 3;
  40018. const MAX_CHARS_IN_BLOCK = 1000;
  40019. const fnArray = context.fnArray,
  40020. argsArray = context.argsArray;
  40021. const curr = context.iCurr;
  40022. const iFirstBeginText = curr - 4;
  40023. const iFirstSetFont = curr - 3;
  40024. const iFirstSetTextMatrix = curr - 2;
  40025. const iFirstShowText = curr - 1;
  40026. const iFirstEndText = curr;
  40027. const firstSetFontArg0 = argsArray[iFirstSetFont][0];
  40028. const firstSetFontArg1 = argsArray[iFirstSetFont][1];
  40029. let count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
  40030. if (count < MIN_CHARS_IN_BLOCK) {
  40031. return i - (i - iFirstBeginText) % 5;
  40032. }
  40033. let iFirst = iFirstBeginText;
  40034. if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
  40035. count++;
  40036. iFirst -= 5;
  40037. }
  40038. let iEndText = iFirst + 4;
  40039. for (let q = 1; q < count; q++) {
  40040. fnArray.splice(iEndText, 3);
  40041. argsArray.splice(iEndText, 3);
  40042. iEndText += 2;
  40043. }
  40044. return iEndText + 1;
  40045. });
  40046. class NullOptimizer {
  40047. constructor(queue) {
  40048. this.queue = queue;
  40049. }
  40050. _optimize() {}
  40051. push(fn, args) {
  40052. this.queue.fnArray.push(fn);
  40053. this.queue.argsArray.push(args);
  40054. this._optimize();
  40055. }
  40056. flush() {}
  40057. reset() {}
  40058. }
  40059. class QueueOptimizer extends NullOptimizer {
  40060. constructor(queue) {
  40061. super(queue);
  40062. this.state = null;
  40063. this.context = {
  40064. iCurr: 0,
  40065. fnArray: queue.fnArray,
  40066. argsArray: queue.argsArray,
  40067. isOffscreenCanvasSupported: false
  40068. };
  40069. this.match = null;
  40070. this.lastProcessed = 0;
  40071. }
  40072. set isOffscreenCanvasSupported(value) {
  40073. this.context.isOffscreenCanvasSupported = value;
  40074. }
  40075. _optimize() {
  40076. const fnArray = this.queue.fnArray;
  40077. let i = this.lastProcessed,
  40078. ii = fnArray.length;
  40079. let state = this.state;
  40080. let match = this.match;
  40081. if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
  40082. this.lastProcessed = ii;
  40083. return;
  40084. }
  40085. const context = this.context;
  40086. while (i < ii) {
  40087. if (match) {
  40088. const iterate = (0, match.iterateFn)(context, i);
  40089. if (iterate) {
  40090. i++;
  40091. continue;
  40092. }
  40093. i = (0, match.processFn)(context, i + 1);
  40094. ii = fnArray.length;
  40095. match = null;
  40096. state = null;
  40097. if (i >= ii) {
  40098. break;
  40099. }
  40100. }
  40101. state = (state || InitialState)[fnArray[i]];
  40102. if (!state || Array.isArray(state)) {
  40103. i++;
  40104. continue;
  40105. }
  40106. context.iCurr = i;
  40107. i++;
  40108. if (state.checkFn && !(0, state.checkFn)(context)) {
  40109. state = null;
  40110. continue;
  40111. }
  40112. match = state;
  40113. state = null;
  40114. }
  40115. this.state = state;
  40116. this.match = match;
  40117. this.lastProcessed = i;
  40118. }
  40119. flush() {
  40120. while (this.match) {
  40121. const length = this.queue.fnArray.length;
  40122. this.lastProcessed = (0, this.match.processFn)(this.context, length);
  40123. this.match = null;
  40124. this.state = null;
  40125. this._optimize();
  40126. }
  40127. }
  40128. reset() {
  40129. this.state = null;
  40130. this.match = null;
  40131. this.lastProcessed = 0;
  40132. }
  40133. }
  40134. class OperatorList {
  40135. static CHUNK_SIZE = 1000;
  40136. static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
  40137. constructor(intent = 0, streamSink) {
  40138. this._streamSink = streamSink;
  40139. this.fnArray = [];
  40140. this.argsArray = [];
  40141. this.optimizer = streamSink && !(intent & _util.RenderingIntentFlag.OPLIST) ? new QueueOptimizer(this) : new NullOptimizer(this);
  40142. this.dependencies = new Set();
  40143. this._totalLength = 0;
  40144. this.weight = 0;
  40145. this._resolved = streamSink ? null : Promise.resolve();
  40146. }
  40147. set isOffscreenCanvasSupported(value) {
  40148. this.optimizer.isOffscreenCanvasSupported = value;
  40149. }
  40150. get length() {
  40151. return this.argsArray.length;
  40152. }
  40153. get ready() {
  40154. return this._resolved || this._streamSink.ready;
  40155. }
  40156. get totalLength() {
  40157. return this._totalLength + this.length;
  40158. }
  40159. addOp(fn, args) {
  40160. this.optimizer.push(fn, args);
  40161. this.weight++;
  40162. if (this._streamSink) {
  40163. if (this.weight >= OperatorList.CHUNK_SIZE) {
  40164. this.flush();
  40165. } else if (this.weight >= OperatorList.CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
  40166. this.flush();
  40167. }
  40168. }
  40169. }
  40170. addImageOps(fn, args, optionalContent) {
  40171. if (optionalContent !== undefined) {
  40172. this.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  40173. }
  40174. this.addOp(fn, args);
  40175. if (optionalContent !== undefined) {
  40176. this.addOp(_util.OPS.endMarkedContent, []);
  40177. }
  40178. }
  40179. addDependency(dependency) {
  40180. if (this.dependencies.has(dependency)) {
  40181. return;
  40182. }
  40183. this.dependencies.add(dependency);
  40184. this.addOp(_util.OPS.dependency, [dependency]);
  40185. }
  40186. addDependencies(dependencies) {
  40187. for (const dependency of dependencies) {
  40188. this.addDependency(dependency);
  40189. }
  40190. }
  40191. addOpList(opList) {
  40192. if (!(opList instanceof OperatorList)) {
  40193. (0, _util.warn)('addOpList - ignoring invalid "opList" parameter.');
  40194. return;
  40195. }
  40196. for (const dependency of opList.dependencies) {
  40197. this.dependencies.add(dependency);
  40198. }
  40199. for (let i = 0, ii = opList.length; i < ii; i++) {
  40200. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  40201. }
  40202. }
  40203. getIR() {
  40204. return {
  40205. fnArray: this.fnArray,
  40206. argsArray: this.argsArray,
  40207. length: this.length
  40208. };
  40209. }
  40210. get _transfers() {
  40211. const transfers = [];
  40212. const {
  40213. fnArray,
  40214. argsArray,
  40215. length
  40216. } = this;
  40217. for (let i = 0; i < length; i++) {
  40218. switch (fnArray[i]) {
  40219. case _util.OPS.paintInlineImageXObject:
  40220. case _util.OPS.paintInlineImageXObjectGroup:
  40221. case _util.OPS.paintImageMaskXObject:
  40222. const arg = argsArray[i][0];
  40223. if (!arg.cached && arg.data?.buffer instanceof ArrayBuffer) {
  40224. transfers.push(arg.data.buffer);
  40225. }
  40226. break;
  40227. }
  40228. }
  40229. return transfers;
  40230. }
  40231. flush(lastChunk = false, separateAnnots = null) {
  40232. this.optimizer.flush();
  40233. const length = this.length;
  40234. this._totalLength += length;
  40235. this._streamSink.enqueue({
  40236. fnArray: this.fnArray,
  40237. argsArray: this.argsArray,
  40238. lastChunk,
  40239. separateAnnots,
  40240. length
  40241. }, 1, this._transfers);
  40242. this.dependencies.clear();
  40243. this.fnArray.length = 0;
  40244. this.argsArray.length = 0;
  40245. this.weight = 0;
  40246. this.optimizer.reset();
  40247. }
  40248. }
  40249. exports.OperatorList = OperatorList;
  40250. /***/ }),
  40251. /* 65 */
  40252. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  40253. Object.defineProperty(exports, "__esModule", ({
  40254. value: true
  40255. }));
  40256. exports.PDFImage = void 0;
  40257. var _util = __w_pdfjs_require__(2);
  40258. var _image_utils = __w_pdfjs_require__(28);
  40259. var _base_stream = __w_pdfjs_require__(5);
  40260. var _colorspace = __w_pdfjs_require__(12);
  40261. var _decode_stream = __w_pdfjs_require__(18);
  40262. var _image_resizer = __w_pdfjs_require__(62);
  40263. var _jpeg_stream = __w_pdfjs_require__(26);
  40264. var _jpx = __w_pdfjs_require__(30);
  40265. var _primitives = __w_pdfjs_require__(4);
  40266. function decodeAndClamp(value, addend, coefficient, max) {
  40267. value = addend + value * coefficient;
  40268. if (value < 0) {
  40269. value = 0;
  40270. } else if (value > max) {
  40271. value = max;
  40272. }
  40273. return value;
  40274. }
  40275. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  40276. const length = w2 * h2;
  40277. let dest;
  40278. if (bpc <= 8) {
  40279. dest = new Uint8Array(length);
  40280. } else if (bpc <= 16) {
  40281. dest = new Uint16Array(length);
  40282. } else {
  40283. dest = new Uint32Array(length);
  40284. }
  40285. const xRatio = w1 / w2;
  40286. const yRatio = h1 / h2;
  40287. let i,
  40288. j,
  40289. py,
  40290. newIndex = 0,
  40291. oldIndex;
  40292. const xScaled = new Uint16Array(w2);
  40293. const w1Scanline = w1;
  40294. for (i = 0; i < w2; i++) {
  40295. xScaled[i] = Math.floor(i * xRatio);
  40296. }
  40297. for (i = 0; i < h2; i++) {
  40298. py = Math.floor(i * yRatio) * w1Scanline;
  40299. for (j = 0; j < w2; j++) {
  40300. oldIndex = py + xScaled[j];
  40301. dest[newIndex++] = src[oldIndex];
  40302. }
  40303. }
  40304. return dest;
  40305. }
  40306. class PDFImage {
  40307. constructor({
  40308. xref,
  40309. res,
  40310. image,
  40311. isInline = false,
  40312. smask = null,
  40313. mask = null,
  40314. isMask = false,
  40315. pdfFunctionFactory,
  40316. localColorSpaceCache
  40317. }) {
  40318. this.image = image;
  40319. const dict = image.dict;
  40320. const filter = dict.get("F", "Filter");
  40321. let filterName;
  40322. if (filter instanceof _primitives.Name) {
  40323. filterName = filter.name;
  40324. } else if (Array.isArray(filter)) {
  40325. const filterZero = xref.fetchIfRef(filter[0]);
  40326. if (filterZero instanceof _primitives.Name) {
  40327. filterName = filterZero.name;
  40328. }
  40329. }
  40330. switch (filterName) {
  40331. case "JPXDecode":
  40332. const jpxImage = new _jpx.JpxImage();
  40333. jpxImage.parseImageProperties(image.stream);
  40334. image.stream.reset();
  40335. image.width = jpxImage.width;
  40336. image.height = jpxImage.height;
  40337. image.bitsPerComponent = jpxImage.bitsPerComponent;
  40338. image.numComps = jpxImage.componentsCount;
  40339. break;
  40340. case "JBIG2Decode":
  40341. image.bitsPerComponent = 1;
  40342. image.numComps = 1;
  40343. break;
  40344. }
  40345. let width = dict.get("W", "Width");
  40346. let height = dict.get("H", "Height");
  40347. if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
  40348. (0, _util.warn)("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
  40349. width = image.width;
  40350. height = image.height;
  40351. }
  40352. if (width < 1 || height < 1) {
  40353. throw new _util.FormatError(`Invalid image width: ${width} or height: ${height}`);
  40354. }
  40355. this.width = width;
  40356. this.height = height;
  40357. this.interpolate = dict.get("I", "Interpolate");
  40358. this.imageMask = dict.get("IM", "ImageMask") || false;
  40359. this.matte = dict.get("Matte") || false;
  40360. let bitsPerComponent = image.bitsPerComponent;
  40361. if (!bitsPerComponent) {
  40362. bitsPerComponent = dict.get("BPC", "BitsPerComponent");
  40363. if (!bitsPerComponent) {
  40364. if (this.imageMask) {
  40365. bitsPerComponent = 1;
  40366. } else {
  40367. throw new _util.FormatError(`Bits per component missing in image: ${this.imageMask}`);
  40368. }
  40369. }
  40370. }
  40371. this.bpc = bitsPerComponent;
  40372. if (!this.imageMask) {
  40373. let colorSpace = dict.getRaw("CS") || dict.getRaw("ColorSpace");
  40374. if (!colorSpace) {
  40375. (0, _util.info)("JPX images (which do not require color spaces)");
  40376. switch (image.numComps) {
  40377. case 1:
  40378. colorSpace = _primitives.Name.get("DeviceGray");
  40379. break;
  40380. case 3:
  40381. colorSpace = _primitives.Name.get("DeviceRGB");
  40382. break;
  40383. case 4:
  40384. colorSpace = _primitives.Name.get("DeviceCMYK");
  40385. break;
  40386. default:
  40387. throw new Error(`JPX images with ${image.numComps} color components not supported.`);
  40388. }
  40389. }
  40390. this.colorSpace = _colorspace.ColorSpace.parse({
  40391. cs: colorSpace,
  40392. xref,
  40393. resources: isInline ? res : null,
  40394. pdfFunctionFactory,
  40395. localColorSpaceCache
  40396. });
  40397. this.numComps = this.colorSpace.numComps;
  40398. }
  40399. this.decode = dict.getArray("D", "Decode");
  40400. this.needsDecode = false;
  40401. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
  40402. this.needsDecode = true;
  40403. const max = (1 << bitsPerComponent) - 1;
  40404. this.decodeCoefficients = [];
  40405. this.decodeAddends = [];
  40406. const isIndexed = this.colorSpace?.name === "Indexed";
  40407. for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  40408. const dmin = this.decode[i];
  40409. const dmax = this.decode[i + 1];
  40410. this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
  40411. this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
  40412. }
  40413. }
  40414. if (smask) {
  40415. this.smask = new PDFImage({
  40416. xref,
  40417. res,
  40418. image: smask,
  40419. isInline,
  40420. pdfFunctionFactory,
  40421. localColorSpaceCache
  40422. });
  40423. } else if (mask) {
  40424. if (mask instanceof _base_stream.BaseStream) {
  40425. const maskDict = mask.dict,
  40426. imageMask = maskDict.get("IM", "ImageMask");
  40427. if (!imageMask) {
  40428. (0, _util.warn)("Ignoring /Mask in image without /ImageMask.");
  40429. } else {
  40430. this.mask = new PDFImage({
  40431. xref,
  40432. res,
  40433. image: mask,
  40434. isInline,
  40435. isMask: true,
  40436. pdfFunctionFactory,
  40437. localColorSpaceCache
  40438. });
  40439. }
  40440. } else {
  40441. this.mask = mask;
  40442. }
  40443. }
  40444. }
  40445. static async buildImage({
  40446. xref,
  40447. res,
  40448. image,
  40449. isInline = false,
  40450. pdfFunctionFactory,
  40451. localColorSpaceCache
  40452. }) {
  40453. const imageData = image;
  40454. let smaskData = null;
  40455. let maskData = null;
  40456. const smask = image.dict.get("SMask");
  40457. const mask = image.dict.get("Mask");
  40458. if (smask) {
  40459. if (smask instanceof _base_stream.BaseStream) {
  40460. smaskData = smask;
  40461. } else {
  40462. (0, _util.warn)("Unsupported /SMask format.");
  40463. }
  40464. } else if (mask) {
  40465. if (mask instanceof _base_stream.BaseStream || Array.isArray(mask)) {
  40466. maskData = mask;
  40467. } else {
  40468. (0, _util.warn)("Unsupported /Mask format.");
  40469. }
  40470. }
  40471. return new PDFImage({
  40472. xref,
  40473. res,
  40474. image: imageData,
  40475. isInline,
  40476. smask: smaskData,
  40477. mask: maskData,
  40478. pdfFunctionFactory,
  40479. localColorSpaceCache
  40480. });
  40481. }
  40482. static createRawMask({
  40483. imgArray,
  40484. width,
  40485. height,
  40486. imageIsFromDecodeStream,
  40487. inverseDecode,
  40488. interpolate
  40489. }) {
  40490. const computedLength = (width + 7 >> 3) * height;
  40491. const actualLength = imgArray.byteLength;
  40492. const haveFullData = computedLength === actualLength;
  40493. let data, i;
  40494. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  40495. data = imgArray;
  40496. } else if (!inverseDecode) {
  40497. data = new Uint8Array(imgArray);
  40498. } else {
  40499. data = new Uint8Array(computedLength);
  40500. data.set(imgArray);
  40501. data.fill(0xff, actualLength);
  40502. }
  40503. if (inverseDecode) {
  40504. for (i = 0; i < actualLength; i++) {
  40505. data[i] ^= 0xff;
  40506. }
  40507. }
  40508. return {
  40509. data,
  40510. width,
  40511. height,
  40512. interpolate
  40513. };
  40514. }
  40515. static async createMask({
  40516. imgArray,
  40517. width,
  40518. height,
  40519. imageIsFromDecodeStream,
  40520. inverseDecode,
  40521. interpolate,
  40522. isOffscreenCanvasSupported = false
  40523. }) {
  40524. const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128));
  40525. if (isSingleOpaquePixel) {
  40526. return {
  40527. isSingleOpaquePixel
  40528. };
  40529. }
  40530. if (isOffscreenCanvasSupported) {
  40531. if (_image_resizer.ImageResizer.needsToBeResized(width, height)) {
  40532. const data = new Uint8ClampedArray(width * height * 4);
  40533. (0, _image_utils.convertBlackAndWhiteToRGBA)({
  40534. src: imgArray,
  40535. dest: data,
  40536. width,
  40537. height,
  40538. nonBlackColor: 0,
  40539. inverseDecode
  40540. });
  40541. return _image_resizer.ImageResizer.createImage({
  40542. kind: _util.ImageKind.RGBA_32BPP,
  40543. data,
  40544. width,
  40545. height,
  40546. interpolate
  40547. });
  40548. }
  40549. const canvas = new OffscreenCanvas(width, height);
  40550. const ctx = canvas.getContext("2d");
  40551. const imgData = ctx.createImageData(width, height);
  40552. (0, _image_utils.convertBlackAndWhiteToRGBA)({
  40553. src: imgArray,
  40554. dest: imgData.data,
  40555. width,
  40556. height,
  40557. nonBlackColor: 0,
  40558. inverseDecode
  40559. });
  40560. ctx.putImageData(imgData, 0, 0);
  40561. const bitmap = canvas.transferToImageBitmap();
  40562. return {
  40563. data: null,
  40564. width,
  40565. height,
  40566. interpolate,
  40567. bitmap
  40568. };
  40569. }
  40570. return this.createRawMask({
  40571. imgArray,
  40572. width,
  40573. height,
  40574. inverseDecode,
  40575. imageIsFromDecodeStream,
  40576. interpolate
  40577. });
  40578. }
  40579. get drawWidth() {
  40580. return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
  40581. }
  40582. get drawHeight() {
  40583. return Math.max(this.height, this.smask?.height || 0, this.mask?.height || 0);
  40584. }
  40585. decodeBuffer(buffer) {
  40586. const bpc = this.bpc;
  40587. const numComps = this.numComps;
  40588. const decodeAddends = this.decodeAddends;
  40589. const decodeCoefficients = this.decodeCoefficients;
  40590. const max = (1 << bpc) - 1;
  40591. let i, ii;
  40592. if (bpc === 1) {
  40593. for (i = 0, ii = buffer.length; i < ii; i++) {
  40594. buffer[i] = +!buffer[i];
  40595. }
  40596. return;
  40597. }
  40598. let index = 0;
  40599. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  40600. for (let j = 0; j < numComps; j++) {
  40601. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  40602. index++;
  40603. }
  40604. }
  40605. }
  40606. getComponents(buffer) {
  40607. const bpc = this.bpc;
  40608. if (bpc === 8) {
  40609. return buffer;
  40610. }
  40611. const width = this.width;
  40612. const height = this.height;
  40613. const numComps = this.numComps;
  40614. const length = width * height * numComps;
  40615. let bufferPos = 0;
  40616. let output;
  40617. if (bpc <= 8) {
  40618. output = new Uint8Array(length);
  40619. } else if (bpc <= 16) {
  40620. output = new Uint16Array(length);
  40621. } else {
  40622. output = new Uint32Array(length);
  40623. }
  40624. const rowComps = width * numComps;
  40625. const max = (1 << bpc) - 1;
  40626. let i = 0,
  40627. ii,
  40628. buf;
  40629. if (bpc === 1) {
  40630. let mask, loop1End, loop2End;
  40631. for (let j = 0; j < height; j++) {
  40632. loop1End = i + (rowComps & ~7);
  40633. loop2End = i + rowComps;
  40634. while (i < loop1End) {
  40635. buf = buffer[bufferPos++];
  40636. output[i] = buf >> 7 & 1;
  40637. output[i + 1] = buf >> 6 & 1;
  40638. output[i + 2] = buf >> 5 & 1;
  40639. output[i + 3] = buf >> 4 & 1;
  40640. output[i + 4] = buf >> 3 & 1;
  40641. output[i + 5] = buf >> 2 & 1;
  40642. output[i + 6] = buf >> 1 & 1;
  40643. output[i + 7] = buf & 1;
  40644. i += 8;
  40645. }
  40646. if (i < loop2End) {
  40647. buf = buffer[bufferPos++];
  40648. mask = 128;
  40649. while (i < loop2End) {
  40650. output[i++] = +!!(buf & mask);
  40651. mask >>= 1;
  40652. }
  40653. }
  40654. }
  40655. } else {
  40656. let bits = 0;
  40657. buf = 0;
  40658. for (i = 0, ii = length; i < ii; ++i) {
  40659. if (i % rowComps === 0) {
  40660. buf = 0;
  40661. bits = 0;
  40662. }
  40663. while (bits < bpc) {
  40664. buf = buf << 8 | buffer[bufferPos++];
  40665. bits += 8;
  40666. }
  40667. const remainingBits = bits - bpc;
  40668. let value = buf >> remainingBits;
  40669. if (value < 0) {
  40670. value = 0;
  40671. } else if (value > max) {
  40672. value = max;
  40673. }
  40674. output[i] = value;
  40675. buf &= (1 << remainingBits) - 1;
  40676. bits = remainingBits;
  40677. }
  40678. }
  40679. return output;
  40680. }
  40681. fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  40682. const smask = this.smask;
  40683. const mask = this.mask;
  40684. let alphaBuf, sw, sh, i, ii, j;
  40685. if (smask) {
  40686. sw = smask.width;
  40687. sh = smask.height;
  40688. alphaBuf = new Uint8ClampedArray(sw * sh);
  40689. smask.fillGrayBuffer(alphaBuf);
  40690. if (sw !== width || sh !== height) {
  40691. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  40692. }
  40693. } else if (mask) {
  40694. if (mask instanceof PDFImage) {
  40695. sw = mask.width;
  40696. sh = mask.height;
  40697. alphaBuf = new Uint8ClampedArray(sw * sh);
  40698. mask.numComps = 1;
  40699. mask.fillGrayBuffer(alphaBuf);
  40700. for (i = 0, ii = sw * sh; i < ii; ++i) {
  40701. alphaBuf[i] = 255 - alphaBuf[i];
  40702. }
  40703. if (sw !== width || sh !== height) {
  40704. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  40705. }
  40706. } else if (Array.isArray(mask)) {
  40707. alphaBuf = new Uint8ClampedArray(width * height);
  40708. const numComps = this.numComps;
  40709. for (i = 0, ii = width * height; i < ii; ++i) {
  40710. let opacity = 0;
  40711. const imageOffset = i * numComps;
  40712. for (j = 0; j < numComps; ++j) {
  40713. const color = image[imageOffset + j];
  40714. const maskOffset = j * 2;
  40715. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  40716. opacity = 255;
  40717. break;
  40718. }
  40719. }
  40720. alphaBuf[i] = opacity;
  40721. }
  40722. } else {
  40723. throw new _util.FormatError("Unknown mask format.");
  40724. }
  40725. }
  40726. if (alphaBuf) {
  40727. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  40728. rgbaBuf[j] = alphaBuf[i];
  40729. }
  40730. } else {
  40731. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  40732. rgbaBuf[j] = 255;
  40733. }
  40734. }
  40735. }
  40736. undoPreblend(buffer, width, height) {
  40737. const matte = this.smask?.matte;
  40738. if (!matte) {
  40739. return;
  40740. }
  40741. const matteRgb = this.colorSpace.getRgb(matte, 0);
  40742. const matteR = matteRgb[0];
  40743. const matteG = matteRgb[1];
  40744. const matteB = matteRgb[2];
  40745. const length = width * height * 4;
  40746. for (let i = 0; i < length; i += 4) {
  40747. const alpha = buffer[i + 3];
  40748. if (alpha === 0) {
  40749. buffer[i] = 255;
  40750. buffer[i + 1] = 255;
  40751. buffer[i + 2] = 255;
  40752. continue;
  40753. }
  40754. const k = 255 / alpha;
  40755. buffer[i] = (buffer[i] - matteR) * k + matteR;
  40756. buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG;
  40757. buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB;
  40758. }
  40759. }
  40760. async createImageData(forceRGBA = false, isOffscreenCanvasSupported = false) {
  40761. const drawWidth = this.drawWidth;
  40762. const drawHeight = this.drawHeight;
  40763. const imgData = {
  40764. width: drawWidth,
  40765. height: drawHeight,
  40766. interpolate: this.interpolate,
  40767. kind: 0,
  40768. data: null
  40769. };
  40770. const numComps = this.numComps;
  40771. const originalWidth = this.width;
  40772. const originalHeight = this.height;
  40773. const bpc = this.bpc;
  40774. const rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  40775. const mustBeResized = isOffscreenCanvasSupported && _image_resizer.ImageResizer.needsToBeResized(drawWidth, drawHeight);
  40776. if (!forceRGBA) {
  40777. let kind;
  40778. if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
  40779. kind = _util.ImageKind.GRAYSCALE_1BPP;
  40780. } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) {
  40781. kind = _util.ImageKind.RGB_24BPP;
  40782. }
  40783. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  40784. const data = this.getImageBytes(originalHeight * rowBytes, {});
  40785. if (isOffscreenCanvasSupported) {
  40786. if (mustBeResized) {
  40787. return _image_resizer.ImageResizer.createImage({
  40788. data,
  40789. kind,
  40790. width: drawWidth,
  40791. height: drawHeight,
  40792. interpolate: this.interpolate
  40793. }, this.needsDecode);
  40794. }
  40795. return this.createBitmap(kind, originalWidth, originalHeight, data);
  40796. }
  40797. imgData.kind = kind;
  40798. imgData.data = data;
  40799. if (this.needsDecode) {
  40800. (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
  40801. const buffer = imgData.data;
  40802. for (let i = 0, ii = buffer.length; i < ii; i++) {
  40803. buffer[i] ^= 0xff;
  40804. }
  40805. }
  40806. return imgData;
  40807. }
  40808. if (this.image instanceof _jpeg_stream.JpegStream && !this.smask && !this.mask && !this.needsDecode) {
  40809. let imageLength = originalHeight * rowBytes;
  40810. if (isOffscreenCanvasSupported && !mustBeResized) {
  40811. let isHandled = false;
  40812. switch (this.colorSpace.name) {
  40813. case "DeviceGray":
  40814. imageLength *= 4;
  40815. isHandled = true;
  40816. break;
  40817. case "DeviceRGB":
  40818. imageLength = imageLength / 3 * 4;
  40819. isHandled = true;
  40820. break;
  40821. case "DeviceCMYK":
  40822. isHandled = true;
  40823. break;
  40824. }
  40825. if (isHandled) {
  40826. const rgba = this.getImageBytes(imageLength, {
  40827. drawWidth,
  40828. drawHeight,
  40829. forceRGBA: true
  40830. });
  40831. return this.createBitmap(_util.ImageKind.RGBA_32BPP, drawWidth, drawHeight, rgba);
  40832. }
  40833. } else {
  40834. switch (this.colorSpace.name) {
  40835. case "DeviceGray":
  40836. imageLength *= 3;
  40837. case "DeviceRGB":
  40838. case "DeviceCMYK":
  40839. imgData.kind = _util.ImageKind.RGB_24BPP;
  40840. imgData.data = this.getImageBytes(imageLength, {
  40841. drawWidth,
  40842. drawHeight,
  40843. forceRGB: true
  40844. });
  40845. if (mustBeResized) {
  40846. return _image_resizer.ImageResizer.createImage(imgData);
  40847. }
  40848. return imgData;
  40849. }
  40850. }
  40851. }
  40852. }
  40853. const imgArray = this.getImageBytes(originalHeight * rowBytes, {
  40854. internal: true
  40855. });
  40856. const actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  40857. const comps = this.getComponents(imgArray);
  40858. let alpha01, maybeUndoPreblend;
  40859. let canvas, ctx, canvasImgData, data;
  40860. if (isOffscreenCanvasSupported && !mustBeResized) {
  40861. canvas = new OffscreenCanvas(drawWidth, drawHeight);
  40862. ctx = canvas.getContext("2d");
  40863. canvasImgData = ctx.createImageData(drawWidth, drawHeight);
  40864. data = canvasImgData.data;
  40865. }
  40866. imgData.kind = _util.ImageKind.RGBA_32BPP;
  40867. if (!forceRGBA && !this.smask && !this.mask) {
  40868. if (!isOffscreenCanvasSupported || mustBeResized) {
  40869. imgData.kind = _util.ImageKind.RGB_24BPP;
  40870. data = new Uint8ClampedArray(drawWidth * drawHeight * 3);
  40871. alpha01 = 0;
  40872. } else {
  40873. const arr = new Uint32Array(data.buffer);
  40874. arr.fill(_util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff);
  40875. alpha01 = 1;
  40876. }
  40877. maybeUndoPreblend = false;
  40878. } else {
  40879. if (!isOffscreenCanvasSupported || mustBeResized) {
  40880. data = new Uint8ClampedArray(drawWidth * drawHeight * 4);
  40881. }
  40882. alpha01 = 1;
  40883. maybeUndoPreblend = true;
  40884. this.fillOpacity(data, drawWidth, drawHeight, actualHeight, comps);
  40885. }
  40886. if (this.needsDecode) {
  40887. this.decodeBuffer(comps);
  40888. }
  40889. this.colorSpace.fillRgb(data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  40890. if (maybeUndoPreblend) {
  40891. this.undoPreblend(data, drawWidth, actualHeight);
  40892. }
  40893. if (isOffscreenCanvasSupported && !mustBeResized) {
  40894. ctx.putImageData(canvasImgData, 0, 0);
  40895. const bitmap = canvas.transferToImageBitmap();
  40896. return {
  40897. data: null,
  40898. width: drawWidth,
  40899. height: drawHeight,
  40900. bitmap,
  40901. interpolate: this.interpolate
  40902. };
  40903. }
  40904. imgData.data = data;
  40905. if (mustBeResized) {
  40906. return _image_resizer.ImageResizer.createImage(imgData);
  40907. }
  40908. return imgData;
  40909. }
  40910. fillGrayBuffer(buffer) {
  40911. const numComps = this.numComps;
  40912. if (numComps !== 1) {
  40913. throw new _util.FormatError(`Reading gray scale from a color image: ${numComps}`);
  40914. }
  40915. const width = this.width;
  40916. const height = this.height;
  40917. const bpc = this.bpc;
  40918. const rowBytes = width * numComps * bpc + 7 >> 3;
  40919. const imgArray = this.getImageBytes(height * rowBytes, {
  40920. internal: true
  40921. });
  40922. const comps = this.getComponents(imgArray);
  40923. let i, length;
  40924. if (bpc === 1) {
  40925. length = width * height;
  40926. if (this.needsDecode) {
  40927. for (i = 0; i < length; ++i) {
  40928. buffer[i] = comps[i] - 1 & 255;
  40929. }
  40930. } else {
  40931. for (i = 0; i < length; ++i) {
  40932. buffer[i] = -comps[i] & 255;
  40933. }
  40934. }
  40935. return;
  40936. }
  40937. if (this.needsDecode) {
  40938. this.decodeBuffer(comps);
  40939. }
  40940. length = width * height;
  40941. const scale = 255 / ((1 << bpc) - 1);
  40942. for (i = 0; i < length; ++i) {
  40943. buffer[i] = scale * comps[i];
  40944. }
  40945. }
  40946. createBitmap(kind, width, height, src) {
  40947. const canvas = new OffscreenCanvas(width, height);
  40948. const ctx = canvas.getContext("2d");
  40949. let imgData;
  40950. if (kind === _util.ImageKind.RGBA_32BPP) {
  40951. imgData = new ImageData(src, width, height);
  40952. } else {
  40953. imgData = ctx.createImageData(width, height);
  40954. (0, _image_utils.convertToRGBA)({
  40955. kind,
  40956. src,
  40957. dest: new Uint32Array(imgData.data.buffer),
  40958. width,
  40959. height,
  40960. inverseDecode: this.needsDecode
  40961. });
  40962. }
  40963. ctx.putImageData(imgData, 0, 0);
  40964. const bitmap = canvas.transferToImageBitmap();
  40965. return {
  40966. data: null,
  40967. width,
  40968. height,
  40969. bitmap,
  40970. interpolate: this.interpolate
  40971. };
  40972. }
  40973. getImageBytes(length, {
  40974. drawWidth,
  40975. drawHeight,
  40976. forceRGBA = false,
  40977. forceRGB = false,
  40978. internal = false
  40979. }) {
  40980. this.image.reset();
  40981. this.image.drawWidth = drawWidth || this.width;
  40982. this.image.drawHeight = drawHeight || this.height;
  40983. this.image.forceRGBA = !!forceRGBA;
  40984. this.image.forceRGB = !!forceRGB;
  40985. const imageBytes = this.image.getBytes(length);
  40986. if (internal || this.image instanceof _decode_stream.DecodeStream) {
  40987. return imageBytes;
  40988. }
  40989. (0, _util.assert)(imageBytes instanceof Uint8Array, 'PDFImage.getImageBytes: Unsupported "imageBytes" type.');
  40990. return new Uint8Array(imageBytes);
  40991. }
  40992. }
  40993. exports.PDFImage = PDFImage;
  40994. /***/ }),
  40995. /* 66 */
  40996. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  40997. Object.defineProperty(exports, "__esModule", ({
  40998. value: true
  40999. }));
  41000. exports.incrementalUpdate = incrementalUpdate;
  41001. exports.writeDict = writeDict;
  41002. exports.writeObject = writeObject;
  41003. var _util = __w_pdfjs_require__(2);
  41004. var _primitives = __w_pdfjs_require__(4);
  41005. var _core_utils = __w_pdfjs_require__(3);
  41006. var _xml_parser = __w_pdfjs_require__(67);
  41007. var _base_stream = __w_pdfjs_require__(5);
  41008. var _crypto = __w_pdfjs_require__(68);
  41009. async function writeObject(ref, obj, buffer, transform) {
  41010. buffer.push(`${ref.num} ${ref.gen} obj\n`);
  41011. if (obj instanceof _primitives.Dict) {
  41012. await writeDict(obj, buffer, transform);
  41013. } else if (obj instanceof _base_stream.BaseStream) {
  41014. await writeStream(obj, buffer, transform);
  41015. }
  41016. buffer.push("\nendobj\n");
  41017. }
  41018. async function writeDict(dict, buffer, transform) {
  41019. buffer.push("<<");
  41020. for (const key of dict.getKeys()) {
  41021. buffer.push(` /${(0, _core_utils.escapePDFName)(key)} `);
  41022. await writeValue(dict.getRaw(key), buffer, transform);
  41023. }
  41024. buffer.push(">>");
  41025. }
  41026. async function writeStream(stream, buffer, transform) {
  41027. let string = stream.getString();
  41028. const {
  41029. dict
  41030. } = stream;
  41031. const [filter, params] = await Promise.all([dict.getAsync("Filter"), dict.getAsync("DecodeParms")]);
  41032. const filterZero = Array.isArray(filter) ? await dict.xref.fetchIfRefAsync(filter[0]) : filter;
  41033. const isFilterZeroFlateDecode = (0, _primitives.isName)(filterZero, "FlateDecode");
  41034. const MIN_LENGTH_FOR_COMPRESSING = 256;
  41035. if (typeof CompressionStream !== "undefined" && (string.length >= MIN_LENGTH_FOR_COMPRESSING || isFilterZeroFlateDecode)) {
  41036. try {
  41037. const byteArray = (0, _util.stringToBytes)(string);
  41038. const cs = new CompressionStream("deflate");
  41039. const writer = cs.writable.getWriter();
  41040. writer.write(byteArray);
  41041. writer.close();
  41042. const buf = await new Response(cs.readable).arrayBuffer();
  41043. string = (0, _util.bytesToString)(new Uint8Array(buf));
  41044. let newFilter, newParams;
  41045. if (!filter) {
  41046. newFilter = _primitives.Name.get("FlateDecode");
  41047. } else if (!isFilterZeroFlateDecode) {
  41048. newFilter = Array.isArray(filter) ? [_primitives.Name.get("FlateDecode"), ...filter] : [_primitives.Name.get("FlateDecode"), filter];
  41049. if (params) {
  41050. newParams = Array.isArray(params) ? [null, ...params] : [null, params];
  41051. }
  41052. }
  41053. if (newFilter) {
  41054. dict.set("Filter", newFilter);
  41055. }
  41056. if (newParams) {
  41057. dict.set("DecodeParms", newParams);
  41058. }
  41059. } catch (ex) {
  41060. (0, _util.info)(`writeStream - cannot compress data: "${ex}".`);
  41061. }
  41062. }
  41063. if (transform !== null) {
  41064. string = transform.encryptString(string);
  41065. }
  41066. dict.set("Length", string.length);
  41067. await writeDict(dict, buffer, transform);
  41068. buffer.push(" stream\n", string, "\nendstream");
  41069. }
  41070. async function writeArray(array, buffer, transform) {
  41071. buffer.push("[");
  41072. let first = true;
  41073. for (const val of array) {
  41074. if (!first) {
  41075. buffer.push(" ");
  41076. } else {
  41077. first = false;
  41078. }
  41079. await writeValue(val, buffer, transform);
  41080. }
  41081. buffer.push("]");
  41082. }
  41083. async function writeValue(value, buffer, transform) {
  41084. if (value instanceof _primitives.Name) {
  41085. buffer.push(`/${(0, _core_utils.escapePDFName)(value.name)}`);
  41086. } else if (value instanceof _primitives.Ref) {
  41087. buffer.push(`${value.num} ${value.gen} R`);
  41088. } else if (Array.isArray(value)) {
  41089. await writeArray(value, buffer, transform);
  41090. } else if (typeof value === "string") {
  41091. if (transform !== null) {
  41092. value = transform.encryptString(value);
  41093. }
  41094. buffer.push(`(${(0, _core_utils.escapeString)(value)})`);
  41095. } else if (typeof value === "number") {
  41096. buffer.push((0, _core_utils.numberToString)(value));
  41097. } else if (typeof value === "boolean") {
  41098. buffer.push(value.toString());
  41099. } else if (value instanceof _primitives.Dict) {
  41100. await writeDict(value, buffer, transform);
  41101. } else if (value instanceof _base_stream.BaseStream) {
  41102. await writeStream(value, buffer, transform);
  41103. } else if (value === null) {
  41104. buffer.push("null");
  41105. } else {
  41106. (0, _util.warn)(`Unhandled value in writer: ${typeof value}, please file a bug.`);
  41107. }
  41108. }
  41109. function writeInt(number, size, offset, buffer) {
  41110. for (let i = size + offset - 1; i > offset - 1; i--) {
  41111. buffer[i] = number & 0xff;
  41112. number >>= 8;
  41113. }
  41114. return offset + size;
  41115. }
  41116. function writeString(string, offset, buffer) {
  41117. for (let i = 0, len = string.length; i < len; i++) {
  41118. buffer[offset + i] = string.charCodeAt(i) & 0xff;
  41119. }
  41120. }
  41121. function computeMD5(filesize, xrefInfo) {
  41122. const time = Math.floor(Date.now() / 1000);
  41123. const filename = xrefInfo.filename || "";
  41124. const md5Buffer = [time.toString(), filename, filesize.toString()];
  41125. let md5BufferLen = md5Buffer.reduce((a, str) => a + str.length, 0);
  41126. for (const value of Object.values(xrefInfo.info)) {
  41127. md5Buffer.push(value);
  41128. md5BufferLen += value.length;
  41129. }
  41130. const array = new Uint8Array(md5BufferLen);
  41131. let offset = 0;
  41132. for (const str of md5Buffer) {
  41133. writeString(str, offset, array);
  41134. offset += str.length;
  41135. }
  41136. return (0, _util.bytesToString)((0, _crypto.calculateMD5)(array));
  41137. }
  41138. function writeXFADataForAcroform(str, newRefs) {
  41139. const xml = new _xml_parser.SimpleXMLParser({
  41140. hasAttributes: true
  41141. }).parseFromString(str);
  41142. for (const {
  41143. xfa
  41144. } of newRefs) {
  41145. if (!xfa) {
  41146. continue;
  41147. }
  41148. const {
  41149. path,
  41150. value
  41151. } = xfa;
  41152. if (!path) {
  41153. continue;
  41154. }
  41155. const nodePath = (0, _core_utils.parseXFAPath)(path);
  41156. let node = xml.documentElement.searchNode(nodePath, 0);
  41157. if (!node && nodePath.length > 1) {
  41158. node = xml.documentElement.searchNode([nodePath.at(-1)], 0);
  41159. }
  41160. if (node) {
  41161. node.childNodes = Array.isArray(value) ? value.map(val => new _xml_parser.SimpleDOMNode("value", val)) : [new _xml_parser.SimpleDOMNode("#text", value)];
  41162. } else {
  41163. (0, _util.warn)(`Node not found for path: ${path}`);
  41164. }
  41165. }
  41166. const buffer = [];
  41167. xml.documentElement.dump(buffer);
  41168. return buffer.join("");
  41169. }
  41170. async function updateAcroform({
  41171. xref,
  41172. acroForm,
  41173. acroFormRef,
  41174. hasXfa,
  41175. hasXfaDatasetsEntry,
  41176. xfaDatasetsRef,
  41177. needAppearances,
  41178. newRefs
  41179. }) {
  41180. if (hasXfa && !hasXfaDatasetsEntry && !xfaDatasetsRef) {
  41181. (0, _util.warn)("XFA - Cannot save it");
  41182. }
  41183. if (!needAppearances && (!hasXfa || !xfaDatasetsRef || hasXfaDatasetsEntry)) {
  41184. return;
  41185. }
  41186. const dict = new _primitives.Dict(xref);
  41187. for (const key of acroForm.getKeys()) {
  41188. dict.set(key, acroForm.getRaw(key));
  41189. }
  41190. if (hasXfa && !hasXfaDatasetsEntry) {
  41191. const newXfa = acroForm.get("XFA").slice();
  41192. newXfa.splice(2, 0, "datasets");
  41193. newXfa.splice(3, 0, xfaDatasetsRef);
  41194. dict.set("XFA", newXfa);
  41195. }
  41196. if (needAppearances) {
  41197. dict.set("NeedAppearances", true);
  41198. }
  41199. const encrypt = xref.encrypt;
  41200. let transform = null;
  41201. if (encrypt) {
  41202. transform = encrypt.createCipherTransform(acroFormRef.num, acroFormRef.gen);
  41203. }
  41204. const buffer = [];
  41205. await writeObject(acroFormRef, dict, buffer, transform);
  41206. newRefs.push({
  41207. ref: acroFormRef,
  41208. data: buffer.join("")
  41209. });
  41210. }
  41211. function updateXFA({
  41212. xfaData,
  41213. xfaDatasetsRef,
  41214. newRefs,
  41215. xref
  41216. }) {
  41217. if (xfaData === null) {
  41218. const datasets = xref.fetchIfRef(xfaDatasetsRef);
  41219. xfaData = writeXFADataForAcroform(datasets.getString(), newRefs);
  41220. }
  41221. const encrypt = xref.encrypt;
  41222. if (encrypt) {
  41223. const transform = encrypt.createCipherTransform(xfaDatasetsRef.num, xfaDatasetsRef.gen);
  41224. xfaData = transform.encryptString(xfaData);
  41225. }
  41226. const data = `${xfaDatasetsRef.num} ${xfaDatasetsRef.gen} obj\n` + `<< /Type /EmbeddedFile /Length ${xfaData.length}>>\nstream\n` + xfaData + "\nendstream\nendobj\n";
  41227. newRefs.push({
  41228. ref: xfaDatasetsRef,
  41229. data
  41230. });
  41231. }
  41232. async function incrementalUpdate({
  41233. originalData,
  41234. xrefInfo,
  41235. newRefs,
  41236. xref = null,
  41237. hasXfa = false,
  41238. xfaDatasetsRef = null,
  41239. hasXfaDatasetsEntry = false,
  41240. needAppearances,
  41241. acroFormRef = null,
  41242. acroForm = null,
  41243. xfaData = null
  41244. }) {
  41245. await updateAcroform({
  41246. xref,
  41247. acroForm,
  41248. acroFormRef,
  41249. hasXfa,
  41250. hasXfaDatasetsEntry,
  41251. xfaDatasetsRef,
  41252. needAppearances,
  41253. newRefs
  41254. });
  41255. if (hasXfa) {
  41256. updateXFA({
  41257. xfaData,
  41258. xfaDatasetsRef,
  41259. newRefs,
  41260. xref
  41261. });
  41262. }
  41263. const newXref = new _primitives.Dict(null);
  41264. const refForXrefTable = xrefInfo.newRef;
  41265. let buffer, baseOffset;
  41266. const lastByte = originalData.at(-1);
  41267. if (lastByte === 0x0a || lastByte === 0x0d) {
  41268. buffer = [];
  41269. baseOffset = originalData.length;
  41270. } else {
  41271. buffer = ["\n"];
  41272. baseOffset = originalData.length + 1;
  41273. }
  41274. newXref.set("Size", refForXrefTable.num + 1);
  41275. newXref.set("Prev", xrefInfo.startXRef);
  41276. newXref.set("Type", _primitives.Name.get("XRef"));
  41277. if (xrefInfo.rootRef !== null) {
  41278. newXref.set("Root", xrefInfo.rootRef);
  41279. }
  41280. if (xrefInfo.infoRef !== null) {
  41281. newXref.set("Info", xrefInfo.infoRef);
  41282. }
  41283. if (xrefInfo.encryptRef !== null) {
  41284. newXref.set("Encrypt", xrefInfo.encryptRef);
  41285. }
  41286. newRefs.push({
  41287. ref: refForXrefTable,
  41288. data: ""
  41289. });
  41290. newRefs = newRefs.sort((a, b) => {
  41291. return a.ref.num - b.ref.num;
  41292. });
  41293. const xrefTableData = [[0, 1, 0xffff]];
  41294. const indexes = [0, 1];
  41295. let maxOffset = 0;
  41296. for (const {
  41297. ref,
  41298. data
  41299. } of newRefs) {
  41300. maxOffset = Math.max(maxOffset, baseOffset);
  41301. xrefTableData.push([1, baseOffset, Math.min(ref.gen, 0xffff)]);
  41302. baseOffset += data.length;
  41303. indexes.push(ref.num, 1);
  41304. buffer.push(data);
  41305. }
  41306. newXref.set("Index", indexes);
  41307. if (Array.isArray(xrefInfo.fileIds) && xrefInfo.fileIds.length > 0) {
  41308. const md5 = computeMD5(baseOffset, xrefInfo);
  41309. newXref.set("ID", [xrefInfo.fileIds[0], md5]);
  41310. }
  41311. const offsetSize = Math.ceil(Math.log2(maxOffset) / 8);
  41312. const sizes = [1, offsetSize, 2];
  41313. const structSize = sizes[0] + sizes[1] + sizes[2];
  41314. const tableLength = structSize * xrefTableData.length;
  41315. newXref.set("W", sizes);
  41316. newXref.set("Length", tableLength);
  41317. buffer.push(`${refForXrefTable.num} ${refForXrefTable.gen} obj\n`);
  41318. await writeDict(newXref, buffer, null);
  41319. buffer.push(" stream\n");
  41320. const bufferLen = buffer.reduce((a, str) => a + str.length, 0);
  41321. const footer = `\nendstream\nendobj\nstartxref\n${baseOffset}\n%%EOF\n`;
  41322. const array = new Uint8Array(originalData.length + bufferLen + tableLength + footer.length);
  41323. array.set(originalData);
  41324. let offset = originalData.length;
  41325. for (const str of buffer) {
  41326. writeString(str, offset, array);
  41327. offset += str.length;
  41328. }
  41329. for (const [type, objOffset, gen] of xrefTableData) {
  41330. offset = writeInt(type, sizes[0], offset, array);
  41331. offset = writeInt(objOffset, sizes[1], offset, array);
  41332. offset = writeInt(gen, sizes[2], offset, array);
  41333. }
  41334. writeString(footer, offset, array);
  41335. return array;
  41336. }
  41337. /***/ }),
  41338. /* 67 */
  41339. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  41340. Object.defineProperty(exports, "__esModule", ({
  41341. value: true
  41342. }));
  41343. exports.XMLParserErrorCode = exports.XMLParserBase = exports.SimpleXMLParser = exports.SimpleDOMNode = void 0;
  41344. var _core_utils = __w_pdfjs_require__(3);
  41345. const XMLParserErrorCode = {
  41346. NoError: 0,
  41347. EndOfDocument: -1,
  41348. UnterminatedCdat: -2,
  41349. UnterminatedXmlDeclaration: -3,
  41350. UnterminatedDoctypeDeclaration: -4,
  41351. UnterminatedComment: -5,
  41352. MalformedElement: -6,
  41353. OutOfMemory: -7,
  41354. UnterminatedAttributeValue: -8,
  41355. UnterminatedElement: -9,
  41356. ElementNeverBegun: -10
  41357. };
  41358. exports.XMLParserErrorCode = XMLParserErrorCode;
  41359. function isWhitespace(s, index) {
  41360. const ch = s[index];
  41361. return ch === " " || ch === "\n" || ch === "\r" || ch === "\t";
  41362. }
  41363. function isWhitespaceString(s) {
  41364. for (let i = 0, ii = s.length; i < ii; i++) {
  41365. if (!isWhitespace(s, i)) {
  41366. return false;
  41367. }
  41368. }
  41369. return true;
  41370. }
  41371. class XMLParserBase {
  41372. _resolveEntities(s) {
  41373. return s.replaceAll(/&([^;]+);/g, (all, entity) => {
  41374. if (entity.substring(0, 2) === "#x") {
  41375. return String.fromCodePoint(parseInt(entity.substring(2), 16));
  41376. } else if (entity.substring(0, 1) === "#") {
  41377. return String.fromCodePoint(parseInt(entity.substring(1), 10));
  41378. }
  41379. switch (entity) {
  41380. case "lt":
  41381. return "<";
  41382. case "gt":
  41383. return ">";
  41384. case "amp":
  41385. return "&";
  41386. case "quot":
  41387. return '"';
  41388. case "apos":
  41389. return "'";
  41390. }
  41391. return this.onResolveEntity(entity);
  41392. });
  41393. }
  41394. _parseContent(s, start) {
  41395. const attributes = [];
  41396. let pos = start;
  41397. function skipWs() {
  41398. while (pos < s.length && isWhitespace(s, pos)) {
  41399. ++pos;
  41400. }
  41401. }
  41402. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  41403. ++pos;
  41404. }
  41405. const name = s.substring(start, pos);
  41406. skipWs();
  41407. while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") {
  41408. skipWs();
  41409. let attrName = "",
  41410. attrValue = "";
  41411. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") {
  41412. attrName += s[pos];
  41413. ++pos;
  41414. }
  41415. skipWs();
  41416. if (s[pos] !== "=") {
  41417. return null;
  41418. }
  41419. ++pos;
  41420. skipWs();
  41421. const attrEndChar = s[pos];
  41422. if (attrEndChar !== '"' && attrEndChar !== "'") {
  41423. return null;
  41424. }
  41425. const attrEndIndex = s.indexOf(attrEndChar, ++pos);
  41426. if (attrEndIndex < 0) {
  41427. return null;
  41428. }
  41429. attrValue = s.substring(pos, attrEndIndex);
  41430. attributes.push({
  41431. name: attrName,
  41432. value: this._resolveEntities(attrValue)
  41433. });
  41434. pos = attrEndIndex + 1;
  41435. skipWs();
  41436. }
  41437. return {
  41438. name,
  41439. attributes,
  41440. parsed: pos - start
  41441. };
  41442. }
  41443. _parseProcessingInstruction(s, start) {
  41444. let pos = start;
  41445. function skipWs() {
  41446. while (pos < s.length && isWhitespace(s, pos)) {
  41447. ++pos;
  41448. }
  41449. }
  41450. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "?" && s[pos] !== "/") {
  41451. ++pos;
  41452. }
  41453. const name = s.substring(start, pos);
  41454. skipWs();
  41455. const attrStart = pos;
  41456. while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) {
  41457. ++pos;
  41458. }
  41459. const value = s.substring(attrStart, pos);
  41460. return {
  41461. name,
  41462. value,
  41463. parsed: pos - start
  41464. };
  41465. }
  41466. parseXml(s) {
  41467. let i = 0;
  41468. while (i < s.length) {
  41469. const ch = s[i];
  41470. let j = i;
  41471. if (ch === "<") {
  41472. ++j;
  41473. const ch2 = s[j];
  41474. let q;
  41475. switch (ch2) {
  41476. case "/":
  41477. ++j;
  41478. q = s.indexOf(">", j);
  41479. if (q < 0) {
  41480. this.onError(XMLParserErrorCode.UnterminatedElement);
  41481. return;
  41482. }
  41483. this.onEndElement(s.substring(j, q));
  41484. j = q + 1;
  41485. break;
  41486. case "?":
  41487. ++j;
  41488. const pi = this._parseProcessingInstruction(s, j);
  41489. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") {
  41490. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  41491. return;
  41492. }
  41493. this.onPi(pi.name, pi.value);
  41494. j += pi.parsed + 2;
  41495. break;
  41496. case "!":
  41497. if (s.substring(j + 1, j + 3) === "--") {
  41498. q = s.indexOf("-->", j + 3);
  41499. if (q < 0) {
  41500. this.onError(XMLParserErrorCode.UnterminatedComment);
  41501. return;
  41502. }
  41503. this.onComment(s.substring(j + 3, q));
  41504. j = q + 3;
  41505. } else if (s.substring(j + 1, j + 8) === "[CDATA[") {
  41506. q = s.indexOf("]]>", j + 8);
  41507. if (q < 0) {
  41508. this.onError(XMLParserErrorCode.UnterminatedCdat);
  41509. return;
  41510. }
  41511. this.onCdata(s.substring(j + 8, q));
  41512. j = q + 3;
  41513. } else if (s.substring(j + 1, j + 8) === "DOCTYPE") {
  41514. const q2 = s.indexOf("[", j + 8);
  41515. let complexDoctype = false;
  41516. q = s.indexOf(">", j + 8);
  41517. if (q < 0) {
  41518. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  41519. return;
  41520. }
  41521. if (q2 > 0 && q > q2) {
  41522. q = s.indexOf("]>", j + 8);
  41523. if (q < 0) {
  41524. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  41525. return;
  41526. }
  41527. complexDoctype = true;
  41528. }
  41529. const doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  41530. this.onDoctype(doctypeContent);
  41531. j = q + (complexDoctype ? 2 : 1);
  41532. } else {
  41533. this.onError(XMLParserErrorCode.MalformedElement);
  41534. return;
  41535. }
  41536. break;
  41537. default:
  41538. const content = this._parseContent(s, j);
  41539. if (content === null) {
  41540. this.onError(XMLParserErrorCode.MalformedElement);
  41541. return;
  41542. }
  41543. let isClosed = false;
  41544. if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") {
  41545. isClosed = true;
  41546. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") {
  41547. this.onError(XMLParserErrorCode.UnterminatedElement);
  41548. return;
  41549. }
  41550. this.onBeginElement(content.name, content.attributes, isClosed);
  41551. j += content.parsed + (isClosed ? 2 : 1);
  41552. break;
  41553. }
  41554. } else {
  41555. while (j < s.length && s[j] !== "<") {
  41556. j++;
  41557. }
  41558. const text = s.substring(i, j);
  41559. this.onText(this._resolveEntities(text));
  41560. }
  41561. i = j;
  41562. }
  41563. }
  41564. onResolveEntity(name) {
  41565. return `&${name};`;
  41566. }
  41567. onPi(name, value) {}
  41568. onComment(text) {}
  41569. onCdata(text) {}
  41570. onDoctype(doctypeContent) {}
  41571. onText(text) {}
  41572. onBeginElement(name, attributes, isEmpty) {}
  41573. onEndElement(name) {}
  41574. onError(code) {}
  41575. }
  41576. exports.XMLParserBase = XMLParserBase;
  41577. class SimpleDOMNode {
  41578. constructor(nodeName, nodeValue) {
  41579. this.nodeName = nodeName;
  41580. this.nodeValue = nodeValue;
  41581. Object.defineProperty(this, "parentNode", {
  41582. value: null,
  41583. writable: true
  41584. });
  41585. }
  41586. get firstChild() {
  41587. return this.childNodes?.[0];
  41588. }
  41589. get nextSibling() {
  41590. const childNodes = this.parentNode.childNodes;
  41591. if (!childNodes) {
  41592. return undefined;
  41593. }
  41594. const index = childNodes.indexOf(this);
  41595. if (index === -1) {
  41596. return undefined;
  41597. }
  41598. return childNodes[index + 1];
  41599. }
  41600. get textContent() {
  41601. if (!this.childNodes) {
  41602. return this.nodeValue || "";
  41603. }
  41604. return this.childNodes.map(function (child) {
  41605. return child.textContent;
  41606. }).join("");
  41607. }
  41608. get children() {
  41609. return this.childNodes || [];
  41610. }
  41611. hasChildNodes() {
  41612. return this.childNodes?.length > 0;
  41613. }
  41614. searchNode(paths, pos) {
  41615. if (pos >= paths.length) {
  41616. return this;
  41617. }
  41618. const component = paths[pos];
  41619. const stack = [];
  41620. let node = this;
  41621. while (true) {
  41622. if (component.name === node.nodeName) {
  41623. if (component.pos === 0) {
  41624. const res = node.searchNode(paths, pos + 1);
  41625. if (res !== null) {
  41626. return res;
  41627. }
  41628. } else if (stack.length === 0) {
  41629. return null;
  41630. } else {
  41631. const [parent] = stack.pop();
  41632. let siblingPos = 0;
  41633. for (const child of parent.childNodes) {
  41634. if (component.name === child.nodeName) {
  41635. if (siblingPos === component.pos) {
  41636. return child.searchNode(paths, pos + 1);
  41637. }
  41638. siblingPos++;
  41639. }
  41640. }
  41641. return node.searchNode(paths, pos + 1);
  41642. }
  41643. }
  41644. if (node.childNodes?.length > 0) {
  41645. stack.push([node, 0]);
  41646. node = node.childNodes[0];
  41647. } else if (stack.length === 0) {
  41648. return null;
  41649. } else {
  41650. while (stack.length !== 0) {
  41651. const [parent, currentPos] = stack.pop();
  41652. const newPos = currentPos + 1;
  41653. if (newPos < parent.childNodes.length) {
  41654. stack.push([parent, newPos]);
  41655. node = parent.childNodes[newPos];
  41656. break;
  41657. }
  41658. }
  41659. if (stack.length === 0) {
  41660. return null;
  41661. }
  41662. }
  41663. }
  41664. }
  41665. dump(buffer) {
  41666. if (this.nodeName === "#text") {
  41667. buffer.push((0, _core_utils.encodeToXmlString)(this.nodeValue));
  41668. return;
  41669. }
  41670. buffer.push(`<${this.nodeName}`);
  41671. if (this.attributes) {
  41672. for (const attribute of this.attributes) {
  41673. buffer.push(` ${attribute.name}="${(0, _core_utils.encodeToXmlString)(attribute.value)}"`);
  41674. }
  41675. }
  41676. if (this.hasChildNodes()) {
  41677. buffer.push(">");
  41678. for (const child of this.childNodes) {
  41679. child.dump(buffer);
  41680. }
  41681. buffer.push(`</${this.nodeName}>`);
  41682. } else if (this.nodeValue) {
  41683. buffer.push(`>${(0, _core_utils.encodeToXmlString)(this.nodeValue)}</${this.nodeName}>`);
  41684. } else {
  41685. buffer.push("/>");
  41686. }
  41687. }
  41688. }
  41689. exports.SimpleDOMNode = SimpleDOMNode;
  41690. class SimpleXMLParser extends XMLParserBase {
  41691. constructor({
  41692. hasAttributes = false,
  41693. lowerCaseName = false
  41694. }) {
  41695. super();
  41696. this._currentFragment = null;
  41697. this._stack = null;
  41698. this._errorCode = XMLParserErrorCode.NoError;
  41699. this._hasAttributes = hasAttributes;
  41700. this._lowerCaseName = lowerCaseName;
  41701. }
  41702. parseFromString(data) {
  41703. this._currentFragment = [];
  41704. this._stack = [];
  41705. this._errorCode = XMLParserErrorCode.NoError;
  41706. this.parseXml(data);
  41707. if (this._errorCode !== XMLParserErrorCode.NoError) {
  41708. return undefined;
  41709. }
  41710. const [documentElement] = this._currentFragment;
  41711. if (!documentElement) {
  41712. return undefined;
  41713. }
  41714. return {
  41715. documentElement
  41716. };
  41717. }
  41718. onText(text) {
  41719. if (isWhitespaceString(text)) {
  41720. return;
  41721. }
  41722. const node = new SimpleDOMNode("#text", text);
  41723. this._currentFragment.push(node);
  41724. }
  41725. onCdata(text) {
  41726. const node = new SimpleDOMNode("#text", text);
  41727. this._currentFragment.push(node);
  41728. }
  41729. onBeginElement(name, attributes, isEmpty) {
  41730. if (this._lowerCaseName) {
  41731. name = name.toLowerCase();
  41732. }
  41733. const node = new SimpleDOMNode(name);
  41734. node.childNodes = [];
  41735. if (this._hasAttributes) {
  41736. node.attributes = attributes;
  41737. }
  41738. this._currentFragment.push(node);
  41739. if (isEmpty) {
  41740. return;
  41741. }
  41742. this._stack.push(this._currentFragment);
  41743. this._currentFragment = node.childNodes;
  41744. }
  41745. onEndElement(name) {
  41746. this._currentFragment = this._stack.pop() || [];
  41747. const lastElement = this._currentFragment.at(-1);
  41748. if (!lastElement) {
  41749. return null;
  41750. }
  41751. for (const childNode of lastElement.childNodes) {
  41752. childNode.parentNode = lastElement;
  41753. }
  41754. return lastElement;
  41755. }
  41756. onError(code) {
  41757. this._errorCode = code;
  41758. }
  41759. }
  41760. exports.SimpleXMLParser = SimpleXMLParser;
  41761. /***/ }),
  41762. /* 68 */
  41763. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  41764. Object.defineProperty(exports, "__esModule", ({
  41765. value: true
  41766. }));
  41767. exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
  41768. exports.calculateSHA384 = calculateSHA384;
  41769. exports.calculateSHA512 = void 0;
  41770. var _util = __w_pdfjs_require__(2);
  41771. var _primitives = __w_pdfjs_require__(4);
  41772. var _decrypt_stream = __w_pdfjs_require__(69);
  41773. class ARCFourCipher {
  41774. constructor(key) {
  41775. this.a = 0;
  41776. this.b = 0;
  41777. const s = new Uint8Array(256);
  41778. const keyLength = key.length;
  41779. for (let i = 0; i < 256; ++i) {
  41780. s[i] = i;
  41781. }
  41782. for (let i = 0, j = 0; i < 256; ++i) {
  41783. const tmp = s[i];
  41784. j = j + tmp + key[i % keyLength] & 0xff;
  41785. s[i] = s[j];
  41786. s[j] = tmp;
  41787. }
  41788. this.s = s;
  41789. }
  41790. encryptBlock(data) {
  41791. let a = this.a,
  41792. b = this.b;
  41793. const s = this.s;
  41794. const n = data.length;
  41795. const output = new Uint8Array(n);
  41796. for (let i = 0; i < n; ++i) {
  41797. a = a + 1 & 0xff;
  41798. const tmp = s[a];
  41799. b = b + tmp & 0xff;
  41800. const tmp2 = s[b];
  41801. s[a] = tmp2;
  41802. s[b] = tmp;
  41803. output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
  41804. }
  41805. this.a = a;
  41806. this.b = b;
  41807. return output;
  41808. }
  41809. decryptBlock(data) {
  41810. return this.encryptBlock(data);
  41811. }
  41812. encrypt(data) {
  41813. return this.encryptBlock(data);
  41814. }
  41815. }
  41816. exports.ARCFourCipher = ARCFourCipher;
  41817. const calculateMD5 = function calculateMD5Closure() {
  41818. const r = new Uint8Array([7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]);
  41819. const k = new Int32Array([-680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426, -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162, 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632, 643717713, -373897302, -701558691, 38016083, -660478335, -405537848, 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784, 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556, -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222, -722521979, 76029189, -640364487, -421815835, 530742520, -995338651, -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606, -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649, -145523070, -1120210379, 718787259, -343485551]);
  41820. function hash(data, offset, length) {
  41821. let h0 = 1732584193,
  41822. h1 = -271733879,
  41823. h2 = -1732584194,
  41824. h3 = 271733878;
  41825. const paddedLength = length + 72 & ~63;
  41826. const padded = new Uint8Array(paddedLength);
  41827. let i, j;
  41828. for (i = 0; i < length; ++i) {
  41829. padded[i] = data[offset++];
  41830. }
  41831. padded[i++] = 0x80;
  41832. const n = paddedLength - 8;
  41833. while (i < n) {
  41834. padded[i++] = 0;
  41835. }
  41836. padded[i++] = length << 3 & 0xff;
  41837. padded[i++] = length >> 5 & 0xff;
  41838. padded[i++] = length >> 13 & 0xff;
  41839. padded[i++] = length >> 21 & 0xff;
  41840. padded[i++] = length >>> 29 & 0xff;
  41841. padded[i++] = 0;
  41842. padded[i++] = 0;
  41843. padded[i++] = 0;
  41844. const w = new Int32Array(16);
  41845. for (i = 0; i < paddedLength;) {
  41846. for (j = 0; j < 16; ++j, i += 4) {
  41847. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  41848. }
  41849. let a = h0,
  41850. b = h1,
  41851. c = h2,
  41852. d = h3,
  41853. f,
  41854. g;
  41855. for (j = 0; j < 64; ++j) {
  41856. if (j < 16) {
  41857. f = b & c | ~b & d;
  41858. g = j;
  41859. } else if (j < 32) {
  41860. f = d & b | ~d & c;
  41861. g = 5 * j + 1 & 15;
  41862. } else if (j < 48) {
  41863. f = b ^ c ^ d;
  41864. g = 3 * j + 5 & 15;
  41865. } else {
  41866. f = c ^ (b | ~d);
  41867. g = 7 * j & 15;
  41868. }
  41869. const tmp = d,
  41870. rotateArg = a + f + k[j] + w[g] | 0,
  41871. rotate = r[j];
  41872. d = c;
  41873. c = b;
  41874. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  41875. a = tmp;
  41876. }
  41877. h0 = h0 + a | 0;
  41878. h1 = h1 + b | 0;
  41879. h2 = h2 + c | 0;
  41880. h3 = h3 + d | 0;
  41881. }
  41882. return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]);
  41883. }
  41884. return hash;
  41885. }();
  41886. exports.calculateMD5 = calculateMD5;
  41887. class Word64 {
  41888. constructor(highInteger, lowInteger) {
  41889. this.high = highInteger | 0;
  41890. this.low = lowInteger | 0;
  41891. }
  41892. and(word) {
  41893. this.high &= word.high;
  41894. this.low &= word.low;
  41895. }
  41896. xor(word) {
  41897. this.high ^= word.high;
  41898. this.low ^= word.low;
  41899. }
  41900. or(word) {
  41901. this.high |= word.high;
  41902. this.low |= word.low;
  41903. }
  41904. shiftRight(places) {
  41905. if (places >= 32) {
  41906. this.low = this.high >>> places - 32 | 0;
  41907. this.high = 0;
  41908. } else {
  41909. this.low = this.low >>> places | this.high << 32 - places;
  41910. this.high = this.high >>> places | 0;
  41911. }
  41912. }
  41913. shiftLeft(places) {
  41914. if (places >= 32) {
  41915. this.high = this.low << places - 32;
  41916. this.low = 0;
  41917. } else {
  41918. this.high = this.high << places | this.low >>> 32 - places;
  41919. this.low <<= places;
  41920. }
  41921. }
  41922. rotateRight(places) {
  41923. let low, high;
  41924. if (places & 32) {
  41925. high = this.low;
  41926. low = this.high;
  41927. } else {
  41928. low = this.low;
  41929. high = this.high;
  41930. }
  41931. places &= 31;
  41932. this.low = low >>> places | high << 32 - places;
  41933. this.high = high >>> places | low << 32 - places;
  41934. }
  41935. not() {
  41936. this.high = ~this.high;
  41937. this.low = ~this.low;
  41938. }
  41939. add(word) {
  41940. const lowAdd = (this.low >>> 0) + (word.low >>> 0);
  41941. let highAdd = (this.high >>> 0) + (word.high >>> 0);
  41942. if (lowAdd > 0xffffffff) {
  41943. highAdd += 1;
  41944. }
  41945. this.low = lowAdd | 0;
  41946. this.high = highAdd | 0;
  41947. }
  41948. copyTo(bytes, offset) {
  41949. bytes[offset] = this.high >>> 24 & 0xff;
  41950. bytes[offset + 1] = this.high >> 16 & 0xff;
  41951. bytes[offset + 2] = this.high >> 8 & 0xff;
  41952. bytes[offset + 3] = this.high & 0xff;
  41953. bytes[offset + 4] = this.low >>> 24 & 0xff;
  41954. bytes[offset + 5] = this.low >> 16 & 0xff;
  41955. bytes[offset + 6] = this.low >> 8 & 0xff;
  41956. bytes[offset + 7] = this.low & 0xff;
  41957. }
  41958. assign(word) {
  41959. this.high = word.high;
  41960. this.low = word.low;
  41961. }
  41962. }
  41963. const calculateSHA256 = function calculateSHA256Closure() {
  41964. function rotr(x, n) {
  41965. return x >>> n | x << 32 - n;
  41966. }
  41967. function ch(x, y, z) {
  41968. return x & y ^ ~x & z;
  41969. }
  41970. function maj(x, y, z) {
  41971. return x & y ^ x & z ^ y & z;
  41972. }
  41973. function sigma(x) {
  41974. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  41975. }
  41976. function sigmaPrime(x) {
  41977. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  41978. }
  41979. function littleSigma(x) {
  41980. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  41981. }
  41982. function littleSigmaPrime(x) {
  41983. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  41984. }
  41985. const k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
  41986. function hash(data, offset, length) {
  41987. let h0 = 0x6a09e667,
  41988. h1 = 0xbb67ae85,
  41989. h2 = 0x3c6ef372,
  41990. h3 = 0xa54ff53a,
  41991. h4 = 0x510e527f,
  41992. h5 = 0x9b05688c,
  41993. h6 = 0x1f83d9ab,
  41994. h7 = 0x5be0cd19;
  41995. const paddedLength = Math.ceil((length + 9) / 64) * 64;
  41996. const padded = new Uint8Array(paddedLength);
  41997. let i, j;
  41998. for (i = 0; i < length; ++i) {
  41999. padded[i] = data[offset++];
  42000. }
  42001. padded[i++] = 0x80;
  42002. const n = paddedLength - 8;
  42003. while (i < n) {
  42004. padded[i++] = 0;
  42005. }
  42006. padded[i++] = 0;
  42007. padded[i++] = 0;
  42008. padded[i++] = 0;
  42009. padded[i++] = length >>> 29 & 0xff;
  42010. padded[i++] = length >> 21 & 0xff;
  42011. padded[i++] = length >> 13 & 0xff;
  42012. padded[i++] = length >> 5 & 0xff;
  42013. padded[i++] = length << 3 & 0xff;
  42014. const w = new Uint32Array(64);
  42015. for (i = 0; i < paddedLength;) {
  42016. for (j = 0; j < 16; ++j) {
  42017. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  42018. i += 4;
  42019. }
  42020. for (j = 16; j < 64; ++j) {
  42021. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  42022. }
  42023. let a = h0,
  42024. b = h1,
  42025. c = h2,
  42026. d = h3,
  42027. e = h4,
  42028. f = h5,
  42029. g = h6,
  42030. h = h7,
  42031. t1,
  42032. t2;
  42033. for (j = 0; j < 64; ++j) {
  42034. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  42035. t2 = sigma(a) + maj(a, b, c);
  42036. h = g;
  42037. g = f;
  42038. f = e;
  42039. e = d + t1 | 0;
  42040. d = c;
  42041. c = b;
  42042. b = a;
  42043. a = t1 + t2 | 0;
  42044. }
  42045. h0 = h0 + a | 0;
  42046. h1 = h1 + b | 0;
  42047. h2 = h2 + c | 0;
  42048. h3 = h3 + d | 0;
  42049. h4 = h4 + e | 0;
  42050. h5 = h5 + f | 0;
  42051. h6 = h6 + g | 0;
  42052. h7 = h7 + h | 0;
  42053. }
  42054. return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]);
  42055. }
  42056. return hash;
  42057. }();
  42058. exports.calculateSHA256 = calculateSHA256;
  42059. const calculateSHA512 = function calculateSHA512Closure() {
  42060. function ch(result, x, y, z, tmp) {
  42061. result.assign(x);
  42062. result.and(y);
  42063. tmp.assign(x);
  42064. tmp.not();
  42065. tmp.and(z);
  42066. result.xor(tmp);
  42067. }
  42068. function maj(result, x, y, z, tmp) {
  42069. result.assign(x);
  42070. result.and(y);
  42071. tmp.assign(x);
  42072. tmp.and(z);
  42073. result.xor(tmp);
  42074. tmp.assign(y);
  42075. tmp.and(z);
  42076. result.xor(tmp);
  42077. }
  42078. function sigma(result, x, tmp) {
  42079. result.assign(x);
  42080. result.rotateRight(28);
  42081. tmp.assign(x);
  42082. tmp.rotateRight(34);
  42083. result.xor(tmp);
  42084. tmp.assign(x);
  42085. tmp.rotateRight(39);
  42086. result.xor(tmp);
  42087. }
  42088. function sigmaPrime(result, x, tmp) {
  42089. result.assign(x);
  42090. result.rotateRight(14);
  42091. tmp.assign(x);
  42092. tmp.rotateRight(18);
  42093. result.xor(tmp);
  42094. tmp.assign(x);
  42095. tmp.rotateRight(41);
  42096. result.xor(tmp);
  42097. }
  42098. function littleSigma(result, x, tmp) {
  42099. result.assign(x);
  42100. result.rotateRight(1);
  42101. tmp.assign(x);
  42102. tmp.rotateRight(8);
  42103. result.xor(tmp);
  42104. tmp.assign(x);
  42105. tmp.shiftRight(7);
  42106. result.xor(tmp);
  42107. }
  42108. function littleSigmaPrime(result, x, tmp) {
  42109. result.assign(x);
  42110. result.rotateRight(19);
  42111. tmp.assign(x);
  42112. tmp.rotateRight(61);
  42113. result.xor(tmp);
  42114. tmp.assign(x);
  42115. tmp.shiftRight(6);
  42116. result.xor(tmp);
  42117. }
  42118. const k = [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];
  42119. function hash(data, offset, length, mode384 = false) {
  42120. let h0, h1, h2, h3, h4, h5, h6, h7;
  42121. if (!mode384) {
  42122. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  42123. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  42124. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  42125. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  42126. h4 = new Word64(0x510e527f, 0xade682d1);
  42127. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  42128. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  42129. h7 = new Word64(0x5be0cd19, 0x137e2179);
  42130. } else {
  42131. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  42132. h1 = new Word64(0x629a292a, 0x367cd507);
  42133. h2 = new Word64(0x9159015a, 0x3070dd17);
  42134. h3 = new Word64(0x152fecd8, 0xf70e5939);
  42135. h4 = new Word64(0x67332667, 0xffc00b31);
  42136. h5 = new Word64(0x8eb44a87, 0x68581511);
  42137. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  42138. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  42139. }
  42140. const paddedLength = Math.ceil((length + 17) / 128) * 128;
  42141. const padded = new Uint8Array(paddedLength);
  42142. let i, j;
  42143. for (i = 0; i < length; ++i) {
  42144. padded[i] = data[offset++];
  42145. }
  42146. padded[i++] = 0x80;
  42147. const n = paddedLength - 16;
  42148. while (i < n) {
  42149. padded[i++] = 0;
  42150. }
  42151. padded[i++] = 0;
  42152. padded[i++] = 0;
  42153. padded[i++] = 0;
  42154. padded[i++] = 0;
  42155. padded[i++] = 0;
  42156. padded[i++] = 0;
  42157. padded[i++] = 0;
  42158. padded[i++] = 0;
  42159. padded[i++] = 0;
  42160. padded[i++] = 0;
  42161. padded[i++] = 0;
  42162. padded[i++] = length >>> 29 & 0xff;
  42163. padded[i++] = length >> 21 & 0xff;
  42164. padded[i++] = length >> 13 & 0xff;
  42165. padded[i++] = length >> 5 & 0xff;
  42166. padded[i++] = length << 3 & 0xff;
  42167. const w = new Array(80);
  42168. for (i = 0; i < 80; i++) {
  42169. w[i] = new Word64(0, 0);
  42170. }
  42171. let a = new Word64(0, 0),
  42172. b = new Word64(0, 0),
  42173. c = new Word64(0, 0);
  42174. let d = new Word64(0, 0),
  42175. e = new Word64(0, 0),
  42176. f = new Word64(0, 0);
  42177. let g = new Word64(0, 0),
  42178. h = new Word64(0, 0);
  42179. const t1 = new Word64(0, 0),
  42180. t2 = new Word64(0, 0);
  42181. const tmp1 = new Word64(0, 0),
  42182. tmp2 = new Word64(0, 0);
  42183. let tmp3;
  42184. for (i = 0; i < paddedLength;) {
  42185. for (j = 0; j < 16; ++j) {
  42186. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  42187. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  42188. i += 8;
  42189. }
  42190. for (j = 16; j < 80; ++j) {
  42191. tmp3 = w[j];
  42192. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  42193. tmp3.add(w[j - 7]);
  42194. littleSigma(tmp1, w[j - 15], tmp2);
  42195. tmp3.add(tmp1);
  42196. tmp3.add(w[j - 16]);
  42197. }
  42198. a.assign(h0);
  42199. b.assign(h1);
  42200. c.assign(h2);
  42201. d.assign(h3);
  42202. e.assign(h4);
  42203. f.assign(h5);
  42204. g.assign(h6);
  42205. h.assign(h7);
  42206. for (j = 0; j < 80; ++j) {
  42207. t1.assign(h);
  42208. sigmaPrime(tmp1, e, tmp2);
  42209. t1.add(tmp1);
  42210. ch(tmp1, e, f, g, tmp2);
  42211. t1.add(tmp1);
  42212. t1.add(k[j]);
  42213. t1.add(w[j]);
  42214. sigma(t2, a, tmp2);
  42215. maj(tmp1, a, b, c, tmp2);
  42216. t2.add(tmp1);
  42217. tmp3 = h;
  42218. h = g;
  42219. g = f;
  42220. f = e;
  42221. d.add(t1);
  42222. e = d;
  42223. d = c;
  42224. c = b;
  42225. b = a;
  42226. tmp3.assign(t1);
  42227. tmp3.add(t2);
  42228. a = tmp3;
  42229. }
  42230. h0.add(a);
  42231. h1.add(b);
  42232. h2.add(c);
  42233. h3.add(d);
  42234. h4.add(e);
  42235. h5.add(f);
  42236. h6.add(g);
  42237. h7.add(h);
  42238. }
  42239. let result;
  42240. if (!mode384) {
  42241. result = new Uint8Array(64);
  42242. h0.copyTo(result, 0);
  42243. h1.copyTo(result, 8);
  42244. h2.copyTo(result, 16);
  42245. h3.copyTo(result, 24);
  42246. h4.copyTo(result, 32);
  42247. h5.copyTo(result, 40);
  42248. h6.copyTo(result, 48);
  42249. h7.copyTo(result, 56);
  42250. } else {
  42251. result = new Uint8Array(48);
  42252. h0.copyTo(result, 0);
  42253. h1.copyTo(result, 8);
  42254. h2.copyTo(result, 16);
  42255. h3.copyTo(result, 24);
  42256. h4.copyTo(result, 32);
  42257. h5.copyTo(result, 40);
  42258. }
  42259. return result;
  42260. }
  42261. return hash;
  42262. }();
  42263. exports.calculateSHA512 = calculateSHA512;
  42264. function calculateSHA384(data, offset, length) {
  42265. return calculateSHA512(data, offset, length, true);
  42266. }
  42267. class NullCipher {
  42268. decryptBlock(data) {
  42269. return data;
  42270. }
  42271. encrypt(data) {
  42272. return data;
  42273. }
  42274. }
  42275. class AESBaseCipher {
  42276. constructor() {
  42277. if (this.constructor === AESBaseCipher) {
  42278. (0, _util.unreachable)("Cannot initialize AESBaseCipher.");
  42279. }
  42280. this._s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
  42281. this._inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
  42282. this._mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
  42283. this._mixCol = new Uint8Array(256);
  42284. for (let i = 0; i < 256; i++) {
  42285. this._mixCol[i] = i < 128 ? i << 1 : i << 1 ^ 0x1b;
  42286. }
  42287. this.buffer = new Uint8Array(16);
  42288. this.bufferPosition = 0;
  42289. }
  42290. _expandKey(cipherKey) {
  42291. (0, _util.unreachable)("Cannot call `_expandKey` on the base class");
  42292. }
  42293. _decrypt(input, key) {
  42294. let t, u, v;
  42295. const state = new Uint8Array(16);
  42296. state.set(input);
  42297. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  42298. state[j] ^= key[k];
  42299. }
  42300. for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
  42301. t = state[13];
  42302. state[13] = state[9];
  42303. state[9] = state[5];
  42304. state[5] = state[1];
  42305. state[1] = t;
  42306. t = state[14];
  42307. u = state[10];
  42308. state[14] = state[6];
  42309. state[10] = state[2];
  42310. state[6] = t;
  42311. state[2] = u;
  42312. t = state[15];
  42313. u = state[11];
  42314. v = state[7];
  42315. state[15] = state[3];
  42316. state[11] = t;
  42317. state[7] = u;
  42318. state[3] = v;
  42319. for (let j = 0; j < 16; ++j) {
  42320. state[j] = this._inv_s[state[j]];
  42321. }
  42322. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  42323. state[j] ^= key[k];
  42324. }
  42325. for (let j = 0; j < 16; j += 4) {
  42326. const s0 = this._mix[state[j]];
  42327. const s1 = this._mix[state[j + 1]];
  42328. const s2 = this._mix[state[j + 2]];
  42329. const s3 = this._mix[state[j + 3]];
  42330. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  42331. state[j] = t >>> 24 & 0xff;
  42332. state[j + 1] = t >> 16 & 0xff;
  42333. state[j + 2] = t >> 8 & 0xff;
  42334. state[j + 3] = t & 0xff;
  42335. }
  42336. }
  42337. t = state[13];
  42338. state[13] = state[9];
  42339. state[9] = state[5];
  42340. state[5] = state[1];
  42341. state[1] = t;
  42342. t = state[14];
  42343. u = state[10];
  42344. state[14] = state[6];
  42345. state[10] = state[2];
  42346. state[6] = t;
  42347. state[2] = u;
  42348. t = state[15];
  42349. u = state[11];
  42350. v = state[7];
  42351. state[15] = state[3];
  42352. state[11] = t;
  42353. state[7] = u;
  42354. state[3] = v;
  42355. for (let j = 0; j < 16; ++j) {
  42356. state[j] = this._inv_s[state[j]];
  42357. state[j] ^= key[j];
  42358. }
  42359. return state;
  42360. }
  42361. _encrypt(input, key) {
  42362. const s = this._s;
  42363. let t, u, v;
  42364. const state = new Uint8Array(16);
  42365. state.set(input);
  42366. for (let j = 0; j < 16; ++j) {
  42367. state[j] ^= key[j];
  42368. }
  42369. for (let i = 1; i < this._cyclesOfRepetition; i++) {
  42370. for (let j = 0; j < 16; ++j) {
  42371. state[j] = s[state[j]];
  42372. }
  42373. v = state[1];
  42374. state[1] = state[5];
  42375. state[5] = state[9];
  42376. state[9] = state[13];
  42377. state[13] = v;
  42378. v = state[2];
  42379. u = state[6];
  42380. state[2] = state[10];
  42381. state[6] = state[14];
  42382. state[10] = v;
  42383. state[14] = u;
  42384. v = state[3];
  42385. u = state[7];
  42386. t = state[11];
  42387. state[3] = state[15];
  42388. state[7] = v;
  42389. state[11] = u;
  42390. state[15] = t;
  42391. for (let j = 0; j < 16; j += 4) {
  42392. const s0 = state[j + 0];
  42393. const s1 = state[j + 1];
  42394. const s2 = state[j + 2];
  42395. const s3 = state[j + 3];
  42396. t = s0 ^ s1 ^ s2 ^ s3;
  42397. state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
  42398. state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
  42399. state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
  42400. state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
  42401. }
  42402. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  42403. state[j] ^= key[k];
  42404. }
  42405. }
  42406. for (let j = 0; j < 16; ++j) {
  42407. state[j] = s[state[j]];
  42408. }
  42409. v = state[1];
  42410. state[1] = state[5];
  42411. state[5] = state[9];
  42412. state[9] = state[13];
  42413. state[13] = v;
  42414. v = state[2];
  42415. u = state[6];
  42416. state[2] = state[10];
  42417. state[6] = state[14];
  42418. state[10] = v;
  42419. state[14] = u;
  42420. v = state[3];
  42421. u = state[7];
  42422. t = state[11];
  42423. state[3] = state[15];
  42424. state[7] = v;
  42425. state[11] = u;
  42426. state[15] = t;
  42427. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  42428. state[j] ^= key[k];
  42429. }
  42430. return state;
  42431. }
  42432. _decryptBlock2(data, finalize) {
  42433. const sourceLength = data.length;
  42434. let buffer = this.buffer,
  42435. bufferLength = this.bufferPosition;
  42436. const result = [];
  42437. let iv = this.iv;
  42438. for (let i = 0; i < sourceLength; ++i) {
  42439. buffer[bufferLength] = data[i];
  42440. ++bufferLength;
  42441. if (bufferLength < 16) {
  42442. continue;
  42443. }
  42444. const plain = this._decrypt(buffer, this._key);
  42445. for (let j = 0; j < 16; ++j) {
  42446. plain[j] ^= iv[j];
  42447. }
  42448. iv = buffer;
  42449. result.push(plain);
  42450. buffer = new Uint8Array(16);
  42451. bufferLength = 0;
  42452. }
  42453. this.buffer = buffer;
  42454. this.bufferLength = bufferLength;
  42455. this.iv = iv;
  42456. if (result.length === 0) {
  42457. return new Uint8Array(0);
  42458. }
  42459. let outputLength = 16 * result.length;
  42460. if (finalize) {
  42461. const lastBlock = result.at(-1);
  42462. let psLen = lastBlock[15];
  42463. if (psLen <= 16) {
  42464. for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
  42465. if (lastBlock[i] !== psLen) {
  42466. psLen = 0;
  42467. break;
  42468. }
  42469. }
  42470. outputLength -= psLen;
  42471. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  42472. }
  42473. }
  42474. const output = new Uint8Array(outputLength);
  42475. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  42476. output.set(result[i], j);
  42477. }
  42478. return output;
  42479. }
  42480. decryptBlock(data, finalize, iv = null) {
  42481. const sourceLength = data.length;
  42482. const buffer = this.buffer;
  42483. let bufferLength = this.bufferPosition;
  42484. if (iv) {
  42485. this.iv = iv;
  42486. } else {
  42487. for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  42488. buffer[bufferLength] = data[i];
  42489. }
  42490. if (bufferLength < 16) {
  42491. this.bufferLength = bufferLength;
  42492. return new Uint8Array(0);
  42493. }
  42494. this.iv = buffer;
  42495. data = data.subarray(16);
  42496. }
  42497. this.buffer = new Uint8Array(16);
  42498. this.bufferLength = 0;
  42499. this.decryptBlock = this._decryptBlock2;
  42500. return this.decryptBlock(data, finalize);
  42501. }
  42502. encrypt(data, iv) {
  42503. const sourceLength = data.length;
  42504. let buffer = this.buffer,
  42505. bufferLength = this.bufferPosition;
  42506. const result = [];
  42507. if (!iv) {
  42508. iv = new Uint8Array(16);
  42509. }
  42510. for (let i = 0; i < sourceLength; ++i) {
  42511. buffer[bufferLength] = data[i];
  42512. ++bufferLength;
  42513. if (bufferLength < 16) {
  42514. continue;
  42515. }
  42516. for (let j = 0; j < 16; ++j) {
  42517. buffer[j] ^= iv[j];
  42518. }
  42519. const cipher = this._encrypt(buffer, this._key);
  42520. iv = cipher;
  42521. result.push(cipher);
  42522. buffer = new Uint8Array(16);
  42523. bufferLength = 0;
  42524. }
  42525. this.buffer = buffer;
  42526. this.bufferLength = bufferLength;
  42527. this.iv = iv;
  42528. if (result.length === 0) {
  42529. return new Uint8Array(0);
  42530. }
  42531. const outputLength = 16 * result.length;
  42532. const output = new Uint8Array(outputLength);
  42533. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  42534. output.set(result[i], j);
  42535. }
  42536. return output;
  42537. }
  42538. }
  42539. class AES128Cipher extends AESBaseCipher {
  42540. constructor(key) {
  42541. super();
  42542. this._cyclesOfRepetition = 10;
  42543. this._keySize = 160;
  42544. this._rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
  42545. this._key = this._expandKey(key);
  42546. }
  42547. _expandKey(cipherKey) {
  42548. const b = 176;
  42549. const s = this._s;
  42550. const rcon = this._rcon;
  42551. const result = new Uint8Array(b);
  42552. result.set(cipherKey);
  42553. for (let j = 16, i = 1; j < b; ++i) {
  42554. let t1 = result[j - 3];
  42555. let t2 = result[j - 2];
  42556. let t3 = result[j - 1];
  42557. let t4 = result[j - 4];
  42558. t1 = s[t1];
  42559. t2 = s[t2];
  42560. t3 = s[t3];
  42561. t4 = s[t4];
  42562. t1 ^= rcon[i];
  42563. for (let n = 0; n < 4; ++n) {
  42564. result[j] = t1 ^= result[j - 16];
  42565. j++;
  42566. result[j] = t2 ^= result[j - 16];
  42567. j++;
  42568. result[j] = t3 ^= result[j - 16];
  42569. j++;
  42570. result[j] = t4 ^= result[j - 16];
  42571. j++;
  42572. }
  42573. }
  42574. return result;
  42575. }
  42576. }
  42577. exports.AES128Cipher = AES128Cipher;
  42578. class AES256Cipher extends AESBaseCipher {
  42579. constructor(key) {
  42580. super();
  42581. this._cyclesOfRepetition = 14;
  42582. this._keySize = 224;
  42583. this._key = this._expandKey(key);
  42584. }
  42585. _expandKey(cipherKey) {
  42586. const b = 240;
  42587. const s = this._s;
  42588. const result = new Uint8Array(b);
  42589. result.set(cipherKey);
  42590. let r = 1;
  42591. let t1, t2, t3, t4;
  42592. for (let j = 32, i = 1; j < b; ++i) {
  42593. if (j % 32 === 16) {
  42594. t1 = s[t1];
  42595. t2 = s[t2];
  42596. t3 = s[t3];
  42597. t4 = s[t4];
  42598. } else if (j % 32 === 0) {
  42599. t1 = result[j - 3];
  42600. t2 = result[j - 2];
  42601. t3 = result[j - 1];
  42602. t4 = result[j - 4];
  42603. t1 = s[t1];
  42604. t2 = s[t2];
  42605. t3 = s[t3];
  42606. t4 = s[t4];
  42607. t1 ^= r;
  42608. if ((r <<= 1) >= 256) {
  42609. r = (r ^ 0x1b) & 0xff;
  42610. }
  42611. }
  42612. for (let n = 0; n < 4; ++n) {
  42613. result[j] = t1 ^= result[j - 32];
  42614. j++;
  42615. result[j] = t2 ^= result[j - 32];
  42616. j++;
  42617. result[j] = t3 ^= result[j - 32];
  42618. j++;
  42619. result[j] = t4 ^= result[j - 32];
  42620. j++;
  42621. }
  42622. }
  42623. return result;
  42624. }
  42625. }
  42626. exports.AES256Cipher = AES256Cipher;
  42627. class PDF17 {
  42628. checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  42629. const hashData = new Uint8Array(password.length + 56);
  42630. hashData.set(password, 0);
  42631. hashData.set(ownerValidationSalt, password.length);
  42632. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  42633. const result = calculateSHA256(hashData, 0, hashData.length);
  42634. return (0, _util.isArrayEqual)(result, ownerPassword);
  42635. }
  42636. checkUserPassword(password, userValidationSalt, userPassword) {
  42637. const hashData = new Uint8Array(password.length + 8);
  42638. hashData.set(password, 0);
  42639. hashData.set(userValidationSalt, password.length);
  42640. const result = calculateSHA256(hashData, 0, hashData.length);
  42641. return (0, _util.isArrayEqual)(result, userPassword);
  42642. }
  42643. getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  42644. const hashData = new Uint8Array(password.length + 56);
  42645. hashData.set(password, 0);
  42646. hashData.set(ownerKeySalt, password.length);
  42647. hashData.set(userBytes, password.length + ownerKeySalt.length);
  42648. const key = calculateSHA256(hashData, 0, hashData.length);
  42649. const cipher = new AES256Cipher(key);
  42650. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  42651. }
  42652. getUserKey(password, userKeySalt, userEncryption) {
  42653. const hashData = new Uint8Array(password.length + 8);
  42654. hashData.set(password, 0);
  42655. hashData.set(userKeySalt, password.length);
  42656. const key = calculateSHA256(hashData, 0, hashData.length);
  42657. const cipher = new AES256Cipher(key);
  42658. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  42659. }
  42660. }
  42661. exports.PDF17 = PDF17;
  42662. class PDF20 {
  42663. _hash(password, input, userBytes) {
  42664. let k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  42665. let e = [0];
  42666. let i = 0;
  42667. while (i < 64 || e.at(-1) > i - 32) {
  42668. const combinedLength = password.length + k.length + userBytes.length,
  42669. combinedArray = new Uint8Array(combinedLength);
  42670. let writeOffset = 0;
  42671. combinedArray.set(password, writeOffset);
  42672. writeOffset += password.length;
  42673. combinedArray.set(k, writeOffset);
  42674. writeOffset += k.length;
  42675. combinedArray.set(userBytes, writeOffset);
  42676. const k1 = new Uint8Array(combinedLength * 64);
  42677. for (let j = 0, pos = 0; j < 64; j++, pos += combinedLength) {
  42678. k1.set(combinedArray, pos);
  42679. }
  42680. const cipher = new AES128Cipher(k.subarray(0, 16));
  42681. e = cipher.encrypt(k1, k.subarray(16, 32));
  42682. const remainder = e.slice(0, 16).reduce((a, b) => a + b, 0) % 3;
  42683. if (remainder === 0) {
  42684. k = calculateSHA256(e, 0, e.length);
  42685. } else if (remainder === 1) {
  42686. k = calculateSHA384(e, 0, e.length);
  42687. } else if (remainder === 2) {
  42688. k = calculateSHA512(e, 0, e.length);
  42689. }
  42690. i++;
  42691. }
  42692. return k.subarray(0, 32);
  42693. }
  42694. checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  42695. const hashData = new Uint8Array(password.length + 56);
  42696. hashData.set(password, 0);
  42697. hashData.set(ownerValidationSalt, password.length);
  42698. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  42699. const result = this._hash(password, hashData, userBytes);
  42700. return (0, _util.isArrayEqual)(result, ownerPassword);
  42701. }
  42702. checkUserPassword(password, userValidationSalt, userPassword) {
  42703. const hashData = new Uint8Array(password.length + 8);
  42704. hashData.set(password, 0);
  42705. hashData.set(userValidationSalt, password.length);
  42706. const result = this._hash(password, hashData, []);
  42707. return (0, _util.isArrayEqual)(result, userPassword);
  42708. }
  42709. getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  42710. const hashData = new Uint8Array(password.length + 56);
  42711. hashData.set(password, 0);
  42712. hashData.set(ownerKeySalt, password.length);
  42713. hashData.set(userBytes, password.length + ownerKeySalt.length);
  42714. const key = this._hash(password, hashData, userBytes);
  42715. const cipher = new AES256Cipher(key);
  42716. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  42717. }
  42718. getUserKey(password, userKeySalt, userEncryption) {
  42719. const hashData = new Uint8Array(password.length + 8);
  42720. hashData.set(password, 0);
  42721. hashData.set(userKeySalt, password.length);
  42722. const key = this._hash(password, hashData, []);
  42723. const cipher = new AES256Cipher(key);
  42724. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  42725. }
  42726. }
  42727. exports.PDF20 = PDF20;
  42728. class CipherTransform {
  42729. constructor(stringCipherConstructor, streamCipherConstructor) {
  42730. this.StringCipherConstructor = stringCipherConstructor;
  42731. this.StreamCipherConstructor = streamCipherConstructor;
  42732. }
  42733. createStream(stream, length) {
  42734. const cipher = new this.StreamCipherConstructor();
  42735. return new _decrypt_stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  42736. return cipher.decryptBlock(data, finalize);
  42737. });
  42738. }
  42739. decryptString(s) {
  42740. const cipher = new this.StringCipherConstructor();
  42741. let data = (0, _util.stringToBytes)(s);
  42742. data = cipher.decryptBlock(data, true);
  42743. return (0, _util.bytesToString)(data);
  42744. }
  42745. encryptString(s) {
  42746. const cipher = new this.StringCipherConstructor();
  42747. if (cipher instanceof AESBaseCipher) {
  42748. const strLen = s.length;
  42749. const pad = 16 - strLen % 16;
  42750. s += String.fromCharCode(pad).repeat(pad);
  42751. const iv = new Uint8Array(16);
  42752. if (typeof crypto !== "undefined") {
  42753. crypto.getRandomValues(iv);
  42754. } else {
  42755. for (let i = 0; i < 16; i++) {
  42756. iv[i] = Math.floor(256 * Math.random());
  42757. }
  42758. }
  42759. let data = (0, _util.stringToBytes)(s);
  42760. data = cipher.encrypt(data, iv);
  42761. const buf = new Uint8Array(16 + data.length);
  42762. buf.set(iv);
  42763. buf.set(data, 16);
  42764. return (0, _util.bytesToString)(buf);
  42765. }
  42766. let data = (0, _util.stringToBytes)(s);
  42767. data = cipher.encrypt(data);
  42768. return (0, _util.bytesToString)(data);
  42769. }
  42770. }
  42771. const CipherTransformFactory = function CipherTransformFactoryClosure() {
  42772. const defaultPasswordBytes = new Uint8Array([0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a]);
  42773. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  42774. if (password) {
  42775. const passwordLength = Math.min(127, password.length);
  42776. password = password.subarray(0, passwordLength);
  42777. } else {
  42778. password = [];
  42779. }
  42780. const pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
  42781. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  42782. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  42783. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  42784. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  42785. }
  42786. return null;
  42787. }
  42788. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  42789. const hashDataSize = 40 + ownerPassword.length + fileId.length;
  42790. const hashData = new Uint8Array(hashDataSize);
  42791. let i = 0,
  42792. j,
  42793. n;
  42794. if (password) {
  42795. n = Math.min(32, password.length);
  42796. for (; i < n; ++i) {
  42797. hashData[i] = password[i];
  42798. }
  42799. }
  42800. j = 0;
  42801. while (i < 32) {
  42802. hashData[i++] = defaultPasswordBytes[j++];
  42803. }
  42804. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  42805. hashData[i++] = ownerPassword[j];
  42806. }
  42807. hashData[i++] = flags & 0xff;
  42808. hashData[i++] = flags >> 8 & 0xff;
  42809. hashData[i++] = flags >> 16 & 0xff;
  42810. hashData[i++] = flags >>> 24 & 0xff;
  42811. for (j = 0, n = fileId.length; j < n; ++j) {
  42812. hashData[i++] = fileId[j];
  42813. }
  42814. if (revision >= 4 && !encryptMetadata) {
  42815. hashData[i++] = 0xff;
  42816. hashData[i++] = 0xff;
  42817. hashData[i++] = 0xff;
  42818. hashData[i++] = 0xff;
  42819. }
  42820. let hash = calculateMD5(hashData, 0, i);
  42821. const keyLengthInBytes = keyLength >> 3;
  42822. if (revision >= 3) {
  42823. for (j = 0; j < 50; ++j) {
  42824. hash = calculateMD5(hash, 0, keyLengthInBytes);
  42825. }
  42826. }
  42827. const encryptionKey = hash.subarray(0, keyLengthInBytes);
  42828. let cipher, checkData;
  42829. if (revision >= 3) {
  42830. for (i = 0; i < 32; ++i) {
  42831. hashData[i] = defaultPasswordBytes[i];
  42832. }
  42833. for (j = 0, n = fileId.length; j < n; ++j) {
  42834. hashData[i++] = fileId[j];
  42835. }
  42836. cipher = new ARCFourCipher(encryptionKey);
  42837. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  42838. n = encryptionKey.length;
  42839. const derivedKey = new Uint8Array(n);
  42840. for (j = 1; j <= 19; ++j) {
  42841. for (let k = 0; k < n; ++k) {
  42842. derivedKey[k] = encryptionKey[k] ^ j;
  42843. }
  42844. cipher = new ARCFourCipher(derivedKey);
  42845. checkData = cipher.encryptBlock(checkData);
  42846. }
  42847. for (j = 0, n = checkData.length; j < n; ++j) {
  42848. if (userPassword[j] !== checkData[j]) {
  42849. return null;
  42850. }
  42851. }
  42852. } else {
  42853. cipher = new ARCFourCipher(encryptionKey);
  42854. checkData = cipher.encryptBlock(defaultPasswordBytes);
  42855. for (j = 0, n = checkData.length; j < n; ++j) {
  42856. if (userPassword[j] !== checkData[j]) {
  42857. return null;
  42858. }
  42859. }
  42860. }
  42861. return encryptionKey;
  42862. }
  42863. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  42864. const hashData = new Uint8Array(32);
  42865. let i = 0;
  42866. const n = Math.min(32, password.length);
  42867. for (; i < n; ++i) {
  42868. hashData[i] = password[i];
  42869. }
  42870. let j = 0;
  42871. while (i < 32) {
  42872. hashData[i++] = defaultPasswordBytes[j++];
  42873. }
  42874. let hash = calculateMD5(hashData, 0, i);
  42875. const keyLengthInBytes = keyLength >> 3;
  42876. if (revision >= 3) {
  42877. for (j = 0; j < 50; ++j) {
  42878. hash = calculateMD5(hash, 0, hash.length);
  42879. }
  42880. }
  42881. let cipher, userPassword;
  42882. if (revision >= 3) {
  42883. userPassword = ownerPassword;
  42884. const derivedKey = new Uint8Array(keyLengthInBytes);
  42885. for (j = 19; j >= 0; j--) {
  42886. for (let k = 0; k < keyLengthInBytes; ++k) {
  42887. derivedKey[k] = hash[k] ^ j;
  42888. }
  42889. cipher = new ARCFourCipher(derivedKey);
  42890. userPassword = cipher.encryptBlock(userPassword);
  42891. }
  42892. } else {
  42893. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  42894. userPassword = cipher.encryptBlock(ownerPassword);
  42895. }
  42896. return userPassword;
  42897. }
  42898. const identityName = _primitives.Name.get("Identity");
  42899. function buildObjectKey(num, gen, encryptionKey, isAes = false) {
  42900. const key = new Uint8Array(encryptionKey.length + 9);
  42901. const n = encryptionKey.length;
  42902. let i;
  42903. for (i = 0; i < n; ++i) {
  42904. key[i] = encryptionKey[i];
  42905. }
  42906. key[i++] = num & 0xff;
  42907. key[i++] = num >> 8 & 0xff;
  42908. key[i++] = num >> 16 & 0xff;
  42909. key[i++] = gen & 0xff;
  42910. key[i++] = gen >> 8 & 0xff;
  42911. if (isAes) {
  42912. key[i++] = 0x73;
  42913. key[i++] = 0x41;
  42914. key[i++] = 0x6c;
  42915. key[i++] = 0x54;
  42916. }
  42917. const hash = calculateMD5(key, 0, i);
  42918. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  42919. }
  42920. function buildCipherConstructor(cf, name, num, gen, key) {
  42921. if (!(name instanceof _primitives.Name)) {
  42922. throw new _util.FormatError("Invalid crypt filter name.");
  42923. }
  42924. const cryptFilter = cf.get(name.name);
  42925. let cfm;
  42926. if (cryptFilter !== null && cryptFilter !== undefined) {
  42927. cfm = cryptFilter.get("CFM");
  42928. }
  42929. if (!cfm || cfm.name === "None") {
  42930. return function cipherTransformFactoryBuildCipherConstructorNone() {
  42931. return new NullCipher();
  42932. };
  42933. }
  42934. if (cfm.name === "V2") {
  42935. return function cipherTransformFactoryBuildCipherConstructorV2() {
  42936. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  42937. };
  42938. }
  42939. if (cfm.name === "AESV2") {
  42940. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  42941. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  42942. };
  42943. }
  42944. if (cfm.name === "AESV3") {
  42945. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  42946. return new AES256Cipher(key);
  42947. };
  42948. }
  42949. throw new _util.FormatError("Unknown crypto method");
  42950. }
  42951. class CipherTransformFactory {
  42952. constructor(dict, fileId, password) {
  42953. const filter = dict.get("Filter");
  42954. if (!(0, _primitives.isName)(filter, "Standard")) {
  42955. throw new _util.FormatError("unknown encryption method");
  42956. }
  42957. this.filterName = filter.name;
  42958. this.dict = dict;
  42959. const algorithm = dict.get("V");
  42960. if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  42961. throw new _util.FormatError("unsupported encryption algorithm");
  42962. }
  42963. this.algorithm = algorithm;
  42964. let keyLength = dict.get("Length");
  42965. if (!keyLength) {
  42966. if (algorithm <= 3) {
  42967. keyLength = 40;
  42968. } else {
  42969. const cfDict = dict.get("CF");
  42970. const streamCryptoName = dict.get("StmF");
  42971. if (cfDict instanceof _primitives.Dict && streamCryptoName instanceof _primitives.Name) {
  42972. cfDict.suppressEncryption = true;
  42973. const handlerDict = cfDict.get(streamCryptoName.name);
  42974. keyLength = handlerDict?.get("Length") || 128;
  42975. if (keyLength < 40) {
  42976. keyLength <<= 3;
  42977. }
  42978. }
  42979. }
  42980. }
  42981. if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  42982. throw new _util.FormatError("invalid key length");
  42983. }
  42984. const ownerBytes = (0, _util.stringToBytes)(dict.get("O")),
  42985. userBytes = (0, _util.stringToBytes)(dict.get("U"));
  42986. const ownerPassword = ownerBytes.subarray(0, 32);
  42987. const userPassword = userBytes.subarray(0, 32);
  42988. const flags = dict.get("P");
  42989. const revision = dict.get("R");
  42990. const encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
  42991. this.encryptMetadata = encryptMetadata;
  42992. const fileIdBytes = (0, _util.stringToBytes)(fileId);
  42993. let passwordBytes;
  42994. if (password) {
  42995. if (revision === 6) {
  42996. try {
  42997. password = (0, _util.utf8StringToString)(password);
  42998. } catch {
  42999. (0, _util.warn)("CipherTransformFactory: Unable to convert UTF8 encoded password.");
  43000. }
  43001. }
  43002. passwordBytes = (0, _util.stringToBytes)(password);
  43003. }
  43004. let encryptionKey;
  43005. if (algorithm !== 5) {
  43006. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  43007. } else {
  43008. const ownerValidationSalt = ownerBytes.subarray(32, 40);
  43009. const ownerKeySalt = ownerBytes.subarray(40, 48);
  43010. const uBytes = userBytes.subarray(0, 48);
  43011. const userValidationSalt = userBytes.subarray(32, 40);
  43012. const userKeySalt = userBytes.subarray(40, 48);
  43013. const ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
  43014. const userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
  43015. const perms = (0, _util.stringToBytes)(dict.get("Perms"));
  43016. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  43017. }
  43018. if (!encryptionKey && !password) {
  43019. throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
  43020. } else if (!encryptionKey && password) {
  43021. const decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  43022. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  43023. }
  43024. if (!encryptionKey) {
  43025. throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
  43026. }
  43027. this.encryptionKey = encryptionKey;
  43028. if (algorithm >= 4) {
  43029. const cf = dict.get("CF");
  43030. if (cf instanceof _primitives.Dict) {
  43031. cf.suppressEncryption = true;
  43032. }
  43033. this.cf = cf;
  43034. this.stmf = dict.get("StmF") || identityName;
  43035. this.strf = dict.get("StrF") || identityName;
  43036. this.eff = dict.get("EFF") || this.stmf;
  43037. }
  43038. }
  43039. createCipherTransform(num, gen) {
  43040. if (this.algorithm === 4 || this.algorithm === 5) {
  43041. return new CipherTransform(buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey));
  43042. }
  43043. const key = buildObjectKey(num, gen, this.encryptionKey, false);
  43044. const cipherConstructor = function buildCipherCipherConstructor() {
  43045. return new ARCFourCipher(key);
  43046. };
  43047. return new CipherTransform(cipherConstructor, cipherConstructor);
  43048. }
  43049. }
  43050. return CipherTransformFactory;
  43051. }();
  43052. exports.CipherTransformFactory = CipherTransformFactory;
  43053. /***/ }),
  43054. /* 69 */
  43055. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  43056. Object.defineProperty(exports, "__esModule", ({
  43057. value: true
  43058. }));
  43059. exports.DecryptStream = void 0;
  43060. var _decode_stream = __w_pdfjs_require__(18);
  43061. const chunkSize = 512;
  43062. class DecryptStream extends _decode_stream.DecodeStream {
  43063. constructor(str, maybeLength, decrypt) {
  43064. super(maybeLength);
  43065. this.str = str;
  43066. this.dict = str.dict;
  43067. this.decrypt = decrypt;
  43068. this.nextChunk = null;
  43069. this.initialized = false;
  43070. }
  43071. readBlock() {
  43072. let chunk;
  43073. if (this.initialized) {
  43074. chunk = this.nextChunk;
  43075. } else {
  43076. chunk = this.str.getBytes(chunkSize);
  43077. this.initialized = true;
  43078. }
  43079. if (!chunk || chunk.length === 0) {
  43080. this.eof = true;
  43081. return;
  43082. }
  43083. this.nextChunk = this.str.getBytes(chunkSize);
  43084. const hasMoreData = this.nextChunk?.length > 0;
  43085. const decrypt = this.decrypt;
  43086. chunk = decrypt(chunk, !hasMoreData);
  43087. const bufferLength = this.bufferLength,
  43088. newLength = bufferLength + chunk.length,
  43089. buffer = this.ensureBuffer(newLength);
  43090. buffer.set(chunk, bufferLength);
  43091. this.bufferLength = newLength;
  43092. }
  43093. }
  43094. exports.DecryptStream = DecryptStream;
  43095. /***/ }),
  43096. /* 70 */
  43097. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  43098. Object.defineProperty(exports, "__esModule", ({
  43099. value: true
  43100. }));
  43101. exports.Catalog = void 0;
  43102. var _core_utils = __w_pdfjs_require__(3);
  43103. var _util = __w_pdfjs_require__(2);
  43104. var _primitives = __w_pdfjs_require__(4);
  43105. var _name_number_tree = __w_pdfjs_require__(71);
  43106. var _base_stream = __w_pdfjs_require__(5);
  43107. var _cleanup_helper = __w_pdfjs_require__(72);
  43108. var _colorspace = __w_pdfjs_require__(12);
  43109. var _file_spec = __w_pdfjs_require__(73);
  43110. var _image_utils = __w_pdfjs_require__(59);
  43111. var _metadata_parser = __w_pdfjs_require__(74);
  43112. var _struct_tree = __w_pdfjs_require__(75);
  43113. function fetchDestination(dest) {
  43114. if (dest instanceof _primitives.Dict) {
  43115. dest = dest.get("D");
  43116. }
  43117. return Array.isArray(dest) ? dest : null;
  43118. }
  43119. class Catalog {
  43120. constructor(pdfManager, xref) {
  43121. this.pdfManager = pdfManager;
  43122. this.xref = xref;
  43123. this._catDict = xref.getCatalogObj();
  43124. if (!(this._catDict instanceof _primitives.Dict)) {
  43125. throw new _util.FormatError("Catalog object is not a dictionary.");
  43126. }
  43127. this.toplevelPagesDict;
  43128. this._actualNumPages = null;
  43129. this.fontCache = new _primitives.RefSetCache();
  43130. this.builtInCMapCache = new Map();
  43131. this.standardFontDataCache = new Map();
  43132. this.globalImageCache = new _image_utils.GlobalImageCache();
  43133. this.pageKidsCountCache = new _primitives.RefSetCache();
  43134. this.pageIndexCache = new _primitives.RefSetCache();
  43135. this.nonBlendModesSet = new _primitives.RefSet();
  43136. this.systemFontCache = new Map();
  43137. }
  43138. get version() {
  43139. const version = this._catDict.get("Version");
  43140. if (version instanceof _primitives.Name) {
  43141. if (_core_utils.PDF_VERSION_REGEXP.test(version.name)) {
  43142. return (0, _util.shadow)(this, "version", version.name);
  43143. }
  43144. (0, _util.warn)(`Invalid PDF catalog version: ${version.name}`);
  43145. }
  43146. return (0, _util.shadow)(this, "version", null);
  43147. }
  43148. get lang() {
  43149. const lang = this._catDict.get("Lang");
  43150. return (0, _util.shadow)(this, "lang", typeof lang === "string" ? (0, _util.stringToPDFString)(lang) : null);
  43151. }
  43152. get needsRendering() {
  43153. const needsRendering = this._catDict.get("NeedsRendering");
  43154. return (0, _util.shadow)(this, "needsRendering", typeof needsRendering === "boolean" ? needsRendering : false);
  43155. }
  43156. get collection() {
  43157. let collection = null;
  43158. try {
  43159. const obj = this._catDict.get("Collection");
  43160. if (obj instanceof _primitives.Dict && obj.size > 0) {
  43161. collection = obj;
  43162. }
  43163. } catch (ex) {
  43164. if (ex instanceof _core_utils.MissingDataException) {
  43165. throw ex;
  43166. }
  43167. (0, _util.info)("Cannot fetch Collection entry; assuming no collection is present.");
  43168. }
  43169. return (0, _util.shadow)(this, "collection", collection);
  43170. }
  43171. get acroForm() {
  43172. let acroForm = null;
  43173. try {
  43174. const obj = this._catDict.get("AcroForm");
  43175. if (obj instanceof _primitives.Dict && obj.size > 0) {
  43176. acroForm = obj;
  43177. }
  43178. } catch (ex) {
  43179. if (ex instanceof _core_utils.MissingDataException) {
  43180. throw ex;
  43181. }
  43182. (0, _util.info)("Cannot fetch AcroForm entry; assuming no forms are present.");
  43183. }
  43184. return (0, _util.shadow)(this, "acroForm", acroForm);
  43185. }
  43186. get acroFormRef() {
  43187. const value = this._catDict.getRaw("AcroForm");
  43188. return (0, _util.shadow)(this, "acroFormRef", value instanceof _primitives.Ref ? value : null);
  43189. }
  43190. get metadata() {
  43191. const streamRef = this._catDict.getRaw("Metadata");
  43192. if (!(streamRef instanceof _primitives.Ref)) {
  43193. return (0, _util.shadow)(this, "metadata", null);
  43194. }
  43195. let metadata = null;
  43196. try {
  43197. const stream = this.xref.fetch(streamRef, !this.xref.encrypt?.encryptMetadata);
  43198. if (stream instanceof _base_stream.BaseStream && stream.dict instanceof _primitives.Dict) {
  43199. const type = stream.dict.get("Type");
  43200. const subtype = stream.dict.get("Subtype");
  43201. if ((0, _primitives.isName)(type, "Metadata") && (0, _primitives.isName)(subtype, "XML")) {
  43202. const data = (0, _util.stringToUTF8String)(stream.getString());
  43203. if (data) {
  43204. metadata = new _metadata_parser.MetadataParser(data).serializable;
  43205. }
  43206. }
  43207. }
  43208. } catch (ex) {
  43209. if (ex instanceof _core_utils.MissingDataException) {
  43210. throw ex;
  43211. }
  43212. (0, _util.info)(`Skipping invalid Metadata: "${ex}".`);
  43213. }
  43214. return (0, _util.shadow)(this, "metadata", metadata);
  43215. }
  43216. get markInfo() {
  43217. let markInfo = null;
  43218. try {
  43219. markInfo = this._readMarkInfo();
  43220. } catch (ex) {
  43221. if (ex instanceof _core_utils.MissingDataException) {
  43222. throw ex;
  43223. }
  43224. (0, _util.warn)("Unable to read mark info.");
  43225. }
  43226. return (0, _util.shadow)(this, "markInfo", markInfo);
  43227. }
  43228. _readMarkInfo() {
  43229. const obj = this._catDict.get("MarkInfo");
  43230. if (!(obj instanceof _primitives.Dict)) {
  43231. return null;
  43232. }
  43233. const markInfo = {
  43234. Marked: false,
  43235. UserProperties: false,
  43236. Suspects: false
  43237. };
  43238. for (const key in markInfo) {
  43239. const value = obj.get(key);
  43240. if (typeof value === "boolean") {
  43241. markInfo[key] = value;
  43242. }
  43243. }
  43244. return markInfo;
  43245. }
  43246. get structTreeRoot() {
  43247. let structTree = null;
  43248. try {
  43249. structTree = this._readStructTreeRoot();
  43250. } catch (ex) {
  43251. if (ex instanceof _core_utils.MissingDataException) {
  43252. throw ex;
  43253. }
  43254. (0, _util.warn)("Unable read to structTreeRoot info.");
  43255. }
  43256. return (0, _util.shadow)(this, "structTreeRoot", structTree);
  43257. }
  43258. _readStructTreeRoot() {
  43259. const obj = this._catDict.get("StructTreeRoot");
  43260. if (!(obj instanceof _primitives.Dict)) {
  43261. return null;
  43262. }
  43263. const root = new _struct_tree.StructTreeRoot(obj);
  43264. root.init();
  43265. return root;
  43266. }
  43267. get toplevelPagesDict() {
  43268. const pagesObj = this._catDict.get("Pages");
  43269. if (!(pagesObj instanceof _primitives.Dict)) {
  43270. throw new _util.FormatError("Invalid top-level pages dictionary.");
  43271. }
  43272. return (0, _util.shadow)(this, "toplevelPagesDict", pagesObj);
  43273. }
  43274. get documentOutline() {
  43275. let obj = null;
  43276. try {
  43277. obj = this._readDocumentOutline();
  43278. } catch (ex) {
  43279. if (ex instanceof _core_utils.MissingDataException) {
  43280. throw ex;
  43281. }
  43282. (0, _util.warn)("Unable to read document outline.");
  43283. }
  43284. return (0, _util.shadow)(this, "documentOutline", obj);
  43285. }
  43286. _readDocumentOutline() {
  43287. let obj = this._catDict.get("Outlines");
  43288. if (!(obj instanceof _primitives.Dict)) {
  43289. return null;
  43290. }
  43291. obj = obj.getRaw("First");
  43292. if (!(obj instanceof _primitives.Ref)) {
  43293. return null;
  43294. }
  43295. const root = {
  43296. items: []
  43297. };
  43298. const queue = [{
  43299. obj,
  43300. parent: root
  43301. }];
  43302. const processed = new _primitives.RefSet();
  43303. processed.put(obj);
  43304. const xref = this.xref,
  43305. blackColor = new Uint8ClampedArray(3);
  43306. while (queue.length > 0) {
  43307. const i = queue.shift();
  43308. const outlineDict = xref.fetchIfRef(i.obj);
  43309. if (outlineDict === null) {
  43310. continue;
  43311. }
  43312. if (!outlineDict.has("Title")) {
  43313. throw new _util.FormatError("Invalid outline item encountered.");
  43314. }
  43315. const data = {
  43316. url: null,
  43317. dest: null,
  43318. action: null
  43319. };
  43320. Catalog.parseDestDictionary({
  43321. destDict: outlineDict,
  43322. resultObj: data,
  43323. docBaseUrl: this.pdfManager.docBaseUrl,
  43324. docAttachments: this.attachments
  43325. });
  43326. const title = outlineDict.get("Title");
  43327. const flags = outlineDict.get("F") || 0;
  43328. const color = outlineDict.getArray("C");
  43329. const count = outlineDict.get("Count");
  43330. let rgbColor = blackColor;
  43331. if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  43332. rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
  43333. }
  43334. const outlineItem = {
  43335. action: data.action,
  43336. attachment: data.attachment,
  43337. dest: data.dest,
  43338. url: data.url,
  43339. unsafeUrl: data.unsafeUrl,
  43340. newWindow: data.newWindow,
  43341. setOCGState: data.setOCGState,
  43342. title: (0, _util.stringToPDFString)(title),
  43343. color: rgbColor,
  43344. count: Number.isInteger(count) ? count : undefined,
  43345. bold: !!(flags & 2),
  43346. italic: !!(flags & 1),
  43347. items: []
  43348. };
  43349. i.parent.items.push(outlineItem);
  43350. obj = outlineDict.getRaw("First");
  43351. if (obj instanceof _primitives.Ref && !processed.has(obj)) {
  43352. queue.push({
  43353. obj,
  43354. parent: outlineItem
  43355. });
  43356. processed.put(obj);
  43357. }
  43358. obj = outlineDict.getRaw("Next");
  43359. if (obj instanceof _primitives.Ref && !processed.has(obj)) {
  43360. queue.push({
  43361. obj,
  43362. parent: i.parent
  43363. });
  43364. processed.put(obj);
  43365. }
  43366. }
  43367. return root.items.length > 0 ? root.items : null;
  43368. }
  43369. get permissions() {
  43370. let permissions = null;
  43371. try {
  43372. permissions = this._readPermissions();
  43373. } catch (ex) {
  43374. if (ex instanceof _core_utils.MissingDataException) {
  43375. throw ex;
  43376. }
  43377. (0, _util.warn)("Unable to read permissions.");
  43378. }
  43379. return (0, _util.shadow)(this, "permissions", permissions);
  43380. }
  43381. _readPermissions() {
  43382. const encrypt = this.xref.trailer.get("Encrypt");
  43383. if (!(encrypt instanceof _primitives.Dict)) {
  43384. return null;
  43385. }
  43386. let flags = encrypt.get("P");
  43387. if (typeof flags !== "number") {
  43388. return null;
  43389. }
  43390. flags += 2 ** 32;
  43391. const permissions = [];
  43392. for (const key in _util.PermissionFlag) {
  43393. const value = _util.PermissionFlag[key];
  43394. if (flags & value) {
  43395. permissions.push(value);
  43396. }
  43397. }
  43398. return permissions;
  43399. }
  43400. get optionalContentConfig() {
  43401. let config = null;
  43402. try {
  43403. const properties = this._catDict.get("OCProperties");
  43404. if (!properties) {
  43405. return (0, _util.shadow)(this, "optionalContentConfig", null);
  43406. }
  43407. const defaultConfig = properties.get("D");
  43408. if (!defaultConfig) {
  43409. return (0, _util.shadow)(this, "optionalContentConfig", null);
  43410. }
  43411. const groupsData = properties.get("OCGs");
  43412. if (!Array.isArray(groupsData)) {
  43413. return (0, _util.shadow)(this, "optionalContentConfig", null);
  43414. }
  43415. const groups = [];
  43416. const groupRefs = [];
  43417. for (const groupRef of groupsData) {
  43418. if (!(groupRef instanceof _primitives.Ref)) {
  43419. continue;
  43420. }
  43421. groupRefs.push(groupRef);
  43422. const group = this.xref.fetchIfRef(groupRef);
  43423. groups.push({
  43424. id: groupRef.toString(),
  43425. name: typeof group.get("Name") === "string" ? (0, _util.stringToPDFString)(group.get("Name")) : null,
  43426. intent: typeof group.get("Intent") === "string" ? (0, _util.stringToPDFString)(group.get("Intent")) : null
  43427. });
  43428. }
  43429. config = this._readOptionalContentConfig(defaultConfig, groupRefs);
  43430. config.groups = groups;
  43431. } catch (ex) {
  43432. if (ex instanceof _core_utils.MissingDataException) {
  43433. throw ex;
  43434. }
  43435. (0, _util.warn)(`Unable to read optional content config: ${ex}`);
  43436. }
  43437. return (0, _util.shadow)(this, "optionalContentConfig", config);
  43438. }
  43439. _readOptionalContentConfig(config, contentGroupRefs) {
  43440. function parseOnOff(refs) {
  43441. const onParsed = [];
  43442. if (Array.isArray(refs)) {
  43443. for (const value of refs) {
  43444. if (!(value instanceof _primitives.Ref)) {
  43445. continue;
  43446. }
  43447. if (contentGroupRefs.includes(value)) {
  43448. onParsed.push(value.toString());
  43449. }
  43450. }
  43451. }
  43452. return onParsed;
  43453. }
  43454. function parseOrder(refs, nestedLevels = 0) {
  43455. if (!Array.isArray(refs)) {
  43456. return null;
  43457. }
  43458. const order = [];
  43459. for (const value of refs) {
  43460. if (value instanceof _primitives.Ref && contentGroupRefs.includes(value)) {
  43461. parsedOrderRefs.put(value);
  43462. order.push(value.toString());
  43463. continue;
  43464. }
  43465. const nestedOrder = parseNestedOrder(value, nestedLevels);
  43466. if (nestedOrder) {
  43467. order.push(nestedOrder);
  43468. }
  43469. }
  43470. if (nestedLevels > 0) {
  43471. return order;
  43472. }
  43473. const hiddenGroups = [];
  43474. for (const groupRef of contentGroupRefs) {
  43475. if (parsedOrderRefs.has(groupRef)) {
  43476. continue;
  43477. }
  43478. hiddenGroups.push(groupRef.toString());
  43479. }
  43480. if (hiddenGroups.length) {
  43481. order.push({
  43482. name: null,
  43483. order: hiddenGroups
  43484. });
  43485. }
  43486. return order;
  43487. }
  43488. function parseNestedOrder(ref, nestedLevels) {
  43489. if (++nestedLevels > MAX_NESTED_LEVELS) {
  43490. (0, _util.warn)("parseNestedOrder - reached MAX_NESTED_LEVELS.");
  43491. return null;
  43492. }
  43493. const value = xref.fetchIfRef(ref);
  43494. if (!Array.isArray(value)) {
  43495. return null;
  43496. }
  43497. const nestedName = xref.fetchIfRef(value[0]);
  43498. if (typeof nestedName !== "string") {
  43499. return null;
  43500. }
  43501. const nestedOrder = parseOrder(value.slice(1), nestedLevels);
  43502. if (!nestedOrder || !nestedOrder.length) {
  43503. return null;
  43504. }
  43505. return {
  43506. name: (0, _util.stringToPDFString)(nestedName),
  43507. order: nestedOrder
  43508. };
  43509. }
  43510. const xref = this.xref,
  43511. parsedOrderRefs = new _primitives.RefSet(),
  43512. MAX_NESTED_LEVELS = 10;
  43513. return {
  43514. name: typeof config.get("Name") === "string" ? (0, _util.stringToPDFString)(config.get("Name")) : null,
  43515. creator: typeof config.get("Creator") === "string" ? (0, _util.stringToPDFString)(config.get("Creator")) : null,
  43516. baseState: config.get("BaseState") instanceof _primitives.Name ? config.get("BaseState").name : null,
  43517. on: parseOnOff(config.get("ON")),
  43518. off: parseOnOff(config.get("OFF")),
  43519. order: parseOrder(config.get("Order")),
  43520. groups: null
  43521. };
  43522. }
  43523. setActualNumPages(num = null) {
  43524. this._actualNumPages = num;
  43525. }
  43526. get hasActualNumPages() {
  43527. return this._actualNumPages !== null;
  43528. }
  43529. get _pagesCount() {
  43530. const obj = this.toplevelPagesDict.get("Count");
  43531. if (!Number.isInteger(obj)) {
  43532. throw new _util.FormatError("Page count in top-level pages dictionary is not an integer.");
  43533. }
  43534. return (0, _util.shadow)(this, "_pagesCount", obj);
  43535. }
  43536. get numPages() {
  43537. return this.hasActualNumPages ? this._actualNumPages : this._pagesCount;
  43538. }
  43539. get destinations() {
  43540. const obj = this._readDests(),
  43541. dests = Object.create(null);
  43542. if (obj instanceof _name_number_tree.NameTree) {
  43543. for (const [key, value] of obj.getAll()) {
  43544. const dest = fetchDestination(value);
  43545. if (dest) {
  43546. dests[(0, _util.stringToPDFString)(key)] = dest;
  43547. }
  43548. }
  43549. } else if (obj instanceof _primitives.Dict) {
  43550. obj.forEach(function (key, value) {
  43551. const dest = fetchDestination(value);
  43552. if (dest) {
  43553. dests[key] = dest;
  43554. }
  43555. });
  43556. }
  43557. return (0, _util.shadow)(this, "destinations", dests);
  43558. }
  43559. getDestination(id) {
  43560. const obj = this._readDests();
  43561. if (obj instanceof _name_number_tree.NameTree) {
  43562. const dest = fetchDestination(obj.get(id));
  43563. if (dest) {
  43564. return dest;
  43565. }
  43566. const allDest = this.destinations[id];
  43567. if (allDest) {
  43568. (0, _util.warn)(`Found "${id}" at an incorrect position in the NameTree.`);
  43569. return allDest;
  43570. }
  43571. } else if (obj instanceof _primitives.Dict) {
  43572. const dest = fetchDestination(obj.get(id));
  43573. if (dest) {
  43574. return dest;
  43575. }
  43576. }
  43577. return null;
  43578. }
  43579. _readDests() {
  43580. const obj = this._catDict.get("Names");
  43581. if (obj?.has("Dests")) {
  43582. return new _name_number_tree.NameTree(obj.getRaw("Dests"), this.xref);
  43583. } else if (this._catDict.has("Dests")) {
  43584. return this._catDict.get("Dests");
  43585. }
  43586. return undefined;
  43587. }
  43588. get pageLabels() {
  43589. let obj = null;
  43590. try {
  43591. obj = this._readPageLabels();
  43592. } catch (ex) {
  43593. if (ex instanceof _core_utils.MissingDataException) {
  43594. throw ex;
  43595. }
  43596. (0, _util.warn)("Unable to read page labels.");
  43597. }
  43598. return (0, _util.shadow)(this, "pageLabels", obj);
  43599. }
  43600. _readPageLabels() {
  43601. const obj = this._catDict.getRaw("PageLabels");
  43602. if (!obj) {
  43603. return null;
  43604. }
  43605. const pageLabels = new Array(this.numPages);
  43606. let style = null,
  43607. prefix = "";
  43608. const numberTree = new _name_number_tree.NumberTree(obj, this.xref);
  43609. const nums = numberTree.getAll();
  43610. let currentLabel = "",
  43611. currentIndex = 1;
  43612. for (let i = 0, ii = this.numPages; i < ii; i++) {
  43613. const labelDict = nums.get(i);
  43614. if (labelDict !== undefined) {
  43615. if (!(labelDict instanceof _primitives.Dict)) {
  43616. throw new _util.FormatError("PageLabel is not a dictionary.");
  43617. }
  43618. if (labelDict.has("Type") && !(0, _primitives.isName)(labelDict.get("Type"), "PageLabel")) {
  43619. throw new _util.FormatError("Invalid type in PageLabel dictionary.");
  43620. }
  43621. if (labelDict.has("S")) {
  43622. const s = labelDict.get("S");
  43623. if (!(s instanceof _primitives.Name)) {
  43624. throw new _util.FormatError("Invalid style in PageLabel dictionary.");
  43625. }
  43626. style = s.name;
  43627. } else {
  43628. style = null;
  43629. }
  43630. if (labelDict.has("P")) {
  43631. const p = labelDict.get("P");
  43632. if (typeof p !== "string") {
  43633. throw new _util.FormatError("Invalid prefix in PageLabel dictionary.");
  43634. }
  43635. prefix = (0, _util.stringToPDFString)(p);
  43636. } else {
  43637. prefix = "";
  43638. }
  43639. if (labelDict.has("St")) {
  43640. const st = labelDict.get("St");
  43641. if (!(Number.isInteger(st) && st >= 1)) {
  43642. throw new _util.FormatError("Invalid start in PageLabel dictionary.");
  43643. }
  43644. currentIndex = st;
  43645. } else {
  43646. currentIndex = 1;
  43647. }
  43648. }
  43649. switch (style) {
  43650. case "D":
  43651. currentLabel = currentIndex;
  43652. break;
  43653. case "R":
  43654. case "r":
  43655. currentLabel = (0, _core_utils.toRomanNumerals)(currentIndex, style === "r");
  43656. break;
  43657. case "A":
  43658. case "a":
  43659. const LIMIT = 26;
  43660. const A_UPPER_CASE = 0x41,
  43661. A_LOWER_CASE = 0x61;
  43662. const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
  43663. const letterIndex = currentIndex - 1;
  43664. const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  43665. currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
  43666. break;
  43667. default:
  43668. if (style) {
  43669. throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
  43670. }
  43671. currentLabel = "";
  43672. }
  43673. pageLabels[i] = prefix + currentLabel;
  43674. currentIndex++;
  43675. }
  43676. return pageLabels;
  43677. }
  43678. get pageLayout() {
  43679. const obj = this._catDict.get("PageLayout");
  43680. let pageLayout = "";
  43681. if (obj instanceof _primitives.Name) {
  43682. switch (obj.name) {
  43683. case "SinglePage":
  43684. case "OneColumn":
  43685. case "TwoColumnLeft":
  43686. case "TwoColumnRight":
  43687. case "TwoPageLeft":
  43688. case "TwoPageRight":
  43689. pageLayout = obj.name;
  43690. }
  43691. }
  43692. return (0, _util.shadow)(this, "pageLayout", pageLayout);
  43693. }
  43694. get pageMode() {
  43695. const obj = this._catDict.get("PageMode");
  43696. let pageMode = "UseNone";
  43697. if (obj instanceof _primitives.Name) {
  43698. switch (obj.name) {
  43699. case "UseNone":
  43700. case "UseOutlines":
  43701. case "UseThumbs":
  43702. case "FullScreen":
  43703. case "UseOC":
  43704. case "UseAttachments":
  43705. pageMode = obj.name;
  43706. }
  43707. }
  43708. return (0, _util.shadow)(this, "pageMode", pageMode);
  43709. }
  43710. get viewerPreferences() {
  43711. const obj = this._catDict.get("ViewerPreferences");
  43712. if (!(obj instanceof _primitives.Dict)) {
  43713. return (0, _util.shadow)(this, "viewerPreferences", null);
  43714. }
  43715. let prefs = null;
  43716. for (const key of obj.getKeys()) {
  43717. const value = obj.get(key);
  43718. let prefValue;
  43719. switch (key) {
  43720. case "HideToolbar":
  43721. case "HideMenubar":
  43722. case "HideWindowUI":
  43723. case "FitWindow":
  43724. case "CenterWindow":
  43725. case "DisplayDocTitle":
  43726. case "PickTrayByPDFSize":
  43727. if (typeof value === "boolean") {
  43728. prefValue = value;
  43729. }
  43730. break;
  43731. case "NonFullScreenPageMode":
  43732. if (value instanceof _primitives.Name) {
  43733. switch (value.name) {
  43734. case "UseNone":
  43735. case "UseOutlines":
  43736. case "UseThumbs":
  43737. case "UseOC":
  43738. prefValue = value.name;
  43739. break;
  43740. default:
  43741. prefValue = "UseNone";
  43742. }
  43743. }
  43744. break;
  43745. case "Direction":
  43746. if (value instanceof _primitives.Name) {
  43747. switch (value.name) {
  43748. case "L2R":
  43749. case "R2L":
  43750. prefValue = value.name;
  43751. break;
  43752. default:
  43753. prefValue = "L2R";
  43754. }
  43755. }
  43756. break;
  43757. case "ViewArea":
  43758. case "ViewClip":
  43759. case "PrintArea":
  43760. case "PrintClip":
  43761. if (value instanceof _primitives.Name) {
  43762. switch (value.name) {
  43763. case "MediaBox":
  43764. case "CropBox":
  43765. case "BleedBox":
  43766. case "TrimBox":
  43767. case "ArtBox":
  43768. prefValue = value.name;
  43769. break;
  43770. default:
  43771. prefValue = "CropBox";
  43772. }
  43773. }
  43774. break;
  43775. case "PrintScaling":
  43776. if (value instanceof _primitives.Name) {
  43777. switch (value.name) {
  43778. case "None":
  43779. case "AppDefault":
  43780. prefValue = value.name;
  43781. break;
  43782. default:
  43783. prefValue = "AppDefault";
  43784. }
  43785. }
  43786. break;
  43787. case "Duplex":
  43788. if (value instanceof _primitives.Name) {
  43789. switch (value.name) {
  43790. case "Simplex":
  43791. case "DuplexFlipShortEdge":
  43792. case "DuplexFlipLongEdge":
  43793. prefValue = value.name;
  43794. break;
  43795. default:
  43796. prefValue = "None";
  43797. }
  43798. }
  43799. break;
  43800. case "PrintPageRange":
  43801. if (Array.isArray(value) && value.length % 2 === 0) {
  43802. const isValid = value.every((page, i, arr) => {
  43803. return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages;
  43804. });
  43805. if (isValid) {
  43806. prefValue = value;
  43807. }
  43808. }
  43809. break;
  43810. case "NumCopies":
  43811. if (Number.isInteger(value) && value > 0) {
  43812. prefValue = value;
  43813. }
  43814. break;
  43815. default:
  43816. (0, _util.warn)(`Ignoring non-standard key in ViewerPreferences: ${key}.`);
  43817. continue;
  43818. }
  43819. if (prefValue === undefined) {
  43820. (0, _util.warn)(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
  43821. continue;
  43822. }
  43823. if (!prefs) {
  43824. prefs = Object.create(null);
  43825. }
  43826. prefs[key] = prefValue;
  43827. }
  43828. return (0, _util.shadow)(this, "viewerPreferences", prefs);
  43829. }
  43830. get openAction() {
  43831. const obj = this._catDict.get("OpenAction");
  43832. const openAction = Object.create(null);
  43833. if (obj instanceof _primitives.Dict) {
  43834. const destDict = new _primitives.Dict(this.xref);
  43835. destDict.set("A", obj);
  43836. const resultObj = {
  43837. url: null,
  43838. dest: null,
  43839. action: null
  43840. };
  43841. Catalog.parseDestDictionary({
  43842. destDict,
  43843. resultObj
  43844. });
  43845. if (Array.isArray(resultObj.dest)) {
  43846. openAction.dest = resultObj.dest;
  43847. } else if (resultObj.action) {
  43848. openAction.action = resultObj.action;
  43849. }
  43850. } else if (Array.isArray(obj)) {
  43851. openAction.dest = obj;
  43852. }
  43853. return (0, _util.shadow)(this, "openAction", (0, _util.objectSize)(openAction) > 0 ? openAction : null);
  43854. }
  43855. get attachments() {
  43856. const obj = this._catDict.get("Names");
  43857. let attachments = null;
  43858. if (obj instanceof _primitives.Dict && obj.has("EmbeddedFiles")) {
  43859. const nameTree = new _name_number_tree.NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
  43860. for (const [key, value] of nameTree.getAll()) {
  43861. const fs = new _file_spec.FileSpec(value, this.xref);
  43862. if (!attachments) {
  43863. attachments = Object.create(null);
  43864. }
  43865. attachments[(0, _util.stringToPDFString)(key)] = fs.serializable;
  43866. }
  43867. }
  43868. return (0, _util.shadow)(this, "attachments", attachments);
  43869. }
  43870. get xfaImages() {
  43871. const obj = this._catDict.get("Names");
  43872. let xfaImages = null;
  43873. if (obj instanceof _primitives.Dict && obj.has("XFAImages")) {
  43874. const nameTree = new _name_number_tree.NameTree(obj.getRaw("XFAImages"), this.xref);
  43875. for (const [key, value] of nameTree.getAll()) {
  43876. if (!xfaImages) {
  43877. xfaImages = new _primitives.Dict(this.xref);
  43878. }
  43879. xfaImages.set((0, _util.stringToPDFString)(key), value);
  43880. }
  43881. }
  43882. return (0, _util.shadow)(this, "xfaImages", xfaImages);
  43883. }
  43884. _collectJavaScript() {
  43885. const obj = this._catDict.get("Names");
  43886. let javaScript = null;
  43887. function appendIfJavaScriptDict(name, jsDict) {
  43888. if (!(jsDict instanceof _primitives.Dict)) {
  43889. return;
  43890. }
  43891. if (!(0, _primitives.isName)(jsDict.get("S"), "JavaScript")) {
  43892. return;
  43893. }
  43894. let js = jsDict.get("JS");
  43895. if (js instanceof _base_stream.BaseStream) {
  43896. js = js.getString();
  43897. } else if (typeof js !== "string") {
  43898. return;
  43899. }
  43900. js = (0, _util.stringToPDFString)(js).replaceAll("\x00", "");
  43901. if (js) {
  43902. (javaScript ||= new Map()).set(name, js);
  43903. }
  43904. }
  43905. if (obj instanceof _primitives.Dict && obj.has("JavaScript")) {
  43906. const nameTree = new _name_number_tree.NameTree(obj.getRaw("JavaScript"), this.xref);
  43907. for (const [key, value] of nameTree.getAll()) {
  43908. appendIfJavaScriptDict((0, _util.stringToPDFString)(key), value);
  43909. }
  43910. }
  43911. const openAction = this._catDict.get("OpenAction");
  43912. if (openAction) {
  43913. appendIfJavaScriptDict("OpenAction", openAction);
  43914. }
  43915. return javaScript;
  43916. }
  43917. get jsActions() {
  43918. const javaScript = this._collectJavaScript();
  43919. let actions = (0, _core_utils.collectActions)(this.xref, this._catDict, _util.DocumentActionEventType);
  43920. if (javaScript) {
  43921. actions ||= Object.create(null);
  43922. for (const [key, val] of javaScript) {
  43923. if (key in actions) {
  43924. actions[key].push(val);
  43925. } else {
  43926. actions[key] = [val];
  43927. }
  43928. }
  43929. }
  43930. return (0, _util.shadow)(this, "jsActions", actions);
  43931. }
  43932. async fontFallback(id, handler) {
  43933. const translatedFonts = await Promise.all(this.fontCache);
  43934. for (const translatedFont of translatedFonts) {
  43935. if (translatedFont.loadedName === id) {
  43936. translatedFont.fallback(handler);
  43937. return;
  43938. }
  43939. }
  43940. }
  43941. async cleanup(manuallyTriggered = false) {
  43942. (0, _cleanup_helper.clearGlobalCaches)();
  43943. this.globalImageCache.clear(manuallyTriggered);
  43944. this.pageKidsCountCache.clear();
  43945. this.pageIndexCache.clear();
  43946. this.nonBlendModesSet.clear();
  43947. const translatedFonts = await Promise.all(this.fontCache);
  43948. for (const {
  43949. dict
  43950. } of translatedFonts) {
  43951. delete dict.cacheKey;
  43952. }
  43953. this.fontCache.clear();
  43954. this.builtInCMapCache.clear();
  43955. this.standardFontDataCache.clear();
  43956. this.systemFontCache.clear();
  43957. }
  43958. async getPageDict(pageIndex) {
  43959. const nodesToVisit = [this.toplevelPagesDict];
  43960. const visitedNodes = new _primitives.RefSet();
  43961. const pagesRef = this._catDict.getRaw("Pages");
  43962. if (pagesRef instanceof _primitives.Ref) {
  43963. visitedNodes.put(pagesRef);
  43964. }
  43965. const xref = this.xref,
  43966. pageKidsCountCache = this.pageKidsCountCache,
  43967. pageIndexCache = this.pageIndexCache;
  43968. let currentPageIndex = 0;
  43969. while (nodesToVisit.length) {
  43970. const currentNode = nodesToVisit.pop();
  43971. if (currentNode instanceof _primitives.Ref) {
  43972. const count = pageKidsCountCache.get(currentNode);
  43973. if (count >= 0 && currentPageIndex + count <= pageIndex) {
  43974. currentPageIndex += count;
  43975. continue;
  43976. }
  43977. if (visitedNodes.has(currentNode)) {
  43978. throw new _util.FormatError("Pages tree contains circular reference.");
  43979. }
  43980. visitedNodes.put(currentNode);
  43981. const obj = await xref.fetchAsync(currentNode);
  43982. if (obj instanceof _primitives.Dict) {
  43983. let type = obj.getRaw("Type");
  43984. if (type instanceof _primitives.Ref) {
  43985. type = await xref.fetchAsync(type);
  43986. }
  43987. if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) {
  43988. if (!pageKidsCountCache.has(currentNode)) {
  43989. pageKidsCountCache.put(currentNode, 1);
  43990. }
  43991. if (!pageIndexCache.has(currentNode)) {
  43992. pageIndexCache.put(currentNode, currentPageIndex);
  43993. }
  43994. if (currentPageIndex === pageIndex) {
  43995. return [obj, currentNode];
  43996. }
  43997. currentPageIndex++;
  43998. continue;
  43999. }
  44000. }
  44001. nodesToVisit.push(obj);
  44002. continue;
  44003. }
  44004. if (!(currentNode instanceof _primitives.Dict)) {
  44005. throw new _util.FormatError("Page dictionary kid reference points to wrong type of object.");
  44006. }
  44007. const {
  44008. objId
  44009. } = currentNode;
  44010. let count = currentNode.getRaw("Count");
  44011. if (count instanceof _primitives.Ref) {
  44012. count = await xref.fetchAsync(count);
  44013. }
  44014. if (Number.isInteger(count) && count >= 0) {
  44015. if (objId && !pageKidsCountCache.has(objId)) {
  44016. pageKidsCountCache.put(objId, count);
  44017. }
  44018. if (currentPageIndex + count <= pageIndex) {
  44019. currentPageIndex += count;
  44020. continue;
  44021. }
  44022. }
  44023. let kids = currentNode.getRaw("Kids");
  44024. if (kids instanceof _primitives.Ref) {
  44025. kids = await xref.fetchAsync(kids);
  44026. }
  44027. if (!Array.isArray(kids)) {
  44028. let type = currentNode.getRaw("Type");
  44029. if (type instanceof _primitives.Ref) {
  44030. type = await xref.fetchAsync(type);
  44031. }
  44032. if ((0, _primitives.isName)(type, "Page") || !currentNode.has("Kids")) {
  44033. if (currentPageIndex === pageIndex) {
  44034. return [currentNode, null];
  44035. }
  44036. currentPageIndex++;
  44037. continue;
  44038. }
  44039. throw new _util.FormatError("Page dictionary kids object is not an array.");
  44040. }
  44041. for (let last = kids.length - 1; last >= 0; last--) {
  44042. nodesToVisit.push(kids[last]);
  44043. }
  44044. }
  44045. throw new Error(`Page index ${pageIndex} not found.`);
  44046. }
  44047. async getAllPageDicts(recoveryMode = false) {
  44048. const {
  44049. ignoreErrors
  44050. } = this.pdfManager.evaluatorOptions;
  44051. const queue = [{
  44052. currentNode: this.toplevelPagesDict,
  44053. posInKids: 0
  44054. }];
  44055. const visitedNodes = new _primitives.RefSet();
  44056. const pagesRef = this._catDict.getRaw("Pages");
  44057. if (pagesRef instanceof _primitives.Ref) {
  44058. visitedNodes.put(pagesRef);
  44059. }
  44060. const map = new Map(),
  44061. xref = this.xref,
  44062. pageIndexCache = this.pageIndexCache;
  44063. let pageIndex = 0;
  44064. function addPageDict(pageDict, pageRef) {
  44065. if (pageRef && !pageIndexCache.has(pageRef)) {
  44066. pageIndexCache.put(pageRef, pageIndex);
  44067. }
  44068. map.set(pageIndex++, [pageDict, pageRef]);
  44069. }
  44070. function addPageError(error) {
  44071. if (error instanceof _core_utils.XRefEntryException && !recoveryMode) {
  44072. throw error;
  44073. }
  44074. if (recoveryMode && ignoreErrors && pageIndex === 0) {
  44075. (0, _util.warn)(`getAllPageDicts - Skipping invalid first page: "${error}".`);
  44076. error = _primitives.Dict.empty;
  44077. }
  44078. map.set(pageIndex++, [error, null]);
  44079. }
  44080. while (queue.length > 0) {
  44081. const queueItem = queue.at(-1);
  44082. const {
  44083. currentNode,
  44084. posInKids
  44085. } = queueItem;
  44086. let kids = currentNode.getRaw("Kids");
  44087. if (kids instanceof _primitives.Ref) {
  44088. try {
  44089. kids = await xref.fetchAsync(kids);
  44090. } catch (ex) {
  44091. addPageError(ex);
  44092. break;
  44093. }
  44094. }
  44095. if (!Array.isArray(kids)) {
  44096. addPageError(new _util.FormatError("Page dictionary kids object is not an array."));
  44097. break;
  44098. }
  44099. if (posInKids >= kids.length) {
  44100. queue.pop();
  44101. continue;
  44102. }
  44103. const kidObj = kids[posInKids];
  44104. let obj;
  44105. if (kidObj instanceof _primitives.Ref) {
  44106. if (visitedNodes.has(kidObj)) {
  44107. addPageError(new _util.FormatError("Pages tree contains circular reference."));
  44108. break;
  44109. }
  44110. visitedNodes.put(kidObj);
  44111. try {
  44112. obj = await xref.fetchAsync(kidObj);
  44113. } catch (ex) {
  44114. addPageError(ex);
  44115. break;
  44116. }
  44117. } else {
  44118. obj = kidObj;
  44119. }
  44120. if (!(obj instanceof _primitives.Dict)) {
  44121. addPageError(new _util.FormatError("Page dictionary kid reference points to wrong type of object."));
  44122. break;
  44123. }
  44124. let type = obj.getRaw("Type");
  44125. if (type instanceof _primitives.Ref) {
  44126. try {
  44127. type = await xref.fetchAsync(type);
  44128. } catch (ex) {
  44129. addPageError(ex);
  44130. break;
  44131. }
  44132. }
  44133. if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) {
  44134. addPageDict(obj, kidObj instanceof _primitives.Ref ? kidObj : null);
  44135. } else {
  44136. queue.push({
  44137. currentNode: obj,
  44138. posInKids: 0
  44139. });
  44140. }
  44141. queueItem.posInKids++;
  44142. }
  44143. return map;
  44144. }
  44145. getPageIndex(pageRef) {
  44146. const cachedPageIndex = this.pageIndexCache.get(pageRef);
  44147. if (cachedPageIndex !== undefined) {
  44148. return Promise.resolve(cachedPageIndex);
  44149. }
  44150. const xref = this.xref;
  44151. function pagesBeforeRef(kidRef) {
  44152. let total = 0,
  44153. parentRef;
  44154. return xref.fetchAsync(kidRef).then(function (node) {
  44155. if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !(node instanceof _primitives.Dict && !node.has("Type") && node.has("Contents"))) {
  44156. throw new _util.FormatError("The reference does not point to a /Page dictionary.");
  44157. }
  44158. if (!node) {
  44159. return null;
  44160. }
  44161. if (!(node instanceof _primitives.Dict)) {
  44162. throw new _util.FormatError("Node must be a dictionary.");
  44163. }
  44164. parentRef = node.getRaw("Parent");
  44165. return node.getAsync("Parent");
  44166. }).then(function (parent) {
  44167. if (!parent) {
  44168. return null;
  44169. }
  44170. if (!(parent instanceof _primitives.Dict)) {
  44171. throw new _util.FormatError("Parent must be a dictionary.");
  44172. }
  44173. return parent.getAsync("Kids");
  44174. }).then(function (kids) {
  44175. if (!kids) {
  44176. return null;
  44177. }
  44178. const kidPromises = [];
  44179. let found = false;
  44180. for (const kid of kids) {
  44181. if (!(kid instanceof _primitives.Ref)) {
  44182. throw new _util.FormatError("Kid must be a reference.");
  44183. }
  44184. if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
  44185. found = true;
  44186. break;
  44187. }
  44188. kidPromises.push(xref.fetchAsync(kid).then(function (obj) {
  44189. if (!(obj instanceof _primitives.Dict)) {
  44190. throw new _util.FormatError("Kid node must be a dictionary.");
  44191. }
  44192. if (obj.has("Count")) {
  44193. total += obj.get("Count");
  44194. } else {
  44195. total++;
  44196. }
  44197. }));
  44198. }
  44199. if (!found) {
  44200. throw new _util.FormatError("Kid reference not found in parent's kids.");
  44201. }
  44202. return Promise.all(kidPromises).then(function () {
  44203. return [total, parentRef];
  44204. });
  44205. });
  44206. }
  44207. let total = 0;
  44208. const next = ref => pagesBeforeRef(ref).then(args => {
  44209. if (!args) {
  44210. this.pageIndexCache.put(pageRef, total);
  44211. return total;
  44212. }
  44213. const [count, parentRef] = args;
  44214. total += count;
  44215. return next(parentRef);
  44216. });
  44217. return next(pageRef);
  44218. }
  44219. get baseUrl() {
  44220. const uri = this._catDict.get("URI");
  44221. if (uri instanceof _primitives.Dict) {
  44222. const base = uri.get("Base");
  44223. if (typeof base === "string") {
  44224. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(base, null, {
  44225. tryConvertEncoding: true
  44226. });
  44227. if (absoluteUrl) {
  44228. return (0, _util.shadow)(this, "baseUrl", absoluteUrl.href);
  44229. }
  44230. }
  44231. }
  44232. return (0, _util.shadow)(this, "baseUrl", null);
  44233. }
  44234. static parseDestDictionary(params) {
  44235. const destDict = params.destDict;
  44236. if (!(destDict instanceof _primitives.Dict)) {
  44237. (0, _util.warn)("parseDestDictionary: `destDict` must be a dictionary.");
  44238. return;
  44239. }
  44240. const resultObj = params.resultObj;
  44241. if (typeof resultObj !== "object") {
  44242. (0, _util.warn)("parseDestDictionary: `resultObj` must be an object.");
  44243. return;
  44244. }
  44245. const docBaseUrl = params.docBaseUrl || null;
  44246. const docAttachments = params.docAttachments || null;
  44247. let action = destDict.get("A"),
  44248. url,
  44249. dest;
  44250. if (!(action instanceof _primitives.Dict)) {
  44251. if (destDict.has("Dest")) {
  44252. action = destDict.get("Dest");
  44253. } else {
  44254. action = destDict.get("AA");
  44255. if (action instanceof _primitives.Dict) {
  44256. if (action.has("D")) {
  44257. action = action.get("D");
  44258. } else if (action.has("U")) {
  44259. action = action.get("U");
  44260. }
  44261. }
  44262. }
  44263. }
  44264. if (action instanceof _primitives.Dict) {
  44265. const actionType = action.get("S");
  44266. if (!(actionType instanceof _primitives.Name)) {
  44267. (0, _util.warn)("parseDestDictionary: Invalid type in Action dictionary.");
  44268. return;
  44269. }
  44270. const actionName = actionType.name;
  44271. switch (actionName) {
  44272. case "ResetForm":
  44273. const flags = action.get("Flags");
  44274. const include = ((typeof flags === "number" ? flags : 0) & 1) === 0;
  44275. const fields = [];
  44276. const refs = [];
  44277. for (const obj of action.get("Fields") || []) {
  44278. if (obj instanceof _primitives.Ref) {
  44279. refs.push(obj.toString());
  44280. } else if (typeof obj === "string") {
  44281. fields.push((0, _util.stringToPDFString)(obj));
  44282. }
  44283. }
  44284. resultObj.resetForm = {
  44285. fields,
  44286. refs,
  44287. include
  44288. };
  44289. break;
  44290. case "URI":
  44291. url = action.get("URI");
  44292. if (url instanceof _primitives.Name) {
  44293. url = "/" + url.name;
  44294. }
  44295. break;
  44296. case "GoTo":
  44297. dest = action.get("D");
  44298. break;
  44299. case "Launch":
  44300. case "GoToR":
  44301. const urlDict = action.get("F");
  44302. if (urlDict instanceof _primitives.Dict) {
  44303. url = urlDict.get("F") || null;
  44304. } else if (typeof urlDict === "string") {
  44305. url = urlDict;
  44306. }
  44307. let remoteDest = action.get("D");
  44308. if (remoteDest) {
  44309. if (remoteDest instanceof _primitives.Name) {
  44310. remoteDest = remoteDest.name;
  44311. }
  44312. if (typeof url === "string") {
  44313. const baseUrl = url.split("#")[0];
  44314. if (typeof remoteDest === "string") {
  44315. url = baseUrl + "#" + remoteDest;
  44316. } else if (Array.isArray(remoteDest)) {
  44317. url = baseUrl + "#" + JSON.stringify(remoteDest);
  44318. }
  44319. }
  44320. }
  44321. const newWindow = action.get("NewWindow");
  44322. if (typeof newWindow === "boolean") {
  44323. resultObj.newWindow = newWindow;
  44324. }
  44325. break;
  44326. case "GoToE":
  44327. const target = action.get("T");
  44328. let attachment;
  44329. if (docAttachments && target instanceof _primitives.Dict) {
  44330. const relationship = target.get("R");
  44331. const name = target.get("N");
  44332. if ((0, _primitives.isName)(relationship, "C") && typeof name === "string") {
  44333. attachment = docAttachments[(0, _util.stringToPDFString)(name)];
  44334. }
  44335. }
  44336. if (attachment) {
  44337. resultObj.attachment = attachment;
  44338. } else {
  44339. (0, _util.warn)(`parseDestDictionary - unimplemented "GoToE" action.`);
  44340. }
  44341. break;
  44342. case "Named":
  44343. const namedAction = action.get("N");
  44344. if (namedAction instanceof _primitives.Name) {
  44345. resultObj.action = namedAction.name;
  44346. }
  44347. break;
  44348. case "SetOCGState":
  44349. const state = action.get("State");
  44350. const preserveRB = action.get("PreserveRB");
  44351. if (!Array.isArray(state) || state.length === 0) {
  44352. break;
  44353. }
  44354. const stateArr = [];
  44355. for (const elem of state) {
  44356. if (elem instanceof _primitives.Name) {
  44357. switch (elem.name) {
  44358. case "ON":
  44359. case "OFF":
  44360. case "Toggle":
  44361. stateArr.push(elem.name);
  44362. break;
  44363. }
  44364. } else if (elem instanceof _primitives.Ref) {
  44365. stateArr.push(elem.toString());
  44366. }
  44367. }
  44368. if (stateArr.length !== state.length) {
  44369. break;
  44370. }
  44371. resultObj.setOCGState = {
  44372. state: stateArr,
  44373. preserveRB: typeof preserveRB === "boolean" ? preserveRB : true
  44374. };
  44375. break;
  44376. case "JavaScript":
  44377. const jsAction = action.get("JS");
  44378. let js;
  44379. if (jsAction instanceof _base_stream.BaseStream) {
  44380. js = jsAction.getString();
  44381. } else if (typeof jsAction === "string") {
  44382. js = jsAction;
  44383. }
  44384. const jsURL = js && (0, _core_utils.recoverJsURL)((0, _util.stringToPDFString)(js));
  44385. if (jsURL) {
  44386. url = jsURL.url;
  44387. resultObj.newWindow = jsURL.newWindow;
  44388. break;
  44389. }
  44390. default:
  44391. if (actionName === "JavaScript" || actionName === "SubmitForm") {
  44392. break;
  44393. }
  44394. (0, _util.warn)(`parseDestDictionary - unsupported action: "${actionName}".`);
  44395. break;
  44396. }
  44397. } else if (destDict.has("Dest")) {
  44398. dest = destDict.get("Dest");
  44399. }
  44400. if (typeof url === "string") {
  44401. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl, {
  44402. addDefaultProtocol: true,
  44403. tryConvertEncoding: true
  44404. });
  44405. if (absoluteUrl) {
  44406. resultObj.url = absoluteUrl.href;
  44407. }
  44408. resultObj.unsafeUrl = url;
  44409. }
  44410. if (dest) {
  44411. if (dest instanceof _primitives.Name) {
  44412. dest = dest.name;
  44413. }
  44414. if (typeof dest === "string") {
  44415. resultObj.dest = (0, _util.stringToPDFString)(dest);
  44416. } else if (Array.isArray(dest)) {
  44417. resultObj.dest = dest;
  44418. }
  44419. }
  44420. }
  44421. }
  44422. exports.Catalog = Catalog;
  44423. /***/ }),
  44424. /* 71 */
  44425. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44426. Object.defineProperty(exports, "__esModule", ({
  44427. value: true
  44428. }));
  44429. exports.NumberTree = exports.NameTree = void 0;
  44430. var _primitives = __w_pdfjs_require__(4);
  44431. var _util = __w_pdfjs_require__(2);
  44432. class NameOrNumberTree {
  44433. constructor(root, xref, type) {
  44434. if (this.constructor === NameOrNumberTree) {
  44435. (0, _util.unreachable)("Cannot initialize NameOrNumberTree.");
  44436. }
  44437. this.root = root;
  44438. this.xref = xref;
  44439. this._type = type;
  44440. }
  44441. getAll() {
  44442. const map = new Map();
  44443. if (!this.root) {
  44444. return map;
  44445. }
  44446. const xref = this.xref;
  44447. const processed = new _primitives.RefSet();
  44448. processed.put(this.root);
  44449. const queue = [this.root];
  44450. while (queue.length > 0) {
  44451. const obj = xref.fetchIfRef(queue.shift());
  44452. if (!(obj instanceof _primitives.Dict)) {
  44453. continue;
  44454. }
  44455. if (obj.has("Kids")) {
  44456. const kids = obj.get("Kids");
  44457. if (!Array.isArray(kids)) {
  44458. continue;
  44459. }
  44460. for (const kid of kids) {
  44461. if (processed.has(kid)) {
  44462. throw new _util.FormatError(`Duplicate entry in "${this._type}" tree.`);
  44463. }
  44464. queue.push(kid);
  44465. processed.put(kid);
  44466. }
  44467. continue;
  44468. }
  44469. const entries = obj.get(this._type);
  44470. if (!Array.isArray(entries)) {
  44471. continue;
  44472. }
  44473. for (let i = 0, ii = entries.length; i < ii; i += 2) {
  44474. map.set(xref.fetchIfRef(entries[i]), xref.fetchIfRef(entries[i + 1]));
  44475. }
  44476. }
  44477. return map;
  44478. }
  44479. get(key) {
  44480. if (!this.root) {
  44481. return null;
  44482. }
  44483. const xref = this.xref;
  44484. let kidsOrEntries = xref.fetchIfRef(this.root);
  44485. let loopCount = 0;
  44486. const MAX_LEVELS = 10;
  44487. while (kidsOrEntries.has("Kids")) {
  44488. if (++loopCount > MAX_LEVELS) {
  44489. (0, _util.warn)(`Search depth limit reached for "${this._type}" tree.`);
  44490. return null;
  44491. }
  44492. const kids = kidsOrEntries.get("Kids");
  44493. if (!Array.isArray(kids)) {
  44494. return null;
  44495. }
  44496. let l = 0,
  44497. r = kids.length - 1;
  44498. while (l <= r) {
  44499. const m = l + r >> 1;
  44500. const kid = xref.fetchIfRef(kids[m]);
  44501. const limits = kid.get("Limits");
  44502. if (key < xref.fetchIfRef(limits[0])) {
  44503. r = m - 1;
  44504. } else if (key > xref.fetchIfRef(limits[1])) {
  44505. l = m + 1;
  44506. } else {
  44507. kidsOrEntries = kid;
  44508. break;
  44509. }
  44510. }
  44511. if (l > r) {
  44512. return null;
  44513. }
  44514. }
  44515. const entries = kidsOrEntries.get(this._type);
  44516. if (Array.isArray(entries)) {
  44517. let l = 0,
  44518. r = entries.length - 2;
  44519. while (l <= r) {
  44520. const tmp = l + r >> 1,
  44521. m = tmp + (tmp & 1);
  44522. const currentKey = xref.fetchIfRef(entries[m]);
  44523. if (key < currentKey) {
  44524. r = m - 2;
  44525. } else if (key > currentKey) {
  44526. l = m + 2;
  44527. } else {
  44528. return xref.fetchIfRef(entries[m + 1]);
  44529. }
  44530. }
  44531. }
  44532. return null;
  44533. }
  44534. }
  44535. class NameTree extends NameOrNumberTree {
  44536. constructor(root, xref) {
  44537. super(root, xref, "Names");
  44538. }
  44539. }
  44540. exports.NameTree = NameTree;
  44541. class NumberTree extends NameOrNumberTree {
  44542. constructor(root, xref) {
  44543. super(root, xref, "Nums");
  44544. }
  44545. }
  44546. exports.NumberTree = NumberTree;
  44547. /***/ }),
  44548. /* 72 */
  44549. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44550. Object.defineProperty(exports, "__esModule", ({
  44551. value: true
  44552. }));
  44553. exports.clearGlobalCaches = clearGlobalCaches;
  44554. var _primitives = __w_pdfjs_require__(4);
  44555. var _unicode = __w_pdfjs_require__(40);
  44556. function clearGlobalCaches() {
  44557. (0, _primitives.clearPrimitiveCaches)();
  44558. (0, _unicode.clearUnicodeCaches)();
  44559. }
  44560. /***/ }),
  44561. /* 73 */
  44562. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44563. Object.defineProperty(exports, "__esModule", ({
  44564. value: true
  44565. }));
  44566. exports.FileSpec = void 0;
  44567. var _util = __w_pdfjs_require__(2);
  44568. var _base_stream = __w_pdfjs_require__(5);
  44569. var _primitives = __w_pdfjs_require__(4);
  44570. function pickPlatformItem(dict) {
  44571. if (dict.has("UF")) {
  44572. return dict.get("UF");
  44573. } else if (dict.has("F")) {
  44574. return dict.get("F");
  44575. } else if (dict.has("Unix")) {
  44576. return dict.get("Unix");
  44577. } else if (dict.has("Mac")) {
  44578. return dict.get("Mac");
  44579. } else if (dict.has("DOS")) {
  44580. return dict.get("DOS");
  44581. }
  44582. return null;
  44583. }
  44584. class FileSpec {
  44585. constructor(root, xref) {
  44586. if (!(root instanceof _primitives.Dict)) {
  44587. return;
  44588. }
  44589. this.xref = xref;
  44590. this.root = root;
  44591. if (root.has("FS")) {
  44592. this.fs = root.get("FS");
  44593. }
  44594. this.description = root.has("Desc") ? (0, _util.stringToPDFString)(root.get("Desc")) : "";
  44595. if (root.has("RF")) {
  44596. (0, _util.warn)("Related file specifications are not supported");
  44597. }
  44598. this.contentAvailable = true;
  44599. if (!root.has("EF")) {
  44600. this.contentAvailable = false;
  44601. (0, _util.warn)("Non-embedded file specifications are not supported");
  44602. }
  44603. }
  44604. get filename() {
  44605. if (!this._filename && this.root) {
  44606. const filename = pickPlatformItem(this.root) || "unnamed";
  44607. this._filename = (0, _util.stringToPDFString)(filename).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/");
  44608. }
  44609. return this._filename;
  44610. }
  44611. get content() {
  44612. if (!this.contentAvailable) {
  44613. return null;
  44614. }
  44615. if (!this.contentRef && this.root) {
  44616. this.contentRef = pickPlatformItem(this.root.get("EF"));
  44617. }
  44618. let content = null;
  44619. if (this.contentRef) {
  44620. const fileObj = this.xref.fetchIfRef(this.contentRef);
  44621. if (fileObj instanceof _base_stream.BaseStream) {
  44622. content = fileObj.getBytes();
  44623. } else {
  44624. (0, _util.warn)("Embedded file specification points to non-existing/invalid content");
  44625. }
  44626. } else {
  44627. (0, _util.warn)("Embedded file specification does not have a content");
  44628. }
  44629. return content;
  44630. }
  44631. get serializable() {
  44632. return {
  44633. filename: this.filename,
  44634. content: this.content
  44635. };
  44636. }
  44637. }
  44638. exports.FileSpec = FileSpec;
  44639. /***/ }),
  44640. /* 74 */
  44641. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44642. Object.defineProperty(exports, "__esModule", ({
  44643. value: true
  44644. }));
  44645. exports.MetadataParser = void 0;
  44646. var _xml_parser = __w_pdfjs_require__(67);
  44647. class MetadataParser {
  44648. constructor(data) {
  44649. data = this._repair(data);
  44650. const parser = new _xml_parser.SimpleXMLParser({
  44651. lowerCaseName: true
  44652. });
  44653. const xmlDocument = parser.parseFromString(data);
  44654. this._metadataMap = new Map();
  44655. this._data = data;
  44656. if (xmlDocument) {
  44657. this._parse(xmlDocument);
  44658. }
  44659. }
  44660. _repair(data) {
  44661. return data.replace(/^[^<]+/, "").replaceAll(/>\\376\\377([^<]+)/g, function (all, codes) {
  44662. const bytes = codes.replaceAll(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  44663. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  44664. }).replaceAll(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  44665. switch (name) {
  44666. case "amp":
  44667. return "&";
  44668. case "apos":
  44669. return "'";
  44670. case "gt":
  44671. return ">";
  44672. case "lt":
  44673. return "<";
  44674. case "quot":
  44675. return '"';
  44676. }
  44677. throw new Error(`_repair: ${name} isn't defined.`);
  44678. });
  44679. const charBuf = [">"];
  44680. for (let i = 0, ii = bytes.length; i < ii; i += 2) {
  44681. const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  44682. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  44683. charBuf.push(String.fromCharCode(code));
  44684. } else {
  44685. charBuf.push("&#x" + (0x10000 + code).toString(16).substring(1) + ";");
  44686. }
  44687. }
  44688. return charBuf.join("");
  44689. });
  44690. }
  44691. _getSequence(entry) {
  44692. const name = entry.nodeName;
  44693. if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") {
  44694. return null;
  44695. }
  44696. return entry.childNodes.filter(node => node.nodeName === "rdf:li");
  44697. }
  44698. _parseArray(entry) {
  44699. if (!entry.hasChildNodes()) {
  44700. return;
  44701. }
  44702. const [seqNode] = entry.childNodes;
  44703. const sequence = this._getSequence(seqNode) || [];
  44704. this._metadataMap.set(entry.nodeName, sequence.map(node => node.textContent.trim()));
  44705. }
  44706. _parse(xmlDocument) {
  44707. let rdf = xmlDocument.documentElement;
  44708. if (rdf.nodeName !== "rdf:rdf") {
  44709. rdf = rdf.firstChild;
  44710. while (rdf && rdf.nodeName !== "rdf:rdf") {
  44711. rdf = rdf.nextSibling;
  44712. }
  44713. }
  44714. if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
  44715. return;
  44716. }
  44717. for (const desc of rdf.childNodes) {
  44718. if (desc.nodeName !== "rdf:description") {
  44719. continue;
  44720. }
  44721. for (const entry of desc.childNodes) {
  44722. const name = entry.nodeName;
  44723. switch (name) {
  44724. case "#text":
  44725. continue;
  44726. case "dc:creator":
  44727. case "dc:subject":
  44728. this._parseArray(entry);
  44729. continue;
  44730. }
  44731. this._metadataMap.set(name, entry.textContent.trim());
  44732. }
  44733. }
  44734. }
  44735. get serializable() {
  44736. return {
  44737. parsedData: this._metadataMap,
  44738. rawData: this._data
  44739. };
  44740. }
  44741. }
  44742. exports.MetadataParser = MetadataParser;
  44743. /***/ }),
  44744. /* 75 */
  44745. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44746. Object.defineProperty(exports, "__esModule", ({
  44747. value: true
  44748. }));
  44749. exports.StructTreeRoot = exports.StructTreePage = void 0;
  44750. var _primitives = __w_pdfjs_require__(4);
  44751. var _util = __w_pdfjs_require__(2);
  44752. var _name_number_tree = __w_pdfjs_require__(71);
  44753. const MAX_DEPTH = 40;
  44754. const StructElementType = {
  44755. PAGE_CONTENT: "PAGE_CONTENT",
  44756. STREAM_CONTENT: "STREAM_CONTENT",
  44757. OBJECT: "OBJECT",
  44758. ELEMENT: "ELEMENT"
  44759. };
  44760. class StructTreeRoot {
  44761. constructor(rootDict) {
  44762. this.dict = rootDict;
  44763. this.roleMap = new Map();
  44764. }
  44765. init() {
  44766. this.readRoleMap();
  44767. }
  44768. readRoleMap() {
  44769. const roleMapDict = this.dict.get("RoleMap");
  44770. if (!(roleMapDict instanceof _primitives.Dict)) {
  44771. return;
  44772. }
  44773. roleMapDict.forEach((key, value) => {
  44774. if (!(value instanceof _primitives.Name)) {
  44775. return;
  44776. }
  44777. this.roleMap.set(key, value.name);
  44778. });
  44779. }
  44780. }
  44781. exports.StructTreeRoot = StructTreeRoot;
  44782. class StructElementNode {
  44783. constructor(tree, dict) {
  44784. this.tree = tree;
  44785. this.dict = dict;
  44786. this.kids = [];
  44787. this.parseKids();
  44788. }
  44789. get role() {
  44790. const nameObj = this.dict.get("S");
  44791. const name = nameObj instanceof _primitives.Name ? nameObj.name : "";
  44792. const {
  44793. root
  44794. } = this.tree;
  44795. if (root.roleMap.has(name)) {
  44796. return root.roleMap.get(name);
  44797. }
  44798. return name;
  44799. }
  44800. parseKids() {
  44801. let pageObjId = null;
  44802. const objRef = this.dict.getRaw("Pg");
  44803. if (objRef instanceof _primitives.Ref) {
  44804. pageObjId = objRef.toString();
  44805. }
  44806. const kids = this.dict.get("K");
  44807. if (Array.isArray(kids)) {
  44808. for (const kid of kids) {
  44809. const element = this.parseKid(pageObjId, kid);
  44810. if (element) {
  44811. this.kids.push(element);
  44812. }
  44813. }
  44814. } else {
  44815. const element = this.parseKid(pageObjId, kids);
  44816. if (element) {
  44817. this.kids.push(element);
  44818. }
  44819. }
  44820. }
  44821. parseKid(pageObjId, kid) {
  44822. if (Number.isInteger(kid)) {
  44823. if (this.tree.pageDict.objId !== pageObjId) {
  44824. return null;
  44825. }
  44826. return new StructElement({
  44827. type: StructElementType.PAGE_CONTENT,
  44828. mcid: kid,
  44829. pageObjId
  44830. });
  44831. }
  44832. let kidDict = null;
  44833. if (kid instanceof _primitives.Ref) {
  44834. kidDict = this.dict.xref.fetch(kid);
  44835. } else if (kid instanceof _primitives.Dict) {
  44836. kidDict = kid;
  44837. }
  44838. if (!kidDict) {
  44839. return null;
  44840. }
  44841. const pageRef = kidDict.getRaw("Pg");
  44842. if (pageRef instanceof _primitives.Ref) {
  44843. pageObjId = pageRef.toString();
  44844. }
  44845. const type = kidDict.get("Type") instanceof _primitives.Name ? kidDict.get("Type").name : null;
  44846. if (type === "MCR") {
  44847. if (this.tree.pageDict.objId !== pageObjId) {
  44848. return null;
  44849. }
  44850. return new StructElement({
  44851. type: StructElementType.STREAM_CONTENT,
  44852. refObjId: kidDict.getRaw("Stm") instanceof _primitives.Ref ? kidDict.getRaw("Stm").toString() : null,
  44853. pageObjId,
  44854. mcid: kidDict.get("MCID")
  44855. });
  44856. }
  44857. if (type === "OBJR") {
  44858. if (this.tree.pageDict.objId !== pageObjId) {
  44859. return null;
  44860. }
  44861. return new StructElement({
  44862. type: StructElementType.OBJECT,
  44863. refObjId: kidDict.getRaw("Obj") instanceof _primitives.Ref ? kidDict.getRaw("Obj").toString() : null,
  44864. pageObjId
  44865. });
  44866. }
  44867. return new StructElement({
  44868. type: StructElementType.ELEMENT,
  44869. dict: kidDict
  44870. });
  44871. }
  44872. }
  44873. class StructElement {
  44874. constructor({
  44875. type,
  44876. dict = null,
  44877. mcid = null,
  44878. pageObjId = null,
  44879. refObjId = null
  44880. }) {
  44881. this.type = type;
  44882. this.dict = dict;
  44883. this.mcid = mcid;
  44884. this.pageObjId = pageObjId;
  44885. this.refObjId = refObjId;
  44886. this.parentNode = null;
  44887. }
  44888. }
  44889. class StructTreePage {
  44890. constructor(structTreeRoot, pageDict) {
  44891. this.root = structTreeRoot;
  44892. this.rootDict = structTreeRoot ? structTreeRoot.dict : null;
  44893. this.pageDict = pageDict;
  44894. this.nodes = [];
  44895. }
  44896. parse() {
  44897. if (!this.root || !this.rootDict) {
  44898. return;
  44899. }
  44900. const parentTree = this.rootDict.get("ParentTree");
  44901. if (!parentTree) {
  44902. return;
  44903. }
  44904. const id = this.pageDict.get("StructParents");
  44905. if (!Number.isInteger(id)) {
  44906. return;
  44907. }
  44908. const numberTree = new _name_number_tree.NumberTree(parentTree, this.rootDict.xref);
  44909. const parentArray = numberTree.get(id);
  44910. if (!Array.isArray(parentArray)) {
  44911. return;
  44912. }
  44913. const map = new Map();
  44914. for (const ref of parentArray) {
  44915. if (ref instanceof _primitives.Ref) {
  44916. this.addNode(this.rootDict.xref.fetch(ref), map);
  44917. }
  44918. }
  44919. }
  44920. addNode(dict, map, level = 0) {
  44921. if (level > MAX_DEPTH) {
  44922. (0, _util.warn)("StructTree MAX_DEPTH reached.");
  44923. return null;
  44924. }
  44925. if (map.has(dict)) {
  44926. return map.get(dict);
  44927. }
  44928. const element = new StructElementNode(this, dict);
  44929. map.set(dict, element);
  44930. const parent = dict.get("P");
  44931. if (!parent || (0, _primitives.isName)(parent.get("Type"), "StructTreeRoot")) {
  44932. if (!this.addTopLevelNode(dict, element)) {
  44933. map.delete(dict);
  44934. }
  44935. return element;
  44936. }
  44937. const parentNode = this.addNode(parent, map, level + 1);
  44938. if (!parentNode) {
  44939. return element;
  44940. }
  44941. let save = false;
  44942. for (const kid of parentNode.kids) {
  44943. if (kid.type === StructElementType.ELEMENT && kid.dict === dict) {
  44944. kid.parentNode = element;
  44945. save = true;
  44946. }
  44947. }
  44948. if (!save) {
  44949. map.delete(dict);
  44950. }
  44951. return element;
  44952. }
  44953. addTopLevelNode(dict, element) {
  44954. const obj = this.rootDict.get("K");
  44955. if (!obj) {
  44956. return false;
  44957. }
  44958. if (obj instanceof _primitives.Dict) {
  44959. if (obj.objId !== dict.objId) {
  44960. return false;
  44961. }
  44962. this.nodes[0] = element;
  44963. return true;
  44964. }
  44965. if (!Array.isArray(obj)) {
  44966. return true;
  44967. }
  44968. let save = false;
  44969. for (let i = 0; i < obj.length; i++) {
  44970. const kidRef = obj[i];
  44971. if (kidRef?.toString() === dict.objId) {
  44972. this.nodes[i] = element;
  44973. save = true;
  44974. }
  44975. }
  44976. return save;
  44977. }
  44978. get serializable() {
  44979. function nodeToSerializable(node, parent, level = 0) {
  44980. if (level > MAX_DEPTH) {
  44981. (0, _util.warn)("StructTree too deep to be fully serialized.");
  44982. return;
  44983. }
  44984. const obj = Object.create(null);
  44985. obj.role = node.role;
  44986. obj.children = [];
  44987. parent.children.push(obj);
  44988. const alt = node.dict.get("Alt");
  44989. if (typeof alt === "string") {
  44990. obj.alt = (0, _util.stringToPDFString)(alt);
  44991. }
  44992. const lang = node.dict.get("Lang");
  44993. if (typeof lang === "string") {
  44994. obj.lang = (0, _util.stringToPDFString)(lang);
  44995. }
  44996. for (const kid of node.kids) {
  44997. const kidElement = kid.type === StructElementType.ELEMENT ? kid.parentNode : null;
  44998. if (kidElement) {
  44999. nodeToSerializable(kidElement, obj, level + 1);
  45000. continue;
  45001. } else if (kid.type === StructElementType.PAGE_CONTENT || kid.type === StructElementType.STREAM_CONTENT) {
  45002. obj.children.push({
  45003. type: "content",
  45004. id: `p${kid.pageObjId}_mc${kid.mcid}`
  45005. });
  45006. } else if (kid.type === StructElementType.OBJECT) {
  45007. obj.children.push({
  45008. type: "object",
  45009. id: kid.refObjId
  45010. });
  45011. }
  45012. }
  45013. }
  45014. const root = Object.create(null);
  45015. root.children = [];
  45016. root.role = "Root";
  45017. for (const child of this.nodes) {
  45018. if (!child) {
  45019. continue;
  45020. }
  45021. nodeToSerializable(child, root);
  45022. }
  45023. return root;
  45024. }
  45025. }
  45026. exports.StructTreePage = StructTreePage;
  45027. /***/ }),
  45028. /* 76 */
  45029. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  45030. Object.defineProperty(exports, "__esModule", ({
  45031. value: true
  45032. }));
  45033. exports.ObjectLoader = void 0;
  45034. var _primitives = __w_pdfjs_require__(4);
  45035. var _base_stream = __w_pdfjs_require__(5);
  45036. var _core_utils = __w_pdfjs_require__(3);
  45037. var _util = __w_pdfjs_require__(2);
  45038. function mayHaveChildren(value) {
  45039. return value instanceof _primitives.Ref || value instanceof _primitives.Dict || value instanceof _base_stream.BaseStream || Array.isArray(value);
  45040. }
  45041. function addChildren(node, nodesToVisit) {
  45042. if (node instanceof _primitives.Dict) {
  45043. node = node.getRawValues();
  45044. } else if (node instanceof _base_stream.BaseStream) {
  45045. node = node.dict.getRawValues();
  45046. } else if (!Array.isArray(node)) {
  45047. return;
  45048. }
  45049. for (const rawValue of node) {
  45050. if (mayHaveChildren(rawValue)) {
  45051. nodesToVisit.push(rawValue);
  45052. }
  45053. }
  45054. }
  45055. class ObjectLoader {
  45056. constructor(dict, keys, xref) {
  45057. this.dict = dict;
  45058. this.keys = keys;
  45059. this.xref = xref;
  45060. this.refSet = null;
  45061. }
  45062. async load() {
  45063. if (this.xref.stream.isDataLoaded) {
  45064. return undefined;
  45065. }
  45066. const {
  45067. keys,
  45068. dict
  45069. } = this;
  45070. this.refSet = new _primitives.RefSet();
  45071. const nodesToVisit = [];
  45072. for (const key of keys) {
  45073. const rawValue = dict.getRaw(key);
  45074. if (rawValue !== undefined) {
  45075. nodesToVisit.push(rawValue);
  45076. }
  45077. }
  45078. return this._walk(nodesToVisit);
  45079. }
  45080. async _walk(nodesToVisit) {
  45081. const nodesToRevisit = [];
  45082. const pendingRequests = [];
  45083. while (nodesToVisit.length) {
  45084. let currentNode = nodesToVisit.pop();
  45085. if (currentNode instanceof _primitives.Ref) {
  45086. if (this.refSet.has(currentNode)) {
  45087. continue;
  45088. }
  45089. try {
  45090. this.refSet.put(currentNode);
  45091. currentNode = this.xref.fetch(currentNode);
  45092. } catch (ex) {
  45093. if (!(ex instanceof _core_utils.MissingDataException)) {
  45094. (0, _util.warn)(`ObjectLoader._walk - requesting all data: "${ex}".`);
  45095. this.refSet = null;
  45096. const {
  45097. manager
  45098. } = this.xref.stream;
  45099. return manager.requestAllChunks();
  45100. }
  45101. nodesToRevisit.push(currentNode);
  45102. pendingRequests.push({
  45103. begin: ex.begin,
  45104. end: ex.end
  45105. });
  45106. }
  45107. }
  45108. if (currentNode instanceof _base_stream.BaseStream) {
  45109. const baseStreams = currentNode.getBaseStreams();
  45110. if (baseStreams) {
  45111. let foundMissingData = false;
  45112. for (const stream of baseStreams) {
  45113. if (stream.isDataLoaded) {
  45114. continue;
  45115. }
  45116. foundMissingData = true;
  45117. pendingRequests.push({
  45118. begin: stream.start,
  45119. end: stream.end
  45120. });
  45121. }
  45122. if (foundMissingData) {
  45123. nodesToRevisit.push(currentNode);
  45124. }
  45125. }
  45126. }
  45127. addChildren(currentNode, nodesToVisit);
  45128. }
  45129. if (pendingRequests.length) {
  45130. await this.xref.stream.manager.requestRanges(pendingRequests);
  45131. for (const node of nodesToRevisit) {
  45132. if (node instanceof _primitives.Ref) {
  45133. this.refSet.remove(node);
  45134. }
  45135. }
  45136. return this._walk(nodesToRevisit);
  45137. }
  45138. this.refSet = null;
  45139. return undefined;
  45140. }
  45141. }
  45142. exports.ObjectLoader = ObjectLoader;
  45143. /***/ }),
  45144. /* 77 */
  45145. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  45146. Object.defineProperty(exports, "__esModule", ({
  45147. value: true
  45148. }));
  45149. exports.XFAFactory = void 0;
  45150. var _symbol_utils = __w_pdfjs_require__(78);
  45151. var _bind = __w_pdfjs_require__(79);
  45152. var _data = __w_pdfjs_require__(89);
  45153. var _fonts = __w_pdfjs_require__(85);
  45154. var _utils = __w_pdfjs_require__(84);
  45155. var _util = __w_pdfjs_require__(2);
  45156. var _parser = __w_pdfjs_require__(90);
  45157. var _xhtml = __w_pdfjs_require__(100);
  45158. class XFAFactory {
  45159. constructor(data) {
  45160. try {
  45161. this.root = new _parser.XFAParser().parse(XFAFactory._createDocument(data));
  45162. const binder = new _bind.Binder(this.root);
  45163. this.form = binder.bind();
  45164. this.dataHandler = new _data.DataHandler(this.root, binder.getData());
  45165. this.form[_symbol_utils.$globalData].template = this.form;
  45166. } catch (e) {
  45167. (0, _util.warn)(`XFA - an error occurred during parsing and binding: ${e}`);
  45168. }
  45169. }
  45170. isValid() {
  45171. return this.root && this.form;
  45172. }
  45173. _createPagesHelper() {
  45174. const iterator = this.form[_symbol_utils.$toPages]();
  45175. return new Promise((resolve, reject) => {
  45176. const nextIteration = () => {
  45177. try {
  45178. const value = iterator.next();
  45179. if (value.done) {
  45180. resolve(value.value);
  45181. } else {
  45182. setTimeout(nextIteration, 0);
  45183. }
  45184. } catch (e) {
  45185. reject(e);
  45186. }
  45187. };
  45188. setTimeout(nextIteration, 0);
  45189. });
  45190. }
  45191. async _createPages() {
  45192. try {
  45193. this.pages = await this._createPagesHelper();
  45194. this.dims = this.pages.children.map(c => {
  45195. const {
  45196. width,
  45197. height
  45198. } = c.attributes.style;
  45199. return [0, 0, parseInt(width), parseInt(height)];
  45200. });
  45201. } catch (e) {
  45202. (0, _util.warn)(`XFA - an error occurred during layout: ${e}`);
  45203. }
  45204. }
  45205. getBoundingBox(pageIndex) {
  45206. return this.dims[pageIndex];
  45207. }
  45208. async getNumPages() {
  45209. if (!this.pages) {
  45210. await this._createPages();
  45211. }
  45212. return this.dims.length;
  45213. }
  45214. setImages(images) {
  45215. this.form[_symbol_utils.$globalData].images = images;
  45216. }
  45217. setFonts(fonts) {
  45218. this.form[_symbol_utils.$globalData].fontFinder = new _fonts.FontFinder(fonts);
  45219. const missingFonts = [];
  45220. for (let typeface of this.form[_symbol_utils.$globalData].usedTypefaces) {
  45221. typeface = (0, _utils.stripQuotes)(typeface);
  45222. const font = this.form[_symbol_utils.$globalData].fontFinder.find(typeface);
  45223. if (!font) {
  45224. missingFonts.push(typeface);
  45225. }
  45226. }
  45227. if (missingFonts.length > 0) {
  45228. return missingFonts;
  45229. }
  45230. return null;
  45231. }
  45232. appendFonts(fonts, reallyMissingFonts) {
  45233. this.form[_symbol_utils.$globalData].fontFinder.add(fonts, reallyMissingFonts);
  45234. }
  45235. async getPages() {
  45236. if (!this.pages) {
  45237. await this._createPages();
  45238. }
  45239. const pages = this.pages;
  45240. this.pages = null;
  45241. return pages;
  45242. }
  45243. serializeData(storage) {
  45244. return this.dataHandler.serialize(storage);
  45245. }
  45246. static _createDocument(data) {
  45247. if (!data["/xdp:xdp"]) {
  45248. return data["xdp:xdp"];
  45249. }
  45250. return Object.values(data).join("");
  45251. }
  45252. static getRichTextAsHtml(rc) {
  45253. if (!rc || typeof rc !== "string") {
  45254. return null;
  45255. }
  45256. try {
  45257. let root = new _parser.XFAParser(_xhtml.XhtmlNamespace, true).parse(rc);
  45258. if (!["body", "xhtml"].includes(root[_symbol_utils.$nodeName])) {
  45259. const newRoot = _xhtml.XhtmlNamespace.body({});
  45260. newRoot[_symbol_utils.$appendChild](root);
  45261. root = newRoot;
  45262. }
  45263. const result = root[_symbol_utils.$toHTML]();
  45264. if (!result.success) {
  45265. return null;
  45266. }
  45267. const {
  45268. html
  45269. } = result;
  45270. const {
  45271. attributes
  45272. } = html;
  45273. if (attributes) {
  45274. if (attributes.class) {
  45275. attributes.class = attributes.class.filter(attr => !attr.startsWith("xfa"));
  45276. }
  45277. attributes.dir = "auto";
  45278. }
  45279. return {
  45280. html,
  45281. str: root[_symbol_utils.$text]()
  45282. };
  45283. } catch (e) {
  45284. (0, _util.warn)(`XFA - an error occurred during parsing of rich text: ${e}`);
  45285. }
  45286. return null;
  45287. }
  45288. }
  45289. exports.XFAFactory = XFAFactory;
  45290. /***/ }),
  45291. /* 78 */
  45292. /***/ ((__unused_webpack_module, exports) => {
  45293. Object.defineProperty(exports, "__esModule", ({
  45294. value: true
  45295. }));
  45296. exports.$uid = exports.$toStyle = exports.$toString = exports.$toPages = exports.$toHTML = exports.$text = exports.$tabIndex = exports.$setValue = exports.$setSetAttributes = exports.$setId = exports.$searchNode = exports.$root = exports.$resolvePrototypes = exports.$removeChild = exports.$pushPara = exports.$pushGlyphs = exports.$popPara = exports.$onText = exports.$onChildCheck = exports.$onChild = exports.$nsAttributes = exports.$nodeName = exports.$namespaceId = exports.$lastAttribute = exports.$isUsable = exports.$isTransparent = exports.$isThereMoreWidth = exports.$isSplittable = exports.$isNsAgnostic = exports.$isDescendent = exports.$isDataValue = exports.$isCDATAXml = exports.$isBindable = exports.$insertAt = exports.$indexOf = exports.$ids = exports.$hasSettableValue = exports.$globalData = exports.$getTemplateRoot = exports.$getSubformParent = exports.$getRealChildrenByNameIt = exports.$getParent = exports.$getNextPage = exports.$getExtra = exports.$getDataValue = exports.$getContainedChildren = exports.$getChildrenByNameIt = exports.$getChildrenByName = exports.$getChildrenByClass = exports.$getChildren = exports.$getAvailableSpace = exports.$getAttributes = exports.$getAttributeIt = exports.$flushHTML = exports.$finalize = exports.$extra = exports.$dump = exports.$data = exports.$content = exports.$consumed = exports.$clone = exports.$cleanup = exports.$cleanPage = exports.$clean = exports.$childrenToHTML = exports.$appendChild = exports.$addHTML = exports.$acceptWhitespace = void 0;
  45297. const $acceptWhitespace = Symbol();
  45298. exports.$acceptWhitespace = $acceptWhitespace;
  45299. const $addHTML = Symbol();
  45300. exports.$addHTML = $addHTML;
  45301. const $appendChild = Symbol();
  45302. exports.$appendChild = $appendChild;
  45303. const $childrenToHTML = Symbol();
  45304. exports.$childrenToHTML = $childrenToHTML;
  45305. const $clean = Symbol();
  45306. exports.$clean = $clean;
  45307. const $cleanPage = Symbol();
  45308. exports.$cleanPage = $cleanPage;
  45309. const $cleanup = Symbol();
  45310. exports.$cleanup = $cleanup;
  45311. const $clone = Symbol();
  45312. exports.$clone = $clone;
  45313. const $consumed = Symbol();
  45314. exports.$consumed = $consumed;
  45315. const $content = Symbol("content");
  45316. exports.$content = $content;
  45317. const $data = Symbol("data");
  45318. exports.$data = $data;
  45319. const $dump = Symbol();
  45320. exports.$dump = $dump;
  45321. const $extra = Symbol("extra");
  45322. exports.$extra = $extra;
  45323. const $finalize = Symbol();
  45324. exports.$finalize = $finalize;
  45325. const $flushHTML = Symbol();
  45326. exports.$flushHTML = $flushHTML;
  45327. const $getAttributeIt = Symbol();
  45328. exports.$getAttributeIt = $getAttributeIt;
  45329. const $getAttributes = Symbol();
  45330. exports.$getAttributes = $getAttributes;
  45331. const $getAvailableSpace = Symbol();
  45332. exports.$getAvailableSpace = $getAvailableSpace;
  45333. const $getChildrenByClass = Symbol();
  45334. exports.$getChildrenByClass = $getChildrenByClass;
  45335. const $getChildrenByName = Symbol();
  45336. exports.$getChildrenByName = $getChildrenByName;
  45337. const $getChildrenByNameIt = Symbol();
  45338. exports.$getChildrenByNameIt = $getChildrenByNameIt;
  45339. const $getDataValue = Symbol();
  45340. exports.$getDataValue = $getDataValue;
  45341. const $getExtra = Symbol();
  45342. exports.$getExtra = $getExtra;
  45343. const $getRealChildrenByNameIt = Symbol();
  45344. exports.$getRealChildrenByNameIt = $getRealChildrenByNameIt;
  45345. const $getChildren = Symbol();
  45346. exports.$getChildren = $getChildren;
  45347. const $getContainedChildren = Symbol();
  45348. exports.$getContainedChildren = $getContainedChildren;
  45349. const $getNextPage = Symbol();
  45350. exports.$getNextPage = $getNextPage;
  45351. const $getSubformParent = Symbol();
  45352. exports.$getSubformParent = $getSubformParent;
  45353. const $getParent = Symbol();
  45354. exports.$getParent = $getParent;
  45355. const $getTemplateRoot = Symbol();
  45356. exports.$getTemplateRoot = $getTemplateRoot;
  45357. const $globalData = Symbol();
  45358. exports.$globalData = $globalData;
  45359. const $hasSettableValue = Symbol();
  45360. exports.$hasSettableValue = $hasSettableValue;
  45361. const $ids = Symbol();
  45362. exports.$ids = $ids;
  45363. const $indexOf = Symbol();
  45364. exports.$indexOf = $indexOf;
  45365. const $insertAt = Symbol();
  45366. exports.$insertAt = $insertAt;
  45367. const $isCDATAXml = Symbol();
  45368. exports.$isCDATAXml = $isCDATAXml;
  45369. const $isBindable = Symbol();
  45370. exports.$isBindable = $isBindable;
  45371. const $isDataValue = Symbol();
  45372. exports.$isDataValue = $isDataValue;
  45373. const $isDescendent = Symbol();
  45374. exports.$isDescendent = $isDescendent;
  45375. const $isNsAgnostic = Symbol();
  45376. exports.$isNsAgnostic = $isNsAgnostic;
  45377. const $isSplittable = Symbol();
  45378. exports.$isSplittable = $isSplittable;
  45379. const $isThereMoreWidth = Symbol();
  45380. exports.$isThereMoreWidth = $isThereMoreWidth;
  45381. const $isTransparent = Symbol();
  45382. exports.$isTransparent = $isTransparent;
  45383. const $isUsable = Symbol();
  45384. exports.$isUsable = $isUsable;
  45385. const $lastAttribute = Symbol();
  45386. exports.$lastAttribute = $lastAttribute;
  45387. const $namespaceId = Symbol("namespaceId");
  45388. exports.$namespaceId = $namespaceId;
  45389. const $nodeName = Symbol("nodeName");
  45390. exports.$nodeName = $nodeName;
  45391. const $nsAttributes = Symbol();
  45392. exports.$nsAttributes = $nsAttributes;
  45393. const $onChild = Symbol();
  45394. exports.$onChild = $onChild;
  45395. const $onChildCheck = Symbol();
  45396. exports.$onChildCheck = $onChildCheck;
  45397. const $onText = Symbol();
  45398. exports.$onText = $onText;
  45399. const $pushGlyphs = Symbol();
  45400. exports.$pushGlyphs = $pushGlyphs;
  45401. const $popPara = Symbol();
  45402. exports.$popPara = $popPara;
  45403. const $pushPara = Symbol();
  45404. exports.$pushPara = $pushPara;
  45405. const $removeChild = Symbol();
  45406. exports.$removeChild = $removeChild;
  45407. const $root = Symbol("root");
  45408. exports.$root = $root;
  45409. const $resolvePrototypes = Symbol();
  45410. exports.$resolvePrototypes = $resolvePrototypes;
  45411. const $searchNode = Symbol();
  45412. exports.$searchNode = $searchNode;
  45413. const $setId = Symbol();
  45414. exports.$setId = $setId;
  45415. const $setSetAttributes = Symbol();
  45416. exports.$setSetAttributes = $setSetAttributes;
  45417. const $setValue = Symbol();
  45418. exports.$setValue = $setValue;
  45419. const $tabIndex = Symbol();
  45420. exports.$tabIndex = $tabIndex;
  45421. const $text = Symbol();
  45422. exports.$text = $text;
  45423. const $toPages = Symbol();
  45424. exports.$toPages = $toPages;
  45425. const $toHTML = Symbol();
  45426. exports.$toHTML = $toHTML;
  45427. const $toString = Symbol();
  45428. exports.$toString = $toString;
  45429. const $toStyle = Symbol();
  45430. exports.$toStyle = $toStyle;
  45431. const $uid = Symbol("uid");
  45432. exports.$uid = $uid;
  45433. /***/ }),
  45434. /* 79 */
  45435. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  45436. Object.defineProperty(exports, "__esModule", ({
  45437. value: true
  45438. }));
  45439. exports.Binder = void 0;
  45440. var _symbol_utils = __w_pdfjs_require__(78);
  45441. var _template = __w_pdfjs_require__(80);
  45442. var _som = __w_pdfjs_require__(88);
  45443. var _xfa_object = __w_pdfjs_require__(87);
  45444. var _namespaces = __w_pdfjs_require__(81);
  45445. var _util = __w_pdfjs_require__(2);
  45446. const NS_DATASETS = _namespaces.NamespaceIds.datasets.id;
  45447. function createText(content) {
  45448. const node = new _template.Text({});
  45449. node[_symbol_utils.$content] = content;
  45450. return node;
  45451. }
  45452. class Binder {
  45453. constructor(root) {
  45454. this.root = root;
  45455. this.datasets = root.datasets;
  45456. this.data = root.datasets?.data || new _xfa_object.XmlObject(_namespaces.NamespaceIds.datasets.id, "data");
  45457. this.emptyMerge = this.data[_symbol_utils.$getChildren]().length === 0;
  45458. this.root.form = this.form = root.template[_symbol_utils.$clone]();
  45459. }
  45460. _isConsumeData() {
  45461. return !this.emptyMerge && this._mergeMode;
  45462. }
  45463. _isMatchTemplate() {
  45464. return !this._isConsumeData();
  45465. }
  45466. bind() {
  45467. this._bindElement(this.form, this.data);
  45468. return this.form;
  45469. }
  45470. getData() {
  45471. return this.data;
  45472. }
  45473. _bindValue(formNode, data, picture) {
  45474. formNode[_symbol_utils.$data] = data;
  45475. if (formNode[_symbol_utils.$hasSettableValue]()) {
  45476. if (data[_symbol_utils.$isDataValue]()) {
  45477. const value = data[_symbol_utils.$getDataValue]();
  45478. formNode[_symbol_utils.$setValue](createText(value));
  45479. } else if (formNode instanceof _template.Field && formNode.ui?.choiceList?.open === "multiSelect") {
  45480. const value = data[_symbol_utils.$getChildren]().map(child => child[_symbol_utils.$content].trim()).join("\n");
  45481. formNode[_symbol_utils.$setValue](createText(value));
  45482. } else if (this._isConsumeData()) {
  45483. (0, _util.warn)(`XFA - Nodes haven't the same type.`);
  45484. }
  45485. } else if (!data[_symbol_utils.$isDataValue]() || this._isMatchTemplate()) {
  45486. this._bindElement(formNode, data);
  45487. } else {
  45488. (0, _util.warn)(`XFA - Nodes haven't the same type.`);
  45489. }
  45490. }
  45491. _findDataByNameToConsume(name, isValue, dataNode, global) {
  45492. if (!name) {
  45493. return null;
  45494. }
  45495. let generator, match;
  45496. for (let i = 0; i < 3; i++) {
  45497. generator = dataNode[_symbol_utils.$getRealChildrenByNameIt](name, false, true);
  45498. while (true) {
  45499. match = generator.next().value;
  45500. if (!match) {
  45501. break;
  45502. }
  45503. if (isValue === match[_symbol_utils.$isDataValue]()) {
  45504. return match;
  45505. }
  45506. }
  45507. if (dataNode[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.datasets.id && dataNode[_symbol_utils.$nodeName] === "data") {
  45508. break;
  45509. }
  45510. dataNode = dataNode[_symbol_utils.$getParent]();
  45511. }
  45512. if (!global) {
  45513. return null;
  45514. }
  45515. generator = this.data[_symbol_utils.$getRealChildrenByNameIt](name, true, false);
  45516. match = generator.next().value;
  45517. if (match) {
  45518. return match;
  45519. }
  45520. generator = this.data[_symbol_utils.$getAttributeIt](name, true);
  45521. match = generator.next().value;
  45522. if (match?.[_symbol_utils.$isDataValue]()) {
  45523. return match;
  45524. }
  45525. return null;
  45526. }
  45527. _setProperties(formNode, dataNode) {
  45528. if (!formNode.hasOwnProperty("setProperty")) {
  45529. return;
  45530. }
  45531. for (const {
  45532. ref,
  45533. target,
  45534. connection
  45535. } of formNode.setProperty.children) {
  45536. if (connection) {
  45537. continue;
  45538. }
  45539. if (!ref) {
  45540. continue;
  45541. }
  45542. const nodes = (0, _som.searchNode)(this.root, dataNode, ref, false, false);
  45543. if (!nodes) {
  45544. (0, _util.warn)(`XFA - Invalid reference: ${ref}.`);
  45545. continue;
  45546. }
  45547. const [node] = nodes;
  45548. if (!node[_symbol_utils.$isDescendent](this.data)) {
  45549. (0, _util.warn)(`XFA - Invalid node: must be a data node.`);
  45550. continue;
  45551. }
  45552. const targetNodes = (0, _som.searchNode)(this.root, formNode, target, false, false);
  45553. if (!targetNodes) {
  45554. (0, _util.warn)(`XFA - Invalid target: ${target}.`);
  45555. continue;
  45556. }
  45557. const [targetNode] = targetNodes;
  45558. if (!targetNode[_symbol_utils.$isDescendent](formNode)) {
  45559. (0, _util.warn)(`XFA - Invalid target: must be a property or subproperty.`);
  45560. continue;
  45561. }
  45562. const targetParent = targetNode[_symbol_utils.$getParent]();
  45563. if (targetNode instanceof _template.SetProperty || targetParent instanceof _template.SetProperty) {
  45564. (0, _util.warn)(`XFA - Invalid target: cannot be a setProperty or one of its properties.`);
  45565. continue;
  45566. }
  45567. if (targetNode instanceof _template.BindItems || targetParent instanceof _template.BindItems) {
  45568. (0, _util.warn)(`XFA - Invalid target: cannot be a bindItems or one of its properties.`);
  45569. continue;
  45570. }
  45571. const content = node[_symbol_utils.$text]();
  45572. const name = targetNode[_symbol_utils.$nodeName];
  45573. if (targetNode instanceof _xfa_object.XFAAttribute) {
  45574. const attrs = Object.create(null);
  45575. attrs[name] = content;
  45576. const obj = Reflect.construct(Object.getPrototypeOf(targetParent).constructor, [attrs]);
  45577. targetParent[name] = obj[name];
  45578. continue;
  45579. }
  45580. if (!targetNode.hasOwnProperty(_symbol_utils.$content)) {
  45581. (0, _util.warn)(`XFA - Invalid node to use in setProperty`);
  45582. continue;
  45583. }
  45584. targetNode[_symbol_utils.$data] = node;
  45585. targetNode[_symbol_utils.$content] = content;
  45586. targetNode[_symbol_utils.$finalize]();
  45587. }
  45588. }
  45589. _bindItems(formNode, dataNode) {
  45590. if (!formNode.hasOwnProperty("items") || !formNode.hasOwnProperty("bindItems") || formNode.bindItems.isEmpty()) {
  45591. return;
  45592. }
  45593. for (const item of formNode.items.children) {
  45594. formNode[_symbol_utils.$removeChild](item);
  45595. }
  45596. formNode.items.clear();
  45597. const labels = new _template.Items({});
  45598. const values = new _template.Items({});
  45599. formNode[_symbol_utils.$appendChild](labels);
  45600. formNode.items.push(labels);
  45601. formNode[_symbol_utils.$appendChild](values);
  45602. formNode.items.push(values);
  45603. for (const {
  45604. ref,
  45605. labelRef,
  45606. valueRef,
  45607. connection
  45608. } of formNode.bindItems.children) {
  45609. if (connection) {
  45610. continue;
  45611. }
  45612. if (!ref) {
  45613. continue;
  45614. }
  45615. const nodes = (0, _som.searchNode)(this.root, dataNode, ref, false, false);
  45616. if (!nodes) {
  45617. (0, _util.warn)(`XFA - Invalid reference: ${ref}.`);
  45618. continue;
  45619. }
  45620. for (const node of nodes) {
  45621. if (!node[_symbol_utils.$isDescendent](this.datasets)) {
  45622. (0, _util.warn)(`XFA - Invalid ref (${ref}): must be a datasets child.`);
  45623. continue;
  45624. }
  45625. const labelNodes = (0, _som.searchNode)(this.root, node, labelRef, true, false);
  45626. if (!labelNodes) {
  45627. (0, _util.warn)(`XFA - Invalid label: ${labelRef}.`);
  45628. continue;
  45629. }
  45630. const [labelNode] = labelNodes;
  45631. if (!labelNode[_symbol_utils.$isDescendent](this.datasets)) {
  45632. (0, _util.warn)(`XFA - Invalid label: must be a datasets child.`);
  45633. continue;
  45634. }
  45635. const valueNodes = (0, _som.searchNode)(this.root, node, valueRef, true, false);
  45636. if (!valueNodes) {
  45637. (0, _util.warn)(`XFA - Invalid value: ${valueRef}.`);
  45638. continue;
  45639. }
  45640. const [valueNode] = valueNodes;
  45641. if (!valueNode[_symbol_utils.$isDescendent](this.datasets)) {
  45642. (0, _util.warn)(`XFA - Invalid value: must be a datasets child.`);
  45643. continue;
  45644. }
  45645. const label = createText(labelNode[_symbol_utils.$text]());
  45646. const value = createText(valueNode[_symbol_utils.$text]());
  45647. labels[_symbol_utils.$appendChild](label);
  45648. labels.text.push(label);
  45649. values[_symbol_utils.$appendChild](value);
  45650. values.text.push(value);
  45651. }
  45652. }
  45653. }
  45654. _bindOccurrences(formNode, matches, picture) {
  45655. let baseClone;
  45656. if (matches.length > 1) {
  45657. baseClone = formNode[_symbol_utils.$clone]();
  45658. baseClone[_symbol_utils.$removeChild](baseClone.occur);
  45659. baseClone.occur = null;
  45660. }
  45661. this._bindValue(formNode, matches[0], picture);
  45662. this._setProperties(formNode, matches[0]);
  45663. this._bindItems(formNode, matches[0]);
  45664. if (matches.length === 1) {
  45665. return;
  45666. }
  45667. const parent = formNode[_symbol_utils.$getParent]();
  45668. const name = formNode[_symbol_utils.$nodeName];
  45669. const pos = parent[_symbol_utils.$indexOf](formNode);
  45670. for (let i = 1, ii = matches.length; i < ii; i++) {
  45671. const match = matches[i];
  45672. const clone = baseClone[_symbol_utils.$clone]();
  45673. parent[name].push(clone);
  45674. parent[_symbol_utils.$insertAt](pos + i, clone);
  45675. this._bindValue(clone, match, picture);
  45676. this._setProperties(clone, match);
  45677. this._bindItems(clone, match);
  45678. }
  45679. }
  45680. _createOccurrences(formNode) {
  45681. if (!this.emptyMerge) {
  45682. return;
  45683. }
  45684. const {
  45685. occur
  45686. } = formNode;
  45687. if (!occur || occur.initial <= 1) {
  45688. return;
  45689. }
  45690. const parent = formNode[_symbol_utils.$getParent]();
  45691. const name = formNode[_symbol_utils.$nodeName];
  45692. if (!(parent[name] instanceof _xfa_object.XFAObjectArray)) {
  45693. return;
  45694. }
  45695. let currentNumber;
  45696. if (formNode.name) {
  45697. currentNumber = parent[name].children.filter(e => e.name === formNode.name).length;
  45698. } else {
  45699. currentNumber = parent[name].children.length;
  45700. }
  45701. const pos = parent[_symbol_utils.$indexOf](formNode) + 1;
  45702. const ii = occur.initial - currentNumber;
  45703. if (ii) {
  45704. const nodeClone = formNode[_symbol_utils.$clone]();
  45705. nodeClone[_symbol_utils.$removeChild](nodeClone.occur);
  45706. nodeClone.occur = null;
  45707. parent[name].push(nodeClone);
  45708. parent[_symbol_utils.$insertAt](pos, nodeClone);
  45709. for (let i = 1; i < ii; i++) {
  45710. const clone = nodeClone[_symbol_utils.$clone]();
  45711. parent[name].push(clone);
  45712. parent[_symbol_utils.$insertAt](pos + i, clone);
  45713. }
  45714. }
  45715. }
  45716. _getOccurInfo(formNode) {
  45717. const {
  45718. name,
  45719. occur
  45720. } = formNode;
  45721. if (!occur || !name) {
  45722. return [1, 1];
  45723. }
  45724. const max = occur.max === -1 ? Infinity : occur.max;
  45725. return [occur.min, max];
  45726. }
  45727. _setAndBind(formNode, dataNode) {
  45728. this._setProperties(formNode, dataNode);
  45729. this._bindItems(formNode, dataNode);
  45730. this._bindElement(formNode, dataNode);
  45731. }
  45732. _bindElement(formNode, dataNode) {
  45733. const uselessNodes = [];
  45734. this._createOccurrences(formNode);
  45735. for (const child of formNode[_symbol_utils.$getChildren]()) {
  45736. if (child[_symbol_utils.$data]) {
  45737. continue;
  45738. }
  45739. if (this._mergeMode === undefined && child[_symbol_utils.$nodeName] === "subform") {
  45740. this._mergeMode = child.mergeMode === "consumeData";
  45741. const dataChildren = dataNode[_symbol_utils.$getChildren]();
  45742. if (dataChildren.length > 0) {
  45743. this._bindOccurrences(child, [dataChildren[0]], null);
  45744. } else if (this.emptyMerge) {
  45745. const nsId = dataNode[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : dataNode[_symbol_utils.$namespaceId];
  45746. const dataChild = child[_symbol_utils.$data] = new _xfa_object.XmlObject(nsId, child.name || "root");
  45747. dataNode[_symbol_utils.$appendChild](dataChild);
  45748. this._bindElement(child, dataChild);
  45749. }
  45750. continue;
  45751. }
  45752. if (!child[_symbol_utils.$isBindable]()) {
  45753. continue;
  45754. }
  45755. let global = false;
  45756. let picture = null;
  45757. let ref = null;
  45758. let match = null;
  45759. if (child.bind) {
  45760. switch (child.bind.match) {
  45761. case "none":
  45762. this._setAndBind(child, dataNode);
  45763. continue;
  45764. case "global":
  45765. global = true;
  45766. break;
  45767. case "dataRef":
  45768. if (!child.bind.ref) {
  45769. (0, _util.warn)(`XFA - ref is empty in node ${child[_symbol_utils.$nodeName]}.`);
  45770. this._setAndBind(child, dataNode);
  45771. continue;
  45772. }
  45773. ref = child.bind.ref;
  45774. break;
  45775. default:
  45776. break;
  45777. }
  45778. if (child.bind.picture) {
  45779. picture = child.bind.picture[_symbol_utils.$content];
  45780. }
  45781. }
  45782. const [min, max] = this._getOccurInfo(child);
  45783. if (ref) {
  45784. match = (0, _som.searchNode)(this.root, dataNode, ref, true, false);
  45785. if (match === null) {
  45786. match = (0, _som.createDataNode)(this.data, dataNode, ref);
  45787. if (!match) {
  45788. continue;
  45789. }
  45790. if (this._isConsumeData()) {
  45791. match[_symbol_utils.$consumed] = true;
  45792. }
  45793. this._setAndBind(child, match);
  45794. continue;
  45795. } else {
  45796. if (this._isConsumeData()) {
  45797. match = match.filter(node => !node[_symbol_utils.$consumed]);
  45798. }
  45799. if (match.length > max) {
  45800. match = match.slice(0, max);
  45801. } else if (match.length === 0) {
  45802. match = null;
  45803. }
  45804. if (match && this._isConsumeData()) {
  45805. match.forEach(node => {
  45806. node[_symbol_utils.$consumed] = true;
  45807. });
  45808. }
  45809. }
  45810. } else {
  45811. if (!child.name) {
  45812. this._setAndBind(child, dataNode);
  45813. continue;
  45814. }
  45815. if (this._isConsumeData()) {
  45816. const matches = [];
  45817. while (matches.length < max) {
  45818. const found = this._findDataByNameToConsume(child.name, child[_symbol_utils.$hasSettableValue](), dataNode, global);
  45819. if (!found) {
  45820. break;
  45821. }
  45822. found[_symbol_utils.$consumed] = true;
  45823. matches.push(found);
  45824. }
  45825. match = matches.length > 0 ? matches : null;
  45826. } else {
  45827. match = dataNode[_symbol_utils.$getRealChildrenByNameIt](child.name, false, this.emptyMerge).next().value;
  45828. if (!match) {
  45829. if (min === 0) {
  45830. uselessNodes.push(child);
  45831. continue;
  45832. }
  45833. const nsId = dataNode[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : dataNode[_symbol_utils.$namespaceId];
  45834. match = child[_symbol_utils.$data] = new _xfa_object.XmlObject(nsId, child.name);
  45835. if (this.emptyMerge) {
  45836. match[_symbol_utils.$consumed] = true;
  45837. }
  45838. dataNode[_symbol_utils.$appendChild](match);
  45839. this._setAndBind(child, match);
  45840. continue;
  45841. }
  45842. if (this.emptyMerge) {
  45843. match[_symbol_utils.$consumed] = true;
  45844. }
  45845. match = [match];
  45846. }
  45847. }
  45848. if (match) {
  45849. this._bindOccurrences(child, match, picture);
  45850. } else if (min > 0) {
  45851. this._setAndBind(child, dataNode);
  45852. } else {
  45853. uselessNodes.push(child);
  45854. }
  45855. }
  45856. uselessNodes.forEach(node => node[_symbol_utils.$getParent]()[_symbol_utils.$removeChild](node));
  45857. }
  45858. }
  45859. exports.Binder = Binder;
  45860. /***/ }),
  45861. /* 80 */
  45862. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  45863. Object.defineProperty(exports, "__esModule", ({
  45864. value: true
  45865. }));
  45866. exports.Value = exports.Text = exports.TemplateNamespace = exports.Template = exports.SetProperty = exports.Items = exports.Field = exports.BindItems = void 0;
  45867. var _symbol_utils = __w_pdfjs_require__(78);
  45868. var _namespaces = __w_pdfjs_require__(81);
  45869. var _layout = __w_pdfjs_require__(82);
  45870. var _html_utils = __w_pdfjs_require__(83);
  45871. var _xfa_object = __w_pdfjs_require__(87);
  45872. var _utils = __w_pdfjs_require__(84);
  45873. var _util = __w_pdfjs_require__(2);
  45874. var _fonts = __w_pdfjs_require__(85);
  45875. var _core_utils = __w_pdfjs_require__(3);
  45876. var _som = __w_pdfjs_require__(88);
  45877. const TEMPLATE_NS_ID = _namespaces.NamespaceIds.template.id;
  45878. const SVG_NS = "http://www.w3.org/2000/svg";
  45879. const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
  45880. const MAX_EMPTY_PAGES = 3;
  45881. const DEFAULT_TAB_INDEX = 5000;
  45882. const HEADING_PATTERN = /^H(\d+)$/;
  45883. const MIMES = new Set(["image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png", "image/apng", "image/x-png", "image/bmp", "image/x-ms-bmp", "image/tiff", "image/tif", "application/octet-stream"]);
  45884. const IMAGES_HEADERS = [[[0x42, 0x4d], "image/bmp"], [[0xff, 0xd8, 0xff], "image/jpeg"], [[0x49, 0x49, 0x2a, 0x00], "image/tiff"], [[0x4d, 0x4d, 0x00, 0x2a], "image/tiff"], [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], "image/gif"], [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], "image/png"]];
  45885. function getBorderDims(node) {
  45886. if (!node || !node.border) {
  45887. return {
  45888. w: 0,
  45889. h: 0
  45890. };
  45891. }
  45892. const borderExtra = node.border[_symbol_utils.$getExtra]();
  45893. if (!borderExtra) {
  45894. return {
  45895. w: 0,
  45896. h: 0
  45897. };
  45898. }
  45899. return {
  45900. w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
  45901. h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
  45902. };
  45903. }
  45904. function hasMargin(node) {
  45905. return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
  45906. }
  45907. function _setValue(templateNode, value) {
  45908. if (!templateNode.value) {
  45909. const nodeValue = new Value({});
  45910. templateNode[_symbol_utils.$appendChild](nodeValue);
  45911. templateNode.value = nodeValue;
  45912. }
  45913. templateNode.value[_symbol_utils.$setValue](value);
  45914. }
  45915. function* getContainedChildren(node) {
  45916. for (const child of node[_symbol_utils.$getChildren]()) {
  45917. if (child instanceof SubformSet) {
  45918. yield* child[_symbol_utils.$getContainedChildren]();
  45919. continue;
  45920. }
  45921. yield child;
  45922. }
  45923. }
  45924. function isRequired(node) {
  45925. return node.validate?.nullTest === "error";
  45926. }
  45927. function setTabIndex(node) {
  45928. while (node) {
  45929. if (!node.traversal) {
  45930. node[_symbol_utils.$tabIndex] = node[_symbol_utils.$getParent]()[_symbol_utils.$tabIndex];
  45931. return;
  45932. }
  45933. if (node[_symbol_utils.$tabIndex]) {
  45934. return;
  45935. }
  45936. let next = null;
  45937. for (const child of node.traversal[_symbol_utils.$getChildren]()) {
  45938. if (child.operation === "next") {
  45939. next = child;
  45940. break;
  45941. }
  45942. }
  45943. if (!next || !next.ref) {
  45944. node[_symbol_utils.$tabIndex] = node[_symbol_utils.$getParent]()[_symbol_utils.$tabIndex];
  45945. return;
  45946. }
  45947. const root = node[_symbol_utils.$getTemplateRoot]();
  45948. node[_symbol_utils.$tabIndex] = ++root[_symbol_utils.$tabIndex];
  45949. const ref = root[_symbol_utils.$searchNode](next.ref, node);
  45950. if (!ref) {
  45951. return;
  45952. }
  45953. node = ref[0];
  45954. }
  45955. }
  45956. function applyAssist(obj, attributes) {
  45957. const assist = obj.assist;
  45958. if (assist) {
  45959. const assistTitle = assist[_symbol_utils.$toHTML]();
  45960. if (assistTitle) {
  45961. attributes.title = assistTitle;
  45962. }
  45963. const role = assist.role;
  45964. const match = role.match(HEADING_PATTERN);
  45965. if (match) {
  45966. const ariaRole = "heading";
  45967. const ariaLevel = match[1];
  45968. attributes.role = ariaRole;
  45969. attributes["aria-level"] = ariaLevel;
  45970. }
  45971. }
  45972. if (obj.layout === "table") {
  45973. attributes.role = "table";
  45974. } else if (obj.layout === "row") {
  45975. attributes.role = "row";
  45976. } else {
  45977. const parent = obj[_symbol_utils.$getParent]();
  45978. if (parent.layout === "row") {
  45979. attributes.role = parent.assist?.role === "TH" ? "columnheader" : "cell";
  45980. }
  45981. }
  45982. }
  45983. function ariaLabel(obj) {
  45984. if (!obj.assist) {
  45985. return null;
  45986. }
  45987. const assist = obj.assist;
  45988. if (assist.speak && assist.speak[_symbol_utils.$content] !== "") {
  45989. return assist.speak[_symbol_utils.$content];
  45990. }
  45991. if (assist.toolTip) {
  45992. return assist.toolTip[_symbol_utils.$content];
  45993. }
  45994. return null;
  45995. }
  45996. function valueToHtml(value) {
  45997. return _utils.HTMLResult.success({
  45998. name: "div",
  45999. attributes: {
  46000. class: ["xfaRich"],
  46001. style: Object.create(null)
  46002. },
  46003. children: [{
  46004. name: "span",
  46005. attributes: {
  46006. style: Object.create(null)
  46007. },
  46008. value
  46009. }]
  46010. });
  46011. }
  46012. function setFirstUnsplittable(node) {
  46013. const root = node[_symbol_utils.$getTemplateRoot]();
  46014. if (root[_symbol_utils.$extra].firstUnsplittable === null) {
  46015. root[_symbol_utils.$extra].firstUnsplittable = node;
  46016. root[_symbol_utils.$extra].noLayoutFailure = true;
  46017. }
  46018. }
  46019. function unsetFirstUnsplittable(node) {
  46020. const root = node[_symbol_utils.$getTemplateRoot]();
  46021. if (root[_symbol_utils.$extra].firstUnsplittable === node) {
  46022. root[_symbol_utils.$extra].noLayoutFailure = false;
  46023. }
  46024. }
  46025. function handleBreak(node) {
  46026. if (node[_symbol_utils.$extra]) {
  46027. return false;
  46028. }
  46029. node[_symbol_utils.$extra] = Object.create(null);
  46030. if (node.targetType === "auto") {
  46031. return false;
  46032. }
  46033. const root = node[_symbol_utils.$getTemplateRoot]();
  46034. let target = null;
  46035. if (node.target) {
  46036. target = root[_symbol_utils.$searchNode](node.target, node[_symbol_utils.$getParent]());
  46037. if (!target) {
  46038. return false;
  46039. }
  46040. target = target[0];
  46041. }
  46042. const {
  46043. currentPageArea,
  46044. currentContentArea
  46045. } = root[_symbol_utils.$extra];
  46046. if (node.targetType === "pageArea") {
  46047. if (!(target instanceof PageArea)) {
  46048. target = null;
  46049. }
  46050. if (node.startNew) {
  46051. node[_symbol_utils.$extra].target = target || currentPageArea;
  46052. return true;
  46053. } else if (target && target !== currentPageArea) {
  46054. node[_symbol_utils.$extra].target = target;
  46055. return true;
  46056. }
  46057. return false;
  46058. }
  46059. if (!(target instanceof ContentArea)) {
  46060. target = null;
  46061. }
  46062. const pageArea = target && target[_symbol_utils.$getParent]();
  46063. let index;
  46064. let nextPageArea = pageArea;
  46065. if (node.startNew) {
  46066. if (target) {
  46067. const contentAreas = pageArea.contentArea.children;
  46068. const indexForCurrent = contentAreas.indexOf(currentContentArea);
  46069. const indexForTarget = contentAreas.indexOf(target);
  46070. if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
  46071. nextPageArea = null;
  46072. }
  46073. index = indexForTarget - 1;
  46074. } else {
  46075. index = currentPageArea.contentArea.children.indexOf(currentContentArea);
  46076. }
  46077. } else if (target && target !== currentContentArea) {
  46078. const contentAreas = pageArea.contentArea.children;
  46079. index = contentAreas.indexOf(target) - 1;
  46080. nextPageArea = pageArea === currentPageArea ? null : pageArea;
  46081. } else {
  46082. return false;
  46083. }
  46084. node[_symbol_utils.$extra].target = nextPageArea;
  46085. node[_symbol_utils.$extra].index = index;
  46086. return true;
  46087. }
  46088. function handleOverflow(node, extraNode, space) {
  46089. const root = node[_symbol_utils.$getTemplateRoot]();
  46090. const saved = root[_symbol_utils.$extra].noLayoutFailure;
  46091. const savedMethod = extraNode[_symbol_utils.$getSubformParent];
  46092. extraNode[_symbol_utils.$getSubformParent] = () => node;
  46093. root[_symbol_utils.$extra].noLayoutFailure = true;
  46094. const res = extraNode[_symbol_utils.$toHTML](space);
  46095. node[_symbol_utils.$addHTML](res.html, res.bbox);
  46096. root[_symbol_utils.$extra].noLayoutFailure = saved;
  46097. extraNode[_symbol_utils.$getSubformParent] = savedMethod;
  46098. }
  46099. class AppearanceFilter extends _xfa_object.StringObject {
  46100. constructor(attributes) {
  46101. super(TEMPLATE_NS_ID, "appearanceFilter");
  46102. this.id = attributes.id || "";
  46103. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  46104. this.use = attributes.use || "";
  46105. this.usehref = attributes.usehref || "";
  46106. }
  46107. }
  46108. class Arc extends _xfa_object.XFAObject {
  46109. constructor(attributes) {
  46110. super(TEMPLATE_NS_ID, "arc", true);
  46111. this.circular = (0, _utils.getInteger)({
  46112. data: attributes.circular,
  46113. defaultValue: 0,
  46114. validate: x => x === 1
  46115. });
  46116. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  46117. this.id = attributes.id || "";
  46118. this.startAngle = (0, _utils.getFloat)({
  46119. data: attributes.startAngle,
  46120. defaultValue: 0,
  46121. validate: x => true
  46122. });
  46123. this.sweepAngle = (0, _utils.getFloat)({
  46124. data: attributes.sweepAngle,
  46125. defaultValue: 360,
  46126. validate: x => true
  46127. });
  46128. this.use = attributes.use || "";
  46129. this.usehref = attributes.usehref || "";
  46130. this.edge = null;
  46131. this.fill = null;
  46132. }
  46133. [_symbol_utils.$toHTML]() {
  46134. const edge = this.edge || new Edge({});
  46135. const edgeStyle = edge[_symbol_utils.$toStyle]();
  46136. const style = Object.create(null);
  46137. if (this.fill?.presence === "visible") {
  46138. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  46139. } else {
  46140. style.fill = "transparent";
  46141. }
  46142. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  46143. style.stroke = edgeStyle.color;
  46144. let arc;
  46145. const attributes = {
  46146. xmlns: SVG_NS,
  46147. style: {
  46148. width: "100%",
  46149. height: "100%",
  46150. overflow: "visible"
  46151. }
  46152. };
  46153. if (this.sweepAngle === 360) {
  46154. arc = {
  46155. name: "ellipse",
  46156. attributes: {
  46157. xmlns: SVG_NS,
  46158. cx: "50%",
  46159. cy: "50%",
  46160. rx: "50%",
  46161. ry: "50%",
  46162. style
  46163. }
  46164. };
  46165. } else {
  46166. const startAngle = this.startAngle * Math.PI / 180;
  46167. const sweepAngle = this.sweepAngle * Math.PI / 180;
  46168. const largeArc = this.sweepAngle > 180 ? 1 : 0;
  46169. const [x1, y1, x2, y2] = [50 * (1 + Math.cos(startAngle)), 50 * (1 - Math.sin(startAngle)), 50 * (1 + Math.cos(startAngle + sweepAngle)), 50 * (1 - Math.sin(startAngle + sweepAngle))];
  46170. arc = {
  46171. name: "path",
  46172. attributes: {
  46173. xmlns: SVG_NS,
  46174. d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
  46175. vectorEffect: "non-scaling-stroke",
  46176. style
  46177. }
  46178. };
  46179. Object.assign(attributes, {
  46180. viewBox: "0 0 100 100",
  46181. preserveAspectRatio: "none"
  46182. });
  46183. }
  46184. const svg = {
  46185. name: "svg",
  46186. children: [arc],
  46187. attributes
  46188. };
  46189. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  46190. if (hasMargin(parent)) {
  46191. return _utils.HTMLResult.success({
  46192. name: "div",
  46193. attributes: {
  46194. style: {
  46195. display: "inline",
  46196. width: "100%",
  46197. height: "100%"
  46198. }
  46199. },
  46200. children: [svg]
  46201. });
  46202. }
  46203. svg.attributes.style.position = "absolute";
  46204. return _utils.HTMLResult.success(svg);
  46205. }
  46206. }
  46207. class Area extends _xfa_object.XFAObject {
  46208. constructor(attributes) {
  46209. super(TEMPLATE_NS_ID, "area", true);
  46210. this.colSpan = (0, _utils.getInteger)({
  46211. data: attributes.colSpan,
  46212. defaultValue: 1,
  46213. validate: n => n >= 1 || n === -1
  46214. });
  46215. this.id = attributes.id || "";
  46216. this.name = attributes.name || "";
  46217. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  46218. this.use = attributes.use || "";
  46219. this.usehref = attributes.usehref || "";
  46220. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  46221. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  46222. this.desc = null;
  46223. this.extras = null;
  46224. this.area = new _xfa_object.XFAObjectArray();
  46225. this.draw = new _xfa_object.XFAObjectArray();
  46226. this.exObject = new _xfa_object.XFAObjectArray();
  46227. this.exclGroup = new _xfa_object.XFAObjectArray();
  46228. this.field = new _xfa_object.XFAObjectArray();
  46229. this.subform = new _xfa_object.XFAObjectArray();
  46230. this.subformSet = new _xfa_object.XFAObjectArray();
  46231. }
  46232. *[_symbol_utils.$getContainedChildren]() {
  46233. yield* getContainedChildren(this);
  46234. }
  46235. [_symbol_utils.$isTransparent]() {
  46236. return true;
  46237. }
  46238. [_symbol_utils.$isBindable]() {
  46239. return true;
  46240. }
  46241. [_symbol_utils.$addHTML](html, bbox) {
  46242. const [x, y, w, h] = bbox;
  46243. this[_symbol_utils.$extra].width = Math.max(this[_symbol_utils.$extra].width, x + w);
  46244. this[_symbol_utils.$extra].height = Math.max(this[_symbol_utils.$extra].height, y + h);
  46245. this[_symbol_utils.$extra].children.push(html);
  46246. }
  46247. [_symbol_utils.$getAvailableSpace]() {
  46248. return this[_symbol_utils.$extra].availableSpace;
  46249. }
  46250. [_symbol_utils.$toHTML](availableSpace) {
  46251. const style = (0, _html_utils.toStyle)(this, "position");
  46252. const attributes = {
  46253. style,
  46254. id: this[_symbol_utils.$uid],
  46255. class: ["xfaArea"]
  46256. };
  46257. if ((0, _html_utils.isPrintOnly)(this)) {
  46258. attributes.class.push("xfaPrintOnly");
  46259. }
  46260. if (this.name) {
  46261. attributes.xfaName = this.name;
  46262. }
  46263. const children = [];
  46264. this[_symbol_utils.$extra] = {
  46265. children,
  46266. width: 0,
  46267. height: 0,
  46268. availableSpace
  46269. };
  46270. const result = this[_symbol_utils.$childrenToHTML]({
  46271. filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
  46272. include: true
  46273. });
  46274. if (!result.success) {
  46275. if (result.isBreak()) {
  46276. return result;
  46277. }
  46278. delete this[_symbol_utils.$extra];
  46279. return _utils.HTMLResult.FAILURE;
  46280. }
  46281. style.width = (0, _html_utils.measureToString)(this[_symbol_utils.$extra].width);
  46282. style.height = (0, _html_utils.measureToString)(this[_symbol_utils.$extra].height);
  46283. const html = {
  46284. name: "div",
  46285. attributes,
  46286. children
  46287. };
  46288. const bbox = [this.x, this.y, this[_symbol_utils.$extra].width, this[_symbol_utils.$extra].height];
  46289. delete this[_symbol_utils.$extra];
  46290. return _utils.HTMLResult.success(html, bbox);
  46291. }
  46292. }
  46293. class Assist extends _xfa_object.XFAObject {
  46294. constructor(attributes) {
  46295. super(TEMPLATE_NS_ID, "assist", true);
  46296. this.id = attributes.id || "";
  46297. this.role = attributes.role || "";
  46298. this.use = attributes.use || "";
  46299. this.usehref = attributes.usehref || "";
  46300. this.speak = null;
  46301. this.toolTip = null;
  46302. }
  46303. [_symbol_utils.$toHTML]() {
  46304. return this.toolTip?.[_symbol_utils.$content] || null;
  46305. }
  46306. }
  46307. class Barcode extends _xfa_object.XFAObject {
  46308. constructor(attributes) {
  46309. super(TEMPLATE_NS_ID, "barcode", true);
  46310. this.charEncoding = (0, _utils.getKeyword)({
  46311. data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
  46312. defaultValue: "",
  46313. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  46314. });
  46315. this.checksum = (0, _utils.getStringOption)(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);
  46316. this.dataColumnCount = (0, _utils.getInteger)({
  46317. data: attributes.dataColumnCount,
  46318. defaultValue: -1,
  46319. validate: x => x >= 0
  46320. });
  46321. this.dataLength = (0, _utils.getInteger)({
  46322. data: attributes.dataLength,
  46323. defaultValue: -1,
  46324. validate: x => x >= 0
  46325. });
  46326. this.dataPrep = (0, _utils.getStringOption)(attributes.dataPrep, ["none", "flateCompress"]);
  46327. this.dataRowCount = (0, _utils.getInteger)({
  46328. data: attributes.dataRowCount,
  46329. defaultValue: -1,
  46330. validate: x => x >= 0
  46331. });
  46332. this.endChar = attributes.endChar || "";
  46333. this.errorCorrectionLevel = (0, _utils.getInteger)({
  46334. data: attributes.errorCorrectionLevel,
  46335. defaultValue: -1,
  46336. validate: x => x >= 0 && x <= 8
  46337. });
  46338. this.id = attributes.id || "";
  46339. this.moduleHeight = (0, _utils.getMeasurement)(attributes.moduleHeight, "5mm");
  46340. this.moduleWidth = (0, _utils.getMeasurement)(attributes.moduleWidth, "0.25mm");
  46341. this.printCheckDigit = (0, _utils.getInteger)({
  46342. data: attributes.printCheckDigit,
  46343. defaultValue: 0,
  46344. validate: x => x === 1
  46345. });
  46346. this.rowColumnRatio = (0, _utils.getRatio)(attributes.rowColumnRatio);
  46347. this.startChar = attributes.startChar || "";
  46348. this.textLocation = (0, _utils.getStringOption)(attributes.textLocation, ["below", "above", "aboveEmbedded", "belowEmbedded", "none"]);
  46349. this.truncate = (0, _utils.getInteger)({
  46350. data: attributes.truncate,
  46351. defaultValue: 0,
  46352. validate: x => x === 1
  46353. });
  46354. this.type = (0, _utils.getStringOption)(attributes.type ? attributes.type.toLowerCase() : "", ["aztec", "codabar", "code2of5industrial", "code2of5interleaved", "code2of5matrix", "code2of5standard", "code3of9", "code3of9extended", "code11", "code49", "code93", "code128", "code128a", "code128b", "code128c", "code128sscc", "datamatrix", "ean8", "ean8add2", "ean8add5", "ean13", "ean13add2", "ean13add5", "ean13pwcd", "fim", "logmars", "maxicode", "msi", "pdf417", "pdf417macro", "plessey", "postauscust2", "postauscust3", "postausreplypaid", "postausstandard", "postukrm4scc", "postusdpbc", "postusimb", "postusstandard", "postus5zip", "qrcode", "rfid", "rss14", "rss14expanded", "rss14limited", "rss14stacked", "rss14stackedomni", "rss14truncated", "telepen", "ucc128", "ucc128random", "ucc128sscc", "upca", "upcaadd2", "upcaadd5", "upcapwcd", "upce", "upceadd2", "upceadd5", "upcean2", "upcean5", "upsmaxicode"]);
  46355. this.upsMode = (0, _utils.getStringOption)(attributes.upsMode, ["usCarrier", "internationalCarrier", "secureSymbol", "standardSymbol"]);
  46356. this.use = attributes.use || "";
  46357. this.usehref = attributes.usehref || "";
  46358. this.wideNarrowRatio = (0, _utils.getRatio)(attributes.wideNarrowRatio);
  46359. this.encrypt = null;
  46360. this.extras = null;
  46361. }
  46362. }
  46363. class Bind extends _xfa_object.XFAObject {
  46364. constructor(attributes) {
  46365. super(TEMPLATE_NS_ID, "bind", true);
  46366. this.match = (0, _utils.getStringOption)(attributes.match, ["once", "dataRef", "global", "none"]);
  46367. this.ref = attributes.ref || "";
  46368. this.picture = null;
  46369. }
  46370. }
  46371. class BindItems extends _xfa_object.XFAObject {
  46372. constructor(attributes) {
  46373. super(TEMPLATE_NS_ID, "bindItems");
  46374. this.connection = attributes.connection || "";
  46375. this.labelRef = attributes.labelRef || "";
  46376. this.ref = attributes.ref || "";
  46377. this.valueRef = attributes.valueRef || "";
  46378. }
  46379. }
  46380. exports.BindItems = BindItems;
  46381. class Bookend extends _xfa_object.XFAObject {
  46382. constructor(attributes) {
  46383. super(TEMPLATE_NS_ID, "bookend");
  46384. this.id = attributes.id || "";
  46385. this.leader = attributes.leader || "";
  46386. this.trailer = attributes.trailer || "";
  46387. this.use = attributes.use || "";
  46388. this.usehref = attributes.usehref || "";
  46389. }
  46390. }
  46391. class BooleanElement extends _xfa_object.Option01 {
  46392. constructor(attributes) {
  46393. super(TEMPLATE_NS_ID, "boolean");
  46394. this.id = attributes.id || "";
  46395. this.name = attributes.name || "";
  46396. this.use = attributes.use || "";
  46397. this.usehref = attributes.usehref || "";
  46398. }
  46399. [_symbol_utils.$toHTML](availableSpace) {
  46400. return valueToHtml(this[_symbol_utils.$content] === 1 ? "1" : "0");
  46401. }
  46402. }
  46403. class Border extends _xfa_object.XFAObject {
  46404. constructor(attributes) {
  46405. super(TEMPLATE_NS_ID, "border", true);
  46406. this.break = (0, _utils.getStringOption)(attributes.break, ["close", "open"]);
  46407. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  46408. this.id = attributes.id || "";
  46409. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  46410. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  46411. this.use = attributes.use || "";
  46412. this.usehref = attributes.usehref || "";
  46413. this.corner = new _xfa_object.XFAObjectArray(4);
  46414. this.edge = new _xfa_object.XFAObjectArray(4);
  46415. this.extras = null;
  46416. this.fill = null;
  46417. this.margin = null;
  46418. }
  46419. [_symbol_utils.$getExtra]() {
  46420. if (!this[_symbol_utils.$extra]) {
  46421. const edges = this.edge.children.slice();
  46422. if (edges.length < 4) {
  46423. const defaultEdge = edges.at(-1) || new Edge({});
  46424. for (let i = edges.length; i < 4; i++) {
  46425. edges.push(defaultEdge);
  46426. }
  46427. }
  46428. const widths = edges.map(edge => edge.thickness);
  46429. const insets = [0, 0, 0, 0];
  46430. if (this.margin) {
  46431. insets[0] = this.margin.topInset;
  46432. insets[1] = this.margin.rightInset;
  46433. insets[2] = this.margin.bottomInset;
  46434. insets[3] = this.margin.leftInset;
  46435. }
  46436. this[_symbol_utils.$extra] = {
  46437. widths,
  46438. insets,
  46439. edges
  46440. };
  46441. }
  46442. return this[_symbol_utils.$extra];
  46443. }
  46444. [_symbol_utils.$toStyle]() {
  46445. const {
  46446. edges
  46447. } = this[_symbol_utils.$getExtra]();
  46448. const edgeStyles = edges.map(node => {
  46449. const style = node[_symbol_utils.$toStyle]();
  46450. style.color ||= "#000000";
  46451. return style;
  46452. });
  46453. const style = Object.create(null);
  46454. if (this.margin) {
  46455. Object.assign(style, this.margin[_symbol_utils.$toStyle]());
  46456. }
  46457. if (this.fill?.presence === "visible") {
  46458. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  46459. }
  46460. if (this.corner.children.some(node => node.radius !== 0)) {
  46461. const cornerStyles = this.corner.children.map(node => node[_symbol_utils.$toStyle]());
  46462. if (cornerStyles.length === 2 || cornerStyles.length === 3) {
  46463. const last = cornerStyles.at(-1);
  46464. for (let i = cornerStyles.length; i < 4; i++) {
  46465. cornerStyles.push(last);
  46466. }
  46467. }
  46468. style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
  46469. }
  46470. switch (this.presence) {
  46471. case "invisible":
  46472. case "hidden":
  46473. style.borderStyle = "";
  46474. break;
  46475. case "inactive":
  46476. style.borderStyle = "none";
  46477. break;
  46478. default:
  46479. style.borderStyle = edgeStyles.map(s => s.style).join(" ");
  46480. break;
  46481. }
  46482. style.borderWidth = edgeStyles.map(s => s.width).join(" ");
  46483. style.borderColor = edgeStyles.map(s => s.color).join(" ");
  46484. return style;
  46485. }
  46486. }
  46487. class Break extends _xfa_object.XFAObject {
  46488. constructor(attributes) {
  46489. super(TEMPLATE_NS_ID, "break", true);
  46490. this.after = (0, _utils.getStringOption)(attributes.after, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  46491. this.afterTarget = attributes.afterTarget || "";
  46492. this.before = (0, _utils.getStringOption)(attributes.before, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  46493. this.beforeTarget = attributes.beforeTarget || "";
  46494. this.bookendLeader = attributes.bookendLeader || "";
  46495. this.bookendTrailer = attributes.bookendTrailer || "";
  46496. this.id = attributes.id || "";
  46497. this.overflowLeader = attributes.overflowLeader || "";
  46498. this.overflowTarget = attributes.overflowTarget || "";
  46499. this.overflowTrailer = attributes.overflowTrailer || "";
  46500. this.startNew = (0, _utils.getInteger)({
  46501. data: attributes.startNew,
  46502. defaultValue: 0,
  46503. validate: x => x === 1
  46504. });
  46505. this.use = attributes.use || "";
  46506. this.usehref = attributes.usehref || "";
  46507. this.extras = null;
  46508. }
  46509. }
  46510. class BreakAfter extends _xfa_object.XFAObject {
  46511. constructor(attributes) {
  46512. super(TEMPLATE_NS_ID, "breakAfter", true);
  46513. this.id = attributes.id || "";
  46514. this.leader = attributes.leader || "";
  46515. this.startNew = (0, _utils.getInteger)({
  46516. data: attributes.startNew,
  46517. defaultValue: 0,
  46518. validate: x => x === 1
  46519. });
  46520. this.target = attributes.target || "";
  46521. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  46522. this.trailer = attributes.trailer || "";
  46523. this.use = attributes.use || "";
  46524. this.usehref = attributes.usehref || "";
  46525. this.script = null;
  46526. }
  46527. }
  46528. class BreakBefore extends _xfa_object.XFAObject {
  46529. constructor(attributes) {
  46530. super(TEMPLATE_NS_ID, "breakBefore", true);
  46531. this.id = attributes.id || "";
  46532. this.leader = attributes.leader || "";
  46533. this.startNew = (0, _utils.getInteger)({
  46534. data: attributes.startNew,
  46535. defaultValue: 0,
  46536. validate: x => x === 1
  46537. });
  46538. this.target = attributes.target || "";
  46539. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  46540. this.trailer = attributes.trailer || "";
  46541. this.use = attributes.use || "";
  46542. this.usehref = attributes.usehref || "";
  46543. this.script = null;
  46544. }
  46545. [_symbol_utils.$toHTML](availableSpace) {
  46546. this[_symbol_utils.$extra] = {};
  46547. return _utils.HTMLResult.FAILURE;
  46548. }
  46549. }
  46550. class Button extends _xfa_object.XFAObject {
  46551. constructor(attributes) {
  46552. super(TEMPLATE_NS_ID, "button", true);
  46553. this.highlight = (0, _utils.getStringOption)(attributes.highlight, ["inverted", "none", "outline", "push"]);
  46554. this.id = attributes.id || "";
  46555. this.use = attributes.use || "";
  46556. this.usehref = attributes.usehref || "";
  46557. this.extras = null;
  46558. }
  46559. [_symbol_utils.$toHTML](availableSpace) {
  46560. const parent = this[_symbol_utils.$getParent]();
  46561. const grandpa = parent[_symbol_utils.$getParent]();
  46562. const htmlButton = {
  46563. name: "button",
  46564. attributes: {
  46565. id: this[_symbol_utils.$uid],
  46566. class: ["xfaButton"],
  46567. style: {}
  46568. },
  46569. children: []
  46570. };
  46571. for (const event of grandpa.event.children) {
  46572. if (event.activity !== "click" || !event.script) {
  46573. continue;
  46574. }
  46575. const jsURL = (0, _core_utils.recoverJsURL)(event.script[_symbol_utils.$content]);
  46576. if (!jsURL) {
  46577. continue;
  46578. }
  46579. const href = (0, _html_utils.fixURL)(jsURL.url);
  46580. if (!href) {
  46581. continue;
  46582. }
  46583. htmlButton.children.push({
  46584. name: "a",
  46585. attributes: {
  46586. id: "link" + this[_symbol_utils.$uid],
  46587. href,
  46588. newWindow: jsURL.newWindow,
  46589. class: ["xfaLink"],
  46590. style: {}
  46591. },
  46592. children: []
  46593. });
  46594. }
  46595. return _utils.HTMLResult.success(htmlButton);
  46596. }
  46597. }
  46598. class Calculate extends _xfa_object.XFAObject {
  46599. constructor(attributes) {
  46600. super(TEMPLATE_NS_ID, "calculate", true);
  46601. this.id = attributes.id || "";
  46602. this.override = (0, _utils.getStringOption)(attributes.override, ["disabled", "error", "ignore", "warning"]);
  46603. this.use = attributes.use || "";
  46604. this.usehref = attributes.usehref || "";
  46605. this.extras = null;
  46606. this.message = null;
  46607. this.script = null;
  46608. }
  46609. }
  46610. class Caption extends _xfa_object.XFAObject {
  46611. constructor(attributes) {
  46612. super(TEMPLATE_NS_ID, "caption", true);
  46613. this.id = attributes.id || "";
  46614. this.placement = (0, _utils.getStringOption)(attributes.placement, ["left", "bottom", "inline", "right", "top"]);
  46615. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  46616. this.reserve = Math.ceil((0, _utils.getMeasurement)(attributes.reserve));
  46617. this.use = attributes.use || "";
  46618. this.usehref = attributes.usehref || "";
  46619. this.extras = null;
  46620. this.font = null;
  46621. this.margin = null;
  46622. this.para = null;
  46623. this.value = null;
  46624. }
  46625. [_symbol_utils.$setValue](value) {
  46626. _setValue(this, value);
  46627. }
  46628. [_symbol_utils.$getExtra](availableSpace) {
  46629. if (!this[_symbol_utils.$extra]) {
  46630. let {
  46631. width,
  46632. height
  46633. } = availableSpace;
  46634. switch (this.placement) {
  46635. case "left":
  46636. case "right":
  46637. case "inline":
  46638. width = this.reserve <= 0 ? width : this.reserve;
  46639. break;
  46640. case "top":
  46641. case "bottom":
  46642. height = this.reserve <= 0 ? height : this.reserve;
  46643. break;
  46644. }
  46645. this[_symbol_utils.$extra] = (0, _html_utils.layoutNode)(this, {
  46646. width,
  46647. height
  46648. });
  46649. }
  46650. return this[_symbol_utils.$extra];
  46651. }
  46652. [_symbol_utils.$toHTML](availableSpace) {
  46653. if (!this.value) {
  46654. return _utils.HTMLResult.EMPTY;
  46655. }
  46656. this[_symbol_utils.$pushPara]();
  46657. const value = this.value[_symbol_utils.$toHTML](availableSpace).html;
  46658. if (!value) {
  46659. this[_symbol_utils.$popPara]();
  46660. return _utils.HTMLResult.EMPTY;
  46661. }
  46662. const savedReserve = this.reserve;
  46663. if (this.reserve <= 0) {
  46664. const {
  46665. w,
  46666. h
  46667. } = this[_symbol_utils.$getExtra](availableSpace);
  46668. switch (this.placement) {
  46669. case "left":
  46670. case "right":
  46671. case "inline":
  46672. this.reserve = w;
  46673. break;
  46674. case "top":
  46675. case "bottom":
  46676. this.reserve = h;
  46677. break;
  46678. }
  46679. }
  46680. const children = [];
  46681. if (typeof value === "string") {
  46682. children.push({
  46683. name: "#text",
  46684. value
  46685. });
  46686. } else {
  46687. children.push(value);
  46688. }
  46689. const style = (0, _html_utils.toStyle)(this, "font", "margin", "visibility");
  46690. switch (this.placement) {
  46691. case "left":
  46692. case "right":
  46693. if (this.reserve > 0) {
  46694. style.width = (0, _html_utils.measureToString)(this.reserve);
  46695. }
  46696. break;
  46697. case "top":
  46698. case "bottom":
  46699. if (this.reserve > 0) {
  46700. style.height = (0, _html_utils.measureToString)(this.reserve);
  46701. }
  46702. break;
  46703. }
  46704. (0, _html_utils.setPara)(this, null, value);
  46705. this[_symbol_utils.$popPara]();
  46706. this.reserve = savedReserve;
  46707. return _utils.HTMLResult.success({
  46708. name: "div",
  46709. attributes: {
  46710. style,
  46711. class: ["xfaCaption"]
  46712. },
  46713. children
  46714. });
  46715. }
  46716. }
  46717. class Certificate extends _xfa_object.StringObject {
  46718. constructor(attributes) {
  46719. super(TEMPLATE_NS_ID, "certificate");
  46720. this.id = attributes.id || "";
  46721. this.name = attributes.name || "";
  46722. this.use = attributes.use || "";
  46723. this.usehref = attributes.usehref || "";
  46724. }
  46725. }
  46726. class Certificates extends _xfa_object.XFAObject {
  46727. constructor(attributes) {
  46728. super(TEMPLATE_NS_ID, "certificates", true);
  46729. this.credentialServerPolicy = (0, _utils.getStringOption)(attributes.credentialServerPolicy, ["optional", "required"]);
  46730. this.id = attributes.id || "";
  46731. this.url = attributes.url || "";
  46732. this.urlPolicy = attributes.urlPolicy || "";
  46733. this.use = attributes.use || "";
  46734. this.usehref = attributes.usehref || "";
  46735. this.encryption = null;
  46736. this.issuers = null;
  46737. this.keyUsage = null;
  46738. this.oids = null;
  46739. this.signing = null;
  46740. this.subjectDNs = null;
  46741. }
  46742. }
  46743. class CheckButton extends _xfa_object.XFAObject {
  46744. constructor(attributes) {
  46745. super(TEMPLATE_NS_ID, "checkButton", true);
  46746. this.id = attributes.id || "";
  46747. this.mark = (0, _utils.getStringOption)(attributes.mark, ["default", "check", "circle", "cross", "diamond", "square", "star"]);
  46748. this.shape = (0, _utils.getStringOption)(attributes.shape, ["square", "round"]);
  46749. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  46750. this.use = attributes.use || "";
  46751. this.usehref = attributes.usehref || "";
  46752. this.border = null;
  46753. this.extras = null;
  46754. this.margin = null;
  46755. }
  46756. [_symbol_utils.$toHTML](availableSpace) {
  46757. const style = (0, _html_utils.toStyle)("margin");
  46758. const size = (0, _html_utils.measureToString)(this.size);
  46759. style.width = style.height = size;
  46760. let type;
  46761. let className;
  46762. let groupId;
  46763. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  46764. const items = field.items.children.length && field.items.children[0][_symbol_utils.$toHTML]().html || [];
  46765. const exportedValue = {
  46766. on: (items[0] !== undefined ? items[0] : "on").toString(),
  46767. off: (items[1] !== undefined ? items[1] : "off").toString()
  46768. };
  46769. const value = field.value?.[_symbol_utils.$text]() || "off";
  46770. const checked = value === exportedValue.on || undefined;
  46771. const container = field[_symbol_utils.$getSubformParent]();
  46772. const fieldId = field[_symbol_utils.$uid];
  46773. let dataId;
  46774. if (container instanceof ExclGroup) {
  46775. groupId = container[_symbol_utils.$uid];
  46776. type = "radio";
  46777. className = "xfaRadio";
  46778. dataId = container[_symbol_utils.$data]?.[_symbol_utils.$uid] || container[_symbol_utils.$uid];
  46779. } else {
  46780. type = "checkbox";
  46781. className = "xfaCheckbox";
  46782. dataId = field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid];
  46783. }
  46784. const input = {
  46785. name: "input",
  46786. attributes: {
  46787. class: [className],
  46788. style,
  46789. fieldId,
  46790. dataId,
  46791. type,
  46792. checked,
  46793. xfaOn: exportedValue.on,
  46794. xfaOff: exportedValue.off,
  46795. "aria-label": ariaLabel(field),
  46796. "aria-required": false
  46797. }
  46798. };
  46799. if (groupId) {
  46800. input.attributes.name = groupId;
  46801. }
  46802. if (isRequired(field)) {
  46803. input.attributes["aria-required"] = true;
  46804. input.attributes.required = true;
  46805. }
  46806. return _utils.HTMLResult.success({
  46807. name: "label",
  46808. attributes: {
  46809. class: ["xfaLabel"]
  46810. },
  46811. children: [input]
  46812. });
  46813. }
  46814. }
  46815. class ChoiceList extends _xfa_object.XFAObject {
  46816. constructor(attributes) {
  46817. super(TEMPLATE_NS_ID, "choiceList", true);
  46818. this.commitOn = (0, _utils.getStringOption)(attributes.commitOn, ["select", "exit"]);
  46819. this.id = attributes.id || "";
  46820. this.open = (0, _utils.getStringOption)(attributes.open, ["userControl", "always", "multiSelect", "onEntry"]);
  46821. this.textEntry = (0, _utils.getInteger)({
  46822. data: attributes.textEntry,
  46823. defaultValue: 0,
  46824. validate: x => x === 1
  46825. });
  46826. this.use = attributes.use || "";
  46827. this.usehref = attributes.usehref || "";
  46828. this.border = null;
  46829. this.extras = null;
  46830. this.margin = null;
  46831. }
  46832. [_symbol_utils.$toHTML](availableSpace) {
  46833. const style = (0, _html_utils.toStyle)(this, "border", "margin");
  46834. const ui = this[_symbol_utils.$getParent]();
  46835. const field = ui[_symbol_utils.$getParent]();
  46836. const fontSize = field.font?.size || 10;
  46837. const optionStyle = {
  46838. fontSize: `calc(${fontSize}px * var(--scale-factor))`
  46839. };
  46840. const children = [];
  46841. if (field.items.children.length > 0) {
  46842. const items = field.items;
  46843. let displayedIndex = 0;
  46844. let saveIndex = 0;
  46845. if (items.children.length === 2) {
  46846. displayedIndex = items.children[0].save;
  46847. saveIndex = 1 - displayedIndex;
  46848. }
  46849. const displayed = items.children[displayedIndex][_symbol_utils.$toHTML]().html;
  46850. const values = items.children[saveIndex][_symbol_utils.$toHTML]().html;
  46851. let selected = false;
  46852. const value = field.value?.[_symbol_utils.$text]() || "";
  46853. for (let i = 0, ii = displayed.length; i < ii; i++) {
  46854. const option = {
  46855. name: "option",
  46856. attributes: {
  46857. value: values[i] || displayed[i],
  46858. style: optionStyle
  46859. },
  46860. value: displayed[i]
  46861. };
  46862. if (values[i] === value) {
  46863. option.attributes.selected = selected = true;
  46864. }
  46865. children.push(option);
  46866. }
  46867. if (!selected) {
  46868. children.splice(0, 0, {
  46869. name: "option",
  46870. attributes: {
  46871. hidden: true,
  46872. selected: true
  46873. },
  46874. value: " "
  46875. });
  46876. }
  46877. }
  46878. const selectAttributes = {
  46879. class: ["xfaSelect"],
  46880. fieldId: field[_symbol_utils.$uid],
  46881. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  46882. style,
  46883. "aria-label": ariaLabel(field),
  46884. "aria-required": false
  46885. };
  46886. if (isRequired(field)) {
  46887. selectAttributes["aria-required"] = true;
  46888. selectAttributes.required = true;
  46889. }
  46890. if (this.open === "multiSelect") {
  46891. selectAttributes.multiple = true;
  46892. }
  46893. return _utils.HTMLResult.success({
  46894. name: "label",
  46895. attributes: {
  46896. class: ["xfaLabel"]
  46897. },
  46898. children: [{
  46899. name: "select",
  46900. children,
  46901. attributes: selectAttributes
  46902. }]
  46903. });
  46904. }
  46905. }
  46906. class Color extends _xfa_object.XFAObject {
  46907. constructor(attributes) {
  46908. super(TEMPLATE_NS_ID, "color", true);
  46909. this.cSpace = (0, _utils.getStringOption)(attributes.cSpace, ["SRGB"]);
  46910. this.id = attributes.id || "";
  46911. this.use = attributes.use || "";
  46912. this.usehref = attributes.usehref || "";
  46913. this.value = attributes.value ? (0, _utils.getColor)(attributes.value) : "";
  46914. this.extras = null;
  46915. }
  46916. [_symbol_utils.$hasSettableValue]() {
  46917. return false;
  46918. }
  46919. [_symbol_utils.$toStyle]() {
  46920. return this.value ? _util.Util.makeHexColor(this.value.r, this.value.g, this.value.b) : null;
  46921. }
  46922. }
  46923. class Comb extends _xfa_object.XFAObject {
  46924. constructor(attributes) {
  46925. super(TEMPLATE_NS_ID, "comb");
  46926. this.id = attributes.id || "";
  46927. this.numberOfCells = (0, _utils.getInteger)({
  46928. data: attributes.numberOfCells,
  46929. defaultValue: 0,
  46930. validate: x => x >= 0
  46931. });
  46932. this.use = attributes.use || "";
  46933. this.usehref = attributes.usehref || "";
  46934. }
  46935. }
  46936. class Connect extends _xfa_object.XFAObject {
  46937. constructor(attributes) {
  46938. super(TEMPLATE_NS_ID, "connect", true);
  46939. this.connection = attributes.connection || "";
  46940. this.id = attributes.id || "";
  46941. this.ref = attributes.ref || "";
  46942. this.usage = (0, _utils.getStringOption)(attributes.usage, ["exportAndImport", "exportOnly", "importOnly"]);
  46943. this.use = attributes.use || "";
  46944. this.usehref = attributes.usehref || "";
  46945. this.picture = null;
  46946. }
  46947. }
  46948. class ContentArea extends _xfa_object.XFAObject {
  46949. constructor(attributes) {
  46950. super(TEMPLATE_NS_ID, "contentArea", true);
  46951. this.h = (0, _utils.getMeasurement)(attributes.h);
  46952. this.id = attributes.id || "";
  46953. this.name = attributes.name || "";
  46954. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  46955. this.use = attributes.use || "";
  46956. this.usehref = attributes.usehref || "";
  46957. this.w = (0, _utils.getMeasurement)(attributes.w);
  46958. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  46959. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  46960. this.desc = null;
  46961. this.extras = null;
  46962. }
  46963. [_symbol_utils.$toHTML](availableSpace) {
  46964. const left = (0, _html_utils.measureToString)(this.x);
  46965. const top = (0, _html_utils.measureToString)(this.y);
  46966. const style = {
  46967. left,
  46968. top,
  46969. width: (0, _html_utils.measureToString)(this.w),
  46970. height: (0, _html_utils.measureToString)(this.h)
  46971. };
  46972. const classNames = ["xfaContentarea"];
  46973. if ((0, _html_utils.isPrintOnly)(this)) {
  46974. classNames.push("xfaPrintOnly");
  46975. }
  46976. return _utils.HTMLResult.success({
  46977. name: "div",
  46978. children: [],
  46979. attributes: {
  46980. style,
  46981. class: classNames,
  46982. id: this[_symbol_utils.$uid]
  46983. }
  46984. });
  46985. }
  46986. }
  46987. class Corner extends _xfa_object.XFAObject {
  46988. constructor(attributes) {
  46989. super(TEMPLATE_NS_ID, "corner", true);
  46990. this.id = attributes.id || "";
  46991. this.inverted = (0, _utils.getInteger)({
  46992. data: attributes.inverted,
  46993. defaultValue: 0,
  46994. validate: x => x === 1
  46995. });
  46996. this.join = (0, _utils.getStringOption)(attributes.join, ["square", "round"]);
  46997. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  46998. this.radius = (0, _utils.getMeasurement)(attributes.radius);
  46999. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  47000. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  47001. this.use = attributes.use || "";
  47002. this.usehref = attributes.usehref || "";
  47003. this.color = null;
  47004. this.extras = null;
  47005. }
  47006. [_symbol_utils.$toStyle]() {
  47007. const style = (0, _html_utils.toStyle)(this, "visibility");
  47008. style.radius = (0, _html_utils.measureToString)(this.join === "square" ? 0 : this.radius);
  47009. return style;
  47010. }
  47011. }
  47012. class DateElement extends _xfa_object.ContentObject {
  47013. constructor(attributes) {
  47014. super(TEMPLATE_NS_ID, "date");
  47015. this.id = attributes.id || "";
  47016. this.name = attributes.name || "";
  47017. this.use = attributes.use || "";
  47018. this.usehref = attributes.usehref || "";
  47019. }
  47020. [_symbol_utils.$finalize]() {
  47021. const date = this[_symbol_utils.$content].trim();
  47022. this[_symbol_utils.$content] = date ? new Date(date) : null;
  47023. }
  47024. [_symbol_utils.$toHTML](availableSpace) {
  47025. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  47026. }
  47027. }
  47028. class DateTime extends _xfa_object.ContentObject {
  47029. constructor(attributes) {
  47030. super(TEMPLATE_NS_ID, "dateTime");
  47031. this.id = attributes.id || "";
  47032. this.name = attributes.name || "";
  47033. this.use = attributes.use || "";
  47034. this.usehref = attributes.usehref || "";
  47035. }
  47036. [_symbol_utils.$finalize]() {
  47037. const date = this[_symbol_utils.$content].trim();
  47038. this[_symbol_utils.$content] = date ? new Date(date) : null;
  47039. }
  47040. [_symbol_utils.$toHTML](availableSpace) {
  47041. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  47042. }
  47043. }
  47044. class DateTimeEdit extends _xfa_object.XFAObject {
  47045. constructor(attributes) {
  47046. super(TEMPLATE_NS_ID, "dateTimeEdit", true);
  47047. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  47048. this.id = attributes.id || "";
  47049. this.picker = (0, _utils.getStringOption)(attributes.picker, ["host", "none"]);
  47050. this.use = attributes.use || "";
  47051. this.usehref = attributes.usehref || "";
  47052. this.border = null;
  47053. this.comb = null;
  47054. this.extras = null;
  47055. this.margin = null;
  47056. }
  47057. [_symbol_utils.$toHTML](availableSpace) {
  47058. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  47059. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  47060. const html = {
  47061. name: "input",
  47062. attributes: {
  47063. type: "text",
  47064. fieldId: field[_symbol_utils.$uid],
  47065. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  47066. class: ["xfaTextfield"],
  47067. style,
  47068. "aria-label": ariaLabel(field),
  47069. "aria-required": false
  47070. }
  47071. };
  47072. if (isRequired(field)) {
  47073. html.attributes["aria-required"] = true;
  47074. html.attributes.required = true;
  47075. }
  47076. return _utils.HTMLResult.success({
  47077. name: "label",
  47078. attributes: {
  47079. class: ["xfaLabel"]
  47080. },
  47081. children: [html]
  47082. });
  47083. }
  47084. }
  47085. class Decimal extends _xfa_object.ContentObject {
  47086. constructor(attributes) {
  47087. super(TEMPLATE_NS_ID, "decimal");
  47088. this.fracDigits = (0, _utils.getInteger)({
  47089. data: attributes.fracDigits,
  47090. defaultValue: 2,
  47091. validate: x => true
  47092. });
  47093. this.id = attributes.id || "";
  47094. this.leadDigits = (0, _utils.getInteger)({
  47095. data: attributes.leadDigits,
  47096. defaultValue: -1,
  47097. validate: x => true
  47098. });
  47099. this.name = attributes.name || "";
  47100. this.use = attributes.use || "";
  47101. this.usehref = attributes.usehref || "";
  47102. }
  47103. [_symbol_utils.$finalize]() {
  47104. const number = parseFloat(this[_symbol_utils.$content].trim());
  47105. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  47106. }
  47107. [_symbol_utils.$toHTML](availableSpace) {
  47108. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  47109. }
  47110. }
  47111. class DefaultUi extends _xfa_object.XFAObject {
  47112. constructor(attributes) {
  47113. super(TEMPLATE_NS_ID, "defaultUi", true);
  47114. this.id = attributes.id || "";
  47115. this.use = attributes.use || "";
  47116. this.usehref = attributes.usehref || "";
  47117. this.extras = null;
  47118. }
  47119. }
  47120. class Desc extends _xfa_object.XFAObject {
  47121. constructor(attributes) {
  47122. super(TEMPLATE_NS_ID, "desc", true);
  47123. this.id = attributes.id || "";
  47124. this.use = attributes.use || "";
  47125. this.usehref = attributes.usehref || "";
  47126. this.boolean = new _xfa_object.XFAObjectArray();
  47127. this.date = new _xfa_object.XFAObjectArray();
  47128. this.dateTime = new _xfa_object.XFAObjectArray();
  47129. this.decimal = new _xfa_object.XFAObjectArray();
  47130. this.exData = new _xfa_object.XFAObjectArray();
  47131. this.float = new _xfa_object.XFAObjectArray();
  47132. this.image = new _xfa_object.XFAObjectArray();
  47133. this.integer = new _xfa_object.XFAObjectArray();
  47134. this.text = new _xfa_object.XFAObjectArray();
  47135. this.time = new _xfa_object.XFAObjectArray();
  47136. }
  47137. }
  47138. class DigestMethod extends _xfa_object.OptionObject {
  47139. constructor(attributes) {
  47140. super(TEMPLATE_NS_ID, "digestMethod", ["", "SHA1", "SHA256", "SHA512", "RIPEMD160"]);
  47141. this.id = attributes.id || "";
  47142. this.use = attributes.use || "";
  47143. this.usehref = attributes.usehref || "";
  47144. }
  47145. }
  47146. class DigestMethods extends _xfa_object.XFAObject {
  47147. constructor(attributes) {
  47148. super(TEMPLATE_NS_ID, "digestMethods", true);
  47149. this.id = attributes.id || "";
  47150. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  47151. this.use = attributes.use || "";
  47152. this.usehref = attributes.usehref || "";
  47153. this.digestMethod = new _xfa_object.XFAObjectArray();
  47154. }
  47155. }
  47156. class Draw extends _xfa_object.XFAObject {
  47157. constructor(attributes) {
  47158. super(TEMPLATE_NS_ID, "draw", true);
  47159. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  47160. this.colSpan = (0, _utils.getInteger)({
  47161. data: attributes.colSpan,
  47162. defaultValue: 1,
  47163. validate: n => n >= 1 || n === -1
  47164. });
  47165. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  47166. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  47167. this.id = attributes.id || "";
  47168. this.locale = attributes.locale || "";
  47169. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  47170. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  47171. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  47172. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  47173. this.name = attributes.name || "";
  47174. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  47175. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  47176. this.rotate = (0, _utils.getInteger)({
  47177. data: attributes.rotate,
  47178. defaultValue: 0,
  47179. validate: x => x % 90 === 0
  47180. });
  47181. this.use = attributes.use || "";
  47182. this.usehref = attributes.usehref || "";
  47183. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  47184. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  47185. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  47186. this.assist = null;
  47187. this.border = null;
  47188. this.caption = null;
  47189. this.desc = null;
  47190. this.extras = null;
  47191. this.font = null;
  47192. this.keep = null;
  47193. this.margin = null;
  47194. this.para = null;
  47195. this.traversal = null;
  47196. this.ui = null;
  47197. this.value = null;
  47198. this.setProperty = new _xfa_object.XFAObjectArray();
  47199. }
  47200. [_symbol_utils.$setValue](value) {
  47201. _setValue(this, value);
  47202. }
  47203. [_symbol_utils.$toHTML](availableSpace) {
  47204. setTabIndex(this);
  47205. if (this.presence === "hidden" || this.presence === "inactive") {
  47206. return _utils.HTMLResult.EMPTY;
  47207. }
  47208. (0, _html_utils.fixDimensions)(this);
  47209. this[_symbol_utils.$pushPara]();
  47210. const savedW = this.w;
  47211. const savedH = this.h;
  47212. const {
  47213. w,
  47214. h,
  47215. isBroken
  47216. } = (0, _html_utils.layoutNode)(this, availableSpace);
  47217. if (w && this.w === "") {
  47218. if (isBroken && this[_symbol_utils.$getSubformParent]()[_symbol_utils.$isThereMoreWidth]()) {
  47219. this[_symbol_utils.$popPara]();
  47220. return _utils.HTMLResult.FAILURE;
  47221. }
  47222. this.w = w;
  47223. }
  47224. if (h && this.h === "") {
  47225. this.h = h;
  47226. }
  47227. setFirstUnsplittable(this);
  47228. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  47229. this.w = savedW;
  47230. this.h = savedH;
  47231. this[_symbol_utils.$popPara]();
  47232. return _utils.HTMLResult.FAILURE;
  47233. }
  47234. unsetFirstUnsplittable(this);
  47235. const style = (0, _html_utils.toStyle)(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "border", "margin");
  47236. (0, _html_utils.setMinMaxDimensions)(this, style);
  47237. if (style.margin) {
  47238. style.padding = style.margin;
  47239. delete style.margin;
  47240. }
  47241. const classNames = ["xfaDraw"];
  47242. if (this.font) {
  47243. classNames.push("xfaFont");
  47244. }
  47245. if ((0, _html_utils.isPrintOnly)(this)) {
  47246. classNames.push("xfaPrintOnly");
  47247. }
  47248. const attributes = {
  47249. style,
  47250. id: this[_symbol_utils.$uid],
  47251. class: classNames
  47252. };
  47253. if (this.name) {
  47254. attributes.xfaName = this.name;
  47255. }
  47256. const html = {
  47257. name: "div",
  47258. attributes,
  47259. children: []
  47260. };
  47261. applyAssist(this, attributes);
  47262. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  47263. const value = this.value ? this.value[_symbol_utils.$toHTML](availableSpace).html : null;
  47264. if (value === null) {
  47265. this.w = savedW;
  47266. this.h = savedH;
  47267. this[_symbol_utils.$popPara]();
  47268. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  47269. }
  47270. html.children.push(value);
  47271. (0, _html_utils.setPara)(this, style, value);
  47272. this.w = savedW;
  47273. this.h = savedH;
  47274. this[_symbol_utils.$popPara]();
  47275. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  47276. }
  47277. }
  47278. class Edge extends _xfa_object.XFAObject {
  47279. constructor(attributes) {
  47280. super(TEMPLATE_NS_ID, "edge", true);
  47281. this.cap = (0, _utils.getStringOption)(attributes.cap, ["square", "butt", "round"]);
  47282. this.id = attributes.id || "";
  47283. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  47284. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  47285. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  47286. this.use = attributes.use || "";
  47287. this.usehref = attributes.usehref || "";
  47288. this.color = null;
  47289. this.extras = null;
  47290. }
  47291. [_symbol_utils.$toStyle]() {
  47292. const style = (0, _html_utils.toStyle)(this, "visibility");
  47293. Object.assign(style, {
  47294. linecap: this.cap,
  47295. width: (0, _html_utils.measureToString)(this.thickness),
  47296. color: this.color ? this.color[_symbol_utils.$toStyle]() : "#000000",
  47297. style: ""
  47298. });
  47299. if (this.presence !== "visible") {
  47300. style.style = "none";
  47301. } else {
  47302. switch (this.stroke) {
  47303. case "solid":
  47304. style.style = "solid";
  47305. break;
  47306. case "dashDot":
  47307. style.style = "dashed";
  47308. break;
  47309. case "dashDotDot":
  47310. style.style = "dashed";
  47311. break;
  47312. case "dashed":
  47313. style.style = "dashed";
  47314. break;
  47315. case "dotted":
  47316. style.style = "dotted";
  47317. break;
  47318. case "embossed":
  47319. style.style = "ridge";
  47320. break;
  47321. case "etched":
  47322. style.style = "groove";
  47323. break;
  47324. case "lowered":
  47325. style.style = "inset";
  47326. break;
  47327. case "raised":
  47328. style.style = "outset";
  47329. break;
  47330. }
  47331. }
  47332. return style;
  47333. }
  47334. }
  47335. class Encoding extends _xfa_object.OptionObject {
  47336. constructor(attributes) {
  47337. super(TEMPLATE_NS_ID, "encoding", ["adbe.x509.rsa_sha1", "adbe.pkcs7.detached", "adbe.pkcs7.sha1"]);
  47338. this.id = attributes.id || "";
  47339. this.use = attributes.use || "";
  47340. this.usehref = attributes.usehref || "";
  47341. }
  47342. }
  47343. class Encodings extends _xfa_object.XFAObject {
  47344. constructor(attributes) {
  47345. super(TEMPLATE_NS_ID, "encodings", true);
  47346. this.id = attributes.id || "";
  47347. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  47348. this.use = attributes.use || "";
  47349. this.usehref = attributes.usehref || "";
  47350. this.encoding = new _xfa_object.XFAObjectArray();
  47351. }
  47352. }
  47353. class Encrypt extends _xfa_object.XFAObject {
  47354. constructor(attributes) {
  47355. super(TEMPLATE_NS_ID, "encrypt", true);
  47356. this.id = attributes.id || "";
  47357. this.use = attributes.use || "";
  47358. this.usehref = attributes.usehref || "";
  47359. this.certificate = null;
  47360. }
  47361. }
  47362. class EncryptData extends _xfa_object.XFAObject {
  47363. constructor(attributes) {
  47364. super(TEMPLATE_NS_ID, "encryptData", true);
  47365. this.id = attributes.id || "";
  47366. this.operation = (0, _utils.getStringOption)(attributes.operation, ["encrypt", "decrypt"]);
  47367. this.target = attributes.target || "";
  47368. this.use = attributes.use || "";
  47369. this.usehref = attributes.usehref || "";
  47370. this.filter = null;
  47371. this.manifest = null;
  47372. }
  47373. }
  47374. class Encryption extends _xfa_object.XFAObject {
  47375. constructor(attributes) {
  47376. super(TEMPLATE_NS_ID, "encryption", true);
  47377. this.id = attributes.id || "";
  47378. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  47379. this.use = attributes.use || "";
  47380. this.usehref = attributes.usehref || "";
  47381. this.certificate = new _xfa_object.XFAObjectArray();
  47382. }
  47383. }
  47384. class EncryptionMethod extends _xfa_object.OptionObject {
  47385. constructor(attributes) {
  47386. super(TEMPLATE_NS_ID, "encryptionMethod", ["", "AES256-CBC", "TRIPLEDES-CBC", "AES128-CBC", "AES192-CBC"]);
  47387. this.id = attributes.id || "";
  47388. this.use = attributes.use || "";
  47389. this.usehref = attributes.usehref || "";
  47390. }
  47391. }
  47392. class EncryptionMethods extends _xfa_object.XFAObject {
  47393. constructor(attributes) {
  47394. super(TEMPLATE_NS_ID, "encryptionMethods", true);
  47395. this.id = attributes.id || "";
  47396. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  47397. this.use = attributes.use || "";
  47398. this.usehref = attributes.usehref || "";
  47399. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  47400. }
  47401. }
  47402. class Event extends _xfa_object.XFAObject {
  47403. constructor(attributes) {
  47404. super(TEMPLATE_NS_ID, "event", true);
  47405. this.activity = (0, _utils.getStringOption)(attributes.activity, ["click", "change", "docClose", "docReady", "enter", "exit", "full", "indexChange", "initialize", "mouseDown", "mouseEnter", "mouseExit", "mouseUp", "postExecute", "postOpen", "postPrint", "postSave", "postSign", "postSubmit", "preExecute", "preOpen", "prePrint", "preSave", "preSign", "preSubmit", "ready", "validationState"]);
  47406. this.id = attributes.id || "";
  47407. this.listen = (0, _utils.getStringOption)(attributes.listen, ["refOnly", "refAndDescendents"]);
  47408. this.name = attributes.name || "";
  47409. this.ref = attributes.ref || "";
  47410. this.use = attributes.use || "";
  47411. this.usehref = attributes.usehref || "";
  47412. this.extras = null;
  47413. this.encryptData = null;
  47414. this.execute = null;
  47415. this.script = null;
  47416. this.signData = null;
  47417. this.submit = null;
  47418. }
  47419. }
  47420. class ExData extends _xfa_object.ContentObject {
  47421. constructor(attributes) {
  47422. super(TEMPLATE_NS_ID, "exData");
  47423. this.contentType = attributes.contentType || "";
  47424. this.href = attributes.href || "";
  47425. this.id = attributes.id || "";
  47426. this.maxLength = (0, _utils.getInteger)({
  47427. data: attributes.maxLength,
  47428. defaultValue: -1,
  47429. validate: x => x >= -1
  47430. });
  47431. this.name = attributes.name || "";
  47432. this.rid = attributes.rid || "";
  47433. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["none", "base64", "package"]);
  47434. this.use = attributes.use || "";
  47435. this.usehref = attributes.usehref || "";
  47436. }
  47437. [_symbol_utils.$isCDATAXml]() {
  47438. return this.contentType === "text/html";
  47439. }
  47440. [_symbol_utils.$onChild](child) {
  47441. if (this.contentType === "text/html" && child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  47442. this[_symbol_utils.$content] = child;
  47443. return true;
  47444. }
  47445. if (this.contentType === "text/xml") {
  47446. this[_symbol_utils.$content] = child;
  47447. return true;
  47448. }
  47449. return false;
  47450. }
  47451. [_symbol_utils.$toHTML](availableSpace) {
  47452. if (this.contentType !== "text/html" || !this[_symbol_utils.$content]) {
  47453. return _utils.HTMLResult.EMPTY;
  47454. }
  47455. return this[_symbol_utils.$content][_symbol_utils.$toHTML](availableSpace);
  47456. }
  47457. }
  47458. class ExObject extends _xfa_object.XFAObject {
  47459. constructor(attributes) {
  47460. super(TEMPLATE_NS_ID, "exObject", true);
  47461. this.archive = attributes.archive || "";
  47462. this.classId = attributes.classId || "";
  47463. this.codeBase = attributes.codeBase || "";
  47464. this.codeType = attributes.codeType || "";
  47465. this.id = attributes.id || "";
  47466. this.name = attributes.name || "";
  47467. this.use = attributes.use || "";
  47468. this.usehref = attributes.usehref || "";
  47469. this.extras = null;
  47470. this.boolean = new _xfa_object.XFAObjectArray();
  47471. this.date = new _xfa_object.XFAObjectArray();
  47472. this.dateTime = new _xfa_object.XFAObjectArray();
  47473. this.decimal = new _xfa_object.XFAObjectArray();
  47474. this.exData = new _xfa_object.XFAObjectArray();
  47475. this.exObject = new _xfa_object.XFAObjectArray();
  47476. this.float = new _xfa_object.XFAObjectArray();
  47477. this.image = new _xfa_object.XFAObjectArray();
  47478. this.integer = new _xfa_object.XFAObjectArray();
  47479. this.text = new _xfa_object.XFAObjectArray();
  47480. this.time = new _xfa_object.XFAObjectArray();
  47481. }
  47482. }
  47483. class ExclGroup extends _xfa_object.XFAObject {
  47484. constructor(attributes) {
  47485. super(TEMPLATE_NS_ID, "exclGroup", true);
  47486. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  47487. this.accessKey = attributes.accessKey || "";
  47488. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  47489. this.colSpan = (0, _utils.getInteger)({
  47490. data: attributes.colSpan,
  47491. defaultValue: 1,
  47492. validate: n => n >= 1 || n === -1
  47493. });
  47494. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  47495. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  47496. this.id = attributes.id || "";
  47497. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  47498. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  47499. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  47500. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  47501. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  47502. this.name = attributes.name || "";
  47503. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  47504. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  47505. this.use = attributes.use || "";
  47506. this.usehref = attributes.usehref || "";
  47507. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  47508. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  47509. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  47510. this.assist = null;
  47511. this.bind = null;
  47512. this.border = null;
  47513. this.calculate = null;
  47514. this.caption = null;
  47515. this.desc = null;
  47516. this.extras = null;
  47517. this.margin = null;
  47518. this.para = null;
  47519. this.traversal = null;
  47520. this.validate = null;
  47521. this.connect = new _xfa_object.XFAObjectArray();
  47522. this.event = new _xfa_object.XFAObjectArray();
  47523. this.field = new _xfa_object.XFAObjectArray();
  47524. this.setProperty = new _xfa_object.XFAObjectArray();
  47525. }
  47526. [_symbol_utils.$isBindable]() {
  47527. return true;
  47528. }
  47529. [_symbol_utils.$hasSettableValue]() {
  47530. return true;
  47531. }
  47532. [_symbol_utils.$setValue](value) {
  47533. for (const field of this.field.children) {
  47534. if (!field.value) {
  47535. const nodeValue = new Value({});
  47536. field[_symbol_utils.$appendChild](nodeValue);
  47537. field.value = nodeValue;
  47538. }
  47539. field.value[_symbol_utils.$setValue](value);
  47540. }
  47541. }
  47542. [_symbol_utils.$isThereMoreWidth]() {
  47543. return this.layout.endsWith("-tb") && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine > 0 || this[_symbol_utils.$getParent]()[_symbol_utils.$isThereMoreWidth]();
  47544. }
  47545. [_symbol_utils.$isSplittable]() {
  47546. const parent = this[_symbol_utils.$getSubformParent]();
  47547. if (!parent[_symbol_utils.$isSplittable]()) {
  47548. return false;
  47549. }
  47550. if (this[_symbol_utils.$extra]._isSplittable !== undefined) {
  47551. return this[_symbol_utils.$extra]._isSplittable;
  47552. }
  47553. if (this.layout === "position" || this.layout.includes("row")) {
  47554. this[_symbol_utils.$extra]._isSplittable = false;
  47555. return false;
  47556. }
  47557. if (parent.layout?.endsWith("-tb") && parent[_symbol_utils.$extra].numberInLine !== 0) {
  47558. return false;
  47559. }
  47560. this[_symbol_utils.$extra]._isSplittable = true;
  47561. return true;
  47562. }
  47563. [_symbol_utils.$flushHTML]() {
  47564. return (0, _layout.flushHTML)(this);
  47565. }
  47566. [_symbol_utils.$addHTML](html, bbox) {
  47567. (0, _layout.addHTML)(this, html, bbox);
  47568. }
  47569. [_symbol_utils.$getAvailableSpace]() {
  47570. return (0, _layout.getAvailableSpace)(this);
  47571. }
  47572. [_symbol_utils.$toHTML](availableSpace) {
  47573. setTabIndex(this);
  47574. if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  47575. return _utils.HTMLResult.EMPTY;
  47576. }
  47577. (0, _html_utils.fixDimensions)(this);
  47578. const children = [];
  47579. const attributes = {
  47580. id: this[_symbol_utils.$uid],
  47581. class: []
  47582. };
  47583. (0, _html_utils.setAccess)(this, attributes.class);
  47584. if (!this[_symbol_utils.$extra]) {
  47585. this[_symbol_utils.$extra] = Object.create(null);
  47586. }
  47587. Object.assign(this[_symbol_utils.$extra], {
  47588. children,
  47589. attributes,
  47590. attempt: 0,
  47591. line: null,
  47592. numberInLine: 0,
  47593. availableSpace: {
  47594. width: Math.min(this.w || Infinity, availableSpace.width),
  47595. height: Math.min(this.h || Infinity, availableSpace.height)
  47596. },
  47597. width: 0,
  47598. height: 0,
  47599. prevHeight: 0,
  47600. currentWidth: 0
  47601. });
  47602. const isSplittable = this[_symbol_utils.$isSplittable]();
  47603. if (!isSplittable) {
  47604. setFirstUnsplittable(this);
  47605. }
  47606. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  47607. return _utils.HTMLResult.FAILURE;
  47608. }
  47609. const filter = new Set(["field"]);
  47610. if (this.layout.includes("row")) {
  47611. const columnWidths = this[_symbol_utils.$getSubformParent]().columnWidths;
  47612. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  47613. this[_symbol_utils.$extra].columnWidths = columnWidths;
  47614. this[_symbol_utils.$extra].currentColumn = 0;
  47615. }
  47616. }
  47617. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  47618. const classNames = ["xfaExclgroup"];
  47619. const cl = (0, _html_utils.layoutClass)(this);
  47620. if (cl) {
  47621. classNames.push(cl);
  47622. }
  47623. if ((0, _html_utils.isPrintOnly)(this)) {
  47624. classNames.push("xfaPrintOnly");
  47625. }
  47626. attributes.style = style;
  47627. attributes.class = classNames;
  47628. if (this.name) {
  47629. attributes.xfaName = this.name;
  47630. }
  47631. this[_symbol_utils.$pushPara]();
  47632. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  47633. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  47634. for (; this[_symbol_utils.$extra].attempt < maxRun; this[_symbol_utils.$extra].attempt++) {
  47635. if (isLrTb && this[_symbol_utils.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  47636. this[_symbol_utils.$extra].numberInLine = 0;
  47637. }
  47638. const result = this[_symbol_utils.$childrenToHTML]({
  47639. filter,
  47640. include: true
  47641. });
  47642. if (result.success) {
  47643. break;
  47644. }
  47645. if (result.isBreak()) {
  47646. this[_symbol_utils.$popPara]();
  47647. return result;
  47648. }
  47649. if (isLrTb && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine === 0 && !this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  47650. this[_symbol_utils.$extra].attempt = maxRun;
  47651. break;
  47652. }
  47653. }
  47654. this[_symbol_utils.$popPara]();
  47655. if (!isSplittable) {
  47656. unsetFirstUnsplittable(this);
  47657. }
  47658. if (this[_symbol_utils.$extra].attempt === maxRun) {
  47659. if (!isSplittable) {
  47660. delete this[_symbol_utils.$extra];
  47661. }
  47662. return _utils.HTMLResult.FAILURE;
  47663. }
  47664. let marginH = 0;
  47665. let marginV = 0;
  47666. if (this.margin) {
  47667. marginH = this.margin.leftInset + this.margin.rightInset;
  47668. marginV = this.margin.topInset + this.margin.bottomInset;
  47669. }
  47670. const width = Math.max(this[_symbol_utils.$extra].width + marginH, this.w || 0);
  47671. const height = Math.max(this[_symbol_utils.$extra].height + marginV, this.h || 0);
  47672. const bbox = [this.x, this.y, width, height];
  47673. if (this.w === "") {
  47674. style.width = (0, _html_utils.measureToString)(width);
  47675. }
  47676. if (this.h === "") {
  47677. style.height = (0, _html_utils.measureToString)(height);
  47678. }
  47679. const html = {
  47680. name: "div",
  47681. attributes,
  47682. children
  47683. };
  47684. applyAssist(this, attributes);
  47685. delete this[_symbol_utils.$extra];
  47686. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  47687. }
  47688. }
  47689. class Execute extends _xfa_object.XFAObject {
  47690. constructor(attributes) {
  47691. super(TEMPLATE_NS_ID, "execute");
  47692. this.connection = attributes.connection || "";
  47693. this.executeType = (0, _utils.getStringOption)(attributes.executeType, ["import", "remerge"]);
  47694. this.id = attributes.id || "";
  47695. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  47696. this.use = attributes.use || "";
  47697. this.usehref = attributes.usehref || "";
  47698. }
  47699. }
  47700. class Extras extends _xfa_object.XFAObject {
  47701. constructor(attributes) {
  47702. super(TEMPLATE_NS_ID, "extras", true);
  47703. this.id = attributes.id || "";
  47704. this.name = attributes.name || "";
  47705. this.use = attributes.use || "";
  47706. this.usehref = attributes.usehref || "";
  47707. this.boolean = new _xfa_object.XFAObjectArray();
  47708. this.date = new _xfa_object.XFAObjectArray();
  47709. this.dateTime = new _xfa_object.XFAObjectArray();
  47710. this.decimal = new _xfa_object.XFAObjectArray();
  47711. this.exData = new _xfa_object.XFAObjectArray();
  47712. this.extras = new _xfa_object.XFAObjectArray();
  47713. this.float = new _xfa_object.XFAObjectArray();
  47714. this.image = new _xfa_object.XFAObjectArray();
  47715. this.integer = new _xfa_object.XFAObjectArray();
  47716. this.text = new _xfa_object.XFAObjectArray();
  47717. this.time = new _xfa_object.XFAObjectArray();
  47718. }
  47719. }
  47720. class Field extends _xfa_object.XFAObject {
  47721. constructor(attributes) {
  47722. super(TEMPLATE_NS_ID, "field", true);
  47723. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  47724. this.accessKey = attributes.accessKey || "";
  47725. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  47726. this.colSpan = (0, _utils.getInteger)({
  47727. data: attributes.colSpan,
  47728. defaultValue: 1,
  47729. validate: n => n >= 1 || n === -1
  47730. });
  47731. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  47732. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  47733. this.id = attributes.id || "";
  47734. this.locale = attributes.locale || "";
  47735. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  47736. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  47737. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  47738. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  47739. this.name = attributes.name || "";
  47740. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  47741. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  47742. this.rotate = (0, _utils.getInteger)({
  47743. data: attributes.rotate,
  47744. defaultValue: 0,
  47745. validate: x => x % 90 === 0
  47746. });
  47747. this.use = attributes.use || "";
  47748. this.usehref = attributes.usehref || "";
  47749. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  47750. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  47751. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  47752. this.assist = null;
  47753. this.bind = null;
  47754. this.border = null;
  47755. this.calculate = null;
  47756. this.caption = null;
  47757. this.desc = null;
  47758. this.extras = null;
  47759. this.font = null;
  47760. this.format = null;
  47761. this.items = new _xfa_object.XFAObjectArray(2);
  47762. this.keep = null;
  47763. this.margin = null;
  47764. this.para = null;
  47765. this.traversal = null;
  47766. this.ui = null;
  47767. this.validate = null;
  47768. this.value = null;
  47769. this.bindItems = new _xfa_object.XFAObjectArray();
  47770. this.connect = new _xfa_object.XFAObjectArray();
  47771. this.event = new _xfa_object.XFAObjectArray();
  47772. this.setProperty = new _xfa_object.XFAObjectArray();
  47773. }
  47774. [_symbol_utils.$isBindable]() {
  47775. return true;
  47776. }
  47777. [_symbol_utils.$setValue](value) {
  47778. _setValue(this, value);
  47779. }
  47780. [_symbol_utils.$toHTML](availableSpace) {
  47781. setTabIndex(this);
  47782. if (!this.ui) {
  47783. this.ui = new Ui({});
  47784. this.ui[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  47785. this[_symbol_utils.$appendChild](this.ui);
  47786. let node;
  47787. switch (this.items.children.length) {
  47788. case 0:
  47789. node = new TextEdit({});
  47790. this.ui.textEdit = node;
  47791. break;
  47792. case 1:
  47793. node = new CheckButton({});
  47794. this.ui.checkButton = node;
  47795. break;
  47796. case 2:
  47797. node = new ChoiceList({});
  47798. this.ui.choiceList = node;
  47799. break;
  47800. }
  47801. this.ui[_symbol_utils.$appendChild](node);
  47802. }
  47803. if (!this.ui || this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  47804. return _utils.HTMLResult.EMPTY;
  47805. }
  47806. if (this.caption) {
  47807. delete this.caption[_symbol_utils.$extra];
  47808. }
  47809. this[_symbol_utils.$pushPara]();
  47810. const caption = this.caption ? this.caption[_symbol_utils.$toHTML](availableSpace).html : null;
  47811. const savedW = this.w;
  47812. const savedH = this.h;
  47813. let marginH = 0;
  47814. let marginV = 0;
  47815. if (this.margin) {
  47816. marginH = this.margin.leftInset + this.margin.rightInset;
  47817. marginV = this.margin.topInset + this.margin.bottomInset;
  47818. }
  47819. let borderDims = null;
  47820. if (this.w === "" || this.h === "") {
  47821. let width = null;
  47822. let height = null;
  47823. let uiW = 0;
  47824. let uiH = 0;
  47825. if (this.ui.checkButton) {
  47826. uiW = uiH = this.ui.checkButton.size;
  47827. } else {
  47828. const {
  47829. w,
  47830. h
  47831. } = (0, _html_utils.layoutNode)(this, availableSpace);
  47832. if (w !== null) {
  47833. uiW = w;
  47834. uiH = h;
  47835. } else {
  47836. uiH = (0, _fonts.getMetrics)(this.font, true).lineNoGap;
  47837. }
  47838. }
  47839. borderDims = getBorderDims(this.ui[_symbol_utils.$getExtra]());
  47840. uiW += borderDims.w;
  47841. uiH += borderDims.h;
  47842. if (this.caption) {
  47843. const {
  47844. w,
  47845. h,
  47846. isBroken
  47847. } = this.caption[_symbol_utils.$getExtra](availableSpace);
  47848. if (isBroken && this[_symbol_utils.$getSubformParent]()[_symbol_utils.$isThereMoreWidth]()) {
  47849. this[_symbol_utils.$popPara]();
  47850. return _utils.HTMLResult.FAILURE;
  47851. }
  47852. width = w;
  47853. height = h;
  47854. switch (this.caption.placement) {
  47855. case "left":
  47856. case "right":
  47857. case "inline":
  47858. width += uiW;
  47859. break;
  47860. case "top":
  47861. case "bottom":
  47862. height += uiH;
  47863. break;
  47864. }
  47865. } else {
  47866. width = uiW;
  47867. height = uiH;
  47868. }
  47869. if (width && this.w === "") {
  47870. width += marginH;
  47871. this.w = Math.min(this.maxW <= 0 ? Infinity : this.maxW, this.minW + 1 < width ? width : this.minW);
  47872. }
  47873. if (height && this.h === "") {
  47874. height += marginV;
  47875. this.h = Math.min(this.maxH <= 0 ? Infinity : this.maxH, this.minH + 1 < height ? height : this.minH);
  47876. }
  47877. }
  47878. this[_symbol_utils.$popPara]();
  47879. (0, _html_utils.fixDimensions)(this);
  47880. setFirstUnsplittable(this);
  47881. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  47882. this.w = savedW;
  47883. this.h = savedH;
  47884. this[_symbol_utils.$popPara]();
  47885. return _utils.HTMLResult.FAILURE;
  47886. }
  47887. unsetFirstUnsplittable(this);
  47888. const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "margin", "hAlign");
  47889. (0, _html_utils.setMinMaxDimensions)(this, style);
  47890. const classNames = ["xfaField"];
  47891. if (this.font) {
  47892. classNames.push("xfaFont");
  47893. }
  47894. if ((0, _html_utils.isPrintOnly)(this)) {
  47895. classNames.push("xfaPrintOnly");
  47896. }
  47897. const attributes = {
  47898. style,
  47899. id: this[_symbol_utils.$uid],
  47900. class: classNames
  47901. };
  47902. if (style.margin) {
  47903. style.padding = style.margin;
  47904. delete style.margin;
  47905. }
  47906. (0, _html_utils.setAccess)(this, classNames);
  47907. if (this.name) {
  47908. attributes.xfaName = this.name;
  47909. }
  47910. const children = [];
  47911. const html = {
  47912. name: "div",
  47913. attributes,
  47914. children
  47915. };
  47916. applyAssist(this, attributes);
  47917. const borderStyle = this.border ? this.border[_symbol_utils.$toStyle]() : null;
  47918. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  47919. const ui = this.ui[_symbol_utils.$toHTML]().html;
  47920. if (!ui) {
  47921. Object.assign(style, borderStyle);
  47922. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  47923. }
  47924. if (this[_symbol_utils.$tabIndex]) {
  47925. if (ui.children?.[0]) {
  47926. ui.children[0].attributes.tabindex = this[_symbol_utils.$tabIndex];
  47927. } else {
  47928. ui.attributes.tabindex = this[_symbol_utils.$tabIndex];
  47929. }
  47930. }
  47931. if (!ui.attributes.style) {
  47932. ui.attributes.style = Object.create(null);
  47933. }
  47934. let aElement = null;
  47935. if (this.ui.button) {
  47936. if (ui.children.length === 1) {
  47937. [aElement] = ui.children.splice(0, 1);
  47938. }
  47939. Object.assign(ui.attributes.style, borderStyle);
  47940. } else {
  47941. Object.assign(style, borderStyle);
  47942. }
  47943. children.push(ui);
  47944. if (this.value) {
  47945. if (this.ui.imageEdit) {
  47946. ui.children.push(this.value[_symbol_utils.$toHTML]().html);
  47947. } else if (!this.ui.button) {
  47948. let value = "";
  47949. if (this.value.exData) {
  47950. value = this.value.exData[_symbol_utils.$text]();
  47951. } else if (this.value.text) {
  47952. value = this.value.text[_symbol_utils.$getExtra]();
  47953. } else {
  47954. const htmlValue = this.value[_symbol_utils.$toHTML]().html;
  47955. if (htmlValue !== null) {
  47956. value = htmlValue.children[0].value;
  47957. }
  47958. }
  47959. if (this.ui.textEdit && this.value.text?.maxChars) {
  47960. ui.children[0].attributes.maxLength = this.value.text.maxChars;
  47961. }
  47962. if (value) {
  47963. if (this.ui.numericEdit) {
  47964. value = parseFloat(value);
  47965. value = isNaN(value) ? "" : value.toString();
  47966. }
  47967. if (ui.children[0].name === "textarea") {
  47968. ui.children[0].attributes.textContent = value;
  47969. } else {
  47970. ui.children[0].attributes.value = value;
  47971. }
  47972. }
  47973. }
  47974. }
  47975. if (!this.ui.imageEdit && ui.children?.[0] && this.h) {
  47976. borderDims = borderDims || getBorderDims(this.ui[_symbol_utils.$getExtra]());
  47977. let captionHeight = 0;
  47978. if (this.caption && ["top", "bottom"].includes(this.caption.placement)) {
  47979. captionHeight = this.caption.reserve;
  47980. if (captionHeight <= 0) {
  47981. captionHeight = this.caption[_symbol_utils.$getExtra](availableSpace).h;
  47982. }
  47983. const inputHeight = this.h - captionHeight - marginV - borderDims.h;
  47984. ui.children[0].attributes.style.height = (0, _html_utils.measureToString)(inputHeight);
  47985. } else {
  47986. ui.children[0].attributes.style.height = "100%";
  47987. }
  47988. }
  47989. if (aElement) {
  47990. ui.children.push(aElement);
  47991. }
  47992. if (!caption) {
  47993. if (ui.attributes.class) {
  47994. ui.attributes.class.push("xfaLeft");
  47995. }
  47996. this.w = savedW;
  47997. this.h = savedH;
  47998. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  47999. }
  48000. if (this.ui.button) {
  48001. if (style.padding) {
  48002. delete style.padding;
  48003. }
  48004. if (caption.name === "div") {
  48005. caption.name = "span";
  48006. }
  48007. ui.children.push(caption);
  48008. return _utils.HTMLResult.success(html, bbox);
  48009. } else if (this.ui.checkButton) {
  48010. caption.attributes.class[0] = "xfaCaptionForCheckButton";
  48011. }
  48012. if (!ui.attributes.class) {
  48013. ui.attributes.class = [];
  48014. }
  48015. ui.children.splice(0, 0, caption);
  48016. switch (this.caption.placement) {
  48017. case "left":
  48018. ui.attributes.class.push("xfaLeft");
  48019. break;
  48020. case "right":
  48021. ui.attributes.class.push("xfaRight");
  48022. break;
  48023. case "top":
  48024. ui.attributes.class.push("xfaTop");
  48025. break;
  48026. case "bottom":
  48027. ui.attributes.class.push("xfaBottom");
  48028. break;
  48029. case "inline":
  48030. ui.attributes.class.push("xfaLeft");
  48031. break;
  48032. }
  48033. this.w = savedW;
  48034. this.h = savedH;
  48035. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  48036. }
  48037. }
  48038. exports.Field = Field;
  48039. class Fill extends _xfa_object.XFAObject {
  48040. constructor(attributes) {
  48041. super(TEMPLATE_NS_ID, "fill", true);
  48042. this.id = attributes.id || "";
  48043. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  48044. this.use = attributes.use || "";
  48045. this.usehref = attributes.usehref || "";
  48046. this.color = null;
  48047. this.extras = null;
  48048. this.linear = null;
  48049. this.pattern = null;
  48050. this.radial = null;
  48051. this.solid = null;
  48052. this.stipple = null;
  48053. }
  48054. [_symbol_utils.$toStyle]() {
  48055. const parent = this[_symbol_utils.$getParent]();
  48056. const grandpa = parent[_symbol_utils.$getParent]();
  48057. const ggrandpa = grandpa[_symbol_utils.$getParent]();
  48058. const style = Object.create(null);
  48059. let propName = "color";
  48060. let altPropName = propName;
  48061. if (parent instanceof Border) {
  48062. propName = "background-color";
  48063. altPropName = "background";
  48064. if (ggrandpa instanceof Ui) {
  48065. style.backgroundColor = "white";
  48066. }
  48067. }
  48068. if (parent instanceof Rectangle || parent instanceof Arc) {
  48069. propName = altPropName = "fill";
  48070. style.fill = "white";
  48071. }
  48072. for (const name of Object.getOwnPropertyNames(this)) {
  48073. if (name === "extras" || name === "color") {
  48074. continue;
  48075. }
  48076. const obj = this[name];
  48077. if (!(obj instanceof _xfa_object.XFAObject)) {
  48078. continue;
  48079. }
  48080. const color = obj[_symbol_utils.$toStyle](this.color);
  48081. if (color) {
  48082. style[color.startsWith("#") ? propName : altPropName] = color;
  48083. }
  48084. return style;
  48085. }
  48086. if (this.color?.value) {
  48087. const color = this.color[_symbol_utils.$toStyle]();
  48088. style[color.startsWith("#") ? propName : altPropName] = color;
  48089. }
  48090. return style;
  48091. }
  48092. }
  48093. class Filter extends _xfa_object.XFAObject {
  48094. constructor(attributes) {
  48095. super(TEMPLATE_NS_ID, "filter", true);
  48096. this.addRevocationInfo = (0, _utils.getStringOption)(attributes.addRevocationInfo, ["", "required", "optional", "none"]);
  48097. this.id = attributes.id || "";
  48098. this.name = attributes.name || "";
  48099. this.use = attributes.use || "";
  48100. this.usehref = attributes.usehref || "";
  48101. this.version = (0, _utils.getInteger)({
  48102. data: this.version,
  48103. defaultValue: 5,
  48104. validate: x => x >= 1 && x <= 5
  48105. });
  48106. this.appearanceFilter = null;
  48107. this.certificates = null;
  48108. this.digestMethods = null;
  48109. this.encodings = null;
  48110. this.encryptionMethods = null;
  48111. this.handler = null;
  48112. this.lockDocument = null;
  48113. this.mdp = null;
  48114. this.reasons = null;
  48115. this.timeStamp = null;
  48116. }
  48117. }
  48118. class Float extends _xfa_object.ContentObject {
  48119. constructor(attributes) {
  48120. super(TEMPLATE_NS_ID, "float");
  48121. this.id = attributes.id || "";
  48122. this.name = attributes.name || "";
  48123. this.use = attributes.use || "";
  48124. this.usehref = attributes.usehref || "";
  48125. }
  48126. [_symbol_utils.$finalize]() {
  48127. const number = parseFloat(this[_symbol_utils.$content].trim());
  48128. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  48129. }
  48130. [_symbol_utils.$toHTML](availableSpace) {
  48131. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  48132. }
  48133. }
  48134. class Font extends _xfa_object.XFAObject {
  48135. constructor(attributes) {
  48136. super(TEMPLATE_NS_ID, "font", true);
  48137. this.baselineShift = (0, _utils.getMeasurement)(attributes.baselineShift);
  48138. this.fontHorizontalScale = (0, _utils.getFloat)({
  48139. data: attributes.fontHorizontalScale,
  48140. defaultValue: 100,
  48141. validate: x => x >= 0
  48142. });
  48143. this.fontVerticalScale = (0, _utils.getFloat)({
  48144. data: attributes.fontVerticalScale,
  48145. defaultValue: 100,
  48146. validate: x => x >= 0
  48147. });
  48148. this.id = attributes.id || "";
  48149. this.kerningMode = (0, _utils.getStringOption)(attributes.kerningMode, ["none", "pair"]);
  48150. this.letterSpacing = (0, _utils.getMeasurement)(attributes.letterSpacing, "0");
  48151. this.lineThrough = (0, _utils.getInteger)({
  48152. data: attributes.lineThrough,
  48153. defaultValue: 0,
  48154. validate: x => x === 1 || x === 2
  48155. });
  48156. this.lineThroughPeriod = (0, _utils.getStringOption)(attributes.lineThroughPeriod, ["all", "word"]);
  48157. this.overline = (0, _utils.getInteger)({
  48158. data: attributes.overline,
  48159. defaultValue: 0,
  48160. validate: x => x === 1 || x === 2
  48161. });
  48162. this.overlinePeriod = (0, _utils.getStringOption)(attributes.overlinePeriod, ["all", "word"]);
  48163. this.posture = (0, _utils.getStringOption)(attributes.posture, ["normal", "italic"]);
  48164. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  48165. this.typeface = attributes.typeface || "Courier";
  48166. this.underline = (0, _utils.getInteger)({
  48167. data: attributes.underline,
  48168. defaultValue: 0,
  48169. validate: x => x === 1 || x === 2
  48170. });
  48171. this.underlinePeriod = (0, _utils.getStringOption)(attributes.underlinePeriod, ["all", "word"]);
  48172. this.use = attributes.use || "";
  48173. this.usehref = attributes.usehref || "";
  48174. this.weight = (0, _utils.getStringOption)(attributes.weight, ["normal", "bold"]);
  48175. this.extras = null;
  48176. this.fill = null;
  48177. }
  48178. [_symbol_utils.$clean](builder) {
  48179. super[_symbol_utils.$clean](builder);
  48180. this[_symbol_utils.$globalData].usedTypefaces.add(this.typeface);
  48181. }
  48182. [_symbol_utils.$toStyle]() {
  48183. const style = (0, _html_utils.toStyle)(this, "fill");
  48184. const color = style.color;
  48185. if (color) {
  48186. if (color === "#000000") {
  48187. delete style.color;
  48188. } else if (!color.startsWith("#")) {
  48189. style.background = color;
  48190. style.backgroundClip = "text";
  48191. style.color = "transparent";
  48192. }
  48193. }
  48194. if (this.baselineShift) {
  48195. style.verticalAlign = (0, _html_utils.measureToString)(this.baselineShift);
  48196. }
  48197. style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
  48198. style.letterSpacing = (0, _html_utils.measureToString)(this.letterSpacing);
  48199. if (this.lineThrough !== 0) {
  48200. style.textDecoration = "line-through";
  48201. if (this.lineThrough === 2) {
  48202. style.textDecorationStyle = "double";
  48203. }
  48204. }
  48205. if (this.overline !== 0) {
  48206. style.textDecoration = "overline";
  48207. if (this.overline === 2) {
  48208. style.textDecorationStyle = "double";
  48209. }
  48210. }
  48211. style.fontStyle = this.posture;
  48212. style.fontSize = (0, _html_utils.measureToString)(0.99 * this.size);
  48213. (0, _html_utils.setFontFamily)(this, this, this[_symbol_utils.$globalData].fontFinder, style);
  48214. if (this.underline !== 0) {
  48215. style.textDecoration = "underline";
  48216. if (this.underline === 2) {
  48217. style.textDecorationStyle = "double";
  48218. }
  48219. }
  48220. style.fontWeight = this.weight;
  48221. return style;
  48222. }
  48223. }
  48224. class Format extends _xfa_object.XFAObject {
  48225. constructor(attributes) {
  48226. super(TEMPLATE_NS_ID, "format", true);
  48227. this.id = attributes.id || "";
  48228. this.use = attributes.use || "";
  48229. this.usehref = attributes.usehref || "";
  48230. this.extras = null;
  48231. this.picture = null;
  48232. }
  48233. }
  48234. class Handler extends _xfa_object.StringObject {
  48235. constructor(attributes) {
  48236. super(TEMPLATE_NS_ID, "handler");
  48237. this.id = attributes.id || "";
  48238. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  48239. this.use = attributes.use || "";
  48240. this.usehref = attributes.usehref || "";
  48241. }
  48242. }
  48243. class Hyphenation extends _xfa_object.XFAObject {
  48244. constructor(attributes) {
  48245. super(TEMPLATE_NS_ID, "hyphenation");
  48246. this.excludeAllCaps = (0, _utils.getInteger)({
  48247. data: attributes.excludeAllCaps,
  48248. defaultValue: 0,
  48249. validate: x => x === 1
  48250. });
  48251. this.excludeInitialCap = (0, _utils.getInteger)({
  48252. data: attributes.excludeInitialCap,
  48253. defaultValue: 0,
  48254. validate: x => x === 1
  48255. });
  48256. this.hyphenate = (0, _utils.getInteger)({
  48257. data: attributes.hyphenate,
  48258. defaultValue: 0,
  48259. validate: x => x === 1
  48260. });
  48261. this.id = attributes.id || "";
  48262. this.pushCharacterCount = (0, _utils.getInteger)({
  48263. data: attributes.pushCharacterCount,
  48264. defaultValue: 3,
  48265. validate: x => x >= 0
  48266. });
  48267. this.remainCharacterCount = (0, _utils.getInteger)({
  48268. data: attributes.remainCharacterCount,
  48269. defaultValue: 3,
  48270. validate: x => x >= 0
  48271. });
  48272. this.use = attributes.use || "";
  48273. this.usehref = attributes.usehref || "";
  48274. this.wordCharacterCount = (0, _utils.getInteger)({
  48275. data: attributes.wordCharacterCount,
  48276. defaultValue: 7,
  48277. validate: x => x >= 0
  48278. });
  48279. }
  48280. }
  48281. class Image extends _xfa_object.StringObject {
  48282. constructor(attributes) {
  48283. super(TEMPLATE_NS_ID, "image");
  48284. this.aspect = (0, _utils.getStringOption)(attributes.aspect, ["fit", "actual", "height", "none", "width"]);
  48285. this.contentType = attributes.contentType || "";
  48286. this.href = attributes.href || "";
  48287. this.id = attributes.id || "";
  48288. this.name = attributes.name || "";
  48289. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["base64", "none", "package"]);
  48290. this.use = attributes.use || "";
  48291. this.usehref = attributes.usehref || "";
  48292. }
  48293. [_symbol_utils.$toHTML]() {
  48294. if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
  48295. return _utils.HTMLResult.EMPTY;
  48296. }
  48297. let buffer = this[_symbol_utils.$globalData].images && this[_symbol_utils.$globalData].images.get(this.href);
  48298. if (!buffer && (this.href || !this[_symbol_utils.$content])) {
  48299. return _utils.HTMLResult.EMPTY;
  48300. }
  48301. if (!buffer && this.transferEncoding === "base64") {
  48302. buffer = (0, _util.stringToBytes)(atob(this[_symbol_utils.$content]));
  48303. }
  48304. if (!buffer) {
  48305. return _utils.HTMLResult.EMPTY;
  48306. }
  48307. if (!this.contentType) {
  48308. for (const [header, type] of IMAGES_HEADERS) {
  48309. if (buffer.length > header.length && header.every((x, i) => x === buffer[i])) {
  48310. this.contentType = type;
  48311. break;
  48312. }
  48313. }
  48314. if (!this.contentType) {
  48315. return _utils.HTMLResult.EMPTY;
  48316. }
  48317. }
  48318. const blob = new Blob([buffer], {
  48319. type: this.contentType
  48320. });
  48321. let style;
  48322. switch (this.aspect) {
  48323. case "fit":
  48324. case "actual":
  48325. break;
  48326. case "height":
  48327. style = {
  48328. height: "100%",
  48329. objectFit: "fill"
  48330. };
  48331. break;
  48332. case "none":
  48333. style = {
  48334. width: "100%",
  48335. height: "100%",
  48336. objectFit: "fill"
  48337. };
  48338. break;
  48339. case "width":
  48340. style = {
  48341. width: "100%",
  48342. objectFit: "fill"
  48343. };
  48344. break;
  48345. }
  48346. const parent = this[_symbol_utils.$getParent]();
  48347. return _utils.HTMLResult.success({
  48348. name: "img",
  48349. attributes: {
  48350. class: ["xfaImage"],
  48351. style,
  48352. src: URL.createObjectURL(blob),
  48353. alt: parent ? ariaLabel(parent[_symbol_utils.$getParent]()) : null
  48354. }
  48355. });
  48356. }
  48357. }
  48358. class ImageEdit extends _xfa_object.XFAObject {
  48359. constructor(attributes) {
  48360. super(TEMPLATE_NS_ID, "imageEdit", true);
  48361. this.data = (0, _utils.getStringOption)(attributes.data, ["link", "embed"]);
  48362. this.id = attributes.id || "";
  48363. this.use = attributes.use || "";
  48364. this.usehref = attributes.usehref || "";
  48365. this.border = null;
  48366. this.extras = null;
  48367. this.margin = null;
  48368. }
  48369. [_symbol_utils.$toHTML](availableSpace) {
  48370. if (this.data === "embed") {
  48371. return _utils.HTMLResult.success({
  48372. name: "div",
  48373. children: [],
  48374. attributes: {}
  48375. });
  48376. }
  48377. return _utils.HTMLResult.EMPTY;
  48378. }
  48379. }
  48380. class Integer extends _xfa_object.ContentObject {
  48381. constructor(attributes) {
  48382. super(TEMPLATE_NS_ID, "integer");
  48383. this.id = attributes.id || "";
  48384. this.name = attributes.name || "";
  48385. this.use = attributes.use || "";
  48386. this.usehref = attributes.usehref || "";
  48387. }
  48388. [_symbol_utils.$finalize]() {
  48389. const number = parseInt(this[_symbol_utils.$content].trim(), 10);
  48390. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  48391. }
  48392. [_symbol_utils.$toHTML](availableSpace) {
  48393. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  48394. }
  48395. }
  48396. class Issuers extends _xfa_object.XFAObject {
  48397. constructor(attributes) {
  48398. super(TEMPLATE_NS_ID, "issuers", true);
  48399. this.id = attributes.id || "";
  48400. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  48401. this.use = attributes.use || "";
  48402. this.usehref = attributes.usehref || "";
  48403. this.certificate = new _xfa_object.XFAObjectArray();
  48404. }
  48405. }
  48406. class Items extends _xfa_object.XFAObject {
  48407. constructor(attributes) {
  48408. super(TEMPLATE_NS_ID, "items", true);
  48409. this.id = attributes.id || "";
  48410. this.name = attributes.name || "";
  48411. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  48412. this.ref = attributes.ref || "";
  48413. this.save = (0, _utils.getInteger)({
  48414. data: attributes.save,
  48415. defaultValue: 0,
  48416. validate: x => x === 1
  48417. });
  48418. this.use = attributes.use || "";
  48419. this.usehref = attributes.usehref || "";
  48420. this.boolean = new _xfa_object.XFAObjectArray();
  48421. this.date = new _xfa_object.XFAObjectArray();
  48422. this.dateTime = new _xfa_object.XFAObjectArray();
  48423. this.decimal = new _xfa_object.XFAObjectArray();
  48424. this.exData = new _xfa_object.XFAObjectArray();
  48425. this.float = new _xfa_object.XFAObjectArray();
  48426. this.image = new _xfa_object.XFAObjectArray();
  48427. this.integer = new _xfa_object.XFAObjectArray();
  48428. this.text = new _xfa_object.XFAObjectArray();
  48429. this.time = new _xfa_object.XFAObjectArray();
  48430. }
  48431. [_symbol_utils.$toHTML]() {
  48432. const output = [];
  48433. for (const child of this[_symbol_utils.$getChildren]()) {
  48434. output.push(child[_symbol_utils.$text]());
  48435. }
  48436. return _utils.HTMLResult.success(output);
  48437. }
  48438. }
  48439. exports.Items = Items;
  48440. class Keep extends _xfa_object.XFAObject {
  48441. constructor(attributes) {
  48442. super(TEMPLATE_NS_ID, "keep", true);
  48443. this.id = attributes.id || "";
  48444. const options = ["none", "contentArea", "pageArea"];
  48445. this.intact = (0, _utils.getStringOption)(attributes.intact, options);
  48446. this.next = (0, _utils.getStringOption)(attributes.next, options);
  48447. this.previous = (0, _utils.getStringOption)(attributes.previous, options);
  48448. this.use = attributes.use || "";
  48449. this.usehref = attributes.usehref || "";
  48450. this.extras = null;
  48451. }
  48452. }
  48453. class KeyUsage extends _xfa_object.XFAObject {
  48454. constructor(attributes) {
  48455. super(TEMPLATE_NS_ID, "keyUsage");
  48456. const options = ["", "yes", "no"];
  48457. this.crlSign = (0, _utils.getStringOption)(attributes.crlSign, options);
  48458. this.dataEncipherment = (0, _utils.getStringOption)(attributes.dataEncipherment, options);
  48459. this.decipherOnly = (0, _utils.getStringOption)(attributes.decipherOnly, options);
  48460. this.digitalSignature = (0, _utils.getStringOption)(attributes.digitalSignature, options);
  48461. this.encipherOnly = (0, _utils.getStringOption)(attributes.encipherOnly, options);
  48462. this.id = attributes.id || "";
  48463. this.keyAgreement = (0, _utils.getStringOption)(attributes.keyAgreement, options);
  48464. this.keyCertSign = (0, _utils.getStringOption)(attributes.keyCertSign, options);
  48465. this.keyEncipherment = (0, _utils.getStringOption)(attributes.keyEncipherment, options);
  48466. this.nonRepudiation = (0, _utils.getStringOption)(attributes.nonRepudiation, options);
  48467. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  48468. this.use = attributes.use || "";
  48469. this.usehref = attributes.usehref || "";
  48470. }
  48471. }
  48472. class Line extends _xfa_object.XFAObject {
  48473. constructor(attributes) {
  48474. super(TEMPLATE_NS_ID, "line", true);
  48475. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  48476. this.id = attributes.id || "";
  48477. this.slope = (0, _utils.getStringOption)(attributes.slope, ["\\", "/"]);
  48478. this.use = attributes.use || "";
  48479. this.usehref = attributes.usehref || "";
  48480. this.edge = null;
  48481. }
  48482. [_symbol_utils.$toHTML]() {
  48483. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  48484. const edge = this.edge || new Edge({});
  48485. const edgeStyle = edge[_symbol_utils.$toStyle]();
  48486. const style = Object.create(null);
  48487. const thickness = edge.presence === "visible" ? edge.thickness : 0;
  48488. style.strokeWidth = (0, _html_utils.measureToString)(thickness);
  48489. style.stroke = edgeStyle.color;
  48490. let x1, y1, x2, y2;
  48491. let width = "100%";
  48492. let height = "100%";
  48493. if (parent.w <= thickness) {
  48494. [x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
  48495. width = style.strokeWidth;
  48496. } else if (parent.h <= thickness) {
  48497. [x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
  48498. height = style.strokeWidth;
  48499. } else if (this.slope === "\\") {
  48500. [x1, y1, x2, y2] = [0, 0, "100%", "100%"];
  48501. } else {
  48502. [x1, y1, x2, y2] = [0, "100%", "100%", 0];
  48503. }
  48504. const line = {
  48505. name: "line",
  48506. attributes: {
  48507. xmlns: SVG_NS,
  48508. x1,
  48509. y1,
  48510. x2,
  48511. y2,
  48512. style
  48513. }
  48514. };
  48515. const svg = {
  48516. name: "svg",
  48517. children: [line],
  48518. attributes: {
  48519. xmlns: SVG_NS,
  48520. width,
  48521. height,
  48522. style: {
  48523. overflow: "visible"
  48524. }
  48525. }
  48526. };
  48527. if (hasMargin(parent)) {
  48528. return _utils.HTMLResult.success({
  48529. name: "div",
  48530. attributes: {
  48531. style: {
  48532. display: "inline",
  48533. width: "100%",
  48534. height: "100%"
  48535. }
  48536. },
  48537. children: [svg]
  48538. });
  48539. }
  48540. svg.attributes.style.position = "absolute";
  48541. return _utils.HTMLResult.success(svg);
  48542. }
  48543. }
  48544. class Linear extends _xfa_object.XFAObject {
  48545. constructor(attributes) {
  48546. super(TEMPLATE_NS_ID, "linear", true);
  48547. this.id = attributes.id || "";
  48548. this.type = (0, _utils.getStringOption)(attributes.type, ["toRight", "toBottom", "toLeft", "toTop"]);
  48549. this.use = attributes.use || "";
  48550. this.usehref = attributes.usehref || "";
  48551. this.color = null;
  48552. this.extras = null;
  48553. }
  48554. [_symbol_utils.$toStyle](startColor) {
  48555. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  48556. const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
  48557. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  48558. return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
  48559. }
  48560. }
  48561. class LockDocument extends _xfa_object.ContentObject {
  48562. constructor(attributes) {
  48563. super(TEMPLATE_NS_ID, "lockDocument");
  48564. this.id = attributes.id || "";
  48565. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  48566. this.use = attributes.use || "";
  48567. this.usehref = attributes.usehref || "";
  48568. }
  48569. [_symbol_utils.$finalize]() {
  48570. this[_symbol_utils.$content] = (0, _utils.getStringOption)(this[_symbol_utils.$content], ["auto", "0", "1"]);
  48571. }
  48572. }
  48573. class Manifest extends _xfa_object.XFAObject {
  48574. constructor(attributes) {
  48575. super(TEMPLATE_NS_ID, "manifest", true);
  48576. this.action = (0, _utils.getStringOption)(attributes.action, ["include", "all", "exclude"]);
  48577. this.id = attributes.id || "";
  48578. this.name = attributes.name || "";
  48579. this.use = attributes.use || "";
  48580. this.usehref = attributes.usehref || "";
  48581. this.extras = null;
  48582. this.ref = new _xfa_object.XFAObjectArray();
  48583. }
  48584. }
  48585. class Margin extends _xfa_object.XFAObject {
  48586. constructor(attributes) {
  48587. super(TEMPLATE_NS_ID, "margin", true);
  48588. this.bottomInset = (0, _utils.getMeasurement)(attributes.bottomInset, "0");
  48589. this.id = attributes.id || "";
  48590. this.leftInset = (0, _utils.getMeasurement)(attributes.leftInset, "0");
  48591. this.rightInset = (0, _utils.getMeasurement)(attributes.rightInset, "0");
  48592. this.topInset = (0, _utils.getMeasurement)(attributes.topInset, "0");
  48593. this.use = attributes.use || "";
  48594. this.usehref = attributes.usehref || "";
  48595. this.extras = null;
  48596. }
  48597. [_symbol_utils.$toStyle]() {
  48598. return {
  48599. margin: (0, _html_utils.measureToString)(this.topInset) + " " + (0, _html_utils.measureToString)(this.rightInset) + " " + (0, _html_utils.measureToString)(this.bottomInset) + " " + (0, _html_utils.measureToString)(this.leftInset)
  48600. };
  48601. }
  48602. }
  48603. class Mdp extends _xfa_object.XFAObject {
  48604. constructor(attributes) {
  48605. super(TEMPLATE_NS_ID, "mdp");
  48606. this.id = attributes.id || "";
  48607. this.permissions = (0, _utils.getInteger)({
  48608. data: attributes.permissions,
  48609. defaultValue: 2,
  48610. validate: x => x === 1 || x === 3
  48611. });
  48612. this.signatureType = (0, _utils.getStringOption)(attributes.signatureType, ["filler", "author"]);
  48613. this.use = attributes.use || "";
  48614. this.usehref = attributes.usehref || "";
  48615. }
  48616. }
  48617. class Medium extends _xfa_object.XFAObject {
  48618. constructor(attributes) {
  48619. super(TEMPLATE_NS_ID, "medium");
  48620. this.id = attributes.id || "";
  48621. this.imagingBBox = (0, _utils.getBBox)(attributes.imagingBBox);
  48622. this.long = (0, _utils.getMeasurement)(attributes.long);
  48623. this.orientation = (0, _utils.getStringOption)(attributes.orientation, ["portrait", "landscape"]);
  48624. this.short = (0, _utils.getMeasurement)(attributes.short);
  48625. this.stock = attributes.stock || "";
  48626. this.trayIn = (0, _utils.getStringOption)(attributes.trayIn, ["auto", "delegate", "pageFront"]);
  48627. this.trayOut = (0, _utils.getStringOption)(attributes.trayOut, ["auto", "delegate"]);
  48628. this.use = attributes.use || "";
  48629. this.usehref = attributes.usehref || "";
  48630. }
  48631. }
  48632. class Message extends _xfa_object.XFAObject {
  48633. constructor(attributes) {
  48634. super(TEMPLATE_NS_ID, "message", true);
  48635. this.id = attributes.id || "";
  48636. this.use = attributes.use || "";
  48637. this.usehref = attributes.usehref || "";
  48638. this.text = new _xfa_object.XFAObjectArray();
  48639. }
  48640. }
  48641. class NumericEdit extends _xfa_object.XFAObject {
  48642. constructor(attributes) {
  48643. super(TEMPLATE_NS_ID, "numericEdit", true);
  48644. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  48645. this.id = attributes.id || "";
  48646. this.use = attributes.use || "";
  48647. this.usehref = attributes.usehref || "";
  48648. this.border = null;
  48649. this.comb = null;
  48650. this.extras = null;
  48651. this.margin = null;
  48652. }
  48653. [_symbol_utils.$toHTML](availableSpace) {
  48654. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  48655. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  48656. const html = {
  48657. name: "input",
  48658. attributes: {
  48659. type: "text",
  48660. fieldId: field[_symbol_utils.$uid],
  48661. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  48662. class: ["xfaTextfield"],
  48663. style,
  48664. "aria-label": ariaLabel(field),
  48665. "aria-required": false
  48666. }
  48667. };
  48668. if (isRequired(field)) {
  48669. html.attributes["aria-required"] = true;
  48670. html.attributes.required = true;
  48671. }
  48672. return _utils.HTMLResult.success({
  48673. name: "label",
  48674. attributes: {
  48675. class: ["xfaLabel"]
  48676. },
  48677. children: [html]
  48678. });
  48679. }
  48680. }
  48681. class Occur extends _xfa_object.XFAObject {
  48682. constructor(attributes) {
  48683. super(TEMPLATE_NS_ID, "occur", true);
  48684. this.id = attributes.id || "";
  48685. this.initial = attributes.initial !== "" ? (0, _utils.getInteger)({
  48686. data: attributes.initial,
  48687. defaultValue: "",
  48688. validate: x => true
  48689. }) : "";
  48690. this.max = attributes.max !== "" ? (0, _utils.getInteger)({
  48691. data: attributes.max,
  48692. defaultValue: 1,
  48693. validate: x => true
  48694. }) : "";
  48695. this.min = attributes.min !== "" ? (0, _utils.getInteger)({
  48696. data: attributes.min,
  48697. defaultValue: 1,
  48698. validate: x => true
  48699. }) : "";
  48700. this.use = attributes.use || "";
  48701. this.usehref = attributes.usehref || "";
  48702. this.extras = null;
  48703. }
  48704. [_symbol_utils.$clean]() {
  48705. const parent = this[_symbol_utils.$getParent]();
  48706. const originalMin = this.min;
  48707. if (this.min === "") {
  48708. this.min = parent instanceof PageArea || parent instanceof PageSet ? 0 : 1;
  48709. }
  48710. if (this.max === "") {
  48711. if (originalMin === "") {
  48712. this.max = parent instanceof PageArea || parent instanceof PageSet ? -1 : 1;
  48713. } else {
  48714. this.max = this.min;
  48715. }
  48716. }
  48717. if (this.max !== -1 && this.max < this.min) {
  48718. this.max = this.min;
  48719. }
  48720. if (this.initial === "") {
  48721. this.initial = parent instanceof Template ? 1 : this.min;
  48722. }
  48723. }
  48724. }
  48725. class Oid extends _xfa_object.StringObject {
  48726. constructor(attributes) {
  48727. super(TEMPLATE_NS_ID, "oid");
  48728. this.id = attributes.id || "";
  48729. this.name = attributes.name || "";
  48730. this.use = attributes.use || "";
  48731. this.usehref = attributes.usehref || "";
  48732. }
  48733. }
  48734. class Oids extends _xfa_object.XFAObject {
  48735. constructor(attributes) {
  48736. super(TEMPLATE_NS_ID, "oids", true);
  48737. this.id = attributes.id || "";
  48738. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  48739. this.use = attributes.use || "";
  48740. this.usehref = attributes.usehref || "";
  48741. this.oid = new _xfa_object.XFAObjectArray();
  48742. }
  48743. }
  48744. class Overflow extends _xfa_object.XFAObject {
  48745. constructor(attributes) {
  48746. super(TEMPLATE_NS_ID, "overflow");
  48747. this.id = attributes.id || "";
  48748. this.leader = attributes.leader || "";
  48749. this.target = attributes.target || "";
  48750. this.trailer = attributes.trailer || "";
  48751. this.use = attributes.use || "";
  48752. this.usehref = attributes.usehref || "";
  48753. }
  48754. [_symbol_utils.$getExtra]() {
  48755. if (!this[_symbol_utils.$extra]) {
  48756. const parent = this[_symbol_utils.$getParent]();
  48757. const root = this[_symbol_utils.$getTemplateRoot]();
  48758. const target = root[_symbol_utils.$searchNode](this.target, parent);
  48759. const leader = root[_symbol_utils.$searchNode](this.leader, parent);
  48760. const trailer = root[_symbol_utils.$searchNode](this.trailer, parent);
  48761. this[_symbol_utils.$extra] = {
  48762. target: target?.[0] || null,
  48763. leader: leader?.[0] || null,
  48764. trailer: trailer?.[0] || null,
  48765. addLeader: false,
  48766. addTrailer: false
  48767. };
  48768. }
  48769. return this[_symbol_utils.$extra];
  48770. }
  48771. }
  48772. class PageArea extends _xfa_object.XFAObject {
  48773. constructor(attributes) {
  48774. super(TEMPLATE_NS_ID, "pageArea", true);
  48775. this.blankOrNotBlank = (0, _utils.getStringOption)(attributes.blankOrNotBlank, ["any", "blank", "notBlank"]);
  48776. this.id = attributes.id || "";
  48777. this.initialNumber = (0, _utils.getInteger)({
  48778. data: attributes.initialNumber,
  48779. defaultValue: 1,
  48780. validate: x => true
  48781. });
  48782. this.name = attributes.name || "";
  48783. this.numbered = (0, _utils.getInteger)({
  48784. data: attributes.numbered,
  48785. defaultValue: 1,
  48786. validate: x => true
  48787. });
  48788. this.oddOrEven = (0, _utils.getStringOption)(attributes.oddOrEven, ["any", "even", "odd"]);
  48789. this.pagePosition = (0, _utils.getStringOption)(attributes.pagePosition, ["any", "first", "last", "only", "rest"]);
  48790. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  48791. this.use = attributes.use || "";
  48792. this.usehref = attributes.usehref || "";
  48793. this.desc = null;
  48794. this.extras = null;
  48795. this.medium = null;
  48796. this.occur = null;
  48797. this.area = new _xfa_object.XFAObjectArray();
  48798. this.contentArea = new _xfa_object.XFAObjectArray();
  48799. this.draw = new _xfa_object.XFAObjectArray();
  48800. this.exclGroup = new _xfa_object.XFAObjectArray();
  48801. this.field = new _xfa_object.XFAObjectArray();
  48802. this.subform = new _xfa_object.XFAObjectArray();
  48803. }
  48804. [_symbol_utils.$isUsable]() {
  48805. if (!this[_symbol_utils.$extra]) {
  48806. this[_symbol_utils.$extra] = {
  48807. numberOfUse: 0
  48808. };
  48809. return true;
  48810. }
  48811. return !this.occur || this.occur.max === -1 || this[_symbol_utils.$extra].numberOfUse < this.occur.max;
  48812. }
  48813. [_symbol_utils.$cleanPage]() {
  48814. delete this[_symbol_utils.$extra];
  48815. }
  48816. [_symbol_utils.$getNextPage]() {
  48817. if (!this[_symbol_utils.$extra]) {
  48818. this[_symbol_utils.$extra] = {
  48819. numberOfUse: 0
  48820. };
  48821. }
  48822. const parent = this[_symbol_utils.$getParent]();
  48823. if (parent.relation === "orderedOccurrence") {
  48824. if (this[_symbol_utils.$isUsable]()) {
  48825. this[_symbol_utils.$extra].numberOfUse += 1;
  48826. return this;
  48827. }
  48828. }
  48829. return parent[_symbol_utils.$getNextPage]();
  48830. }
  48831. [_symbol_utils.$getAvailableSpace]() {
  48832. return this[_symbol_utils.$extra].space || {
  48833. width: 0,
  48834. height: 0
  48835. };
  48836. }
  48837. [_symbol_utils.$toHTML]() {
  48838. if (!this[_symbol_utils.$extra]) {
  48839. this[_symbol_utils.$extra] = {
  48840. numberOfUse: 1
  48841. };
  48842. }
  48843. const children = [];
  48844. this[_symbol_utils.$extra].children = children;
  48845. const style = Object.create(null);
  48846. if (this.medium && this.medium.short && this.medium.long) {
  48847. style.width = (0, _html_utils.measureToString)(this.medium.short);
  48848. style.height = (0, _html_utils.measureToString)(this.medium.long);
  48849. this[_symbol_utils.$extra].space = {
  48850. width: this.medium.short,
  48851. height: this.medium.long
  48852. };
  48853. if (this.medium.orientation === "landscape") {
  48854. const x = style.width;
  48855. style.width = style.height;
  48856. style.height = x;
  48857. this[_symbol_utils.$extra].space = {
  48858. width: this.medium.long,
  48859. height: this.medium.short
  48860. };
  48861. }
  48862. } else {
  48863. (0, _util.warn)("XFA - No medium specified in pageArea: please file a bug.");
  48864. }
  48865. this[_symbol_utils.$childrenToHTML]({
  48866. filter: new Set(["area", "draw", "field", "subform"]),
  48867. include: true
  48868. });
  48869. this[_symbol_utils.$childrenToHTML]({
  48870. filter: new Set(["contentArea"]),
  48871. include: true
  48872. });
  48873. return _utils.HTMLResult.success({
  48874. name: "div",
  48875. children,
  48876. attributes: {
  48877. class: ["xfaPage"],
  48878. id: this[_symbol_utils.$uid],
  48879. style,
  48880. xfaName: this.name
  48881. }
  48882. });
  48883. }
  48884. }
  48885. class PageSet extends _xfa_object.XFAObject {
  48886. constructor(attributes) {
  48887. super(TEMPLATE_NS_ID, "pageSet", true);
  48888. this.duplexImposition = (0, _utils.getStringOption)(attributes.duplexImposition, ["longEdge", "shortEdge"]);
  48889. this.id = attributes.id || "";
  48890. this.name = attributes.name || "";
  48891. this.relation = (0, _utils.getStringOption)(attributes.relation, ["orderedOccurrence", "duplexPaginated", "simplexPaginated"]);
  48892. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  48893. this.use = attributes.use || "";
  48894. this.usehref = attributes.usehref || "";
  48895. this.extras = null;
  48896. this.occur = null;
  48897. this.pageArea = new _xfa_object.XFAObjectArray();
  48898. this.pageSet = new _xfa_object.XFAObjectArray();
  48899. }
  48900. [_symbol_utils.$cleanPage]() {
  48901. for (const page of this.pageArea.children) {
  48902. page[_symbol_utils.$cleanPage]();
  48903. }
  48904. for (const page of this.pageSet.children) {
  48905. page[_symbol_utils.$cleanPage]();
  48906. }
  48907. }
  48908. [_symbol_utils.$isUsable]() {
  48909. return !this.occur || this.occur.max === -1 || this[_symbol_utils.$extra].numberOfUse < this.occur.max;
  48910. }
  48911. [_symbol_utils.$getNextPage]() {
  48912. if (!this[_symbol_utils.$extra]) {
  48913. this[_symbol_utils.$extra] = {
  48914. numberOfUse: 1,
  48915. pageIndex: -1,
  48916. pageSetIndex: -1
  48917. };
  48918. }
  48919. if (this.relation === "orderedOccurrence") {
  48920. if (this[_symbol_utils.$extra].pageIndex + 1 < this.pageArea.children.length) {
  48921. this[_symbol_utils.$extra].pageIndex += 1;
  48922. const pageArea = this.pageArea.children[this[_symbol_utils.$extra].pageIndex];
  48923. return pageArea[_symbol_utils.$getNextPage]();
  48924. }
  48925. if (this[_symbol_utils.$extra].pageSetIndex + 1 < this.pageSet.children.length) {
  48926. this[_symbol_utils.$extra].pageSetIndex += 1;
  48927. return this.pageSet.children[this[_symbol_utils.$extra].pageSetIndex][_symbol_utils.$getNextPage]();
  48928. }
  48929. if (this[_symbol_utils.$isUsable]()) {
  48930. this[_symbol_utils.$extra].numberOfUse += 1;
  48931. this[_symbol_utils.$extra].pageIndex = -1;
  48932. this[_symbol_utils.$extra].pageSetIndex = -1;
  48933. return this[_symbol_utils.$getNextPage]();
  48934. }
  48935. const parent = this[_symbol_utils.$getParent]();
  48936. if (parent instanceof PageSet) {
  48937. return parent[_symbol_utils.$getNextPage]();
  48938. }
  48939. this[_symbol_utils.$cleanPage]();
  48940. return this[_symbol_utils.$getNextPage]();
  48941. }
  48942. const pageNumber = this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].pageNumber;
  48943. const parity = pageNumber % 2 === 0 ? "even" : "odd";
  48944. const position = pageNumber === 0 ? "first" : "rest";
  48945. let page = this.pageArea.children.find(p => p.oddOrEven === parity && p.pagePosition === position);
  48946. if (page) {
  48947. return page;
  48948. }
  48949. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === position);
  48950. if (page) {
  48951. return page;
  48952. }
  48953. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === "any");
  48954. if (page) {
  48955. return page;
  48956. }
  48957. return this.pageArea.children[0];
  48958. }
  48959. }
  48960. class Para extends _xfa_object.XFAObject {
  48961. constructor(attributes) {
  48962. super(TEMPLATE_NS_ID, "para", true);
  48963. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  48964. this.id = attributes.id || "";
  48965. this.lineHeight = attributes.lineHeight ? (0, _utils.getMeasurement)(attributes.lineHeight, "0pt") : "";
  48966. this.marginLeft = attributes.marginLeft ? (0, _utils.getMeasurement)(attributes.marginLeft, "0pt") : "";
  48967. this.marginRight = attributes.marginRight ? (0, _utils.getMeasurement)(attributes.marginRight, "0pt") : "";
  48968. this.orphans = (0, _utils.getInteger)({
  48969. data: attributes.orphans,
  48970. defaultValue: 0,
  48971. validate: x => x >= 0
  48972. });
  48973. this.preserve = attributes.preserve || "";
  48974. this.radixOffset = attributes.radixOffset ? (0, _utils.getMeasurement)(attributes.radixOffset, "0pt") : "";
  48975. this.spaceAbove = attributes.spaceAbove ? (0, _utils.getMeasurement)(attributes.spaceAbove, "0pt") : "";
  48976. this.spaceBelow = attributes.spaceBelow ? (0, _utils.getMeasurement)(attributes.spaceBelow, "0pt") : "";
  48977. this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : "";
  48978. this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? (0, _utils.getMeasurement)(x) : x);
  48979. this.textIndent = attributes.textIndent ? (0, _utils.getMeasurement)(attributes.textIndent, "0pt") : "";
  48980. this.use = attributes.use || "";
  48981. this.usehref = attributes.usehref || "";
  48982. this.vAlign = (0, _utils.getStringOption)(attributes.vAlign, ["top", "bottom", "middle"]);
  48983. this.widows = (0, _utils.getInteger)({
  48984. data: attributes.widows,
  48985. defaultValue: 0,
  48986. validate: x => x >= 0
  48987. });
  48988. this.hyphenation = null;
  48989. }
  48990. [_symbol_utils.$toStyle]() {
  48991. const style = (0, _html_utils.toStyle)(this, "hAlign");
  48992. if (this.marginLeft !== "") {
  48993. style.paddingLeft = (0, _html_utils.measureToString)(this.marginLeft);
  48994. }
  48995. if (this.marginRight !== "") {
  48996. style.paddingight = (0, _html_utils.measureToString)(this.marginRight);
  48997. }
  48998. if (this.spaceAbove !== "") {
  48999. style.paddingTop = (0, _html_utils.measureToString)(this.spaceAbove);
  49000. }
  49001. if (this.spaceBelow !== "") {
  49002. style.paddingBottom = (0, _html_utils.measureToString)(this.spaceBelow);
  49003. }
  49004. if (this.textIndent !== "") {
  49005. style.textIndent = (0, _html_utils.measureToString)(this.textIndent);
  49006. (0, _html_utils.fixTextIndent)(style);
  49007. }
  49008. if (this.lineHeight > 0) {
  49009. style.lineHeight = (0, _html_utils.measureToString)(this.lineHeight);
  49010. }
  49011. if (this.tabDefault !== "") {
  49012. style.tabSize = (0, _html_utils.measureToString)(this.tabDefault);
  49013. }
  49014. if (this.tabStops.length > 0) {}
  49015. if (this.hyphenatation) {
  49016. Object.assign(style, this.hyphenatation[_symbol_utils.$toStyle]());
  49017. }
  49018. return style;
  49019. }
  49020. }
  49021. class PasswordEdit extends _xfa_object.XFAObject {
  49022. constructor(attributes) {
  49023. super(TEMPLATE_NS_ID, "passwordEdit", true);
  49024. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  49025. this.id = attributes.id || "";
  49026. this.passwordChar = attributes.passwordChar || "*";
  49027. this.use = attributes.use || "";
  49028. this.usehref = attributes.usehref || "";
  49029. this.border = null;
  49030. this.extras = null;
  49031. this.margin = null;
  49032. }
  49033. }
  49034. class Pattern extends _xfa_object.XFAObject {
  49035. constructor(attributes) {
  49036. super(TEMPLATE_NS_ID, "pattern", true);
  49037. this.id = attributes.id || "";
  49038. this.type = (0, _utils.getStringOption)(attributes.type, ["crossHatch", "crossDiagonal", "diagonalLeft", "diagonalRight", "horizontal", "vertical"]);
  49039. this.use = attributes.use || "";
  49040. this.usehref = attributes.usehref || "";
  49041. this.color = null;
  49042. this.extras = null;
  49043. }
  49044. [_symbol_utils.$toStyle](startColor) {
  49045. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  49046. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  49047. const width = 5;
  49048. const cmd = "repeating-linear-gradient";
  49049. const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${2 * width}px`;
  49050. switch (this.type) {
  49051. case "crossHatch":
  49052. return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
  49053. case "crossDiagonal":
  49054. return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
  49055. case "diagonalLeft":
  49056. return `${cmd}(45deg,${colors})`;
  49057. case "diagonalRight":
  49058. return `${cmd}(-45deg,${colors})`;
  49059. case "horizontal":
  49060. return `${cmd}(to top,${colors})`;
  49061. case "vertical":
  49062. return `${cmd}(to right,${colors})`;
  49063. }
  49064. return "";
  49065. }
  49066. }
  49067. class Picture extends _xfa_object.StringObject {
  49068. constructor(attributes) {
  49069. super(TEMPLATE_NS_ID, "picture");
  49070. this.id = attributes.id || "";
  49071. this.use = attributes.use || "";
  49072. this.usehref = attributes.usehref || "";
  49073. }
  49074. }
  49075. class Proto extends _xfa_object.XFAObject {
  49076. constructor(attributes) {
  49077. super(TEMPLATE_NS_ID, "proto", true);
  49078. this.appearanceFilter = new _xfa_object.XFAObjectArray();
  49079. this.arc = new _xfa_object.XFAObjectArray();
  49080. this.area = new _xfa_object.XFAObjectArray();
  49081. this.assist = new _xfa_object.XFAObjectArray();
  49082. this.barcode = new _xfa_object.XFAObjectArray();
  49083. this.bindItems = new _xfa_object.XFAObjectArray();
  49084. this.bookend = new _xfa_object.XFAObjectArray();
  49085. this.boolean = new _xfa_object.XFAObjectArray();
  49086. this.border = new _xfa_object.XFAObjectArray();
  49087. this.break = new _xfa_object.XFAObjectArray();
  49088. this.breakAfter = new _xfa_object.XFAObjectArray();
  49089. this.breakBefore = new _xfa_object.XFAObjectArray();
  49090. this.button = new _xfa_object.XFAObjectArray();
  49091. this.calculate = new _xfa_object.XFAObjectArray();
  49092. this.caption = new _xfa_object.XFAObjectArray();
  49093. this.certificate = new _xfa_object.XFAObjectArray();
  49094. this.certificates = new _xfa_object.XFAObjectArray();
  49095. this.checkButton = new _xfa_object.XFAObjectArray();
  49096. this.choiceList = new _xfa_object.XFAObjectArray();
  49097. this.color = new _xfa_object.XFAObjectArray();
  49098. this.comb = new _xfa_object.XFAObjectArray();
  49099. this.connect = new _xfa_object.XFAObjectArray();
  49100. this.contentArea = new _xfa_object.XFAObjectArray();
  49101. this.corner = new _xfa_object.XFAObjectArray();
  49102. this.date = new _xfa_object.XFAObjectArray();
  49103. this.dateTime = new _xfa_object.XFAObjectArray();
  49104. this.dateTimeEdit = new _xfa_object.XFAObjectArray();
  49105. this.decimal = new _xfa_object.XFAObjectArray();
  49106. this.defaultUi = new _xfa_object.XFAObjectArray();
  49107. this.desc = new _xfa_object.XFAObjectArray();
  49108. this.digestMethod = new _xfa_object.XFAObjectArray();
  49109. this.digestMethods = new _xfa_object.XFAObjectArray();
  49110. this.draw = new _xfa_object.XFAObjectArray();
  49111. this.edge = new _xfa_object.XFAObjectArray();
  49112. this.encoding = new _xfa_object.XFAObjectArray();
  49113. this.encodings = new _xfa_object.XFAObjectArray();
  49114. this.encrypt = new _xfa_object.XFAObjectArray();
  49115. this.encryptData = new _xfa_object.XFAObjectArray();
  49116. this.encryption = new _xfa_object.XFAObjectArray();
  49117. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  49118. this.encryptionMethods = new _xfa_object.XFAObjectArray();
  49119. this.event = new _xfa_object.XFAObjectArray();
  49120. this.exData = new _xfa_object.XFAObjectArray();
  49121. this.exObject = new _xfa_object.XFAObjectArray();
  49122. this.exclGroup = new _xfa_object.XFAObjectArray();
  49123. this.execute = new _xfa_object.XFAObjectArray();
  49124. this.extras = new _xfa_object.XFAObjectArray();
  49125. this.field = new _xfa_object.XFAObjectArray();
  49126. this.fill = new _xfa_object.XFAObjectArray();
  49127. this.filter = new _xfa_object.XFAObjectArray();
  49128. this.float = new _xfa_object.XFAObjectArray();
  49129. this.font = new _xfa_object.XFAObjectArray();
  49130. this.format = new _xfa_object.XFAObjectArray();
  49131. this.handler = new _xfa_object.XFAObjectArray();
  49132. this.hyphenation = new _xfa_object.XFAObjectArray();
  49133. this.image = new _xfa_object.XFAObjectArray();
  49134. this.imageEdit = new _xfa_object.XFAObjectArray();
  49135. this.integer = new _xfa_object.XFAObjectArray();
  49136. this.issuers = new _xfa_object.XFAObjectArray();
  49137. this.items = new _xfa_object.XFAObjectArray();
  49138. this.keep = new _xfa_object.XFAObjectArray();
  49139. this.keyUsage = new _xfa_object.XFAObjectArray();
  49140. this.line = new _xfa_object.XFAObjectArray();
  49141. this.linear = new _xfa_object.XFAObjectArray();
  49142. this.lockDocument = new _xfa_object.XFAObjectArray();
  49143. this.manifest = new _xfa_object.XFAObjectArray();
  49144. this.margin = new _xfa_object.XFAObjectArray();
  49145. this.mdp = new _xfa_object.XFAObjectArray();
  49146. this.medium = new _xfa_object.XFAObjectArray();
  49147. this.message = new _xfa_object.XFAObjectArray();
  49148. this.numericEdit = new _xfa_object.XFAObjectArray();
  49149. this.occur = new _xfa_object.XFAObjectArray();
  49150. this.oid = new _xfa_object.XFAObjectArray();
  49151. this.oids = new _xfa_object.XFAObjectArray();
  49152. this.overflow = new _xfa_object.XFAObjectArray();
  49153. this.pageArea = new _xfa_object.XFAObjectArray();
  49154. this.pageSet = new _xfa_object.XFAObjectArray();
  49155. this.para = new _xfa_object.XFAObjectArray();
  49156. this.passwordEdit = new _xfa_object.XFAObjectArray();
  49157. this.pattern = new _xfa_object.XFAObjectArray();
  49158. this.picture = new _xfa_object.XFAObjectArray();
  49159. this.radial = new _xfa_object.XFAObjectArray();
  49160. this.reason = new _xfa_object.XFAObjectArray();
  49161. this.reasons = new _xfa_object.XFAObjectArray();
  49162. this.rectangle = new _xfa_object.XFAObjectArray();
  49163. this.ref = new _xfa_object.XFAObjectArray();
  49164. this.script = new _xfa_object.XFAObjectArray();
  49165. this.setProperty = new _xfa_object.XFAObjectArray();
  49166. this.signData = new _xfa_object.XFAObjectArray();
  49167. this.signature = new _xfa_object.XFAObjectArray();
  49168. this.signing = new _xfa_object.XFAObjectArray();
  49169. this.solid = new _xfa_object.XFAObjectArray();
  49170. this.speak = new _xfa_object.XFAObjectArray();
  49171. this.stipple = new _xfa_object.XFAObjectArray();
  49172. this.subform = new _xfa_object.XFAObjectArray();
  49173. this.subformSet = new _xfa_object.XFAObjectArray();
  49174. this.subjectDN = new _xfa_object.XFAObjectArray();
  49175. this.subjectDNs = new _xfa_object.XFAObjectArray();
  49176. this.submit = new _xfa_object.XFAObjectArray();
  49177. this.text = new _xfa_object.XFAObjectArray();
  49178. this.textEdit = new _xfa_object.XFAObjectArray();
  49179. this.time = new _xfa_object.XFAObjectArray();
  49180. this.timeStamp = new _xfa_object.XFAObjectArray();
  49181. this.toolTip = new _xfa_object.XFAObjectArray();
  49182. this.traversal = new _xfa_object.XFAObjectArray();
  49183. this.traverse = new _xfa_object.XFAObjectArray();
  49184. this.ui = new _xfa_object.XFAObjectArray();
  49185. this.validate = new _xfa_object.XFAObjectArray();
  49186. this.value = new _xfa_object.XFAObjectArray();
  49187. this.variables = new _xfa_object.XFAObjectArray();
  49188. }
  49189. }
  49190. class Radial extends _xfa_object.XFAObject {
  49191. constructor(attributes) {
  49192. super(TEMPLATE_NS_ID, "radial", true);
  49193. this.id = attributes.id || "";
  49194. this.type = (0, _utils.getStringOption)(attributes.type, ["toEdge", "toCenter"]);
  49195. this.use = attributes.use || "";
  49196. this.usehref = attributes.usehref || "";
  49197. this.color = null;
  49198. this.extras = null;
  49199. }
  49200. [_symbol_utils.$toStyle](startColor) {
  49201. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  49202. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  49203. const colors = this.type === "toEdge" ? `${startColor},${endColor}` : `${endColor},${startColor}`;
  49204. return `radial-gradient(circle at center, ${colors})`;
  49205. }
  49206. }
  49207. class Reason extends _xfa_object.StringObject {
  49208. constructor(attributes) {
  49209. super(TEMPLATE_NS_ID, "reason");
  49210. this.id = attributes.id || "";
  49211. this.name = attributes.name || "";
  49212. this.use = attributes.use || "";
  49213. this.usehref = attributes.usehref || "";
  49214. }
  49215. }
  49216. class Reasons extends _xfa_object.XFAObject {
  49217. constructor(attributes) {
  49218. super(TEMPLATE_NS_ID, "reasons", true);
  49219. this.id = attributes.id || "";
  49220. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  49221. this.use = attributes.use || "";
  49222. this.usehref = attributes.usehref || "";
  49223. this.reason = new _xfa_object.XFAObjectArray();
  49224. }
  49225. }
  49226. class Rectangle extends _xfa_object.XFAObject {
  49227. constructor(attributes) {
  49228. super(TEMPLATE_NS_ID, "rectangle", true);
  49229. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  49230. this.id = attributes.id || "";
  49231. this.use = attributes.use || "";
  49232. this.usehref = attributes.usehref || "";
  49233. this.corner = new _xfa_object.XFAObjectArray(4);
  49234. this.edge = new _xfa_object.XFAObjectArray(4);
  49235. this.fill = null;
  49236. }
  49237. [_symbol_utils.$toHTML]() {
  49238. const edge = this.edge.children.length ? this.edge.children[0] : new Edge({});
  49239. const edgeStyle = edge[_symbol_utils.$toStyle]();
  49240. const style = Object.create(null);
  49241. if (this.fill?.presence === "visible") {
  49242. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  49243. } else {
  49244. style.fill = "transparent";
  49245. }
  49246. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  49247. style.stroke = edgeStyle.color;
  49248. const corner = this.corner.children.length ? this.corner.children[0] : new Corner({});
  49249. const cornerStyle = corner[_symbol_utils.$toStyle]();
  49250. const rect = {
  49251. name: "rect",
  49252. attributes: {
  49253. xmlns: SVG_NS,
  49254. width: "100%",
  49255. height: "100%",
  49256. x: 0,
  49257. y: 0,
  49258. rx: cornerStyle.radius,
  49259. ry: cornerStyle.radius,
  49260. style
  49261. }
  49262. };
  49263. const svg = {
  49264. name: "svg",
  49265. children: [rect],
  49266. attributes: {
  49267. xmlns: SVG_NS,
  49268. style: {
  49269. overflow: "visible"
  49270. },
  49271. width: "100%",
  49272. height: "100%"
  49273. }
  49274. };
  49275. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  49276. if (hasMargin(parent)) {
  49277. return _utils.HTMLResult.success({
  49278. name: "div",
  49279. attributes: {
  49280. style: {
  49281. display: "inline",
  49282. width: "100%",
  49283. height: "100%"
  49284. }
  49285. },
  49286. children: [svg]
  49287. });
  49288. }
  49289. svg.attributes.style.position = "absolute";
  49290. return _utils.HTMLResult.success(svg);
  49291. }
  49292. }
  49293. class RefElement extends _xfa_object.StringObject {
  49294. constructor(attributes) {
  49295. super(TEMPLATE_NS_ID, "ref");
  49296. this.id = attributes.id || "";
  49297. this.use = attributes.use || "";
  49298. this.usehref = attributes.usehref || "";
  49299. }
  49300. }
  49301. class Script extends _xfa_object.StringObject {
  49302. constructor(attributes) {
  49303. super(TEMPLATE_NS_ID, "script");
  49304. this.binding = attributes.binding || "";
  49305. this.contentType = attributes.contentType || "";
  49306. this.id = attributes.id || "";
  49307. this.name = attributes.name || "";
  49308. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  49309. this.use = attributes.use || "";
  49310. this.usehref = attributes.usehref || "";
  49311. }
  49312. }
  49313. class SetProperty extends _xfa_object.XFAObject {
  49314. constructor(attributes) {
  49315. super(TEMPLATE_NS_ID, "setProperty");
  49316. this.connection = attributes.connection || "";
  49317. this.ref = attributes.ref || "";
  49318. this.target = attributes.target || "";
  49319. }
  49320. }
  49321. exports.SetProperty = SetProperty;
  49322. class SignData extends _xfa_object.XFAObject {
  49323. constructor(attributes) {
  49324. super(TEMPLATE_NS_ID, "signData", true);
  49325. this.id = attributes.id || "";
  49326. this.operation = (0, _utils.getStringOption)(attributes.operation, ["sign", "clear", "verify"]);
  49327. this.ref = attributes.ref || "";
  49328. this.target = attributes.target || "";
  49329. this.use = attributes.use || "";
  49330. this.usehref = attributes.usehref || "";
  49331. this.filter = null;
  49332. this.manifest = null;
  49333. }
  49334. }
  49335. class Signature extends _xfa_object.XFAObject {
  49336. constructor(attributes) {
  49337. super(TEMPLATE_NS_ID, "signature", true);
  49338. this.id = attributes.id || "";
  49339. this.type = (0, _utils.getStringOption)(attributes.type, ["PDF1.3", "PDF1.6"]);
  49340. this.use = attributes.use || "";
  49341. this.usehref = attributes.usehref || "";
  49342. this.border = null;
  49343. this.extras = null;
  49344. this.filter = null;
  49345. this.manifest = null;
  49346. this.margin = null;
  49347. }
  49348. }
  49349. class Signing extends _xfa_object.XFAObject {
  49350. constructor(attributes) {
  49351. super(TEMPLATE_NS_ID, "signing", true);
  49352. this.id = attributes.id || "";
  49353. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  49354. this.use = attributes.use || "";
  49355. this.usehref = attributes.usehref || "";
  49356. this.certificate = new _xfa_object.XFAObjectArray();
  49357. }
  49358. }
  49359. class Solid extends _xfa_object.XFAObject {
  49360. constructor(attributes) {
  49361. super(TEMPLATE_NS_ID, "solid", true);
  49362. this.id = attributes.id || "";
  49363. this.use = attributes.use || "";
  49364. this.usehref = attributes.usehref || "";
  49365. this.extras = null;
  49366. }
  49367. [_symbol_utils.$toStyle](startColor) {
  49368. return startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  49369. }
  49370. }
  49371. class Speak extends _xfa_object.StringObject {
  49372. constructor(attributes) {
  49373. super(TEMPLATE_NS_ID, "speak");
  49374. this.disable = (0, _utils.getInteger)({
  49375. data: attributes.disable,
  49376. defaultValue: 0,
  49377. validate: x => x === 1
  49378. });
  49379. this.id = attributes.id || "";
  49380. this.priority = (0, _utils.getStringOption)(attributes.priority, ["custom", "caption", "name", "toolTip"]);
  49381. this.rid = attributes.rid || "";
  49382. this.use = attributes.use || "";
  49383. this.usehref = attributes.usehref || "";
  49384. }
  49385. }
  49386. class Stipple extends _xfa_object.XFAObject {
  49387. constructor(attributes) {
  49388. super(TEMPLATE_NS_ID, "stipple", true);
  49389. this.id = attributes.id || "";
  49390. this.rate = (0, _utils.getInteger)({
  49391. data: attributes.rate,
  49392. defaultValue: 50,
  49393. validate: x => x >= 0 && x <= 100
  49394. });
  49395. this.use = attributes.use || "";
  49396. this.usehref = attributes.usehref || "";
  49397. this.color = null;
  49398. this.extras = null;
  49399. }
  49400. [_symbol_utils.$toStyle](bgColor) {
  49401. const alpha = this.rate / 100;
  49402. return _util.Util.makeHexColor(Math.round(bgColor.value.r * (1 - alpha) + this.value.r * alpha), Math.round(bgColor.value.g * (1 - alpha) + this.value.g * alpha), Math.round(bgColor.value.b * (1 - alpha) + this.value.b * alpha));
  49403. }
  49404. }
  49405. class Subform extends _xfa_object.XFAObject {
  49406. constructor(attributes) {
  49407. super(TEMPLATE_NS_ID, "subform", true);
  49408. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  49409. this.allowMacro = (0, _utils.getInteger)({
  49410. data: attributes.allowMacro,
  49411. defaultValue: 0,
  49412. validate: x => x === 1
  49413. });
  49414. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  49415. this.colSpan = (0, _utils.getInteger)({
  49416. data: attributes.colSpan,
  49417. defaultValue: 1,
  49418. validate: n => n >= 1 || n === -1
  49419. });
  49420. this.columnWidths = (attributes.columnWidths || "").trim().split(/\s+/).map(x => x === "-1" ? -1 : (0, _utils.getMeasurement)(x));
  49421. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  49422. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  49423. this.id = attributes.id || "";
  49424. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  49425. this.locale = attributes.locale || "";
  49426. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  49427. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  49428. this.mergeMode = (0, _utils.getStringOption)(attributes.mergeMode, ["consumeData", "matchTemplate"]);
  49429. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  49430. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  49431. this.name = attributes.name || "";
  49432. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  49433. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  49434. this.restoreState = (0, _utils.getStringOption)(attributes.restoreState, ["manual", "auto"]);
  49435. this.scope = (0, _utils.getStringOption)(attributes.scope, ["name", "none"]);
  49436. this.use = attributes.use || "";
  49437. this.usehref = attributes.usehref || "";
  49438. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  49439. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  49440. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  49441. this.assist = null;
  49442. this.bind = null;
  49443. this.bookend = null;
  49444. this.border = null;
  49445. this.break = null;
  49446. this.calculate = null;
  49447. this.desc = null;
  49448. this.extras = null;
  49449. this.keep = null;
  49450. this.margin = null;
  49451. this.occur = null;
  49452. this.overflow = null;
  49453. this.pageSet = null;
  49454. this.para = null;
  49455. this.traversal = null;
  49456. this.validate = null;
  49457. this.variables = null;
  49458. this.area = new _xfa_object.XFAObjectArray();
  49459. this.breakAfter = new _xfa_object.XFAObjectArray();
  49460. this.breakBefore = new _xfa_object.XFAObjectArray();
  49461. this.connect = new _xfa_object.XFAObjectArray();
  49462. this.draw = new _xfa_object.XFAObjectArray();
  49463. this.event = new _xfa_object.XFAObjectArray();
  49464. this.exObject = new _xfa_object.XFAObjectArray();
  49465. this.exclGroup = new _xfa_object.XFAObjectArray();
  49466. this.field = new _xfa_object.XFAObjectArray();
  49467. this.proto = new _xfa_object.XFAObjectArray();
  49468. this.setProperty = new _xfa_object.XFAObjectArray();
  49469. this.subform = new _xfa_object.XFAObjectArray();
  49470. this.subformSet = new _xfa_object.XFAObjectArray();
  49471. }
  49472. [_symbol_utils.$getSubformParent]() {
  49473. const parent = this[_symbol_utils.$getParent]();
  49474. if (parent instanceof SubformSet) {
  49475. return parent[_symbol_utils.$getSubformParent]();
  49476. }
  49477. return parent;
  49478. }
  49479. [_symbol_utils.$isBindable]() {
  49480. return true;
  49481. }
  49482. [_symbol_utils.$isThereMoreWidth]() {
  49483. return this.layout.endsWith("-tb") && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine > 0 || this[_symbol_utils.$getParent]()[_symbol_utils.$isThereMoreWidth]();
  49484. }
  49485. *[_symbol_utils.$getContainedChildren]() {
  49486. yield* getContainedChildren(this);
  49487. }
  49488. [_symbol_utils.$flushHTML]() {
  49489. return (0, _layout.flushHTML)(this);
  49490. }
  49491. [_symbol_utils.$addHTML](html, bbox) {
  49492. (0, _layout.addHTML)(this, html, bbox);
  49493. }
  49494. [_symbol_utils.$getAvailableSpace]() {
  49495. return (0, _layout.getAvailableSpace)(this);
  49496. }
  49497. [_symbol_utils.$isSplittable]() {
  49498. const parent = this[_symbol_utils.$getSubformParent]();
  49499. if (!parent[_symbol_utils.$isSplittable]()) {
  49500. return false;
  49501. }
  49502. if (this[_symbol_utils.$extra]._isSplittable !== undefined) {
  49503. return this[_symbol_utils.$extra]._isSplittable;
  49504. }
  49505. if (this.layout === "position" || this.layout.includes("row")) {
  49506. this[_symbol_utils.$extra]._isSplittable = false;
  49507. return false;
  49508. }
  49509. if (this.keep && this.keep.intact !== "none") {
  49510. this[_symbol_utils.$extra]._isSplittable = false;
  49511. return false;
  49512. }
  49513. if (parent.layout?.endsWith("-tb") && parent[_symbol_utils.$extra].numberInLine !== 0) {
  49514. return false;
  49515. }
  49516. this[_symbol_utils.$extra]._isSplittable = true;
  49517. return true;
  49518. }
  49519. [_symbol_utils.$toHTML](availableSpace) {
  49520. setTabIndex(this);
  49521. if (this.break) {
  49522. if (this.break.after !== "auto" || this.break.afterTarget !== "") {
  49523. const node = new BreakAfter({
  49524. targetType: this.break.after,
  49525. target: this.break.afterTarget,
  49526. startNew: this.break.startNew.toString()
  49527. });
  49528. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  49529. this[_symbol_utils.$appendChild](node);
  49530. this.breakAfter.push(node);
  49531. }
  49532. if (this.break.before !== "auto" || this.break.beforeTarget !== "") {
  49533. const node = new BreakBefore({
  49534. targetType: this.break.before,
  49535. target: this.break.beforeTarget,
  49536. startNew: this.break.startNew.toString()
  49537. });
  49538. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  49539. this[_symbol_utils.$appendChild](node);
  49540. this.breakBefore.push(node);
  49541. }
  49542. if (this.break.overflowTarget !== "") {
  49543. const node = new Overflow({
  49544. target: this.break.overflowTarget,
  49545. leader: this.break.overflowLeader,
  49546. trailer: this.break.overflowTrailer
  49547. });
  49548. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  49549. this[_symbol_utils.$appendChild](node);
  49550. this.overflow.push(node);
  49551. }
  49552. this[_symbol_utils.$removeChild](this.break);
  49553. this.break = null;
  49554. }
  49555. if (this.presence === "hidden" || this.presence === "inactive") {
  49556. return _utils.HTMLResult.EMPTY;
  49557. }
  49558. if (this.breakBefore.children.length > 1 || this.breakAfter.children.length > 1) {
  49559. (0, _util.warn)("XFA - Several breakBefore or breakAfter in subforms: please file a bug.");
  49560. }
  49561. if (this.breakBefore.children.length >= 1) {
  49562. const breakBefore = this.breakBefore.children[0];
  49563. if (handleBreak(breakBefore)) {
  49564. return _utils.HTMLResult.breakNode(breakBefore);
  49565. }
  49566. }
  49567. if (this[_symbol_utils.$extra]?.afterBreakAfter) {
  49568. return _utils.HTMLResult.EMPTY;
  49569. }
  49570. (0, _html_utils.fixDimensions)(this);
  49571. const children = [];
  49572. const attributes = {
  49573. id: this[_symbol_utils.$uid],
  49574. class: []
  49575. };
  49576. (0, _html_utils.setAccess)(this, attributes.class);
  49577. if (!this[_symbol_utils.$extra]) {
  49578. this[_symbol_utils.$extra] = Object.create(null);
  49579. }
  49580. Object.assign(this[_symbol_utils.$extra], {
  49581. children,
  49582. line: null,
  49583. attributes,
  49584. attempt: 0,
  49585. numberInLine: 0,
  49586. availableSpace: {
  49587. width: Math.min(this.w || Infinity, availableSpace.width),
  49588. height: Math.min(this.h || Infinity, availableSpace.height)
  49589. },
  49590. width: 0,
  49591. height: 0,
  49592. prevHeight: 0,
  49593. currentWidth: 0
  49594. });
  49595. const root = this[_symbol_utils.$getTemplateRoot]();
  49596. const savedNoLayoutFailure = root[_symbol_utils.$extra].noLayoutFailure;
  49597. const isSplittable = this[_symbol_utils.$isSplittable]();
  49598. if (!isSplittable) {
  49599. setFirstUnsplittable(this);
  49600. }
  49601. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  49602. return _utils.HTMLResult.FAILURE;
  49603. }
  49604. const filter = new Set(["area", "draw", "exclGroup", "field", "subform", "subformSet"]);
  49605. if (this.layout.includes("row")) {
  49606. const columnWidths = this[_symbol_utils.$getSubformParent]().columnWidths;
  49607. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  49608. this[_symbol_utils.$extra].columnWidths = columnWidths;
  49609. this[_symbol_utils.$extra].currentColumn = 0;
  49610. }
  49611. }
  49612. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  49613. const classNames = ["xfaSubform"];
  49614. const cl = (0, _html_utils.layoutClass)(this);
  49615. if (cl) {
  49616. classNames.push(cl);
  49617. }
  49618. attributes.style = style;
  49619. attributes.class = classNames;
  49620. if (this.name) {
  49621. attributes.xfaName = this.name;
  49622. }
  49623. if (this.overflow) {
  49624. const overflowExtra = this.overflow[_symbol_utils.$getExtra]();
  49625. if (overflowExtra.addLeader) {
  49626. overflowExtra.addLeader = false;
  49627. handleOverflow(this, overflowExtra.leader, availableSpace);
  49628. }
  49629. }
  49630. this[_symbol_utils.$pushPara]();
  49631. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  49632. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  49633. for (; this[_symbol_utils.$extra].attempt < maxRun; this[_symbol_utils.$extra].attempt++) {
  49634. if (isLrTb && this[_symbol_utils.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  49635. this[_symbol_utils.$extra].numberInLine = 0;
  49636. }
  49637. const result = this[_symbol_utils.$childrenToHTML]({
  49638. filter,
  49639. include: true
  49640. });
  49641. if (result.success) {
  49642. break;
  49643. }
  49644. if (result.isBreak()) {
  49645. this[_symbol_utils.$popPara]();
  49646. return result;
  49647. }
  49648. if (isLrTb && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine === 0 && !root[_symbol_utils.$extra].noLayoutFailure) {
  49649. this[_symbol_utils.$extra].attempt = maxRun;
  49650. break;
  49651. }
  49652. }
  49653. this[_symbol_utils.$popPara]();
  49654. if (!isSplittable) {
  49655. unsetFirstUnsplittable(this);
  49656. }
  49657. root[_symbol_utils.$extra].noLayoutFailure = savedNoLayoutFailure;
  49658. if (this[_symbol_utils.$extra].attempt === maxRun) {
  49659. if (this.overflow) {
  49660. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].overflowNode = this.overflow;
  49661. }
  49662. if (!isSplittable) {
  49663. delete this[_symbol_utils.$extra];
  49664. }
  49665. return _utils.HTMLResult.FAILURE;
  49666. }
  49667. if (this.overflow) {
  49668. const overflowExtra = this.overflow[_symbol_utils.$getExtra]();
  49669. if (overflowExtra.addTrailer) {
  49670. overflowExtra.addTrailer = false;
  49671. handleOverflow(this, overflowExtra.trailer, availableSpace);
  49672. }
  49673. }
  49674. let marginH = 0;
  49675. let marginV = 0;
  49676. if (this.margin) {
  49677. marginH = this.margin.leftInset + this.margin.rightInset;
  49678. marginV = this.margin.topInset + this.margin.bottomInset;
  49679. }
  49680. const width = Math.max(this[_symbol_utils.$extra].width + marginH, this.w || 0);
  49681. const height = Math.max(this[_symbol_utils.$extra].height + marginV, this.h || 0);
  49682. const bbox = [this.x, this.y, width, height];
  49683. if (this.w === "") {
  49684. style.width = (0, _html_utils.measureToString)(width);
  49685. }
  49686. if (this.h === "") {
  49687. style.height = (0, _html_utils.measureToString)(height);
  49688. }
  49689. if ((style.width === "0px" || style.height === "0px") && children.length === 0) {
  49690. return _utils.HTMLResult.EMPTY;
  49691. }
  49692. const html = {
  49693. name: "div",
  49694. attributes,
  49695. children
  49696. };
  49697. applyAssist(this, attributes);
  49698. const result = _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  49699. if (this.breakAfter.children.length >= 1) {
  49700. const breakAfter = this.breakAfter.children[0];
  49701. if (handleBreak(breakAfter)) {
  49702. this[_symbol_utils.$extra].afterBreakAfter = result;
  49703. return _utils.HTMLResult.breakNode(breakAfter);
  49704. }
  49705. }
  49706. delete this[_symbol_utils.$extra];
  49707. return result;
  49708. }
  49709. }
  49710. class SubformSet extends _xfa_object.XFAObject {
  49711. constructor(attributes) {
  49712. super(TEMPLATE_NS_ID, "subformSet", true);
  49713. this.id = attributes.id || "";
  49714. this.name = attributes.name || "";
  49715. this.relation = (0, _utils.getStringOption)(attributes.relation, ["ordered", "choice", "unordered"]);
  49716. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  49717. this.use = attributes.use || "";
  49718. this.usehref = attributes.usehref || "";
  49719. this.bookend = null;
  49720. this.break = null;
  49721. this.desc = null;
  49722. this.extras = null;
  49723. this.occur = null;
  49724. this.overflow = null;
  49725. this.breakAfter = new _xfa_object.XFAObjectArray();
  49726. this.breakBefore = new _xfa_object.XFAObjectArray();
  49727. this.subform = new _xfa_object.XFAObjectArray();
  49728. this.subformSet = new _xfa_object.XFAObjectArray();
  49729. }
  49730. *[_symbol_utils.$getContainedChildren]() {
  49731. yield* getContainedChildren(this);
  49732. }
  49733. [_symbol_utils.$getSubformParent]() {
  49734. let parent = this[_symbol_utils.$getParent]();
  49735. while (!(parent instanceof Subform)) {
  49736. parent = parent[_symbol_utils.$getParent]();
  49737. }
  49738. return parent;
  49739. }
  49740. [_symbol_utils.$isBindable]() {
  49741. return true;
  49742. }
  49743. }
  49744. class SubjectDN extends _xfa_object.ContentObject {
  49745. constructor(attributes) {
  49746. super(TEMPLATE_NS_ID, "subjectDN");
  49747. this.delimiter = attributes.delimiter || ",";
  49748. this.id = attributes.id || "";
  49749. this.name = attributes.name || "";
  49750. this.use = attributes.use || "";
  49751. this.usehref = attributes.usehref || "";
  49752. }
  49753. [_symbol_utils.$finalize]() {
  49754. this[_symbol_utils.$content] = new Map(this[_symbol_utils.$content].split(this.delimiter).map(kv => {
  49755. kv = kv.split("=", 2);
  49756. kv[0] = kv[0].trim();
  49757. return kv;
  49758. }));
  49759. }
  49760. }
  49761. class SubjectDNs extends _xfa_object.XFAObject {
  49762. constructor(attributes) {
  49763. super(TEMPLATE_NS_ID, "subjectDNs", true);
  49764. this.id = attributes.id || "";
  49765. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  49766. this.use = attributes.use || "";
  49767. this.usehref = attributes.usehref || "";
  49768. this.subjectDN = new _xfa_object.XFAObjectArray();
  49769. }
  49770. }
  49771. class Submit extends _xfa_object.XFAObject {
  49772. constructor(attributes) {
  49773. super(TEMPLATE_NS_ID, "submit", true);
  49774. this.embedPDF = (0, _utils.getInteger)({
  49775. data: attributes.embedPDF,
  49776. defaultValue: 0,
  49777. validate: x => x === 1
  49778. });
  49779. this.format = (0, _utils.getStringOption)(attributes.format, ["xdp", "formdata", "pdf", "urlencoded", "xfd", "xml"]);
  49780. this.id = attributes.id || "";
  49781. this.target = attributes.target || "";
  49782. this.textEncoding = (0, _utils.getKeyword)({
  49783. data: attributes.textEncoding ? attributes.textEncoding.toLowerCase() : "",
  49784. defaultValue: "",
  49785. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  49786. });
  49787. this.use = attributes.use || "";
  49788. this.usehref = attributes.usehref || "";
  49789. this.xdpContent = attributes.xdpContent || "";
  49790. this.encrypt = null;
  49791. this.encryptData = new _xfa_object.XFAObjectArray();
  49792. this.signData = new _xfa_object.XFAObjectArray();
  49793. }
  49794. }
  49795. class Template extends _xfa_object.XFAObject {
  49796. constructor(attributes) {
  49797. super(TEMPLATE_NS_ID, "template", true);
  49798. this.baseProfile = (0, _utils.getStringOption)(attributes.baseProfile, ["full", "interactiveForms"]);
  49799. this.extras = null;
  49800. this.subform = new _xfa_object.XFAObjectArray();
  49801. }
  49802. [_symbol_utils.$finalize]() {
  49803. if (this.subform.children.length === 0) {
  49804. (0, _util.warn)("XFA - No subforms in template node.");
  49805. }
  49806. if (this.subform.children.length >= 2) {
  49807. (0, _util.warn)("XFA - Several subforms in template node: please file a bug.");
  49808. }
  49809. this[_symbol_utils.$tabIndex] = DEFAULT_TAB_INDEX;
  49810. }
  49811. [_symbol_utils.$isSplittable]() {
  49812. return true;
  49813. }
  49814. [_symbol_utils.$searchNode](expr, container) {
  49815. if (expr.startsWith("#")) {
  49816. return [this[_symbol_utils.$ids].get(expr.slice(1))];
  49817. }
  49818. return (0, _som.searchNode)(this, container, expr, true, true);
  49819. }
  49820. *[_symbol_utils.$toPages]() {
  49821. if (!this.subform.children.length) {
  49822. return _utils.HTMLResult.success({
  49823. name: "div",
  49824. children: []
  49825. });
  49826. }
  49827. this[_symbol_utils.$extra] = {
  49828. overflowNode: null,
  49829. firstUnsplittable: null,
  49830. currentContentArea: null,
  49831. currentPageArea: null,
  49832. noLayoutFailure: false,
  49833. pageNumber: 1,
  49834. pagePosition: "first",
  49835. oddOrEven: "odd",
  49836. blankOrNotBlank: "nonBlank",
  49837. paraStack: []
  49838. };
  49839. const root = this.subform.children[0];
  49840. root.pageSet[_symbol_utils.$cleanPage]();
  49841. const pageAreas = root.pageSet.pageArea.children;
  49842. const mainHtml = {
  49843. name: "div",
  49844. children: []
  49845. };
  49846. let pageArea = null;
  49847. let breakBefore = null;
  49848. let breakBeforeTarget = null;
  49849. if (root.breakBefore.children.length >= 1) {
  49850. breakBefore = root.breakBefore.children[0];
  49851. breakBeforeTarget = breakBefore.target;
  49852. } else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
  49853. breakBefore = root.subform.children[0].breakBefore.children[0];
  49854. breakBeforeTarget = breakBefore.target;
  49855. } else if (root.break?.beforeTarget) {
  49856. breakBefore = root.break;
  49857. breakBeforeTarget = breakBefore.beforeTarget;
  49858. } else if (root.subform.children.length >= 1 && root.subform.children[0].break?.beforeTarget) {
  49859. breakBefore = root.subform.children[0].break;
  49860. breakBeforeTarget = breakBefore.beforeTarget;
  49861. }
  49862. if (breakBefore) {
  49863. const target = this[_symbol_utils.$searchNode](breakBeforeTarget, breakBefore[_symbol_utils.$getParent]());
  49864. if (target instanceof PageArea) {
  49865. pageArea = target;
  49866. breakBefore[_symbol_utils.$extra] = {};
  49867. }
  49868. }
  49869. if (!pageArea) {
  49870. pageArea = pageAreas[0];
  49871. }
  49872. pageArea[_symbol_utils.$extra] = {
  49873. numberOfUse: 1
  49874. };
  49875. const pageAreaParent = pageArea[_symbol_utils.$getParent]();
  49876. pageAreaParent[_symbol_utils.$extra] = {
  49877. numberOfUse: 1,
  49878. pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
  49879. pageSetIndex: 0
  49880. };
  49881. let targetPageArea;
  49882. let leader = null;
  49883. let trailer = null;
  49884. let hasSomething = true;
  49885. let hasSomethingCounter = 0;
  49886. let startIndex = 0;
  49887. while (true) {
  49888. if (!hasSomething) {
  49889. mainHtml.children.pop();
  49890. if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
  49891. (0, _util.warn)("XFA - Something goes wrong: please file a bug.");
  49892. return mainHtml;
  49893. }
  49894. } else {
  49895. hasSomethingCounter = 0;
  49896. }
  49897. targetPageArea = null;
  49898. this[_symbol_utils.$extra].currentPageArea = pageArea;
  49899. const page = pageArea[_symbol_utils.$toHTML]().html;
  49900. mainHtml.children.push(page);
  49901. if (leader) {
  49902. this[_symbol_utils.$extra].noLayoutFailure = true;
  49903. page.children.push(leader[_symbol_utils.$toHTML](pageArea[_symbol_utils.$extra].space).html);
  49904. leader = null;
  49905. }
  49906. if (trailer) {
  49907. this[_symbol_utils.$extra].noLayoutFailure = true;
  49908. page.children.push(trailer[_symbol_utils.$toHTML](pageArea[_symbol_utils.$extra].space).html);
  49909. trailer = null;
  49910. }
  49911. const contentAreas = pageArea.contentArea.children;
  49912. const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
  49913. hasSomething = false;
  49914. this[_symbol_utils.$extra].firstUnsplittable = null;
  49915. this[_symbol_utils.$extra].noLayoutFailure = false;
  49916. const flush = index => {
  49917. const html = root[_symbol_utils.$flushHTML]();
  49918. if (html) {
  49919. hasSomething ||= html.children?.length > 0;
  49920. htmlContentAreas[index].children.push(html);
  49921. }
  49922. };
  49923. for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
  49924. const contentArea = this[_symbol_utils.$extra].currentContentArea = contentAreas[i];
  49925. const space = {
  49926. width: contentArea.w,
  49927. height: contentArea.h
  49928. };
  49929. startIndex = 0;
  49930. if (leader) {
  49931. htmlContentAreas[i].children.push(leader[_symbol_utils.$toHTML](space).html);
  49932. leader = null;
  49933. }
  49934. if (trailer) {
  49935. htmlContentAreas[i].children.push(trailer[_symbol_utils.$toHTML](space).html);
  49936. trailer = null;
  49937. }
  49938. const html = root[_symbol_utils.$toHTML](space);
  49939. if (html.success) {
  49940. if (html.html) {
  49941. hasSomething ||= html.html.children?.length > 0;
  49942. htmlContentAreas[i].children.push(html.html);
  49943. } else if (!hasSomething && mainHtml.children.length > 1) {
  49944. mainHtml.children.pop();
  49945. }
  49946. return mainHtml;
  49947. }
  49948. if (html.isBreak()) {
  49949. const node = html.breakNode;
  49950. flush(i);
  49951. if (node.targetType === "auto") {
  49952. continue;
  49953. }
  49954. if (node.leader) {
  49955. leader = this[_symbol_utils.$searchNode](node.leader, node[_symbol_utils.$getParent]());
  49956. leader = leader ? leader[0] : null;
  49957. }
  49958. if (node.trailer) {
  49959. trailer = this[_symbol_utils.$searchNode](node.trailer, node[_symbol_utils.$getParent]());
  49960. trailer = trailer ? trailer[0] : null;
  49961. }
  49962. if (node.targetType === "pageArea") {
  49963. targetPageArea = node[_symbol_utils.$extra].target;
  49964. i = Infinity;
  49965. } else if (!node[_symbol_utils.$extra].target) {
  49966. i = node[_symbol_utils.$extra].index;
  49967. } else {
  49968. targetPageArea = node[_symbol_utils.$extra].target;
  49969. startIndex = node[_symbol_utils.$extra].index + 1;
  49970. i = Infinity;
  49971. }
  49972. continue;
  49973. }
  49974. if (this[_symbol_utils.$extra].overflowNode) {
  49975. const node = this[_symbol_utils.$extra].overflowNode;
  49976. this[_symbol_utils.$extra].overflowNode = null;
  49977. const overflowExtra = node[_symbol_utils.$getExtra]();
  49978. const target = overflowExtra.target;
  49979. overflowExtra.addLeader = overflowExtra.leader !== null;
  49980. overflowExtra.addTrailer = overflowExtra.trailer !== null;
  49981. flush(i);
  49982. const currentIndex = i;
  49983. i = Infinity;
  49984. if (target instanceof PageArea) {
  49985. targetPageArea = target;
  49986. } else if (target instanceof ContentArea) {
  49987. const index = contentAreas.indexOf(target);
  49988. if (index !== -1) {
  49989. if (index > currentIndex) {
  49990. i = index - 1;
  49991. } else {
  49992. startIndex = index;
  49993. }
  49994. } else {
  49995. targetPageArea = target[_symbol_utils.$getParent]();
  49996. startIndex = targetPageArea.contentArea.children.indexOf(target);
  49997. }
  49998. }
  49999. continue;
  50000. }
  50001. flush(i);
  50002. }
  50003. this[_symbol_utils.$extra].pageNumber += 1;
  50004. if (targetPageArea) {
  50005. if (targetPageArea[_symbol_utils.$isUsable]()) {
  50006. targetPageArea[_symbol_utils.$extra].numberOfUse += 1;
  50007. } else {
  50008. targetPageArea = null;
  50009. }
  50010. }
  50011. pageArea = targetPageArea || pageArea[_symbol_utils.$getNextPage]();
  50012. yield null;
  50013. }
  50014. }
  50015. }
  50016. exports.Template = Template;
  50017. class Text extends _xfa_object.ContentObject {
  50018. constructor(attributes) {
  50019. super(TEMPLATE_NS_ID, "text");
  50020. this.id = attributes.id || "";
  50021. this.maxChars = (0, _utils.getInteger)({
  50022. data: attributes.maxChars,
  50023. defaultValue: 0,
  50024. validate: x => x >= 0
  50025. });
  50026. this.name = attributes.name || "";
  50027. this.rid = attributes.rid || "";
  50028. this.use = attributes.use || "";
  50029. this.usehref = attributes.usehref || "";
  50030. }
  50031. [_symbol_utils.$acceptWhitespace]() {
  50032. return true;
  50033. }
  50034. [_symbol_utils.$onChild](child) {
  50035. if (child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  50036. this[_symbol_utils.$content] = child;
  50037. return true;
  50038. }
  50039. (0, _util.warn)(`XFA - Invalid content in Text: ${child[_symbol_utils.$nodeName]}.`);
  50040. return false;
  50041. }
  50042. [_symbol_utils.$onText](str) {
  50043. if (this[_symbol_utils.$content] instanceof _xfa_object.XFAObject) {
  50044. return;
  50045. }
  50046. super[_symbol_utils.$onText](str);
  50047. }
  50048. [_symbol_utils.$finalize]() {
  50049. if (typeof this[_symbol_utils.$content] === "string") {
  50050. this[_symbol_utils.$content] = this[_symbol_utils.$content].replaceAll("\r\n", "\n");
  50051. }
  50052. }
  50053. [_symbol_utils.$getExtra]() {
  50054. if (typeof this[_symbol_utils.$content] === "string") {
  50055. return this[_symbol_utils.$content].split(/[\u2029\u2028\n]/).reduce((acc, line) => {
  50056. if (line) {
  50057. acc.push(line);
  50058. }
  50059. return acc;
  50060. }, []).join("\n");
  50061. }
  50062. return this[_symbol_utils.$content][_symbol_utils.$text]();
  50063. }
  50064. [_symbol_utils.$toHTML](availableSpace) {
  50065. if (typeof this[_symbol_utils.$content] === "string") {
  50066. const html = valueToHtml(this[_symbol_utils.$content]).html;
  50067. if (this[_symbol_utils.$content].includes("\u2029")) {
  50068. html.name = "div";
  50069. html.children = [];
  50070. this[_symbol_utils.$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
  50071. acc.push({
  50072. name: "span",
  50073. value: line
  50074. }, {
  50075. name: "br"
  50076. });
  50077. return acc;
  50078. }, [])).forEach(lines => {
  50079. html.children.push({
  50080. name: "p",
  50081. children: lines
  50082. });
  50083. });
  50084. } else if (/[\u2028\n]/.test(this[_symbol_utils.$content])) {
  50085. html.name = "div";
  50086. html.children = [];
  50087. this[_symbol_utils.$content].split(/[\u2028\n]/).forEach(line => {
  50088. html.children.push({
  50089. name: "span",
  50090. value: line
  50091. }, {
  50092. name: "br"
  50093. });
  50094. });
  50095. }
  50096. return _utils.HTMLResult.success(html);
  50097. }
  50098. return this[_symbol_utils.$content][_symbol_utils.$toHTML](availableSpace);
  50099. }
  50100. }
  50101. exports.Text = Text;
  50102. class TextEdit extends _xfa_object.XFAObject {
  50103. constructor(attributes) {
  50104. super(TEMPLATE_NS_ID, "textEdit", true);
  50105. this.allowRichText = (0, _utils.getInteger)({
  50106. data: attributes.allowRichText,
  50107. defaultValue: 0,
  50108. validate: x => x === 1
  50109. });
  50110. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  50111. this.id = attributes.id || "";
  50112. this.multiLine = (0, _utils.getInteger)({
  50113. data: attributes.multiLine,
  50114. defaultValue: "",
  50115. validate: x => x === 0 || x === 1
  50116. });
  50117. this.use = attributes.use || "";
  50118. this.usehref = attributes.usehref || "";
  50119. this.vScrollPolicy = (0, _utils.getStringOption)(attributes.vScrollPolicy, ["auto", "off", "on"]);
  50120. this.border = null;
  50121. this.comb = null;
  50122. this.extras = null;
  50123. this.margin = null;
  50124. }
  50125. [_symbol_utils.$toHTML](availableSpace) {
  50126. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  50127. let html;
  50128. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  50129. if (this.multiLine === "") {
  50130. this.multiLine = field instanceof Draw ? 1 : 0;
  50131. }
  50132. if (this.multiLine === 1) {
  50133. html = {
  50134. name: "textarea",
  50135. attributes: {
  50136. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  50137. fieldId: field[_symbol_utils.$uid],
  50138. class: ["xfaTextfield"],
  50139. style,
  50140. "aria-label": ariaLabel(field),
  50141. "aria-required": false
  50142. }
  50143. };
  50144. } else {
  50145. html = {
  50146. name: "input",
  50147. attributes: {
  50148. type: "text",
  50149. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  50150. fieldId: field[_symbol_utils.$uid],
  50151. class: ["xfaTextfield"],
  50152. style,
  50153. "aria-label": ariaLabel(field),
  50154. "aria-required": false
  50155. }
  50156. };
  50157. }
  50158. if (isRequired(field)) {
  50159. html.attributes["aria-required"] = true;
  50160. html.attributes.required = true;
  50161. }
  50162. return _utils.HTMLResult.success({
  50163. name: "label",
  50164. attributes: {
  50165. class: ["xfaLabel"]
  50166. },
  50167. children: [html]
  50168. });
  50169. }
  50170. }
  50171. class Time extends _xfa_object.StringObject {
  50172. constructor(attributes) {
  50173. super(TEMPLATE_NS_ID, "time");
  50174. this.id = attributes.id || "";
  50175. this.name = attributes.name || "";
  50176. this.use = attributes.use || "";
  50177. this.usehref = attributes.usehref || "";
  50178. }
  50179. [_symbol_utils.$finalize]() {
  50180. const date = this[_symbol_utils.$content].trim();
  50181. this[_symbol_utils.$content] = date ? new Date(date) : null;
  50182. }
  50183. [_symbol_utils.$toHTML](availableSpace) {
  50184. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  50185. }
  50186. }
  50187. class TimeStamp extends _xfa_object.XFAObject {
  50188. constructor(attributes) {
  50189. super(TEMPLATE_NS_ID, "timeStamp");
  50190. this.id = attributes.id || "";
  50191. this.server = attributes.server || "";
  50192. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  50193. this.use = attributes.use || "";
  50194. this.usehref = attributes.usehref || "";
  50195. }
  50196. }
  50197. class ToolTip extends _xfa_object.StringObject {
  50198. constructor(attributes) {
  50199. super(TEMPLATE_NS_ID, "toolTip");
  50200. this.id = attributes.id || "";
  50201. this.rid = attributes.rid || "";
  50202. this.use = attributes.use || "";
  50203. this.usehref = attributes.usehref || "";
  50204. }
  50205. }
  50206. class Traversal extends _xfa_object.XFAObject {
  50207. constructor(attributes) {
  50208. super(TEMPLATE_NS_ID, "traversal", true);
  50209. this.id = attributes.id || "";
  50210. this.use = attributes.use || "";
  50211. this.usehref = attributes.usehref || "";
  50212. this.extras = null;
  50213. this.traverse = new _xfa_object.XFAObjectArray();
  50214. }
  50215. }
  50216. class Traverse extends _xfa_object.XFAObject {
  50217. constructor(attributes) {
  50218. super(TEMPLATE_NS_ID, "traverse", true);
  50219. this.id = attributes.id || "";
  50220. this.operation = (0, _utils.getStringOption)(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
  50221. this.ref = attributes.ref || "";
  50222. this.use = attributes.use || "";
  50223. this.usehref = attributes.usehref || "";
  50224. this.extras = null;
  50225. this.script = null;
  50226. }
  50227. get name() {
  50228. return this.operation;
  50229. }
  50230. [_symbol_utils.$isTransparent]() {
  50231. return false;
  50232. }
  50233. }
  50234. class Ui extends _xfa_object.XFAObject {
  50235. constructor(attributes) {
  50236. super(TEMPLATE_NS_ID, "ui", true);
  50237. this.id = attributes.id || "";
  50238. this.use = attributes.use || "";
  50239. this.usehref = attributes.usehref || "";
  50240. this.extras = null;
  50241. this.picture = null;
  50242. this.barcode = null;
  50243. this.button = null;
  50244. this.checkButton = null;
  50245. this.choiceList = null;
  50246. this.dateTimeEdit = null;
  50247. this.defaultUi = null;
  50248. this.imageEdit = null;
  50249. this.numericEdit = null;
  50250. this.passwordEdit = null;
  50251. this.signature = null;
  50252. this.textEdit = null;
  50253. }
  50254. [_symbol_utils.$getExtra]() {
  50255. if (this[_symbol_utils.$extra] === undefined) {
  50256. for (const name of Object.getOwnPropertyNames(this)) {
  50257. if (name === "extras" || name === "picture") {
  50258. continue;
  50259. }
  50260. const obj = this[name];
  50261. if (!(obj instanceof _xfa_object.XFAObject)) {
  50262. continue;
  50263. }
  50264. this[_symbol_utils.$extra] = obj;
  50265. return obj;
  50266. }
  50267. this[_symbol_utils.$extra] = null;
  50268. }
  50269. return this[_symbol_utils.$extra];
  50270. }
  50271. [_symbol_utils.$toHTML](availableSpace) {
  50272. const obj = this[_symbol_utils.$getExtra]();
  50273. if (obj) {
  50274. return obj[_symbol_utils.$toHTML](availableSpace);
  50275. }
  50276. return _utils.HTMLResult.EMPTY;
  50277. }
  50278. }
  50279. class Validate extends _xfa_object.XFAObject {
  50280. constructor(attributes) {
  50281. super(TEMPLATE_NS_ID, "validate", true);
  50282. this.formatTest = (0, _utils.getStringOption)(attributes.formatTest, ["warning", "disabled", "error"]);
  50283. this.id = attributes.id || "";
  50284. this.nullTest = (0, _utils.getStringOption)(attributes.nullTest, ["disabled", "error", "warning"]);
  50285. this.scriptTest = (0, _utils.getStringOption)(attributes.scriptTest, ["error", "disabled", "warning"]);
  50286. this.use = attributes.use || "";
  50287. this.usehref = attributes.usehref || "";
  50288. this.extras = null;
  50289. this.message = null;
  50290. this.picture = null;
  50291. this.script = null;
  50292. }
  50293. }
  50294. class Value extends _xfa_object.XFAObject {
  50295. constructor(attributes) {
  50296. super(TEMPLATE_NS_ID, "value", true);
  50297. this.id = attributes.id || "";
  50298. this.override = (0, _utils.getInteger)({
  50299. data: attributes.override,
  50300. defaultValue: 0,
  50301. validate: x => x === 1
  50302. });
  50303. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  50304. this.use = attributes.use || "";
  50305. this.usehref = attributes.usehref || "";
  50306. this.arc = null;
  50307. this.boolean = null;
  50308. this.date = null;
  50309. this.dateTime = null;
  50310. this.decimal = null;
  50311. this.exData = null;
  50312. this.float = null;
  50313. this.image = null;
  50314. this.integer = null;
  50315. this.line = null;
  50316. this.rectangle = null;
  50317. this.text = null;
  50318. this.time = null;
  50319. }
  50320. [_symbol_utils.$setValue](value) {
  50321. const parent = this[_symbol_utils.$getParent]();
  50322. if (parent instanceof Field) {
  50323. if (parent.ui?.imageEdit) {
  50324. if (!this.image) {
  50325. this.image = new Image({});
  50326. this[_symbol_utils.$appendChild](this.image);
  50327. }
  50328. this.image[_symbol_utils.$content] = value[_symbol_utils.$content];
  50329. return;
  50330. }
  50331. }
  50332. const valueName = value[_symbol_utils.$nodeName];
  50333. if (this[valueName] !== null) {
  50334. this[valueName][_symbol_utils.$content] = value[_symbol_utils.$content];
  50335. return;
  50336. }
  50337. for (const name of Object.getOwnPropertyNames(this)) {
  50338. const obj = this[name];
  50339. if (obj instanceof _xfa_object.XFAObject) {
  50340. this[name] = null;
  50341. this[_symbol_utils.$removeChild](obj);
  50342. }
  50343. }
  50344. this[value[_symbol_utils.$nodeName]] = value;
  50345. this[_symbol_utils.$appendChild](value);
  50346. }
  50347. [_symbol_utils.$text]() {
  50348. if (this.exData) {
  50349. if (typeof this.exData[_symbol_utils.$content] === "string") {
  50350. return this.exData[_symbol_utils.$content].trim();
  50351. }
  50352. return this.exData[_symbol_utils.$content][_symbol_utils.$text]().trim();
  50353. }
  50354. for (const name of Object.getOwnPropertyNames(this)) {
  50355. if (name === "image") {
  50356. continue;
  50357. }
  50358. const obj = this[name];
  50359. if (obj instanceof _xfa_object.XFAObject) {
  50360. return (obj[_symbol_utils.$content] || "").toString().trim();
  50361. }
  50362. }
  50363. return null;
  50364. }
  50365. [_symbol_utils.$toHTML](availableSpace) {
  50366. for (const name of Object.getOwnPropertyNames(this)) {
  50367. const obj = this[name];
  50368. if (!(obj instanceof _xfa_object.XFAObject)) {
  50369. continue;
  50370. }
  50371. return obj[_symbol_utils.$toHTML](availableSpace);
  50372. }
  50373. return _utils.HTMLResult.EMPTY;
  50374. }
  50375. }
  50376. exports.Value = Value;
  50377. class Variables extends _xfa_object.XFAObject {
  50378. constructor(attributes) {
  50379. super(TEMPLATE_NS_ID, "variables", true);
  50380. this.id = attributes.id || "";
  50381. this.use = attributes.use || "";
  50382. this.usehref = attributes.usehref || "";
  50383. this.boolean = new _xfa_object.XFAObjectArray();
  50384. this.date = new _xfa_object.XFAObjectArray();
  50385. this.dateTime = new _xfa_object.XFAObjectArray();
  50386. this.decimal = new _xfa_object.XFAObjectArray();
  50387. this.exData = new _xfa_object.XFAObjectArray();
  50388. this.float = new _xfa_object.XFAObjectArray();
  50389. this.image = new _xfa_object.XFAObjectArray();
  50390. this.integer = new _xfa_object.XFAObjectArray();
  50391. this.manifest = new _xfa_object.XFAObjectArray();
  50392. this.script = new _xfa_object.XFAObjectArray();
  50393. this.text = new _xfa_object.XFAObjectArray();
  50394. this.time = new _xfa_object.XFAObjectArray();
  50395. }
  50396. [_symbol_utils.$isTransparent]() {
  50397. return true;
  50398. }
  50399. }
  50400. class TemplateNamespace {
  50401. static [_namespaces.$buildXFAObject](name, attributes) {
  50402. if (TemplateNamespace.hasOwnProperty(name)) {
  50403. const node = TemplateNamespace[name](attributes);
  50404. node[_symbol_utils.$setSetAttributes](attributes);
  50405. return node;
  50406. }
  50407. return undefined;
  50408. }
  50409. static appearanceFilter(attrs) {
  50410. return new AppearanceFilter(attrs);
  50411. }
  50412. static arc(attrs) {
  50413. return new Arc(attrs);
  50414. }
  50415. static area(attrs) {
  50416. return new Area(attrs);
  50417. }
  50418. static assist(attrs) {
  50419. return new Assist(attrs);
  50420. }
  50421. static barcode(attrs) {
  50422. return new Barcode(attrs);
  50423. }
  50424. static bind(attrs) {
  50425. return new Bind(attrs);
  50426. }
  50427. static bindItems(attrs) {
  50428. return new BindItems(attrs);
  50429. }
  50430. static bookend(attrs) {
  50431. return new Bookend(attrs);
  50432. }
  50433. static boolean(attrs) {
  50434. return new BooleanElement(attrs);
  50435. }
  50436. static border(attrs) {
  50437. return new Border(attrs);
  50438. }
  50439. static break(attrs) {
  50440. return new Break(attrs);
  50441. }
  50442. static breakAfter(attrs) {
  50443. return new BreakAfter(attrs);
  50444. }
  50445. static breakBefore(attrs) {
  50446. return new BreakBefore(attrs);
  50447. }
  50448. static button(attrs) {
  50449. return new Button(attrs);
  50450. }
  50451. static calculate(attrs) {
  50452. return new Calculate(attrs);
  50453. }
  50454. static caption(attrs) {
  50455. return new Caption(attrs);
  50456. }
  50457. static certificate(attrs) {
  50458. return new Certificate(attrs);
  50459. }
  50460. static certificates(attrs) {
  50461. return new Certificates(attrs);
  50462. }
  50463. static checkButton(attrs) {
  50464. return new CheckButton(attrs);
  50465. }
  50466. static choiceList(attrs) {
  50467. return new ChoiceList(attrs);
  50468. }
  50469. static color(attrs) {
  50470. return new Color(attrs);
  50471. }
  50472. static comb(attrs) {
  50473. return new Comb(attrs);
  50474. }
  50475. static connect(attrs) {
  50476. return new Connect(attrs);
  50477. }
  50478. static contentArea(attrs) {
  50479. return new ContentArea(attrs);
  50480. }
  50481. static corner(attrs) {
  50482. return new Corner(attrs);
  50483. }
  50484. static date(attrs) {
  50485. return new DateElement(attrs);
  50486. }
  50487. static dateTime(attrs) {
  50488. return new DateTime(attrs);
  50489. }
  50490. static dateTimeEdit(attrs) {
  50491. return new DateTimeEdit(attrs);
  50492. }
  50493. static decimal(attrs) {
  50494. return new Decimal(attrs);
  50495. }
  50496. static defaultUi(attrs) {
  50497. return new DefaultUi(attrs);
  50498. }
  50499. static desc(attrs) {
  50500. return new Desc(attrs);
  50501. }
  50502. static digestMethod(attrs) {
  50503. return new DigestMethod(attrs);
  50504. }
  50505. static digestMethods(attrs) {
  50506. return new DigestMethods(attrs);
  50507. }
  50508. static draw(attrs) {
  50509. return new Draw(attrs);
  50510. }
  50511. static edge(attrs) {
  50512. return new Edge(attrs);
  50513. }
  50514. static encoding(attrs) {
  50515. return new Encoding(attrs);
  50516. }
  50517. static encodings(attrs) {
  50518. return new Encodings(attrs);
  50519. }
  50520. static encrypt(attrs) {
  50521. return new Encrypt(attrs);
  50522. }
  50523. static encryptData(attrs) {
  50524. return new EncryptData(attrs);
  50525. }
  50526. static encryption(attrs) {
  50527. return new Encryption(attrs);
  50528. }
  50529. static encryptionMethod(attrs) {
  50530. return new EncryptionMethod(attrs);
  50531. }
  50532. static encryptionMethods(attrs) {
  50533. return new EncryptionMethods(attrs);
  50534. }
  50535. static event(attrs) {
  50536. return new Event(attrs);
  50537. }
  50538. static exData(attrs) {
  50539. return new ExData(attrs);
  50540. }
  50541. static exObject(attrs) {
  50542. return new ExObject(attrs);
  50543. }
  50544. static exclGroup(attrs) {
  50545. return new ExclGroup(attrs);
  50546. }
  50547. static execute(attrs) {
  50548. return new Execute(attrs);
  50549. }
  50550. static extras(attrs) {
  50551. return new Extras(attrs);
  50552. }
  50553. static field(attrs) {
  50554. return new Field(attrs);
  50555. }
  50556. static fill(attrs) {
  50557. return new Fill(attrs);
  50558. }
  50559. static filter(attrs) {
  50560. return new Filter(attrs);
  50561. }
  50562. static float(attrs) {
  50563. return new Float(attrs);
  50564. }
  50565. static font(attrs) {
  50566. return new Font(attrs);
  50567. }
  50568. static format(attrs) {
  50569. return new Format(attrs);
  50570. }
  50571. static handler(attrs) {
  50572. return new Handler(attrs);
  50573. }
  50574. static hyphenation(attrs) {
  50575. return new Hyphenation(attrs);
  50576. }
  50577. static image(attrs) {
  50578. return new Image(attrs);
  50579. }
  50580. static imageEdit(attrs) {
  50581. return new ImageEdit(attrs);
  50582. }
  50583. static integer(attrs) {
  50584. return new Integer(attrs);
  50585. }
  50586. static issuers(attrs) {
  50587. return new Issuers(attrs);
  50588. }
  50589. static items(attrs) {
  50590. return new Items(attrs);
  50591. }
  50592. static keep(attrs) {
  50593. return new Keep(attrs);
  50594. }
  50595. static keyUsage(attrs) {
  50596. return new KeyUsage(attrs);
  50597. }
  50598. static line(attrs) {
  50599. return new Line(attrs);
  50600. }
  50601. static linear(attrs) {
  50602. return new Linear(attrs);
  50603. }
  50604. static lockDocument(attrs) {
  50605. return new LockDocument(attrs);
  50606. }
  50607. static manifest(attrs) {
  50608. return new Manifest(attrs);
  50609. }
  50610. static margin(attrs) {
  50611. return new Margin(attrs);
  50612. }
  50613. static mdp(attrs) {
  50614. return new Mdp(attrs);
  50615. }
  50616. static medium(attrs) {
  50617. return new Medium(attrs);
  50618. }
  50619. static message(attrs) {
  50620. return new Message(attrs);
  50621. }
  50622. static numericEdit(attrs) {
  50623. return new NumericEdit(attrs);
  50624. }
  50625. static occur(attrs) {
  50626. return new Occur(attrs);
  50627. }
  50628. static oid(attrs) {
  50629. return new Oid(attrs);
  50630. }
  50631. static oids(attrs) {
  50632. return new Oids(attrs);
  50633. }
  50634. static overflow(attrs) {
  50635. return new Overflow(attrs);
  50636. }
  50637. static pageArea(attrs) {
  50638. return new PageArea(attrs);
  50639. }
  50640. static pageSet(attrs) {
  50641. return new PageSet(attrs);
  50642. }
  50643. static para(attrs) {
  50644. return new Para(attrs);
  50645. }
  50646. static passwordEdit(attrs) {
  50647. return new PasswordEdit(attrs);
  50648. }
  50649. static pattern(attrs) {
  50650. return new Pattern(attrs);
  50651. }
  50652. static picture(attrs) {
  50653. return new Picture(attrs);
  50654. }
  50655. static proto(attrs) {
  50656. return new Proto(attrs);
  50657. }
  50658. static radial(attrs) {
  50659. return new Radial(attrs);
  50660. }
  50661. static reason(attrs) {
  50662. return new Reason(attrs);
  50663. }
  50664. static reasons(attrs) {
  50665. return new Reasons(attrs);
  50666. }
  50667. static rectangle(attrs) {
  50668. return new Rectangle(attrs);
  50669. }
  50670. static ref(attrs) {
  50671. return new RefElement(attrs);
  50672. }
  50673. static script(attrs) {
  50674. return new Script(attrs);
  50675. }
  50676. static setProperty(attrs) {
  50677. return new SetProperty(attrs);
  50678. }
  50679. static signData(attrs) {
  50680. return new SignData(attrs);
  50681. }
  50682. static signature(attrs) {
  50683. return new Signature(attrs);
  50684. }
  50685. static signing(attrs) {
  50686. return new Signing(attrs);
  50687. }
  50688. static solid(attrs) {
  50689. return new Solid(attrs);
  50690. }
  50691. static speak(attrs) {
  50692. return new Speak(attrs);
  50693. }
  50694. static stipple(attrs) {
  50695. return new Stipple(attrs);
  50696. }
  50697. static subform(attrs) {
  50698. return new Subform(attrs);
  50699. }
  50700. static subformSet(attrs) {
  50701. return new SubformSet(attrs);
  50702. }
  50703. static subjectDN(attrs) {
  50704. return new SubjectDN(attrs);
  50705. }
  50706. static subjectDNs(attrs) {
  50707. return new SubjectDNs(attrs);
  50708. }
  50709. static submit(attrs) {
  50710. return new Submit(attrs);
  50711. }
  50712. static template(attrs) {
  50713. return new Template(attrs);
  50714. }
  50715. static text(attrs) {
  50716. return new Text(attrs);
  50717. }
  50718. static textEdit(attrs) {
  50719. return new TextEdit(attrs);
  50720. }
  50721. static time(attrs) {
  50722. return new Time(attrs);
  50723. }
  50724. static timeStamp(attrs) {
  50725. return new TimeStamp(attrs);
  50726. }
  50727. static toolTip(attrs) {
  50728. return new ToolTip(attrs);
  50729. }
  50730. static traversal(attrs) {
  50731. return new Traversal(attrs);
  50732. }
  50733. static traverse(attrs) {
  50734. return new Traverse(attrs);
  50735. }
  50736. static ui(attrs) {
  50737. return new Ui(attrs);
  50738. }
  50739. static validate(attrs) {
  50740. return new Validate(attrs);
  50741. }
  50742. static value(attrs) {
  50743. return new Value(attrs);
  50744. }
  50745. static variables(attrs) {
  50746. return new Variables(attrs);
  50747. }
  50748. }
  50749. exports.TemplateNamespace = TemplateNamespace;
  50750. /***/ }),
  50751. /* 81 */
  50752. /***/ ((__unused_webpack_module, exports) => {
  50753. Object.defineProperty(exports, "__esModule", ({
  50754. value: true
  50755. }));
  50756. exports.NamespaceIds = exports.$buildXFAObject = void 0;
  50757. const $buildXFAObject = Symbol();
  50758. exports.$buildXFAObject = $buildXFAObject;
  50759. const NamespaceIds = {
  50760. config: {
  50761. id: 0,
  50762. check: ns => ns.startsWith("http://www.xfa.org/schema/xci/")
  50763. },
  50764. connectionSet: {
  50765. id: 1,
  50766. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-connection-set/")
  50767. },
  50768. datasets: {
  50769. id: 2,
  50770. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-data/")
  50771. },
  50772. form: {
  50773. id: 3,
  50774. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-form/")
  50775. },
  50776. localeSet: {
  50777. id: 4,
  50778. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-locale-set/")
  50779. },
  50780. pdf: {
  50781. id: 5,
  50782. check: ns => ns === "http://ns.adobe.com/xdp/pdf/"
  50783. },
  50784. signature: {
  50785. id: 6,
  50786. check: ns => ns === "http://www.w3.org/2000/09/xmldsig#"
  50787. },
  50788. sourceSet: {
  50789. id: 7,
  50790. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-source-set/")
  50791. },
  50792. stylesheet: {
  50793. id: 8,
  50794. check: ns => ns === "http://www.w3.org/1999/XSL/Transform"
  50795. },
  50796. template: {
  50797. id: 9,
  50798. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-template/")
  50799. },
  50800. xdc: {
  50801. id: 10,
  50802. check: ns => ns.startsWith("http://www.xfa.org/schema/xdc/")
  50803. },
  50804. xdp: {
  50805. id: 11,
  50806. check: ns => ns === "http://ns.adobe.com/xdp/"
  50807. },
  50808. xfdf: {
  50809. id: 12,
  50810. check: ns => ns === "http://ns.adobe.com/xfdf/"
  50811. },
  50812. xhtml: {
  50813. id: 13,
  50814. check: ns => ns === "http://www.w3.org/1999/xhtml"
  50815. },
  50816. xmpmeta: {
  50817. id: 14,
  50818. check: ns => ns === "http://ns.adobe.com/xmpmeta/"
  50819. }
  50820. };
  50821. exports.NamespaceIds = NamespaceIds;
  50822. /***/ }),
  50823. /* 82 */
  50824. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  50825. Object.defineProperty(exports, "__esModule", ({
  50826. value: true
  50827. }));
  50828. exports.addHTML = addHTML;
  50829. exports.checkDimensions = checkDimensions;
  50830. exports.flushHTML = flushHTML;
  50831. exports.getAvailableSpace = getAvailableSpace;
  50832. var _symbol_utils = __w_pdfjs_require__(78);
  50833. var _html_utils = __w_pdfjs_require__(83);
  50834. function createLine(node, children) {
  50835. return {
  50836. name: "div",
  50837. attributes: {
  50838. class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"]
  50839. },
  50840. children
  50841. };
  50842. }
  50843. function flushHTML(node) {
  50844. if (!node[_symbol_utils.$extra]) {
  50845. return null;
  50846. }
  50847. const attributes = node[_symbol_utils.$extra].attributes;
  50848. const html = {
  50849. name: "div",
  50850. attributes,
  50851. children: node[_symbol_utils.$extra].children
  50852. };
  50853. if (node[_symbol_utils.$extra].failingNode) {
  50854. const htmlFromFailing = node[_symbol_utils.$extra].failingNode[_symbol_utils.$flushHTML]();
  50855. if (htmlFromFailing) {
  50856. if (node.layout.endsWith("-tb")) {
  50857. html.children.push(createLine(node, [htmlFromFailing]));
  50858. } else {
  50859. html.children.push(htmlFromFailing);
  50860. }
  50861. }
  50862. }
  50863. if (html.children.length === 0) {
  50864. return null;
  50865. }
  50866. return html;
  50867. }
  50868. function addHTML(node, html, bbox) {
  50869. const extra = node[_symbol_utils.$extra];
  50870. const availableSpace = extra.availableSpace;
  50871. const [x, y, w, h] = bbox;
  50872. switch (node.layout) {
  50873. case "position":
  50874. {
  50875. extra.width = Math.max(extra.width, x + w);
  50876. extra.height = Math.max(extra.height, y + h);
  50877. extra.children.push(html);
  50878. break;
  50879. }
  50880. case "lr-tb":
  50881. case "rl-tb":
  50882. if (!extra.line || extra.attempt === 1) {
  50883. extra.line = createLine(node, []);
  50884. extra.children.push(extra.line);
  50885. extra.numberInLine = 0;
  50886. }
  50887. extra.numberInLine += 1;
  50888. extra.line.children.push(html);
  50889. if (extra.attempt === 0) {
  50890. extra.currentWidth += w;
  50891. extra.height = Math.max(extra.height, extra.prevHeight + h);
  50892. } else {
  50893. extra.currentWidth = w;
  50894. extra.prevHeight = extra.height;
  50895. extra.height += h;
  50896. extra.attempt = 0;
  50897. }
  50898. extra.width = Math.max(extra.width, extra.currentWidth);
  50899. break;
  50900. case "rl-row":
  50901. case "row":
  50902. {
  50903. extra.children.push(html);
  50904. extra.width += w;
  50905. extra.height = Math.max(extra.height, h);
  50906. const height = (0, _html_utils.measureToString)(extra.height);
  50907. for (const child of extra.children) {
  50908. child.attributes.style.height = height;
  50909. }
  50910. break;
  50911. }
  50912. case "table":
  50913. {
  50914. extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
  50915. extra.height += h;
  50916. extra.children.push(html);
  50917. break;
  50918. }
  50919. case "tb":
  50920. {
  50921. extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
  50922. extra.height += h;
  50923. extra.children.push(html);
  50924. break;
  50925. }
  50926. }
  50927. }
  50928. function getAvailableSpace(node) {
  50929. const availableSpace = node[_symbol_utils.$extra].availableSpace;
  50930. const marginV = node.margin ? node.margin.topInset + node.margin.bottomInset : 0;
  50931. const marginH = node.margin ? node.margin.leftInset + node.margin.rightInset : 0;
  50932. switch (node.layout) {
  50933. case "lr-tb":
  50934. case "rl-tb":
  50935. if (node[_symbol_utils.$extra].attempt === 0) {
  50936. return {
  50937. width: availableSpace.width - marginH - node[_symbol_utils.$extra].currentWidth,
  50938. height: availableSpace.height - marginV - node[_symbol_utils.$extra].prevHeight
  50939. };
  50940. }
  50941. return {
  50942. width: availableSpace.width - marginH,
  50943. height: availableSpace.height - marginV - node[_symbol_utils.$extra].height
  50944. };
  50945. case "rl-row":
  50946. case "row":
  50947. const width = node[_symbol_utils.$extra].columnWidths.slice(node[_symbol_utils.$extra].currentColumn).reduce((a, x) => a + x);
  50948. return {
  50949. width,
  50950. height: availableSpace.height - marginH
  50951. };
  50952. case "table":
  50953. case "tb":
  50954. return {
  50955. width: availableSpace.width - marginH,
  50956. height: availableSpace.height - marginV - node[_symbol_utils.$extra].height
  50957. };
  50958. case "position":
  50959. default:
  50960. return availableSpace;
  50961. }
  50962. }
  50963. function getTransformedBBox(node) {
  50964. let w = node.w === "" ? NaN : node.w;
  50965. let h = node.h === "" ? NaN : node.h;
  50966. let [centerX, centerY] = [0, 0];
  50967. switch (node.anchorType || "") {
  50968. case "bottomCenter":
  50969. [centerX, centerY] = [w / 2, h];
  50970. break;
  50971. case "bottomLeft":
  50972. [centerX, centerY] = [0, h];
  50973. break;
  50974. case "bottomRight":
  50975. [centerX, centerY] = [w, h];
  50976. break;
  50977. case "middleCenter":
  50978. [centerX, centerY] = [w / 2, h / 2];
  50979. break;
  50980. case "middleLeft":
  50981. [centerX, centerY] = [0, h / 2];
  50982. break;
  50983. case "middleRight":
  50984. [centerX, centerY] = [w, h / 2];
  50985. break;
  50986. case "topCenter":
  50987. [centerX, centerY] = [w / 2, 0];
  50988. break;
  50989. case "topRight":
  50990. [centerX, centerY] = [w, 0];
  50991. break;
  50992. }
  50993. let x, y;
  50994. switch (node.rotate || 0) {
  50995. case 0:
  50996. [x, y] = [-centerX, -centerY];
  50997. break;
  50998. case 90:
  50999. [x, y] = [-centerY, centerX];
  51000. [w, h] = [h, -w];
  51001. break;
  51002. case 180:
  51003. [x, y] = [centerX, centerY];
  51004. [w, h] = [-w, -h];
  51005. break;
  51006. case 270:
  51007. [x, y] = [centerY, -centerX];
  51008. [w, h] = [-h, w];
  51009. break;
  51010. }
  51011. return [node.x + x + Math.min(0, w), node.y + y + Math.min(0, h), Math.abs(w), Math.abs(h)];
  51012. }
  51013. function checkDimensions(node, space) {
  51014. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].firstUnsplittable === null) {
  51015. return true;
  51016. }
  51017. if (node.w === 0 || node.h === 0) {
  51018. return true;
  51019. }
  51020. const ERROR = 2;
  51021. const parent = node[_symbol_utils.$getSubformParent]();
  51022. const attempt = parent[_symbol_utils.$extra]?.attempt || 0;
  51023. const [, y, w, h] = getTransformedBBox(node);
  51024. switch (parent.layout) {
  51025. case "lr-tb":
  51026. case "rl-tb":
  51027. if (attempt === 0) {
  51028. if (!node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51029. if (node.h !== "" && Math.round(h - space.height) > ERROR) {
  51030. return false;
  51031. }
  51032. if (node.w !== "") {
  51033. if (Math.round(w - space.width) <= ERROR) {
  51034. return true;
  51035. }
  51036. if (parent[_symbol_utils.$extra].numberInLine === 0) {
  51037. return space.height > ERROR;
  51038. }
  51039. return false;
  51040. }
  51041. return space.width > ERROR;
  51042. }
  51043. if (node.w !== "") {
  51044. return Math.round(w - space.width) <= ERROR;
  51045. }
  51046. return space.width > ERROR;
  51047. }
  51048. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51049. return true;
  51050. }
  51051. if (node.h !== "" && Math.round(h - space.height) > ERROR) {
  51052. return false;
  51053. }
  51054. if (node.w === "" || Math.round(w - space.width) <= ERROR) {
  51055. return space.height > ERROR;
  51056. }
  51057. if (parent[_symbol_utils.$isThereMoreWidth]()) {
  51058. return false;
  51059. }
  51060. return space.height > ERROR;
  51061. case "table":
  51062. case "tb":
  51063. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51064. return true;
  51065. }
  51066. if (node.h !== "" && !node[_symbol_utils.$isSplittable]()) {
  51067. return Math.round(h - space.height) <= ERROR;
  51068. }
  51069. if (node.w === "" || Math.round(w - space.width) <= ERROR) {
  51070. return space.height > ERROR;
  51071. }
  51072. if (parent[_symbol_utils.$isThereMoreWidth]()) {
  51073. return false;
  51074. }
  51075. return space.height > ERROR;
  51076. case "position":
  51077. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51078. return true;
  51079. }
  51080. if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
  51081. return true;
  51082. }
  51083. const area = node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].currentContentArea;
  51084. return h + y > area.h;
  51085. case "rl-row":
  51086. case "row":
  51087. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51088. return true;
  51089. }
  51090. if (node.h !== "") {
  51091. return Math.round(h - space.height) <= ERROR;
  51092. }
  51093. return true;
  51094. default:
  51095. return true;
  51096. }
  51097. }
  51098. /***/ }),
  51099. /* 83 */
  51100. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  51101. Object.defineProperty(exports, "__esModule", ({
  51102. value: true
  51103. }));
  51104. exports.computeBbox = computeBbox;
  51105. exports.createWrapper = createWrapper;
  51106. exports.fixDimensions = fixDimensions;
  51107. exports.fixTextIndent = fixTextIndent;
  51108. exports.fixURL = fixURL;
  51109. exports.isPrintOnly = isPrintOnly;
  51110. exports.layoutClass = layoutClass;
  51111. exports.layoutNode = layoutNode;
  51112. exports.measureToString = measureToString;
  51113. exports.setAccess = setAccess;
  51114. exports.setFontFamily = setFontFamily;
  51115. exports.setMinMaxDimensions = setMinMaxDimensions;
  51116. exports.setPara = setPara;
  51117. exports.toStyle = toStyle;
  51118. var _symbol_utils = __w_pdfjs_require__(78);
  51119. var _util = __w_pdfjs_require__(2);
  51120. var _utils = __w_pdfjs_require__(84);
  51121. var _fonts = __w_pdfjs_require__(85);
  51122. var _text = __w_pdfjs_require__(86);
  51123. var _xfa_object = __w_pdfjs_require__(87);
  51124. function measureToString(m) {
  51125. if (typeof m === "string") {
  51126. return "0px";
  51127. }
  51128. return Number.isInteger(m) ? `${m}px` : `${m.toFixed(2)}px`;
  51129. }
  51130. const converters = {
  51131. anchorType(node, style) {
  51132. const parent = node[_symbol_utils.$getSubformParent]();
  51133. if (!parent || parent.layout && parent.layout !== "position") {
  51134. return;
  51135. }
  51136. if (!("transform" in style)) {
  51137. style.transform = "";
  51138. }
  51139. switch (node.anchorType) {
  51140. case "bottomCenter":
  51141. style.transform += "translate(-50%, -100%)";
  51142. break;
  51143. case "bottomLeft":
  51144. style.transform += "translate(0,-100%)";
  51145. break;
  51146. case "bottomRight":
  51147. style.transform += "translate(-100%,-100%)";
  51148. break;
  51149. case "middleCenter":
  51150. style.transform += "translate(-50%,-50%)";
  51151. break;
  51152. case "middleLeft":
  51153. style.transform += "translate(0,-50%)";
  51154. break;
  51155. case "middleRight":
  51156. style.transform += "translate(-100%,-50%)";
  51157. break;
  51158. case "topCenter":
  51159. style.transform += "translate(-50%,0)";
  51160. break;
  51161. case "topRight":
  51162. style.transform += "translate(-100%,0)";
  51163. break;
  51164. }
  51165. },
  51166. dimensions(node, style) {
  51167. const parent = node[_symbol_utils.$getSubformParent]();
  51168. let width = node.w;
  51169. const height = node.h;
  51170. if (parent.layout?.includes("row")) {
  51171. const extra = parent[_symbol_utils.$extra];
  51172. const colSpan = node.colSpan;
  51173. let w;
  51174. if (colSpan === -1) {
  51175. w = extra.columnWidths.slice(extra.currentColumn).reduce((a, x) => a + x, 0);
  51176. extra.currentColumn = 0;
  51177. } else {
  51178. w = extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan).reduce((a, x) => a + x, 0);
  51179. extra.currentColumn = (extra.currentColumn + node.colSpan) % extra.columnWidths.length;
  51180. }
  51181. if (!isNaN(w)) {
  51182. width = node.w = w;
  51183. }
  51184. }
  51185. style.width = width !== "" ? measureToString(width) : "auto";
  51186. style.height = height !== "" ? measureToString(height) : "auto";
  51187. },
  51188. position(node, style) {
  51189. const parent = node[_symbol_utils.$getSubformParent]();
  51190. if (parent?.layout && parent.layout !== "position") {
  51191. return;
  51192. }
  51193. style.position = "absolute";
  51194. style.left = measureToString(node.x);
  51195. style.top = measureToString(node.y);
  51196. },
  51197. rotate(node, style) {
  51198. if (node.rotate) {
  51199. if (!("transform" in style)) {
  51200. style.transform = "";
  51201. }
  51202. style.transform += `rotate(-${node.rotate}deg)`;
  51203. style.transformOrigin = "top left";
  51204. }
  51205. },
  51206. presence(node, style) {
  51207. switch (node.presence) {
  51208. case "invisible":
  51209. style.visibility = "hidden";
  51210. break;
  51211. case "hidden":
  51212. case "inactive":
  51213. style.display = "none";
  51214. break;
  51215. }
  51216. },
  51217. hAlign(node, style) {
  51218. if (node[_symbol_utils.$nodeName] === "para") {
  51219. switch (node.hAlign) {
  51220. case "justifyAll":
  51221. style.textAlign = "justify-all";
  51222. break;
  51223. case "radix":
  51224. style.textAlign = "left";
  51225. break;
  51226. default:
  51227. style.textAlign = node.hAlign;
  51228. }
  51229. } else {
  51230. switch (node.hAlign) {
  51231. case "left":
  51232. style.alignSelf = "start";
  51233. break;
  51234. case "center":
  51235. style.alignSelf = "center";
  51236. break;
  51237. case "right":
  51238. style.alignSelf = "end";
  51239. break;
  51240. }
  51241. }
  51242. },
  51243. margin(node, style) {
  51244. if (node.margin) {
  51245. style.margin = node.margin[_symbol_utils.$toStyle]().margin;
  51246. }
  51247. }
  51248. };
  51249. function setMinMaxDimensions(node, style) {
  51250. const parent = node[_symbol_utils.$getSubformParent]();
  51251. if (parent.layout === "position") {
  51252. if (node.minW > 0) {
  51253. style.minWidth = measureToString(node.minW);
  51254. }
  51255. if (node.maxW > 0) {
  51256. style.maxWidth = measureToString(node.maxW);
  51257. }
  51258. if (node.minH > 0) {
  51259. style.minHeight = measureToString(node.minH);
  51260. }
  51261. if (node.maxH > 0) {
  51262. style.maxHeight = measureToString(node.maxH);
  51263. }
  51264. }
  51265. }
  51266. function layoutText(text, xfaFont, margin, lineHeight, fontFinder, width) {
  51267. const measure = new _text.TextMeasure(xfaFont, margin, lineHeight, fontFinder);
  51268. if (typeof text === "string") {
  51269. measure.addString(text);
  51270. } else {
  51271. text[_symbol_utils.$pushGlyphs](measure);
  51272. }
  51273. return measure.compute(width);
  51274. }
  51275. function layoutNode(node, availableSpace) {
  51276. let height = null;
  51277. let width = null;
  51278. let isBroken = false;
  51279. if ((!node.w || !node.h) && node.value) {
  51280. let marginH = 0;
  51281. let marginV = 0;
  51282. if (node.margin) {
  51283. marginH = node.margin.leftInset + node.margin.rightInset;
  51284. marginV = node.margin.topInset + node.margin.bottomInset;
  51285. }
  51286. let lineHeight = null;
  51287. let margin = null;
  51288. if (node.para) {
  51289. margin = Object.create(null);
  51290. lineHeight = node.para.lineHeight === "" ? null : node.para.lineHeight;
  51291. margin.top = node.para.spaceAbove === "" ? 0 : node.para.spaceAbove;
  51292. margin.bottom = node.para.spaceBelow === "" ? 0 : node.para.spaceBelow;
  51293. margin.left = node.para.marginLeft === "" ? 0 : node.para.marginLeft;
  51294. margin.right = node.para.marginRight === "" ? 0 : node.para.marginRight;
  51295. }
  51296. let font = node.font;
  51297. if (!font) {
  51298. const root = node[_symbol_utils.$getTemplateRoot]();
  51299. let parent = node[_symbol_utils.$getParent]();
  51300. while (parent && parent !== root) {
  51301. if (parent.font) {
  51302. font = parent.font;
  51303. break;
  51304. }
  51305. parent = parent[_symbol_utils.$getParent]();
  51306. }
  51307. }
  51308. const maxWidth = (node.w || availableSpace.width) - marginH;
  51309. const fontFinder = node[_symbol_utils.$globalData].fontFinder;
  51310. if (node.value.exData && node.value.exData[_symbol_utils.$content] && node.value.exData.contentType === "text/html") {
  51311. const res = layoutText(node.value.exData[_symbol_utils.$content], font, margin, lineHeight, fontFinder, maxWidth);
  51312. width = res.width;
  51313. height = res.height;
  51314. isBroken = res.isBroken;
  51315. } else {
  51316. const text = node.value[_symbol_utils.$text]();
  51317. if (text) {
  51318. const res = layoutText(text, font, margin, lineHeight, fontFinder, maxWidth);
  51319. width = res.width;
  51320. height = res.height;
  51321. isBroken = res.isBroken;
  51322. }
  51323. }
  51324. if (width !== null && !node.w) {
  51325. width += marginH;
  51326. }
  51327. if (height !== null && !node.h) {
  51328. height += marginV;
  51329. }
  51330. }
  51331. return {
  51332. w: width,
  51333. h: height,
  51334. isBroken
  51335. };
  51336. }
  51337. function computeBbox(node, html, availableSpace) {
  51338. let bbox;
  51339. if (node.w !== "" && node.h !== "") {
  51340. bbox = [node.x, node.y, node.w, node.h];
  51341. } else {
  51342. if (!availableSpace) {
  51343. return null;
  51344. }
  51345. let width = node.w;
  51346. if (width === "") {
  51347. if (node.maxW === 0) {
  51348. const parent = node[_symbol_utils.$getSubformParent]();
  51349. width = parent.layout === "position" && parent.w !== "" ? 0 : node.minW;
  51350. } else {
  51351. width = Math.min(node.maxW, availableSpace.width);
  51352. }
  51353. html.attributes.style.width = measureToString(width);
  51354. }
  51355. let height = node.h;
  51356. if (height === "") {
  51357. if (node.maxH === 0) {
  51358. const parent = node[_symbol_utils.$getSubformParent]();
  51359. height = parent.layout === "position" && parent.h !== "" ? 0 : node.minH;
  51360. } else {
  51361. height = Math.min(node.maxH, availableSpace.height);
  51362. }
  51363. html.attributes.style.height = measureToString(height);
  51364. }
  51365. bbox = [node.x, node.y, width, height];
  51366. }
  51367. return bbox;
  51368. }
  51369. function fixDimensions(node) {
  51370. const parent = node[_symbol_utils.$getSubformParent]();
  51371. if (parent.layout?.includes("row")) {
  51372. const extra = parent[_symbol_utils.$extra];
  51373. const colSpan = node.colSpan;
  51374. let width;
  51375. if (colSpan === -1) {
  51376. width = extra.columnWidths.slice(extra.currentColumn).reduce((a, w) => a + w, 0);
  51377. } else {
  51378. width = extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan).reduce((a, w) => a + w, 0);
  51379. }
  51380. if (!isNaN(width)) {
  51381. node.w = width;
  51382. }
  51383. }
  51384. if (parent.layout && parent.layout !== "position") {
  51385. node.x = node.y = 0;
  51386. }
  51387. if (node.layout === "table") {
  51388. if (node.w === "" && Array.isArray(node.columnWidths)) {
  51389. node.w = node.columnWidths.reduce((a, x) => a + x, 0);
  51390. }
  51391. }
  51392. }
  51393. function layoutClass(node) {
  51394. switch (node.layout) {
  51395. case "position":
  51396. return "xfaPosition";
  51397. case "lr-tb":
  51398. return "xfaLrTb";
  51399. case "rl-row":
  51400. return "xfaRlRow";
  51401. case "rl-tb":
  51402. return "xfaRlTb";
  51403. case "row":
  51404. return "xfaRow";
  51405. case "table":
  51406. return "xfaTable";
  51407. case "tb":
  51408. return "xfaTb";
  51409. default:
  51410. return "xfaPosition";
  51411. }
  51412. }
  51413. function toStyle(node, ...names) {
  51414. const style = Object.create(null);
  51415. for (const name of names) {
  51416. const value = node[name];
  51417. if (value === null) {
  51418. continue;
  51419. }
  51420. if (converters.hasOwnProperty(name)) {
  51421. converters[name](node, style);
  51422. continue;
  51423. }
  51424. if (value instanceof _xfa_object.XFAObject) {
  51425. const newStyle = value[_symbol_utils.$toStyle]();
  51426. if (newStyle) {
  51427. Object.assign(style, newStyle);
  51428. } else {
  51429. (0, _util.warn)(`(DEBUG) - XFA - style for ${name} not implemented yet`);
  51430. }
  51431. }
  51432. }
  51433. return style;
  51434. }
  51435. function createWrapper(node, html) {
  51436. const {
  51437. attributes
  51438. } = html;
  51439. const {
  51440. style
  51441. } = attributes;
  51442. const wrapper = {
  51443. name: "div",
  51444. attributes: {
  51445. class: ["xfaWrapper"],
  51446. style: Object.create(null)
  51447. },
  51448. children: []
  51449. };
  51450. attributes.class.push("xfaWrapped");
  51451. if (node.border) {
  51452. const {
  51453. widths,
  51454. insets
  51455. } = node.border[_symbol_utils.$extra];
  51456. let width, height;
  51457. let top = insets[0];
  51458. let left = insets[3];
  51459. const insetsH = insets[0] + insets[2];
  51460. const insetsW = insets[1] + insets[3];
  51461. switch (node.border.hand) {
  51462. case "even":
  51463. top -= widths[0] / 2;
  51464. left -= widths[3] / 2;
  51465. width = `calc(100% + ${(widths[1] + widths[3]) / 2 - insetsW}px)`;
  51466. height = `calc(100% + ${(widths[0] + widths[2]) / 2 - insetsH}px)`;
  51467. break;
  51468. case "left":
  51469. top -= widths[0];
  51470. left -= widths[3];
  51471. width = `calc(100% + ${widths[1] + widths[3] - insetsW}px)`;
  51472. height = `calc(100% + ${widths[0] + widths[2] - insetsH}px)`;
  51473. break;
  51474. case "right":
  51475. width = insetsW ? `calc(100% - ${insetsW}px)` : "100%";
  51476. height = insetsH ? `calc(100% - ${insetsH}px)` : "100%";
  51477. break;
  51478. }
  51479. const classNames = ["xfaBorder"];
  51480. if (isPrintOnly(node.border)) {
  51481. classNames.push("xfaPrintOnly");
  51482. }
  51483. const border = {
  51484. name: "div",
  51485. attributes: {
  51486. class: classNames,
  51487. style: {
  51488. top: `${top}px`,
  51489. left: `${left}px`,
  51490. width,
  51491. height
  51492. }
  51493. },
  51494. children: []
  51495. };
  51496. for (const key of ["border", "borderWidth", "borderColor", "borderRadius", "borderStyle"]) {
  51497. if (style[key] !== undefined) {
  51498. border.attributes.style[key] = style[key];
  51499. delete style[key];
  51500. }
  51501. }
  51502. wrapper.children.push(border, html);
  51503. } else {
  51504. wrapper.children.push(html);
  51505. }
  51506. for (const key of ["background", "backgroundClip", "top", "left", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "transform", "transformOrigin", "visibility"]) {
  51507. if (style[key] !== undefined) {
  51508. wrapper.attributes.style[key] = style[key];
  51509. delete style[key];
  51510. }
  51511. }
  51512. wrapper.attributes.style.position = style.position === "absolute" ? "absolute" : "relative";
  51513. delete style.position;
  51514. if (style.alignSelf) {
  51515. wrapper.attributes.style.alignSelf = style.alignSelf;
  51516. delete style.alignSelf;
  51517. }
  51518. return wrapper;
  51519. }
  51520. function fixTextIndent(styles) {
  51521. const indent = (0, _utils.getMeasurement)(styles.textIndent, "0px");
  51522. if (indent >= 0) {
  51523. return;
  51524. }
  51525. const align = styles.textAlign === "right" ? "right" : "left";
  51526. const name = "padding" + (align === "left" ? "Left" : "Right");
  51527. const padding = (0, _utils.getMeasurement)(styles[name], "0px");
  51528. styles[name] = `${padding - indent}px`;
  51529. }
  51530. function setAccess(node, classNames) {
  51531. switch (node.access) {
  51532. case "nonInteractive":
  51533. classNames.push("xfaNonInteractive");
  51534. break;
  51535. case "readOnly":
  51536. classNames.push("xfaReadOnly");
  51537. break;
  51538. case "protected":
  51539. classNames.push("xfaDisabled");
  51540. break;
  51541. }
  51542. }
  51543. function isPrintOnly(node) {
  51544. return node.relevant.length > 0 && !node.relevant[0].excluded && node.relevant[0].viewname === "print";
  51545. }
  51546. function getCurrentPara(node) {
  51547. const stack = node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack;
  51548. return stack.length ? stack.at(-1) : null;
  51549. }
  51550. function setPara(node, nodeStyle, value) {
  51551. if (value.attributes.class?.includes("xfaRich")) {
  51552. if (nodeStyle) {
  51553. if (node.h === "") {
  51554. nodeStyle.height = "auto";
  51555. }
  51556. if (node.w === "") {
  51557. nodeStyle.width = "auto";
  51558. }
  51559. }
  51560. const para = getCurrentPara(node);
  51561. if (para) {
  51562. const valueStyle = value.attributes.style;
  51563. valueStyle.display = "flex";
  51564. valueStyle.flexDirection = "column";
  51565. switch (para.vAlign) {
  51566. case "top":
  51567. valueStyle.justifyContent = "start";
  51568. break;
  51569. case "bottom":
  51570. valueStyle.justifyContent = "end";
  51571. break;
  51572. case "middle":
  51573. valueStyle.justifyContent = "center";
  51574. break;
  51575. }
  51576. const paraStyle = para[_symbol_utils.$toStyle]();
  51577. for (const [key, val] of Object.entries(paraStyle)) {
  51578. if (!(key in valueStyle)) {
  51579. valueStyle[key] = val;
  51580. }
  51581. }
  51582. }
  51583. }
  51584. }
  51585. function setFontFamily(xfaFont, node, fontFinder, style) {
  51586. if (!fontFinder) {
  51587. delete style.fontFamily;
  51588. return;
  51589. }
  51590. const name = (0, _utils.stripQuotes)(xfaFont.typeface);
  51591. style.fontFamily = `"${name}"`;
  51592. const typeface = fontFinder.find(name);
  51593. if (typeface) {
  51594. const {
  51595. fontFamily
  51596. } = typeface.regular.cssFontInfo;
  51597. if (fontFamily !== name) {
  51598. style.fontFamily = `"${fontFamily}"`;
  51599. }
  51600. const para = getCurrentPara(node);
  51601. if (para && para.lineHeight !== "") {
  51602. return;
  51603. }
  51604. if (style.lineHeight) {
  51605. return;
  51606. }
  51607. const pdfFont = (0, _fonts.selectFont)(xfaFont, typeface);
  51608. if (pdfFont) {
  51609. style.lineHeight = Math.max(1.2, pdfFont.lineHeight);
  51610. }
  51611. }
  51612. }
  51613. function fixURL(str) {
  51614. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(str, null, {
  51615. addDefaultProtocol: true,
  51616. tryConvertEncoding: true
  51617. });
  51618. return absoluteUrl ? absoluteUrl.href : null;
  51619. }
  51620. /***/ }),
  51621. /* 84 */
  51622. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  51623. Object.defineProperty(exports, "__esModule", ({
  51624. value: true
  51625. }));
  51626. exports.HTMLResult = void 0;
  51627. exports.getBBox = getBBox;
  51628. exports.getColor = getColor;
  51629. exports.getFloat = getFloat;
  51630. exports.getInteger = getInteger;
  51631. exports.getKeyword = getKeyword;
  51632. exports.getMeasurement = getMeasurement;
  51633. exports.getRatio = getRatio;
  51634. exports.getRelevant = getRelevant;
  51635. exports.getStringOption = getStringOption;
  51636. exports.stripQuotes = stripQuotes;
  51637. var _util = __w_pdfjs_require__(2);
  51638. const dimConverters = {
  51639. pt: x => x,
  51640. cm: x => x / 2.54 * 72,
  51641. mm: x => x / (10 * 2.54) * 72,
  51642. in: x => x * 72,
  51643. px: x => x
  51644. };
  51645. const measurementPattern = /([+-]?\d+\.?\d*)(.*)/;
  51646. function stripQuotes(str) {
  51647. if (str.startsWith("'") || str.startsWith('"')) {
  51648. return str.slice(1, -1);
  51649. }
  51650. return str;
  51651. }
  51652. function getInteger({
  51653. data,
  51654. defaultValue,
  51655. validate
  51656. }) {
  51657. if (!data) {
  51658. return defaultValue;
  51659. }
  51660. data = data.trim();
  51661. const n = parseInt(data, 10);
  51662. if (!isNaN(n) && validate(n)) {
  51663. return n;
  51664. }
  51665. return defaultValue;
  51666. }
  51667. function getFloat({
  51668. data,
  51669. defaultValue,
  51670. validate
  51671. }) {
  51672. if (!data) {
  51673. return defaultValue;
  51674. }
  51675. data = data.trim();
  51676. const n = parseFloat(data);
  51677. if (!isNaN(n) && validate(n)) {
  51678. return n;
  51679. }
  51680. return defaultValue;
  51681. }
  51682. function getKeyword({
  51683. data,
  51684. defaultValue,
  51685. validate
  51686. }) {
  51687. if (!data) {
  51688. return defaultValue;
  51689. }
  51690. data = data.trim();
  51691. if (validate(data)) {
  51692. return data;
  51693. }
  51694. return defaultValue;
  51695. }
  51696. function getStringOption(data, options) {
  51697. return getKeyword({
  51698. data,
  51699. defaultValue: options[0],
  51700. validate: k => options.includes(k)
  51701. });
  51702. }
  51703. function getMeasurement(str, def = "0") {
  51704. def ||= "0";
  51705. if (!str) {
  51706. return getMeasurement(def);
  51707. }
  51708. const match = str.trim().match(measurementPattern);
  51709. if (!match) {
  51710. return getMeasurement(def);
  51711. }
  51712. const [, valueStr, unit] = match;
  51713. const value = parseFloat(valueStr);
  51714. if (isNaN(value)) {
  51715. return getMeasurement(def);
  51716. }
  51717. if (value === 0) {
  51718. return 0;
  51719. }
  51720. const conv = dimConverters[unit];
  51721. if (conv) {
  51722. return conv(value);
  51723. }
  51724. return value;
  51725. }
  51726. function getRatio(data) {
  51727. if (!data) {
  51728. return {
  51729. num: 1,
  51730. den: 1
  51731. };
  51732. }
  51733. const ratio = data.trim().split(/\s*:\s*/).map(x => parseFloat(x)).filter(x => !isNaN(x));
  51734. if (ratio.length === 1) {
  51735. ratio.push(1);
  51736. }
  51737. if (ratio.length === 0) {
  51738. return {
  51739. num: 1,
  51740. den: 1
  51741. };
  51742. }
  51743. const [num, den] = ratio;
  51744. return {
  51745. num,
  51746. den
  51747. };
  51748. }
  51749. function getRelevant(data) {
  51750. if (!data) {
  51751. return [];
  51752. }
  51753. return data.trim().split(/\s+/).map(e => {
  51754. return {
  51755. excluded: e[0] === "-",
  51756. viewname: e.substring(1)
  51757. };
  51758. });
  51759. }
  51760. function getColor(data, def = [0, 0, 0]) {
  51761. let [r, g, b] = def;
  51762. if (!data) {
  51763. return {
  51764. r,
  51765. g,
  51766. b
  51767. };
  51768. }
  51769. const color = data.trim().split(/\s*,\s*/).map(c => Math.min(Math.max(0, parseInt(c.trim(), 10)), 255)).map(c => isNaN(c) ? 0 : c);
  51770. if (color.length < 3) {
  51771. return {
  51772. r,
  51773. g,
  51774. b
  51775. };
  51776. }
  51777. [r, g, b] = color;
  51778. return {
  51779. r,
  51780. g,
  51781. b
  51782. };
  51783. }
  51784. function getBBox(data) {
  51785. const def = -1;
  51786. if (!data) {
  51787. return {
  51788. x: def,
  51789. y: def,
  51790. width: def,
  51791. height: def
  51792. };
  51793. }
  51794. const bbox = data.trim().split(/\s*,\s*/).map(m => getMeasurement(m, "-1"));
  51795. if (bbox.length < 4 || bbox[2] < 0 || bbox[3] < 0) {
  51796. return {
  51797. x: def,
  51798. y: def,
  51799. width: def,
  51800. height: def
  51801. };
  51802. }
  51803. const [x, y, width, height] = bbox;
  51804. return {
  51805. x,
  51806. y,
  51807. width,
  51808. height
  51809. };
  51810. }
  51811. class HTMLResult {
  51812. static get FAILURE() {
  51813. return (0, _util.shadow)(this, "FAILURE", new HTMLResult(false, null, null, null));
  51814. }
  51815. static get EMPTY() {
  51816. return (0, _util.shadow)(this, "EMPTY", new HTMLResult(true, null, null, null));
  51817. }
  51818. constructor(success, html, bbox, breakNode) {
  51819. this.success = success;
  51820. this.html = html;
  51821. this.bbox = bbox;
  51822. this.breakNode = breakNode;
  51823. }
  51824. isBreak() {
  51825. return !!this.breakNode;
  51826. }
  51827. static breakNode(node) {
  51828. return new HTMLResult(false, null, null, node);
  51829. }
  51830. static success(html, bbox = null) {
  51831. return new HTMLResult(true, html, bbox, null);
  51832. }
  51833. }
  51834. exports.HTMLResult = HTMLResult;
  51835. /***/ }),
  51836. /* 85 */
  51837. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  51838. Object.defineProperty(exports, "__esModule", ({
  51839. value: true
  51840. }));
  51841. exports.FontFinder = void 0;
  51842. exports.getMetrics = getMetrics;
  51843. exports.selectFont = selectFont;
  51844. var _symbol_utils = __w_pdfjs_require__(78);
  51845. var _utils = __w_pdfjs_require__(84);
  51846. var _util = __w_pdfjs_require__(2);
  51847. class FontFinder {
  51848. constructor(pdfFonts) {
  51849. this.fonts = new Map();
  51850. this.cache = new Map();
  51851. this.warned = new Set();
  51852. this.defaultFont = null;
  51853. this.add(pdfFonts);
  51854. }
  51855. add(pdfFonts, reallyMissingFonts = null) {
  51856. for (const pdfFont of pdfFonts) {
  51857. this.addPdfFont(pdfFont);
  51858. }
  51859. for (const pdfFont of this.fonts.values()) {
  51860. if (!pdfFont.regular) {
  51861. pdfFont.regular = pdfFont.italic || pdfFont.bold || pdfFont.bolditalic;
  51862. }
  51863. }
  51864. if (!reallyMissingFonts || reallyMissingFonts.size === 0) {
  51865. return;
  51866. }
  51867. const myriad = this.fonts.get("PdfJS-Fallback-PdfJS-XFA");
  51868. for (const missing of reallyMissingFonts) {
  51869. this.fonts.set(missing, myriad);
  51870. }
  51871. }
  51872. addPdfFont(pdfFont) {
  51873. const cssFontInfo = pdfFont.cssFontInfo;
  51874. const name = cssFontInfo.fontFamily;
  51875. let font = this.fonts.get(name);
  51876. if (!font) {
  51877. font = Object.create(null);
  51878. this.fonts.set(name, font);
  51879. if (!this.defaultFont) {
  51880. this.defaultFont = font;
  51881. }
  51882. }
  51883. let property = "";
  51884. const fontWeight = parseFloat(cssFontInfo.fontWeight);
  51885. if (parseFloat(cssFontInfo.italicAngle) !== 0) {
  51886. property = fontWeight >= 700 ? "bolditalic" : "italic";
  51887. } else if (fontWeight >= 700) {
  51888. property = "bold";
  51889. }
  51890. if (!property) {
  51891. if (pdfFont.name.includes("Bold") || pdfFont.psName?.includes("Bold")) {
  51892. property = "bold";
  51893. }
  51894. if (pdfFont.name.includes("Italic") || pdfFont.name.endsWith("It") || pdfFont.psName?.includes("Italic") || pdfFont.psName?.endsWith("It")) {
  51895. property += "italic";
  51896. }
  51897. }
  51898. if (!property) {
  51899. property = "regular";
  51900. }
  51901. font[property] = pdfFont;
  51902. }
  51903. getDefault() {
  51904. return this.defaultFont;
  51905. }
  51906. find(fontName, mustWarn = true) {
  51907. let font = this.fonts.get(fontName) || this.cache.get(fontName);
  51908. if (font) {
  51909. return font;
  51910. }
  51911. const pattern = /,|-|_| |bolditalic|bold|italic|regular|it/gi;
  51912. let name = fontName.replaceAll(pattern, "");
  51913. font = this.fonts.get(name);
  51914. if (font) {
  51915. this.cache.set(fontName, font);
  51916. return font;
  51917. }
  51918. name = name.toLowerCase();
  51919. const maybe = [];
  51920. for (const [family, pdfFont] of this.fonts.entries()) {
  51921. if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  51922. maybe.push(pdfFont);
  51923. }
  51924. }
  51925. if (maybe.length === 0) {
  51926. for (const [, pdfFont] of this.fonts.entries()) {
  51927. if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  51928. maybe.push(pdfFont);
  51929. }
  51930. }
  51931. }
  51932. if (maybe.length === 0) {
  51933. name = name.replaceAll(/psmt|mt/gi, "");
  51934. for (const [family, pdfFont] of this.fonts.entries()) {
  51935. if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  51936. maybe.push(pdfFont);
  51937. }
  51938. }
  51939. }
  51940. if (maybe.length === 0) {
  51941. for (const pdfFont of this.fonts.values()) {
  51942. if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  51943. maybe.push(pdfFont);
  51944. }
  51945. }
  51946. }
  51947. if (maybe.length >= 1) {
  51948. if (maybe.length !== 1 && mustWarn) {
  51949. (0, _util.warn)(`XFA - Too many choices to guess the correct font: ${fontName}`);
  51950. }
  51951. this.cache.set(fontName, maybe[0]);
  51952. return maybe[0];
  51953. }
  51954. if (mustWarn && !this.warned.has(fontName)) {
  51955. this.warned.add(fontName);
  51956. (0, _util.warn)(`XFA - Cannot find the font: ${fontName}`);
  51957. }
  51958. return null;
  51959. }
  51960. }
  51961. exports.FontFinder = FontFinder;
  51962. function selectFont(xfaFont, typeface) {
  51963. if (xfaFont.posture === "italic") {
  51964. if (xfaFont.weight === "bold") {
  51965. return typeface.bolditalic;
  51966. }
  51967. return typeface.italic;
  51968. } else if (xfaFont.weight === "bold") {
  51969. return typeface.bold;
  51970. }
  51971. return typeface.regular;
  51972. }
  51973. function getMetrics(xfaFont, real = false) {
  51974. let pdfFont = null;
  51975. if (xfaFont) {
  51976. const name = (0, _utils.stripQuotes)(xfaFont.typeface);
  51977. const typeface = xfaFont[_symbol_utils.$globalData].fontFinder.find(name);
  51978. pdfFont = selectFont(xfaFont, typeface);
  51979. }
  51980. if (!pdfFont) {
  51981. return {
  51982. lineHeight: 12,
  51983. lineGap: 2,
  51984. lineNoGap: 10
  51985. };
  51986. }
  51987. const size = xfaFont.size || 10;
  51988. const lineHeight = pdfFont.lineHeight ? Math.max(real ? 0 : 1.2, pdfFont.lineHeight) : 1.2;
  51989. const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
  51990. return {
  51991. lineHeight: lineHeight * size,
  51992. lineGap: lineGap * size,
  51993. lineNoGap: Math.max(1, lineHeight - lineGap) * size
  51994. };
  51995. }
  51996. /***/ }),
  51997. /* 86 */
  51998. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  51999. Object.defineProperty(exports, "__esModule", ({
  52000. value: true
  52001. }));
  52002. exports.TextMeasure = void 0;
  52003. var _fonts = __w_pdfjs_require__(85);
  52004. const WIDTH_FACTOR = 1.02;
  52005. class FontInfo {
  52006. constructor(xfaFont, margin, lineHeight, fontFinder) {
  52007. this.lineHeight = lineHeight;
  52008. this.paraMargin = margin || {
  52009. top: 0,
  52010. bottom: 0,
  52011. left: 0,
  52012. right: 0
  52013. };
  52014. if (!xfaFont) {
  52015. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  52016. return;
  52017. }
  52018. this.xfaFont = {
  52019. typeface: xfaFont.typeface,
  52020. posture: xfaFont.posture,
  52021. weight: xfaFont.weight,
  52022. size: xfaFont.size,
  52023. letterSpacing: xfaFont.letterSpacing
  52024. };
  52025. const typeface = fontFinder.find(xfaFont.typeface);
  52026. if (!typeface) {
  52027. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  52028. return;
  52029. }
  52030. this.pdfFont = (0, _fonts.selectFont)(xfaFont, typeface);
  52031. if (!this.pdfFont) {
  52032. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  52033. }
  52034. }
  52035. defaultFont(fontFinder) {
  52036. const font = fontFinder.find("Helvetica", false) || fontFinder.find("Myriad Pro", false) || fontFinder.find("Arial", false) || fontFinder.getDefault();
  52037. if (font?.regular) {
  52038. const pdfFont = font.regular;
  52039. const info = pdfFont.cssFontInfo;
  52040. const xfaFont = {
  52041. typeface: info.fontFamily,
  52042. posture: "normal",
  52043. weight: "normal",
  52044. size: 10,
  52045. letterSpacing: 0
  52046. };
  52047. return [pdfFont, xfaFont];
  52048. }
  52049. const xfaFont = {
  52050. typeface: "Courier",
  52051. posture: "normal",
  52052. weight: "normal",
  52053. size: 10,
  52054. letterSpacing: 0
  52055. };
  52056. return [null, xfaFont];
  52057. }
  52058. }
  52059. class FontSelector {
  52060. constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder) {
  52061. this.fontFinder = fontFinder;
  52062. this.stack = [new FontInfo(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder)];
  52063. }
  52064. pushData(xfaFont, margin, lineHeight) {
  52065. const lastFont = this.stack.at(-1);
  52066. for (const name of ["typeface", "posture", "weight", "size", "letterSpacing"]) {
  52067. if (!xfaFont[name]) {
  52068. xfaFont[name] = lastFont.xfaFont[name];
  52069. }
  52070. }
  52071. for (const name of ["top", "bottom", "left", "right"]) {
  52072. if (isNaN(margin[name])) {
  52073. margin[name] = lastFont.paraMargin[name];
  52074. }
  52075. }
  52076. const fontInfo = new FontInfo(xfaFont, margin, lineHeight || lastFont.lineHeight, this.fontFinder);
  52077. if (!fontInfo.pdfFont) {
  52078. fontInfo.pdfFont = lastFont.pdfFont;
  52079. }
  52080. this.stack.push(fontInfo);
  52081. }
  52082. popFont() {
  52083. this.stack.pop();
  52084. }
  52085. topFont() {
  52086. return this.stack.at(-1);
  52087. }
  52088. }
  52089. class TextMeasure {
  52090. constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts) {
  52091. this.glyphs = [];
  52092. this.fontSelector = new FontSelector(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts);
  52093. this.extraHeight = 0;
  52094. }
  52095. pushData(xfaFont, margin, lineHeight) {
  52096. this.fontSelector.pushData(xfaFont, margin, lineHeight);
  52097. }
  52098. popFont(xfaFont) {
  52099. return this.fontSelector.popFont();
  52100. }
  52101. addPara() {
  52102. const lastFont = this.fontSelector.topFont();
  52103. this.extraHeight += lastFont.paraMargin.top + lastFont.paraMargin.bottom;
  52104. }
  52105. addString(str) {
  52106. if (!str) {
  52107. return;
  52108. }
  52109. const lastFont = this.fontSelector.topFont();
  52110. const fontSize = lastFont.xfaFont.size;
  52111. if (lastFont.pdfFont) {
  52112. const letterSpacing = lastFont.xfaFont.letterSpacing;
  52113. const pdfFont = lastFont.pdfFont;
  52114. const fontLineHeight = pdfFont.lineHeight || 1.2;
  52115. const lineHeight = lastFont.lineHeight || Math.max(1.2, fontLineHeight) * fontSize;
  52116. const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
  52117. const noGap = fontLineHeight - lineGap;
  52118. const firstLineHeight = Math.max(1, noGap) * fontSize;
  52119. const scale = fontSize / 1000;
  52120. const fallbackWidth = pdfFont.defaultWidth || pdfFont.charsToGlyphs(" ")[0].width;
  52121. for (const line of str.split(/[\u2029\n]/)) {
  52122. const encodedLine = pdfFont.encodeString(line).join("");
  52123. const glyphs = pdfFont.charsToGlyphs(encodedLine);
  52124. for (const glyph of glyphs) {
  52125. const width = glyph.width || fallbackWidth;
  52126. this.glyphs.push([width * scale + letterSpacing, lineHeight, firstLineHeight, glyph.unicode, false]);
  52127. }
  52128. this.glyphs.push([0, 0, 0, "\n", true]);
  52129. }
  52130. this.glyphs.pop();
  52131. return;
  52132. }
  52133. for (const line of str.split(/[\u2029\n]/)) {
  52134. for (const char of line.split("")) {
  52135. this.glyphs.push([fontSize, 1.2 * fontSize, fontSize, char, false]);
  52136. }
  52137. this.glyphs.push([0, 0, 0, "\n", true]);
  52138. }
  52139. this.glyphs.pop();
  52140. }
  52141. compute(maxWidth) {
  52142. let lastSpacePos = -1,
  52143. lastSpaceWidth = 0,
  52144. width = 0,
  52145. height = 0,
  52146. currentLineWidth = 0,
  52147. currentLineHeight = 0;
  52148. let isBroken = false;
  52149. let isFirstLine = true;
  52150. for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
  52151. const [glyphWidth, lineHeight, firstLineHeight, char, isEOL] = this.glyphs[i];
  52152. const isSpace = char === " ";
  52153. const glyphHeight = isFirstLine ? firstLineHeight : lineHeight;
  52154. if (isEOL) {
  52155. width = Math.max(width, currentLineWidth);
  52156. currentLineWidth = 0;
  52157. height += currentLineHeight;
  52158. currentLineHeight = glyphHeight;
  52159. lastSpacePos = -1;
  52160. lastSpaceWidth = 0;
  52161. isFirstLine = false;
  52162. continue;
  52163. }
  52164. if (isSpace) {
  52165. if (currentLineWidth + glyphWidth > maxWidth) {
  52166. width = Math.max(width, currentLineWidth);
  52167. currentLineWidth = 0;
  52168. height += currentLineHeight;
  52169. currentLineHeight = glyphHeight;
  52170. lastSpacePos = -1;
  52171. lastSpaceWidth = 0;
  52172. isBroken = true;
  52173. isFirstLine = false;
  52174. } else {
  52175. currentLineHeight = Math.max(glyphHeight, currentLineHeight);
  52176. lastSpaceWidth = currentLineWidth;
  52177. currentLineWidth += glyphWidth;
  52178. lastSpacePos = i;
  52179. }
  52180. continue;
  52181. }
  52182. if (currentLineWidth + glyphWidth > maxWidth) {
  52183. height += currentLineHeight;
  52184. currentLineHeight = glyphHeight;
  52185. if (lastSpacePos !== -1) {
  52186. i = lastSpacePos;
  52187. width = Math.max(width, lastSpaceWidth);
  52188. currentLineWidth = 0;
  52189. lastSpacePos = -1;
  52190. lastSpaceWidth = 0;
  52191. } else {
  52192. width = Math.max(width, currentLineWidth);
  52193. currentLineWidth = glyphWidth;
  52194. }
  52195. isBroken = true;
  52196. isFirstLine = false;
  52197. continue;
  52198. }
  52199. currentLineWidth += glyphWidth;
  52200. currentLineHeight = Math.max(glyphHeight, currentLineHeight);
  52201. }
  52202. width = Math.max(width, currentLineWidth);
  52203. height += currentLineHeight + this.extraHeight;
  52204. return {
  52205. width: WIDTH_FACTOR * width,
  52206. height,
  52207. isBroken
  52208. };
  52209. }
  52210. }
  52211. exports.TextMeasure = TextMeasure;
  52212. /***/ }),
  52213. /* 87 */
  52214. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  52215. Object.defineProperty(exports, "__esModule", ({
  52216. value: true
  52217. }));
  52218. exports.XmlObject = exports.XFAObjectArray = exports.XFAObject = exports.XFAAttribute = exports.StringObject = exports.OptionObject = exports.Option10 = exports.Option01 = exports.IntegerObject = exports.ContentObject = void 0;
  52219. var _symbol_utils = __w_pdfjs_require__(78);
  52220. var _utils = __w_pdfjs_require__(84);
  52221. var _util = __w_pdfjs_require__(2);
  52222. var _core_utils = __w_pdfjs_require__(3);
  52223. var _namespaces = __w_pdfjs_require__(81);
  52224. var _som = __w_pdfjs_require__(88);
  52225. const _applyPrototype = Symbol();
  52226. const _attributes = Symbol();
  52227. const _attributeNames = Symbol();
  52228. const _children = Symbol("_children");
  52229. const _cloneAttribute = Symbol();
  52230. const _dataValue = Symbol();
  52231. const _defaultValue = Symbol();
  52232. const _filteredChildrenGenerator = Symbol();
  52233. const _getPrototype = Symbol();
  52234. const _getUnsetAttributes = Symbol();
  52235. const _hasChildren = Symbol();
  52236. const _max = Symbol();
  52237. const _options = Symbol();
  52238. const _parent = Symbol("parent");
  52239. const _resolvePrototypesHelper = Symbol();
  52240. const _setAttributes = Symbol();
  52241. const _validator = Symbol();
  52242. let uid = 0;
  52243. const NS_DATASETS = _namespaces.NamespaceIds.datasets.id;
  52244. class XFAObject {
  52245. constructor(nsId, name, hasChildren = false) {
  52246. this[_symbol_utils.$namespaceId] = nsId;
  52247. this[_symbol_utils.$nodeName] = name;
  52248. this[_hasChildren] = hasChildren;
  52249. this[_parent] = null;
  52250. this[_children] = [];
  52251. this[_symbol_utils.$uid] = `${name}${uid++}`;
  52252. this[_symbol_utils.$globalData] = null;
  52253. }
  52254. get isXFAObject() {
  52255. return true;
  52256. }
  52257. get isXFAObjectArray() {
  52258. return false;
  52259. }
  52260. createNodes(path) {
  52261. let root = this,
  52262. node = null;
  52263. for (const {
  52264. name,
  52265. index
  52266. } of path) {
  52267. for (let i = 0, ii = isFinite(index) ? index : 0; i <= ii; i++) {
  52268. const nsId = root[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : root[_symbol_utils.$namespaceId];
  52269. node = new XmlObject(nsId, name);
  52270. root[_symbol_utils.$appendChild](node);
  52271. }
  52272. root = node;
  52273. }
  52274. return node;
  52275. }
  52276. [_symbol_utils.$onChild](child) {
  52277. if (!this[_hasChildren] || !this[_symbol_utils.$onChildCheck](child)) {
  52278. return false;
  52279. }
  52280. const name = child[_symbol_utils.$nodeName];
  52281. const node = this[name];
  52282. if (node instanceof XFAObjectArray) {
  52283. if (node.push(child)) {
  52284. this[_symbol_utils.$appendChild](child);
  52285. return true;
  52286. }
  52287. } else {
  52288. if (node !== null) {
  52289. this[_symbol_utils.$removeChild](node);
  52290. }
  52291. this[name] = child;
  52292. this[_symbol_utils.$appendChild](child);
  52293. return true;
  52294. }
  52295. let id = "";
  52296. if (this.id) {
  52297. id = ` (id: ${this.id})`;
  52298. } else if (this.name) {
  52299. id = ` (name: ${this.name} ${this.h.value})`;
  52300. }
  52301. (0, _util.warn)(`XFA - node "${this[_symbol_utils.$nodeName]}"${id} has already enough "${name}"!`);
  52302. return false;
  52303. }
  52304. [_symbol_utils.$onChildCheck](child) {
  52305. return this.hasOwnProperty(child[_symbol_utils.$nodeName]) && child[_symbol_utils.$namespaceId] === this[_symbol_utils.$namespaceId];
  52306. }
  52307. [_symbol_utils.$isNsAgnostic]() {
  52308. return false;
  52309. }
  52310. [_symbol_utils.$acceptWhitespace]() {
  52311. return false;
  52312. }
  52313. [_symbol_utils.$isCDATAXml]() {
  52314. return false;
  52315. }
  52316. [_symbol_utils.$isBindable]() {
  52317. return false;
  52318. }
  52319. [_symbol_utils.$popPara]() {
  52320. if (this.para) {
  52321. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack.pop();
  52322. }
  52323. }
  52324. [_symbol_utils.$pushPara]() {
  52325. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack.push(this.para);
  52326. }
  52327. [_symbol_utils.$setId](ids) {
  52328. if (this.id && this[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.template.id) {
  52329. ids.set(this.id, this);
  52330. }
  52331. }
  52332. [_symbol_utils.$getTemplateRoot]() {
  52333. return this[_symbol_utils.$globalData].template;
  52334. }
  52335. [_symbol_utils.$isSplittable]() {
  52336. return false;
  52337. }
  52338. [_symbol_utils.$isThereMoreWidth]() {
  52339. return false;
  52340. }
  52341. [_symbol_utils.$appendChild](child) {
  52342. child[_parent] = this;
  52343. this[_children].push(child);
  52344. if (!child[_symbol_utils.$globalData] && this[_symbol_utils.$globalData]) {
  52345. child[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  52346. }
  52347. }
  52348. [_symbol_utils.$removeChild](child) {
  52349. const i = this[_children].indexOf(child);
  52350. this[_children].splice(i, 1);
  52351. }
  52352. [_symbol_utils.$hasSettableValue]() {
  52353. return this.hasOwnProperty("value");
  52354. }
  52355. [_symbol_utils.$setValue](_) {}
  52356. [_symbol_utils.$onText](_) {}
  52357. [_symbol_utils.$finalize]() {}
  52358. [_symbol_utils.$clean](builder) {
  52359. delete this[_hasChildren];
  52360. if (this[_symbol_utils.$cleanup]) {
  52361. builder.clean(this[_symbol_utils.$cleanup]);
  52362. delete this[_symbol_utils.$cleanup];
  52363. }
  52364. }
  52365. [_symbol_utils.$indexOf](child) {
  52366. return this[_children].indexOf(child);
  52367. }
  52368. [_symbol_utils.$insertAt](i, child) {
  52369. child[_parent] = this;
  52370. this[_children].splice(i, 0, child);
  52371. if (!child[_symbol_utils.$globalData] && this[_symbol_utils.$globalData]) {
  52372. child[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  52373. }
  52374. }
  52375. [_symbol_utils.$isTransparent]() {
  52376. return !this.name;
  52377. }
  52378. [_symbol_utils.$lastAttribute]() {
  52379. return "";
  52380. }
  52381. [_symbol_utils.$text]() {
  52382. if (this[_children].length === 0) {
  52383. return this[_symbol_utils.$content];
  52384. }
  52385. return this[_children].map(c => c[_symbol_utils.$text]()).join("");
  52386. }
  52387. get [_attributeNames]() {
  52388. const proto = Object.getPrototypeOf(this);
  52389. if (!proto._attributes) {
  52390. const attributes = proto._attributes = new Set();
  52391. for (const name of Object.getOwnPropertyNames(this)) {
  52392. if (this[name] === null || this[name] instanceof XFAObject || this[name] instanceof XFAObjectArray) {
  52393. break;
  52394. }
  52395. attributes.add(name);
  52396. }
  52397. }
  52398. return (0, _util.shadow)(this, _attributeNames, proto._attributes);
  52399. }
  52400. [_symbol_utils.$isDescendent](parent) {
  52401. let node = this;
  52402. while (node) {
  52403. if (node === parent) {
  52404. return true;
  52405. }
  52406. node = node[_symbol_utils.$getParent]();
  52407. }
  52408. return false;
  52409. }
  52410. [_symbol_utils.$getParent]() {
  52411. return this[_parent];
  52412. }
  52413. [_symbol_utils.$getSubformParent]() {
  52414. return this[_symbol_utils.$getParent]();
  52415. }
  52416. [_symbol_utils.$getChildren](name = null) {
  52417. if (!name) {
  52418. return this[_children];
  52419. }
  52420. return this[name];
  52421. }
  52422. [_symbol_utils.$dump]() {
  52423. const dumped = Object.create(null);
  52424. if (this[_symbol_utils.$content]) {
  52425. dumped.$content = this[_symbol_utils.$content];
  52426. }
  52427. for (const name of Object.getOwnPropertyNames(this)) {
  52428. const value = this[name];
  52429. if (value === null) {
  52430. continue;
  52431. }
  52432. if (value instanceof XFAObject) {
  52433. dumped[name] = value[_symbol_utils.$dump]();
  52434. } else if (value instanceof XFAObjectArray) {
  52435. if (!value.isEmpty()) {
  52436. dumped[name] = value.dump();
  52437. }
  52438. } else {
  52439. dumped[name] = value;
  52440. }
  52441. }
  52442. return dumped;
  52443. }
  52444. [_symbol_utils.$toStyle]() {
  52445. return null;
  52446. }
  52447. [_symbol_utils.$toHTML]() {
  52448. return _utils.HTMLResult.EMPTY;
  52449. }
  52450. *[_symbol_utils.$getContainedChildren]() {
  52451. for (const node of this[_symbol_utils.$getChildren]()) {
  52452. yield node;
  52453. }
  52454. }
  52455. *[_filteredChildrenGenerator](filter, include) {
  52456. for (const node of this[_symbol_utils.$getContainedChildren]()) {
  52457. if (!filter || include === filter.has(node[_symbol_utils.$nodeName])) {
  52458. const availableSpace = this[_symbol_utils.$getAvailableSpace]();
  52459. const res = node[_symbol_utils.$toHTML](availableSpace);
  52460. if (!res.success) {
  52461. this[_symbol_utils.$extra].failingNode = node;
  52462. }
  52463. yield res;
  52464. }
  52465. }
  52466. }
  52467. [_symbol_utils.$flushHTML]() {
  52468. return null;
  52469. }
  52470. [_symbol_utils.$addHTML](html, bbox) {
  52471. this[_symbol_utils.$extra].children.push(html);
  52472. }
  52473. [_symbol_utils.$getAvailableSpace]() {}
  52474. [_symbol_utils.$childrenToHTML]({
  52475. filter = null,
  52476. include = true
  52477. }) {
  52478. if (!this[_symbol_utils.$extra].generator) {
  52479. this[_symbol_utils.$extra].generator = this[_filteredChildrenGenerator](filter, include);
  52480. } else {
  52481. const availableSpace = this[_symbol_utils.$getAvailableSpace]();
  52482. const res = this[_symbol_utils.$extra].failingNode[_symbol_utils.$toHTML](availableSpace);
  52483. if (!res.success) {
  52484. return res;
  52485. }
  52486. if (res.html) {
  52487. this[_symbol_utils.$addHTML](res.html, res.bbox);
  52488. }
  52489. delete this[_symbol_utils.$extra].failingNode;
  52490. }
  52491. while (true) {
  52492. const gen = this[_symbol_utils.$extra].generator.next();
  52493. if (gen.done) {
  52494. break;
  52495. }
  52496. const res = gen.value;
  52497. if (!res.success) {
  52498. return res;
  52499. }
  52500. if (res.html) {
  52501. this[_symbol_utils.$addHTML](res.html, res.bbox);
  52502. }
  52503. }
  52504. this[_symbol_utils.$extra].generator = null;
  52505. return _utils.HTMLResult.EMPTY;
  52506. }
  52507. [_symbol_utils.$setSetAttributes](attributes) {
  52508. this[_setAttributes] = new Set(Object.keys(attributes));
  52509. }
  52510. [_getUnsetAttributes](protoAttributes) {
  52511. const allAttr = this[_attributeNames];
  52512. const setAttr = this[_setAttributes];
  52513. return [...protoAttributes].filter(x => allAttr.has(x) && !setAttr.has(x));
  52514. }
  52515. [_symbol_utils.$resolvePrototypes](ids, ancestors = new Set()) {
  52516. for (const child of this[_children]) {
  52517. child[_resolvePrototypesHelper](ids, ancestors);
  52518. }
  52519. }
  52520. [_resolvePrototypesHelper](ids, ancestors) {
  52521. const proto = this[_getPrototype](ids, ancestors);
  52522. if (proto) {
  52523. this[_applyPrototype](proto, ids, ancestors);
  52524. } else {
  52525. this[_symbol_utils.$resolvePrototypes](ids, ancestors);
  52526. }
  52527. }
  52528. [_getPrototype](ids, ancestors) {
  52529. const {
  52530. use,
  52531. usehref
  52532. } = this;
  52533. if (!use && !usehref) {
  52534. return null;
  52535. }
  52536. let proto = null;
  52537. let somExpression = null;
  52538. let id = null;
  52539. let ref = use;
  52540. if (usehref) {
  52541. ref = usehref;
  52542. if (usehref.startsWith("#som(") && usehref.endsWith(")")) {
  52543. somExpression = usehref.slice("#som(".length, -1);
  52544. } else if (usehref.startsWith(".#som(") && usehref.endsWith(")")) {
  52545. somExpression = usehref.slice(".#som(".length, -1);
  52546. } else if (usehref.startsWith("#")) {
  52547. id = usehref.slice(1);
  52548. } else if (usehref.startsWith(".#")) {
  52549. id = usehref.slice(2);
  52550. }
  52551. } else if (use.startsWith("#")) {
  52552. id = use.slice(1);
  52553. } else {
  52554. somExpression = use;
  52555. }
  52556. this.use = this.usehref = "";
  52557. if (id) {
  52558. proto = ids.get(id);
  52559. } else {
  52560. proto = (0, _som.searchNode)(ids.get(_symbol_utils.$root), this, somExpression, true, false);
  52561. if (proto) {
  52562. proto = proto[0];
  52563. }
  52564. }
  52565. if (!proto) {
  52566. (0, _util.warn)(`XFA - Invalid prototype reference: ${ref}.`);
  52567. return null;
  52568. }
  52569. if (proto[_symbol_utils.$nodeName] !== this[_symbol_utils.$nodeName]) {
  52570. (0, _util.warn)(`XFA - Incompatible prototype: ${proto[_symbol_utils.$nodeName]} !== ${this[_symbol_utils.$nodeName]}.`);
  52571. return null;
  52572. }
  52573. if (ancestors.has(proto)) {
  52574. (0, _util.warn)(`XFA - Cycle detected in prototypes use.`);
  52575. return null;
  52576. }
  52577. ancestors.add(proto);
  52578. const protoProto = proto[_getPrototype](ids, ancestors);
  52579. if (protoProto) {
  52580. proto[_applyPrototype](protoProto, ids, ancestors);
  52581. }
  52582. proto[_symbol_utils.$resolvePrototypes](ids, ancestors);
  52583. ancestors.delete(proto);
  52584. return proto;
  52585. }
  52586. [_applyPrototype](proto, ids, ancestors) {
  52587. if (ancestors.has(proto)) {
  52588. (0, _util.warn)(`XFA - Cycle detected in prototypes use.`);
  52589. return;
  52590. }
  52591. if (!this[_symbol_utils.$content] && proto[_symbol_utils.$content]) {
  52592. this[_symbol_utils.$content] = proto[_symbol_utils.$content];
  52593. }
  52594. const newAncestors = new Set(ancestors);
  52595. newAncestors.add(proto);
  52596. for (const unsetAttrName of this[_getUnsetAttributes](proto[_setAttributes])) {
  52597. this[unsetAttrName] = proto[unsetAttrName];
  52598. if (this[_setAttributes]) {
  52599. this[_setAttributes].add(unsetAttrName);
  52600. }
  52601. }
  52602. for (const name of Object.getOwnPropertyNames(this)) {
  52603. if (this[_attributeNames].has(name)) {
  52604. continue;
  52605. }
  52606. const value = this[name];
  52607. const protoValue = proto[name];
  52608. if (value instanceof XFAObjectArray) {
  52609. for (const child of value[_children]) {
  52610. child[_resolvePrototypesHelper](ids, ancestors);
  52611. }
  52612. for (let i = value[_children].length, ii = protoValue[_children].length; i < ii; i++) {
  52613. const child = proto[_children][i][_symbol_utils.$clone]();
  52614. if (value.push(child)) {
  52615. child[_parent] = this;
  52616. this[_children].push(child);
  52617. child[_resolvePrototypesHelper](ids, ancestors);
  52618. } else {
  52619. break;
  52620. }
  52621. }
  52622. continue;
  52623. }
  52624. if (value !== null) {
  52625. value[_symbol_utils.$resolvePrototypes](ids, ancestors);
  52626. if (protoValue) {
  52627. value[_applyPrototype](protoValue, ids, ancestors);
  52628. }
  52629. continue;
  52630. }
  52631. if (protoValue !== null) {
  52632. const child = protoValue[_symbol_utils.$clone]();
  52633. child[_parent] = this;
  52634. this[name] = child;
  52635. this[_children].push(child);
  52636. child[_resolvePrototypesHelper](ids, ancestors);
  52637. }
  52638. }
  52639. }
  52640. static [_cloneAttribute](obj) {
  52641. if (Array.isArray(obj)) {
  52642. return obj.map(x => XFAObject[_cloneAttribute](x));
  52643. }
  52644. if (typeof obj === "object" && obj !== null) {
  52645. return Object.assign({}, obj);
  52646. }
  52647. return obj;
  52648. }
  52649. [_symbol_utils.$clone]() {
  52650. const clone = Object.create(Object.getPrototypeOf(this));
  52651. for (const $symbol of Object.getOwnPropertySymbols(this)) {
  52652. try {
  52653. clone[$symbol] = this[$symbol];
  52654. } catch {
  52655. (0, _util.shadow)(clone, $symbol, this[$symbol]);
  52656. }
  52657. }
  52658. clone[_symbol_utils.$uid] = `${clone[_symbol_utils.$nodeName]}${uid++}`;
  52659. clone[_children] = [];
  52660. for (const name of Object.getOwnPropertyNames(this)) {
  52661. if (this[_attributeNames].has(name)) {
  52662. clone[name] = XFAObject[_cloneAttribute](this[name]);
  52663. continue;
  52664. }
  52665. const value = this[name];
  52666. clone[name] = value instanceof XFAObjectArray ? new XFAObjectArray(value[_max]) : null;
  52667. }
  52668. for (const child of this[_children]) {
  52669. const name = child[_symbol_utils.$nodeName];
  52670. const clonedChild = child[_symbol_utils.$clone]();
  52671. clone[_children].push(clonedChild);
  52672. clonedChild[_parent] = clone;
  52673. if (clone[name] === null) {
  52674. clone[name] = clonedChild;
  52675. } else {
  52676. clone[name][_children].push(clonedChild);
  52677. }
  52678. }
  52679. return clone;
  52680. }
  52681. [_symbol_utils.$getChildren](name = null) {
  52682. if (!name) {
  52683. return this[_children];
  52684. }
  52685. return this[_children].filter(c => c[_symbol_utils.$nodeName] === name);
  52686. }
  52687. [_symbol_utils.$getChildrenByClass](name) {
  52688. return this[name];
  52689. }
  52690. [_symbol_utils.$getChildrenByName](name, allTransparent, first = true) {
  52691. return Array.from(this[_symbol_utils.$getChildrenByNameIt](name, allTransparent, first));
  52692. }
  52693. *[_symbol_utils.$getChildrenByNameIt](name, allTransparent, first = true) {
  52694. if (name === "parent") {
  52695. yield this[_parent];
  52696. return;
  52697. }
  52698. for (const child of this[_children]) {
  52699. if (child[_symbol_utils.$nodeName] === name) {
  52700. yield child;
  52701. }
  52702. if (child.name === name) {
  52703. yield child;
  52704. }
  52705. if (allTransparent || child[_symbol_utils.$isTransparent]()) {
  52706. yield* child[_symbol_utils.$getChildrenByNameIt](name, allTransparent, false);
  52707. }
  52708. }
  52709. if (first && this[_attributeNames].has(name)) {
  52710. yield new XFAAttribute(this, name, this[name]);
  52711. }
  52712. }
  52713. }
  52714. exports.XFAObject = XFAObject;
  52715. class XFAObjectArray {
  52716. constructor(max = Infinity) {
  52717. this[_max] = max;
  52718. this[_children] = [];
  52719. }
  52720. get isXFAObject() {
  52721. return false;
  52722. }
  52723. get isXFAObjectArray() {
  52724. return true;
  52725. }
  52726. push(child) {
  52727. const len = this[_children].length;
  52728. if (len <= this[_max]) {
  52729. this[_children].push(child);
  52730. return true;
  52731. }
  52732. (0, _util.warn)(`XFA - node "${child[_symbol_utils.$nodeName]}" accepts no more than ${this[_max]} children`);
  52733. return false;
  52734. }
  52735. isEmpty() {
  52736. return this[_children].length === 0;
  52737. }
  52738. dump() {
  52739. return this[_children].length === 1 ? this[_children][0][_symbol_utils.$dump]() : this[_children].map(x => x[_symbol_utils.$dump]());
  52740. }
  52741. [_symbol_utils.$clone]() {
  52742. const clone = new XFAObjectArray(this[_max]);
  52743. clone[_children] = this[_children].map(c => c[_symbol_utils.$clone]());
  52744. return clone;
  52745. }
  52746. get children() {
  52747. return this[_children];
  52748. }
  52749. clear() {
  52750. this[_children].length = 0;
  52751. }
  52752. }
  52753. exports.XFAObjectArray = XFAObjectArray;
  52754. class XFAAttribute {
  52755. constructor(node, name, value) {
  52756. this[_parent] = node;
  52757. this[_symbol_utils.$nodeName] = name;
  52758. this[_symbol_utils.$content] = value;
  52759. this[_symbol_utils.$consumed] = false;
  52760. this[_symbol_utils.$uid] = `attribute${uid++}`;
  52761. }
  52762. [_symbol_utils.$getParent]() {
  52763. return this[_parent];
  52764. }
  52765. [_symbol_utils.$isDataValue]() {
  52766. return true;
  52767. }
  52768. [_symbol_utils.$getDataValue]() {
  52769. return this[_symbol_utils.$content].trim();
  52770. }
  52771. [_symbol_utils.$setValue](value) {
  52772. value = value.value || "";
  52773. this[_symbol_utils.$content] = value.toString();
  52774. }
  52775. [_symbol_utils.$text]() {
  52776. return this[_symbol_utils.$content];
  52777. }
  52778. [_symbol_utils.$isDescendent](parent) {
  52779. return this[_parent] === parent || this[_parent][_symbol_utils.$isDescendent](parent);
  52780. }
  52781. }
  52782. exports.XFAAttribute = XFAAttribute;
  52783. class XmlObject extends XFAObject {
  52784. constructor(nsId, name, attributes = {}) {
  52785. super(nsId, name);
  52786. this[_symbol_utils.$content] = "";
  52787. this[_dataValue] = null;
  52788. if (name !== "#text") {
  52789. const map = new Map();
  52790. this[_attributes] = map;
  52791. for (const [attrName, value] of Object.entries(attributes)) {
  52792. map.set(attrName, new XFAAttribute(this, attrName, value));
  52793. }
  52794. if (attributes.hasOwnProperty(_symbol_utils.$nsAttributes)) {
  52795. const dataNode = attributes[_symbol_utils.$nsAttributes].xfa.dataNode;
  52796. if (dataNode !== undefined) {
  52797. if (dataNode === "dataGroup") {
  52798. this[_dataValue] = false;
  52799. } else if (dataNode === "dataValue") {
  52800. this[_dataValue] = true;
  52801. }
  52802. }
  52803. }
  52804. }
  52805. this[_symbol_utils.$consumed] = false;
  52806. }
  52807. [_symbol_utils.$toString](buf) {
  52808. const tagName = this[_symbol_utils.$nodeName];
  52809. if (tagName === "#text") {
  52810. buf.push((0, _core_utils.encodeToXmlString)(this[_symbol_utils.$content]));
  52811. return;
  52812. }
  52813. const utf8TagName = (0, _util.utf8StringToString)(tagName);
  52814. const prefix = this[_symbol_utils.$namespaceId] === NS_DATASETS ? "xfa:" : "";
  52815. buf.push(`<${prefix}${utf8TagName}`);
  52816. for (const [name, value] of this[_attributes].entries()) {
  52817. const utf8Name = (0, _util.utf8StringToString)(name);
  52818. buf.push(` ${utf8Name}="${(0, _core_utils.encodeToXmlString)(value[_symbol_utils.$content])}"`);
  52819. }
  52820. if (this[_dataValue] !== null) {
  52821. if (this[_dataValue]) {
  52822. buf.push(` xfa:dataNode="dataValue"`);
  52823. } else {
  52824. buf.push(` xfa:dataNode="dataGroup"`);
  52825. }
  52826. }
  52827. if (!this[_symbol_utils.$content] && this[_children].length === 0) {
  52828. buf.push("/>");
  52829. return;
  52830. }
  52831. buf.push(">");
  52832. if (this[_symbol_utils.$content]) {
  52833. if (typeof this[_symbol_utils.$content] === "string") {
  52834. buf.push((0, _core_utils.encodeToXmlString)(this[_symbol_utils.$content]));
  52835. } else {
  52836. this[_symbol_utils.$content][_symbol_utils.$toString](buf);
  52837. }
  52838. } else {
  52839. for (const child of this[_children]) {
  52840. child[_symbol_utils.$toString](buf);
  52841. }
  52842. }
  52843. buf.push(`</${prefix}${utf8TagName}>`);
  52844. }
  52845. [_symbol_utils.$onChild](child) {
  52846. if (this[_symbol_utils.$content]) {
  52847. const node = new XmlObject(this[_symbol_utils.$namespaceId], "#text");
  52848. this[_symbol_utils.$appendChild](node);
  52849. node[_symbol_utils.$content] = this[_symbol_utils.$content];
  52850. this[_symbol_utils.$content] = "";
  52851. }
  52852. this[_symbol_utils.$appendChild](child);
  52853. return true;
  52854. }
  52855. [_symbol_utils.$onText](str) {
  52856. this[_symbol_utils.$content] += str;
  52857. }
  52858. [_symbol_utils.$finalize]() {
  52859. if (this[_symbol_utils.$content] && this[_children].length > 0) {
  52860. const node = new XmlObject(this[_symbol_utils.$namespaceId], "#text");
  52861. this[_symbol_utils.$appendChild](node);
  52862. node[_symbol_utils.$content] = this[_symbol_utils.$content];
  52863. delete this[_symbol_utils.$content];
  52864. }
  52865. }
  52866. [_symbol_utils.$toHTML]() {
  52867. if (this[_symbol_utils.$nodeName] === "#text") {
  52868. return _utils.HTMLResult.success({
  52869. name: "#text",
  52870. value: this[_symbol_utils.$content]
  52871. });
  52872. }
  52873. return _utils.HTMLResult.EMPTY;
  52874. }
  52875. [_symbol_utils.$getChildren](name = null) {
  52876. if (!name) {
  52877. return this[_children];
  52878. }
  52879. return this[_children].filter(c => c[_symbol_utils.$nodeName] === name);
  52880. }
  52881. [_symbol_utils.$getAttributes]() {
  52882. return this[_attributes];
  52883. }
  52884. [_symbol_utils.$getChildrenByClass](name) {
  52885. const value = this[_attributes].get(name);
  52886. if (value !== undefined) {
  52887. return value;
  52888. }
  52889. return this[_symbol_utils.$getChildren](name);
  52890. }
  52891. *[_symbol_utils.$getChildrenByNameIt](name, allTransparent) {
  52892. const value = this[_attributes].get(name);
  52893. if (value) {
  52894. yield value;
  52895. }
  52896. for (const child of this[_children]) {
  52897. if (child[_symbol_utils.$nodeName] === name) {
  52898. yield child;
  52899. }
  52900. if (allTransparent) {
  52901. yield* child[_symbol_utils.$getChildrenByNameIt](name, allTransparent);
  52902. }
  52903. }
  52904. }
  52905. *[_symbol_utils.$getAttributeIt](name, skipConsumed) {
  52906. const value = this[_attributes].get(name);
  52907. if (value && (!skipConsumed || !value[_symbol_utils.$consumed])) {
  52908. yield value;
  52909. }
  52910. for (const child of this[_children]) {
  52911. yield* child[_symbol_utils.$getAttributeIt](name, skipConsumed);
  52912. }
  52913. }
  52914. *[_symbol_utils.$getRealChildrenByNameIt](name, allTransparent, skipConsumed) {
  52915. for (const child of this[_children]) {
  52916. if (child[_symbol_utils.$nodeName] === name && (!skipConsumed || !child[_symbol_utils.$consumed])) {
  52917. yield child;
  52918. }
  52919. if (allTransparent) {
  52920. yield* child[_symbol_utils.$getRealChildrenByNameIt](name, allTransparent, skipConsumed);
  52921. }
  52922. }
  52923. }
  52924. [_symbol_utils.$isDataValue]() {
  52925. if (this[_dataValue] === null) {
  52926. return this[_children].length === 0 || this[_children][0][_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id;
  52927. }
  52928. return this[_dataValue];
  52929. }
  52930. [_symbol_utils.$getDataValue]() {
  52931. if (this[_dataValue] === null) {
  52932. if (this[_children].length === 0) {
  52933. return this[_symbol_utils.$content].trim();
  52934. }
  52935. if (this[_children][0][_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  52936. return this[_children][0][_symbol_utils.$text]().trim();
  52937. }
  52938. return null;
  52939. }
  52940. return this[_symbol_utils.$content].trim();
  52941. }
  52942. [_symbol_utils.$setValue](value) {
  52943. value = value.value || "";
  52944. this[_symbol_utils.$content] = value.toString();
  52945. }
  52946. [_symbol_utils.$dump](hasNS = false) {
  52947. const dumped = Object.create(null);
  52948. if (hasNS) {
  52949. dumped.$ns = this[_symbol_utils.$namespaceId];
  52950. }
  52951. if (this[_symbol_utils.$content]) {
  52952. dumped.$content = this[_symbol_utils.$content];
  52953. }
  52954. dumped.$name = this[_symbol_utils.$nodeName];
  52955. dumped.children = [];
  52956. for (const child of this[_children]) {
  52957. dumped.children.push(child[_symbol_utils.$dump](hasNS));
  52958. }
  52959. dumped.attributes = Object.create(null);
  52960. for (const [name, value] of this[_attributes]) {
  52961. dumped.attributes[name] = value[_symbol_utils.$content];
  52962. }
  52963. return dumped;
  52964. }
  52965. }
  52966. exports.XmlObject = XmlObject;
  52967. class ContentObject extends XFAObject {
  52968. constructor(nsId, name) {
  52969. super(nsId, name);
  52970. this[_symbol_utils.$content] = "";
  52971. }
  52972. [_symbol_utils.$onText](text) {
  52973. this[_symbol_utils.$content] += text;
  52974. }
  52975. [_symbol_utils.$finalize]() {}
  52976. }
  52977. exports.ContentObject = ContentObject;
  52978. class OptionObject extends ContentObject {
  52979. constructor(nsId, name, options) {
  52980. super(nsId, name);
  52981. this[_options] = options;
  52982. }
  52983. [_symbol_utils.$finalize]() {
  52984. this[_symbol_utils.$content] = (0, _utils.getKeyword)({
  52985. data: this[_symbol_utils.$content],
  52986. defaultValue: this[_options][0],
  52987. validate: k => this[_options].includes(k)
  52988. });
  52989. }
  52990. [_symbol_utils.$clean](builder) {
  52991. super[_symbol_utils.$clean](builder);
  52992. delete this[_options];
  52993. }
  52994. }
  52995. exports.OptionObject = OptionObject;
  52996. class StringObject extends ContentObject {
  52997. [_symbol_utils.$finalize]() {
  52998. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  52999. }
  53000. }
  53001. exports.StringObject = StringObject;
  53002. class IntegerObject extends ContentObject {
  53003. constructor(nsId, name, defaultValue, validator) {
  53004. super(nsId, name);
  53005. this[_defaultValue] = defaultValue;
  53006. this[_validator] = validator;
  53007. }
  53008. [_symbol_utils.$finalize]() {
  53009. this[_symbol_utils.$content] = (0, _utils.getInteger)({
  53010. data: this[_symbol_utils.$content],
  53011. defaultValue: this[_defaultValue],
  53012. validate: this[_validator]
  53013. });
  53014. }
  53015. [_symbol_utils.$clean](builder) {
  53016. super[_symbol_utils.$clean](builder);
  53017. delete this[_defaultValue];
  53018. delete this[_validator];
  53019. }
  53020. }
  53021. exports.IntegerObject = IntegerObject;
  53022. class Option01 extends IntegerObject {
  53023. constructor(nsId, name) {
  53024. super(nsId, name, 0, n => n === 1);
  53025. }
  53026. }
  53027. exports.Option01 = Option01;
  53028. class Option10 extends IntegerObject {
  53029. constructor(nsId, name) {
  53030. super(nsId, name, 1, n => n === 0);
  53031. }
  53032. }
  53033. exports.Option10 = Option10;
  53034. /***/ }),
  53035. /* 88 */
  53036. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53037. Object.defineProperty(exports, "__esModule", ({
  53038. value: true
  53039. }));
  53040. exports.createDataNode = createDataNode;
  53041. exports.searchNode = searchNode;
  53042. var _symbol_utils = __w_pdfjs_require__(78);
  53043. var _util = __w_pdfjs_require__(2);
  53044. const namePattern = /^[^.[]+/;
  53045. const indexPattern = /^[^\]]+/;
  53046. const operators = {
  53047. dot: 0,
  53048. dotDot: 1,
  53049. dotHash: 2,
  53050. dotBracket: 3,
  53051. dotParen: 4
  53052. };
  53053. const shortcuts = new Map([["$data", (root, current) => root.datasets ? root.datasets.data : root], ["$record", (root, current) => (root.datasets ? root.datasets.data : root)[_symbol_utils.$getChildren]()[0]], ["$template", (root, current) => root.template], ["$connectionSet", (root, current) => root.connectionSet], ["$form", (root, current) => root.form], ["$layout", (root, current) => root.layout], ["$host", (root, current) => root.host], ["$dataWindow", (root, current) => root.dataWindow], ["$event", (root, current) => root.event], ["!", (root, current) => root.datasets], ["$xfa", (root, current) => root], ["xfa", (root, current) => root], ["$", (root, current) => current]]);
  53054. const somCache = new WeakMap();
  53055. function parseIndex(index) {
  53056. index = index.trim();
  53057. if (index === "*") {
  53058. return Infinity;
  53059. }
  53060. return parseInt(index, 10) || 0;
  53061. }
  53062. function parseExpression(expr, dotDotAllowed, noExpr = true) {
  53063. let match = expr.match(namePattern);
  53064. if (!match) {
  53065. return null;
  53066. }
  53067. let [name] = match;
  53068. const parsed = [{
  53069. name,
  53070. cacheName: "." + name,
  53071. index: 0,
  53072. js: null,
  53073. formCalc: null,
  53074. operator: operators.dot
  53075. }];
  53076. let pos = name.length;
  53077. while (pos < expr.length) {
  53078. const spos = pos;
  53079. const char = expr.charAt(pos++);
  53080. if (char === "[") {
  53081. match = expr.slice(pos).match(indexPattern);
  53082. if (!match) {
  53083. (0, _util.warn)("XFA - Invalid index in SOM expression");
  53084. return null;
  53085. }
  53086. parsed.at(-1).index = parseIndex(match[0]);
  53087. pos += match[0].length + 1;
  53088. continue;
  53089. }
  53090. let operator;
  53091. switch (expr.charAt(pos)) {
  53092. case ".":
  53093. if (!dotDotAllowed) {
  53094. return null;
  53095. }
  53096. pos++;
  53097. operator = operators.dotDot;
  53098. break;
  53099. case "#":
  53100. pos++;
  53101. operator = operators.dotHash;
  53102. break;
  53103. case "[":
  53104. if (noExpr) {
  53105. (0, _util.warn)("XFA - SOM expression contains a FormCalc subexpression which is not supported for now.");
  53106. return null;
  53107. }
  53108. operator = operators.dotBracket;
  53109. break;
  53110. case "(":
  53111. if (noExpr) {
  53112. (0, _util.warn)("XFA - SOM expression contains a JavaScript subexpression which is not supported for now.");
  53113. return null;
  53114. }
  53115. operator = operators.dotParen;
  53116. break;
  53117. default:
  53118. operator = operators.dot;
  53119. break;
  53120. }
  53121. match = expr.slice(pos).match(namePattern);
  53122. if (!match) {
  53123. break;
  53124. }
  53125. [name] = match;
  53126. pos += name.length;
  53127. parsed.push({
  53128. name,
  53129. cacheName: expr.slice(spos, pos),
  53130. operator,
  53131. index: 0,
  53132. js: null,
  53133. formCalc: null
  53134. });
  53135. }
  53136. return parsed;
  53137. }
  53138. function searchNode(root, container, expr, dotDotAllowed = true, useCache = true) {
  53139. const parsed = parseExpression(expr, dotDotAllowed);
  53140. if (!parsed) {
  53141. return null;
  53142. }
  53143. const fn = shortcuts.get(parsed[0].name);
  53144. let i = 0;
  53145. let isQualified;
  53146. if (fn) {
  53147. isQualified = true;
  53148. root = [fn(root, container)];
  53149. i = 1;
  53150. } else {
  53151. isQualified = container === null;
  53152. root = [container || root];
  53153. }
  53154. for (let ii = parsed.length; i < ii; i++) {
  53155. const {
  53156. name,
  53157. cacheName,
  53158. operator,
  53159. index
  53160. } = parsed[i];
  53161. const nodes = [];
  53162. for (const node of root) {
  53163. if (!node.isXFAObject) {
  53164. continue;
  53165. }
  53166. let children, cached;
  53167. if (useCache) {
  53168. cached = somCache.get(node);
  53169. if (!cached) {
  53170. cached = new Map();
  53171. somCache.set(node, cached);
  53172. }
  53173. children = cached.get(cacheName);
  53174. }
  53175. if (!children) {
  53176. switch (operator) {
  53177. case operators.dot:
  53178. children = node[_symbol_utils.$getChildrenByName](name, false);
  53179. break;
  53180. case operators.dotDot:
  53181. children = node[_symbol_utils.$getChildrenByName](name, true);
  53182. break;
  53183. case operators.dotHash:
  53184. children = node[_symbol_utils.$getChildrenByClass](name);
  53185. children = children.isXFAObjectArray ? children.children : [children];
  53186. break;
  53187. default:
  53188. break;
  53189. }
  53190. if (useCache) {
  53191. cached.set(cacheName, children);
  53192. }
  53193. }
  53194. if (children.length > 0) {
  53195. nodes.push(children);
  53196. }
  53197. }
  53198. if (nodes.length === 0 && !isQualified && i === 0) {
  53199. const parent = container[_symbol_utils.$getParent]();
  53200. container = parent;
  53201. if (!container) {
  53202. return null;
  53203. }
  53204. i = -1;
  53205. root = [container];
  53206. continue;
  53207. }
  53208. root = isFinite(index) ? nodes.filter(node => index < node.length).map(node => node[index]) : nodes.flat();
  53209. }
  53210. if (root.length === 0) {
  53211. return null;
  53212. }
  53213. return root;
  53214. }
  53215. function createDataNode(root, container, expr) {
  53216. const parsed = parseExpression(expr);
  53217. if (!parsed) {
  53218. return null;
  53219. }
  53220. if (parsed.some(x => x.operator === operators.dotDot)) {
  53221. return null;
  53222. }
  53223. const fn = shortcuts.get(parsed[0].name);
  53224. let i = 0;
  53225. if (fn) {
  53226. root = fn(root, container);
  53227. i = 1;
  53228. } else {
  53229. root = container || root;
  53230. }
  53231. for (let ii = parsed.length; i < ii; i++) {
  53232. const {
  53233. name,
  53234. operator,
  53235. index
  53236. } = parsed[i];
  53237. if (!isFinite(index)) {
  53238. parsed[i].index = 0;
  53239. return root.createNodes(parsed.slice(i));
  53240. }
  53241. let children;
  53242. switch (operator) {
  53243. case operators.dot:
  53244. children = root[_symbol_utils.$getChildrenByName](name, false);
  53245. break;
  53246. case operators.dotDot:
  53247. children = root[_symbol_utils.$getChildrenByName](name, true);
  53248. break;
  53249. case operators.dotHash:
  53250. children = root[_symbol_utils.$getChildrenByClass](name);
  53251. children = children.isXFAObjectArray ? children.children : [children];
  53252. break;
  53253. default:
  53254. break;
  53255. }
  53256. if (children.length === 0) {
  53257. return root.createNodes(parsed.slice(i));
  53258. }
  53259. if (index < children.length) {
  53260. const child = children[index];
  53261. if (!child.isXFAObject) {
  53262. (0, _util.warn)(`XFA - Cannot create a node.`);
  53263. return null;
  53264. }
  53265. root = child;
  53266. } else {
  53267. parsed[i].index = index - children.length;
  53268. return root.createNodes(parsed.slice(i));
  53269. }
  53270. }
  53271. return null;
  53272. }
  53273. /***/ }),
  53274. /* 89 */
  53275. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53276. Object.defineProperty(exports, "__esModule", ({
  53277. value: true
  53278. }));
  53279. exports.DataHandler = void 0;
  53280. var _symbol_utils = __w_pdfjs_require__(78);
  53281. class DataHandler {
  53282. constructor(root, data) {
  53283. this.data = data;
  53284. this.dataset = root.datasets || null;
  53285. }
  53286. serialize(storage) {
  53287. const stack = [[-1, this.data[_symbol_utils.$getChildren]()]];
  53288. while (stack.length > 0) {
  53289. const last = stack.at(-1);
  53290. const [i, children] = last;
  53291. if (i + 1 === children.length) {
  53292. stack.pop();
  53293. continue;
  53294. }
  53295. const child = children[++last[0]];
  53296. const storageEntry = storage.get(child[_symbol_utils.$uid]);
  53297. if (storageEntry) {
  53298. child[_symbol_utils.$setValue](storageEntry);
  53299. } else {
  53300. const attributes = child[_symbol_utils.$getAttributes]();
  53301. for (const value of attributes.values()) {
  53302. const entry = storage.get(value[_symbol_utils.$uid]);
  53303. if (entry) {
  53304. value[_symbol_utils.$setValue](entry);
  53305. break;
  53306. }
  53307. }
  53308. }
  53309. const nodes = child[_symbol_utils.$getChildren]();
  53310. if (nodes.length > 0) {
  53311. stack.push([-1, nodes]);
  53312. }
  53313. }
  53314. const buf = [`<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">`];
  53315. if (this.dataset) {
  53316. for (const child of this.dataset[_symbol_utils.$getChildren]()) {
  53317. if (child[_symbol_utils.$nodeName] !== "data") {
  53318. child[_symbol_utils.$toString](buf);
  53319. }
  53320. }
  53321. }
  53322. this.data[_symbol_utils.$toString](buf);
  53323. buf.push("</xfa:datasets>");
  53324. return buf.join("");
  53325. }
  53326. }
  53327. exports.DataHandler = DataHandler;
  53328. /***/ }),
  53329. /* 90 */
  53330. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53331. Object.defineProperty(exports, "__esModule", ({
  53332. value: true
  53333. }));
  53334. exports.XFAParser = void 0;
  53335. var _symbol_utils = __w_pdfjs_require__(78);
  53336. var _xml_parser = __w_pdfjs_require__(67);
  53337. var _builder = __w_pdfjs_require__(91);
  53338. var _util = __w_pdfjs_require__(2);
  53339. class XFAParser extends _xml_parser.XMLParserBase {
  53340. constructor(rootNameSpace = null, richText = false) {
  53341. super();
  53342. this._builder = new _builder.Builder(rootNameSpace);
  53343. this._stack = [];
  53344. this._globalData = {
  53345. usedTypefaces: new Set()
  53346. };
  53347. this._ids = new Map();
  53348. this._current = this._builder.buildRoot(this._ids);
  53349. this._errorCode = _xml_parser.XMLParserErrorCode.NoError;
  53350. this._whiteRegex = /^\s+$/;
  53351. this._nbsps = /\xa0+/g;
  53352. this._richText = richText;
  53353. }
  53354. parse(data) {
  53355. this.parseXml(data);
  53356. if (this._errorCode !== _xml_parser.XMLParserErrorCode.NoError) {
  53357. return undefined;
  53358. }
  53359. this._current[_symbol_utils.$finalize]();
  53360. return this._current.element;
  53361. }
  53362. onText(text) {
  53363. text = text.replace(this._nbsps, match => match.slice(1) + " ");
  53364. if (this._richText || this._current[_symbol_utils.$acceptWhitespace]()) {
  53365. this._current[_symbol_utils.$onText](text, this._richText);
  53366. return;
  53367. }
  53368. if (this._whiteRegex.test(text)) {
  53369. return;
  53370. }
  53371. this._current[_symbol_utils.$onText](text.trim());
  53372. }
  53373. onCdata(text) {
  53374. this._current[_symbol_utils.$onText](text);
  53375. }
  53376. _mkAttributes(attributes, tagName) {
  53377. let namespace = null;
  53378. let prefixes = null;
  53379. const attributeObj = Object.create({});
  53380. for (const {
  53381. name,
  53382. value
  53383. } of attributes) {
  53384. if (name === "xmlns") {
  53385. if (!namespace) {
  53386. namespace = value;
  53387. } else {
  53388. (0, _util.warn)(`XFA - multiple namespace definition in <${tagName}>`);
  53389. }
  53390. } else if (name.startsWith("xmlns:")) {
  53391. const prefix = name.substring("xmlns:".length);
  53392. if (!prefixes) {
  53393. prefixes = [];
  53394. }
  53395. prefixes.push({
  53396. prefix,
  53397. value
  53398. });
  53399. } else {
  53400. const i = name.indexOf(":");
  53401. if (i === -1) {
  53402. attributeObj[name] = value;
  53403. } else {
  53404. let nsAttrs = attributeObj[_symbol_utils.$nsAttributes];
  53405. if (!nsAttrs) {
  53406. nsAttrs = attributeObj[_symbol_utils.$nsAttributes] = Object.create(null);
  53407. }
  53408. const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
  53409. const attrs = nsAttrs[ns] ||= Object.create(null);
  53410. attrs[attrName] = value;
  53411. }
  53412. }
  53413. }
  53414. return [namespace, prefixes, attributeObj];
  53415. }
  53416. _getNameAndPrefix(name, nsAgnostic) {
  53417. const i = name.indexOf(":");
  53418. if (i === -1) {
  53419. return [name, null];
  53420. }
  53421. return [name.substring(i + 1), nsAgnostic ? "" : name.substring(0, i)];
  53422. }
  53423. onBeginElement(tagName, attributes, isEmpty) {
  53424. const [namespace, prefixes, attributesObj] = this._mkAttributes(attributes, tagName);
  53425. const [name, nsPrefix] = this._getNameAndPrefix(tagName, this._builder.isNsAgnostic());
  53426. const node = this._builder.build({
  53427. nsPrefix,
  53428. name,
  53429. attributes: attributesObj,
  53430. namespace,
  53431. prefixes
  53432. });
  53433. node[_symbol_utils.$globalData] = this._globalData;
  53434. if (isEmpty) {
  53435. node[_symbol_utils.$finalize]();
  53436. if (this._current[_symbol_utils.$onChild](node)) {
  53437. node[_symbol_utils.$setId](this._ids);
  53438. }
  53439. node[_symbol_utils.$clean](this._builder);
  53440. return;
  53441. }
  53442. this._stack.push(this._current);
  53443. this._current = node;
  53444. }
  53445. onEndElement(name) {
  53446. const node = this._current;
  53447. if (node[_symbol_utils.$isCDATAXml]() && typeof node[_symbol_utils.$content] === "string") {
  53448. const parser = new XFAParser();
  53449. parser._globalData = this._globalData;
  53450. const root = parser.parse(node[_symbol_utils.$content]);
  53451. node[_symbol_utils.$content] = null;
  53452. node[_symbol_utils.$onChild](root);
  53453. }
  53454. node[_symbol_utils.$finalize]();
  53455. this._current = this._stack.pop();
  53456. if (this._current[_symbol_utils.$onChild](node)) {
  53457. node[_symbol_utils.$setId](this._ids);
  53458. }
  53459. node[_symbol_utils.$clean](this._builder);
  53460. }
  53461. onError(code) {
  53462. this._errorCode = code;
  53463. }
  53464. }
  53465. exports.XFAParser = XFAParser;
  53466. /***/ }),
  53467. /* 91 */
  53468. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53469. Object.defineProperty(exports, "__esModule", ({
  53470. value: true
  53471. }));
  53472. exports.Builder = void 0;
  53473. var _namespaces = __w_pdfjs_require__(81);
  53474. var _symbol_utils = __w_pdfjs_require__(78);
  53475. var _setup = __w_pdfjs_require__(92);
  53476. var _template = __w_pdfjs_require__(80);
  53477. var _unknown = __w_pdfjs_require__(101);
  53478. var _util = __w_pdfjs_require__(2);
  53479. var _xfa_object = __w_pdfjs_require__(87);
  53480. class Root extends _xfa_object.XFAObject {
  53481. constructor(ids) {
  53482. super(-1, "root", Object.create(null));
  53483. this.element = null;
  53484. this[_symbol_utils.$ids] = ids;
  53485. }
  53486. [_symbol_utils.$onChild](child) {
  53487. this.element = child;
  53488. return true;
  53489. }
  53490. [_symbol_utils.$finalize]() {
  53491. super[_symbol_utils.$finalize]();
  53492. if (this.element.template instanceof _template.Template) {
  53493. this[_symbol_utils.$ids].set(_symbol_utils.$root, this.element);
  53494. this.element.template[_symbol_utils.$resolvePrototypes](this[_symbol_utils.$ids]);
  53495. this.element.template[_symbol_utils.$ids] = this[_symbol_utils.$ids];
  53496. }
  53497. }
  53498. }
  53499. class Empty extends _xfa_object.XFAObject {
  53500. constructor() {
  53501. super(-1, "", Object.create(null));
  53502. }
  53503. [_symbol_utils.$onChild](_) {
  53504. return false;
  53505. }
  53506. }
  53507. class Builder {
  53508. constructor(rootNameSpace = null) {
  53509. this._namespaceStack = [];
  53510. this._nsAgnosticLevel = 0;
  53511. this._namespacePrefixes = new Map();
  53512. this._namespaces = new Map();
  53513. this._nextNsId = Math.max(...Object.values(_namespaces.NamespaceIds).map(({
  53514. id
  53515. }) => id));
  53516. this._currentNamespace = rootNameSpace || new _unknown.UnknownNamespace(++this._nextNsId);
  53517. }
  53518. buildRoot(ids) {
  53519. return new Root(ids);
  53520. }
  53521. build({
  53522. nsPrefix,
  53523. name,
  53524. attributes,
  53525. namespace,
  53526. prefixes
  53527. }) {
  53528. const hasNamespaceDef = namespace !== null;
  53529. if (hasNamespaceDef) {
  53530. this._namespaceStack.push(this._currentNamespace);
  53531. this._currentNamespace = this._searchNamespace(namespace);
  53532. }
  53533. if (prefixes) {
  53534. this._addNamespacePrefix(prefixes);
  53535. }
  53536. if (attributes.hasOwnProperty(_symbol_utils.$nsAttributes)) {
  53537. const dataTemplate = _setup.NamespaceSetUp.datasets;
  53538. const nsAttrs = attributes[_symbol_utils.$nsAttributes];
  53539. let xfaAttrs = null;
  53540. for (const [ns, attrs] of Object.entries(nsAttrs)) {
  53541. const nsToUse = this._getNamespaceToUse(ns);
  53542. if (nsToUse === dataTemplate) {
  53543. xfaAttrs = {
  53544. xfa: attrs
  53545. };
  53546. break;
  53547. }
  53548. }
  53549. if (xfaAttrs) {
  53550. attributes[_symbol_utils.$nsAttributes] = xfaAttrs;
  53551. } else {
  53552. delete attributes[_symbol_utils.$nsAttributes];
  53553. }
  53554. }
  53555. const namespaceToUse = this._getNamespaceToUse(nsPrefix);
  53556. const node = namespaceToUse?.[_namespaces.$buildXFAObject](name, attributes) || new Empty();
  53557. if (node[_symbol_utils.$isNsAgnostic]()) {
  53558. this._nsAgnosticLevel++;
  53559. }
  53560. if (hasNamespaceDef || prefixes || node[_symbol_utils.$isNsAgnostic]()) {
  53561. node[_symbol_utils.$cleanup] = {
  53562. hasNamespace: hasNamespaceDef,
  53563. prefixes,
  53564. nsAgnostic: node[_symbol_utils.$isNsAgnostic]()
  53565. };
  53566. }
  53567. return node;
  53568. }
  53569. isNsAgnostic() {
  53570. return this._nsAgnosticLevel > 0;
  53571. }
  53572. _searchNamespace(nsName) {
  53573. let ns = this._namespaces.get(nsName);
  53574. if (ns) {
  53575. return ns;
  53576. }
  53577. for (const [name, {
  53578. check
  53579. }] of Object.entries(_namespaces.NamespaceIds)) {
  53580. if (check(nsName)) {
  53581. ns = _setup.NamespaceSetUp[name];
  53582. if (ns) {
  53583. this._namespaces.set(nsName, ns);
  53584. return ns;
  53585. }
  53586. break;
  53587. }
  53588. }
  53589. ns = new _unknown.UnknownNamespace(++this._nextNsId);
  53590. this._namespaces.set(nsName, ns);
  53591. return ns;
  53592. }
  53593. _addNamespacePrefix(prefixes) {
  53594. for (const {
  53595. prefix,
  53596. value
  53597. } of prefixes) {
  53598. const namespace = this._searchNamespace(value);
  53599. let prefixStack = this._namespacePrefixes.get(prefix);
  53600. if (!prefixStack) {
  53601. prefixStack = [];
  53602. this._namespacePrefixes.set(prefix, prefixStack);
  53603. }
  53604. prefixStack.push(namespace);
  53605. }
  53606. }
  53607. _getNamespaceToUse(prefix) {
  53608. if (!prefix) {
  53609. return this._currentNamespace;
  53610. }
  53611. const prefixStack = this._namespacePrefixes.get(prefix);
  53612. if (prefixStack?.length > 0) {
  53613. return prefixStack.at(-1);
  53614. }
  53615. (0, _util.warn)(`Unknown namespace prefix: ${prefix}.`);
  53616. return null;
  53617. }
  53618. clean(data) {
  53619. const {
  53620. hasNamespace,
  53621. prefixes,
  53622. nsAgnostic
  53623. } = data;
  53624. if (hasNamespace) {
  53625. this._currentNamespace = this._namespaceStack.pop();
  53626. }
  53627. if (prefixes) {
  53628. prefixes.forEach(({
  53629. prefix
  53630. }) => {
  53631. this._namespacePrefixes.get(prefix).pop();
  53632. });
  53633. }
  53634. if (nsAgnostic) {
  53635. this._nsAgnosticLevel--;
  53636. }
  53637. }
  53638. }
  53639. exports.Builder = Builder;
  53640. /***/ }),
  53641. /* 92 */
  53642. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53643. Object.defineProperty(exports, "__esModule", ({
  53644. value: true
  53645. }));
  53646. exports.NamespaceSetUp = void 0;
  53647. var _config = __w_pdfjs_require__(93);
  53648. var _connection_set = __w_pdfjs_require__(94);
  53649. var _datasets = __w_pdfjs_require__(95);
  53650. var _locale_set = __w_pdfjs_require__(96);
  53651. var _signature = __w_pdfjs_require__(97);
  53652. var _stylesheet = __w_pdfjs_require__(98);
  53653. var _template = __w_pdfjs_require__(80);
  53654. var _xdp = __w_pdfjs_require__(99);
  53655. var _xhtml = __w_pdfjs_require__(100);
  53656. const NamespaceSetUp = {
  53657. config: _config.ConfigNamespace,
  53658. connection: _connection_set.ConnectionSetNamespace,
  53659. datasets: _datasets.DatasetsNamespace,
  53660. localeSet: _locale_set.LocaleSetNamespace,
  53661. signature: _signature.SignatureNamespace,
  53662. stylesheet: _stylesheet.StylesheetNamespace,
  53663. template: _template.TemplateNamespace,
  53664. xdp: _xdp.XdpNamespace,
  53665. xhtml: _xhtml.XhtmlNamespace
  53666. };
  53667. exports.NamespaceSetUp = NamespaceSetUp;
  53668. /***/ }),
  53669. /* 93 */
  53670. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  53671. Object.defineProperty(exports, "__esModule", ({
  53672. value: true
  53673. }));
  53674. exports.ConfigNamespace = void 0;
  53675. var _namespaces = __w_pdfjs_require__(81);
  53676. var _symbol_utils = __w_pdfjs_require__(78);
  53677. var _xfa_object = __w_pdfjs_require__(87);
  53678. var _utils = __w_pdfjs_require__(84);
  53679. var _util = __w_pdfjs_require__(2);
  53680. const CONFIG_NS_ID = _namespaces.NamespaceIds.config.id;
  53681. class Acrobat extends _xfa_object.XFAObject {
  53682. constructor(attributes) {
  53683. super(CONFIG_NS_ID, "acrobat", true);
  53684. this.acrobat7 = null;
  53685. this.autoSave = null;
  53686. this.common = null;
  53687. this.validate = null;
  53688. this.validateApprovalSignatures = null;
  53689. this.submitUrl = new _xfa_object.XFAObjectArray();
  53690. }
  53691. }
  53692. class Acrobat7 extends _xfa_object.XFAObject {
  53693. constructor(attributes) {
  53694. super(CONFIG_NS_ID, "acrobat7", true);
  53695. this.dynamicRender = null;
  53696. }
  53697. }
  53698. class ADBE_JSConsole extends _xfa_object.OptionObject {
  53699. constructor(attributes) {
  53700. super(CONFIG_NS_ID, "ADBE_JSConsole", ["delegate", "Enable", "Disable"]);
  53701. }
  53702. }
  53703. class ADBE_JSDebugger extends _xfa_object.OptionObject {
  53704. constructor(attributes) {
  53705. super(CONFIG_NS_ID, "ADBE_JSDebugger", ["delegate", "Enable", "Disable"]);
  53706. }
  53707. }
  53708. class AddSilentPrint extends _xfa_object.Option01 {
  53709. constructor(attributes) {
  53710. super(CONFIG_NS_ID, "addSilentPrint");
  53711. }
  53712. }
  53713. class AddViewerPreferences extends _xfa_object.Option01 {
  53714. constructor(attributes) {
  53715. super(CONFIG_NS_ID, "addViewerPreferences");
  53716. }
  53717. }
  53718. class AdjustData extends _xfa_object.Option10 {
  53719. constructor(attributes) {
  53720. super(CONFIG_NS_ID, "adjustData");
  53721. }
  53722. }
  53723. class AdobeExtensionLevel extends _xfa_object.IntegerObject {
  53724. constructor(attributes) {
  53725. super(CONFIG_NS_ID, "adobeExtensionLevel", 0, n => n >= 1 && n <= 8);
  53726. }
  53727. }
  53728. class Agent extends _xfa_object.XFAObject {
  53729. constructor(attributes) {
  53730. super(CONFIG_NS_ID, "agent", true);
  53731. this.name = attributes.name ? attributes.name.trim() : "";
  53732. this.common = new _xfa_object.XFAObjectArray();
  53733. }
  53734. }
  53735. class AlwaysEmbed extends _xfa_object.ContentObject {
  53736. constructor(attributes) {
  53737. super(CONFIG_NS_ID, "alwaysEmbed");
  53738. }
  53739. }
  53740. class Amd extends _xfa_object.StringObject {
  53741. constructor(attributes) {
  53742. super(CONFIG_NS_ID, "amd");
  53743. }
  53744. }
  53745. class Area extends _xfa_object.XFAObject {
  53746. constructor(attributes) {
  53747. super(CONFIG_NS_ID, "area");
  53748. this.level = (0, _utils.getInteger)({
  53749. data: attributes.level,
  53750. defaultValue: 0,
  53751. validate: n => n >= 1 && n <= 3
  53752. });
  53753. this.name = (0, _utils.getStringOption)(attributes.name, ["", "barcode", "coreinit", "deviceDriver", "font", "general", "layout", "merge", "script", "signature", "sourceSet", "templateCache"]);
  53754. }
  53755. }
  53756. class Attributes extends _xfa_object.OptionObject {
  53757. constructor(attributes) {
  53758. super(CONFIG_NS_ID, "attributes", ["preserve", "delegate", "ignore"]);
  53759. }
  53760. }
  53761. class AutoSave extends _xfa_object.OptionObject {
  53762. constructor(attributes) {
  53763. super(CONFIG_NS_ID, "autoSave", ["disabled", "enabled"]);
  53764. }
  53765. }
  53766. class Base extends _xfa_object.StringObject {
  53767. constructor(attributes) {
  53768. super(CONFIG_NS_ID, "base");
  53769. }
  53770. }
  53771. class BatchOutput extends _xfa_object.XFAObject {
  53772. constructor(attributes) {
  53773. super(CONFIG_NS_ID, "batchOutput");
  53774. this.format = (0, _utils.getStringOption)(attributes.format, ["none", "concat", "zip", "zipCompress"]);
  53775. }
  53776. }
  53777. class BehaviorOverride extends _xfa_object.ContentObject {
  53778. constructor(attributes) {
  53779. super(CONFIG_NS_ID, "behaviorOverride");
  53780. }
  53781. [_symbol_utils.$finalize]() {
  53782. this[_symbol_utils.$content] = new Map(this[_symbol_utils.$content].trim().split(/\s+/).filter(x => x.includes(":")).map(x => x.split(":", 2)));
  53783. }
  53784. }
  53785. class Cache extends _xfa_object.XFAObject {
  53786. constructor(attributes) {
  53787. super(CONFIG_NS_ID, "cache", true);
  53788. this.templateCache = null;
  53789. }
  53790. }
  53791. class Change extends _xfa_object.Option01 {
  53792. constructor(attributes) {
  53793. super(CONFIG_NS_ID, "change");
  53794. }
  53795. }
  53796. class Common extends _xfa_object.XFAObject {
  53797. constructor(attributes) {
  53798. super(CONFIG_NS_ID, "common", true);
  53799. this.data = null;
  53800. this.locale = null;
  53801. this.localeSet = null;
  53802. this.messaging = null;
  53803. this.suppressBanner = null;
  53804. this.template = null;
  53805. this.validationMessaging = null;
  53806. this.versionControl = null;
  53807. this.log = new _xfa_object.XFAObjectArray();
  53808. }
  53809. }
  53810. class Compress extends _xfa_object.XFAObject {
  53811. constructor(attributes) {
  53812. super(CONFIG_NS_ID, "compress");
  53813. this.scope = (0, _utils.getStringOption)(attributes.scope, ["imageOnly", "document"]);
  53814. }
  53815. }
  53816. class CompressLogicalStructure extends _xfa_object.Option01 {
  53817. constructor(attributes) {
  53818. super(CONFIG_NS_ID, "compressLogicalStructure");
  53819. }
  53820. }
  53821. class CompressObjectStream extends _xfa_object.Option10 {
  53822. constructor(attributes) {
  53823. super(CONFIG_NS_ID, "compressObjectStream");
  53824. }
  53825. }
  53826. class Compression extends _xfa_object.XFAObject {
  53827. constructor(attributes) {
  53828. super(CONFIG_NS_ID, "compression", true);
  53829. this.compressLogicalStructure = null;
  53830. this.compressObjectStream = null;
  53831. this.level = null;
  53832. this.type = null;
  53833. }
  53834. }
  53835. class Config extends _xfa_object.XFAObject {
  53836. constructor(attributes) {
  53837. super(CONFIG_NS_ID, "config", true);
  53838. this.acrobat = null;
  53839. this.present = null;
  53840. this.trace = null;
  53841. this.agent = new _xfa_object.XFAObjectArray();
  53842. }
  53843. }
  53844. class Conformance extends _xfa_object.OptionObject {
  53845. constructor(attributes) {
  53846. super(CONFIG_NS_ID, "conformance", ["A", "B"]);
  53847. }
  53848. }
  53849. class ContentCopy extends _xfa_object.Option01 {
  53850. constructor(attributes) {
  53851. super(CONFIG_NS_ID, "contentCopy");
  53852. }
  53853. }
  53854. class Copies extends _xfa_object.IntegerObject {
  53855. constructor(attributes) {
  53856. super(CONFIG_NS_ID, "copies", 1, n => n >= 1);
  53857. }
  53858. }
  53859. class Creator extends _xfa_object.StringObject {
  53860. constructor(attributes) {
  53861. super(CONFIG_NS_ID, "creator");
  53862. }
  53863. }
  53864. class CurrentPage extends _xfa_object.IntegerObject {
  53865. constructor(attributes) {
  53866. super(CONFIG_NS_ID, "currentPage", 0, n => n >= 0);
  53867. }
  53868. }
  53869. class Data extends _xfa_object.XFAObject {
  53870. constructor(attributes) {
  53871. super(CONFIG_NS_ID, "data", true);
  53872. this.adjustData = null;
  53873. this.attributes = null;
  53874. this.incrementalLoad = null;
  53875. this.outputXSL = null;
  53876. this.range = null;
  53877. this.record = null;
  53878. this.startNode = null;
  53879. this.uri = null;
  53880. this.window = null;
  53881. this.xsl = null;
  53882. this.excludeNS = new _xfa_object.XFAObjectArray();
  53883. this.transform = new _xfa_object.XFAObjectArray();
  53884. }
  53885. }
  53886. class Debug extends _xfa_object.XFAObject {
  53887. constructor(attributes) {
  53888. super(CONFIG_NS_ID, "debug", true);
  53889. this.uri = null;
  53890. }
  53891. }
  53892. class DefaultTypeface extends _xfa_object.ContentObject {
  53893. constructor(attributes) {
  53894. super(CONFIG_NS_ID, "defaultTypeface");
  53895. this.writingScript = (0, _utils.getStringOption)(attributes.writingScript, ["*", "Arabic", "Cyrillic", "EastEuropeanRoman", "Greek", "Hebrew", "Japanese", "Korean", "Roman", "SimplifiedChinese", "Thai", "TraditionalChinese", "Vietnamese"]);
  53896. }
  53897. }
  53898. class Destination extends _xfa_object.OptionObject {
  53899. constructor(attributes) {
  53900. super(CONFIG_NS_ID, "destination", ["pdf", "pcl", "ps", "webClient", "zpl"]);
  53901. }
  53902. }
  53903. class DocumentAssembly extends _xfa_object.Option01 {
  53904. constructor(attributes) {
  53905. super(CONFIG_NS_ID, "documentAssembly");
  53906. }
  53907. }
  53908. class Driver extends _xfa_object.XFAObject {
  53909. constructor(attributes) {
  53910. super(CONFIG_NS_ID, "driver", true);
  53911. this.name = attributes.name ? attributes.name.trim() : "";
  53912. this.fontInfo = null;
  53913. this.xdc = null;
  53914. }
  53915. }
  53916. class DuplexOption extends _xfa_object.OptionObject {
  53917. constructor(attributes) {
  53918. super(CONFIG_NS_ID, "duplexOption", ["simplex", "duplexFlipLongEdge", "duplexFlipShortEdge"]);
  53919. }
  53920. }
  53921. class DynamicRender extends _xfa_object.OptionObject {
  53922. constructor(attributes) {
  53923. super(CONFIG_NS_ID, "dynamicRender", ["forbidden", "required"]);
  53924. }
  53925. }
  53926. class Embed extends _xfa_object.Option01 {
  53927. constructor(attributes) {
  53928. super(CONFIG_NS_ID, "embed");
  53929. }
  53930. }
  53931. class Encrypt extends _xfa_object.Option01 {
  53932. constructor(attributes) {
  53933. super(CONFIG_NS_ID, "encrypt");
  53934. }
  53935. }
  53936. class Encryption extends _xfa_object.XFAObject {
  53937. constructor(attributes) {
  53938. super(CONFIG_NS_ID, "encryption", true);
  53939. this.encrypt = null;
  53940. this.encryptionLevel = null;
  53941. this.permissions = null;
  53942. }
  53943. }
  53944. class EncryptionLevel extends _xfa_object.OptionObject {
  53945. constructor(attributes) {
  53946. super(CONFIG_NS_ID, "encryptionLevel", ["40bit", "128bit"]);
  53947. }
  53948. }
  53949. class Enforce extends _xfa_object.StringObject {
  53950. constructor(attributes) {
  53951. super(CONFIG_NS_ID, "enforce");
  53952. }
  53953. }
  53954. class Equate extends _xfa_object.XFAObject {
  53955. constructor(attributes) {
  53956. super(CONFIG_NS_ID, "equate");
  53957. this.force = (0, _utils.getInteger)({
  53958. data: attributes.force,
  53959. defaultValue: 1,
  53960. validate: n => n === 0
  53961. });
  53962. this.from = attributes.from || "";
  53963. this.to = attributes.to || "";
  53964. }
  53965. }
  53966. class EquateRange extends _xfa_object.XFAObject {
  53967. constructor(attributes) {
  53968. super(CONFIG_NS_ID, "equateRange");
  53969. this.from = attributes.from || "";
  53970. this.to = attributes.to || "";
  53971. this._unicodeRange = attributes.unicodeRange || "";
  53972. }
  53973. get unicodeRange() {
  53974. const ranges = [];
  53975. const unicodeRegex = /U\+([0-9a-fA-F]+)/;
  53976. const unicodeRange = this._unicodeRange;
  53977. for (let range of unicodeRange.split(",").map(x => x.trim()).filter(x => !!x)) {
  53978. range = range.split("-", 2).map(x => {
  53979. const found = x.match(unicodeRegex);
  53980. if (!found) {
  53981. return 0;
  53982. }
  53983. return parseInt(found[1], 16);
  53984. });
  53985. if (range.length === 1) {
  53986. range.push(range[0]);
  53987. }
  53988. ranges.push(range);
  53989. }
  53990. return (0, _util.shadow)(this, "unicodeRange", ranges);
  53991. }
  53992. }
  53993. class Exclude extends _xfa_object.ContentObject {
  53994. constructor(attributes) {
  53995. super(CONFIG_NS_ID, "exclude");
  53996. }
  53997. [_symbol_utils.$finalize]() {
  53998. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => x && ["calculate", "close", "enter", "exit", "initialize", "ready", "validate"].includes(x));
  53999. }
  54000. }
  54001. class ExcludeNS extends _xfa_object.StringObject {
  54002. constructor(attributes) {
  54003. super(CONFIG_NS_ID, "excludeNS");
  54004. }
  54005. }
  54006. class FlipLabel extends _xfa_object.OptionObject {
  54007. constructor(attributes) {
  54008. super(CONFIG_NS_ID, "flipLabel", ["usePrinterSetting", "on", "off"]);
  54009. }
  54010. }
  54011. class FontInfo extends _xfa_object.XFAObject {
  54012. constructor(attributes) {
  54013. super(CONFIG_NS_ID, "fontInfo", true);
  54014. this.embed = null;
  54015. this.map = null;
  54016. this.subsetBelow = null;
  54017. this.alwaysEmbed = new _xfa_object.XFAObjectArray();
  54018. this.defaultTypeface = new _xfa_object.XFAObjectArray();
  54019. this.neverEmbed = new _xfa_object.XFAObjectArray();
  54020. }
  54021. }
  54022. class FormFieldFilling extends _xfa_object.Option01 {
  54023. constructor(attributes) {
  54024. super(CONFIG_NS_ID, "formFieldFilling");
  54025. }
  54026. }
  54027. class GroupParent extends _xfa_object.StringObject {
  54028. constructor(attributes) {
  54029. super(CONFIG_NS_ID, "groupParent");
  54030. }
  54031. }
  54032. class IfEmpty extends _xfa_object.OptionObject {
  54033. constructor(attributes) {
  54034. super(CONFIG_NS_ID, "ifEmpty", ["dataValue", "dataGroup", "ignore", "remove"]);
  54035. }
  54036. }
  54037. class IncludeXDPContent extends _xfa_object.StringObject {
  54038. constructor(attributes) {
  54039. super(CONFIG_NS_ID, "includeXDPContent");
  54040. }
  54041. }
  54042. class IncrementalLoad extends _xfa_object.OptionObject {
  54043. constructor(attributes) {
  54044. super(CONFIG_NS_ID, "incrementalLoad", ["none", "forwardOnly"]);
  54045. }
  54046. }
  54047. class IncrementalMerge extends _xfa_object.Option01 {
  54048. constructor(attributes) {
  54049. super(CONFIG_NS_ID, "incrementalMerge");
  54050. }
  54051. }
  54052. class Interactive extends _xfa_object.Option01 {
  54053. constructor(attributes) {
  54054. super(CONFIG_NS_ID, "interactive");
  54055. }
  54056. }
  54057. class Jog extends _xfa_object.OptionObject {
  54058. constructor(attributes) {
  54059. super(CONFIG_NS_ID, "jog", ["usePrinterSetting", "none", "pageSet"]);
  54060. }
  54061. }
  54062. class LabelPrinter extends _xfa_object.XFAObject {
  54063. constructor(attributes) {
  54064. super(CONFIG_NS_ID, "labelPrinter", true);
  54065. this.name = (0, _utils.getStringOption)(attributes.name, ["zpl", "dpl", "ipl", "tcpl"]);
  54066. this.batchOutput = null;
  54067. this.flipLabel = null;
  54068. this.fontInfo = null;
  54069. this.xdc = null;
  54070. }
  54071. }
  54072. class Layout extends _xfa_object.OptionObject {
  54073. constructor(attributes) {
  54074. super(CONFIG_NS_ID, "layout", ["paginate", "panel"]);
  54075. }
  54076. }
  54077. class Level extends _xfa_object.IntegerObject {
  54078. constructor(attributes) {
  54079. super(CONFIG_NS_ID, "level", 0, n => n > 0);
  54080. }
  54081. }
  54082. class Linearized extends _xfa_object.Option01 {
  54083. constructor(attributes) {
  54084. super(CONFIG_NS_ID, "linearized");
  54085. }
  54086. }
  54087. class Locale extends _xfa_object.StringObject {
  54088. constructor(attributes) {
  54089. super(CONFIG_NS_ID, "locale");
  54090. }
  54091. }
  54092. class LocaleSet extends _xfa_object.StringObject {
  54093. constructor(attributes) {
  54094. super(CONFIG_NS_ID, "localeSet");
  54095. }
  54096. }
  54097. class Log extends _xfa_object.XFAObject {
  54098. constructor(attributes) {
  54099. super(CONFIG_NS_ID, "log", true);
  54100. this.mode = null;
  54101. this.threshold = null;
  54102. this.to = null;
  54103. this.uri = null;
  54104. }
  54105. }
  54106. class MapElement extends _xfa_object.XFAObject {
  54107. constructor(attributes) {
  54108. super(CONFIG_NS_ID, "map", true);
  54109. this.equate = new _xfa_object.XFAObjectArray();
  54110. this.equateRange = new _xfa_object.XFAObjectArray();
  54111. }
  54112. }
  54113. class MediumInfo extends _xfa_object.XFAObject {
  54114. constructor(attributes) {
  54115. super(CONFIG_NS_ID, "mediumInfo", true);
  54116. this.map = null;
  54117. }
  54118. }
  54119. class Message extends _xfa_object.XFAObject {
  54120. constructor(attributes) {
  54121. super(CONFIG_NS_ID, "message", true);
  54122. this.msgId = null;
  54123. this.severity = null;
  54124. }
  54125. }
  54126. class Messaging extends _xfa_object.XFAObject {
  54127. constructor(attributes) {
  54128. super(CONFIG_NS_ID, "messaging", true);
  54129. this.message = new _xfa_object.XFAObjectArray();
  54130. }
  54131. }
  54132. class Mode extends _xfa_object.OptionObject {
  54133. constructor(attributes) {
  54134. super(CONFIG_NS_ID, "mode", ["append", "overwrite"]);
  54135. }
  54136. }
  54137. class ModifyAnnots extends _xfa_object.Option01 {
  54138. constructor(attributes) {
  54139. super(CONFIG_NS_ID, "modifyAnnots");
  54140. }
  54141. }
  54142. class MsgId extends _xfa_object.IntegerObject {
  54143. constructor(attributes) {
  54144. super(CONFIG_NS_ID, "msgId", 1, n => n >= 1);
  54145. }
  54146. }
  54147. class NameAttr extends _xfa_object.StringObject {
  54148. constructor(attributes) {
  54149. super(CONFIG_NS_ID, "nameAttr");
  54150. }
  54151. }
  54152. class NeverEmbed extends _xfa_object.ContentObject {
  54153. constructor(attributes) {
  54154. super(CONFIG_NS_ID, "neverEmbed");
  54155. }
  54156. }
  54157. class NumberOfCopies extends _xfa_object.IntegerObject {
  54158. constructor(attributes) {
  54159. super(CONFIG_NS_ID, "numberOfCopies", null, n => n >= 2 && n <= 5);
  54160. }
  54161. }
  54162. class OpenAction extends _xfa_object.XFAObject {
  54163. constructor(attributes) {
  54164. super(CONFIG_NS_ID, "openAction", true);
  54165. this.destination = null;
  54166. }
  54167. }
  54168. class Output extends _xfa_object.XFAObject {
  54169. constructor(attributes) {
  54170. super(CONFIG_NS_ID, "output", true);
  54171. this.to = null;
  54172. this.type = null;
  54173. this.uri = null;
  54174. }
  54175. }
  54176. class OutputBin extends _xfa_object.StringObject {
  54177. constructor(attributes) {
  54178. super(CONFIG_NS_ID, "outputBin");
  54179. }
  54180. }
  54181. class OutputXSL extends _xfa_object.XFAObject {
  54182. constructor(attributes) {
  54183. super(CONFIG_NS_ID, "outputXSL", true);
  54184. this.uri = null;
  54185. }
  54186. }
  54187. class Overprint extends _xfa_object.OptionObject {
  54188. constructor(attributes) {
  54189. super(CONFIG_NS_ID, "overprint", ["none", "both", "draw", "field"]);
  54190. }
  54191. }
  54192. class Packets extends _xfa_object.StringObject {
  54193. constructor(attributes) {
  54194. super(CONFIG_NS_ID, "packets");
  54195. }
  54196. [_symbol_utils.$finalize]() {
  54197. if (this[_symbol_utils.$content] === "*") {
  54198. return;
  54199. }
  54200. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => ["config", "datasets", "template", "xfdf", "xslt"].includes(x));
  54201. }
  54202. }
  54203. class PageOffset extends _xfa_object.XFAObject {
  54204. constructor(attributes) {
  54205. super(CONFIG_NS_ID, "pageOffset");
  54206. this.x = (0, _utils.getInteger)({
  54207. data: attributes.x,
  54208. defaultValue: "useXDCSetting",
  54209. validate: n => true
  54210. });
  54211. this.y = (0, _utils.getInteger)({
  54212. data: attributes.y,
  54213. defaultValue: "useXDCSetting",
  54214. validate: n => true
  54215. });
  54216. }
  54217. }
  54218. class PageRange extends _xfa_object.StringObject {
  54219. constructor(attributes) {
  54220. super(CONFIG_NS_ID, "pageRange");
  54221. }
  54222. [_symbol_utils.$finalize]() {
  54223. const numbers = this[_symbol_utils.$content].trim().split(/\s+/).map(x => parseInt(x, 10));
  54224. const ranges = [];
  54225. for (let i = 0, ii = numbers.length; i < ii; i += 2) {
  54226. ranges.push(numbers.slice(i, i + 2));
  54227. }
  54228. this[_symbol_utils.$content] = ranges;
  54229. }
  54230. }
  54231. class Pagination extends _xfa_object.OptionObject {
  54232. constructor(attributes) {
  54233. super(CONFIG_NS_ID, "pagination", ["simplex", "duplexShortEdge", "duplexLongEdge"]);
  54234. }
  54235. }
  54236. class PaginationOverride extends _xfa_object.OptionObject {
  54237. constructor(attributes) {
  54238. super(CONFIG_NS_ID, "paginationOverride", ["none", "forceDuplex", "forceDuplexLongEdge", "forceDuplexShortEdge", "forceSimplex"]);
  54239. }
  54240. }
  54241. class Part extends _xfa_object.IntegerObject {
  54242. constructor(attributes) {
  54243. super(CONFIG_NS_ID, "part", 1, n => false);
  54244. }
  54245. }
  54246. class Pcl extends _xfa_object.XFAObject {
  54247. constructor(attributes) {
  54248. super(CONFIG_NS_ID, "pcl", true);
  54249. this.name = attributes.name || "";
  54250. this.batchOutput = null;
  54251. this.fontInfo = null;
  54252. this.jog = null;
  54253. this.mediumInfo = null;
  54254. this.outputBin = null;
  54255. this.pageOffset = null;
  54256. this.staple = null;
  54257. this.xdc = null;
  54258. }
  54259. }
  54260. class Pdf extends _xfa_object.XFAObject {
  54261. constructor(attributes) {
  54262. super(CONFIG_NS_ID, "pdf", true);
  54263. this.name = attributes.name || "";
  54264. this.adobeExtensionLevel = null;
  54265. this.batchOutput = null;
  54266. this.compression = null;
  54267. this.creator = null;
  54268. this.encryption = null;
  54269. this.fontInfo = null;
  54270. this.interactive = null;
  54271. this.linearized = null;
  54272. this.openAction = null;
  54273. this.pdfa = null;
  54274. this.producer = null;
  54275. this.renderPolicy = null;
  54276. this.scriptModel = null;
  54277. this.silentPrint = null;
  54278. this.submitFormat = null;
  54279. this.tagged = null;
  54280. this.version = null;
  54281. this.viewerPreferences = null;
  54282. this.xdc = null;
  54283. }
  54284. }
  54285. class Pdfa extends _xfa_object.XFAObject {
  54286. constructor(attributes) {
  54287. super(CONFIG_NS_ID, "pdfa", true);
  54288. this.amd = null;
  54289. this.conformance = null;
  54290. this.includeXDPContent = null;
  54291. this.part = null;
  54292. }
  54293. }
  54294. class Permissions extends _xfa_object.XFAObject {
  54295. constructor(attributes) {
  54296. super(CONFIG_NS_ID, "permissions", true);
  54297. this.accessibleContent = null;
  54298. this.change = null;
  54299. this.contentCopy = null;
  54300. this.documentAssembly = null;
  54301. this.formFieldFilling = null;
  54302. this.modifyAnnots = null;
  54303. this.plaintextMetadata = null;
  54304. this.print = null;
  54305. this.printHighQuality = null;
  54306. }
  54307. }
  54308. class PickTrayByPDFSize extends _xfa_object.Option01 {
  54309. constructor(attributes) {
  54310. super(CONFIG_NS_ID, "pickTrayByPDFSize");
  54311. }
  54312. }
  54313. class Picture extends _xfa_object.StringObject {
  54314. constructor(attributes) {
  54315. super(CONFIG_NS_ID, "picture");
  54316. }
  54317. }
  54318. class PlaintextMetadata extends _xfa_object.Option01 {
  54319. constructor(attributes) {
  54320. super(CONFIG_NS_ID, "plaintextMetadata");
  54321. }
  54322. }
  54323. class Presence extends _xfa_object.OptionObject {
  54324. constructor(attributes) {
  54325. super(CONFIG_NS_ID, "presence", ["preserve", "dissolve", "dissolveStructure", "ignore", "remove"]);
  54326. }
  54327. }
  54328. class Present extends _xfa_object.XFAObject {
  54329. constructor(attributes) {
  54330. super(CONFIG_NS_ID, "present", true);
  54331. this.behaviorOverride = null;
  54332. this.cache = null;
  54333. this.common = null;
  54334. this.copies = null;
  54335. this.destination = null;
  54336. this.incrementalMerge = null;
  54337. this.layout = null;
  54338. this.output = null;
  54339. this.overprint = null;
  54340. this.pagination = null;
  54341. this.paginationOverride = null;
  54342. this.script = null;
  54343. this.validate = null;
  54344. this.xdp = null;
  54345. this.driver = new _xfa_object.XFAObjectArray();
  54346. this.labelPrinter = new _xfa_object.XFAObjectArray();
  54347. this.pcl = new _xfa_object.XFAObjectArray();
  54348. this.pdf = new _xfa_object.XFAObjectArray();
  54349. this.ps = new _xfa_object.XFAObjectArray();
  54350. this.submitUrl = new _xfa_object.XFAObjectArray();
  54351. this.webClient = new _xfa_object.XFAObjectArray();
  54352. this.zpl = new _xfa_object.XFAObjectArray();
  54353. }
  54354. }
  54355. class Print extends _xfa_object.Option01 {
  54356. constructor(attributes) {
  54357. super(CONFIG_NS_ID, "print");
  54358. }
  54359. }
  54360. class PrintHighQuality extends _xfa_object.Option01 {
  54361. constructor(attributes) {
  54362. super(CONFIG_NS_ID, "printHighQuality");
  54363. }
  54364. }
  54365. class PrintScaling extends _xfa_object.OptionObject {
  54366. constructor(attributes) {
  54367. super(CONFIG_NS_ID, "printScaling", ["appdefault", "noScaling"]);
  54368. }
  54369. }
  54370. class PrinterName extends _xfa_object.StringObject {
  54371. constructor(attributes) {
  54372. super(CONFIG_NS_ID, "printerName");
  54373. }
  54374. }
  54375. class Producer extends _xfa_object.StringObject {
  54376. constructor(attributes) {
  54377. super(CONFIG_NS_ID, "producer");
  54378. }
  54379. }
  54380. class Ps extends _xfa_object.XFAObject {
  54381. constructor(attributes) {
  54382. super(CONFIG_NS_ID, "ps", true);
  54383. this.name = attributes.name || "";
  54384. this.batchOutput = null;
  54385. this.fontInfo = null;
  54386. this.jog = null;
  54387. this.mediumInfo = null;
  54388. this.outputBin = null;
  54389. this.staple = null;
  54390. this.xdc = null;
  54391. }
  54392. }
  54393. class Range extends _xfa_object.ContentObject {
  54394. constructor(attributes) {
  54395. super(CONFIG_NS_ID, "range");
  54396. }
  54397. [_symbol_utils.$finalize]() {
  54398. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s*,\s*/, 2).map(range => range.split("-").map(x => parseInt(x.trim(), 10))).filter(range => range.every(x => !isNaN(x))).map(range => {
  54399. if (range.length === 1) {
  54400. range.push(range[0]);
  54401. }
  54402. return range;
  54403. });
  54404. }
  54405. }
  54406. class Record extends _xfa_object.ContentObject {
  54407. constructor(attributes) {
  54408. super(CONFIG_NS_ID, "record");
  54409. }
  54410. [_symbol_utils.$finalize]() {
  54411. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  54412. const n = parseInt(this[_symbol_utils.$content], 10);
  54413. if (!isNaN(n) && n >= 0) {
  54414. this[_symbol_utils.$content] = n;
  54415. }
  54416. }
  54417. }
  54418. class Relevant extends _xfa_object.ContentObject {
  54419. constructor(attributes) {
  54420. super(CONFIG_NS_ID, "relevant");
  54421. }
  54422. [_symbol_utils.$finalize]() {
  54423. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/);
  54424. }
  54425. }
  54426. class Rename extends _xfa_object.ContentObject {
  54427. constructor(attributes) {
  54428. super(CONFIG_NS_ID, "rename");
  54429. }
  54430. [_symbol_utils.$finalize]() {
  54431. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  54432. if (this[_symbol_utils.$content].toLowerCase().startsWith("xml") || new RegExp("[\\p{L}_][\\p{L}\\d._\\p{M}-]*", "u").test(this[_symbol_utils.$content])) {
  54433. (0, _util.warn)("XFA - Rename: invalid XFA name");
  54434. }
  54435. }
  54436. }
  54437. class RenderPolicy extends _xfa_object.OptionObject {
  54438. constructor(attributes) {
  54439. super(CONFIG_NS_ID, "renderPolicy", ["server", "client"]);
  54440. }
  54441. }
  54442. class RunScripts extends _xfa_object.OptionObject {
  54443. constructor(attributes) {
  54444. super(CONFIG_NS_ID, "runScripts", ["both", "client", "none", "server"]);
  54445. }
  54446. }
  54447. class Script extends _xfa_object.XFAObject {
  54448. constructor(attributes) {
  54449. super(CONFIG_NS_ID, "script", true);
  54450. this.currentPage = null;
  54451. this.exclude = null;
  54452. this.runScripts = null;
  54453. }
  54454. }
  54455. class ScriptModel extends _xfa_object.OptionObject {
  54456. constructor(attributes) {
  54457. super(CONFIG_NS_ID, "scriptModel", ["XFA", "none"]);
  54458. }
  54459. }
  54460. class Severity extends _xfa_object.OptionObject {
  54461. constructor(attributes) {
  54462. super(CONFIG_NS_ID, "severity", ["ignore", "error", "information", "trace", "warning"]);
  54463. }
  54464. }
  54465. class SilentPrint extends _xfa_object.XFAObject {
  54466. constructor(attributes) {
  54467. super(CONFIG_NS_ID, "silentPrint", true);
  54468. this.addSilentPrint = null;
  54469. this.printerName = null;
  54470. }
  54471. }
  54472. class Staple extends _xfa_object.XFAObject {
  54473. constructor(attributes) {
  54474. super(CONFIG_NS_ID, "staple");
  54475. this.mode = (0, _utils.getStringOption)(attributes.mode, ["usePrinterSetting", "on", "off"]);
  54476. }
  54477. }
  54478. class StartNode extends _xfa_object.StringObject {
  54479. constructor(attributes) {
  54480. super(CONFIG_NS_ID, "startNode");
  54481. }
  54482. }
  54483. class StartPage extends _xfa_object.IntegerObject {
  54484. constructor(attributes) {
  54485. super(CONFIG_NS_ID, "startPage", 0, n => true);
  54486. }
  54487. }
  54488. class SubmitFormat extends _xfa_object.OptionObject {
  54489. constructor(attributes) {
  54490. super(CONFIG_NS_ID, "submitFormat", ["html", "delegate", "fdf", "xml", "pdf"]);
  54491. }
  54492. }
  54493. class SubmitUrl extends _xfa_object.StringObject {
  54494. constructor(attributes) {
  54495. super(CONFIG_NS_ID, "submitUrl");
  54496. }
  54497. }
  54498. class SubsetBelow extends _xfa_object.IntegerObject {
  54499. constructor(attributes) {
  54500. super(CONFIG_NS_ID, "subsetBelow", 100, n => n >= 0 && n <= 100);
  54501. }
  54502. }
  54503. class SuppressBanner extends _xfa_object.Option01 {
  54504. constructor(attributes) {
  54505. super(CONFIG_NS_ID, "suppressBanner");
  54506. }
  54507. }
  54508. class Tagged extends _xfa_object.Option01 {
  54509. constructor(attributes) {
  54510. super(CONFIG_NS_ID, "tagged");
  54511. }
  54512. }
  54513. class Template extends _xfa_object.XFAObject {
  54514. constructor(attributes) {
  54515. super(CONFIG_NS_ID, "template", true);
  54516. this.base = null;
  54517. this.relevant = null;
  54518. this.startPage = null;
  54519. this.uri = null;
  54520. this.xsl = null;
  54521. }
  54522. }
  54523. class Threshold extends _xfa_object.OptionObject {
  54524. constructor(attributes) {
  54525. super(CONFIG_NS_ID, "threshold", ["trace", "error", "information", "warning"]);
  54526. }
  54527. }
  54528. class To extends _xfa_object.OptionObject {
  54529. constructor(attributes) {
  54530. super(CONFIG_NS_ID, "to", ["null", "memory", "stderr", "stdout", "system", "uri"]);
  54531. }
  54532. }
  54533. class TemplateCache extends _xfa_object.XFAObject {
  54534. constructor(attributes) {
  54535. super(CONFIG_NS_ID, "templateCache");
  54536. this.maxEntries = (0, _utils.getInteger)({
  54537. data: attributes.maxEntries,
  54538. defaultValue: 5,
  54539. validate: n => n >= 0
  54540. });
  54541. }
  54542. }
  54543. class Trace extends _xfa_object.XFAObject {
  54544. constructor(attributes) {
  54545. super(CONFIG_NS_ID, "trace", true);
  54546. this.area = new _xfa_object.XFAObjectArray();
  54547. }
  54548. }
  54549. class Transform extends _xfa_object.XFAObject {
  54550. constructor(attributes) {
  54551. super(CONFIG_NS_ID, "transform", true);
  54552. this.groupParent = null;
  54553. this.ifEmpty = null;
  54554. this.nameAttr = null;
  54555. this.picture = null;
  54556. this.presence = null;
  54557. this.rename = null;
  54558. this.whitespace = null;
  54559. }
  54560. }
  54561. class Type extends _xfa_object.OptionObject {
  54562. constructor(attributes) {
  54563. super(CONFIG_NS_ID, "type", ["none", "ascii85", "asciiHex", "ccittfax", "flate", "lzw", "runLength", "native", "xdp", "mergedXDP"]);
  54564. }
  54565. }
  54566. class Uri extends _xfa_object.StringObject {
  54567. constructor(attributes) {
  54568. super(CONFIG_NS_ID, "uri");
  54569. }
  54570. }
  54571. class Validate extends _xfa_object.OptionObject {
  54572. constructor(attributes) {
  54573. super(CONFIG_NS_ID, "validate", ["preSubmit", "prePrint", "preExecute", "preSave"]);
  54574. }
  54575. }
  54576. class ValidateApprovalSignatures extends _xfa_object.ContentObject {
  54577. constructor(attributes) {
  54578. super(CONFIG_NS_ID, "validateApprovalSignatures");
  54579. }
  54580. [_symbol_utils.$finalize]() {
  54581. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => ["docReady", "postSign"].includes(x));
  54582. }
  54583. }
  54584. class ValidationMessaging extends _xfa_object.OptionObject {
  54585. constructor(attributes) {
  54586. super(CONFIG_NS_ID, "validationMessaging", ["allMessagesIndividually", "allMessagesTogether", "firstMessageOnly", "noMessages"]);
  54587. }
  54588. }
  54589. class Version extends _xfa_object.OptionObject {
  54590. constructor(attributes) {
  54591. super(CONFIG_NS_ID, "version", ["1.7", "1.6", "1.5", "1.4", "1.3", "1.2"]);
  54592. }
  54593. }
  54594. class VersionControl extends _xfa_object.XFAObject {
  54595. constructor(attributes) {
  54596. super(CONFIG_NS_ID, "VersionControl");
  54597. this.outputBelow = (0, _utils.getStringOption)(attributes.outputBelow, ["warn", "error", "update"]);
  54598. this.sourceAbove = (0, _utils.getStringOption)(attributes.sourceAbove, ["warn", "error"]);
  54599. this.sourceBelow = (0, _utils.getStringOption)(attributes.sourceBelow, ["update", "maintain"]);
  54600. }
  54601. }
  54602. class ViewerPreferences extends _xfa_object.XFAObject {
  54603. constructor(attributes) {
  54604. super(CONFIG_NS_ID, "viewerPreferences", true);
  54605. this.ADBE_JSConsole = null;
  54606. this.ADBE_JSDebugger = null;
  54607. this.addViewerPreferences = null;
  54608. this.duplexOption = null;
  54609. this.enforce = null;
  54610. this.numberOfCopies = null;
  54611. this.pageRange = null;
  54612. this.pickTrayByPDFSize = null;
  54613. this.printScaling = null;
  54614. }
  54615. }
  54616. class WebClient extends _xfa_object.XFAObject {
  54617. constructor(attributes) {
  54618. super(CONFIG_NS_ID, "webClient", true);
  54619. this.name = attributes.name ? attributes.name.trim() : "";
  54620. this.fontInfo = null;
  54621. this.xdc = null;
  54622. }
  54623. }
  54624. class Whitespace extends _xfa_object.OptionObject {
  54625. constructor(attributes) {
  54626. super(CONFIG_NS_ID, "whitespace", ["preserve", "ltrim", "normalize", "rtrim", "trim"]);
  54627. }
  54628. }
  54629. class Window extends _xfa_object.ContentObject {
  54630. constructor(attributes) {
  54631. super(CONFIG_NS_ID, "window");
  54632. }
  54633. [_symbol_utils.$finalize]() {
  54634. const pair = this[_symbol_utils.$content].trim().split(/\s*,\s*/, 2).map(x => parseInt(x, 10));
  54635. if (pair.some(x => isNaN(x))) {
  54636. this[_symbol_utils.$content] = [0, 0];
  54637. return;
  54638. }
  54639. if (pair.length === 1) {
  54640. pair.push(pair[0]);
  54641. }
  54642. this[_symbol_utils.$content] = pair;
  54643. }
  54644. }
  54645. class Xdc extends _xfa_object.XFAObject {
  54646. constructor(attributes) {
  54647. super(CONFIG_NS_ID, "xdc", true);
  54648. this.uri = new _xfa_object.XFAObjectArray();
  54649. this.xsl = new _xfa_object.XFAObjectArray();
  54650. }
  54651. }
  54652. class Xdp extends _xfa_object.XFAObject {
  54653. constructor(attributes) {
  54654. super(CONFIG_NS_ID, "xdp", true);
  54655. this.packets = null;
  54656. }
  54657. }
  54658. class Xsl extends _xfa_object.XFAObject {
  54659. constructor(attributes) {
  54660. super(CONFIG_NS_ID, "xsl", true);
  54661. this.debug = null;
  54662. this.uri = null;
  54663. }
  54664. }
  54665. class Zpl extends _xfa_object.XFAObject {
  54666. constructor(attributes) {
  54667. super(CONFIG_NS_ID, "zpl", true);
  54668. this.name = attributes.name ? attributes.name.trim() : "";
  54669. this.batchOutput = null;
  54670. this.flipLabel = null;
  54671. this.fontInfo = null;
  54672. this.xdc = null;
  54673. }
  54674. }
  54675. class ConfigNamespace {
  54676. static [_namespaces.$buildXFAObject](name, attributes) {
  54677. if (ConfigNamespace.hasOwnProperty(name)) {
  54678. return ConfigNamespace[name](attributes);
  54679. }
  54680. return undefined;
  54681. }
  54682. static acrobat(attrs) {
  54683. return new Acrobat(attrs);
  54684. }
  54685. static acrobat7(attrs) {
  54686. return new Acrobat7(attrs);
  54687. }
  54688. static ADBE_JSConsole(attrs) {
  54689. return new ADBE_JSConsole(attrs);
  54690. }
  54691. static ADBE_JSDebugger(attrs) {
  54692. return new ADBE_JSDebugger(attrs);
  54693. }
  54694. static addSilentPrint(attrs) {
  54695. return new AddSilentPrint(attrs);
  54696. }
  54697. static addViewerPreferences(attrs) {
  54698. return new AddViewerPreferences(attrs);
  54699. }
  54700. static adjustData(attrs) {
  54701. return new AdjustData(attrs);
  54702. }
  54703. static adobeExtensionLevel(attrs) {
  54704. return new AdobeExtensionLevel(attrs);
  54705. }
  54706. static agent(attrs) {
  54707. return new Agent(attrs);
  54708. }
  54709. static alwaysEmbed(attrs) {
  54710. return new AlwaysEmbed(attrs);
  54711. }
  54712. static amd(attrs) {
  54713. return new Amd(attrs);
  54714. }
  54715. static area(attrs) {
  54716. return new Area(attrs);
  54717. }
  54718. static attributes(attrs) {
  54719. return new Attributes(attrs);
  54720. }
  54721. static autoSave(attrs) {
  54722. return new AutoSave(attrs);
  54723. }
  54724. static base(attrs) {
  54725. return new Base(attrs);
  54726. }
  54727. static batchOutput(attrs) {
  54728. return new BatchOutput(attrs);
  54729. }
  54730. static behaviorOverride(attrs) {
  54731. return new BehaviorOverride(attrs);
  54732. }
  54733. static cache(attrs) {
  54734. return new Cache(attrs);
  54735. }
  54736. static change(attrs) {
  54737. return new Change(attrs);
  54738. }
  54739. static common(attrs) {
  54740. return new Common(attrs);
  54741. }
  54742. static compress(attrs) {
  54743. return new Compress(attrs);
  54744. }
  54745. static compressLogicalStructure(attrs) {
  54746. return new CompressLogicalStructure(attrs);
  54747. }
  54748. static compressObjectStream(attrs) {
  54749. return new CompressObjectStream(attrs);
  54750. }
  54751. static compression(attrs) {
  54752. return new Compression(attrs);
  54753. }
  54754. static config(attrs) {
  54755. return new Config(attrs);
  54756. }
  54757. static conformance(attrs) {
  54758. return new Conformance(attrs);
  54759. }
  54760. static contentCopy(attrs) {
  54761. return new ContentCopy(attrs);
  54762. }
  54763. static copies(attrs) {
  54764. return new Copies(attrs);
  54765. }
  54766. static creator(attrs) {
  54767. return new Creator(attrs);
  54768. }
  54769. static currentPage(attrs) {
  54770. return new CurrentPage(attrs);
  54771. }
  54772. static data(attrs) {
  54773. return new Data(attrs);
  54774. }
  54775. static debug(attrs) {
  54776. return new Debug(attrs);
  54777. }
  54778. static defaultTypeface(attrs) {
  54779. return new DefaultTypeface(attrs);
  54780. }
  54781. static destination(attrs) {
  54782. return new Destination(attrs);
  54783. }
  54784. static documentAssembly(attrs) {
  54785. return new DocumentAssembly(attrs);
  54786. }
  54787. static driver(attrs) {
  54788. return new Driver(attrs);
  54789. }
  54790. static duplexOption(attrs) {
  54791. return new DuplexOption(attrs);
  54792. }
  54793. static dynamicRender(attrs) {
  54794. return new DynamicRender(attrs);
  54795. }
  54796. static embed(attrs) {
  54797. return new Embed(attrs);
  54798. }
  54799. static encrypt(attrs) {
  54800. return new Encrypt(attrs);
  54801. }
  54802. static encryption(attrs) {
  54803. return new Encryption(attrs);
  54804. }
  54805. static encryptionLevel(attrs) {
  54806. return new EncryptionLevel(attrs);
  54807. }
  54808. static enforce(attrs) {
  54809. return new Enforce(attrs);
  54810. }
  54811. static equate(attrs) {
  54812. return new Equate(attrs);
  54813. }
  54814. static equateRange(attrs) {
  54815. return new EquateRange(attrs);
  54816. }
  54817. static exclude(attrs) {
  54818. return new Exclude(attrs);
  54819. }
  54820. static excludeNS(attrs) {
  54821. return new ExcludeNS(attrs);
  54822. }
  54823. static flipLabel(attrs) {
  54824. return new FlipLabel(attrs);
  54825. }
  54826. static fontInfo(attrs) {
  54827. return new FontInfo(attrs);
  54828. }
  54829. static formFieldFilling(attrs) {
  54830. return new FormFieldFilling(attrs);
  54831. }
  54832. static groupParent(attrs) {
  54833. return new GroupParent(attrs);
  54834. }
  54835. static ifEmpty(attrs) {
  54836. return new IfEmpty(attrs);
  54837. }
  54838. static includeXDPContent(attrs) {
  54839. return new IncludeXDPContent(attrs);
  54840. }
  54841. static incrementalLoad(attrs) {
  54842. return new IncrementalLoad(attrs);
  54843. }
  54844. static incrementalMerge(attrs) {
  54845. return new IncrementalMerge(attrs);
  54846. }
  54847. static interactive(attrs) {
  54848. return new Interactive(attrs);
  54849. }
  54850. static jog(attrs) {
  54851. return new Jog(attrs);
  54852. }
  54853. static labelPrinter(attrs) {
  54854. return new LabelPrinter(attrs);
  54855. }
  54856. static layout(attrs) {
  54857. return new Layout(attrs);
  54858. }
  54859. static level(attrs) {
  54860. return new Level(attrs);
  54861. }
  54862. static linearized(attrs) {
  54863. return new Linearized(attrs);
  54864. }
  54865. static locale(attrs) {
  54866. return new Locale(attrs);
  54867. }
  54868. static localeSet(attrs) {
  54869. return new LocaleSet(attrs);
  54870. }
  54871. static log(attrs) {
  54872. return new Log(attrs);
  54873. }
  54874. static map(attrs) {
  54875. return new MapElement(attrs);
  54876. }
  54877. static mediumInfo(attrs) {
  54878. return new MediumInfo(attrs);
  54879. }
  54880. static message(attrs) {
  54881. return new Message(attrs);
  54882. }
  54883. static messaging(attrs) {
  54884. return new Messaging(attrs);
  54885. }
  54886. static mode(attrs) {
  54887. return new Mode(attrs);
  54888. }
  54889. static modifyAnnots(attrs) {
  54890. return new ModifyAnnots(attrs);
  54891. }
  54892. static msgId(attrs) {
  54893. return new MsgId(attrs);
  54894. }
  54895. static nameAttr(attrs) {
  54896. return new NameAttr(attrs);
  54897. }
  54898. static neverEmbed(attrs) {
  54899. return new NeverEmbed(attrs);
  54900. }
  54901. static numberOfCopies(attrs) {
  54902. return new NumberOfCopies(attrs);
  54903. }
  54904. static openAction(attrs) {
  54905. return new OpenAction(attrs);
  54906. }
  54907. static output(attrs) {
  54908. return new Output(attrs);
  54909. }
  54910. static outputBin(attrs) {
  54911. return new OutputBin(attrs);
  54912. }
  54913. static outputXSL(attrs) {
  54914. return new OutputXSL(attrs);
  54915. }
  54916. static overprint(attrs) {
  54917. return new Overprint(attrs);
  54918. }
  54919. static packets(attrs) {
  54920. return new Packets(attrs);
  54921. }
  54922. static pageOffset(attrs) {
  54923. return new PageOffset(attrs);
  54924. }
  54925. static pageRange(attrs) {
  54926. return new PageRange(attrs);
  54927. }
  54928. static pagination(attrs) {
  54929. return new Pagination(attrs);
  54930. }
  54931. static paginationOverride(attrs) {
  54932. return new PaginationOverride(attrs);
  54933. }
  54934. static part(attrs) {
  54935. return new Part(attrs);
  54936. }
  54937. static pcl(attrs) {
  54938. return new Pcl(attrs);
  54939. }
  54940. static pdf(attrs) {
  54941. return new Pdf(attrs);
  54942. }
  54943. static pdfa(attrs) {
  54944. return new Pdfa(attrs);
  54945. }
  54946. static permissions(attrs) {
  54947. return new Permissions(attrs);
  54948. }
  54949. static pickTrayByPDFSize(attrs) {
  54950. return new PickTrayByPDFSize(attrs);
  54951. }
  54952. static picture(attrs) {
  54953. return new Picture(attrs);
  54954. }
  54955. static plaintextMetadata(attrs) {
  54956. return new PlaintextMetadata(attrs);
  54957. }
  54958. static presence(attrs) {
  54959. return new Presence(attrs);
  54960. }
  54961. static present(attrs) {
  54962. return new Present(attrs);
  54963. }
  54964. static print(attrs) {
  54965. return new Print(attrs);
  54966. }
  54967. static printHighQuality(attrs) {
  54968. return new PrintHighQuality(attrs);
  54969. }
  54970. static printScaling(attrs) {
  54971. return new PrintScaling(attrs);
  54972. }
  54973. static printerName(attrs) {
  54974. return new PrinterName(attrs);
  54975. }
  54976. static producer(attrs) {
  54977. return new Producer(attrs);
  54978. }
  54979. static ps(attrs) {
  54980. return new Ps(attrs);
  54981. }
  54982. static range(attrs) {
  54983. return new Range(attrs);
  54984. }
  54985. static record(attrs) {
  54986. return new Record(attrs);
  54987. }
  54988. static relevant(attrs) {
  54989. return new Relevant(attrs);
  54990. }
  54991. static rename(attrs) {
  54992. return new Rename(attrs);
  54993. }
  54994. static renderPolicy(attrs) {
  54995. return new RenderPolicy(attrs);
  54996. }
  54997. static runScripts(attrs) {
  54998. return new RunScripts(attrs);
  54999. }
  55000. static script(attrs) {
  55001. return new Script(attrs);
  55002. }
  55003. static scriptModel(attrs) {
  55004. return new ScriptModel(attrs);
  55005. }
  55006. static severity(attrs) {
  55007. return new Severity(attrs);
  55008. }
  55009. static silentPrint(attrs) {
  55010. return new SilentPrint(attrs);
  55011. }
  55012. static staple(attrs) {
  55013. return new Staple(attrs);
  55014. }
  55015. static startNode(attrs) {
  55016. return new StartNode(attrs);
  55017. }
  55018. static startPage(attrs) {
  55019. return new StartPage(attrs);
  55020. }
  55021. static submitFormat(attrs) {
  55022. return new SubmitFormat(attrs);
  55023. }
  55024. static submitUrl(attrs) {
  55025. return new SubmitUrl(attrs);
  55026. }
  55027. static subsetBelow(attrs) {
  55028. return new SubsetBelow(attrs);
  55029. }
  55030. static suppressBanner(attrs) {
  55031. return new SuppressBanner(attrs);
  55032. }
  55033. static tagged(attrs) {
  55034. return new Tagged(attrs);
  55035. }
  55036. static template(attrs) {
  55037. return new Template(attrs);
  55038. }
  55039. static templateCache(attrs) {
  55040. return new TemplateCache(attrs);
  55041. }
  55042. static threshold(attrs) {
  55043. return new Threshold(attrs);
  55044. }
  55045. static to(attrs) {
  55046. return new To(attrs);
  55047. }
  55048. static trace(attrs) {
  55049. return new Trace(attrs);
  55050. }
  55051. static transform(attrs) {
  55052. return new Transform(attrs);
  55053. }
  55054. static type(attrs) {
  55055. return new Type(attrs);
  55056. }
  55057. static uri(attrs) {
  55058. return new Uri(attrs);
  55059. }
  55060. static validate(attrs) {
  55061. return new Validate(attrs);
  55062. }
  55063. static validateApprovalSignatures(attrs) {
  55064. return new ValidateApprovalSignatures(attrs);
  55065. }
  55066. static validationMessaging(attrs) {
  55067. return new ValidationMessaging(attrs);
  55068. }
  55069. static version(attrs) {
  55070. return new Version(attrs);
  55071. }
  55072. static versionControl(attrs) {
  55073. return new VersionControl(attrs);
  55074. }
  55075. static viewerPreferences(attrs) {
  55076. return new ViewerPreferences(attrs);
  55077. }
  55078. static webClient(attrs) {
  55079. return new WebClient(attrs);
  55080. }
  55081. static whitespace(attrs) {
  55082. return new Whitespace(attrs);
  55083. }
  55084. static window(attrs) {
  55085. return new Window(attrs);
  55086. }
  55087. static xdc(attrs) {
  55088. return new Xdc(attrs);
  55089. }
  55090. static xdp(attrs) {
  55091. return new Xdp(attrs);
  55092. }
  55093. static xsl(attrs) {
  55094. return new Xsl(attrs);
  55095. }
  55096. static zpl(attrs) {
  55097. return new Zpl(attrs);
  55098. }
  55099. }
  55100. exports.ConfigNamespace = ConfigNamespace;
  55101. /***/ }),
  55102. /* 94 */
  55103. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55104. Object.defineProperty(exports, "__esModule", ({
  55105. value: true
  55106. }));
  55107. exports.ConnectionSetNamespace = void 0;
  55108. var _namespaces = __w_pdfjs_require__(81);
  55109. var _xfa_object = __w_pdfjs_require__(87);
  55110. const CONNECTION_SET_NS_ID = _namespaces.NamespaceIds.connectionSet.id;
  55111. class ConnectionSet extends _xfa_object.XFAObject {
  55112. constructor(attributes) {
  55113. super(CONNECTION_SET_NS_ID, "connectionSet", true);
  55114. this.wsdlConnection = new _xfa_object.XFAObjectArray();
  55115. this.xmlConnection = new _xfa_object.XFAObjectArray();
  55116. this.xsdConnection = new _xfa_object.XFAObjectArray();
  55117. }
  55118. }
  55119. class EffectiveInputPolicy extends _xfa_object.XFAObject {
  55120. constructor(attributes) {
  55121. super(CONNECTION_SET_NS_ID, "effectiveInputPolicy");
  55122. this.id = attributes.id || "";
  55123. this.name = attributes.name || "";
  55124. this.use = attributes.use || "";
  55125. this.usehref = attributes.usehref || "";
  55126. }
  55127. }
  55128. class EffectiveOutputPolicy extends _xfa_object.XFAObject {
  55129. constructor(attributes) {
  55130. super(CONNECTION_SET_NS_ID, "effectiveOutputPolicy");
  55131. this.id = attributes.id || "";
  55132. this.name = attributes.name || "";
  55133. this.use = attributes.use || "";
  55134. this.usehref = attributes.usehref || "";
  55135. }
  55136. }
  55137. class Operation extends _xfa_object.StringObject {
  55138. constructor(attributes) {
  55139. super(CONNECTION_SET_NS_ID, "operation");
  55140. this.id = attributes.id || "";
  55141. this.input = attributes.input || "";
  55142. this.name = attributes.name || "";
  55143. this.output = attributes.output || "";
  55144. this.use = attributes.use || "";
  55145. this.usehref = attributes.usehref || "";
  55146. }
  55147. }
  55148. class RootElement extends _xfa_object.StringObject {
  55149. constructor(attributes) {
  55150. super(CONNECTION_SET_NS_ID, "rootElement");
  55151. this.id = attributes.id || "";
  55152. this.name = attributes.name || "";
  55153. this.use = attributes.use || "";
  55154. this.usehref = attributes.usehref || "";
  55155. }
  55156. }
  55157. class SoapAction extends _xfa_object.StringObject {
  55158. constructor(attributes) {
  55159. super(CONNECTION_SET_NS_ID, "soapAction");
  55160. this.id = attributes.id || "";
  55161. this.name = attributes.name || "";
  55162. this.use = attributes.use || "";
  55163. this.usehref = attributes.usehref || "";
  55164. }
  55165. }
  55166. class SoapAddress extends _xfa_object.StringObject {
  55167. constructor(attributes) {
  55168. super(CONNECTION_SET_NS_ID, "soapAddress");
  55169. this.id = attributes.id || "";
  55170. this.name = attributes.name || "";
  55171. this.use = attributes.use || "";
  55172. this.usehref = attributes.usehref || "";
  55173. }
  55174. }
  55175. class Uri extends _xfa_object.StringObject {
  55176. constructor(attributes) {
  55177. super(CONNECTION_SET_NS_ID, "uri");
  55178. this.id = attributes.id || "";
  55179. this.name = attributes.name || "";
  55180. this.use = attributes.use || "";
  55181. this.usehref = attributes.usehref || "";
  55182. }
  55183. }
  55184. class WsdlAddress extends _xfa_object.StringObject {
  55185. constructor(attributes) {
  55186. super(CONNECTION_SET_NS_ID, "wsdlAddress");
  55187. this.id = attributes.id || "";
  55188. this.name = attributes.name || "";
  55189. this.use = attributes.use || "";
  55190. this.usehref = attributes.usehref || "";
  55191. }
  55192. }
  55193. class WsdlConnection extends _xfa_object.XFAObject {
  55194. constructor(attributes) {
  55195. super(CONNECTION_SET_NS_ID, "wsdlConnection", true);
  55196. this.dataDescription = attributes.dataDescription || "";
  55197. this.name = attributes.name || "";
  55198. this.effectiveInputPolicy = null;
  55199. this.effectiveOutputPolicy = null;
  55200. this.operation = null;
  55201. this.soapAction = null;
  55202. this.soapAddress = null;
  55203. this.wsdlAddress = null;
  55204. }
  55205. }
  55206. class XmlConnection extends _xfa_object.XFAObject {
  55207. constructor(attributes) {
  55208. super(CONNECTION_SET_NS_ID, "xmlConnection", true);
  55209. this.dataDescription = attributes.dataDescription || "";
  55210. this.name = attributes.name || "";
  55211. this.uri = null;
  55212. }
  55213. }
  55214. class XsdConnection extends _xfa_object.XFAObject {
  55215. constructor(attributes) {
  55216. super(CONNECTION_SET_NS_ID, "xsdConnection", true);
  55217. this.dataDescription = attributes.dataDescription || "";
  55218. this.name = attributes.name || "";
  55219. this.rootElement = null;
  55220. this.uri = null;
  55221. }
  55222. }
  55223. class ConnectionSetNamespace {
  55224. static [_namespaces.$buildXFAObject](name, attributes) {
  55225. if (ConnectionSetNamespace.hasOwnProperty(name)) {
  55226. return ConnectionSetNamespace[name](attributes);
  55227. }
  55228. return undefined;
  55229. }
  55230. static connectionSet(attrs) {
  55231. return new ConnectionSet(attrs);
  55232. }
  55233. static effectiveInputPolicy(attrs) {
  55234. return new EffectiveInputPolicy(attrs);
  55235. }
  55236. static effectiveOutputPolicy(attrs) {
  55237. return new EffectiveOutputPolicy(attrs);
  55238. }
  55239. static operation(attrs) {
  55240. return new Operation(attrs);
  55241. }
  55242. static rootElement(attrs) {
  55243. return new RootElement(attrs);
  55244. }
  55245. static soapAction(attrs) {
  55246. return new SoapAction(attrs);
  55247. }
  55248. static soapAddress(attrs) {
  55249. return new SoapAddress(attrs);
  55250. }
  55251. static uri(attrs) {
  55252. return new Uri(attrs);
  55253. }
  55254. static wsdlAddress(attrs) {
  55255. return new WsdlAddress(attrs);
  55256. }
  55257. static wsdlConnection(attrs) {
  55258. return new WsdlConnection(attrs);
  55259. }
  55260. static xmlConnection(attrs) {
  55261. return new XmlConnection(attrs);
  55262. }
  55263. static xsdConnection(attrs) {
  55264. return new XsdConnection(attrs);
  55265. }
  55266. }
  55267. exports.ConnectionSetNamespace = ConnectionSetNamespace;
  55268. /***/ }),
  55269. /* 95 */
  55270. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55271. Object.defineProperty(exports, "__esModule", ({
  55272. value: true
  55273. }));
  55274. exports.DatasetsNamespace = void 0;
  55275. var _symbol_utils = __w_pdfjs_require__(78);
  55276. var _namespaces = __w_pdfjs_require__(81);
  55277. var _xfa_object = __w_pdfjs_require__(87);
  55278. const DATASETS_NS_ID = _namespaces.NamespaceIds.datasets.id;
  55279. class Data extends _xfa_object.XmlObject {
  55280. constructor(attributes) {
  55281. super(DATASETS_NS_ID, "data", attributes);
  55282. }
  55283. [_symbol_utils.$isNsAgnostic]() {
  55284. return true;
  55285. }
  55286. }
  55287. class Datasets extends _xfa_object.XFAObject {
  55288. constructor(attributes) {
  55289. super(DATASETS_NS_ID, "datasets", true);
  55290. this.data = null;
  55291. this.Signature = null;
  55292. }
  55293. [_symbol_utils.$onChild](child) {
  55294. const name = child[_symbol_utils.$nodeName];
  55295. if (name === "data" && child[_symbol_utils.$namespaceId] === DATASETS_NS_ID || name === "Signature" && child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.signature.id) {
  55296. this[name] = child;
  55297. }
  55298. this[_symbol_utils.$appendChild](child);
  55299. }
  55300. }
  55301. class DatasetsNamespace {
  55302. static [_namespaces.$buildXFAObject](name, attributes) {
  55303. if (DatasetsNamespace.hasOwnProperty(name)) {
  55304. return DatasetsNamespace[name](attributes);
  55305. }
  55306. return undefined;
  55307. }
  55308. static datasets(attributes) {
  55309. return new Datasets(attributes);
  55310. }
  55311. static data(attributes) {
  55312. return new Data(attributes);
  55313. }
  55314. }
  55315. exports.DatasetsNamespace = DatasetsNamespace;
  55316. /***/ }),
  55317. /* 96 */
  55318. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55319. Object.defineProperty(exports, "__esModule", ({
  55320. value: true
  55321. }));
  55322. exports.LocaleSetNamespace = void 0;
  55323. var _namespaces = __w_pdfjs_require__(81);
  55324. var _xfa_object = __w_pdfjs_require__(87);
  55325. var _utils = __w_pdfjs_require__(84);
  55326. const LOCALE_SET_NS_ID = _namespaces.NamespaceIds.localeSet.id;
  55327. class CalendarSymbols extends _xfa_object.XFAObject {
  55328. constructor(attributes) {
  55329. super(LOCALE_SET_NS_ID, "calendarSymbols", true);
  55330. this.name = "gregorian";
  55331. this.dayNames = new _xfa_object.XFAObjectArray(2);
  55332. this.eraNames = null;
  55333. this.meridiemNames = null;
  55334. this.monthNames = new _xfa_object.XFAObjectArray(2);
  55335. }
  55336. }
  55337. class CurrencySymbol extends _xfa_object.StringObject {
  55338. constructor(attributes) {
  55339. super(LOCALE_SET_NS_ID, "currencySymbol");
  55340. this.name = (0, _utils.getStringOption)(attributes.name, ["symbol", "isoname", "decimal"]);
  55341. }
  55342. }
  55343. class CurrencySymbols extends _xfa_object.XFAObject {
  55344. constructor(attributes) {
  55345. super(LOCALE_SET_NS_ID, "currencySymbols", true);
  55346. this.currencySymbol = new _xfa_object.XFAObjectArray(3);
  55347. }
  55348. }
  55349. class DatePattern extends _xfa_object.StringObject {
  55350. constructor(attributes) {
  55351. super(LOCALE_SET_NS_ID, "datePattern");
  55352. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  55353. }
  55354. }
  55355. class DatePatterns extends _xfa_object.XFAObject {
  55356. constructor(attributes) {
  55357. super(LOCALE_SET_NS_ID, "datePatterns", true);
  55358. this.datePattern = new _xfa_object.XFAObjectArray(4);
  55359. }
  55360. }
  55361. class DateTimeSymbols extends _xfa_object.ContentObject {
  55362. constructor(attributes) {
  55363. super(LOCALE_SET_NS_ID, "dateTimeSymbols");
  55364. }
  55365. }
  55366. class Day extends _xfa_object.StringObject {
  55367. constructor(attributes) {
  55368. super(LOCALE_SET_NS_ID, "day");
  55369. }
  55370. }
  55371. class DayNames extends _xfa_object.XFAObject {
  55372. constructor(attributes) {
  55373. super(LOCALE_SET_NS_ID, "dayNames", true);
  55374. this.abbr = (0, _utils.getInteger)({
  55375. data: attributes.abbr,
  55376. defaultValue: 0,
  55377. validate: x => x === 1
  55378. });
  55379. this.day = new _xfa_object.XFAObjectArray(7);
  55380. }
  55381. }
  55382. class Era extends _xfa_object.StringObject {
  55383. constructor(attributes) {
  55384. super(LOCALE_SET_NS_ID, "era");
  55385. }
  55386. }
  55387. class EraNames extends _xfa_object.XFAObject {
  55388. constructor(attributes) {
  55389. super(LOCALE_SET_NS_ID, "eraNames", true);
  55390. this.era = new _xfa_object.XFAObjectArray(2);
  55391. }
  55392. }
  55393. class Locale extends _xfa_object.XFAObject {
  55394. constructor(attributes) {
  55395. super(LOCALE_SET_NS_ID, "locale", true);
  55396. this.desc = attributes.desc || "";
  55397. this.name = "isoname";
  55398. this.calendarSymbols = null;
  55399. this.currencySymbols = null;
  55400. this.datePatterns = null;
  55401. this.dateTimeSymbols = null;
  55402. this.numberPatterns = null;
  55403. this.numberSymbols = null;
  55404. this.timePatterns = null;
  55405. this.typeFaces = null;
  55406. }
  55407. }
  55408. class LocaleSet extends _xfa_object.XFAObject {
  55409. constructor(attributes) {
  55410. super(LOCALE_SET_NS_ID, "localeSet", true);
  55411. this.locale = new _xfa_object.XFAObjectArray();
  55412. }
  55413. }
  55414. class Meridiem extends _xfa_object.StringObject {
  55415. constructor(attributes) {
  55416. super(LOCALE_SET_NS_ID, "meridiem");
  55417. }
  55418. }
  55419. class MeridiemNames extends _xfa_object.XFAObject {
  55420. constructor(attributes) {
  55421. super(LOCALE_SET_NS_ID, "meridiemNames", true);
  55422. this.meridiem = new _xfa_object.XFAObjectArray(2);
  55423. }
  55424. }
  55425. class Month extends _xfa_object.StringObject {
  55426. constructor(attributes) {
  55427. super(LOCALE_SET_NS_ID, "month");
  55428. }
  55429. }
  55430. class MonthNames extends _xfa_object.XFAObject {
  55431. constructor(attributes) {
  55432. super(LOCALE_SET_NS_ID, "monthNames", true);
  55433. this.abbr = (0, _utils.getInteger)({
  55434. data: attributes.abbr,
  55435. defaultValue: 0,
  55436. validate: x => x === 1
  55437. });
  55438. this.month = new _xfa_object.XFAObjectArray(12);
  55439. }
  55440. }
  55441. class NumberPattern extends _xfa_object.StringObject {
  55442. constructor(attributes) {
  55443. super(LOCALE_SET_NS_ID, "numberPattern");
  55444. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  55445. }
  55446. }
  55447. class NumberPatterns extends _xfa_object.XFAObject {
  55448. constructor(attributes) {
  55449. super(LOCALE_SET_NS_ID, "numberPatterns", true);
  55450. this.numberPattern = new _xfa_object.XFAObjectArray(4);
  55451. }
  55452. }
  55453. class NumberSymbol extends _xfa_object.StringObject {
  55454. constructor(attributes) {
  55455. super(LOCALE_SET_NS_ID, "numberSymbol");
  55456. this.name = (0, _utils.getStringOption)(attributes.name, ["decimal", "grouping", "percent", "minus", "zero"]);
  55457. }
  55458. }
  55459. class NumberSymbols extends _xfa_object.XFAObject {
  55460. constructor(attributes) {
  55461. super(LOCALE_SET_NS_ID, "numberSymbols", true);
  55462. this.numberSymbol = new _xfa_object.XFAObjectArray(5);
  55463. }
  55464. }
  55465. class TimePattern extends _xfa_object.StringObject {
  55466. constructor(attributes) {
  55467. super(LOCALE_SET_NS_ID, "timePattern");
  55468. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  55469. }
  55470. }
  55471. class TimePatterns extends _xfa_object.XFAObject {
  55472. constructor(attributes) {
  55473. super(LOCALE_SET_NS_ID, "timePatterns", true);
  55474. this.timePattern = new _xfa_object.XFAObjectArray(4);
  55475. }
  55476. }
  55477. class TypeFace extends _xfa_object.XFAObject {
  55478. constructor(attributes) {
  55479. super(LOCALE_SET_NS_ID, "typeFace", true);
  55480. this.name = attributes.name | "";
  55481. }
  55482. }
  55483. class TypeFaces extends _xfa_object.XFAObject {
  55484. constructor(attributes) {
  55485. super(LOCALE_SET_NS_ID, "typeFaces", true);
  55486. this.typeFace = new _xfa_object.XFAObjectArray();
  55487. }
  55488. }
  55489. class LocaleSetNamespace {
  55490. static [_namespaces.$buildXFAObject](name, attributes) {
  55491. if (LocaleSetNamespace.hasOwnProperty(name)) {
  55492. return LocaleSetNamespace[name](attributes);
  55493. }
  55494. return undefined;
  55495. }
  55496. static calendarSymbols(attrs) {
  55497. return new CalendarSymbols(attrs);
  55498. }
  55499. static currencySymbol(attrs) {
  55500. return new CurrencySymbol(attrs);
  55501. }
  55502. static currencySymbols(attrs) {
  55503. return new CurrencySymbols(attrs);
  55504. }
  55505. static datePattern(attrs) {
  55506. return new DatePattern(attrs);
  55507. }
  55508. static datePatterns(attrs) {
  55509. return new DatePatterns(attrs);
  55510. }
  55511. static dateTimeSymbols(attrs) {
  55512. return new DateTimeSymbols(attrs);
  55513. }
  55514. static day(attrs) {
  55515. return new Day(attrs);
  55516. }
  55517. static dayNames(attrs) {
  55518. return new DayNames(attrs);
  55519. }
  55520. static era(attrs) {
  55521. return new Era(attrs);
  55522. }
  55523. static eraNames(attrs) {
  55524. return new EraNames(attrs);
  55525. }
  55526. static locale(attrs) {
  55527. return new Locale(attrs);
  55528. }
  55529. static localeSet(attrs) {
  55530. return new LocaleSet(attrs);
  55531. }
  55532. static meridiem(attrs) {
  55533. return new Meridiem(attrs);
  55534. }
  55535. static meridiemNames(attrs) {
  55536. return new MeridiemNames(attrs);
  55537. }
  55538. static month(attrs) {
  55539. return new Month(attrs);
  55540. }
  55541. static monthNames(attrs) {
  55542. return new MonthNames(attrs);
  55543. }
  55544. static numberPattern(attrs) {
  55545. return new NumberPattern(attrs);
  55546. }
  55547. static numberPatterns(attrs) {
  55548. return new NumberPatterns(attrs);
  55549. }
  55550. static numberSymbol(attrs) {
  55551. return new NumberSymbol(attrs);
  55552. }
  55553. static numberSymbols(attrs) {
  55554. return new NumberSymbols(attrs);
  55555. }
  55556. static timePattern(attrs) {
  55557. return new TimePattern(attrs);
  55558. }
  55559. static timePatterns(attrs) {
  55560. return new TimePatterns(attrs);
  55561. }
  55562. static typeFace(attrs) {
  55563. return new TypeFace(attrs);
  55564. }
  55565. static typeFaces(attrs) {
  55566. return new TypeFaces(attrs);
  55567. }
  55568. }
  55569. exports.LocaleSetNamespace = LocaleSetNamespace;
  55570. /***/ }),
  55571. /* 97 */
  55572. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55573. Object.defineProperty(exports, "__esModule", ({
  55574. value: true
  55575. }));
  55576. exports.SignatureNamespace = void 0;
  55577. var _namespaces = __w_pdfjs_require__(81);
  55578. var _xfa_object = __w_pdfjs_require__(87);
  55579. const SIGNATURE_NS_ID = _namespaces.NamespaceIds.signature.id;
  55580. class Signature extends _xfa_object.XFAObject {
  55581. constructor(attributes) {
  55582. super(SIGNATURE_NS_ID, "signature", true);
  55583. }
  55584. }
  55585. class SignatureNamespace {
  55586. static [_namespaces.$buildXFAObject](name, attributes) {
  55587. if (SignatureNamespace.hasOwnProperty(name)) {
  55588. return SignatureNamespace[name](attributes);
  55589. }
  55590. return undefined;
  55591. }
  55592. static signature(attributes) {
  55593. return new Signature(attributes);
  55594. }
  55595. }
  55596. exports.SignatureNamespace = SignatureNamespace;
  55597. /***/ }),
  55598. /* 98 */
  55599. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55600. Object.defineProperty(exports, "__esModule", ({
  55601. value: true
  55602. }));
  55603. exports.StylesheetNamespace = void 0;
  55604. var _namespaces = __w_pdfjs_require__(81);
  55605. var _xfa_object = __w_pdfjs_require__(87);
  55606. const STYLESHEET_NS_ID = _namespaces.NamespaceIds.stylesheet.id;
  55607. class Stylesheet extends _xfa_object.XFAObject {
  55608. constructor(attributes) {
  55609. super(STYLESHEET_NS_ID, "stylesheet", true);
  55610. }
  55611. }
  55612. class StylesheetNamespace {
  55613. static [_namespaces.$buildXFAObject](name, attributes) {
  55614. if (StylesheetNamespace.hasOwnProperty(name)) {
  55615. return StylesheetNamespace[name](attributes);
  55616. }
  55617. return undefined;
  55618. }
  55619. static stylesheet(attributes) {
  55620. return new Stylesheet(attributes);
  55621. }
  55622. }
  55623. exports.StylesheetNamespace = StylesheetNamespace;
  55624. /***/ }),
  55625. /* 99 */
  55626. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55627. Object.defineProperty(exports, "__esModule", ({
  55628. value: true
  55629. }));
  55630. exports.XdpNamespace = void 0;
  55631. var _namespaces = __w_pdfjs_require__(81);
  55632. var _symbol_utils = __w_pdfjs_require__(78);
  55633. var _xfa_object = __w_pdfjs_require__(87);
  55634. const XDP_NS_ID = _namespaces.NamespaceIds.xdp.id;
  55635. class Xdp extends _xfa_object.XFAObject {
  55636. constructor(attributes) {
  55637. super(XDP_NS_ID, "xdp", true);
  55638. this.uuid = attributes.uuid || "";
  55639. this.timeStamp = attributes.timeStamp || "";
  55640. this.config = null;
  55641. this.connectionSet = null;
  55642. this.datasets = null;
  55643. this.localeSet = null;
  55644. this.stylesheet = new _xfa_object.XFAObjectArray();
  55645. this.template = null;
  55646. }
  55647. [_symbol_utils.$onChildCheck](child) {
  55648. const ns = _namespaces.NamespaceIds[child[_symbol_utils.$nodeName]];
  55649. return ns && child[_symbol_utils.$namespaceId] === ns.id;
  55650. }
  55651. }
  55652. class XdpNamespace {
  55653. static [_namespaces.$buildXFAObject](name, attributes) {
  55654. if (XdpNamespace.hasOwnProperty(name)) {
  55655. return XdpNamespace[name](attributes);
  55656. }
  55657. return undefined;
  55658. }
  55659. static xdp(attributes) {
  55660. return new Xdp(attributes);
  55661. }
  55662. }
  55663. exports.XdpNamespace = XdpNamespace;
  55664. /***/ }),
  55665. /* 100 */
  55666. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55667. Object.defineProperty(exports, "__esModule", ({
  55668. value: true
  55669. }));
  55670. exports.XhtmlNamespace = void 0;
  55671. var _symbol_utils = __w_pdfjs_require__(78);
  55672. var _namespaces = __w_pdfjs_require__(81);
  55673. var _html_utils = __w_pdfjs_require__(83);
  55674. var _utils = __w_pdfjs_require__(84);
  55675. var _xfa_object = __w_pdfjs_require__(87);
  55676. const XHTML_NS_ID = _namespaces.NamespaceIds.xhtml.id;
  55677. const $richText = Symbol();
  55678. const VALID_STYLES = new Set(["color", "font", "font-family", "font-size", "font-stretch", "font-style", "font-weight", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "letter-spacing", "line-height", "orphans", "page-break-after", "page-break-before", "page-break-inside", "tab-interval", "tab-stop", "text-align", "text-decoration", "text-indent", "vertical-align", "widows", "kerning-mode", "xfa-font-horizontal-scale", "xfa-font-vertical-scale", "xfa-spacerun", "xfa-tab-stops"]);
  55679. const StyleMapping = new Map([["page-break-after", "breakAfter"], ["page-break-before", "breakBefore"], ["page-break-inside", "breakInside"], ["kerning-mode", value => value === "none" ? "none" : "normal"], ["xfa-font-horizontal-scale", value => `scaleX(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`], ["xfa-font-vertical-scale", value => `scaleY(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`], ["xfa-spacerun", ""], ["xfa-tab-stops", ""], ["font-size", (value, original) => {
  55680. value = original.fontSize = (0, _utils.getMeasurement)(value);
  55681. return (0, _html_utils.measureToString)(0.99 * value);
  55682. }], ["letter-spacing", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["line-height", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-bottom", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-left", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-right", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-top", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["text-indent", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["font-family", value => value], ["vertical-align", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))]]);
  55683. const spacesRegExp = /\s+/g;
  55684. const crlfRegExp = /[\r\n]+/g;
  55685. const crlfForRichTextRegExp = /\r\n?/g;
  55686. function mapStyle(styleStr, node, richText) {
  55687. const style = Object.create(null);
  55688. if (!styleStr) {
  55689. return style;
  55690. }
  55691. const original = Object.create(null);
  55692. for (const [key, value] of styleStr.split(";").map(s => s.split(":", 2))) {
  55693. const mapping = StyleMapping.get(key);
  55694. if (mapping === "") {
  55695. continue;
  55696. }
  55697. let newValue = value;
  55698. if (mapping) {
  55699. newValue = typeof mapping === "string" ? mapping : mapping(value, original);
  55700. }
  55701. if (key.endsWith("scale")) {
  55702. style.transform = style.transform ? `${style[key]} ${newValue}` : newValue;
  55703. } else {
  55704. style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] = newValue;
  55705. }
  55706. }
  55707. if (style.fontFamily) {
  55708. (0, _html_utils.setFontFamily)({
  55709. typeface: style.fontFamily,
  55710. weight: style.fontWeight || "normal",
  55711. posture: style.fontStyle || "normal",
  55712. size: original.fontSize || 0
  55713. }, node, node[_symbol_utils.$globalData].fontFinder, style);
  55714. }
  55715. if (richText && style.verticalAlign && style.verticalAlign !== "0px" && style.fontSize) {
  55716. const SUB_SUPER_SCRIPT_FACTOR = 0.583;
  55717. const VERTICAL_FACTOR = 0.333;
  55718. const fontSize = (0, _utils.getMeasurement)(style.fontSize);
  55719. style.fontSize = (0, _html_utils.measureToString)(fontSize * SUB_SUPER_SCRIPT_FACTOR);
  55720. style.verticalAlign = (0, _html_utils.measureToString)(Math.sign((0, _utils.getMeasurement)(style.verticalAlign)) * fontSize * VERTICAL_FACTOR);
  55721. }
  55722. if (richText && style.fontSize) {
  55723. style.fontSize = `calc(${style.fontSize} * var(--scale-factor))`;
  55724. }
  55725. (0, _html_utils.fixTextIndent)(style);
  55726. return style;
  55727. }
  55728. function checkStyle(node) {
  55729. if (!node.style) {
  55730. return "";
  55731. }
  55732. return node.style.trim().split(/\s*;\s*/).filter(s => !!s).map(s => s.split(/\s*:\s*/, 2)).filter(([key, value]) => {
  55733. if (key === "font-family") {
  55734. node[_symbol_utils.$globalData].usedTypefaces.add(value);
  55735. }
  55736. return VALID_STYLES.has(key);
  55737. }).map(kv => kv.join(":")).join(";");
  55738. }
  55739. const NoWhites = new Set(["body", "html"]);
  55740. class XhtmlObject extends _xfa_object.XmlObject {
  55741. constructor(attributes, name) {
  55742. super(XHTML_NS_ID, name);
  55743. this[$richText] = false;
  55744. this.style = attributes.style || "";
  55745. }
  55746. [_symbol_utils.$clean](builder) {
  55747. super[_symbol_utils.$clean](builder);
  55748. this.style = checkStyle(this);
  55749. }
  55750. [_symbol_utils.$acceptWhitespace]() {
  55751. return !NoWhites.has(this[_symbol_utils.$nodeName]);
  55752. }
  55753. [_symbol_utils.$onText](str, richText = false) {
  55754. if (!richText) {
  55755. str = str.replaceAll(crlfRegExp, "");
  55756. if (!this.style.includes("xfa-spacerun:yes")) {
  55757. str = str.replaceAll(spacesRegExp, " ");
  55758. }
  55759. } else {
  55760. this[$richText] = true;
  55761. }
  55762. if (str) {
  55763. this[_symbol_utils.$content] += str;
  55764. }
  55765. }
  55766. [_symbol_utils.$pushGlyphs](measure, mustPop = true) {
  55767. const xfaFont = Object.create(null);
  55768. const margin = {
  55769. top: NaN,
  55770. bottom: NaN,
  55771. left: NaN,
  55772. right: NaN
  55773. };
  55774. let lineHeight = null;
  55775. for (const [key, value] of this.style.split(";").map(s => s.split(":", 2))) {
  55776. switch (key) {
  55777. case "font-family":
  55778. xfaFont.typeface = (0, _utils.stripQuotes)(value);
  55779. break;
  55780. case "font-size":
  55781. xfaFont.size = (0, _utils.getMeasurement)(value);
  55782. break;
  55783. case "font-weight":
  55784. xfaFont.weight = value;
  55785. break;
  55786. case "font-style":
  55787. xfaFont.posture = value;
  55788. break;
  55789. case "letter-spacing":
  55790. xfaFont.letterSpacing = (0, _utils.getMeasurement)(value);
  55791. break;
  55792. case "margin":
  55793. const values = value.split(/ \t/).map(x => (0, _utils.getMeasurement)(x));
  55794. switch (values.length) {
  55795. case 1:
  55796. margin.top = margin.bottom = margin.left = margin.right = values[0];
  55797. break;
  55798. case 2:
  55799. margin.top = margin.bottom = values[0];
  55800. margin.left = margin.right = values[1];
  55801. break;
  55802. case 3:
  55803. margin.top = values[0];
  55804. margin.bottom = values[2];
  55805. margin.left = margin.right = values[1];
  55806. break;
  55807. case 4:
  55808. margin.top = values[0];
  55809. margin.left = values[1];
  55810. margin.bottom = values[2];
  55811. margin.right = values[3];
  55812. break;
  55813. }
  55814. break;
  55815. case "margin-top":
  55816. margin.top = (0, _utils.getMeasurement)(value);
  55817. break;
  55818. case "margin-bottom":
  55819. margin.bottom = (0, _utils.getMeasurement)(value);
  55820. break;
  55821. case "margin-left":
  55822. margin.left = (0, _utils.getMeasurement)(value);
  55823. break;
  55824. case "margin-right":
  55825. margin.right = (0, _utils.getMeasurement)(value);
  55826. break;
  55827. case "line-height":
  55828. lineHeight = (0, _utils.getMeasurement)(value);
  55829. break;
  55830. }
  55831. }
  55832. measure.pushData(xfaFont, margin, lineHeight);
  55833. if (this[_symbol_utils.$content]) {
  55834. measure.addString(this[_symbol_utils.$content]);
  55835. } else {
  55836. for (const child of this[_symbol_utils.$getChildren]()) {
  55837. if (child[_symbol_utils.$nodeName] === "#text") {
  55838. measure.addString(child[_symbol_utils.$content]);
  55839. continue;
  55840. }
  55841. child[_symbol_utils.$pushGlyphs](measure);
  55842. }
  55843. }
  55844. if (mustPop) {
  55845. measure.popFont();
  55846. }
  55847. }
  55848. [_symbol_utils.$toHTML](availableSpace) {
  55849. const children = [];
  55850. this[_symbol_utils.$extra] = {
  55851. children
  55852. };
  55853. this[_symbol_utils.$childrenToHTML]({});
  55854. if (children.length === 0 && !this[_symbol_utils.$content]) {
  55855. return _utils.HTMLResult.EMPTY;
  55856. }
  55857. let value;
  55858. if (this[$richText]) {
  55859. value = this[_symbol_utils.$content] ? this[_symbol_utils.$content].replaceAll(crlfForRichTextRegExp, "\n") : undefined;
  55860. } else {
  55861. value = this[_symbol_utils.$content] || undefined;
  55862. }
  55863. return _utils.HTMLResult.success({
  55864. name: this[_symbol_utils.$nodeName],
  55865. attributes: {
  55866. href: this.href,
  55867. style: mapStyle(this.style, this, this[$richText])
  55868. },
  55869. children,
  55870. value
  55871. });
  55872. }
  55873. }
  55874. class A extends XhtmlObject {
  55875. constructor(attributes) {
  55876. super(attributes, "a");
  55877. this.href = (0, _html_utils.fixURL)(attributes.href) || "";
  55878. }
  55879. }
  55880. class B extends XhtmlObject {
  55881. constructor(attributes) {
  55882. super(attributes, "b");
  55883. }
  55884. [_symbol_utils.$pushGlyphs](measure) {
  55885. measure.pushFont({
  55886. weight: "bold"
  55887. });
  55888. super[_symbol_utils.$pushGlyphs](measure);
  55889. measure.popFont();
  55890. }
  55891. }
  55892. class Body extends XhtmlObject {
  55893. constructor(attributes) {
  55894. super(attributes, "body");
  55895. }
  55896. [_symbol_utils.$toHTML](availableSpace) {
  55897. const res = super[_symbol_utils.$toHTML](availableSpace);
  55898. const {
  55899. html
  55900. } = res;
  55901. if (!html) {
  55902. return _utils.HTMLResult.EMPTY;
  55903. }
  55904. html.name = "div";
  55905. html.attributes.class = ["xfaRich"];
  55906. return res;
  55907. }
  55908. }
  55909. class Br extends XhtmlObject {
  55910. constructor(attributes) {
  55911. super(attributes, "br");
  55912. }
  55913. [_symbol_utils.$text]() {
  55914. return "\n";
  55915. }
  55916. [_symbol_utils.$pushGlyphs](measure) {
  55917. measure.addString("\n");
  55918. }
  55919. [_symbol_utils.$toHTML](availableSpace) {
  55920. return _utils.HTMLResult.success({
  55921. name: "br"
  55922. });
  55923. }
  55924. }
  55925. class Html extends XhtmlObject {
  55926. constructor(attributes) {
  55927. super(attributes, "html");
  55928. }
  55929. [_symbol_utils.$toHTML](availableSpace) {
  55930. const children = [];
  55931. this[_symbol_utils.$extra] = {
  55932. children
  55933. };
  55934. this[_symbol_utils.$childrenToHTML]({});
  55935. if (children.length === 0) {
  55936. return _utils.HTMLResult.success({
  55937. name: "div",
  55938. attributes: {
  55939. class: ["xfaRich"],
  55940. style: {}
  55941. },
  55942. value: this[_symbol_utils.$content] || ""
  55943. });
  55944. }
  55945. if (children.length === 1) {
  55946. const child = children[0];
  55947. if (child.attributes?.class.includes("xfaRich")) {
  55948. return _utils.HTMLResult.success(child);
  55949. }
  55950. }
  55951. return _utils.HTMLResult.success({
  55952. name: "div",
  55953. attributes: {
  55954. class: ["xfaRich"],
  55955. style: {}
  55956. },
  55957. children
  55958. });
  55959. }
  55960. }
  55961. class I extends XhtmlObject {
  55962. constructor(attributes) {
  55963. super(attributes, "i");
  55964. }
  55965. [_symbol_utils.$pushGlyphs](measure) {
  55966. measure.pushFont({
  55967. posture: "italic"
  55968. });
  55969. super[_symbol_utils.$pushGlyphs](measure);
  55970. measure.popFont();
  55971. }
  55972. }
  55973. class Li extends XhtmlObject {
  55974. constructor(attributes) {
  55975. super(attributes, "li");
  55976. }
  55977. }
  55978. class Ol extends XhtmlObject {
  55979. constructor(attributes) {
  55980. super(attributes, "ol");
  55981. }
  55982. }
  55983. class P extends XhtmlObject {
  55984. constructor(attributes) {
  55985. super(attributes, "p");
  55986. }
  55987. [_symbol_utils.$pushGlyphs](measure) {
  55988. super[_symbol_utils.$pushGlyphs](measure, false);
  55989. measure.addString("\n");
  55990. measure.addPara();
  55991. measure.popFont();
  55992. }
  55993. [_symbol_utils.$text]() {
  55994. const siblings = this[_symbol_utils.$getParent]()[_symbol_utils.$getChildren]();
  55995. if (siblings.at(-1) === this) {
  55996. return super[_symbol_utils.$text]();
  55997. }
  55998. return super[_symbol_utils.$text]() + "\n";
  55999. }
  56000. }
  56001. class Span extends XhtmlObject {
  56002. constructor(attributes) {
  56003. super(attributes, "span");
  56004. }
  56005. }
  56006. class Sub extends XhtmlObject {
  56007. constructor(attributes) {
  56008. super(attributes, "sub");
  56009. }
  56010. }
  56011. class Sup extends XhtmlObject {
  56012. constructor(attributes) {
  56013. super(attributes, "sup");
  56014. }
  56015. }
  56016. class Ul extends XhtmlObject {
  56017. constructor(attributes) {
  56018. super(attributes, "ul");
  56019. }
  56020. }
  56021. class XhtmlNamespace {
  56022. static [_namespaces.$buildXFAObject](name, attributes) {
  56023. if (XhtmlNamespace.hasOwnProperty(name)) {
  56024. return XhtmlNamespace[name](attributes);
  56025. }
  56026. return undefined;
  56027. }
  56028. static a(attributes) {
  56029. return new A(attributes);
  56030. }
  56031. static b(attributes) {
  56032. return new B(attributes);
  56033. }
  56034. static body(attributes) {
  56035. return new Body(attributes);
  56036. }
  56037. static br(attributes) {
  56038. return new Br(attributes);
  56039. }
  56040. static html(attributes) {
  56041. return new Html(attributes);
  56042. }
  56043. static i(attributes) {
  56044. return new I(attributes);
  56045. }
  56046. static li(attributes) {
  56047. return new Li(attributes);
  56048. }
  56049. static ol(attributes) {
  56050. return new Ol(attributes);
  56051. }
  56052. static p(attributes) {
  56053. return new P(attributes);
  56054. }
  56055. static span(attributes) {
  56056. return new Span(attributes);
  56057. }
  56058. static sub(attributes) {
  56059. return new Sub(attributes);
  56060. }
  56061. static sup(attributes) {
  56062. return new Sup(attributes);
  56063. }
  56064. static ul(attributes) {
  56065. return new Ul(attributes);
  56066. }
  56067. }
  56068. exports.XhtmlNamespace = XhtmlNamespace;
  56069. /***/ }),
  56070. /* 101 */
  56071. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56072. Object.defineProperty(exports, "__esModule", ({
  56073. value: true
  56074. }));
  56075. exports.UnknownNamespace = void 0;
  56076. var _namespaces = __w_pdfjs_require__(81);
  56077. var _xfa_object = __w_pdfjs_require__(87);
  56078. class UnknownNamespace {
  56079. constructor(nsId) {
  56080. this.namespaceId = nsId;
  56081. }
  56082. [_namespaces.$buildXFAObject](name, attributes) {
  56083. return new _xfa_object.XmlObject(this.namespaceId, name, attributes);
  56084. }
  56085. }
  56086. exports.UnknownNamespace = UnknownNamespace;
  56087. /***/ }),
  56088. /* 102 */
  56089. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56090. Object.defineProperty(exports, "__esModule", ({
  56091. value: true
  56092. }));
  56093. exports.DatasetReader = void 0;
  56094. var _util = __w_pdfjs_require__(2);
  56095. var _core_utils = __w_pdfjs_require__(3);
  56096. var _xml_parser = __w_pdfjs_require__(67);
  56097. function decodeString(str) {
  56098. try {
  56099. return (0, _util.stringToUTF8String)(str);
  56100. } catch (ex) {
  56101. (0, _util.warn)(`UTF-8 decoding failed: "${ex}".`);
  56102. return str;
  56103. }
  56104. }
  56105. class DatasetXMLParser extends _xml_parser.SimpleXMLParser {
  56106. constructor(options) {
  56107. super(options);
  56108. this.node = null;
  56109. }
  56110. onEndElement(name) {
  56111. const node = super.onEndElement(name);
  56112. if (node && name === "xfa:datasets") {
  56113. this.node = node;
  56114. throw new Error("Aborting DatasetXMLParser.");
  56115. }
  56116. }
  56117. }
  56118. class DatasetReader {
  56119. constructor(data) {
  56120. if (data.datasets) {
  56121. this.node = new _xml_parser.SimpleXMLParser({
  56122. hasAttributes: true
  56123. }).parseFromString(data.datasets).documentElement;
  56124. } else {
  56125. const parser = new DatasetXMLParser({
  56126. hasAttributes: true
  56127. });
  56128. try {
  56129. parser.parseFromString(data["xdp:xdp"]);
  56130. } catch {}
  56131. this.node = parser.node;
  56132. }
  56133. }
  56134. getValue(path) {
  56135. if (!this.node || !path) {
  56136. return "";
  56137. }
  56138. const node = this.node.searchNode((0, _core_utils.parseXFAPath)(path), 0);
  56139. if (!node) {
  56140. return "";
  56141. }
  56142. const first = node.firstChild;
  56143. if (first?.nodeName === "value") {
  56144. return node.children.map(child => decodeString(child.textContent));
  56145. }
  56146. return decodeString(node.textContent);
  56147. }
  56148. }
  56149. exports.DatasetReader = DatasetReader;
  56150. /***/ }),
  56151. /* 103 */
  56152. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56153. Object.defineProperty(exports, "__esModule", ({
  56154. value: true
  56155. }));
  56156. exports.XRef = void 0;
  56157. var _util = __w_pdfjs_require__(2);
  56158. var _primitives = __w_pdfjs_require__(4);
  56159. var _parser = __w_pdfjs_require__(16);
  56160. var _core_utils = __w_pdfjs_require__(3);
  56161. var _base_stream = __w_pdfjs_require__(5);
  56162. var _crypto = __w_pdfjs_require__(68);
  56163. class XRef {
  56164. #firstXRefStmPos = null;
  56165. constructor(stream, pdfManager) {
  56166. this.stream = stream;
  56167. this.pdfManager = pdfManager;
  56168. this.entries = [];
  56169. this._xrefStms = new Set();
  56170. this._cacheMap = new Map();
  56171. this._pendingRefs = new _primitives.RefSet();
  56172. this._newPersistentRefNum = null;
  56173. this._newTemporaryRefNum = null;
  56174. }
  56175. getNewPersistentRef(obj) {
  56176. if (this._newPersistentRefNum === null) {
  56177. this._newPersistentRefNum = this.entries.length || 1;
  56178. }
  56179. const num = this._newPersistentRefNum++;
  56180. this._cacheMap.set(num, obj);
  56181. return _primitives.Ref.get(num, 0);
  56182. }
  56183. getNewTemporaryRef() {
  56184. if (this._newTemporaryRefNum === null) {
  56185. this._newTemporaryRefNum = this.entries.length || 1;
  56186. }
  56187. return _primitives.Ref.get(this._newTemporaryRefNum++, 0);
  56188. }
  56189. resetNewTemporaryRef() {
  56190. this._newTemporaryRefNum = null;
  56191. }
  56192. setStartXRef(startXRef) {
  56193. this.startXRefQueue = [startXRef];
  56194. }
  56195. parse(recoveryMode = false) {
  56196. let trailerDict;
  56197. if (!recoveryMode) {
  56198. trailerDict = this.readXRef();
  56199. } else {
  56200. (0, _util.warn)("Indexing all PDF objects");
  56201. trailerDict = this.indexObjects();
  56202. }
  56203. trailerDict.assignXref(this);
  56204. this.trailer = trailerDict;
  56205. let encrypt;
  56206. try {
  56207. encrypt = trailerDict.get("Encrypt");
  56208. } catch (ex) {
  56209. if (ex instanceof _core_utils.MissingDataException) {
  56210. throw ex;
  56211. }
  56212. (0, _util.warn)(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`);
  56213. }
  56214. if (encrypt instanceof _primitives.Dict) {
  56215. const ids = trailerDict.get("ID");
  56216. const fileId = ids?.length ? ids[0] : "";
  56217. encrypt.suppressEncryption = true;
  56218. this.encrypt = new _crypto.CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  56219. }
  56220. let root;
  56221. try {
  56222. root = trailerDict.get("Root");
  56223. } catch (ex) {
  56224. if (ex instanceof _core_utils.MissingDataException) {
  56225. throw ex;
  56226. }
  56227. (0, _util.warn)(`XRef.parse - Invalid "Root" reference: "${ex}".`);
  56228. }
  56229. if (root instanceof _primitives.Dict) {
  56230. try {
  56231. const pages = root.get("Pages");
  56232. if (pages instanceof _primitives.Dict) {
  56233. this.root = root;
  56234. return;
  56235. }
  56236. } catch (ex) {
  56237. if (ex instanceof _core_utils.MissingDataException) {
  56238. throw ex;
  56239. }
  56240. (0, _util.warn)(`XRef.parse - Invalid "Pages" reference: "${ex}".`);
  56241. }
  56242. }
  56243. if (!recoveryMode) {
  56244. throw new _core_utils.XRefParseException();
  56245. }
  56246. throw new _util.InvalidPDFException("Invalid Root reference.");
  56247. }
  56248. processXRefTable(parser) {
  56249. if (!("tableState" in this)) {
  56250. this.tableState = {
  56251. entryNum: 0,
  56252. streamPos: parser.lexer.stream.pos,
  56253. parserBuf1: parser.buf1,
  56254. parserBuf2: parser.buf2
  56255. };
  56256. }
  56257. const obj = this.readXRefTable(parser);
  56258. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  56259. throw new _util.FormatError("Invalid XRef table: could not find trailer dictionary");
  56260. }
  56261. let dict = parser.getObj();
  56262. if (!(dict instanceof _primitives.Dict) && dict.dict) {
  56263. dict = dict.dict;
  56264. }
  56265. if (!(dict instanceof _primitives.Dict)) {
  56266. throw new _util.FormatError("Invalid XRef table: could not parse trailer dictionary");
  56267. }
  56268. delete this.tableState;
  56269. return dict;
  56270. }
  56271. readXRefTable(parser) {
  56272. const stream = parser.lexer.stream;
  56273. const tableState = this.tableState;
  56274. stream.pos = tableState.streamPos;
  56275. parser.buf1 = tableState.parserBuf1;
  56276. parser.buf2 = tableState.parserBuf2;
  56277. let obj;
  56278. while (true) {
  56279. if (!("firstEntryNum" in tableState) || !("entryCount" in tableState)) {
  56280. if ((0, _primitives.isCmd)(obj = parser.getObj(), "trailer")) {
  56281. break;
  56282. }
  56283. tableState.firstEntryNum = obj;
  56284. tableState.entryCount = parser.getObj();
  56285. }
  56286. let first = tableState.firstEntryNum;
  56287. const count = tableState.entryCount;
  56288. if (!Number.isInteger(first) || !Number.isInteger(count)) {
  56289. throw new _util.FormatError("Invalid XRef table: wrong types in subsection header");
  56290. }
  56291. for (let i = tableState.entryNum; i < count; i++) {
  56292. tableState.streamPos = stream.pos;
  56293. tableState.entryNum = i;
  56294. tableState.parserBuf1 = parser.buf1;
  56295. tableState.parserBuf2 = parser.buf2;
  56296. const entry = {};
  56297. entry.offset = parser.getObj();
  56298. entry.gen = parser.getObj();
  56299. const type = parser.getObj();
  56300. if (type instanceof _primitives.Cmd) {
  56301. switch (type.cmd) {
  56302. case "f":
  56303. entry.free = true;
  56304. break;
  56305. case "n":
  56306. entry.uncompressed = true;
  56307. break;
  56308. }
  56309. }
  56310. if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
  56311. throw new _util.FormatError(`Invalid entry in XRef subsection: ${first}, ${count}`);
  56312. }
  56313. if (i === 0 && entry.free && first === 1) {
  56314. first = 0;
  56315. }
  56316. if (!this.entries[i + first]) {
  56317. this.entries[i + first] = entry;
  56318. }
  56319. }
  56320. tableState.entryNum = 0;
  56321. tableState.streamPos = stream.pos;
  56322. tableState.parserBuf1 = parser.buf1;
  56323. tableState.parserBuf2 = parser.buf2;
  56324. delete tableState.firstEntryNum;
  56325. delete tableState.entryCount;
  56326. }
  56327. if (this.entries[0] && !this.entries[0].free) {
  56328. throw new _util.FormatError("Invalid XRef table: unexpected first object");
  56329. }
  56330. return obj;
  56331. }
  56332. processXRefStream(stream) {
  56333. if (!("streamState" in this)) {
  56334. const streamParameters = stream.dict;
  56335. const byteWidths = streamParameters.get("W");
  56336. let range = streamParameters.get("Index");
  56337. if (!range) {
  56338. range = [0, streamParameters.get("Size")];
  56339. }
  56340. this.streamState = {
  56341. entryRanges: range,
  56342. byteWidths,
  56343. entryNum: 0,
  56344. streamPos: stream.pos
  56345. };
  56346. }
  56347. this.readXRefStream(stream);
  56348. delete this.streamState;
  56349. return stream.dict;
  56350. }
  56351. readXRefStream(stream) {
  56352. const streamState = this.streamState;
  56353. stream.pos = streamState.streamPos;
  56354. const [typeFieldWidth, offsetFieldWidth, generationFieldWidth] = streamState.byteWidths;
  56355. const entryRanges = streamState.entryRanges;
  56356. while (entryRanges.length > 0) {
  56357. const [first, n] = entryRanges;
  56358. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  56359. throw new _util.FormatError(`Invalid XRef range fields: ${first}, ${n}`);
  56360. }
  56361. if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
  56362. throw new _util.FormatError(`Invalid XRef entry fields length: ${first}, ${n}`);
  56363. }
  56364. for (let i = streamState.entryNum; i < n; ++i) {
  56365. streamState.entryNum = i;
  56366. streamState.streamPos = stream.pos;
  56367. let type = 0,
  56368. offset = 0,
  56369. generation = 0;
  56370. for (let j = 0; j < typeFieldWidth; ++j) {
  56371. const typeByte = stream.getByte();
  56372. if (typeByte === -1) {
  56373. throw new _util.FormatError("Invalid XRef byteWidths 'type'.");
  56374. }
  56375. type = type << 8 | typeByte;
  56376. }
  56377. if (typeFieldWidth === 0) {
  56378. type = 1;
  56379. }
  56380. for (let j = 0; j < offsetFieldWidth; ++j) {
  56381. const offsetByte = stream.getByte();
  56382. if (offsetByte === -1) {
  56383. throw new _util.FormatError("Invalid XRef byteWidths 'offset'.");
  56384. }
  56385. offset = offset << 8 | offsetByte;
  56386. }
  56387. for (let j = 0; j < generationFieldWidth; ++j) {
  56388. const generationByte = stream.getByte();
  56389. if (generationByte === -1) {
  56390. throw new _util.FormatError("Invalid XRef byteWidths 'generation'.");
  56391. }
  56392. generation = generation << 8 | generationByte;
  56393. }
  56394. const entry = {};
  56395. entry.offset = offset;
  56396. entry.gen = generation;
  56397. switch (type) {
  56398. case 0:
  56399. entry.free = true;
  56400. break;
  56401. case 1:
  56402. entry.uncompressed = true;
  56403. break;
  56404. case 2:
  56405. break;
  56406. default:
  56407. throw new _util.FormatError(`Invalid XRef entry type: ${type}`);
  56408. }
  56409. if (!this.entries[first + i]) {
  56410. this.entries[first + i] = entry;
  56411. }
  56412. }
  56413. streamState.entryNum = 0;
  56414. streamState.streamPos = stream.pos;
  56415. entryRanges.splice(0, 2);
  56416. }
  56417. }
  56418. indexObjects() {
  56419. const TAB = 0x9,
  56420. LF = 0xa,
  56421. CR = 0xd,
  56422. SPACE = 0x20;
  56423. const PERCENT = 0x25,
  56424. LT = 0x3c;
  56425. function readToken(data, offset) {
  56426. let token = "",
  56427. ch = data[offset];
  56428. while (ch !== LF && ch !== CR && ch !== LT) {
  56429. if (++offset >= data.length) {
  56430. break;
  56431. }
  56432. token += String.fromCharCode(ch);
  56433. ch = data[offset];
  56434. }
  56435. return token;
  56436. }
  56437. function skipUntil(data, offset, what) {
  56438. const length = what.length,
  56439. dataLength = data.length;
  56440. let skipped = 0;
  56441. while (offset < dataLength) {
  56442. let i = 0;
  56443. while (i < length && data[offset + i] === what[i]) {
  56444. ++i;
  56445. }
  56446. if (i >= length) {
  56447. break;
  56448. }
  56449. offset++;
  56450. skipped++;
  56451. }
  56452. return skipped;
  56453. }
  56454. const gEndobjRegExp = /\b(endobj|\d+\s+\d+\s+obj|xref|trailer\s*<<)\b/g;
  56455. const gStartxrefRegExp = /\b(startxref|\d+\s+\d+\s+obj)\b/g;
  56456. const objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  56457. const trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
  56458. const startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
  56459. const xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
  56460. this.entries.length = 0;
  56461. this._cacheMap.clear();
  56462. const stream = this.stream;
  56463. stream.pos = 0;
  56464. const buffer = stream.getBytes(),
  56465. bufferStr = (0, _util.bytesToString)(buffer),
  56466. length = buffer.length;
  56467. let position = stream.start;
  56468. const trailers = [],
  56469. xrefStms = [];
  56470. while (position < length) {
  56471. let ch = buffer[position];
  56472. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  56473. ++position;
  56474. continue;
  56475. }
  56476. if (ch === PERCENT) {
  56477. do {
  56478. ++position;
  56479. if (position >= length) {
  56480. break;
  56481. }
  56482. ch = buffer[position];
  56483. } while (ch !== LF && ch !== CR);
  56484. continue;
  56485. }
  56486. const token = readToken(buffer, position);
  56487. let m;
  56488. if (token.startsWith("xref") && (token.length === 4 || /\s/.test(token[4]))) {
  56489. position += skipUntil(buffer, position, trailerBytes);
  56490. trailers.push(position);
  56491. position += skipUntil(buffer, position, startxrefBytes);
  56492. } else if (m = objRegExp.exec(token)) {
  56493. const num = m[1] | 0,
  56494. gen = m[2] | 0;
  56495. const startPos = position + token.length;
  56496. let contentLength,
  56497. updateEntries = false;
  56498. if (!this.entries[num]) {
  56499. updateEntries = true;
  56500. } else if (this.entries[num].gen === gen) {
  56501. try {
  56502. const parser = new _parser.Parser({
  56503. lexer: new _parser.Lexer(stream.makeSubStream(startPos))
  56504. });
  56505. parser.getObj();
  56506. updateEntries = true;
  56507. } catch (ex) {
  56508. if (ex instanceof _core_utils.ParserEOFException) {
  56509. (0, _util.warn)(`indexObjects -- checking object (${token}): "${ex}".`);
  56510. } else {
  56511. updateEntries = true;
  56512. }
  56513. }
  56514. }
  56515. if (updateEntries) {
  56516. this.entries[num] = {
  56517. offset: position - stream.start,
  56518. gen,
  56519. uncompressed: true
  56520. };
  56521. }
  56522. gEndobjRegExp.lastIndex = startPos;
  56523. const match = gEndobjRegExp.exec(bufferStr);
  56524. if (match) {
  56525. const endPos = gEndobjRegExp.lastIndex + 1;
  56526. contentLength = endPos - position;
  56527. if (match[1] !== "endobj") {
  56528. (0, _util.warn)(`indexObjects: Found "${match[1]}" inside of another "obj", ` + 'caused by missing "endobj" -- trying to recover.');
  56529. contentLength -= match[1].length + 1;
  56530. }
  56531. } else {
  56532. contentLength = length - position;
  56533. }
  56534. const content = buffer.subarray(position, position + contentLength);
  56535. const xrefTagOffset = skipUntil(content, 0, xrefBytes);
  56536. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  56537. xrefStms.push(position - stream.start);
  56538. this._xrefStms.add(position - stream.start);
  56539. }
  56540. position += contentLength;
  56541. } else if (token.startsWith("trailer") && (token.length === 7 || /\s/.test(token[7]))) {
  56542. trailers.push(position);
  56543. const startPos = position + token.length;
  56544. let contentLength;
  56545. gStartxrefRegExp.lastIndex = startPos;
  56546. const match = gStartxrefRegExp.exec(bufferStr);
  56547. if (match) {
  56548. const endPos = gStartxrefRegExp.lastIndex + 1;
  56549. contentLength = endPos - position;
  56550. if (match[1] !== "startxref") {
  56551. (0, _util.warn)(`indexObjects: Found "${match[1]}" after "trailer", ` + 'caused by missing "startxref" -- trying to recover.');
  56552. contentLength -= match[1].length + 1;
  56553. }
  56554. } else {
  56555. contentLength = length - position;
  56556. }
  56557. position += contentLength;
  56558. } else {
  56559. position += token.length + 1;
  56560. }
  56561. }
  56562. for (const xrefStm of xrefStms) {
  56563. this.startXRefQueue.push(xrefStm);
  56564. this.readXRef(true);
  56565. }
  56566. const trailerDicts = [];
  56567. let isEncrypted = false;
  56568. for (const trailer of trailers) {
  56569. stream.pos = trailer;
  56570. const parser = new _parser.Parser({
  56571. lexer: new _parser.Lexer(stream),
  56572. xref: this,
  56573. allowStreams: true,
  56574. recoveryMode: true
  56575. });
  56576. const obj = parser.getObj();
  56577. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  56578. continue;
  56579. }
  56580. const dict = parser.getObj();
  56581. if (!(dict instanceof _primitives.Dict)) {
  56582. continue;
  56583. }
  56584. trailerDicts.push(dict);
  56585. if (dict.has("Encrypt")) {
  56586. isEncrypted = true;
  56587. }
  56588. }
  56589. let trailerDict, trailerError;
  56590. for (const dict of [...trailerDicts, "genFallback", ...trailerDicts]) {
  56591. if (dict === "genFallback") {
  56592. if (!trailerError) {
  56593. break;
  56594. }
  56595. this._generationFallback = true;
  56596. continue;
  56597. }
  56598. let validPagesDict = false;
  56599. try {
  56600. const rootDict = dict.get("Root");
  56601. if (!(rootDict instanceof _primitives.Dict)) {
  56602. continue;
  56603. }
  56604. const pagesDict = rootDict.get("Pages");
  56605. if (!(pagesDict instanceof _primitives.Dict)) {
  56606. continue;
  56607. }
  56608. const pagesCount = pagesDict.get("Count");
  56609. if (Number.isInteger(pagesCount)) {
  56610. validPagesDict = true;
  56611. }
  56612. } catch (ex) {
  56613. trailerError = ex;
  56614. continue;
  56615. }
  56616. if (validPagesDict && (!isEncrypted || dict.has("Encrypt")) && dict.has("ID")) {
  56617. return dict;
  56618. }
  56619. trailerDict = dict;
  56620. }
  56621. if (trailerDict) {
  56622. return trailerDict;
  56623. }
  56624. if (this.topDict) {
  56625. return this.topDict;
  56626. }
  56627. throw new _util.InvalidPDFException("Invalid PDF structure.");
  56628. }
  56629. readXRef(recoveryMode = false) {
  56630. const stream = this.stream;
  56631. const startXRefParsedCache = new Set();
  56632. while (this.startXRefQueue.length) {
  56633. try {
  56634. const startXRef = this.startXRefQueue[0];
  56635. if (startXRefParsedCache.has(startXRef)) {
  56636. (0, _util.warn)("readXRef - skipping XRef table since it was already parsed.");
  56637. this.startXRefQueue.shift();
  56638. continue;
  56639. }
  56640. startXRefParsedCache.add(startXRef);
  56641. stream.pos = startXRef + stream.start;
  56642. const parser = new _parser.Parser({
  56643. lexer: new _parser.Lexer(stream),
  56644. xref: this,
  56645. allowStreams: true
  56646. });
  56647. let obj = parser.getObj();
  56648. let dict;
  56649. if ((0, _primitives.isCmd)(obj, "xref")) {
  56650. dict = this.processXRefTable(parser);
  56651. if (!this.topDict) {
  56652. this.topDict = dict;
  56653. }
  56654. obj = dict.get("XRefStm");
  56655. if (Number.isInteger(obj) && !this._xrefStms.has(obj)) {
  56656. this._xrefStms.add(obj);
  56657. this.startXRefQueue.push(obj);
  56658. this.#firstXRefStmPos ??= obj;
  56659. }
  56660. } else if (Number.isInteger(obj)) {
  56661. if (!Number.isInteger(parser.getObj()) || !(0, _primitives.isCmd)(parser.getObj(), "obj") || !((obj = parser.getObj()) instanceof _base_stream.BaseStream)) {
  56662. throw new _util.FormatError("Invalid XRef stream");
  56663. }
  56664. dict = this.processXRefStream(obj);
  56665. if (!this.topDict) {
  56666. this.topDict = dict;
  56667. }
  56668. if (!dict) {
  56669. throw new _util.FormatError("Failed to read XRef stream");
  56670. }
  56671. } else {
  56672. throw new _util.FormatError("Invalid XRef stream header");
  56673. }
  56674. obj = dict.get("Prev");
  56675. if (Number.isInteger(obj)) {
  56676. this.startXRefQueue.push(obj);
  56677. } else if (obj instanceof _primitives.Ref) {
  56678. this.startXRefQueue.push(obj.num);
  56679. }
  56680. } catch (e) {
  56681. if (e instanceof _core_utils.MissingDataException) {
  56682. throw e;
  56683. }
  56684. (0, _util.info)("(while reading XRef): " + e);
  56685. }
  56686. this.startXRefQueue.shift();
  56687. }
  56688. if (this.topDict) {
  56689. return this.topDict;
  56690. }
  56691. if (recoveryMode) {
  56692. return undefined;
  56693. }
  56694. throw new _core_utils.XRefParseException();
  56695. }
  56696. get lastXRefStreamPos() {
  56697. return this.#firstXRefStmPos ?? (this._xrefStms.size > 0 ? Math.max(...this._xrefStms) : null);
  56698. }
  56699. getEntry(i) {
  56700. const xrefEntry = this.entries[i];
  56701. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  56702. return xrefEntry;
  56703. }
  56704. return null;
  56705. }
  56706. fetchIfRef(obj, suppressEncryption = false) {
  56707. if (obj instanceof _primitives.Ref) {
  56708. return this.fetch(obj, suppressEncryption);
  56709. }
  56710. return obj;
  56711. }
  56712. fetch(ref, suppressEncryption = false) {
  56713. if (!(ref instanceof _primitives.Ref)) {
  56714. throw new Error("ref object is not a reference");
  56715. }
  56716. const num = ref.num;
  56717. const cacheEntry = this._cacheMap.get(num);
  56718. if (cacheEntry !== undefined) {
  56719. if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
  56720. cacheEntry.objId = ref.toString();
  56721. }
  56722. return cacheEntry;
  56723. }
  56724. let xrefEntry = this.getEntry(num);
  56725. if (xrefEntry === null) {
  56726. this._cacheMap.set(num, xrefEntry);
  56727. return xrefEntry;
  56728. }
  56729. if (this._pendingRefs.has(ref)) {
  56730. this._pendingRefs.remove(ref);
  56731. (0, _util.warn)(`Ignoring circular reference: ${ref}.`);
  56732. return _primitives.CIRCULAR_REF;
  56733. }
  56734. this._pendingRefs.put(ref);
  56735. try {
  56736. xrefEntry = xrefEntry.uncompressed ? this.fetchUncompressed(ref, xrefEntry, suppressEncryption) : this.fetchCompressed(ref, xrefEntry, suppressEncryption);
  56737. this._pendingRefs.remove(ref);
  56738. } catch (ex) {
  56739. this._pendingRefs.remove(ref);
  56740. throw ex;
  56741. }
  56742. if (xrefEntry instanceof _primitives.Dict) {
  56743. xrefEntry.objId = ref.toString();
  56744. } else if (xrefEntry instanceof _base_stream.BaseStream) {
  56745. xrefEntry.dict.objId = ref.toString();
  56746. }
  56747. return xrefEntry;
  56748. }
  56749. fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
  56750. const gen = ref.gen;
  56751. let num = ref.num;
  56752. if (xrefEntry.gen !== gen) {
  56753. const msg = `Inconsistent generation in XRef: ${ref}`;
  56754. if (this._generationFallback && xrefEntry.gen < gen) {
  56755. (0, _util.warn)(msg);
  56756. return this.fetchUncompressed(_primitives.Ref.get(num, xrefEntry.gen), xrefEntry, suppressEncryption);
  56757. }
  56758. throw new _core_utils.XRefEntryException(msg);
  56759. }
  56760. const stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  56761. const parser = new _parser.Parser({
  56762. lexer: new _parser.Lexer(stream),
  56763. xref: this,
  56764. allowStreams: true
  56765. });
  56766. const obj1 = parser.getObj();
  56767. const obj2 = parser.getObj();
  56768. const obj3 = parser.getObj();
  56769. if (obj1 !== num || obj2 !== gen || !(obj3 instanceof _primitives.Cmd)) {
  56770. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  56771. }
  56772. if (obj3.cmd !== "obj") {
  56773. if (obj3.cmd.startsWith("obj")) {
  56774. num = parseInt(obj3.cmd.substring(3), 10);
  56775. if (!Number.isNaN(num)) {
  56776. return num;
  56777. }
  56778. }
  56779. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  56780. }
  56781. xrefEntry = this.encrypt && !suppressEncryption ? parser.getObj(this.encrypt.createCipherTransform(num, gen)) : parser.getObj();
  56782. if (!(xrefEntry instanceof _base_stream.BaseStream)) {
  56783. this._cacheMap.set(num, xrefEntry);
  56784. }
  56785. return xrefEntry;
  56786. }
  56787. fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
  56788. const tableOffset = xrefEntry.offset;
  56789. const stream = this.fetch(_primitives.Ref.get(tableOffset, 0));
  56790. if (!(stream instanceof _base_stream.BaseStream)) {
  56791. throw new _util.FormatError("bad ObjStm stream");
  56792. }
  56793. const first = stream.dict.get("First");
  56794. const n = stream.dict.get("N");
  56795. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  56796. throw new _util.FormatError("invalid first and n parameters for ObjStm stream");
  56797. }
  56798. let parser = new _parser.Parser({
  56799. lexer: new _parser.Lexer(stream),
  56800. xref: this,
  56801. allowStreams: true
  56802. });
  56803. const nums = new Array(n);
  56804. const offsets = new Array(n);
  56805. for (let i = 0; i < n; ++i) {
  56806. const num = parser.getObj();
  56807. if (!Number.isInteger(num)) {
  56808. throw new _util.FormatError(`invalid object number in the ObjStm stream: ${num}`);
  56809. }
  56810. const offset = parser.getObj();
  56811. if (!Number.isInteger(offset)) {
  56812. throw new _util.FormatError(`invalid object offset in the ObjStm stream: ${offset}`);
  56813. }
  56814. nums[i] = num;
  56815. offsets[i] = offset;
  56816. }
  56817. const start = (stream.start || 0) + first;
  56818. const entries = new Array(n);
  56819. for (let i = 0; i < n; ++i) {
  56820. const length = i < n - 1 ? offsets[i + 1] - offsets[i] : undefined;
  56821. if (length < 0) {
  56822. throw new _util.FormatError("Invalid offset in the ObjStm stream.");
  56823. }
  56824. parser = new _parser.Parser({
  56825. lexer: new _parser.Lexer(stream.makeSubStream(start + offsets[i], length, stream.dict)),
  56826. xref: this,
  56827. allowStreams: true
  56828. });
  56829. const obj = parser.getObj();
  56830. entries[i] = obj;
  56831. if (obj instanceof _base_stream.BaseStream) {
  56832. continue;
  56833. }
  56834. const num = nums[i],
  56835. entry = this.entries[num];
  56836. if (entry && entry.offset === tableOffset && entry.gen === i) {
  56837. this._cacheMap.set(num, obj);
  56838. }
  56839. }
  56840. xrefEntry = entries[xrefEntry.gen];
  56841. if (xrefEntry === undefined) {
  56842. throw new _core_utils.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
  56843. }
  56844. return xrefEntry;
  56845. }
  56846. async fetchIfRefAsync(obj, suppressEncryption) {
  56847. if (obj instanceof _primitives.Ref) {
  56848. return this.fetchAsync(obj, suppressEncryption);
  56849. }
  56850. return obj;
  56851. }
  56852. async fetchAsync(ref, suppressEncryption) {
  56853. try {
  56854. return this.fetch(ref, suppressEncryption);
  56855. } catch (ex) {
  56856. if (!(ex instanceof _core_utils.MissingDataException)) {
  56857. throw ex;
  56858. }
  56859. await this.pdfManager.requestRange(ex.begin, ex.end);
  56860. return this.fetchAsync(ref, suppressEncryption);
  56861. }
  56862. }
  56863. getCatalogObj() {
  56864. return this.root;
  56865. }
  56866. }
  56867. exports.XRef = XRef;
  56868. /***/ }),
  56869. /* 104 */
  56870. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56871. Object.defineProperty(exports, "__esModule", ({
  56872. value: true
  56873. }));
  56874. exports.MessageHandler = void 0;
  56875. var _util = __w_pdfjs_require__(2);
  56876. const CallbackKind = {
  56877. UNKNOWN: 0,
  56878. DATA: 1,
  56879. ERROR: 2
  56880. };
  56881. const StreamKind = {
  56882. UNKNOWN: 0,
  56883. CANCEL: 1,
  56884. CANCEL_COMPLETE: 2,
  56885. CLOSE: 3,
  56886. ENQUEUE: 4,
  56887. ERROR: 5,
  56888. PULL: 6,
  56889. PULL_COMPLETE: 7,
  56890. START_COMPLETE: 8
  56891. };
  56892. function wrapReason(reason) {
  56893. if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
  56894. (0, _util.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
  56895. }
  56896. switch (reason.name) {
  56897. case "AbortException":
  56898. return new _util.AbortException(reason.message);
  56899. case "MissingPDFException":
  56900. return new _util.MissingPDFException(reason.message);
  56901. case "PasswordException":
  56902. return new _util.PasswordException(reason.message, reason.code);
  56903. case "UnexpectedResponseException":
  56904. return new _util.UnexpectedResponseException(reason.message, reason.status);
  56905. case "UnknownErrorException":
  56906. return new _util.UnknownErrorException(reason.message, reason.details);
  56907. default:
  56908. return new _util.UnknownErrorException(reason.message, reason.toString());
  56909. }
  56910. }
  56911. class MessageHandler {
  56912. constructor(sourceName, targetName, comObj) {
  56913. this.sourceName = sourceName;
  56914. this.targetName = targetName;
  56915. this.comObj = comObj;
  56916. this.callbackId = 1;
  56917. this.streamId = 1;
  56918. this.streamSinks = Object.create(null);
  56919. this.streamControllers = Object.create(null);
  56920. this.callbackCapabilities = Object.create(null);
  56921. this.actionHandler = Object.create(null);
  56922. this._onComObjOnMessage = event => {
  56923. const data = event.data;
  56924. if (data.targetName !== this.sourceName) {
  56925. return;
  56926. }
  56927. if (data.stream) {
  56928. this.#processStreamMessage(data);
  56929. return;
  56930. }
  56931. if (data.callback) {
  56932. const callbackId = data.callbackId;
  56933. const capability = this.callbackCapabilities[callbackId];
  56934. if (!capability) {
  56935. throw new Error(`Cannot resolve callback ${callbackId}`);
  56936. }
  56937. delete this.callbackCapabilities[callbackId];
  56938. if (data.callback === CallbackKind.DATA) {
  56939. capability.resolve(data.data);
  56940. } else if (data.callback === CallbackKind.ERROR) {
  56941. capability.reject(wrapReason(data.reason));
  56942. } else {
  56943. throw new Error("Unexpected callback case");
  56944. }
  56945. return;
  56946. }
  56947. const action = this.actionHandler[data.action];
  56948. if (!action) {
  56949. throw new Error(`Unknown action from worker: ${data.action}`);
  56950. }
  56951. if (data.callbackId) {
  56952. const cbSourceName = this.sourceName;
  56953. const cbTargetName = data.sourceName;
  56954. new Promise(function (resolve) {
  56955. resolve(action(data.data));
  56956. }).then(function (result) {
  56957. comObj.postMessage({
  56958. sourceName: cbSourceName,
  56959. targetName: cbTargetName,
  56960. callback: CallbackKind.DATA,
  56961. callbackId: data.callbackId,
  56962. data: result
  56963. });
  56964. }, function (reason) {
  56965. comObj.postMessage({
  56966. sourceName: cbSourceName,
  56967. targetName: cbTargetName,
  56968. callback: CallbackKind.ERROR,
  56969. callbackId: data.callbackId,
  56970. reason: wrapReason(reason)
  56971. });
  56972. });
  56973. return;
  56974. }
  56975. if (data.streamId) {
  56976. this.#createStreamSink(data);
  56977. return;
  56978. }
  56979. action(data.data);
  56980. };
  56981. comObj.addEventListener("message", this._onComObjOnMessage);
  56982. }
  56983. on(actionName, handler) {
  56984. const ah = this.actionHandler;
  56985. if (ah[actionName]) {
  56986. throw new Error(`There is already an actionName called "${actionName}"`);
  56987. }
  56988. ah[actionName] = handler;
  56989. }
  56990. send(actionName, data, transfers) {
  56991. this.comObj.postMessage({
  56992. sourceName: this.sourceName,
  56993. targetName: this.targetName,
  56994. action: actionName,
  56995. data
  56996. }, transfers);
  56997. }
  56998. sendWithPromise(actionName, data, transfers) {
  56999. const callbackId = this.callbackId++;
  57000. const capability = new _util.PromiseCapability();
  57001. this.callbackCapabilities[callbackId] = capability;
  57002. try {
  57003. this.comObj.postMessage({
  57004. sourceName: this.sourceName,
  57005. targetName: this.targetName,
  57006. action: actionName,
  57007. callbackId,
  57008. data
  57009. }, transfers);
  57010. } catch (ex) {
  57011. capability.reject(ex);
  57012. }
  57013. return capability.promise;
  57014. }
  57015. sendWithStream(actionName, data, queueingStrategy, transfers) {
  57016. const streamId = this.streamId++,
  57017. sourceName = this.sourceName,
  57018. targetName = this.targetName,
  57019. comObj = this.comObj;
  57020. return new ReadableStream({
  57021. start: controller => {
  57022. const startCapability = new _util.PromiseCapability();
  57023. this.streamControllers[streamId] = {
  57024. controller,
  57025. startCall: startCapability,
  57026. pullCall: null,
  57027. cancelCall: null,
  57028. isClosed: false
  57029. };
  57030. comObj.postMessage({
  57031. sourceName,
  57032. targetName,
  57033. action: actionName,
  57034. streamId,
  57035. data,
  57036. desiredSize: controller.desiredSize
  57037. }, transfers);
  57038. return startCapability.promise;
  57039. },
  57040. pull: controller => {
  57041. const pullCapability = new _util.PromiseCapability();
  57042. this.streamControllers[streamId].pullCall = pullCapability;
  57043. comObj.postMessage({
  57044. sourceName,
  57045. targetName,
  57046. stream: StreamKind.PULL,
  57047. streamId,
  57048. desiredSize: controller.desiredSize
  57049. });
  57050. return pullCapability.promise;
  57051. },
  57052. cancel: reason => {
  57053. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  57054. const cancelCapability = new _util.PromiseCapability();
  57055. this.streamControllers[streamId].cancelCall = cancelCapability;
  57056. this.streamControllers[streamId].isClosed = true;
  57057. comObj.postMessage({
  57058. sourceName,
  57059. targetName,
  57060. stream: StreamKind.CANCEL,
  57061. streamId,
  57062. reason: wrapReason(reason)
  57063. });
  57064. return cancelCapability.promise;
  57065. }
  57066. }, queueingStrategy);
  57067. }
  57068. #createStreamSink(data) {
  57069. const streamId = data.streamId,
  57070. sourceName = this.sourceName,
  57071. targetName = data.sourceName,
  57072. comObj = this.comObj;
  57073. const self = this,
  57074. action = this.actionHandler[data.action];
  57075. const streamSink = {
  57076. enqueue(chunk, size = 1, transfers) {
  57077. if (this.isCancelled) {
  57078. return;
  57079. }
  57080. const lastDesiredSize = this.desiredSize;
  57081. this.desiredSize -= size;
  57082. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  57083. this.sinkCapability = new _util.PromiseCapability();
  57084. this.ready = this.sinkCapability.promise;
  57085. }
  57086. comObj.postMessage({
  57087. sourceName,
  57088. targetName,
  57089. stream: StreamKind.ENQUEUE,
  57090. streamId,
  57091. chunk
  57092. }, transfers);
  57093. },
  57094. close() {
  57095. if (this.isCancelled) {
  57096. return;
  57097. }
  57098. this.isCancelled = true;
  57099. comObj.postMessage({
  57100. sourceName,
  57101. targetName,
  57102. stream: StreamKind.CLOSE,
  57103. streamId
  57104. });
  57105. delete self.streamSinks[streamId];
  57106. },
  57107. error(reason) {
  57108. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  57109. if (this.isCancelled) {
  57110. return;
  57111. }
  57112. this.isCancelled = true;
  57113. comObj.postMessage({
  57114. sourceName,
  57115. targetName,
  57116. stream: StreamKind.ERROR,
  57117. streamId,
  57118. reason: wrapReason(reason)
  57119. });
  57120. },
  57121. sinkCapability: new _util.PromiseCapability(),
  57122. onPull: null,
  57123. onCancel: null,
  57124. isCancelled: false,
  57125. desiredSize: data.desiredSize,
  57126. ready: null
  57127. };
  57128. streamSink.sinkCapability.resolve();
  57129. streamSink.ready = streamSink.sinkCapability.promise;
  57130. this.streamSinks[streamId] = streamSink;
  57131. new Promise(function (resolve) {
  57132. resolve(action(data.data, streamSink));
  57133. }).then(function () {
  57134. comObj.postMessage({
  57135. sourceName,
  57136. targetName,
  57137. stream: StreamKind.START_COMPLETE,
  57138. streamId,
  57139. success: true
  57140. });
  57141. }, function (reason) {
  57142. comObj.postMessage({
  57143. sourceName,
  57144. targetName,
  57145. stream: StreamKind.START_COMPLETE,
  57146. streamId,
  57147. reason: wrapReason(reason)
  57148. });
  57149. });
  57150. }
  57151. #processStreamMessage(data) {
  57152. const streamId = data.streamId,
  57153. sourceName = this.sourceName,
  57154. targetName = data.sourceName,
  57155. comObj = this.comObj;
  57156. const streamController = this.streamControllers[streamId],
  57157. streamSink = this.streamSinks[streamId];
  57158. switch (data.stream) {
  57159. case StreamKind.START_COMPLETE:
  57160. if (data.success) {
  57161. streamController.startCall.resolve();
  57162. } else {
  57163. streamController.startCall.reject(wrapReason(data.reason));
  57164. }
  57165. break;
  57166. case StreamKind.PULL_COMPLETE:
  57167. if (data.success) {
  57168. streamController.pullCall.resolve();
  57169. } else {
  57170. streamController.pullCall.reject(wrapReason(data.reason));
  57171. }
  57172. break;
  57173. case StreamKind.PULL:
  57174. if (!streamSink) {
  57175. comObj.postMessage({
  57176. sourceName,
  57177. targetName,
  57178. stream: StreamKind.PULL_COMPLETE,
  57179. streamId,
  57180. success: true
  57181. });
  57182. break;
  57183. }
  57184. if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
  57185. streamSink.sinkCapability.resolve();
  57186. }
  57187. streamSink.desiredSize = data.desiredSize;
  57188. new Promise(function (resolve) {
  57189. resolve(streamSink.onPull?.());
  57190. }).then(function () {
  57191. comObj.postMessage({
  57192. sourceName,
  57193. targetName,
  57194. stream: StreamKind.PULL_COMPLETE,
  57195. streamId,
  57196. success: true
  57197. });
  57198. }, function (reason) {
  57199. comObj.postMessage({
  57200. sourceName,
  57201. targetName,
  57202. stream: StreamKind.PULL_COMPLETE,
  57203. streamId,
  57204. reason: wrapReason(reason)
  57205. });
  57206. });
  57207. break;
  57208. case StreamKind.ENQUEUE:
  57209. (0, _util.assert)(streamController, "enqueue should have stream controller");
  57210. if (streamController.isClosed) {
  57211. break;
  57212. }
  57213. streamController.controller.enqueue(data.chunk);
  57214. break;
  57215. case StreamKind.CLOSE:
  57216. (0, _util.assert)(streamController, "close should have stream controller");
  57217. if (streamController.isClosed) {
  57218. break;
  57219. }
  57220. streamController.isClosed = true;
  57221. streamController.controller.close();
  57222. this.#deleteStreamController(streamController, streamId);
  57223. break;
  57224. case StreamKind.ERROR:
  57225. (0, _util.assert)(streamController, "error should have stream controller");
  57226. streamController.controller.error(wrapReason(data.reason));
  57227. this.#deleteStreamController(streamController, streamId);
  57228. break;
  57229. case StreamKind.CANCEL_COMPLETE:
  57230. if (data.success) {
  57231. streamController.cancelCall.resolve();
  57232. } else {
  57233. streamController.cancelCall.reject(wrapReason(data.reason));
  57234. }
  57235. this.#deleteStreamController(streamController, streamId);
  57236. break;
  57237. case StreamKind.CANCEL:
  57238. if (!streamSink) {
  57239. break;
  57240. }
  57241. new Promise(function (resolve) {
  57242. resolve(streamSink.onCancel?.(wrapReason(data.reason)));
  57243. }).then(function () {
  57244. comObj.postMessage({
  57245. sourceName,
  57246. targetName,
  57247. stream: StreamKind.CANCEL_COMPLETE,
  57248. streamId,
  57249. success: true
  57250. });
  57251. }, function (reason) {
  57252. comObj.postMessage({
  57253. sourceName,
  57254. targetName,
  57255. stream: StreamKind.CANCEL_COMPLETE,
  57256. streamId,
  57257. reason: wrapReason(reason)
  57258. });
  57259. });
  57260. streamSink.sinkCapability.reject(wrapReason(data.reason));
  57261. streamSink.isCancelled = true;
  57262. delete this.streamSinks[streamId];
  57263. break;
  57264. default:
  57265. throw new Error("Unexpected stream case");
  57266. }
  57267. }
  57268. async #deleteStreamController(streamController, streamId) {
  57269. await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
  57270. delete this.streamControllers[streamId];
  57271. }
  57272. destroy() {
  57273. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  57274. }
  57275. }
  57276. exports.MessageHandler = MessageHandler;
  57277. /***/ }),
  57278. /* 105 */
  57279. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  57280. Object.defineProperty(exports, "__esModule", ({
  57281. value: true
  57282. }));
  57283. exports.PDFWorkerStream = void 0;
  57284. var _util = __w_pdfjs_require__(2);
  57285. class PDFWorkerStream {
  57286. constructor(msgHandler) {
  57287. this._msgHandler = msgHandler;
  57288. this._contentLength = null;
  57289. this._fullRequestReader = null;
  57290. this._rangeRequestReaders = [];
  57291. }
  57292. getFullReader() {
  57293. (0, _util.assert)(!this._fullRequestReader, "PDFWorkerStream.getFullReader can only be called once.");
  57294. this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
  57295. return this._fullRequestReader;
  57296. }
  57297. getRangeReader(begin, end) {
  57298. const reader = new PDFWorkerStreamRangeReader(begin, end, this._msgHandler);
  57299. this._rangeRequestReaders.push(reader);
  57300. return reader;
  57301. }
  57302. cancelAllRequests(reason) {
  57303. this._fullRequestReader?.cancel(reason);
  57304. for (const reader of this._rangeRequestReaders.slice(0)) {
  57305. reader.cancel(reason);
  57306. }
  57307. }
  57308. }
  57309. exports.PDFWorkerStream = PDFWorkerStream;
  57310. class PDFWorkerStreamReader {
  57311. constructor(msgHandler) {
  57312. this._msgHandler = msgHandler;
  57313. this.onProgress = null;
  57314. this._contentLength = null;
  57315. this._isRangeSupported = false;
  57316. this._isStreamingSupported = false;
  57317. const readableStream = this._msgHandler.sendWithStream("GetReader");
  57318. this._reader = readableStream.getReader();
  57319. this._headersReady = this._msgHandler.sendWithPromise("ReaderHeadersReady").then(data => {
  57320. this._isStreamingSupported = data.isStreamingSupported;
  57321. this._isRangeSupported = data.isRangeSupported;
  57322. this._contentLength = data.contentLength;
  57323. });
  57324. }
  57325. get headersReady() {
  57326. return this._headersReady;
  57327. }
  57328. get contentLength() {
  57329. return this._contentLength;
  57330. }
  57331. get isStreamingSupported() {
  57332. return this._isStreamingSupported;
  57333. }
  57334. get isRangeSupported() {
  57335. return this._isRangeSupported;
  57336. }
  57337. async read() {
  57338. const {
  57339. value,
  57340. done
  57341. } = await this._reader.read();
  57342. if (done) {
  57343. return {
  57344. value: undefined,
  57345. done: true
  57346. };
  57347. }
  57348. return {
  57349. value: value.buffer,
  57350. done: false
  57351. };
  57352. }
  57353. cancel(reason) {
  57354. this._reader.cancel(reason);
  57355. }
  57356. }
  57357. class PDFWorkerStreamRangeReader {
  57358. constructor(begin, end, msgHandler) {
  57359. this._msgHandler = msgHandler;
  57360. this.onProgress = null;
  57361. const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
  57362. begin,
  57363. end
  57364. });
  57365. this._reader = readableStream.getReader();
  57366. }
  57367. get isStreamingSupported() {
  57368. return false;
  57369. }
  57370. async read() {
  57371. const {
  57372. value,
  57373. done
  57374. } = await this._reader.read();
  57375. if (done) {
  57376. return {
  57377. value: undefined,
  57378. done: true
  57379. };
  57380. }
  57381. return {
  57382. value: value.buffer,
  57383. done: false
  57384. };
  57385. }
  57386. cancel(reason) {
  57387. this._reader.cancel(reason);
  57388. }
  57389. }
  57390. /***/ })
  57391. /******/ ]);
  57392. /************************************************************************/
  57393. /******/ // The module cache
  57394. /******/ var __webpack_module_cache__ = {};
  57395. /******/
  57396. /******/ // The require function
  57397. /******/ function __w_pdfjs_require__(moduleId) {
  57398. /******/ // Check if module is in cache
  57399. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  57400. /******/ if (cachedModule !== undefined) {
  57401. /******/ return cachedModule.exports;
  57402. /******/ }
  57403. /******/ // Create a new module (and put it into the cache)
  57404. /******/ var module = __webpack_module_cache__[moduleId] = {
  57405. /******/ // no module.id needed
  57406. /******/ // no module.loaded needed
  57407. /******/ exports: {}
  57408. /******/ };
  57409. /******/
  57410. /******/ // Execute the module function
  57411. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  57412. /******/
  57413. /******/ // Return the exports of the module
  57414. /******/ return module.exports;
  57415. /******/ }
  57416. /******/
  57417. /************************************************************************/
  57418. var __webpack_exports__ = {};
  57419. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  57420. (() => {
  57421. var exports = __webpack_exports__;
  57422. Object.defineProperty(exports, "__esModule", ({
  57423. value: true
  57424. }));
  57425. Object.defineProperty(exports, "WorkerMessageHandler", ({
  57426. enumerable: true,
  57427. get: function () {
  57428. return _worker.WorkerMessageHandler;
  57429. }
  57430. }));
  57431. var _worker = __w_pdfjs_require__(1);
  57432. const pdfjsVersion = '3.10.111';
  57433. const pdfjsBuild = 'e142baecb';
  57434. })();
  57435. /******/ return __webpack_exports__;
  57436. /******/ })()
  57437. ;
  57438. });
  57439. //# sourceMappingURL=pdf.worker.js.map